Documentation menu
Migration

How to migrate from the OpenAI API

Move an existing OpenAI SDK integration to TokenAir by changing the base URL and API key.

How-toLast updated: July 2, 2026

Prerequisites

  • An existing OpenAI-compatible SDK integration.
  • A TokenAir API key.
  • A model ID enabled for your TokenAir account.

Step 1: Change environment variables

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

Step 2: Point the SDK at TokenAir

import OpenAI from "openai";

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

Step 3: Verify model IDs

Model names are not always identical across accounts or providers. Use the model IDs shown in your TokenAir account or onboarding notes. Start with a non-production request before switching live traffic.

Step 4: Roll out gradually

  1. Send a single test request.
  2. Run a small batch against your normal prompt mix.
  3. Compare latency, error rate, and output quality.
  4. Confirm your app handles 401, 403, 404, 429, and 5xx responses.
  5. Move production traffic gradually after the checks pass.

Step 5: Keep a rollback path

Keep provider configuration outside the application code path where possible. If you need to roll back, switch environment variables and restart the service instead of editing source code during an incident.

Verification

Your migration is working when your application receives successful chat completion responses from https://api.tokenair.ai/v1 and your own logs show expected status codes, latency, and output shape.

Next steps