通过环境变量配置 API 地址和密钥,无需改动代码即可接入 Nodebyt。
API 端点
Anthropic SDK(Claude Code 等)
ANTHROPIC_BASE_URL=https://api.nodebyt.comOpenAI SDK / HTTP
base_url=https://api.nodebyt.com/v1仅当前终端窗口有效,关闭后失效。适合临时测试。
# PowerShell (valid for current session only)
$env:ANTHROPIC_BASE_URL = "https://api.nodebyt.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-api-key"仅当前终端窗口有效,关闭后失效。适合临时测试。
# bash / zsh (valid for current session only)
export ANTHROPIC_BASE_URL="https://api.nodebyt.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-api-key"Anthropic 官方命令行工具,通过环境变量连接 Nodebyt,无需改动代码。
前往「API Key 管理」页面一键下载配置脚本 →或手动设置环境变量:
# bash / zsh (valid for current session only)
export ANTHROPIC_BASE_URL="https://api.nodebyt.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-api-key"配置完成后启动:
claudeOpenAI 官方 Codex 命令行工具,走 /v1/responses 接口。注意 base_url 必须带 /v1。
前往「API Key 管理」页面一键下载配置脚本 →编辑 ~/.codex/config.toml:
model_provider = "nodebyt"
model = "gpt-5.3-codex"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"
[model_providers.nodebyt]
name = "nodebyt"
base_url = "https://api.nodebyt.com/v1"
wire_api = "responses"
env_key = "NODEBYT_API_KEY"然后设置 API Key 到环境变量:
# bash / zsh
export NODEBYT_API_KEY="sk-your-api-key"配置完成后启动:
codex使用 Anthropic 官方 SDK,通过环境变量自动读取 base_url 和 api_key。
from anthropic import Anthropic
# Automatically reads ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN from env
client = Anthropic()
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)安装:pip install anthropic
请求体加入 stream: true 即可启用 SSE 流式输出,适合聊天界面实时渲染。
from anthropic import Anthropic
client = Anthropic()
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about Go."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)/v1/* 路径遵循 OpenAI 错误格式,错误 JSON 包含 type / code / message。
{
"error": {
"type": "invalid_request_error",
"code": "insufficient_quota",
"message": "余额不足"
}
}常见错误码
| HTTP | Message |
|---|---|
401 | API Key 无效或未提供 |
402 | 余额不足,请前往充值 |
429 | 触发限流或每日配额耗尽 |
503 | 上游渠道全部不可用(熔断中) |