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

# Switch to Token Factory

Nebius Token Factory provides an OpenAI-compatible API, making it easy to migrate existing OpenAI integrations with minimal changes.

## Switching from OpenAI

Here is a standard OpenAI example:

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

client = OpenAI()
response = client.responses.create(
    model="gpt-5.2",
    input="Write a one-sentence bedtime story about a unicorn."
)
print(response.output_text)
```

To switch to Nebius Token Factory:

1. **Set the `base_url`** to the Token Factory endpoint:\
   `https://api.tokenfactory.nebius.com/v1/`
2. **Set your API key** using the `NEBIUS_API_KEY` environment variable. Get your key at: [https://tokenfactory.nebius.com/](https://tokenfactory.nebius.com/)
3. **Specify the model** you want to use (for example, `moonshotai/Kimi-K2.5`).

That's it - no other changes are required.

## Full Example Using Token Factory

```python lines theme={null}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokenfactory.nebius.com/v1/",
    api_key=os.environ.get("NEBIUS_API_KEY")
)

response = client.chat.completions.create(
    model="moonshotai/Kimi-K2.5",
    messages=[
        {
            "role": "system",
            "content": "You are a helpful assistant"
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Write a haiku about cats"
                }
            ]
        }
    ]
)

print(response.to_json())
```
