> For the complete documentation index, see [llms.txt](https://docs.pending.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pending.ai/developer-tools/sdks/python.md).

# Python

The pendingai Python package includes an SDK for the Pending AI APIs, next to the CLI.

The `pendingai` package on [PyPI](https://pypi.org/project/pendingai/) contains the Python SDK as well as the [CLI](https://docs.pending.ai/developer-tools/cli.md). Install it as described in [Installation](https://docs.pending.ai/getting-started/installation.md). This page shows version **0.18.0**, which needs Python 3.11 or later.

## A minimal example

```python
from pendingai import PendingAiClient

client = PendingAiClient()
client.authentication.login()   # opens a browser, then asks which team to use

# PAI Generator: up to 500 molecules in one sample
sample = client.generator.samples.create(size=100)
print(sample.status, len(sample.smiles))

# PAI Retro: queue a retrosynthesis job, then check on it
job = client.retrosynthesis.jobs.create("CC(=O)OC1=CC=CC=C1C(=O)O", number_of_routes=5)
job = client.retrosynthesis.jobs.retrieve(job.id)
print(job.id, job.status)
```

The client exposes one service per API:

| Service                 | Resources                                              |
| ----------------------- | ------------------------------------------------------ |
| `client.authentication` | `login()`, `refresh()`, `logout()`                     |
| `client.generator`      | `models`, `samples`, `sample_batches`                  |
| `client.retrosynthesis` | `engines`, `libraries`, `jobs`, `batches`              |
| `client.synth`          | `searches`, `plans`, `batches`, `engines`, `libraries` |

`client.authentication.login(organization="my-team")` signs in to a team without asking, and `login(device=True)` logs in with a code, for a machine without a browser. A request your team's plan doesn't cover is refused by the API with HTTP `402` and raises an exception. See [Accounts, teams and billing](https://github.com/pendingai/gitbook/tree/main/getting-started/accounts-and-billing.md).

## Tutorial notebook

{% embed url="<https://colab.research.google.com/drive/14WMqrI5gepcgQyXN63nmm0h4vWMFJCkz#scrollTo=5md6N-b7q7c>\_" %}
