Skip to content
ModelsRankingsChatDocsPricing

Developer docs

Quickstart

The gateway speaks the OpenAI wire protocol. Anything that accepts a base URL and a bearer key works unchanged.

Authentication

Send your key in the Authorization header. Base URL: https://api.token265.com/v1.

Authorization: Bearer sk-or-v1-...

First request

curl https://api.token265.com/v1/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      {"role": "system", "content": "You are concise."},
      {"role": "user", "content": "Explain tokenisation in one sentence."}
    ]
  }'
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.token265.com/v1',
  apiKey: process.env.OPENROUTER_KEY,
});

const res = await client.chat.completions.create({
  model: 'openai/gpt-4o-mini',
  messages: [{ role: 'user', content: 'hello' }],
});

Streaming

Set stream: true and read server-sent events. Add stream_options: { "include_usage": true } to receive a final usage frame.

const stream = await client.chat.completions.create({
  model: 'anthropic/claude-sonnet-4',
  stream: true,
  stream_options: { include_usage: true },
  messages: [{ role: 'user', content: 'write a haiku' }],
});

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

Model routing

Model ids are author/model. Requests are routed to a healthy provider for that id using live price and latency; if the first provider fails, the request retries on the next one before any token is charged twice.

  • Model metadata and prices: /models
  • Availability is enforced per key group; a model that is not routed returns 404

Errors

StatusMeaningFix
401Key missing or revokedCreate a new key on the API keys page
402Insufficient creditsTop up the account
404Model not routedCheck the id on /models
429Rate limitedBack off exponentially; raise limits on the console
5xxProvider failure after retriesRetry; the router already failed over

Rate limits

Limits apply per key and per account, and are returned in the x-ratelimit-* headers. Raise them from the console under 系统设置 → 限流.

Admin console

渠道、用户、兑换码、日志都在 new-api 控制台管理,与本前端共用同一套账号体系。

打开管理后台