Documentation

Documentation

666 AI speaks three protocols. Whatever you already use will most likely work — change one address, paste one key, leave the rest alone.

Replace YOUR-ENDPOINT in the examples below with your own endpoint — it is shown on your console home page, or let the setup guide generate the config for you.

Quick start

From signup to a working request in about three minutes.

1. Get a key

Create one on the Keys page. Use a separate key per project and set a spend cap.

2. Set the address

BASE URL
https://YOUR-ENDPOINT/v1

3. Verify

curl
curl https://YOUR-ENDPOINT/v1/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-flash",
       "messages":[{"role":"user","content":"hi"}]}'

# A JSON response means it works

Protocols

One key, one balance, three protocols. You don't need separate keys for different tools.

Live
OpenAI
The most widely supported. Nearly every tool and SDK speaks it.
/v1/chat/completions
Live
Anthropic
Native format for Claude Code and Cline. No adapter needed.
/v1/messages
Coming
Gemini
Google's native format, for projects already written against Gemini.
/v1beta/models
Not sure which? Use the OpenAI format. Best compatibility, and switching models needs no code change.

OpenAI format

The official openai library works as-is. Only base_url changes.

Python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_KEY",
    base_url="https://YOUR-ENDPOINT/v1"
)

resp = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role": "user", "content": "你好"}]
)
print(resp.choices[0].message.content)
Node.js
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_KEY",
  baseURL: "https://YOUR-ENDPOINT/v1"
});

const resp = await client.chat.completions.create({
  model: "deepseek-v4-flash",
  messages: [{ role: "user", content: "你好" }]
});
console.log(resp.choices[0].message.content);

Anthropic format

Using Claude Code or the Anthropic SDK? Use this format, no translation layer. Note this address does not include /v1.

Claude Code
# Add to ~/.zshrc or ~/.bashrc
export ANTHROPIC_BASE_URL="https://YOUR-ENDPOINT"
export ANTHROPIC_AUTH_TOKEN="YOUR_KEY"

# Reopen the terminal, then just run
claude
Python SDK
from anthropic import Anthropic

client = Anthropic(
    api_key="YOUR_KEY",
    base_url="https://YOUR-ENDPOINT"
)

msg = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "你好"}]
)
print(msg.content[0].text)

Gemini format

Coming soon. Until then, Gemini models work through the OpenAI format above with identical functionality.

curl
# Call Gemini like this
curl https://YOUR-ENDPOINT/v1/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-3.5-flash","messages":[{"role":"user","content":"hi"}]}'

Editors & agents

Cursor

  1. Settings → Models → OpenAI API Key
  2. Turn on Override Base URL
  3. Enter the URL and key, hit Verify

Claude Code

  1. Set ANTHROPIC_BASE_URL
  2. Set ANTHROPIC_AUTH_TOKEN
  3. Reopen the terminal, run claude

Cline / Roo Code

  1. Provider: OpenAI Compatible
  2. Enter base URL and key
  3. Model ID from the catalog

Continue

  1. Edit config.json
  2. Set provider to openai
  3. Add the apiBase field

Apps & extensions

ChatBox / NextChat

  1. Choose OpenAI as provider
  2. Enter the gateway address
  3. Type the model name manually

Immersive Translate

  1. Add a custom AI service
  2. Endpoint /v1/chat/completions
  3. Pick a cheap fast model

Open WebUI

  1. Settings → Connections
  2. Add an OpenAI API connection
  3. Enter URL and key, save

Frameworks

Dify

  1. Provider: OpenAI-API-compatible
  2. Enter API endpoint and key
  3. Leave other nodes unchanged

n8n

  1. Create an OpenAI credential
  2. Set base URL to the gateway
  3. Select it in your node

LangChain

  1. Use ChatOpenAI
  2. Pass base_url
  3. Rest of the chain is unchanged

Streaming / tool calling / vision

These behave exactly as with the official APIs — no parameter changes. Support depends on the model; the catalog marks which.

Streaming
stream = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{"role":"user","content":"写一首诗"}],
    stream=True
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Prompt caching

If every request carries the same long prefix — system prompt, project code, documents — the cached portion is billed at a steep discount. Coding and agent workloads benefit most.

Put the unchanging content first and the varying content last. Order is what determines hit rate.

Error codes

StatusMeaningWhat to do
401Invalid or disabled keyCheck the key was copied in full and still exists
402Insufficient balanceTop up in the console
404Model not foundCheck the ID against the catalog
429Too many requestsLower concurrency or retry shortly
500Upstream errorThe gateway retries a backup route automatically. Contact us if it persists

Quotas & limits

Every key can carry its own spend cap and model allowlist. Use one key per project — then any single leak has a fixed maximum loss and you just delete and recreate it.

Failed requests are not billed. Timeouts and upstream errors never reach your invoice.
←