Solunar AI / 接入文档Docs

接入文档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

A · 概念Concepts

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:

你的客户端Your client → Solunar 网关gateway → 官方上游 (Anthropic / OpenAI)Official upstream (Anthropic / OpenAI) → 原样返回Native response

独立加拿大主体(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/messagesAnthropic 原生:Anthropic SDK / Claude Code / 全保真Anthropic native: Anthropic SDK / Claude Code / full fidelityClaude dashClaude dash claude-sonnet-4-6✅ 自动(Claude)auto (Claude)
/v1/chat/completionsOpenAI 兼容:Cursor / Cline / LangChain / GPTOpenAI compatible: Cursor / Cline / LangChain / GPTClaude 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.

SDK 里 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/messagesx-api-key: sk-… + anthropic-version: 2023-06-01 + anthropic-version: 2023-06-01
/v1/chat/completionsAuthorization: Bearer sk-… (OpenAI 风格)(OpenAI style)
B · 模型Models

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)

模型Modeldashcontext最大输出max outtoolvisionthinkingcache
Opus 5.5claude-opus-5-51M128K✓✓始终开启 · effortalways on · effort✓
Sonnet 5.5claude-sonnet-5-51M128K✓✓effort · between_toolseffort · between_tools✓
Fable 5.1claude-fable-5-11M128K✓✓始终开启 · effortalways on · effort✓
Opus 4.8(旗舰)Opus 4.8 (flagship)claude-opus-4-81M128K✓✓自适应adaptive✓
Opus 4.7claude-opus-4-71M128K✓✓自适应adaptive✓
Sonnet 4.6(主力)Sonnet 4.6 (workhorse)claude-sonnet-4-61M64K✓✓自适应adaptive✓
Haiku 4.5(省钱/快)Haiku 4.5 (cheap/fast)claude-haiku-4-5200K64K✓✓扩展extended✓

OpenAI / GPTOpenAI / GPT (单名,只走 /v1/chat/completions)(single name, /v1/chat/completions only)

模型Modelcontext最大输出max out类型typecache
gpt-5.5 (旗舰)(flagship)1,050,000128,000reasoningOpenAI 自动输入缓存OpenAI auto input cache
gpt-5.4 (主力)(workhorse)1,050,000128,000通用generalOpenAI 自动输入缓存OpenAI auto input cache
gpt-5.4-mini (便宜)(cheap)400,000128,000通用generalOpenAI 自动输入缓存OpenAI auto input cache

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.5claude-opus-5-5claude-opus-5.5
Sonnet 5.5claude-sonnet-5-5claude-sonnet-5.5

思考(thinking)Thinking

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)

其他差异Other differences

已生产实测(2026-10-16):Verified in production (2026-10-16): 上面四个模型名经网关调用均正常返回;Sonnet 5.5 同一请求第二次发送时 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.1claude-fable-5-1claude-fable-5.1
数据留存与水印:Data retention and watermark: Anthropic 将 Fable 系列列为"受管模型"(Covered Models),并要求 30 天数据留存:选用 Fable 5.1 时,Anthropic 会将相关内容保留 30 天,且不提供零数据留存(ZDR)。Fable 5.1 生成的文本带有 Anthropic 的统计文本水印;据 Anthropic 说明,水印不改变输出的含义或质量,不增加 token 或隐藏字符,也不包含关于你或你所在组织的信息。如不希望适用这些条件,请选用其他模型。详见隐私政策 §3。 Anthropic designates Fable models as "Covered Models" and requires 30-day data retention for them: when you select Fable 5.1, Anthropic retains the related content for 30 days, and zero data retention (ZDR) is not available. Text generated by Fable 5.1 carries Anthropic's statistical text watermark; according to Anthropic, the watermark does not change the meaning or quality of the output, adds no tokens or hidden characters, and carries no information about you or your organization. If you need these conditions not to apply, choose a different model. See the Privacy Policy §3.

思考(thinking)Thinking

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)

