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)
- Start integrating: Quick start · Request conventions · Models and inputs
- Video generation: Create video tasks · Query and manage tasks · Generation callbacks
- Materials and person verification: Material groups and assets · Person verification
- Integration and troubleshooting: Errors, retries and recovery · Agent integration guide
Unified Video API (v1)
- Tasks, billing & private downloads
- Seedance 2.0
- Seedance 2.0 Fast
- Seedance 2.0 Mini
- Seedance 2.5
- Grok Imagine Video · Generation & editing
- Grok Imagine Video 1.5 · Generation
- Wan 3.0
- Wan 3.0 Prime
- HappyHorse 1.0
- HappyHorse 1.1
Image API
- GPT Image 2.5: image generation and editing
- Nano Banana 2.1: generation and reference editing
- Seedream 5.5: generation, transparent PNG and layers
- Seedream 5.0 Flash image API
- Seedream 5.0 Pro image API
- Seedream 5.0 Lite image API
⚡ Quick Endpoints & Base URLs
| Protocol / Usage | Base URL | Auth Header Format |
|---|---|---|
OpenAI Compatible (/v1) | https://api.tokenlio.ai | Authorization: Bearer <TOKENLIO_API_KEY> |
Anthropic Compatible (/v1/messages) | https://api.tokenlio.ai | x-api-key: <TOKENLIO_API_KEY> or Bearer |
| Developer Console | https://api.tokenlio.ai | Web session / SSO |
| Model Marketplace | https://api.tokenlio.ai/marketplace | Publicly 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:
- Check Override OpenAI Base URL.
- Set Base URL:
https://api.tokenlio.ai - Enter your Tokenlio API Key (
sk-tokenlio-...). - 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:
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:
{
"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)
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
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)
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 Code | Error Reason | Resolution |
|---|---|---|
| 401 Unauthorized | Invalid key format or revoked key | Ensure API key begins with sk-tokenlio- and is active in your Workspace. |
| 402 Payment Required | Workspace balance exhausted | Top up your workspace balance in the Tokenlio Console. |
| 404 Model Not Found | Incorrect model ID or unsupported route | Browse Models Catalog for exact IDs (e.g. openai/gpt-6-astra). |
| 429 Too Many Requests | Upstream rate limit or concurrency peak | Tokenlio automatically fails over across 28 PoP nodes within 10ms. Retry with backoff if sustained. |
🧭 Next Steps
Video API: Seedance 2.0 & 2.5 — Model parameters, asynchronous tasks, fixed billing and private downloads.
Quick Start Guide - From account signup to first request in 3 minutes.
Authentication - Manage API keys, permissions, and team workspace isolation.
Models & Pricing Matrix - Browse all supported models and prompt cache discounts.
