Skip to content
StatusGet API key

OpenAI SDK

TOKEN is OpenAI-compatible. Most clients work after changing two settings:

Setting Value
Base URL https://api.thetoken.dev/v1
API key your tkn_... key from the console
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.thetoken.dev/v1", api_key=os.environ["TOKEN_API_KEY"])
response = client.chat.completions.create(
model="deepseek/deepseek-v4.1-flash",
messages=[
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "What is an API gateway?"},
],
max_tokens=2048,
)
print(response.choices[0].message.content)

/v1/responses works with the same client:

response = client.responses.create(
model="openai/gpt-oss-120b",
input="Name three prime numbers.",
)
print(response.output_text)

The SDKs also read their settings from the environment, which is handy for tools built on them:

Terminal window
export OPENAI_BASE_URL="https://api.thetoken.dev/v1"
export OPENAI_API_KEY="$TOKEN_API_KEY"

Fields and models of each: API reference.

Use TOKEN model IDs such as moonshotai/kimi-k3 or zai-org/glm-5.3. Short aliases such as kimi-k3 work too. OpenAI’s hosted models (for example GPT-5) are not served.

In the console, under API Keys, each key can have:

  • a spending limit
  • an expiry date
  • a model allow-list
  • a group (for example the us-eu-hosted privacy group)

The SDKs retry 429 and 5xx responses twice by default, with backoff. That fits TOKEN’s limits; see Errors and rate limits.