> 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/guides/guides_v2-hi/advanced/python-sdk.md).

# Python SDK गाइड

पूर्ण Python SDK मार्गदर्शिका — sync/async क्लाइंट, मार्केटप्लेस फ़िल्टरिंग, ऑर्डर लाइफसाइकल, स्पॉट मार्केट, वॉलेट संचालन, और त्रुटि प्रबंधन

{% hint style="success" %}
**SDK में नए हैं?** इसके साथ शुरू करें [5-मिनट का क्विकस्टार्ट](/guides/guides_v2-hi/getting-started/python-quickstart.md) पहले।
{% endhint %}

वास्तविक उदाहरणों के साथ त्वरित-शुरुआत ट्यूटोरियल के लिए देखें [Clore.ai Python SDK — 5 मिनट में अपने GPU वर्कफ़्लो को स्वचालित करें](https://blog.clore.ai/cloreai-python-sdk-automate-your-gpu-workflows-in-5-minutes/)

## इंस्टॉलेशन

```bash
pip install clore-ai
```

SDK दो क्लाइंट प्रदान करता है:

* **`CloreAI`** — समकालिक (सरल, स्क्रिप्ट्स के लिए उपयुक्त)
* **`AsyncCloreAI`** — असमकालिक (समवर्ती कार्यों के लिए तेज़)

दोनों में समान मेथड हैं और वही Pydantic मॉडल लौटाते हैं।

***

## समकालिक बनाम असमकालिक — किसका उपयोग कब करें

| उपयोग-प्रकरण                   | क्लाइंट        | क्यों                          |
| ------------------------------ | -------------- | ------------------------------ |
| सरल स्क्रिप्ट्स, एकबारगी कार्य | `CloreAI`      | सरल कोड, बिना `async/await`    |
| मॉनिटरिंग लूप                  | `CloreAI`      | क्रमिक जाँचें ठीक काम करती हैं |
| थोक मार्केटप्लेस क्वेरियाँ     | `AsyncCloreAI` | समवर्ती अनुरोध = तेज़          |
| बैच ऑर्डर निर्माण              | `AsyncCloreAI` | एक साथ कई ऑर्डर बनाएं          |
| वेब अनुप्रयोग                  | `AsyncCloreAI` | नॉन-ब्लॉकिंग I/O               |

### समकालिक उदाहरण

```python
from clore_ai import CloreAI

client = CloreAI()  # CLORE_API_KEY env var का उपयोग करता है

servers = client.marketplace(gpu="RTX 4090")
print(f"{len(servers)} सर्वर मिले")

client.close()  # या कॉन्टेक्स्ट मैनेजर का उपयोग करें
```

### असमकालिक उदाहरण

```python
import asyncio
from clore_ai import AsyncCloreAI

async def main():
    async with AsyncCloreAI() as client:
        servers = await client.marketplace(gpu="RTX 4090")
        print(f"{len(servers)} सर्वर मिले")

asyncio.run(main())
```

### कॉन्टेक्स्ट मैनेजर (अनुशंसित)

दोनों क्लाइंट स्वचालित सफ़ाई के लिए कॉन्टेक्स्ट मैनेजर का समर्थन करते हैं:

```python
# समकालिक
with CloreAI() as client:
    wallets = client.wallets()

# असमकालिक
async with AsyncCloreAI() as client:
    wallets = await client.wallets()
```

***

## क्लाइंट कॉन्फ़िगरेशन

```python
client = CloreAI(
    api_key="your_key",      # या CLORE_API_KEY env var सेट करें
    base_url="https://api.clore.ai/v1",  # कस्टम API एंडपॉइंट
    timeout=30.0,            # सेकंड में अनुरोध टाइमआउट
    max_retries=3            # रेट लिमिट / नेटवर्क त्रुटियों पर पुनः प्रयास
)
```

SDK में एक अंतर्निहित रेट लिमिटर शामिल है:

* **सामान्य अनुरोध:** 1 अनुरोध/सेकंड
* **`create_order`:** कॉल्स के बीच 5-सेकंड का कूलडाउन
* **रेट लिमिट त्रुटियाँ (कोड 5):** स्वचालित घातीय बैकऑफ़

***

## मार्केटप्लेस फ़िल्टरिंग

यह `marketplace()` मेथड सभी उपलब्ध सर्वर लाती है और क्लाइंट-साइड पर फ़िल्टर करती है:

```python
from clore_ai import CloreAI

client = CloreAI()

# सभी उपलब्ध सर्वर
all_servers = client.marketplace()

# GPU मॉडल के अनुसार फ़िल्टर करें (केस-इंसेंसिटिव सबस्ट्रिंग मिलान)
rtx_4090s = client.marketplace(gpu="RTX 4090")

# कई मानदंडों के अनुसार फ़िल्टर करें
budget_gpus = client.marketplace(
    gpu="RTX 4090",
    max_price_usd=1.0,       # अधिकतम $1.00/घंटा
    min_gpu_count=2,          # कम से कम 2 GPU
    min_ram_gb=64.0,          # कम से कम 64GB सिस्टम RAM
    available_only=True       # केवल उपलब्ध सर्वर (डिफ़ॉल्ट)
)
```

### उन्नत फ़िल्टरिंग (क्लाइंट-साइड)

जो फ़िल्टर मेथड में अंतर्निहित नहीं हैं, उनके लिए लौटाए गए `सर्वर` ऑब्जेक्ट्स स्वयं फ़िल्टर करें:

```python
servers = client.marketplace(gpu="RTX 4090")

# उच्च विश्वसनीयता वाले EU के सर्वर
eu_servers = [
    s for s in servers
    if s.location and s.location.upper() in ("DE", "FR", "NL", "FI")
    and s.reliability and s.reliability >= 0.95
]

# कीमत के अनुसार क्रमबद्ध करें
cheapest = sorted(servers, key=lambda s: s.price_usd or float("inf"))
print(f"सबसे सस्ता: सर्वर {cheapest[0].id} — ${cheapest[0].price_usd:.4f}/घं")
```

### सर्वर मॉडल फ़ील्ड

प्रत्येक `MarketplaceServer` ऑब्जेक्ट में ये गुण और सुविधा प्रॉपर्टीज़ होती हैं:

| फ़ील्ड           | प्रकार                | विवरण                                                            |
| ---------------- | --------------------- | ---------------------------------------------------------------- |
| `id`             | `int`                 | सर्वर ID (इसे उपयोग करें `create_order`)                         |
| `gpu_model`      | `str \| None`         | स्पेक्स से प्राप्त GPU विवरण (प्रॉपर्टी)                         |
| `gpu_count`      | `int`                 | से GPU की संख्या `gpu_array` (प्रॉपर्टी)                         |
| `ram_gb`         | `float \| None`       | GB में सिस्टम RAM (प्रॉपर्टी, से `specs.ram`)                    |
| `price_usd`      | `float \| None`       | USD में ऑन-डिमांड कीमत (प्रॉपर्टी, से `price.usd.on_demand_usd`) |
| `spot_price_usd` | `float \| None`       | USD में स्पॉट कीमत (प्रॉपर्टी)                                   |
| `उपलब्ध`         | `bool`                | क्या सर्वर किराए पर नहीं है (प्रॉपर्टी)                          |
| `location`       | `str \| None`         | नेटवर्क स्पेक्स से देश कोड (प्रॉपर्टी)                           |
| `specs`          | `ServerSpecs \| None` | हार्डवेयर स्पेक्स (cpu, ram, disk, gpu, net)                     |
| `price`          | `ServerPrice \| None` | पूर्ण मूल्य संरचना                                               |
| `rented`         | `bool \| None`        | क्या सर्वर वर्तमान में किराए पर है                               |

***

## ऑर्डर प्रबंधन

### ऑर्डर बनाना

```python
order = client.create_order(
    server_id=142,
    image="cloreai/ubuntu22.04-cuda12",
    type="on-demand",               # "on-demand" या "spot"
    currency="bitcoin",             # भुगतान मुद्रा
    ssh_password="MySecurePass",    # SSH एक्सेस
    ports={"22": "tcp", "8888": "http"},  # पोर्ट मैपिंग्स
    env={"HF_TOKEN": "hf_xxx"},    # पर्यावरण चर
    command="bash /start.sh",       # कस्टम स्टार्टअप कमांड
    jupyter_token="my_token"        # Jupyter notebook टोकन
)

print(f"ऑर्डर ID: {order.id}")
print(f"IP: {order.pub_cluster}")
print(f"पोर्ट्स: {order.tcp_ports}")
```

### पूर्ण `create_order` पैरामीटर

| पैरामीटर             | प्रकार  | आवश्यक | विवरण                             |
| -------------------- | ------- | ------ | --------------------------------- |
| `server_id`          | `int`   | ✅      | किराए पर लेने हेतु सर्वर          |
| `image`              | `str`   | ✅      | Docker इमेज                       |
| `type`               | `str`   | ✅      | `"on-demand"` या `"spot"`         |
| `currency`           | `str`   | ✅      | भुगतान मुद्रा (जैसे, `"bitcoin"`) |
| `ssh_password`       | `str`   | —      | SSH पासवर्ड                       |
| `ssh_key`            | `str`   | —      | SSH सार्वजनिक कुंजी               |
| `ports`              | `dict`  | —      | पोर्ट मैपिंग्स (`{"22": "tcp"}`)  |
| `env`                | `dict`  | —      | पर्यावरण चर                       |
| `jupyter_token`      | `str`   | —      | Jupyter notebook टोकन             |
| `command`            | `str`   | —      | स्टार्टअप कमांड                   |
| `spot_price`         | `float` | —      | स्पॉट बोली मूल्य                  |
| `required_price`     | `float` | —      | आवश्यक मूल्य                      |
| `autossh_entrypoint` | `str`   | —      | ऑटो SSH एंट्रीपॉइंट               |

### ऑर्डर सूचीबद्ध करना

```python
# केवल सक्रिय ऑर्डर
active = client.my_orders()
for o in active:
    print(f"ऑर्डर {o.id}: type={o.type}, IP={o.pub_cluster}, status={o.status}")

# पूर्ण किए गए ऑर्डर भी शामिल करें
all_orders = client.my_orders(include_completed=True)
```

### ऑर्डर मॉडल फ़ील्ड

| फ़ील्ड        | प्रकार          | विवरण                                  |
| ------------- | --------------- | -------------------------------------- |
| `id`          | `int`           | ऑर्डर ID                               |
| `server_id`   | `int \| None`   | किराए पर लिए गए सर्वर ID               |
| `type`        | `str`           | `"on-demand"` या `"spot"`              |
| `status`      | `str \| None`   | ऑर्डर स्थिति                           |
| `image`       | `str \| None`   | Docker इमेज                            |
| `currency`    | `str \| None`   | भुगतान मुद्रा                          |
| `price`       | `float \| None` | कीमत                                   |
| `pub_cluster` | `str \| None`   | सार्वजनिक IP / होस्टनेम                |
| `tcp_ports`   | `dict \| None`  | पोर्ट मैपिंग्स (जैसे, `{"22": 50022}`) |
| `created_at`  | `str \| None`   | निर्माण टाइमस्टैम्प                    |

### ऑर्डर मॉनिटर करना

```python
import time

def wait_for_ready(client, order_id, timeout=120):
    """ऑर्डर को सार्वजनिक IP मिलने का इंतज़ार करें."""
    for _ in range(timeout // 10):
        orders = client.my_orders()
        order = next((o for o in orders if o.id == order_id), None)
        if order and order.pub_cluster:
            return order
        time.sleep(10)
    raise TimeoutError(f"{timeout}s बाद ऑर्डर {order_id} तैयार नहीं हुआ")

# उपयोग
order = client.create_order(server_id=142, image="cloreai/ubuntu22.04-cuda12", type="on-demand", currency="bitcoin")
ready = wait_for_ready(client, order.id)
print(f"SSH: ssh root@{ready.pub_cluster} -p {ready.tcp_ports.get('22', 22)}")
```

### ऑर्डर रद्द करना

```python
# वैकल्पिक कारण के साथ रद्द करें
client.cancel_order(order_id=38, issue="कार्य पूर्ण")

# सभी सक्रिय ऑर्डर रद्द करें
orders = client.my_orders()
for order in orders:
    client.cancel_order(order.id, issue="सफ़ाई")
    print(f"ऑर्डर {order.id} रद्द किया गया")
```

***

## सर्वर प्रबंधन (होस्टरों के लिए)

यदि आप Clore पर GPUs होस्ट करते हैं, तो SDK आपको अपने सर्वर प्रबंधित करने देता है:

### अपने सर्वर सूचीबद्ध करें

```python
my_servers = client.my_servers()
for s in my_servers:
    print(f"सर्वर {s.id}: {s.gpu_model} — {s.status}")
```

### सर्वर कॉन्फ़िगरेशन प्राप्त करें

```python
config = client.server_config("MyGPU-Rig")
print(f"नाम: {config.name}")
print(f"दृश्यता: {config.visibility}")
print(f"ऑनलाइन: {config.online}")
print(f"न्यूनतम किराया: {config.mrl}h")
print(f"ऑन-डिमांड कीमत: {config.on_demand_price}")
print(f"स्पॉट कीमत: {config.spot_price}")
```

### सर्वर सेटिंग्स अपडेट करें

```python
client.set_server_settings(
    name="MyGPU-Rig",
    availability=True,       # सर्वर को उपलब्ध बनाएं
    mrl=24,                  # न्यूनतम 24 घंटे का किराया
    on_demand=0.0001,        # BTC में ऑन-डिमांड कीमत
    spot=0.00000113          # BTC में स्पॉट कीमत
)
"सेटिंग्स अपडेट की गईं"
```

***

## स्पॉट मार्केट

स्पॉट ऑर्डर तब बाधित हो सकते हैं यदि कोई आपको अधिक बोली लगा दे। लगभग एक-तिहाई सर्वर स्पॉट कीमत को ऑन-डिमांड से नीचे रखते हैं (मध्य \~13% छूट); बाकी स्पॉट को ऑन-डिमांड कीमत पर सूचीबद्ध करते हैं।

### स्पॉट ऑफ़र देखें

```python
offers = client.spot_marketplace(server_id=6)
for offer in offers:
    print(f"ऑर्डर {offer.get('order_id')}: price={offer.get('price')}")
```

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

```python
order = client.create_order(
    server_id=142,
    image="cloreai/ubuntu22.04-cuda12",
    type="spot",
    currency="bitcoin",
    spot_price=0.0001,       # आपकी बोली मूल्य
    ssh_password="MyPass"
)
print(f"स्पॉट ऑर्डर {order.id} बनाया गया")
```

### स्पॉट कीमत समायोजित करें

```python
# पिछड़ने से बचने के लिए अपनी बोली बढ़ाएँ
client.set_spot_price(order_id=39, price=0.000003)
```

### स्पॉट बोली रणनीति

```python
from clore_ai import CloreAI

client = CloreAI()

def smart_spot_bid(server_id, premium_pct=5):
    """वर्तमान न्यूनतम स्पॉट कीमत से थोड़ा ऊपर बोली लगाएँ."""
    offers = client.spot_marketplace(server_id=server_id)
    if not offers:
        print("कोई स्पॉट ऑफ़र नहीं — आधार के रूप में ऑन-डिमांड कीमत का उपयोग करें")
        return None

    min_price = min(o["price"] for o in offers)
    bid = min_price * (1 + premium_pct / 100)
    print(f"बाज़ार न्यूनतम: {min_price}, बोली: {bid:.8f} (+{premium_pct}%)")
    return bid

# उपयोग
bid = smart_spot_bid(server_id=142, premium_pct=10)
if bid:
    order = client.create_order(
        server_id=142,
        image="cloreai/ubuntu22.04-cuda12",
        type="spot",
        currency="bitcoin",
        spot_price=bid
    )
```

***

## वॉलेट संचालन

### शेष राशि जांचें

```python
wallets = client.wallets()
for w in wallets:
    print(f"{w.name}: {w.balance:.8f}")
    if w.deposit:
        print(f"  जमा पता: {w.deposit}")
```

### कम शेष राशि चेतावनी

```python
from clore_ai import CloreAI

def check_balance(min_btc=0.001):
    """यदि BTC शेष सीमा से कम हो तो चेतावनी दें."""
    client = CloreAI()
    wallets = client.wallets()

    for w in wallets:
        if w.name.lower() == "bitcoin" and w.balance < min_btc:
            print(f"⚠️  BTC शेष कम है: {w.balance:.8f} (न्यूनतम: {min_btc})")
            return False

    print("✅ शेष राशि ठीक है")
    return True

check_balance(min_btc=0.001)
```

***

## त्रुटि प्रबंधन के सर्वोत्तम अभ्यास

### अपवाद पदानुक्रम

```
CloreAPIError (मूल)
├── DBError           (कोड 1) — डेटाबेस त्रुटि
├── InvalidInputError (कोड 2) — गलत इनपुट
├── AuthError         (कोड 3) — अमान्य API कुंजी
├── InvalidEndpointError (कोड 4) — गलत एंडपॉइंट
├── RateLimitError    (कोड 5) — रेट लिमिट लगी (स्वतः पुनः प्रयास)
└── FieldError        (कोड 6) — फ़ील्ड-विशिष्ट त्रुटि
```

### बुनियादी त्रुटि प्रबंधन

```python
from clore_ai import CloreAI
from clore_ai.exceptions import (
    CloreAPIError,
    AuthError,
    RateLimitError,
    InvalidInputError
)

client = CloreAI()

try:
    order = client.create_order(
        server_id=999999,
        image="cloreai/ubuntu22.04-cuda12",
        type="on-demand",
        currency="bitcoin"
    )
except AuthError:
    print("अमान्य API कुंजी — CLORE_API_KEY जांचें")
except InvalidInputError as e:
    print(f"गलत इनपुट: {e}")
except RateLimitError:
    print("रेट लिमिट — SDK स्वचालित रूप से पुनः प्रयास करता है, लेकिन अधिकतम पुनः प्रयास समाप्त हो गए")
except CloreAPIError as e:
    print(f"API त्रुटि (कोड {e.code}): {e}")
```

### बैकऑफ़ के साथ पुनः प्रयास पैटर्न

SDK में दर-सीमाओं और नेटवर्क त्रुटियों के लिए अंतर्निहित पुनःप्रयास हैं (`max_retries=3`). एप्लिकेशन-स्तरीय पुनःप्रयासों के लिए:

```python
import time
from clore_ai import CloreAI
from clore_ai.exceptions import CloreAPIError, RateLimitError

def retry_operation(func, max_attempts=3, base_delay=2.0):
    """Clore API ऑपरेशन को घातीय बैकऑफ़ के साथ पुनः प्रयास करें."""
    for attempt in range(max_attempts):
        try:
            return func()
        except RateLimitError:
            if attempt < max_attempts - 1:
                delay = base_delay * (2 ** attempt)
                print(f"दर-सीमा लग गई, {delay}s में पुनः प्रयास कर रहे हैं...")
                time.sleep(delay)
            else:
                raise
        except CloreAPIError as e:
            if e.code in (1,):  # DB त्रुटियां अस्थायी हो सकती हैं
                if attempt < max_attempts - 1:
                    time.sleep(base_delay)
                    continue
            raise

# उपयोग
client = CloreAI()
servers = retry_operation(lambda: client.marketplace(gpu="RTX 4090"))
```

***

## प्रदर्शन सुझाव

### 1. क्लाइंट का पुनः उपयोग करें

```python
# ❌ गलत — हर बार एक नया HTTP कनेक्शन बनाता है
for _ in range(10):
    client = CloreAI()
    client.marketplace()
    client.close()

# ✅ अच्छा — HTTP कनेक्शन का पुनः उपयोग करता है
client = CloreAI()
for _ in range(10):
    client.marketplace()
client.close()
```

### 2. समवर्ती संचालन के लिए Async का उपयोग करें

```python
import asyncio
from clore_ai import AsyncCloreAI

async def compare_gpus():
    async with AsyncCloreAI() as client:
        # 3 खोजें एक साथ चलाएँ
        rtx4090, rtx3090, a100 = await asyncio.gather(
            client.marketplace(gpu="RTX 4090"),
            client.marketplace(gpu="RTX 3090"),
            client.marketplace(gpu="A100"),
        )

        print(f"RTX 4090: {len(rtx4090)} servers")
        print(f"RTX 3090: {len(rtx3090)} servers")
        print(f"A100: {len(a100)} servers")

asyncio.run(compare_gpus())
```

### 3. Async बैच ऑर्डर निर्माण

```python
import asyncio
from clore_ai import AsyncCloreAI

async def batch_deploy(server_ids):
    async with AsyncCloreAI() as client:
        tasks = [
            client.create_order(
                server_id=sid,
                image="cloreai/ubuntu22.04-cuda12",
                type="on-demand",
                currency="bitcoin",
                ssh_password="BatchPass123",
                ports={"22": "tcp"}
            )
            for sid in server_ids
        ]
        orders = await asyncio.gather(*tasks, return_exceptions=True)

        for sid, result in zip(server_ids, orders):
            if isinstance(result, Exception):
                print(f"सर्वर {sid}: असफल — {result}")
            else:
                print(f"सर्वर {sid}: ऑर्डर {result.id} बनाया गया")

        return orders

# 3 सर्वरों पर एक साथ तैनात करें
asyncio.run(batch_deploy([142, 305, 891]))
```

{% hint style="warning" %}
**ध्यान दें:** SDK कॉलों के बीच 5-सेकंड का कूलडाउन लागू करता है। `create_order` Async मोड में भी, दर-सीमाओं का सम्मान करने के लिए ऑर्डर अंतराल पर दिए जाते हैं।
{% endhint %}

### 4. काम पूरा होने पर क्लाइंट बंद करें

```python
# कॉन्टेक्स्ट मैनेजर इसे स्वचालित रूप से संभालता है
with CloreAI() as client:
    # काम...
    pass  # client.close() स्वचालित रूप से कॉल किया जाता है

# या मैन्युअल रूप से बंद करें
client = CloreAI()
try:
    # काम...
    pass
finally:
    client.close()
```

***

## पूर्ण उदाहरण: GPU वर्कर्स का ऑटो-स्केल

```python
import asyncio
import time
from clore_ai import AsyncCloreAI
from clore_ai.exceptions import CloreAPIError

async def auto_scale(
    gpu_model="RTX 4090",
    max_price=2.0,
    target_workers=3,
    image="cloreai/ubuntu22.04-cuda12"
):
    """GPU वर्कर्स का एक पूल बनाए रखें."""
    async with AsyncCloreAI() as client:
        # 1. वर्तमान ऑर्डर जाँचें
        current_orders = await client.my_orders()
        active_count = len(current_orders)
        print(f"सक्रिय वर्कर्स: {active_count}/{target_workers}")

        if active_count >= target_workers:
            print("लक्ष्य पहले ही प्राप्त हो चुका है। करने को कुछ नहीं।")
            return

        # 2. उपलब्ध सर्वर खोजें
        servers = await client.marketplace(gpu=gpu_model, max_price_usd=max_price)
        servers.sort(key=lambda s: s.price_usd or float("inf"))

        needed = target_workers - active_count
        candidates = servers[:needed]

        if len(candidates) < needed:
            print(f"केवल {len(candidates)} सर्वर उपलब्ध हैं (ज़रूरत {needed} की है)")

        # 3. तैनात करें
        for server in candidates:
            try:
                order = await client.create_order(
                    server_id=server.id,
                    image=image,
                    type="on-demand",
                    currency="bitcoin",
                    ssh_password="WorkerPass123",
                    ports={"22": "tcp"}
                )
                print(f"सर्वर {server.id} पर तैनात किया गया → ऑर्डर {order.id}")
            except CloreAPIError as e:
                print(f"सर्वर {server.id} पर तैनात करने में विफल: {e}")

asyncio.run(auto_scale())
```

***

## अगले चरण

* [CLI ऑटोमेशन](/guides/guides_v2-hi/advanced/cli-automation.md) — Bash स्क्रिप्ट, CI/CD, बैच ऑपरेशन्स
* [बैच प्रोसेसिंग](/guides/guides_v2-hi/advanced/batch-processing.md) — Clore GPU पर बड़े वर्कलोड प्रोसेस करें
* [API एकीकरण](/guides/guides_v2-hi/advanced/api-integration.md) — AI सेवाओं को अपने ऐप्स से कनेक्ट करें


---

# 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/guides/guides_v2-hi/advanced/python-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.
