Documentation menu
Get started

Quickstart

Make a first TokenAir request using the OpenAI SDK and a TokenAir API key.

TutorialLast updated: July 2, 2026

What you need

  • A TokenAir account with API access enabled.
  • A TokenAir API key from Console > API Key Management.
  • A terminal with curl. Node.js 18+ or Python 3.9+ is optional for the SDK examples.

Step 1: Set environment variables

Keep credentials out of source code. Set the base URL and API key in your shell or deployment environment.

export TOKENAIR_BASE_URL="https://api.tokenair.ai/v1"
export TOKENAIR_API_KEY="your_tokenair_api_key"

Step 2: Send a curl request

Use /chat/completions to verify that your key, base URL, and selected model ID work before changing application code.

curl "$TOKENAIR_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $TOKENAIR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-mini",
    "messages": [
      { "role": "user", "content": "Reply with one short sentence." }
    ]
  }'

Step 3: Use the OpenAI Node.js SDK

Install the SDK if your app runs on Node.js, then keep the existing OpenAI client shape and point baseURL at TokenAir.

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOKENAIR_API_KEY,
  baseURL: process.env.TOKENAIR_BASE_URL,
});

const response = await client.chat.completions.create({
  model: "gpt-5-mini",
  messages: [{ role: "user", content: "Hello TokenAir" }],
});

console.log(response.choices[0].message.content);

Step 4: Use the OpenAI Python SDK

Python uses the same two environment variables and the same OpenAI-compatible chat completions shape.

pip install --upgrade openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TOKENAIR_API_KEY"],
    base_url=os.environ["TOKENAIR_BASE_URL"],
)

response = client.chat.completions.create(
    model="gpt-5-mini",
    messages=[{"role": "user", "content": "Hello TokenAir"}],
)

print(response.choices[0].message.content)

Verify the result

A successful call returns a chat completion response with achoices array. If you receive a 401 response, check the API key. If you receive a 404 or model error, confirm that the model ID is enabled for your account.

What you built

You now have a working TokenAir request path using the same OpenAI-compatible request structure your app can use in production. Keep the key server-side, then move on to migration and error handling before routing real user traffic.

Next steps