接入文档Getting Started
纯正、稳定、省钱的官方大模型 API 网关。把代码里的 base_url + api_key 改两行,其余不动 —— Claude 与 OpenAI/GPT 都能接。An official, stable, cost-saving LLM API gateway. Change two lines — base_url + api_key — and keep everything else. Works for both Claude and OpenAI/GPT.
最后更新:Last updated: 2026-10-17
01概述Overview
一句话上手:把现有代码的 base_url + api_key 改两行,其余不动。三个卖点:One line to start: change base_url + api_key in your existing code, keep the rest. Three things we sell:
- 省钱Save money — 走 Claude 时网关自动注入 Prompt Cache,重复 system / 长上下文按缓存价计费(读取约全价 1/10)。你不改一行代码(§07)。on Claude, the gateway auto-injects Prompt Cache; repeated system / long context bills at the cache rate (reads ≈ 1/10 of full price). No code change (§07).
- 纯正 / 不降智Authentic / no downgrade — 走官方上游通道,不静默换小模型、不截断、不改写,原生返回,可自验(§18)。official upstream routing — no silent model swap, no truncation, no rewriting; native responses, self-verifiable (§18).
- 数据边界Data boundary — 网关只记用量与计费元数据、不存请求与响应正文,不设响应缓存;Claude / GPT 上游按其商用条款不用你的内容训练;上游留存与例外见 §17。the gateway records only usage and billing metadata, stores no request or response content, and keeps no response cache; under their commercial terms the Claude / GPT upstreams don't train on your content; upstream retention and exceptions in §17.
独立加拿大主体(Solunar AI Inc.,BC 注册)+ 独立基础设施节点。Independent Canadian entity (Solunar AI Inc., incorporated in BC) on independent infrastructure.
02端点与协议Endpoints & protocols
自助接入只有一个 base_url:https://console.solunarai.com(注册并充值后在 console 生成 key)。它同时支持下面两种协议。Self-serve has a single base_url: https://console.solunarai.com (generate a key in the console after you register and top up). It supports both protocols below.
企业 / 高并发需要专属直连接入?见 §22 联系 service@solunarai.com 单独开通,不走本页自助流程。Enterprise / high-volume needing a dedicated direct endpoint? See §22 — contact service@solunarai.com, handled outside this self-serve flow.
| 协议路径Protocol path | 适用For | 模型名写法(推荐)Model name form (recommended) | Prompt Cache |
|---|---|---|---|
/v1/messages | Anthropic 原生:Anthropic SDK / Claude Code / 全保真Anthropic native: Anthropic SDK / Claude Code / full fidelity | Claude dashClaude dash claude-sonnet-4-6 | ✅ 自动(Claude)auto (Claude) |
/v1/chat/completions | OpenAI 兼容:Cursor / Cline / LangChain / GPTOpenAI compatible: Cursor / Cline / LangChain / GPT | Claude dotClaude dot claude-sonnet-4.6 · GPT gpt-5.5 | ✅ Claude 经网关;GPT 走 OpenAI 自家Claude via gateway; GPT via OpenAI's own |
何时用哪个:要 Claude 全部原生能力(thinking、原生 tool streaming、metadata)→ /v1/messages;工具只说 OpenAI 格式 → /v1/chat/completions;调 GPT → 只走 /v1/chat/completions。做 agent / 多轮工具调用并开扩展思考,务必用 /v1/messages,原因见 原生 vs OpenAI 兼容。Which to use: full Claude native capabilities (thinking, native tool streaming, metadata) → /v1/messages; OpenAI-only tools → /v1/chat/completions; GPT → /v1/chat/completions only. For agents / multi-turn tool use with extended thinking, use /v1/messages — see Native vs OpenAI-compatible.
base_url 取根:Anthropic SDK = https://console.solunarai.com(自动补 /v1/messages);OpenAI SDK = https://console.solunarai.com/v1(自动补 /chat/completions)。curl 用完整路径。In SDKs, base_url is the root: Anthropic SDK = https://console.solunarai.com (appends /v1/messages); OpenAI SDK = https://console.solunarai.com/v1 (appends /chat/completions). curl uses the full path.03鉴权Authentication
注册并充值后,在 console → 令牌 / API Keys 生成 key(sk-…)。两种协议用不同的鉴权头:After you register and top up, generate a key (sk-…) in console → Tokens / API Keys. The two protocols use different auth headers:
| 协议Protocol | 鉴权头Auth header |
|---|---|
/v1/messages | x-api-key: sk-… + anthropic-version: 2023-06-01 + anthropic-version: 2023-06-01 |
/v1/chat/completions | Authorization: Bearer sk-… (OpenAI 风格)(OpenAI style) |
- key 即身份 + 计费主体,勿硬编码进前端 / 公开仓库;泄漏即在 console 吊销重发。A key is identity + billing subject — never hardcode it into a frontend or public repo; revoke and reissue in the console if leaked.
- 同一个 console key 两种协议通用,按上面的头分别带即可。One console key works for both protocols — just send the matching header.
04模型目录与能力矩阵Catalog & capability matrix
完整模型清单 + 单价以登录后 console 为准。下表为能力口径。The full model list + pricing lives in the console after login. The tables below are the capability reference.
Claude 全系Claude family (/v1/messages dash · /v1/chat/completions dot)(/v1/messages dash · /v1/chat/completions dot)
| 模型Model | dash | context | 最大输出max out | tool | vision | thinking | cache |
|---|---|---|---|---|---|---|---|
| Opus 5.5 | claude-opus-5-5 | 1M | 128K | ✓ | ✓ | 始终开启 · effortalways on · effort | ✓ |
| Sonnet 5.5 | claude-sonnet-5-5 | 1M | 128K | ✓ | ✓ | effort · between_toolseffort · between_tools | ✓ |
| Fable 5.1 | claude-fable-5-1 | 1M | 128K | ✓ | ✓ | 始终开启 · effortalways on · effort | ✓ |
| Opus 4.8(旗舰)Opus 4.8 (flagship) | claude-opus-4-8 | 1M | 128K | ✓ | ✓ | 自适应adaptive | ✓ |
| Opus 4.7 | claude-opus-4-7 | 1M | 128K | ✓ | ✓ | 自适应adaptive | ✓ |
| Sonnet 4.6(主力)Sonnet 4.6 (workhorse) | claude-sonnet-4-6 | 1M | 64K | ✓ | ✓ | 自适应adaptive | ✓ |
| Haiku 4.5(省钱/快)Haiku 4.5 (cheap/fast) | claude-haiku-4-5 | 200K | 64K | ✓ | ✓ | 扩展extended | ✓ |
- dot/dash 双名:同一模型有两种写法,推荐
/v1/messages用 dash(claude-sonnet-4-6),/v1/chat/completions用 dot(claude-sonnet-4.6)。确切名称以 console 模型列表为准。dot/dash dual names: each model has two forms; we recommend dash on/v1/messages(claude-sonnet-4-6), and dot on/v1/chat/completions(claude-sonnet-4.6). The exact names are whatever the console model list shows. - 大输出(>16K)请开
stream:true,否则易触发 HTTP 超时。For large outputs (>16K), setstream:trueto avoid HTTP timeouts. - Fable 5.1 的数据留存:Anthropic 对 Fable 系列要求 30 天数据留存、不提供零数据留存,生成的文本带统计水印。选用前请看 Fable 5.1 使用要点 与隐私政策 §3。Fable 5.1 data retention: Anthropic requires 30-day data retention for Fable models, zero data retention is not available, and generated text carries a statistical watermark. See Fable 5.1 essentials and the Privacy Policy §3 before you choose it.
OpenAI / GPTOpenAI / GPT (单名,只走 /v1/chat/completions)(single name, /v1/chat/completions only)
| 模型Model | context | 最大输出max out | 类型type | cache |
|---|---|---|---|---|
gpt-5.5 (旗舰)(flagship) | 1,050,000 | 128,000 | reasoning | OpenAI 自动输入缓存OpenAI auto input cache |
gpt-5.4 (主力)(workhorse) | 1,050,000 | 128,000 | 通用general | OpenAI 自动输入缓存OpenAI auto input cache |
gpt-5.4-mini (便宜)(cheap) | 400,000 | 128,000 | 通用general | OpenAI 自动输入缓存OpenAI auto input cache |
gpt-5.5是 reasoning 模型:输出含推理 token;max_tokens给太小会返回 200 但无可见正文 → 设足够大的输出上限(§06)。gpt-5.5is a reasoning model: output includes reasoning tokens; too small amax_tokensreturns 200 with no visible content → set a generous output cap (§06).- GPT 的缓存 ≠ Anthropic Prompt Cache:GPT 走 OpenAI 自家自动输入缓存(§06 / §07)。GPT cache ≠ Anthropic Prompt Cache: GPT uses OpenAI's own automatic input cache (§06 / §07).
05Claude 接入Claude integration (/v1/messages 原生)(/v1/messages native)
推荐路径,自动省钱(§07)+ 全原生能力保真。Recommended path — automatic savings (§07) + full native fidelity.
Python (anthropic SDK)(anthropic SDK)
import anthropic
client = anthropic.Anthropic(
api_key="sk-your-console-key",
base_url="https://console.solunarai.com", # SDK appends /v1/messages
)
msg = client.messages.create(
model="claude-sonnet-4-6", # dash name
max_tokens=1024,
system="You are a helpful assistant.", # long system caches automatically (§07)
messages=[{"role": "user", "content": "Introduce prompt cache in one line."}],
)
print(msg.content[0].text)
print(msg.usage) # check cache_read_input_tokens
curl
curl https://console.solunarai.com/v1/messages \
-H "x-api-key: sk-your-console-key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":1024,
"system":"You are a helpful assistant.",
"messages":[{"role":"user","content":"Hello"}]}'
thinking(Opus 4.8 / 4.7 / Sonnet 4.6):"thinking":{"type":"adaptive"} + "output_config":{"effort":"high"}。tool use / vision / streaming 按原生用法,网关全保真透传(§18)。Opus 5.5 / Sonnet 5.5 与 Fable 5.1 的思考写法不同,分别见 Opus 5.5 / Sonnet 5.5 使用要点 与 Fable 5.1 使用要点。Thinking (Opus 4.8 / 4.7 / Sonnet 4.6): "thinking":{"type":"adaptive"} + "output_config":{"effort":"high"}. Tool use / vision / streaming behave natively — the gateway passes them through unmodified (§18). Opus 5.5 / Sonnet 5.5 and Fable 5.1 control thinking differently — see Opus 5.5 / Sonnet 5.5 essentials and Fable 5.1 essentials.
Opus 5.5 / Sonnet 5.5 使用要点Opus 5.5 / Sonnet 5.5 essentials
Claude Opus 5.5 与 Sonnet 5.5 已可通过本网关使用。两者都有 1M 上下文窗口,最大输出 128K tokens,Prompt Cache 照常自动生效(§07),被缓存的内容需至少 512 tokens(Opus 5.5 / Sonnet 5.5)才会被缓存。它们在思考控制和几个参数上与之前的 Claude 模型不同,接入前请先看下面几点。Claude Opus 5.5 and Sonnet 5.5 are now available through the gateway. Both have a 1M context window and up to 128K output tokens, and Prompt Cache works automatically as usual (§07). Content must be at least 512 tokens to be cached on Opus 5.5 / Sonnet 5.5. They differ from earlier Claude models in how thinking is controlled and in a few parameters, so read the points below before you switch.
原生Native /v1/messages (dash) |
OpenAI 兼容OpenAI-compatible /v1/chat/completions (dot) |
|
|---|---|---|
| Opus 5.5 | claude-opus-5-5 | claude-opus-5.5 |
| Sonnet 5.5 | claude-sonnet-5-5 | claude-sonnet-5.5 |
思考(thinking)Thinking
- Opus 5.5:思考始终开启,用
output_config.effort控制深度。默认medium,建议在请求里显式设置。Opus 5.5: thinking is always on; control its depth withoutput_config.effort. The default ismedium; we recommend setting it explicitly. - Sonnet 5.5:默认 effort 为
high。如果只想在工具调用之间思考、其余时候不思考,用"thinking":{"type":"between_tools"}。Sonnet 5.5: the default effort ishigh. To think only between tool calls and not otherwise, use"thinking":{"type":"between_tools"}. - 经本网关时:旧写法
"thinking":{"type":"disabled"}和{"type":"enabled","budget_tokens":N}不会报错,而是被改为自适应思考,并按budget_tokens换算成对应的 effort。所以即使写了disabled,也可能产生思考 token。建议直接用effort和between_tools。Through this gateway: the older forms"thinking":{"type":"disabled"}and{"type":"enabled","budget_tokens":N}don't return an error. Instead they are converted to adaptive thinking, withbudget_tokensmapped to a corresponding effort. So even withdisabledyou may see thinking tokens. Useeffortandbetween_toolsdirectly.
curl https://console.solunarai.com/v1/messages \
-H "x-api-key: sk-your-console-key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-opus-5-5","max_tokens":4096,
"output_config":{"effort":"medium"},
"messages":[{"role":"user","content":"Hello"}]}'
# Sonnet 5.5, think only between tool calls:
# "model":"claude-sonnet-5-5", "thinking":{"type":"between_tools"}
参数限制(不满足会返回 400)Parameter limits (otherwise you get a 400)
tool_choice只支持auto;any、tool(以及 OpenAI 兼容写法required)会返回 400。tool_choicesupportsautoonly;any,tool(and the OpenAI-stylerequired) return 400.- 原生
/v1/messages不支持temperature/top_p:传入非默认值会返回 400,建议不传。OpenAI 兼容入口会忽略temperature/top_p(不报错,也不生效)。Native/v1/messagesdoes not supporttemperature/top_p: a non-default value returns 400, so leave them out. The OpenAI-compatible endpoint ignorestemperature/top_p(no error, and no effect). - 计算机操作(computer use)工具只能用
computer_toolset_20260801;旧版computer_20251124会返回 400。The computer use tool must becomputer_toolset_20260801; the oldercomputer_20251124returns 400. - 部分客户端和框架会默认带上
temperature或tool_choice。用 5.5 遇到 400 时,先检查这几个参数。Some clients and frameworks sendtemperatureortool_choiceby default. If you get a 400 on 5.5, check these first.
其他差异Other differences
- 本网关不提供的档位:fast 模式和仅限美国的推理暂不提供。请求里的
speed、inference_geo会被忽略,按标准档执行,响应中的speed为"standard"。Not offered on this gateway: fast mode and US-only inference.speedandinference_geoin a request are ignored and the request runs at the standard tier; the response showsspeedas"standard". - 拒答:上游安全策略拒答时,返回 HTTP 200 和
stop_reason:"refusal",不是错误状态码。请在代码里检查stop_reason,不要只看状态码。Refusals: when the upstream safety policy declines a request, you get HTTP 200 withstop_reason:"refusal", not an error status. Checkstop_reasonin your code rather than relying on the status code alone. - 推理块:与产生它的模型和会话绑定。回传时请原样带回,不要改动,也不要拿到别的模型或会话里复用(见 原生 vs OpenAI 兼容)。Reasoning blocks: tied to the model and conversation that produced them. Send them back unchanged; don't edit them or reuse them with another model or conversation (see Native vs OpenAI-compatible).
- 怎么选接口:做 agent 或多轮工具调用时,请用原生
/v1/messages(原因见 原生 vs OpenAI 兼容)。大输出请开stream:true(§04)。Which endpoint: for agents and multi-turn tool use, use native/v1/messages(see Native vs OpenAI-compatible). For large outputs, setstream:true(§04).
cache_read_input_tokens=3123;响应中 speed 为 "standard"。
all four model names above respond normally through the gateway; a repeated Sonnet 5.5 request returned cache_read_input_tokens=3123 on the second call; responses show speed as "standard".Fable 5.1 使用要点Fable 5.1 essentials NEW
Claude Fable 5.1 已可通过本网关使用。本站不再提供 Fable 5,请改用 claude-fable-5-1。Fable 5.1 的上下文窗口为 1M(默认即最大),最大输出 128K tokens,支持图像输入;Prompt Cache 照常自动生效(§07),被缓存内容需至少 512 tokens。它在思考控制、几个参数和数据留存上与其他 Claude 模型不同,接入前请先看下面几点。Claude Fable 5.1 is now available through the gateway. We no longer offer Claude Fable 5 — use claude-fable-5-1. Fable 5.1 has a 1M context window (the default is also the maximum) and up to 128K output tokens, and accepts image input. Prompt Cache works automatically as usual (§07); content must be at least 512 tokens to be cached. It differs from other Claude models in how thinking is controlled, in a few parameters, and in data retention, so read the points below before you switch.
选型建议:日常工作和大多数编码任务建议用 Opus 5.5;Fable 5.1 适合最难的推理和长时间运行的 agent 任务。Choosing a model: for everyday work and most coding, use Opus 5.5; Fable 5.1 is for the hardest reasoning and long-running agent tasks.
原生Native /v1/messages (dash) |
OpenAI 兼容OpenAI-compatible /v1/chat/completions (dot) |
|
|---|---|---|
| Fable 5.1 | claude-fable-5-1 | claude-fable-5.1 |
思考(thinking)Thinking
- 思考无法关闭,由模型按需决定思考多少(简单问题可能不返回 thinking 块);用
output_config.effort控制深度:low/medium/high/xhigh/max,默认high。Thinking can't be turned off; the model decides how much to think (simple questions may return no thinking block). Control its depth withoutput_config.effort:low/medium/high/xhigh/max, defaulthigh. - 不返回原始思维链。thinking 块默认不显示内容(
display默认为"omitted");需要可读的思考摘要时,设"thinking":{"type":"adaptive","display":"summarized"}。The raw chain of thought is never returned. Thinking blocks show no content by default (displaydefaults to"omitted"); for a readable summary, set"thinking":{"type":"adaptive","display":"summarized"}. - 经本网关时:
"thinking":{"type":"disabled"}会被网关去掉,不报错,思考仍照常进行;{"type":"enabled","budget_tokens":N}会被改为自适应思考并换算成对应的 effort(例如budget_tokens为 1024 时按low),仍可能产生思考 token。建议不传这两种写法,直接用effort。Through this gateway:"thinking":{"type":"disabled"}is removed by the gateway — no error, and thinking still runs;{"type":"enabled","budget_tokens":N}is converted to adaptive thinking with a corresponding effort (for example,budget_tokens1024 runs atlow), so you may still see thinking tokens. Leave both forms out and useeffortdirectly.
curl https://console.solunarai.com/v1/messages \
-H "x-api-key: sk-your-console-key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-fable-5-1","max_tokens":16000,"stream":true,
"output_config":{"effort":"high"},
"thinking":{"type":"adaptive","display":"summarized"},
"messages":[{"role":"user","content":"A train leaves at 09:47 and arrives at 14:18. A second train leaves 38 minutes later and takes 12% less time. When does it arrive? Answer with the time only."}]}'
参数限制(不满足会返回 400)Parameter limits (otherwise you get a 400)
tool_choice只支持auto(默认)和none;{"type":"any"}、{"type":"tool"}(以及 OpenAI 兼容入口的"required"或指定函数)会返回 400,报错信息为tool_choice: type "tool" and "any" are not supported for this model.。需要模型调用某个工具时,在提示里明确要求它使用该工具;需要符合 schema 的 JSON 时,用 strict tool use(工具定义加"strict": true)或 structured outputs(output_config.format)。tool_choicesupports onlyauto(the default) andnone;{"type":"any"}and{"type":"tool"}(and, on the OpenAI-compatible endpoint,"required"or a named function) return 400 with the messagetool_choice: type "tool" and "any" are not supported for this model.To have the model call a particular tool, tell it to use that tool in your prompt; for schema-valid JSON, use strict tool use ("strict": trueon the tool definition) or structured outputs (output_config.format).- 原生
/v1/messages不支持temperature/top_p/top_k:传入非默认值会返回 400,建议不传。OpenAI 兼容入口会忽略temperature/top_p(不报错,也不生效)。Native/v1/messagesdoes not supporttemperature/top_p/top_k: a non-default value returns 400, so leave them out. The OpenAI-compatible endpoint ignorestemperature/top_p(no error, and no effect). - 不支持 assistant 预填(prefill):
messages最后一条为 assistant 消息会返回 400。需要控制输出格式时,用 structured outputs 或 system 提示。Assistant prefill is not supported: a request whose last message is from the assistant returns 400. To control the output format, use structured outputs or the system prompt. - 部分客户端和框架会默认带上
temperature或tool_choice。用 Fable 5.1 遇到 400 时,先检查这两个参数。Some clients and frameworks sendtemperatureortool_choiceby default. If you get a 400 on Fable 5.1, check these two first.
多轮对话与思考块Multi-turn conversations and thinking blocks
- 多轮对话请保持历史只追加:修改更早的轮次会使 Fable 5.1 的 thinking 块失效。回传时把 thinking 块原样带回,不要改动。Keep conversation history append-only: editing earlier turns invalidates Fable 5.1's thinking blocks. Send thinking blocks back unchanged.
- 本网关提供的模型中,只有 Fable 5.1 能读取 Fable 5.1 的 thinking 块;对话中途换成其他模型,这些 thinking 块会被丢弃。Among the models on this gateway, only Fable 5.1 can read Fable 5.1's thinking blocks; if you switch to another model mid-conversation, those thinking blocks are dropped.
- 做 agent 或多轮工具调用时,请用原生
/v1/messages(见 原生 vs OpenAI 兼容)。For agents and multi-turn tool use, use native/v1/messages(see Native vs OpenAI-compatible).
其他Other
- 拒答:上游安全策略拒答时,返回 HTTP 200 和
stop_reason:"refusal",不是错误状态码。请在代码里检查stop_reason,不要只看状态码。Refusals: when the upstream safety policy declines a request, you get HTTP 200 withstop_reason:"refusal", not an error status. Checkstop_reasonin your code rather than relying on the status code alone. - 长耗时:难题上的单次请求可能持续数分钟。请开
stream:true,并把客户端超时设得足够长。Long requests: a single request on a hard task can run for several minutes. Setstream:trueand give your client a long enough timeout. - 不提供的选项:请求里的
speed、inference_geo会被忽略,按标准档执行,响应中的speed为"standard"。Ignored options:speedandinference_geoin a request are ignored and the request runs at the standard tier; the response showsspeedas"standard". - 原有 Fable 5 代码:本站不再提供 Fable 5。把模型名改为
claude-fable-5-1(兼容接口推荐用claude-fable-5.1);去掉tool_choice的any/tool;确认多轮历史只追加、thinking 块原样回传。Existing Fable 5 code: we no longer offer Claude Fable 5. Change the model name toclaude-fable-5-1(claude-fable-5.1recommended on the compatible endpoint); removetool_choiceany/tool; keep multi-turn history append-only and send thinking blocks back unchanged.
cache_read_input_tokens=2083;被缓存内容 478 tokens 时不缓存、542 tokens 时缓存;上面的示例原样运行返回 200;调用 claude-fable-5 返回模型不可用。
both model names respond normally through the gateway on both endpoints; a repeated request returned cache_read_input_tokens=2083 on the second call; content of 478 tokens was not cached while 542 tokens was; the example above runs unchanged with a 200; calling claude-fable-5 returns "model not available".06OpenAI / GPT 接入OpenAI / GPT integration
GPT 系列与所有 OpenAI 兼容客户端走这条路径。The GPT family and every OpenAI-compatible client use this path.
Python (openai SDK)(openai SDK)
from openai import OpenAI
client = OpenAI(
api_key="sk-your-console-key",
base_url="https://console.solunarai.com/v1", # note the /v1
)
r = client.chat.completions.create(
model="gpt-5.5",
max_tokens=4096, # reasoning model: give it room, or you get 200 with empty content
messages=[{"role": "user", "content": "Introduce yourself in one line."}],
)
print(r.choices[0].message.content)
print(r.usage) # check prompt_tokens_details.cached_tokens
两件事要分清Two things to keep straight
- reasoning(gpt-5.5):先"思考"再回答,
max_tokens太小 → 预算被推理吃光 → HTTP 200 但content为空。设足够大的输出上限(如 ≥4096)。reasoning (gpt-5.5): it thinks before answering — too small amax_tokensmeans the budget is spent on reasoning → HTTP 200 with emptycontent. Set a generous cap (e.g. ≥4096). - OpenAI 缓存 vs Anthropic Prompt Cache:GPT 走 OpenAI 官方自动输入缓存,相同前缀重复请求命中段约 0.1× 输入价,无需任何
cache_control;命中看usage.prompt_tokens_details.cached_tokens。Claude 走网关注入的 Anthropic Prompt Cache(§07),机制不同,别混。OpenAI cache vs Anthropic Prompt Cache: GPT uses OpenAI's official automatic input cache — repeated identical prefixes bill the cached portion at ≈0.1× input, nocache_controlneeded; checkusage.prompt_tokens_details.cached_tokens. Claude uses the gateway-injected Anthropic Prompt Cache (§07) — different mechanism, don't conflate. - Claude 也可走此路径(dot 名),同样经网关自动缓存(2026-10-15 实测
cached_tokens=7146)。Claude can also use this path (dot name) and still caches via the gateway (measuredcached_tokens=7146, 2026-10-15). - Claude 走此路径的推理:用
reasoning_effort开启,返回reasoning_content;推理不跨轮延续。agent / 多轮工具调用请改用原生/v1/messages(原生 vs OpenAI 兼容)。Reasoning for Claude on this path: enable it withreasoning_effort; you getreasoning_contentback, and reasoning does not carry across turns. For agents / multi-turn tool use, switch to native/v1/messages(Native vs OpenAI-compatible).
原生接口 vs OpenAI 兼容接口(Claude 模型)Native vs OpenAI-compatible (Claude models)
Claude 模型提供两个接入入口:Anthropic 原生 Messages 接口 /v1/messages,以及 OpenAI 兼容接口 /v1/chat/completions。两者都支持对话、工具调用和流式输出,主要区别在于扩展思考(extended thinking)能否在多轮之间延续。Claude models are available through two endpoints: the Anthropic-native Messages API, /v1/messages, and the OpenAI-compatible /v1/chat/completions. Both support chat, tool use and streaming. The main difference is whether extended thinking carries over between turns.
原生 /v1/messages:响应里的 thinking 块连同签名(signature)完整返回。把上一轮 assistant 返回的 content 原样放回 messages,模型就能在多轮对话和工具调用之间延续之前的推理。流式输出中 thinking_delta / signature_delta 正常下发;anthropic-beta 请求头原样转发给上游;system 提示会自动加上 Prompt Cache 标记,同样的长 system 从第二次请求起按缓存读取计费(§07)。claude-sonnet-4-6 使用 1M 上下文窗口无需额外 beta 头。Native /v1/messages: thinking blocks are returned in full, together with their signatures. Send the previous assistant content back unchanged in messages, and the model continues its earlier reasoning across turns and tool calls. When streaming, thinking_delta / signature_delta events arrive as normal; the anthropic-beta header is forwarded upstream as-is; the system prompt is automatically marked for Prompt Cache, so a repeated long system prompt is billed at the cache-read rate from the second request onward (§07). The 1M context window on claude-sonnet-4-6 needs no extra beta header.
回传时请保持 thinking 块完整、不要改动:如果 thinking 块缺失或签名无效,请求仍会成功,但这部分推理不会被延续。Keep thinking blocks intact when you send them back: if a thinking block is missing or its signature is invalid, the request still succeeds, but that reasoning does not carry over.
OpenAI 兼容 /v1/chat/completions:调用 Claude 模型时,用 reasoning_effort 开启推理,推理文本在 reasoning_content 字段返回(流式下分块返回)。这个入口不返回 thinking 块和签名,所以上一轮的推理不会带到下一轮:下一轮模型会重新推理,请求不会报错,但推理不连续。thinking 参数在这个入口不生效,会被忽略。工具调用和流式输出均正常。OpenAI-compatible /v1/chat/completions: for Claude models, enable reasoning with reasoning_effort; the reasoning text comes back in reasoning_content (in chunks when streaming). This endpoint returns no thinking blocks or signatures, so reasoning from one turn does not carry into the next: the model reasons afresh, with no error, but without continuity. The thinking parameter has no effect here and is ignored. Tool calls and streaming work normally.
claude-sonnet-4-6)经公网入口完整返回、无截断,相同 system 的第二次请求按缓存读取计费。
on the native endpoint, thinking blocks and signatures round-trip correctly across multi-turn tool calls, and streamed thinking / signature deltas arrive normally. A single ~310K-token request (claude-sonnet-4-6) came back complete through the public endpoint with no truncation, and a repeat with the same system prompt was billed at the cache-read rate.原生Native /v1/messages |
OpenAI 兼容OpenAI-compatible /v1/chat/completions |
|
|---|---|---|
| 鉴权 / base_url / 模型名Auth / base_url / model name | x-api-key · https://console.solunarai.com · 推荐 dash 名(§02–§03)dash name recommended (§02–§03) | Bearer · https://console.solunarai.com/v1 · 推荐 dot 名(§02–§03)dot name recommended (§02–§03) |
| 开启推理Enable reasoning | thinking 参数(§05)thinking parameter (§05) | reasoning_effort;thinking 参数不生效; thinking is ignored |
| 返回的推理内容Reasoning returned as | thinking 块 + 签名thinking blocks + signature | reasoning_content(文本,无签名) (text, no signature) |
| 多轮 / 工具调用之间的推理Reasoning across turns / tool calls | ✓ 延续(把 thinking 块原样回传)continues (send thinking blocks back unchanged) | 不延续(下一轮重新推理,不报错)does not continue (fresh reasoning, no error) |
| 流式Streaming | ✓ 含incl. thinking_delta / signature_delta | ✓ 含 reasoning_content 分块incl. chunked reasoning_content |
| 工具调用Tool use | ✓ | ✓ |
anthropic-beta 请求头anthropic-beta header | ✓ 原样转发forwarded as-is | — |
| Prompt Cache | ✓ system 自动标记(§07)system marked automatically (§07) | ✓ system 自动标记,命中量见 usage.prompt_tokens_details.cached_tokens(§07)system marked automatically; hits shown in usage.prompt_tokens_details.cached_tokens (§07) |
怎么选:做智能体或多轮工具调用、并依赖扩展思考连续性(例如 Claude Code、自建 agent)时,请用原生 /v1/messages;普通对话、一次性问答,以及只支持 OpenAI 协议的工具,用 OpenAI 兼容接口即可。从兼容接口切到原生:base_url 去掉 /v1、鉴权头改为 x-api-key,模型名推荐改为 dash 写法。Which to use: for agents and multi-turn tool use that rely on extended thinking carrying over (for example Claude Code or your own agent), use native /v1/messages. For plain chat, one-off Q&A, and tools that only speak the OpenAI protocol, the OpenAI-compatible endpoint is fine. Switching from compatible to native: drop /v1 from the base_url and use the x-api-key header; the dash model name is recommended.
07★ Prompt Cache(0 代码改动)★ Prompt Cache (zero code change)
机制:走 Claude 时,网关自动给 system prompt 注入缓存标记 —— 你不改一行代码。重复的 system / 长上下文在后续请求按缓存价计费(读取约全价 1/10)。How it works: on Claude, the gateway automatically injects cache markers on your system prompt — no code change. A repeated system / long context is billed at the cache rate on later requests (reads ≈ 1/10 of full price).
/v1/messages cache_read_input_tokens=8409、/v1/chat/completions cached_tokens=7146,均按缓存价(0.1×)计费 —— 重复请求端到端省约 90%。
Sending the same long system twice: /v1/messages returned cache_read_input_tokens=8409 and /v1/chat/completions returned cached_tokens=7146, both billed at the cache rate (0.1×) — about 90% cheaper end-to-end on the repeat.- 触发:被缓存内容(通常 system)需达上游最小可缓存长度(随模型不同,约 512–4096 tokens:Opus 5.5 / Sonnet 5.5 / Fable 5.1 = 512,Sonnet 4.6 = 2048,Opus 4.8 / 4.7 与 Haiku 4.5 = 4096),且两次间隔在缓存有效期内。低于阈值静默不缓存。Trigger: cached content (usually system) must reach the upstream minimum cacheable length (model-dependent, ≈ 512–4096 tokens: Opus 5.5 / Sonnet 5.5 / Fable 5.1 = 512, Sonnet 4.6 = 2048, Opus 4.8 / 4.7 and Haiku 4.5 = 4096), within the cache window between calls. Below the threshold it silently won't cache.
- 省多少:缓存命中段按全价 1/10 计(接近约 90% 上限);重复 system 实测端到端约 90%(2026-10-15)。How much: cached hits bill at 1/10 (~90% ceiling); end-to-end about 90% measured on a repeated-system test (2026-10-15).
- 看是否命中:
/v1/messages读usage.cache_read_input_tokens > 0;/v1/chat/completions读usage.prompt_tokens_details.cached_tokens > 0。Hit check:/v1/messages→usage.cache_read_input_tokens > 0;/v1/chat/completions→usage.prompt_tokens_details.cached_tokens > 0. - 长上下文 / RAG:可在 system 块标
{"type":"ephemeral","ttl":"1h"}(写贵约 2×、命中读恒约 0.1×,适合长会话 / 反复问同一份长文档)。Long context / RAG: mark a system block{"type":"ephemeral","ttl":"1h"}(write ≈2×, hits read ≈0.1× — good for long sessions / repeatedly querying one long document).
这是 Anthropic 官方 Prompt Cache。网关本身不设响应缓存;为降低你的费用,网关会请上游启用提示缓存:上游可能短时保存请求开头部分的处理结果,使重复请求更便宜,通常为几分钟,最长约 24 小时,视提供方而定。该缓存由上游按其自身政策维护,而非由我们维护(§17、隐私政策 §1)。This is the official Anthropic Prompt Cache. The gateway itself keeps no response cache; to reduce your cost, it asks the upstream to apply prompt caching: the upstream may temporarily hold a processed form of the beginning of a request so repeated requests are cheaper — generally for a few minutes and at most about 24 hours, depending on the provider. That cache is maintained by the upstream under its own policies, not by us (§17, Privacy Policy §1).
速查表 — 找你的工具Find your tool
先在下表找到你的客户端 / 智能体,看走哪条路径、模型名怎么写,再点"跳转"看配置。Find your client / agent below — see which path and model-name form to use, then jump to its config.
/v1/messages):base_url https://console.solunarai.com、鉴权 x-api-key、模型推荐 dash(claude-sonnet-4-6);兼容(/v1/chat/completions):base_url https://console.solunarai.com/v1、鉴权 Bearer、模型推荐 dot(claude-sonnet-4.6)或 gpt(gpt-5.5)。Uniform rules — native (/v1/messages): base_url https://console.solunarai.com, auth x-api-key, model dash recommended (claude-sonnet-4-6); compatible (/v1/chat/completions): base_url https://console.solunarai.com/v1, auth Bearer, model dot recommended (claude-sonnet-4.6) or gpt (gpt-5.5).| 工具 / 智能体Tool / agent | 类别Category | 路径Path | model | 跳转Jump |
|---|---|---|---|---|
| Claude Code | CLI 编码 agentCLI coding agent | native | dash | §10 |
| Cursor | 编辑器Editor | 兼容compat | dot · gpt | §11 |
| Cline | VS Code Agent | 皆可either | dot · dash | §12 |
| Roo Code | VS Code Agent | 皆可either | dot · dash | §12 |
| Continue | 编辑器 AgentEditor agent | 皆可either | dash · dot · gpt | §14 |
| Aider | CLI 编码CLI coding | 兼容compat | openai/… | §14 |
| LangChain / LangGraph | 框架Framework | 皆可either | dash · dot · gpt | §13 |
| Cherry Studio | 桌面客户端Desktop | 兼容compat | dot · gpt | §14 |
| ChatBox | 桌面客户端Desktop | 兼容compat | dot · gpt | §14 |
| Open WebUI | 自托管Self-host | 兼容compat | dot · gpt | §14 |
| LobeChat | 自托管 / 桌面Self-host | 兼容compat | dot · gpt | §14 |
| NextChat | 自托管 / 桌面Self-host | 兼容compat | dot · gpt | §14 |
| Dify | Agent / 工作流平台Agent platform | 兼容compat | dot · gpt | §14 |
| Anthropic / OpenAI SDK | 代码Code | 各自native / compat | dash / dot · gpt | §08–09 |
| 其它 OpenAI-兼容Other OpenAI-compatible | — | 兼容compat | dot · gpt | §14 |
标"皆可"的 agent 类工具(Cline / Roo Code / Continue / LangChain):如需扩展思考跨轮延续,选 native(Anthropic 提供方 + dash 名),见 原生 vs OpenAI 兼容。For agent tools marked "either" (Cline / Roo Code / Continue / LangChain): if you need extended thinking to carry across turns, choose native (Anthropic provider + dash name) — see Native vs OpenAI-compatible.
08Anthropic SDK (Python / Node)(Python / Node)
base_url = https://console.solunarai.com · key = x-api-key · model = Claude dash 名(推荐)。Python 见 §05。base_url = https://console.solunarai.com · key = x-api-key · model = Claude dash name (recommended). Python in §05.
Node (@anthropic-ai/sdk)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "sk-your-console-key",
baseURL: "https://console.solunarai.com",
});
const msg = await client.messages.create({
model: "claude-sonnet-4-6", max_tokens: 1024,
system: "You are a helpful assistant.",
messages: [{ role: "user", content: "Hello" }],
});
console.log(msg.content[0].text);
09OpenAI SDK (Python / Node)(Python / Node)
base_url = https://console.solunarai.com/v1 · key = Authorization: Bearer · model = gpt-5.5 等或 Claude dot 名(推荐)。Python 见 §06。base_url = https://console.solunarai.com/v1 · key = Authorization: Bearer · model = gpt-5.5 etc. or a Claude dot name (recommended). Python in §06.
Node (openai)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-your-console-key",
baseURL: "https://console.solunarai.com/v1",
});
const r = await client.chat.completions.create({
model: "gpt-5.5", max_tokens: 4096,
messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);
10Claude Code
走 Anthropic 原生 /v1/messages(自动省钱)。设环境变量指向网关:Uses Anthropic-native /v1/messages (automatic savings). Point the env vars at the gateway:
export ANTHROPIC_BASE_URL="https://console.solunarai.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-console-key" # or ANTHROPIC_API_KEY
export ANTHROPIC_MODEL="claude-sonnet-4-6" # dash name
claude
启动后照常用;Prompt Cache 自动生效,无需改任何配置。换模型直接改 ANTHROPIC_MODEL(用 console 清单里的确切名称,推荐 dash 写法)。Use it as usual; Prompt Cache works automatically, no config change. To switch models, change ANTHROPIC_MODEL (use the exact name from the console list; the dash form is recommended).
11Cursor
走 OpenAI 兼容路径。Settings → Models:Uses the OpenAI-compatible path. Settings → Models:
- Override OpenAI Base URL =
https://console.solunarai.com/v1 - OpenAI API Key =
sk-your-console-key - Add model(自定义模型名):
gpt-5.5或 Claude dot 名claude-sonnet-4.6Add model (custom name):gpt-5.5or a Claude dot nameclaude-sonnet-4.6
保存后在模型选择器里选刚加的模型即可。Save, then pick the model you added in the model selector.
12Cline / Roo Code (VS Code 扩展)(VS Code extension)
用 OpenAI Compatible 提供方:Use the OpenAI Compatible provider:
- Base URL =
https://console.solunarai.com/v1 - API Key =
sk-your-console-key - Model ID =
gpt-5.5或 Claude dot 名claude-sonnet-4.6or Claude dot nameclaude-sonnet-4.6
也可用 Anthropic 提供方走 native:Base URL = https://console.solunarai.com、Key = sk-…、模型推荐用 dash 名。Or use the Anthropic provider for native: Base URL = https://console.solunarai.com, Key = sk-…, model = dash name (recommended).
Roo Code(Cline 的活跃分支)配置完全相同:用 OpenAI Compatible 或 Anthropic 提供方,按上面填即可。Roo Code (an active Cline fork) is configured identically — use the OpenAI Compatible or Anthropic provider with the same values above.
13LangChain / LangGraph
走 Claude(native,自动省钱)Claude (native, auto savings)
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(
model="claude-sonnet-4-6",
api_key="sk-your-console-key",
base_url="https://console.solunarai.com",
)
print(llm.invoke("Hello").content)
走 GPT 或 OpenAI 兼容GPT / OpenAI-compatible
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-5.5",
api_key="sk-your-console-key",
base_url="https://console.solunarai.com/v1",
max_tokens=4096,
)
print(llm.invoke("Hello").content)
LangGraph 节点里直接复用上面的 llm 实例。Reuse the llm instance directly inside LangGraph nodes.
14更多 AI Agent 与客户端More AI agents & clients
更多主流 AI agent / 客户端的具体填法;凡"OpenAI 兼容"的,都按上面速查表的统一规则(base_url 带 /v1 + Bearer key + 模型名)。Concrete config for more mainstream AI agents / clients. Anything "OpenAI-compatible" follows the uniform rules in the lookup table above (base_url with /v1 + Bearer key + model name).
Continue (VS Code / JetBrains)(VS Code / JetBrains)
在 config.json(或 config.yaml)的 models 里加条目,native 与兼容两种都可:Add entries under models in config.json (or config.yaml) — both native and compatible work:
{
"models": [
{ "title": "Solunar Claude", "provider": "anthropic",
"apiBase": "https://console.solunarai.com",
"apiKey": "sk-your-console-key", "model": "claude-sonnet-4-6" },
{ "title": "Solunar GPT", "provider": "openai",
"apiBase": "https://console.solunarai.com/v1",
"apiKey": "sk-your-console-key", "model": "gpt-5.5" }
]
}
Aider (CLI 编码 agent)(CLI coding agent)
走 OpenAI 兼容(底层用 litellm,模型名加 openai/ 前缀):Use the OpenAI-compatible route (litellm under the hood — prefix the model with openai/):
export OPENAI_API_BASE="https://console.solunarai.com/v1"
export OPENAI_API_KEY="sk-your-console-key"
aider --model openai/gpt-5.5
# or Claude (dot name):
aider --model openai/claude-sonnet-4.6
桌面 & 自托管客户端Desktop & self-hosted clients
都走 OpenAI 兼容,在各自"自定义 / OpenAI 接口"设置里填:All OpenAI-compatible — fill these into each app's "custom / OpenAI endpoint" settings:
| 客户端Client | 填入位置(Base URL + Key + 模型)Where to put it (Base URL + Key + model) |
|---|---|
| Cherry Studio | 设置 → 模型服务 → 添加(OpenAI 兼容):API 地址 https://console.solunarai.com/v1 + 密钥 + 添加模型 gpt-5.5 / claude-sonnet-4.6Settings → Model providers → add (OpenAI-compatible): API host https://console.solunarai.com/v1 + key + add model gpt-5.5 / claude-sonnet-4.6 |
| ChatBox | 设置 → 模型提供方 = OpenAI API 兼容:API Host https://console.solunarai.com/v1 + API Key + 模型名Settings → provider = OpenAI-API-compatible: API Host https://console.solunarai.com/v1 + API key + model name |
| Open WebUI | Settings → Connections → OpenAI API:Base URL https://console.solunarai.com/v1 + KeySettings → Connections → OpenAI API: Base URL https://console.solunarai.com/v1 + key |
| LobeChat | 设置 → 语言模型 → OpenAI:接口代理地址 https://console.solunarai.com/v1 + API Key + 自定义模型名Settings → Language model → OpenAI: API proxy https://console.solunarai.com/v1 + API key + custom model name |
| NextChat | 设置 → 自定义接口:接口地址 https://console.solunarai.com/v1 + API Key + 模型Settings → custom endpoint: API URL https://console.solunarai.com/v1 + API key + model |
Dify (Agent / 工作流平台)(agent / workflow platform)
- 设置 → 模型供应商 → OpenAI-API-compatible:API endpoint URL
https://console.solunarai.com/v1+ API Keysk-…+ Model Namegpt-5.5/claude-sonnet-4.6。Settings → Model Provider → OpenAI-API-compatible: API endpoint URLhttps://console.solunarai.com/v1+ API Keysk-…+ Model Namegpt-5.5/claude-sonnet-4.6. - 然后在应用 / Agent 编排里选该模型即可。Then select that model in your app / agent orchestration.
其它任何"OpenAI 兼容"客户端(n8n、Flowise、各类桌面 App…)同理:能填 Base URL + Key + 模型名就能接。Any other "OpenAI-compatible" client (n8n, Flowise, various desktop apps…) works the same way: if it lets you set Base URL + Key + model name, it connects.
15计费与额度Billing & credits
- 预付额度:充值后按用量扣减,console 看余额 / 明细。Prepaid credits: usage is deducted from your balance; see balance/usage in the console.
- 充值:在线信用卡(Stripe)+ 兑换码(国内卡 / 对公 / SWIFT)。Top up: card online (Stripe) + redemption codes (domestic cards / wire / SWIFT).
- 价格 / 倍率:登录后 console 可见。Pricing / rates: visible in the console after login.
- 缓存计费:命中按缓存价(约 0.1×),不按全价(§07)。Cache billing: hits bill at the cache rate (≈0.1×), not full price (§07).
- 退款:见退款政策(已消费不退;未消费 14 天内可申请;人工审核)。Refunds: see the Refund Policy (consumed credit is non-refundable; unused within 14 days may be requested; manual review).
16限额与速率Limits & rate
- 账号有并发 / 速率限制以保障稳定;起步阶段单笔 / 单日充值有上限(风控)。Accounts have concurrency / rate limits for stability; during onboarding, per-transaction / per-day top-up caps apply (risk control).
- 余额为 0 或撞限额会返回相应错误(§19)。Zero balance or hitting a limit returns the corresponding error (§19).
- 需要更高额度 / 并发或企业实施 → service@solunarai.com。For higher limits / concurrency or enterprise rollout → service@solunarai.com.
17数据边界(你的数据只属于你)Data boundary (your data is yours)
- 不训练、不出售 NEW:我们不拿你的 prompt / 输出训练模型,也不出售。No training, no selling NEW: we don't train models on your prompts/outputs, and we don't sell them.
- 网关不存正文 NEW:控制台 / 计费与推理层不存储你 API 请求与响应的正文,只记用量与计费元数据(逻辑模型名、token 数、时间戳、请求标识、所用 API key 的标识、扣费金额、IP 地址)。请求失败时,上游返回的报错信息可能以截断摘录形式保存在运营日志中用于排障,并按隐私政策 §5 的期限删除。The gateway doesn't store content NEW: the console/billing and inference layers don't store the body text of your API requests or responses; they record only usage and billing metadata (logical model name, token counts, timestamps, request identifiers, an identifier of the API key used, the amount charged, IP address). When a request fails, a shortened copy of the upstream's error message may be kept in operational logs for troubleshooting and is deleted on the schedule in Privacy Policy §5.
- 网关不设响应缓存 NEW:为降低费用,网关会请上游启用提示缓存(§07):上游可能短时保存请求开头部分的处理结果,通常几分钟、最长约 24 小时(视提供方而定),由上游按其自身政策维护。No response cache at the gateway NEW: to reduce your cost, the gateway asks the upstream to apply prompt caching (§07): the upstream may temporarily hold a processed form of the beginning of a request — generally a few minutes, at most about 24 hours depending on the provider — under its own policies.
- 上游 NEW:请求转发给官方 Anthropic / OpenAI 履行;按其商用条款,你的内容不用于训练其模型。上游按其自身政策在有限期间内保留内容,我们无法控制。截至隐私政策撰写时:Anthropic 默认在 30 天内删除 API 输入与输出,对被判定违反其使用政策的内容可能保留更久;Claude Fable 系列(如 Fable 5.1)要求 30 天留存、不提供零数据留存;OpenAI 的 API 滥用监控日志最长保留 30 天。数据可能在美国等地处理。详见隐私政策 §3 / §4 / §5。Upstream NEW: requests are forwarded to the official Anthropic / OpenAI for fulfillment; under their commercial terms your content is not used to train their models. Upstreams retain content for limited periods under their own policies, which we don't control. At the time the Privacy Policy was written: Anthropic deletes API inputs and outputs within 30 days by default and may keep content flagged for Usage Policy violations longer; Claude Fable models (such as Fable 5.1) require 30-day retention, with no zero data retention; OpenAI retains API abuse-monitoring logs for up to 30 days. Data may be processed in the United States and elsewhere. See the Privacy Policy §3 / §4 / §5.
详见隐私政策 / 服务条款 / 可接受使用政策。See the Privacy Policy / Terms / Acceptable Use Policy.
18验证"官方纯正 / 不降智"Verify integrity (no downgrade)
我们承诺官方通道、不降级,你可自验:We promise official routing, no downgrade. You can verify:
- 行为一致:同 prompt 与官方示例行为一致(无裁剪 / 降参)。Consistent behavior: same prompt behaves like the official example (no truncation / param downgrade).
- 完整能力:走
/v1/messages时,Claude 的 tool use、thinking、tool_choice、metadata、streaming 全保真透传。网关的改动只有两类:注入 cache 标记(不改变语义);以及 Opus 5.5 / Sonnet 5.5 / Fable 5.1 的兼容处理 —— 旧版thinking写法改为自适应思考,speed/inference_geo按标准档处理(见 Opus 5.5 / Sonnet 5.5 使用要点 与 Fable 5.1 使用要点)。Full capabilities: on/v1/messages, Claude's tool use, thinking, tool_choice, metadata, and streaming are passed through with full fidelity. The gateway changes only two kinds of things: the cache marker (non-semantic), and compatibility adjustments for Opus 5.5 / Sonnet 5.5 / Fable 5.1 — olderthinkingforms become adaptive thinking, andspeed/inference_georun at the standard tier (see Opus 5.5 / Sonnet 5.5 essentials and Fable 5.1 essentials). - 原生元数据:
usage/stop_reason等为上游原生返回。GPT 走官方 OpenAI API,原生返回。Native metadata:usage/stop_reasonare returned natively by the upstream. GPT runs on the official OpenAI API, native responses. - 我们不做:静默换小模型、截断上下文、改写你 prompt 的内容或语义。网关不做跨模型的自动降级或升级:你请求哪个模型,就由哪个模型处理;上游出错时,错误会返回给你的客户端(状态码沿用上游语义,见 §19),而不是悄悄换成另一个模型给出结果。临时性错误可能先在同一模型上自动重试,但不会换到别的模型。We do not silently swap to a smaller model, truncate context, or alter the content or meaning of your prompt. The gateway does no cross-model fallback — no automatic downgrade or upgrade. The model you request is the model that answers; if the upstream returns an error, that error comes back to your client (status codes follow upstream semantics, see §19) instead of a quiet answer from a different model. Transient errors may be retried on the same model first, but not on a different one.
19错误码参考Error codes
返回沿用上游 HTTP 语义(Anthropic / OpenAI 风格)。SDK 一律用类型化异常判别,别用错误信息字符串匹配。Responses follow upstream HTTP semantics (Anthropic / OpenAI style). Always branch on the SDK's typed exceptions, not on error-message string matching.
| 码Code | 类型Type | 重试Retry | 网关侧常见原因Common cause |
|---|---|---|---|
| 400 | invalid_request | 否no | JSON 格式错 / 缺 model·max_tokens / 角色不交替 / 参数超限malformed JSON / missing model·max_tokens / roles not alternating / param out of range |
| 401 | authentication | 否no | key 无效 / 缺鉴权头 / 头用错(x-api-key vs Bearer)invalid key / missing header / wrong header (x-api-key vs Bearer) |
| 402 | insufficient_quota | 否no | console 余额为 0 / 欠费 → 充值zero balance / unpaid → top up |
| 403 | permission | 否no | key 无权访问该模型 / 该模型未对你开放;API key 剩余额度不足以覆盖本次 max_tokens 的预估费用时也会返回 403 → 调小 max_tokens 或提高该 key 的额度key lacks access to the model / model not enabled for you; also returned when the API key's remaining quota can't cover the estimated cost of this request's max_tokens → lower max_tokens or raise that key's quota |
| 404 | not_found_error(Claude 原生) (Claude native) / model_not_found(OpenAI 兼容) (OpenAI-compatible) | 否no | 模型名不存在、拼错或已不再提供(如 claude-fable-5)→ 核对控制台定价页的模型名;端点路径错误也返回 404model name doesn't exist, has a typo, or is no longer offered (e.g. claude-fable-5) → check the model name against the console pricing page; a wrong endpoint path also returns 404 |
| 413 | request_too_large | 否no | 请求体 / 输入过大 → 截断历史 / 分块request/input too large → trim history / chunk |
| 429 | rate_limit | 是yes | 撞 RPM/TPM / 单笔单日上限 → 退避重试,查 retry-afterRPM/TPM or per-tx/day cap → back off, check retry-after |
| 500 | api_error | 是yes | 上游 / 处理临时故障 → 指数退避transient upstream/processing error → exponential backoff |
| 529 | overloaded | 是yes | 上游过载 → 退避 / 换模型 / 错峰upstream overloaded → back off / switch model / spread load |
若某个已上架模型暂时没有可用通道,返回 503,可稍后重试。If a listed model temporarily has no available capacity, the request returns 503 — retry later.
cache_read=0(没省到钱)不是错误,排查见 §20。cache_read=0 (no savings) is not an error — see §20.
20故障排查Troubleshooting
| 现象Symptom | 排查Check |
|---|---|
| cache 没命中cache miss | ① Claude 还是 GPT(GPT 看 cached_tokens)② 内容是否达最小长度(约 512–4096,随模型,§07)③ 前缀是否逐字节一致(时间戳/UUID/未排序 JSON 会破)④ 间隔是否超期① Claude or GPT (GPT → cached_tokens) ② content ≥ minimum (≈512–4096, model-dependent, §07) ③ prefix byte-identical (timestamps/UUIDs/unsorted JSON break it) ④ gap within window |
| 401 鉴权失败401 auth failed | key 有效 / 余额 > 0 / 头正确(messages 用 x-api-key、chat 用 Bearer)key valid / balance > 0 / correct header (messages → x-api-key, chat → Bearer) |
| 模型名报错(404)model name error (404) | 先核对模型名(与控制台定价页一致),重试无效;推荐 messages 用 dash、chat 用 dot;GPT 只走 chat/completionscheck the model name against the console pricing page first; retrying won't help; recommended: messages → dash, chat → dot; GPT → chat/completions only |
| gpt-5.5 返回 200 但 content 空gpt-5.5 200 with empty content | reasoning 模型,max_tokens 被推理吃光 → 调大输出上限(§06)reasoning model — max_tokens spent on reasoning → raise the output cap (§06) |
| 余额不足 / 限流(429)low balance / 429 | 查 console 余额 + 单笔/单日上限;退避重试(§16/§19)check balance + per-tx/day caps; back off and retry (§16/§19) |
| streaming 中断streaming cut off | 设 stream:true 且正确处理 SSE;大输出务必开 streamset stream:true and handle SSE; always stream large outputs |
| Opus / Sonnet 5.5 返回 400Opus / Sonnet 5.5 returns 400 | 检查 temperature / top_p(原生入口不要传)、tool_choice(只用 auto)、computer use 工具版本(computer_toolset_20260801),见 5.5 要点check temperature / top_p (leave out on the native endpoint), tool_choice (auto only), computer use tool version (computer_toolset_20260801) — see 5.5 essentials |
| 返回 200 但没有正常回答200 but no normal answer | 看 stop_reason:为 "refusal" 表示上游安全策略拒答,不是网关错误check stop_reason: "refusal" means the upstream safety policy declined — not a gateway error |
| Fable 5.1 返回 400Fable 5.1 returns 400 | 检查 temperature / top_p / top_k(原生入口不要传)、tool_choice(只用 auto 或 none)、最后一条消息是不是 assistant(不支持预填),见 Fable 5.1 要点check temperature / top_p / top_k (leave out on the native endpoint), tool_choice (auto or none only), whether the last message is from the assistant (no prefill) — see Fable 5.1 essentials |
调用 claude-fable-5 返回 404claude-fable-5 returns 404 | 本站不再提供 Fable 5,请改用 claude-fable-5-1(兼容接口 claude-fable-5.1),并按 Fable 5.1 要点 检查参数We no longer offer Claude Fable 5 — use claude-fable-5-1 (claude-fable-5.1 on the compatible endpoint) and check parameters per Fable 5.1 essentials |
21FAQ
接入要改代码吗? 只改 base_url + api_key 两行;Claude 的 Prompt Cache 自动,0 额外改动(迁移见下)。Any code change? Just base_url + api_key; Claude's Prompt Cache is automatic, zero extra change (see Migration).
省钱是真的吗? Claude 走网关自动注入官方 Prompt Cache,重复 system 场景生产实测端到端约 90%,接近缓存上限(2026-10-15)。Is the saving real? On Claude the gateway auto-injects the official Prompt Cache — about 90% end-to-end measured on repeated-system workloads, close to the cache ceiling (2026-10-15).
支持 GPT 吗? 支持 gpt-5.5 / gpt-5.4 / gpt-5.4-mini,走 /v1/chat/completions(§06)。GPT supported? Yes — gpt-5.5 / gpt-5.4 / gpt-5.4-mini, via /v1/chat/completions (§06).
你们会存我的 prompt 吗? 网关不存请求与响应正文、不设响应缓存;我们不训练、不出售。Claude / GPT 上游按其商用条款不用你的内容训练,但会按其政策短期保留(如 Anthropic 默认 30 天内删除,Fable 系列要求 30 天留存),上游提示缓存也会短时保存请求开头部分。详见 §17 与隐私政策。Do you store my prompts? The gateway doesn't store request or response content and keeps no response cache; we don't train on it or sell it. Under their commercial terms the Claude / GPT upstreams don't train on your content, but they retain it briefly under their own policies (for example, Anthropic deletes within 30 days by default and requires 30-day retention for Fable models), and upstream prompt caching briefly holds the beginning of a request. See §17 and the Privacy Policy.
是"降智"中转吗? 不是。官方通道、原生返回、可自验(§18)。Is this a "downgraded" relay? No. Official routing, native responses, self-verifiable (§18).
Claude 和 GPT 的缓存一样吗? 不一样:Claude = 网关注入的 Anthropic Prompt Cache;GPT = OpenAI 自家自动输入缓存(§06/§07)。Same cache for Claude and GPT? No: Claude = gateway-injected Anthropic Prompt Cache; GPT = OpenAI's own automatic input cache (§06/§07).
国内卡能付吗? 信用卡走 Stripe;不便的用兑换码 / 对公(§15)。Can I pay with a domestic card? Cards via Stripe; otherwise redemption codes / wire (§15).
22联系 / 企业实施Contact / enterprise
技术接入 · 提额 · 企业实施 / 专属直连(高校 / SMB 定制化):Integration · higher limits · enterprise & dedicated direct access (university / SMB): service@solunarai.com
→迁移指南Migration guide
从 Anthropic 官方直连(改 2 行)From Anthropic direct (2 lines)
client = anthropic.Anthropic(
- api_key="official-key",
+ api_key="sk-your-console-key",
+ base_url="https://console.solunarai.com",
)
模型名不变(dash);Prompt Cache 自动生效。Model names unchanged (dash); Prompt Cache kicks in automatically.
从 OpenAI 官方(改 base_url + key)From OpenAI direct (base_url + key)
client = OpenAI(
- api_key="official-key",
+ api_key="sk-your-console-key",
+ base_url="https://console.solunarai.com/v1",
)
gpt-5.5 等名称直接用;Claude 模型推荐用 dot 名。Use gpt-5.5 etc. directly; for Claude models the dot name is recommended.