XRToken API Docs

Quick Start

Connect to 50+ AI models in a few lines of code

API Configuration
After saving, the Try It panel below sends real requests with this key.
Base: api.xrtoken.ai

XRToken is compatible with both OpenAI and Anthropic API formats. Just change base_url and api_key to get started.

Endpoints

PurposeFull URLAuthentication
Chat (OpenAI)https://YOUR_API_BASE/v1/chat/completionsAuthorization: Bearer YOUR_API_KEY
Chat (Anthropic)https://YOUR_API_BASE/v1/messagesx-api-key: YOUR_API_KEY
Web searchhttps://YOUR_API_BASE/v1/searchAuthorization: Bearer YOUR_API_KEY
Doubao Agenthttps://YOUR_API_BASE/v1/agent/chat/completionsAuthorization: Bearer YOUR_API_KEY
Agent opening / config / eventshttps://YOUR_API_BASE/v1/agent/opening-questions etc.Authorization: Bearer YOUR_API_KEY
Model Listhttps://YOUR_API_BASE/v1/modelsNone required

The base_url format differs by SDK:

  • OpenAI SDK: base_url="https://YOUR_API_BASE/v1" (SDK appends /chat/completions)
  • Anthropic SDK: base_url="https://YOUR_API_BASE" (SDK appends /v1/messages)

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://YOUR_API_BASE/v1",
    api_key="YOUR_API_KEY"
)

response = client.chat.completions.create(
    model="doubao-seed-2.0-pro",
    messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="doubao-seed-2.0-pro",
    messages=[{"role": "user", "content": "Write a poem"}],
    stream=True
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Node.js (OpenAI SDK)

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://YOUR_API_BASE/v1',
  apiKey: 'YOUR_API_KEY',
});

const response = await client.chat.completions.create({
  model: 'doubao-seed-2.0-pro',
  messages: [{ role: 'user', content: 'Hello' }],
});
console.log(response.choices[0].message.content);

// Streaming
const stream = await client.chat.completions.create({
  model: 'doubao-seed-2.0-pro',
  messages: [{ role: 'user', content: 'Write a poem' }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Python (Anthropic SDK)

import anthropic

client = anthropic.Anthropic(
    base_url="https://YOUR_API_BASE",
    api_key="YOUR_API_KEY"
)

message = client.messages.create(
    model="MiniMax-M2.7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}]
)
print(message.content[0].text)

# Streaming
with client.messages.stream(
    model="MiniMax-M2.7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a poem"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="")

cURL

OpenAI format:

curl -X POST https://YOUR_API_BASE/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seed-2.0-pro",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": false
  }'

Anthropic format:

curl -X POST https://YOUR_API_BASE/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M2.7",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

For agents

Do not paste HTML pages into the chat. Send the prompt below; the agent reads the docs index, then fetches .md pages as needed. Append .md to any docs URL for that page's Markdown.

Read https://xrtoken.ai/llms.txt first. It is the public XRToken API docs index. Fetch the .md links you need; do not assume unlisted endpoints exist.

On this page