多轮对话与思考块Multi-turn conversations and thinking blocks

其他Other

已生产实测(2026-10-17):Verified in production (2026-10-17): 两个模型名在两个入口经网关调用均正常返回;同一请求第二次发送时 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

原生接口 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.

已生产实测(2026-10-14):Verified in production (2026-10-14): 原生入口多轮工具调用中 thinking 块与签名回传正常,流式 thinking / signature 增量正常;一次约 31 万 token 的请求(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 namex-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 reasoningthinking 参数(§05)thinking parameter (§05)reasoning_effort;thinking 参数不生效; thinking is ignored
返回的推理内容Reasoning returned asthinking 块 + 签名thinking blocks + signaturereasoning_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.

C · 省钱Savings

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).

已生产实测(2026-10-15):Verified in production (2026-10-15): 同一长 system 发两次,第二次 /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.

这是 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).

D · 集成指南(per-tool)Integration guides (per-tool)

速查表 — 找你的工具Find your tool

先在下表找到你的客户端 / 智能体,看走哪条路径、模型名怎么写,再点"跳转"看配置。Find your client / agent below — see which path and model-name form to use, then jump to its config.

统一规则 —— native(/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 CodeCLI 编码 agentCLI coding agentnativedash§10
Cursor编辑器Editor兼容compatdot · gpt§11
ClineVS Code Agent皆可eitherdot · dash§12
Roo CodeVS Code Agent皆可eitherdot · dash§12
Continue编辑器 AgentEditor agent皆可eitherdash · dot · gpt§14
AiderCLI 编码CLI coding兼容compatopenai/…§14
LangChain / LangGraph框架Framework皆可eitherdash · dot · gpt§13
Cherry Studio桌面客户端Desktop兼容compatdot · gpt§14
ChatBox桌面客户端Desktop兼容compatdot · gpt§14
Open WebUI自托管Self-host兼容compatdot · gpt§14
LobeChat自托管 / 桌面Self-host兼容compatdot · gpt§14
NextChat自托管 / 桌面Self-host兼容compatdot · gpt§14
DifyAgent / 工作流平台Agent platform兼容compatdot · gpt§14
Anthropic / OpenAI SDK代码Code各自native / compatdash / dot · gpt§08–09
其它 OpenAI-兼容Other OpenAI-compatible—兼容compatdot · 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:

保存后在模型选择器里选刚加的模型即可。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:

也可用 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 WebUISettings → 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 兼容"客户端(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.

E · 运维Operations

15计费与额度Billing & credits

16限额与速率Limits & rate

17数据边界(你的数据只属于你)Data boundary (your data is yours)

详见隐私政策 / 服务条款 / 可接受使用政策。See the Privacy Policy / Terms / Acceptable Use Policy.

18验证"官方纯正 / 不降智"Verify integrity (no downgrade)

我们承诺官方通道、不降级,你可自验:We promise official routing, no downgrade. You can verify:

F · 参考Reference

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
400invalid_request否noJSON 格式错 / 缺 model·max_tokens / 角色不交替 / 参数超限malformed JSON / missing model·max_tokens / roles not alternating / param out of range
401authentication否nokey 无效 / 缺鉴权头 / 头用错(x-api-key vs Bearer)invalid key / missing header / wrong header (x-api-key vs Bearer)
402insufficient_quota否noconsole 余额为 0 / 欠费 → 充值zero balance / unpaid → top up
403permission否nokey 无权访问该模型 / 该模型未对你开放;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
404not_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
413request_too_large否no请求体 / 输入过大 → 截断历史 / 分块request/input too large → trim history / chunk
429rate_limit是yes撞 RPM/TPM / 单笔单日上限 → 退避重试,查 retry-afterRPM/TPM or per-tx/day cap → back off, check retry-after
500api_error是yes上游 / 处理临时故障 → 指数退避transient upstream/processing error → exponential backoff
529overloaded是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 failedkey 有效 / 余额 > 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 contentreasoning 模型,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

→迁移指南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.