Reference
API examples
The API matches the official OpenAI and Anthropic formats. Existing code only needs a new base_url and key; nothing else changes.
One key works with every model. Your key is stored only in your own browser and is never uploaded to any server.
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /v1/messages | Anthropic Messages (native Claude format) |
| POST | /v1/chat/completions | OpenAI Chat Completions |
| POST | /v1/responses | OpenAI Responses (used by Codex) |
| GET | /v1/models | Models available to the current key |
Authentication: the OpenAI format uses Authorization: Bearer sk-...; the Anthropic format uses x-api-key: sk-.... Both headers are accepted.
OpenAI format
Terminal
pip install openaimain.py
from openai import OpenAI
client = OpenAI(
base_url="https://api.tokilabs.xyz/v1",
api_key="sk-your-key",
)
resp = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(resp.choices[0].message.content)Terminal
npm install openaiindex.mjs
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.tokilabs.xyz/v1",
apiKey: "sk-your-key",
});
const resp = await client.chat.completions.create({
model: "gpt-6.1-sol",
messages: [{ role: "user", content: "Introduce yourself in one sentence" }],
});
console.log(resp.choices[0].message.content);Terminal (macOS / Linux / Git Bash)
curl https://api.tokilabs.xyz/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"stream": true,
"messages": [{"role": "user", "content": "Introduce yourself in one sentence"}]
}'Anthropic format
The Anthropic SDK base_url does not include
/v1.Terminal
pip install anthropicmain.py
import anthropic
client = anthropic.Anthropic(
base_url="https://api.tokilabs.xyz",
api_key="sk-your-key",
)
msg = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(msg.content[0].text)Terminal
npm install @anthropic-ai/sdkindex.mjs
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.tokilabs.xyz",
apiKey: "sk-your-key",
});
const msg = await client.messages.create({
model: "claude-sonnet-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Introduce yourself in one sentence" }],
});
console.log(msg.content[0].text);Terminal (macOS / Linux / Git Bash)
curl https://api.tokilabs.xyz/v1/messages \
-H "x-api-key: sk-your-key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Introduce yourself in one sentence"}]
}'Read from environment variables
Both official SDKs read environment variables automatically. Once OPENAI_BASE_URL (set to https://api.tokilabs.xyz/v1) and OPENAI_API_KEY are set, you do not need the endpoint or key in code:
Python
from openai import OpenAI
client = OpenAI() # Uses OPENAI_BASE_URL and OPENAI_API_KEY automaticallyThe Anthropic SDK reads its key from
ANTHROPIC_API_KEY, while Claude Code uses ANTHROPIC_AUTH_TOKEN. When using the Anthropic SDK in code, also set ANTHROPIC_API_KEY.