Chat API
One key,
access everylarge model
Compatible with OpenAI (Chat Completions / Responses) and the Anthropic protocol. Swap base_url for Lumen and call Claude, GPT, Gemini, DeepSeek and more from your existing SDK, client, Claude Code or Codex, billed by token.
Endpoints
OpenAI Chat Completions compatible. Works with most clients and SDKs.
OpenAI Responses compatible. Works with the Codex CLI and the latest OpenAI SDK.
Anthropic Messages compatible. Works with Claude Code and the Anthropic SDK.
Base URL https://lumen.mengfanlab.top· Every endpoint supports streaming (SSE) and non-streaming, with response shapes matching the corresponding official protocol.
Authentication
Authenticate with a Bearer key
Create a key starting with sk-lumen- in the console and put it in the request header. Each call is billed from your account credits at the unit price of the chosen model and group.
Authorization: Bearer sk-lumen-•••
- · The key is both identity and quota, so keep it safe and revoke it in the console if leaked.
- · /v1/messages uses the Anthropic protocol; authenticate with Authorization: Bearer (not x-api-key).
Quick start
Start a conversation
Pick either protocol. The examples below use Claude Opus 4.8 and are all streaming requests.
POST /v1/chat/completions · OpenAI compatible
curl https://lumen.mengfanlab.top/v1/chat/completions \
-H "Authorization: Bearer sk-lumen-•••" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-8",
"stream": true,
"messages": [
{ "role": "user", "content": "用一句话介绍你自己" }
]
}'POST /v1/messages · Anthropic compatible
curl https://lumen.mengfanlab.top/v1/messages \
-H "Authorization: Bearer sk-lumen-•••" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-8",
"max_tokens": 1024,
"stream": true,
"messages": [
{ "role": "user", "content": "用一句话介绍你自己" }
]
}'Request parameters
Common fields
Field semantics match the official docs of the chosen protocol; here are the most commonly used ones.
Model code, see "Supported models" below.
List of conversation messages, structured per the corresponding protocol (role + content).
Defaults to true for SSE streaming; set to false for a single response.
Maximum tokens to generate. Required for Anthropic /v1/messages.
Sampling temperature, controls randomness.
Other fields (tools, tool_choice, system, stop, etc.) are passed through to the upstream per protocol with identical behavior.
Streaming
SSE streaming responses
When stream is true, the response is text/event-stream, returning incremental content chunk by chunk, with the same shape as the official APIs.
- · OpenAI: each frame is a data: {...} chunk, the last frame carries usage, ending with data: [DONE].
- · Anthropic: an event stream of message_start / content_block_delta / message_delta / message_stop.
- · Billing is settled after the stream ends, based on actual token usage.
Supported models
Pass one of these codes
Just put the code in the model field. The full list and live unit prices are in the console.
Connect Claude Code
Point Claude Code at Lumen
Set the environment variables, then run claude directly. base_url should not include /v1; Claude Code appends /v1/messages automatically.
ANTHROPIC_BASE_URL=https://lumen.mengfanlab.top \ ANTHROPIC_AUTH_TOKEN=sk-lumen-••• \ ANTHROPIC_MODEL=claude-opus-4-8 \ ANTHROPIC_SMALL_FAST_MODEL=claude-sonnet-4-6 \ claude
Authenticate with ANTHROPIC_AUTH_TOKEN (sends Authorization: Bearer); use Lumen model codes. Some low-price groups are restricted to the Claude Code client only.
Connect Codex
Point the Codex CLI at Lumen
Codex uses the OpenAI Responses protocol. After installing, write two files under ~/.codex: config.toml sets base_url and the model, auth.json holds the key.
1 · Install the Codex CLI
npm i -g @openai/codex@latest
2 · ~/.codex/config.toml
model_provider = "lumen" model = "gpt-5.5" [model_providers.lumen] name = "lumen" base_url = "https://lumen.mengfanlab.top/v1" wire_api = "responses" requires_openai_auth = true
3 · ~/.codex/auth.json
{
"OPENAI_API_KEY": "sk-lumen-•••"
}4 · Run
codex
- · base_url must include /v1; Codex appends /v1/responses automatically; wire_api must be responses.
- · Put the key in auth.json's OPENAI_API_KEY (starting with sk-lumen-); Codex sends it as Authorization: Bearer. Use a key from a regular group (cc_only groups are Claude Code only).
- · Set model to a Lumen model code, see "Supported models" above; restart codex after changing the config.
Error codes
Invalid request body.
Key missing, invalid, or revoked.
Insufficient account credits.
This group is restricted (e.g. Claude Code client only).
The requested model does not exist in this group.
Upstream rate limit or error; the gateway passes the upstream status through unchanged.
Questions or partnerships, email [email protected].