> ## Documentation Index
> Fetch the complete documentation index at: https://docs.smartlyq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> The official SmartlyQ SDK for Python.

<Info>
  **Install:** `pip install smartlyq` · [GitHub](https://github.com/SmartlyQ/smartlyq-python) · [PyPI](https://pypi.org/project/smartlyq/) · Python 3.9+, built on httpx.
</Info>

## Quickstart

```python theme={null}
from smartlyq import SmartlyQ

sq = SmartlyQ()  # reads SMARTLYQ_API_KEY, or pass api_key="sqk_live_..."

# Who am I?
me = sq.account.get_me()

# Publish a social post
post = sq.social.create_post({
    "text": "Hello from the SmartlyQ SDK!",
    "account_ids": ["acc_123"],
})

# Generate an image with AI
image = sq.images.generate({"prompt": "A minimalist product shot of a smart speaker"})
```

Every API resource is an attribute on the client - `sq.social`, `sq.images`, `sq.videos`, `sq.articles`, `sq.seo`, `sq.contacts`, `sq.chatbots`, `sq.captain`, `sq.workspaces`, `sq.profiles`, and the rest - with snake\_case method names mirroring the other SDKs.

## Configuration

```python theme={null}
sq = SmartlyQ(
    api_key="sqk_live_...",  # or set SMARTLYQ_API_KEY
    timeout=60.0,             # per-request timeout (seconds)
    max_retries=2,            # automatic retries on 429/5xx
)
```

Per-request options are keyword arguments on every method:

```python theme={null}
sq.social.create_post(
    body,
    idempotency_key="my-unique-key",  # safe retries for writes
    profile_id="prof_123",            # act on behalf of a managed Profile
    timeout=10.0,
)
```

The client is a context manager if you want deterministic cleanup:

```python theme={null}
with SmartlyQ() as sq:
    sq.account.get_me()
```

## Async jobs

Generation endpoints return a job - poll it until it completes (see [Async jobs](/guides/async-jobs)):

```python theme={null}
import time

result = sq.videos.generate({"prompt": "A 5s product teaser"})
job_id = result["data"]["job_id"]

job = sq.jobs.get(job_id)
while job["data"]["status"] in ("queued", "processing"):
    time.sleep(3)
    job = sq.jobs.get(job_id)
print(job["data"]["result"])
```

## Error handling

```python theme={null}
from smartlyq import SmartlyQ, SmartlyQError

try:
    sq.articles.generate({"topic": "AI trends"})
except SmartlyQError as err:
    print(err.status_code, err.code, err, err.request_id)
```

The full method reference lives in the [repository README](https://github.com/SmartlyQ/smartlyq-python#api-reference); request and response schemas are in the [API Reference](/api-reference/account/get-me).

## Next steps

<CardGroup cols={3}>
  <Card title="API Reference" icon="book" href="/api-reference/account/get-me">
    Request and response schemas for every endpoint.
  </Card>

  <Card title="Async jobs" icon="clock" href="/guides/async-jobs">
    How generation jobs work and how to poll them.
  </Card>

  <Card title="Source on GitHub" icon="github" href="https://github.com/SmartlyQ/smartlyq-python">
    Issues, changelog, and the full method reference.
  </Card>
</CardGroup>
