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-06-16

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 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/completionsWhich to use: full Claude native capabilities (thinking, native tool streaming, metadata) → /v1/messages; OpenAI-only tools → /v1/chat/completions; GPT → /v1/chat/completions only.

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
Fable 5claude-fable-51M128K自适应adaptive
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 NEW (单名,只走 /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(Fable 5 / Opus 4.8 / 4.7 / Sonnet 4.6):"thinking":{"type":"adaptive"} + "output_config":{"effort":"high"}。tool use / vision / streaming 按原生用法,网关全保真透传(§18)。Thinking (Fable 5 / 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).

06OpenAI / GPT 接入OpenAI / GPT integration NEW

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

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-06-15):Verified in production (2026-06-15): 同一长 system 发两次,第二次 /v1/messages cache_read_input_tokens=1385/v1/chat/completions cached_tokens=1219,均按缓存价(0.1×)计费 —— 重复请求端到端省约 87% Sending the same long system twice: /v1/messages returned cache_read_input_tokens=1385 and /v1/chat/completions returned cached_tokens=1219, both billed at the cache rate (0.1×) — about 87% cheaper end-to-end on the repeat.

这是 Anthropic 官方 Prompt Cache,与"我们不缓存你的内容"(§17)不冲突:它是上游侧对你自己请求前缀的计费优化,按工作区隔离,不跨客户。这与"推理层响应缓存已禁用"是两件事。This is the official Anthropic Prompt Cache and does not conflict with "we don't store your content" (§17): it's an upstream billing optimization on your own request prefix, isolated per workspace, never shared across customers. That is separate from "the inference-layer response cache is disabled."

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 rulesnative (/v1/messages): base_url https://console.solunarai.com, auth x-api-key, model dash (claude-sonnet-4-6); compatible (/v1/chat/completions): base_url https://console.solunarai.com/v1, auth Bearer, model dot (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

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. 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. 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 dash name from the console list).

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.

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_requestnoJSON 格式错 / 缺 model·max_tokens / 角色不交替 / 参数超限malformed JSON / missing model·max_tokens / roles not alternating / param out of range
401authenticationnokey 无效 / 缺鉴权头 / 头用错(x-api-key vs Bearer)invalid key / missing header / wrong header (x-api-key vs Bearer)
402insufficient_quotanoconsole 余额为 0 / 欠费 → 充值zero balance / unpaid → top up
403permissionnokey 无权访问该模型 / 该模型未对你开放key lacks access to the model / model not enabled for you
404not_foundno模型名拼错 / 写法用错(dash↔dot) / 端点路径错model name typo / wrong form (dash↔dot) / wrong endpoint path
413request_too_largeno请求体 / 输入过大 → 截断历史 / 分块request/input too large → trim history / chunk
429rate_limityes撞 RPM/TPM / 单笔单日上限 → 退避重试,查 retry-afterRPM/TPM or per-tx/day cap → back off, check retry-after
500api_erroryes上游 / 处理临时故障 → 指数退避transient upstream/processing error → exponential backoff
529overloadedyes上游过载 → 退避 / 换模型 / 错峰upstream overloaded → back off / switch model / spread load

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)② 内容是否达最小长度(约 2048–4096,§07)③ 前缀是否逐字节一致(时间戳/UUID/未排序 JSON 会破)④ 间隔是否超期① Claude or GPT (GPT → cached_tokens) ② content ≥ minimum (≈2048–4096, §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)
模型 404model 404用 console 确切名;messages 用 dash、chat 用 dot;GPT 只走 chat/completionsuse the exact console name; 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 offstream:true 且正确处理 SSE;大输出务必开 streamset stream:true and handle SSE; always stream large outputs

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 场景生产实测端到端约 87%、接近约 90% 缓存上限(2026-06-15)。Is the saving real? On Claude the gateway auto-injects the official Prompt Cache — about 87% end-to-end measured on repeated-system workloads, approaching the ~90% cache ceiling (2026-06-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 吗? 不存正文、不缓存内容、不训练、不转卖(§17)。Do you read / store my prompts? No content stored, no content caching, no training, no resale (§17).

是"降智"中转吗? 不是。官方通道、原生返回、可自验(§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 use the dot name.