Skip to main content
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:
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.eu-west1.nebius.com/v1/
  2. Set your API key using the NEBIUS_API_KEY environment variable. Get your key at: 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

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokenfactory.eu-west1.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())