Connect Your Coding CLI in 60 Seconds 60 秒接入三大终端 AI 编程神器
One LightAI API key (sk-...) unlocks native Claude 5.5 / Fable 5.2 and GPT-6 / 6.1 across Claude Code, OpenCode, and Codex CLI at a flat 70% discount.
使用同一个 LightAI 密钥(sk-...),即可在 Claude Code、OpenCode 与 Codex CLI 中以官方 3 折直连最新一代 Claude 5.5 / Fable 5.2 与 GPT-6 / 6.1 旗舰模型。
| Client客户端工具 | Exact Base URL填写的 Base URL | Trailing /v1?结尾是否带 /v1 | Native Wire Protocol底层原生协议 |
|---|---|---|---|
| Claude Code | https://api.lightai.io |
NO /v1不带 /v1 | Anthropic /v1/messages |
| OpenCode | https://api.lightai.io/v1 |
Include /v1带 /v1 | @ai-sdk/anthropic + openai |
| Codex CLI | https://api.lightai.io/v1 |
Include /v1带 /v1 | OpenAI /v1/responses |
1. Claude Code
Claude Code speaks native Anthropic Messages (/v1/messages) with full Extended Thinking and 0.025×–0.05× Prompt Caching support.
Claude Code 走原生 Anthropic Messages(/v1/messages)协议,满血支持 Extended Thinking 深度思考与低至 0.025×–0.05× 的提示词缓存省钱。
ANTHROPIC_BASE_URL as https://api.lightai.io (without /v1), because Claude Code appends /v1/messages automatically.
防踩坑提示:ANTHROPIC_BASE_URL 请填 https://api.lightai.io(结尾不要加 /v1),因为 Claude Code 会自动拼接 /v1/messages。
Option A · Quick Shell Launch方式一:终端环境变量快速启动
export ANTHROPIC_BASE_URL="https://api.lightai.io" export ANTHROPIC_AUTH_TOKEN="sk-your-lightai-key" claude
Option B · Persistent Config (Recommended)方式二:写入永久配置文件(推荐,一劳永逸)
Save to ~/.claude/settings.json so every terminal tab and IDE session automatically uses LightAI and defaults to claude-opus-5-5:
写入 ~/.claude/settings.json 后,所有新开终端窗口与 IDE 内置终端都会自动生效,无需每次 export:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.lightai.io",
"ANTHROPIC_AUTH_TOKEN": "sk-your-lightai-key"
},
"model": "claude-opus-5-5"
}
2. OpenCode
OpenCode lets you switch freely between Claude 5.5 / Fable 5.2 and GPT-6 / 6.1 inside a single coding session. Our template configures @ai-sdk/anthropic for Claude (so native 0.025×–0.05× Prompt Caching triggers automatically!) and @ai-sdk/openai-compatible for GPT-6, with LightAI's exact 70%-off rates shown in OpenCode's live cost bar.
OpenCode 支持在同一编程会话中自由切换 Claude 5.5 / Fable 5.2 与 GPT-6 / 6.1。下方配置为 Claude 启用原生 @ai-sdk/anthropic 驱动(自动激活低至 0.025×–0.05× 缓存省钱与思考块),并内置了全部 6 款纯血旗舰的精确 3 折单价,让 OpenCode 右下角实时费用统计与实际扣费分毫不差。
Option A · 1-Line Auto Installer (Recommended)方式一:一行命令自动配齐全部 6 款主力旗舰(推荐)
Automatically backs up any existing opencode.json to opencode.json.bak and merges all 6 LightAI flagship models:
自动备份你原有的 opencode.json 为 .bak,无损注入 LightAI 全系 Claude 5.5 + GPT-6.1 旗舰模型:
export LIGHTAI_API_KEY="sk-your-lightai-key" curl -fsSL https://api.lightai.io/static/opencode.sh | sh opencode
Option B · Full Manual Template (~/.config/opencode/opencode.json)方式二:手动复制完整模板 (~/.config/opencode/opencode.json)
{
"$schema": "https://opencode.ai/config.json",
"model": "lightai-claude/claude-opus-5-5",
"provider": {
"lightai-claude": {
"name": "LightAI (Claude)",
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "https://api.lightai.io/v1",
"apiKey": "sk-your-lightai-key"
},
"models": {
"claude-fable-5-2": {
"name": "Claude Fable 5.2",
"reasoning": true,
"tool_call": true,
"attachment": true,
"temperature": true,
"cost": { "input": 2.40, "output": 12.00, "cache_read": 0.06, "cache_write": 3.00 },
"limit": { "context": 200000, "output": 64000 }
},
"claude-opus-5-5": {
"name": "Claude Opus 5.5",
"reasoning": true,
"tool_call": true,
"attachment": true,
"temperature": true,
"cost": { "input": 1.20, "output": 6.00, "cache_read": 0.06, "cache_write": 1.50 },
"limit": { "context": 200000, "output": 64000 }
},
"claude-sonnet-5-5": {
"name": "Claude Sonnet 5.5",
"reasoning": true,
"tool_call": true,
"attachment": true,
"temperature": true,
"cost": { "input": 0.60, "output": 3.00, "cache_read": 0.03, "cache_write": 0.75 },
"limit": { "context": 200000, "output": 64000 }
}
}
},
"lightai-openai": {
"name": "LightAI (OpenAI)",
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.lightai.io/v1",
"apiKey": "sk-your-lightai-key"
},
"models": {
"gpt-6-astra": {
"name": "GPT-6 Astra",
"reasoning": true,
"tool_call": true,
"attachment": true,
"temperature": true,
"cost": { "input": 3.00, "output": 15.00, "cache_read": 0.30 },
"limit": { "context": 400000, "output": 128000 }
},
"gpt-6.1-sol": {
"name": "GPT-6.1 Sol",
"reasoning": true,
"tool_call": true,
"attachment": true,
"temperature": true,
"cost": { "input": 0.60, "output": 3.00, "cache_read": 0.03 },
"limit": { "context": 400000, "output": 128000 }
},
"gpt-6.1-terra": {
"name": "GPT-6.1 Terra",
"reasoning": true,
"tool_call": true,
"attachment": true,
"temperature": true,
"cost": { "input": 0.30, "output": 1.50, "cache_read": 0.015 },
"limit": { "context": 400000, "output": 64000 }
}
}
}
}
}
3. Codex CLI
Codex CLI and the Codex desktop app share ~/.codex/config.toml and communicate over the native OpenAI Responses API (/v1/responses). You can set model to gpt-6.1-sol, gpt-6-astra, or gpt-6.1-terra.
Codex CLI 与 Codex 桌面端共用 ~/.codex/config.toml,底层走原生 OpenAI Responses 协议(/v1/responses)。主力日常编程推荐 gpt-6.1-sol,复杂架构攻坚可切换为 gpt-6-astra。
model = "gpt-6.1-sol" model_provider = "lightai" [model_providers.lightai] name = "LightAI" base_url = "https://api.lightai.io/v1" experimental_bearer_token = "sk-your-lightai-key" wire_api = "responses"
sk-... key inside experimental_bearer_token (do not add a Bearer prefix), then run codex directly in your project folder.
提示:experimental_bearer_token 内直接填纯 sk-... 密钥(不要加 Bearer 前缀),保存后在项目目录直接运行 codex 即可。
Models & Legacy Auto-Upgrade旗舰模型价格与老模型号自动升级
Many CLI tools hardcode older 4.x or 5.x model names for background title generation or sub-agents. LightAI silently maps all legacy aliases to their newest-generation flagship counterparts so requests never fail with "model not found": 许多客户端子任务或插件内部写死了旧版 4.x / 5.x 模型名。LightAI 网关在底层做了无缝兼容映射,无需修改客户端源码即可自动路由至最新一代旗舰:
| Flagship Model ID最新旗舰模型号 | Input / Output (1M)输入 / 输出 (每百万) | Cache Read (30% of Official)缓存读取 (官方 3 折) | Auto-Upgraded Legacy Aliases后台自动兼容映射的旧模型号 |
|---|---|---|---|
claude-fable-5-2 |
$2.40 / $12.00 | $0.06 (0.025×) | claude-fable-5, 5-0, 5-1 |
claude-opus-5-5 |
$1.20 / $6.00 | $0.06 (0.05×) | claude-opus-5 / 5-1 / 5-2, 4-8 / 4-7 / 4-6 / 4-5 |
claude-sonnet-5-5 |
$0.60 / $3.00 | $0.03 (0.05×) | claude-sonnet-5 / 5-1 / 5-2, 4-6 / 4-5 |
gpt-6-astra |
$3.00 / $15.00 | $0.30 (0.10×) | gpt-6 |
gpt-6.1-sol |
$0.60 / $3.00 | $0.03 (0.05×) | gpt-6-sol, gpt-5.6-sol, gpt-5.4 / 5.2 / 5.1 / 5 |
gpt-6.1-terra |
$0.30 / $1.50 | $0.015 (0.05×) | gpt-6-luna, gpt-5.6-terra / luna, gpt-5.1-mini / 5-mini |
Prompt Caching & USDT Top-Up FAQ缓存计费与 USDT/USDC 充值说明
When using Claude Code, OpenCode, or Codex CLI on a large codebase, 85%+ of each turn repeats your system prompt and repository context. LightAI mirrors official cache multipliers at flat 30% of official rates: 0.025× on Fable 5.2 ($0.06 / 1M), 0.05× on Opus 5.5 ($0.06 / 1M), Sonnet 5.5 & GPT-6.1 Sol ($0.03 / 1M), and GPT-6.1 Terra ($0.015 / 1M), plus 0.10× on GPT-6 Astra ($0.30 / 1M). Cache creation is 1.25× once. No manual setup required!
在用 Claude Code、OpenCode 或 Codex 改项目代码时,每一轮对话有 85% 以上的上下文(项目文件与系统提示词)是重复的。LightAI 严格同步官方最新缓存读取倍率并同样按官方 3 折计费:Fable 5.2 为 0.025×(仅 $0.06 / 1M),Opus 5.5 为 0.05×($0.06 / 1M),Sonnet 5.5 与 GPT-6.1 Sol 为 0.05×($0.03 / 1M),GPT-6.1 Terra 仅 $0.015 / 1M,GPT-6 Astra 为 0.10×($0.30 / 1M);首次写入缓存为 1.25×。三大工具均已内置自动触发,无需任何额外配置。
We support 1:1 USD top-ups from $1 via TRC20, BSC (BEP20), Arbitrum, Base, Polygon, and ERC20. Always transfer the exact decimal amount displayed on the checkout page (e.g. 10.02 USDT) on the matching chain — our on-chain listener matches orders by exact amount and credits your account automatically within 5–30 seconds. Balances never expire.
支持 $1 起充,1 USDT/USDC = $1.00 额度,覆盖 TRC20、BSC (BEP20)、Arbitrum、Base、Polygon 与 ERC20。转账时请务必核对所选公链,并严格按照收银台显示的精确小数金额转入(如显示 10.02 就转 10.02,交易所提币请注意扣除手续费后的实际到账金额),链上确认后 5~30 秒全自动秒上分,余额永不过期。
Common HTTP Error Codes常见报错状态码速查
| Code | Meaning & Fix原因与排查方法 |
|---|---|
401 |
Invalid or missing API key. Verify your sk-... token in Console → API Keys and ensure no extra spaces or Bearer duplication.API Key 无效或未传。请前往「控制台 → 令牌管理」核对 sk-... 密钥是否复制完整、有无多余空格。 |
402 / 403 |
Insufficient account or token quota. Top up in Console → Wallet or check if you set a spend limit on that specific token.账户余额不足或该令牌设置了额度上限。请前往「钱包充值」补足额度,或将令牌设为无限额度。 |
404 |
Wrong endpoint path — usually caused by adding /v1 to Claude Code's ANTHROPIC_BASE_URL or omitting /v1 in OpenCode / Codex CLI.接口路径错误——常见于 Claude Code 误加了 /v1,或 OpenCode / Codex 漏填了 /v1,请对照页面顶部表格修正。 |
429 |
Burst concurrency limit reached. CLI clients will automatically back off and retry within 1–2 seconds.瞬时并发过高触发限流保护,Claude Code / OpenCode 会自动退避并在 1~2 秒内重试成功。 |
502 / 504 |
Temporary upstream congestion or long reasoning timeout. Retry the turn; no quota is deducted on failed upstream requests.上游瞬时拥塞或超长思考超时。直接重试即可,未完成的失败请求不会扣除额度。 |