Examples
Python example
Call TokenAir from Python with the official OpenAI SDK.
Install
pip install --upgrade openaiSet environment variables
export TOKENAIR_BASE_URL="https://api.tokenair.ai/v1"
export TOKENAIR_API_KEY="your_tokenair_api_key"Run a request
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TOKENAIR_API_KEY"],
base_url=os.environ["TOKENAIR_BASE_URL"],
)
completion = client.chat.completions.create(
model="gpt-5-mini",
messages=[
{"role": "system", "content": "You write concise implementation notes."},
{"role": "user", "content": "Give me a three-step API migration checklist."},
],
)
print(completion.choices[0].message.content)Verify output
Run the file from a server-side Python environment. A successful response prints the assistant message. Keep the API key in your process environment or secret manager, not in the Python file.