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

# Python SDK Installation

> How to install and set up the AI Stats Python SDK

<Note type="warning">
  **SDKs are in very early alpha**: We're working as hard as we can to get them into a stable state. Please bear with us as we iterate rapidly.
</Note>

## Installation

```bash theme={null}
pip install ai-stats-py-sdk
```

## Requirements

* Python 3.10+

## Setup

### API key

Create an API key in the [AI Stats Dashboard](https://ai-stats.phaseo.app/gateway/keys).

### Environment variable

```bash theme={null}
export AI_STATS_API_KEY="aistats_v1_sk_<kid>_<secret>"
```

### Basic usage

```python theme={null}
from ai_stats import AIStats
import os

client = AIStats(api_key=os.environ["AI_STATS_API_KEY"])

response = client.generate_text(
    {
        "model": "openai/gpt-5-nano",
        "messages": [{"role": "user", "content": "Hello!"}],
    }
)

print(response["choices"][0]["message"]["content"])
```

### Optional client configuration

```python theme={null}
from ai_stats import AIStats

client = AIStats(
    api_key="your-api-key",
    base_url="https://api.phaseo.app/v1",
    timeout=30.0,
)
```

## Next steps

* Check out the [Usage Guide](./usage.mdx)
* Browse the [API Reference](../../api-reference/introduction.mdx)
