Skip to content

Integration Guide & Assistant Conventions ​

Welcome to Tokenlio Developer Docs. Tokenlio provides a unified, enterprise-grade AI API gateway compatible with standard OpenAI, Anthropic, and Google protocols.

Access frontier models like openai/gpt-6-astra, anthropic/claude-opus-5.5, and deepseek/deepseek-v4-pro through a single endpoint with automated failover and transparent billing.


Video API ​

Choose either interface independently. Use the request and response format for the selected API.

Seedance Native API (v3) ​

Unified Video API (v1) ​

Image API ​

⚡ Quick Endpoints & Base URLs ​

Protocol / UsageBase URLAuth Header Format
OpenAI Compatible (/v1)https://api.tokenlio.aiAuthorization: Bearer <TOKENLIO_API_KEY>
Anthropic Compatible (/v1/messages)https://api.tokenlio.aix-api-key: <TOKENLIO_API_KEY> or Bearer
Developer Consolehttps://api.tokenlio.aiWeb session / SSO
Model Marketplacehttps://api.tokenlio.ai/marketplacePublicly browsable

HTTP Base URL and SDK configuration are different

For raw HTTP (curl / fetch), use https://api.tokenlio.ai as the Base URL and include /v1 in each endpoint path. Set OpenAI Python/Node SDK base_url / baseURL to https://api.tokenlio.ai/v1 because those SDKs append resource paths. Anthropic SDK / Claude Code uses the origin https://api.tokenlio.ai and adds its own versioned path. Do not append the version twice.


🛠️ Tool & Assistant Setup (Cursor, Claude Code, Windsurf) ​

You can drop Tokenlio directly into your favorite development tools without custom plugins:

1. Cursor IDE Setup ​

Navigate to Cursor Settings ➔ Models ➔ OpenAI API Key:

  1. Check Override OpenAI Base URL.
  2. Set Base URL: https://api.tokenlio.ai
  3. Enter your Tokenlio API Key (sk-tokenlio-...).
  4. Add desired model IDs: openai/gpt-6-astra, anthropic/claude-opus-5.5, deepseek/deepseek-v4-pro.

2. Claude Code CLI Setup ​

In your terminal or .bashrc / .zshrc:

bash
export ANTHROPIC_BASE_URL="https://api.tokenlio.ai"
export ANTHROPIC_AUTH_TOKEN="sk-tokenlio-your-key-here"
export ANTHROPIC_MODEL="anthropic/claude-opus-5.5"

3. Continue / VS Code Setup ​

In your ~/.continue/config.json:

json
{
  "models": [
    {
      "title": "Tokenlio GPT-6 Astra",
      "provider": "openai",
      "model": "openai/gpt-6-astra",
      "apiKey": "sk-tokenlio-your-key",
      "apiBase": "https://api.tokenlio.ai"
    },
    {
      "title": "Tokenlio Claude Opus 5.5",
      "provider": "openai",
      "model": "anthropic/claude-opus-5.5",
      "apiKey": "sk-tokenlio-your-key",
      "apiBase": "https://api.tokenlio.ai"
    }
  ]
}

🚀 SDK Integration Examples ​

Python (OpenAI SDK) ​

python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokenlio.ai/v1",
    api_key=os.environ.get("TOKENLIO_API_KEY", "sk-tokenlio-your-key")
)

# Chat completion with streaming
response = client.chat.completions.create(
    model="openai/gpt-6-astra",
    messages=[
        {"role": "system", "content": "You are an expert systems engineer."},
        {"role": "user", "content": "Explain Anycast routing resilience in 3 sentences."}
    ],
    stream=True
)

for chunk in response:
    content = chunk.choices[0].delta.content or ""
    print(content, end="", flush=True)
print()

Node.js / TypeScript ​

typescript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.tokenlio.ai/v1',
  apiKey: process.env.TOKENLIO_API_KEY || 'sk-tokenlio-your-key',
});

async function main() {
  const stream = await client.chat.completions.create({
    model: 'anthropic/claude-opus-5.5',
    messages: [{ role: 'user', content: 'Generate a TypeScript union validator.' }],
    stream: true,
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
  }
}

main();

cURL (Anthropic Messages API Compatible) ​

bash
curl https://api.tokenlio.ai/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: sk-tokenlio-your-key" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "anthropic/claude-opus-5.5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, Claude via Tokenlio!"}
    ]
  }'

🔍 Context Endpoints for LLMs & Agents ​

Like modern developer documentation, Tokenlio exposes machine-readable indexes for automated AI agents and web crawlers:

  • /llms.txt: Standard documentation index and routing table for LLM agent discovery.
  • Model marketplace: Real-time publicly accessible model catalog with full context limits, multi-level prompt caching rates, and input/output pricing.

⚠️ Common Status Codes & Troubleshooting ​

HTTP CodeError ReasonResolution
401 UnauthorizedInvalid key format or revoked keyEnsure API key begins with sk-tokenlio- and is active in your Workspace.
402 Payment RequiredWorkspace balance exhaustedTop up your workspace balance in the Tokenlio Console.
404 Model Not FoundIncorrect model ID or unsupported routeBrowse Models Catalog for exact IDs (e.g. openai/gpt-6-astra).
429 Too Many RequestsUpstream rate limit or concurrency peakTokenlio automatically fails over across 28 PoP nodes within 10ms. Retry with backoff if sustained.

🧭 Next Steps ​

Access leading AI models through one unified API