Developer documentation

Start with one command.

Connect Codex automatically, or use the API directly with the models available to your account.

RESTJSONAccount scoped
Automatic setup

Set up in one command.

Connect Codex to AI Providers without manually editing configuration files.

The setup utility verifies your account, discovers your available models, and configures Codex automatically.

Terminal
$ npx @aiproviders/setup
  1. 1Get your AI Providers API key.
  2. 2Open Terminal or PowerShell.
  3. 3Run: npx @aiproviders/setup
  4. 4Paste your API key into the secure prompt.
  5. 5Start Codex.
Secure key entry
Automatic model discovery
Config backup
Safe rollback
No generation request during setup

Use --dry-run to preview changes. The setup process validates configuration and available models but does not send a generation request. Your key is stored locally in your Codex configuration; keep that file private.

Authentication

Send your customer key in the Authorization header. Keep keys server-side; never put them in browser bundles, URLs, or Git.

Usage limits are enforced before model work begins.

Requests stop when account access, model access, or available tokens do not permit the operation.

Models

Call GET /models with your API key. The response lists customer-facing models enabled by the platform. A model may remain listed while temporarily unavailable; use its availability status and retry a different model when needed.

Server-authoritative response shape
{
  "object": "list",
  "data": [{ "id": "<available-model-id>" }]
}

API examples

Use a model ID returned by your authenticated GET /models request.

JavaScript
import OpenAI from "openai";
const client = new OpenAI({
  apiKey: process.env.AI_PROVIDERS_API_KEY,
  baseURL: "https://api.aiproviders.online/v1",
});
const response = await client.chat.completions.create({
  model: "your-enabled-model",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0]?.message);
Python
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["AI_PROVIDERS_API_KEY"],
    base_url="https://api.aiproviders.online/v1",
)
response = client.chat.completions.create(
    model="your-enabled-model",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
cURL
curl https://api.aiproviders.online/v1/chat/completions \
  -H "Authorization: Bearer $AI_PROVIDERS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-enabled-model","messages":[{"role":"user","content":"Hello"}]}'

Manual configuration

Use npx @aiproviders/setup for the safest path. Open the advanced details only when you need to manage Codex configuration yourself.

Advanced setup
%USERPROFILE%\\.codex\\config.toml
# Manual setup only. The installer writes this safely for you.
model = "your-enabled-model"
model_provider = "aiproviders"

[model_providers.aiproviders]
name = "AI Providers"
base_url = "https://api.aiproviders.online/v1"
wire_api = "responses"
requires_openai_auth = false
experimental_bearer_token = "YOUR_AI_PROVIDERS_API_KEY"

Errors

Errors use a stable envelope with neutral messages. Common codes include model_not_allowed, token_limit_reached, invalid_api_key, account_suspended, and service_temporarily_unavailable.

{"error":{"code":"token_limit_reached","message":"Your allocated token balance has been exhausted. Please contact support.","request_id":"req_..."}}
Open your portal