> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/clore.ai/clore.ai-eng-hi/developers/cli-sdk.md).

# CLI और SDK गाइड

## अवलोकन

Clore.ai एक प्रदान करता है **REST API** जो GPU मार्केटप्लेस तक पूर्ण प्रोग्रामेटिक पहुँच सक्षम करता है — सर्वर सूचीबद्ध करना, ऑर्डर बनाना, डिप्लॉयमेंट्स की निगरानी करना, और किराये रद्द करना।

> **नोट:** फिलहाल कोई आधिकारिक CLI बाइनरी नहीं है। सभी ऑटोमेशन सीधे REST API के माध्यम से, जैसे `curl`, Python, या Node.js के साथ।

**आधार URL:** `https://api.clore.ai/v1`

**प्रतिक्रिया प्रारूप:** JSON। प्रत्येक प्रतिक्रिया में एक `code` फ़ील्ड होता है जो स्थिति दर्शाता है।

***

## प्रमाणीकरण

अपना API key यहाँ से जनरेट करें [Clore.ai डैशबोर्ड](https://clore.ai):

1. अपने खाते में लॉग इन करें
2. नेविगेट करें **API** सेटिंग्स में अनुभाग
3. अपना API key जनरेट और कॉपी करें

**हेडर प्रारूप:**

```
auth: YOUR_API_KEY
```

> ⚠️ **महत्वपूर्ण:** auth हेडर है `auth`, **नहीं** `Authorization: Bearer`. गलत प्रारूप का उपयोग करने पर code लौटेगा `3` (अमान्य API टोकन)।

**उदाहरण:**

```bash
curl -H 'auth: YOUR_API_KEY' 'https://api.clore.ai/v1/marketplace'
```

***

## त्वरित शुरुआत

### मार्केटप्लेस सर्वर सूचीबद्ध करें

सभी उपलब्ध GPU सर्वरों को ब्राउज़ करें:

```bash
curl -XGET \\
  -H 'auth: YOUR_API_KEY' \\
  'https://api.clore.ai/v1/marketplace'
```

**प्रतिक्रिया:**

```json
{
  "servers": [
    {
      "id": 6,
      "owner": 4,
      "mrl": 73,
      "price": {
        "on_demand": { "bitcoin": 0.00001 },
        "spot": { "bitcoin": 0.000001 }
      },
      "rented": false,
      "specs": {
        "cpu": "Intel Core i9-11900",
        "ram": 62.67,
        "gpu": "1x NVIDIA GeForce GTX 1080 Ti",
        "gpuram": 11,
        "net": { "up": 26.38, "down": 118.42, "cc": "CZ" }
      }
    }
  ],
  "my_servers": [1, 2, 4],
  "code": 0
}
```

***

### अपने ऑर्डर प्राप्त करें

```bash
curl -XGET \\
  -H 'auth: YOUR_API_KEY' \\
  'https://api.clore.ai/v1/my_orders'
```

पूर्ण/समाप्त ऑर्डर शामिल करें:

```bash
curl -XGET \\
  -H 'auth: YOUR_API_KEY' \\
  'https://api.clore.ai/v1/my_orders?return_completed=true'
```

***

### ऑर्डर बनाएं (ऑन-डिमांड)

```bash
curl -XPOST \\
  -H 'auth: YOUR_API_KEY' \\
  -H 'Content-type: application/json' \\
  -d '{
    "currency": "bitcoin",
    "image": "cloreai/ubuntu20.04-jupyter",
    "renting_server": 6,
    "type": "on-demand",
    "ports": {
      "22": "tcp",
      "8888": "http"
    },
    "ssh_password": "YourSSHPassword123",
    "jupyter_token": "YourJupyterToken123"
  }' \\
  'https://api.clore.ai/v1/create_order'
```

**प्रतिक्रिया:**

```json
{ "code": 0 }
```

***

### स्पॉट ऑर्डर बनाएं

स्पॉट ऑर्डर सस्ते होते हैं लेकिन उन पर अधिक बोली लगाई जा सकती है। आप प्रति दिन अपनी कीमत तय करते हैं:

```bash
curl -XPOST \\
  -H 'auth: YOUR_API_KEY' \\
  -H 'Content-type: application/json' \\
  -d '{
    "currency": "bitcoin",
    "image": "cloreai/ubuntu20.04-jupyter",
    "renting_server": 6,
    "type": "spot",
    "spotprice": 0.000005,
    "ports": {
      "22": "tcp",
      "8888": "http"
    },
    "ssh_password": "YourSSHPassword123"
  }' \\
  'https://api.clore.ai/v1/create_order'
```

***

### ऑर्डर की स्थिति जांचें

```bash
curl -XGET \\
  -H 'auth: YOUR_API_KEY' \\
  'https://api.clore.ai/v1/my_orders'
```

सक्रिय ऑर्डर में शामिल हैं `pub_cluster` (होस्टनेम) और `tcp_ports` SSH पहुँच के लिए:

```json
{
  "id": 38,
  "pub_cluster": ["n1.c1.clorecloud.net", "n2.c1.clorecloud.net"],
  "tcp_ports": ["22:10000"],
  "http_port": "8888",
  "expired": false
}
```

अपने किराये पर लिए गए सर्वर में SSH करें:

```bash
ssh root@n1.c1.clorecloud.net -p 10000
```

***

### ऑर्डर रद्द करें

```bash
curl -XPOST \\
  -H 'auth: YOUR_API_KEY' \\
  -H 'Content-type: application/json' \\
  -d '{
    "id": 38
  }' \\
  'https://api.clore.ai/v1/cancel_order'
```

वैकल्पिक रूप से सर्वर से संबंधित कोई समस्या रिपोर्ट करें:

```bash
curl -XPOST \\
  -H 'auth: YOUR_API_KEY' \\
  -H 'Content-type: application/json' \\
  -d '{
    "id": 38,
    "issue": "GPU बहुत गर्म हो रहा था और प्रदर्शन थ्रॉटल कर रहा था"
  }' \\
  'https://api.clore.ai/v1/cancel_order'
```

***

## Python SDK

एक हल्का रैपर जो `requests` लाइब्रेरी। इसे इस तरह इंस्टॉल करें:

```bash
pip install requests
```

### CloreClient क्लास

```python
import requests
import time

class CloreClient:
    """Clore.ai REST API के लिए सरल Python SDK."""
    
    BASE_URL = "https://api.clore.ai/v1"
    
    def __init__(self, api_key: str):
        self.api_key = api_key
        self.session = requests.Session()
        self.session.headers.update({"auth": api_key})
    
    def _get(self, endpoint: str, params: dict = None) -> dict:
        url = f"{self.BASE_URL}/{endpoint}"
        response = self.session.get(url, params=params)
        response.raise_for_status()
        data = response.json()
        if data.get("code") != 0:
            raise CloreAPIError(data)
        return data
    
    def _post(self, endpoint: str, body: dict) -> dict:
        url = f"{self.BASE_URL}/{endpoint}"
        self.session.headers.update({"Content-type": "application/json"})
        response = self.session.post(url, json=body)
        response.raise_for_status()
        data = response.json()
        if data.get("code") != 0:
            raise CloreAPIError(data)
        return data
    
    def list_servers(self) -> list:
        """मार्केटप्लेस पर उपलब्ध सभी सर्वर प्राप्त करें."""
        data = self._get("marketplace")
        return data["servers"]
    
    def get_server_details(self, server_id: int) -> dict:
        """किसी विशिष्ट सर्वर के लिए स्पॉट मार्केटप्लेस जानकारी प्राप्त करें."""
        data = self._get("spot_marketplace", params={"market": server_id})
        return data["market"]
    
    def create_order(
        self,
        server_id: int,
        image: str,
        order_type: str = "on-demand",
        currency: str = "bitcoin",
        spotprice: float = None,
        ports: dict = None,
        ssh_password: str = None,
        ssh_key: str = None,
        jupyter_token: str = None,
        env: dict = None,
        command: str = None,
    ) -> dict:
        """
        एक on-demand या spot ऑर्डर बनाएं।
        
        आर्ग्स:
            server_id: किराये पर लेने वाले सर्वर की ID
            image: Docker image (उदा. 'cloreai/ubuntu20.04-jupyter')
            order_type: 'on-demand' या 'spot'
            currency: 'bitcoin' (डिफ़ॉल्ट)
            spotprice: स्पॉट ऑर्डर के लिए आवश्यक — BTC में प्रति दिन कीमत
            ports: पोर्ट फ़ॉरवर्डिंग, उदा. {"22": "tcp", "8888": "http"}
            ssh_password: SSH पासवर्ड (केवल अल्फ़ान्यूमेरिक वर्ण)
            ssh_key: SSH सार्वजनिक कुंजी
            jupyter_token: Jupyter notebook टोकन
            env: पर्यावरण चर का डिक्शनरी
            command: कंटेनर शुरू होने के बाद चलाने के लिए शेल कमांड
        """
        if order_type == "spot" and spotprice is None:
            raise ValueError("spotprice is required for spot orders")
        
        body = {
            "currency": currency,
            "image": image,
            "renting_server": server_id,
            "type": order_type,
        }
        
        if spotprice is not None:
            body["spotprice"] = spotprice
        if ports:
            body["ports"] = ports
        if ssh_password:
            body["ssh_password"] = ssh_password
        if ssh_key:
            body["ssh_key"] = ssh_key
        if jupyter_token:
            body["jupyter_token"] = jupyter_token
        if env:
            body["env"] = env
        if command:
            body["command"] = command
        
        return self._post("create_order", body)
    
    def get_orders(self, include_completed: bool = False) -> list:
        """अपने सक्रिय (और वैकल्पिक रूप से पूर्ण) ऑर्डर प्राप्त करें."""
        params = {"return_completed": "true"} if include_completed else {}
        data = self._get("my_orders", params=params)
        return data["orders"]
    
    def cancel_order(self, order_id: int, issue: str = None) -> dict:
        """एक ऑर्डर रद्द करें। वैकल्पिक रूप से कोई समस्या रिपोर्ट करें."""
        body = {"id": order_id}
        if issue:
            body["issue"] = issue
        return self._post("cancel_order", body)
    
    def get_wallets(self) -> list:
        """अपने वॉलेट और बैलेंस प्राप्त करें."""
        data = self._get("wallets")
        return data["wallets"]
    
    def get_my_servers(self) -> list:
        """वे सर्वर प्राप्त करें जिन्हें आप मार्केटप्लेस को प्रदान कर रहे हैं."""
        data = self._get("my_servers")
        return data["servers"]


class CloreAPIError(Exception):
    """जब Clore API गैर-शून्य code लौटाती है, तब उठाया जाता है."""
    
    ERROR_CODES = {
        0: "सामान्य",
        1: "डेटाबेस त्रुटि",
        2: "अमान्य इनपुट डेटा",
        3: "अमान्य API टोकन",
        4: "अमान्य एंडपॉइंट",
        5: "रेट सीमा पार हो गई (1 अनुरोध/सेकंड)",
        6: "त्रुटि (त्रुटि फ़ील्ड देखें)",
    }
    
    def __init__(self, response: dict):
        self.code = response.get("code")
        self.error = response.get("error", "")
        message = self.ERROR_CODES.get(self.code, f"अज्ञात code {self.code}")
        if self.error:
            message = f"{message}: {self.error}"
        super().__init__(f"Clore API त्रुटि {self.code}: {message}")
```

### पूर्ण कार्यशील उदाहरण

```python
import os
from clore_client import CloreClient, CloreAPIError

# क्लाइंट आरंभ करें
client = CloreClient(api_key=os.environ["CLORE_API_KEY"] )

# 1. मार्केटप्लेस ब्राउज़ करें
servers = client.list_servers()
print(f"मार्केटप्लेस पर {len(servers)} सर्वर मिले")

# 2. उपलब्ध RTX 4090 सर्वर फ़िल्टर करें
rtx4090_servers = [
    s for s in servers
    if "4090" in s["specs"].get("gpu", "") and not s["rented"]
]

if not rtx4090_servers:
    print("कोई उपलब्ध RTX 4090 सर्वर नहीं मिला")
    exit(1)

# 3. सबसे सस्ता चुनें
cheapest = min(rtx4090_servers, key=lambda s: s["price"]["on_demand"]["bitcoin"] )
print(f"सबसे सस्ता RTX 4090: सर्वर ID {cheapest['id']}, "
      f"कीमत {cheapest['price']['on_demand']['bitcoin']:.8f} BTC/दिन")

# 4. ऑर्डर बनाएं
try:
    client.create_order(
        server_id=cheapest["id"],
        image="cloreai/ubuntu20.04-jupyter",
        order_type="on-demand",
        currency="bitcoin",
        ports={"22": "tcp", "8888": "http"},
        ssh_password="SecurePass123",
        jupyter_token="MyToken123",
    )
    print("ऑर्डर सफलतापूर्वक बनाया गया!")
except CloreAPIError as e:
    print(f"ऑर्डर बनाने में विफल: {e}")
    exit(1)

# 5. अपने ऑर्डर जांचें
orders = client.get_orders()
for order in orders:
    if not order.get("expired"):
        cluster = order.get("pub_cluster", [])
        tcp = order.get("tcp_ports", [])
        print(f"ऑर्डर {order['id']}: सर्वर {order['si']}")
        if cluster and tcp:
            ssh_port = tcp[0].split(":")[1]
            print(f"  SSH: ssh root@{cluster[0]} -p {ssh_port}")
```

***

## Node.js उदाहरण

मूल `fetch` API (Node.js 18+):

```javascript
const BASE_URL = 'https://api.clore.ai/v1';

class CloreClient {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.defaultHeaders = {
      'auth': apiKey,
    };
  }

  async get(endpoint, params = {}) {
    const url = new URL(`${BASE_URL}/${endpoint}`);
    Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
    
    const res = await fetch(url.toString(), {
      headers: this.defaultHeaders,
    });
    
    const data = await res.json();
    if (data.code !== 0) {
      throw new Error(`Clore API त्रुटि ${data.code}: ${data.error || 'अज्ञात'}`);
    }
    return data;
  }

  async post(endpoint, body) {
    const res = await fetch(`${BASE_URL}/${endpoint}`, {
      method: 'POST',
      headers: {
        ...this.defaultHeaders,
        'Content-type': 'application/json',
      },
      body: JSON.stringify(body),
    });
    
    const data = await res.json();
    if (data.code !== 0) {
      throw new Error(`Clore API त्रुटि ${data.code}: ${data.error || 'अज्ञात'}`);
    }
    return data;
  }

  async listServers() {
    const data = await this.get('marketplace');
    return data.servers;
  }

  async getOrders(includeCompleted = false) {
    const params = includeCompleted ? { return_completed: 'true' } : {};
    const data = await this.get('my_orders', params);
    return data.orders;
  }

  async createOrder({ serverId, image, type = 'on-demand', currency = 'bitcoin', spotprice, ports, sshPassword, jupyterToken, env, command }) {
    const body = {
      currency,
      image,
      renting_server: serverId,
      type,
      ...(spotprice && { spotprice }),
      ...(ports && { ports }),
      ...(sshPassword && { ssh_password: sshPassword }),
      ...(jupyterToken && { jupyter_token: jupyterToken }),
      ...(env && { env }),
      ...(command && { command }),
    };
    return this.post('create_order', body);
  }

  async cancelOrder(orderId, issue = null) {
    const body = { id: orderId };
    if (issue) body.issue = issue;
    return this.post('cancel_order', body);
  }
}

// उपयोग उदाहरण
const client = new CloreClient(process.env.CLORE_API_KEY);

async function main() {
  // मार्केटप्लेस सूची
  const servers = await client.listServers();
  console.log(`मार्केटप्लेस में ${servers.length} सर्वर हैं`);

  // उपलब्ध RTX 4090 सर्वर खोजें
  const available = servers.filter(
    s => s.specs.gpu.includes('4090') && !s.rented
  );
  console.log(`उपलब्ध RTX 4090 सर्वर: ${available.length}`);

  // वर्तमान ऑर्डर प्राप्त करें
  const orders = await client.getOrders();
  const activeOrders = orders.filter(o => !o.expired);
  console.log(`सक्रिय ऑर्डर: ${activeOrders.length}`);

  for (const order of activeOrders) {
    const host = order.pub_cluster?.[0];
    const portMapping = order.tcp_ports?.[0];
    if (host && portMapping) {
      const sshPort = portMapping.split(':')[1];
      console.log(`ऑर्डर ${order.id} → ssh root@${host} -p ${sshPort}`);
    }
  }
}

main().catch(console.error);
```

***

## सामान्य कार्यप्रवाह

### सबसे सस्ता RTX 4090 खोजें और उसे किराए पर लें

```python
from clore_client import CloreClient

client = CloreClient(api_key="YOUR_API_KEY")

def rent_cheapest_rtx4090(image="cloreai/ubuntu20.04-jupyter", ssh_password="SecurePass123"):
    servers = client.list_servers()
    
    # उपलब्ध RTX 4090 फ़िल्टर करें
    candidates = [
        s for s in servers
        if "4090" in s["specs"].get("gpu", "")
        and not s["rented"]
    ]
    
    if not candidates:
        raise RuntimeError("कोई उपलब्ध RTX 4090 सर्वर नहीं मिला")
    
    # ऑन-डिमांड BTC कीमत के अनुसार क्रमबद्ध करें
    candidates.sort(key=lambda s: s["price"]["on_demand"]["bitcoin"] )
    best = candidates[0]
    
    price_btc = best["price"]["on_demand"]["bitcoin"]
    print(f"सर्वर {best['id']} किराए पर लिया जा रहा है: {best['specs']['gpu']} @ {price_btc:.8f} BTC/day")
    
    client.create_order(
        server_id=best["id"],
        image=image,
        order_type="on-demand",
        currency="bitcoin",
        ports={"22": "tcp"},
        ssh_password=ssh_password,
    )
    
    print("हो गया! SSH कनेक्शन विवरण के लिए अपने ऑर्डर देखें।")
    return best["id"]

rent_cheapest_rtx4090()
```

***

### मेरे ऑर्डर मॉनिटर करें

```python
import time
from clore_client import CloreClient

client = CloreClient(api_key="YOUR_API_KEY")

def monitor_orders(poll_interval_seconds=60):
    """ऑर्डरों को पोल करें और स्थिति अपडेट प्रिंट करें।"""
    print(f"ऑर्डरों की निगरानी की जा रही है (हर {poll_interval_seconds}s पर पोलिंग). रोकने के लिए Ctrl+C दबाएँ.\n")
    
    while True:
        orders = client.get_orders(include_completed=False)
        active = [o for o in orders if not o.get("expired")]
        
        print(f"--- {len(active)} सक्रिय ऑर्डर ---")
        for order in active:
            cluster = order.get("pub_cluster", [])
            tcp = order.get("tcp_ports", [])
            spend = order.get("spend", 0)
            
            ssh_info = ""
            if cluster and tcp:
                port = tcp[0].split(":")[1]
                ssh_info = f" | SSH: {cluster[0]}:{port}"
            
            print(f"  ऑर्डर {order['id']}: सर्वर {order['si']}"
                  f" | खर्च {spend:.8f} BTC{ssh_info}")
        
        if not active:
            print("  कोई सक्रिय ऑर्डर नहीं हैं.")
        
        print()
        time.sleep(poll_interval_seconds)

monitor_orders()
```

***

### जब कीमत X से नीचे गिरे तो स्वतः किराए पर लें

```python
import time
from clore_client import CloreClient

client = CloreClient(api_key="YOUR_API_KEY")

def auto_rent_on_price_drop(
    gpu_model: str = "RTX 4090",
    max_price_btc: float = 0.00015,
    image: str = "cloreai/ubuntu20.04-jupyter",
    ssh_password: str = "SecurePass123",
    check_interval_seconds: int = 120,
):
    """
    मार्केटप्लेस पर नज़र रखें और कीमत सीमा से नीचे आने पर स्वतः GPU किराए पर लें।
    
    आर्ग्स:
        खोजने के लिए GPU मॉडल का नाम (केस-इन्सेंसिटिव)
        BTC में प्रति दिन अधिकतम स्वीकार्य कीमत
        तैनात करने के लिए Docker इमेज
        कंटेनर के लिए SSH पासवर्ड
        कितनी बार जाँच करनी है (rate limits का सम्मान करें!)
    """
    print(f"{gpu_model} को ≤ {max_price_btc:.8f} BTC/day पर देख रहे हैं...")
    
    while True:
        servers = client.list_servers()
        
        for server in servers:
            gpu = server["specs"].get("gpu", "")
            if gpu_model.lower() not in gpu.lower():
                continue
            if server["rented"]:
                continue
            
            price = server["price"]["on_demand"]["bitcoin"]
            if price <= max_price_btc:
                print(f"🎯 मैच मिल गया! सर्वर {server['id']}: {gpu} @ {price:.8f} BTC/day")
                
                try:
                    client.create_order(
                        server_id=server["id"],
                        image=image,
                        order_type="on-demand",
                        currency="bitcoin",
                        ports={"22": "tcp"},
                        ssh_password=ssh_password,
                        required_price=price,  # इस कीमत को लॉक करें
                    )
                    print(f"✅ सर्वर {server['id']} के लिए ऑर्डर बना दिया गया!")
                    return server["id"]
                except Exception as e:
                    print(f"ऑर्डर बनाने में विफल: {e}. पुनः प्रयास किया जाएगा...")
        
        print(f"अभी तक कोई मेल नहीं मिला. {check_interval_seconds}s में फिर जाँच करेंगे...")
        time.sleep(check_interval_seconds)

auto_rent_on_price_drop(gpu_model="4090", max_price_btc=0.00012)
```

***

## वेबसॉकेट

Clore.ai REST API वर्तमान में WebSocket endpoint प्रदान नहीं करता है। रीयल-टाइम मॉनिटरिंग के लिए, उचित अंतराल पर polling का उपयोग करें (नीचे rate limits देखें)।

***

## रेट सीमाएँ

| एंडपॉइंट                           | सीमा                 |
| ---------------------------------- | -------------------- |
| अधिकांश एंडपॉइंट                   | **1 अनुरोध/सेकंड**   |
| `create_order`                     | **1 अनुरोध/5 सेकंड** |
| `set_spot_price` (मूल्य में कटौती) | प्रति **600 सेकंड**  |

**रेट-लिमिट प्रतिक्रिया (कोड 5):**

```json
{ "code": 5 }
```

**सर्वोत्तम अभ्यास:**

* जोड़ें `time.sleep(1)` लगातार API कॉलों के बीच
* के लिए `create_order`, अनुरोधों के बीच कम से कम 5 सेकंड प्रतीक्षा करें
* मॉनिटरिंग लूप के लिए 60+ सेकंड के पोलिंग अंतराल का उपयोग करें
* यदि आपको इसे बार-बार क्वेरी करना हो, तो मार्केटप्लेस डेटा को स्थानीय रूप से कैश करें

**Python सहायक:**

```python
import time

def safe_api_call(fn, *args, delay=1.1, **kwargs):
    """रेट-लिमिट सुरक्षा के साथ API कॉल को रैप करें।"""
    result = fn(*args, **kwargs)
    time.sleep(delay)
    return result
```

***

## त्रुटि प्रबंधन

हर API प्रतिक्रिया में एक `code` फ़ील्ड शामिल होती है। इसका मान `0` सफलता का संकेत देता है।

### त्रुटि कोड

| कोड | अर्थ                                    | कार्रवाई                                  |
| --- | --------------------------------------- | ----------------------------------------- |
| `0` | सफलता                                   | —                                         |
| `1` | डेटाबेस त्रुटि                          | देरी के बाद पुनः प्रयास करें              |
| `2` | अमान्य इनपुट डेटा                       | अपने अनुरोध बॉडी/पैरामीटर जाँचें          |
| `3` | अमान्य API टोकन                         | डैशबोर्ड में अपनी API कुंजी सत्यापित करें |
| `4` | अमान्य एंडपॉइंट                         | एंडपॉइंट URL जाँचें                       |
| `5` | रेट सीमा पार हो गई (1 req/sec)          | अनुरोधों के बीच देरी जोड़ें               |
| `6` | एप्लिकेशन त्रुटि (देखें `error` फ़ील्ड) | विवरण के लिए `error` फ़ील्ड पढ़ें         |

### कोड 6 उप-त्रुटियाँ

| `error` मान                   | अर्थ                                                                              |
| ----------------------------- | --------------------------------------------------------------------------------- |
| `exceeded_max_step`           | स्पॉट मूल्य में कटौती बहुत बड़ी है; देखें `max_step` फ़ील्ड                       |
| `can_lower_every_600_seconds` | स्पॉट मूल्य को फिर से घटाने से पहले प्रतीक्षा करनी होगी; देखें `time_to_lowering` |

### Python त्रुटि प्रबंधन उदाहरण

```python
from clore_client import CloreClient, CloreAPIError
import time

client = CloreClient(api_key="YOUR_API_KEY")

def create_order_with_retry(server_id, image, max_retries=3):
    for attempt in range(max_retries):
        try:
            return client.create_order(
                server_id=server_id,
                image=image,
                order_type="on-demand",
                currency="bitcoin",
                ports={"22": "tcp"},
                ssh_password="SecurePass123",
            )
        except CloreAPIError as e:
            if e.code == 5:  # रेट सीमा
                print(f"रेट सीमा लगी। 5s प्रतीक्षा कर रहे हैं... (प्रयास {attempt+1}/{max_retries})")
                time.sleep(5)
            elif e.code == 3:  # खराब API कुंजी
                print("अमान्य API कुंजी! अपनी CLORE_API_KEY जाँचें.")
                raise
            elif e.code == 2:  # खराब इनपुट
                print(f"अमान्य अनुरोध: {e}")
                raise
            else:
                print(f"API त्रुटि: {e}. 3s में पुनः प्रयास किया जाएगा...")
                time.sleep(3)
    
    raise RuntimeError(f"{max_retries} प्रयासों के बाद विफल")
```

### JavaScript त्रुटि प्रबंधन उदाहरण

```javascript
async function createOrderWithRetry(client, serverConfig, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await client.createOrder(serverConfig);
    } catch (err) {
      const code = parseInt(err.message.match(/error (\d+)/)?.[1]);
      
      if (code === 5) {
        console.log(`रेट सीमा लगी। 5s प्रतीक्षा कर रहे हैं... (प्रयास ${attempt + 1}/${maxRetries})`);
        await new Promise(r => setTimeout(r, 5000));
      } else if (code === 3) {
        throw new Error('अमान्य API कुंजी');
      } else {
        console.log(`API त्रुटि: ${err.message}. 3s में पुनः प्रयास किया जाएगा...`);
        await new Promise(r => setTimeout(r, 3000));
      }
    }
  }
  throw new Error(`${maxRetries} प्रयासों के बाद विफल`);
}
```

***

## उपलब्ध Docker इमेजें

Clore.ai GPU वर्कलोड के लिए अनुकूलित पूर्व-निर्मित इमेजें प्रदान करता है:

| इमेज                          | विवरण                     |
| ----------------------------- | ------------------------- |
| `cloreai/ubuntu20.04-jupyter` | Ubuntu 20.04 + JupyterLab |
| `cloreai/ubuntu22.04-jupyter` | Ubuntu 22.04 + JupyterLab |

आप कोई भी सार्वजनिक Docker Hub इमेज भी उपयोग कर सकते हैं। GPU एक्सेस के लिए, CUDA-सक्षम इमेजें उपयोग करें, जैसे:

```
nvidia/cuda:12.1.0-devel-ubuntu22.04
```

***

## पोर्ट फ़ॉरवर्डिंग

ऑर्डर बनाते समय, उजागर करने के लिए पोर्ट निर्दिष्ट करें:

```json
{
  "ports": {
    "22": "tcp",
    "8888": "http",
    "6006": "http"
  }
}
```

* **`"tcp"`** — सीधा TCP पोर्ट फ़ॉरवर्डिंग (SSH, कस्टम सर्वरों के लिए)
* **`"http"`** — HTTPS प्रॉक्सी (Jupyter, वेब UI के लिए)। प्रति केवल एक HTTP पोर्ट की अनुमति है `http_port` फ़ील्ड.

ऑर्डर बनने के बाद, कनेक्शन विवरण इसमें दिखाई देते हैं `my_orders`:

```json
{
  "pub_cluster": ["n1.c1.clorecloud.net", "n2.c1.clorecloud.net"],
  "tcp_ports": ["22:10000"],
  "http_port": "8888"
}
```

SSH के माध्यम से कनेक्ट करें:

```bash
ssh root@n1.c1.clorecloud.net -p 10000
```

ब्राउज़र के माध्यम से Jupyter एक्सेस करें: `https://n1.c1.clorecloud.net` (का उपयोग करता है `http_port`)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/clore.ai/clore.ai-eng-hi/developers/cli-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
