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

# Python SDK

> Install the to11 Python SDK, render a prompt, and send it with your own provider client.

The `to11ai-sdk` package gives Python services typed access to to11. You use it to render managed prompts at runtime, shaped for the provider client you already use, and to manage prompts, versions, skills, and project environments from code. It mirrors the [TypeScript SDK](https://to11.ai/docs/reference/typescript-sdk.md) surface with snake\_case, synchronous methods.

The SDK talks to the to11 API (`https://api.to11.ai`). It never sends the model request itself — there is no `.chat()`. Your own provider client (OpenAI, Anthropic, or any other) sends the rendered prompt to the provider, with your own provider key.

The distribution is published as `to11ai-sdk` and imported as `to11ai_sdk`, under the MPL-2.0 license.

## Runtime requirements

* **Python:** 3.10 or later.
* **One runtime dependency:** [Pydantic](https://docs.pydantic.dev/) 2.14.3 or later. The client is synchronous — there is no async client; every method returns its value directly.
* **Credentials:** a to11 API key and a project id. The SDK reads `TO11_API_KEY` and `TO11_PROJECT_ID` from the environment, and `TO11_API_URL` for the API address, which defaults to `https://api.to11.ai`. Run it server-side: a to11 API key must never reach an end user's device.

## Installation

```bash pip theme={null}
pip install to11ai-sdk
```

```bash uv theme={null}
uv add to11ai-sdk
```

```bash poetry theme={null}
poetry add to11ai-sdk
```

Install your provider client, such as `openai` or `anthropic`, separately; the SDK does not depend on it.

## The happy path

Create a client, render a prompt shaped for OpenAI, and send it with your OpenAI client:

```python theme={null}
from to11ai_sdk import create_client
from openai import OpenAI

# Reads TO11_API_KEY and TO11_PROJECT_ID from the environment.
to11 = create_client(format="openai")
openai = OpenAI()  # reads OPENAI_API_KEY

prompt = to11.prompts.render("welcome-message", variables={"name": "Ada"})

res = openai.chat.completions.create(
    **prompt["config"],
    messages=prompt["messages"],
)
```

`prompt["config"]` carries the model settings from the prompt version's **Config** pane, `prompt["messages"]` the rendered messages, and `prompt["metadata"]` which prompt version produced them, for your own logging.

## Where to next

> [card] [Configuration](https://to11.ai/docs/reference/python-sdk/configuration.md)
>
> Client options, credential resolution, and what the client exposes.

> [card] [Rendering prompts](https://to11.ai/docs/reference/python-sdk/rendering-prompts.md)
>
> Formats, the rendered result shape, and the converters.

> [card] [Prompt management](https://to11.ai/docs/reference/python-sdk/prompts.md)
>
> Prompt lifecycle, versions, labels, skills, and project environments.

> [card] [Errors](https://to11.ai/docs/reference/python-sdk/errors.md)
>
> The typed error classes the SDK raises, and how to catch them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.