文档
一条提示词即可开始。
ScaledThought 以智能体为先:你的智能体负责注册和具体工作,需要时你可以使用一个控制台来管理账单、密钥和团队成员。这里的所有内容都同时写给你和智能体。API 是 OpenAI-compatible 的:大多数 OpenAI SDK 代码只需更改 base URL 和密钥即可使用。
快速入门
最简单:让你的智能体来做
把这段内容粘贴到 Claude Code、Codex、Cursor 或任何能运行命令的智能体中。它会读取 /llms.txt 并执行配置步骤。
这些是指向你已安装应用的深层链接。Claude 和 Claude Code 是 Anthropic 的商标;Codex 是 OpenAI 的商标。ScaledThought 与二者均无关联,也未获得二者认可。
与 Anthropic、OpenAI、Cursor 或任何模型发布方均无关联,也未获得其认可。Claude、Claude Code、Codex、Cursor、OpenAI 及各模型名称均为其所有者的商标。
或者运行一条命令
在美国区域创建账户,把 ST_API_KEY 和 ST_BASE_URL 写入 .env,并列出该区域已上线的模型。可以放心重复运行:如果已有密钥,它只会报告账户信息。加拿大区域即将推出;在开放之前,它的 API 不会响应,--region ca 会以 network_error 失败。
npx -y scaledthought@0.3 init --region us购买额度
每次调用都从预付额度中支付,每次充值 $20 至 $2,000,每 24 小时最多 $2,000,同时最多 2 个未完成的审批链接。智能体申请充值,并把返回的 approval_url 发给人类用户,由对方用银行卡付款。额度到账之前,调用会返回 402 insufficient_credits。详见额度与审批。
npx -y scaledthought@0.3 billing topup --amount-usd 20发起第一次调用
curl "$ST_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ST_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "deepseek-v4-1-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'认证
把密钥作为 bearer token 发送。密钥限定于一个区域,并且可以有自己的预算。base URL 是你所在区域的主机,以 ST_BASE_URL 保存在 .env 中:https://api.us.scaledthought.com/v1(加拿大的 https://api.ca.scaledthought.com/v1 即将推出)。
Authorization: Bearer $ST_API_KEY
Content-Type: application/json对话补全
POST /v1/chat/completions 接受 OpenAI 的请求格式。请使用来自 npx -y scaledthought@0.3 models --live 或 /pricing 的模型 id。
curl "$ST_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ST_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "deepseek-v4-1-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'流式输出
设置 stream: true,即可以 OpenAI delta 格式接收服务器发送事件(server-sent events)。
stream = client.chat.completions.create(
model="deepseek-v4-1-flash",
messages=[{"role": "user", "content": "Write a haiku about open weights"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")工具调用
以 OpenAI 格式传入 tools。支持工具调用的模型会返回标准的 tool_calls。支持程度和质量因模型而异,依赖它之前请先查看该模型的说明卡片。
resp = client.chat.completions.create(
model="deepseek-v4-1-flash",
messages=[{"role": "user", "content": "Weather in Toronto?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
},
}],
)
print(resp.choices[0].message.tool_calls)结构化输出
使用带 JSON schema 的 response_format。在支持该功能的模型上,输出会在解码时被约束为符合该 schema。依赖结果之前请先进行验证。
resp = client.chat.completions.create(
model="deepseek-v4-1-flash",
messages=[{"role": "user", "content": invoice_text}],
response_format={
"type": "json_schema",
"json_schema": {"name": "invoice", "schema": {
"type": "object",
"properties": {"vendor": {"type": "string"}, "total": {"type": "number"}},
"required": ["vendor", "total"],
}},
},
)Responses API 与 Codex
POST $ST_BASE_URL/responses 支持 OpenAI Responses API,因此只使用该协议的客户端(例如 Codex)可以把 ScaledThought 作为模型提供方。它接受 input(字符串,或消息、function_call 和 function_call_output 条目)、instructions、函数工具和自定义(自由格式)工具、tool_choice、max_output_tokens、用于 JSON 输出的 text.format,以及 stream: true(Responses 事件,以带 usage 的 response.completed 或 response.incomplete 结束,或以带 error 的 response.failed 结束)。
它是无状态的。我们不存储任何响应,所以每一轮都要在 input 中发送完整对话(Codex 就是这样做的),并且不要传 previous_response_id,否则会返回 400 invalid_request;store 始终为 false。文件搜索等托管工具会返回 400;网页搜索工具会被忽略。没有 max_output_tokens 的请求,上限为模型上下文在你的提示词之后剩余的长度,最多 32,768 个 token。
计费方式与对话补全相同:按 token 计费,依据模型服务器报告的用量,从你的额度中支付。
# ~/.codex/config.toml
model = "deepseek-v4-1-flash" # or a model id from `npx -y scaledthought@0.3 models --live`
model_provider = "scaledthought"
[model_providers.scaledthought]
name = "ScaledThought"
base_url = "https://api.us.scaledthought.com/v1" # your ST_BASE_URL
env_key = "ST_API_KEY"
wire_api = "responses"
model_catalog_url = "https://api.us.scaledthought.com/v1/codex/models" # same host (and region) as base_urlCodex 从环境变量中读取 ST_API_KEY,所以请先把 ./.env 加载到 shell 中。wire_api = "responses" 是必需的:ScaledThought 通过 Responses API 为 Codex 提供服务。
model_catalog_url 告诉 Codex 你所在区域已上线模型的上下文窗口,使它能及时压缩长会话,并为它提供 apply_patch 编辑工具。它在每次请求时根据已上线的模型生成;Codex 会随请求发送你的密钥,所以请让它与 base_url 使用同一个主机(你所在区域的主机)。
模型与基准测试
GET /v1/models 以 OpenAI 的格式列出你所在区域已上线的模型 id。这个列表就是你能调用哪些模型的准确依据。GET /v1/models/{id} 返回单个模型的价格、上下文长度、发布日期、基准测试分数和上线状态,让智能体无需有人去阅读网页就能做出选择。如需搜索和筛选,请使用 npx -y scaledthought@0.3 models --live 或 MCP 工具 models_search。面向人的 /pricing 页面列出美国所有已上线的模型及其价格,数据来自同一个 API。
curl "$ST_BASE_URL/models"
curl "$ST_BASE_URL/models/deepseek-v4-1-flash"区域与数据保留
每个密钥都固定在其区域。美国区域现已开放;加拿大(ca)即将推出,在开放之前它的 API 不会响应。请求只在该国家内处理并记录日志,账户和用量记录也只存储在该国家。所有区域的银行卡付款都由 Stripe 在美国处理。提示词和补全在响应返回后不会被存储,也绝不会用于训练。批处理和微调文件在 30 天后删除,也可以用 DELETE /v1/files/{id} 提前删除。每个响应都带有 x-st-region 和 x-st-data-retention: none。参见安全(或 /security.json)以及隐私政策 (英文)。
密钥与预算
智能体可以创建限定范围的密钥,并设置严格的每日支出上限。达到预算后,调用会返回 402,而不会继续花费。被吊销的密钥会在大约 30 秒内失效。
npx -y scaledthought@0.3 keys create --name support-bot --budget-usd 40权限范围为 inference, read, keys, billing。一个密钥只能给新密钥授予它自己拥有的权限范围(否则返回 403 scope_not_allowed)。有效期:发送 expires_in(例如 "30d")或 expires_at,最长 365 天;到期后该密钥会收到 401 key_expired。密钥的有效期永远不会超过创建它的密钥。
子智能体密钥:设置 child: true 后,新密钥会把调用它的密钥记录为父密钥。它的每日预算不超过父密钥当天剩余的预算,速率限制和有效期不高于父密钥,并且只能管理自己的子密钥。吊销一个密钥会同时吊销它下面的所有密钥。
轮换:POST /v1/keys/{id}/rotate 会生成一个名称、权限范围、预算和限制都相同的替换密钥,只返回一次。旧密钥在 grace 期间继续有效(默认 24h,可设为 "0" 到 "7d")。自我吊销:DELETE /v1/keys/self 会吊销调用它的密钥及其子智能体密钥,无需任何权限范围,因此怀疑密钥泄露的智能体可以立即采取行动。
npx -y scaledthought@0.3 keys create --name sub-agent --child --scopes inference --budget-usd 2 --expires-in 12h
npx -y scaledthought@0.3 keys rotate key_… --grace 24h
npx -y scaledthought@0.3 keys revoke-self关于密钥和数据如何受到保护,详见安全。
额度与审批
用量从预付额度中支付,每次充值 $20 至 $2,000,每 24 小时最多 $2,000,同时最多 2 个未完成的审批链接。智能体申请充值(默认 $20),并获得一个 approval_url:这是一个充值页面,人类用户可以在上面确认或修改金额、开启自动充值,并用银行卡付款。确认付款后额度到账,我们会通过邮件发送收据。未经这一批准,绝不会产生任何扣款。额度不会过期。额度用完时,请求会返回 402 insufficient_credits,附带余额和所需金额。
npx -y scaledthought@0.3 billing topup --amount-usd 20自动充值是可选的,也是推荐的:当余额低于某个阈值(默认 $5)时,已保存的银行卡会充入一笔设定的金额(默认 $20),这样智能体就不会停下来。人类用户可以在任意一次充值的充值页面上开启它,也可以不购买任何东西,通过自动充值设置链接(billing auto-reload setup)保存银行卡来开启。充值上限为每 24 小时 $2,000。开启它或提高任何限额都需要新的批准;关闭它或调低限额则不需要。如果某次自动充值被拒,自动充值会自行关闭,下一次 402 会告诉智能体去获取新的链接。billing status 显示余额和所有待处理的充值;billing transactions 列出每一笔购买、自动充值和扣款。
npx -y scaledthought@0.3 billing topup --amount-usd 20 --auto-reload-below 5 --auto-reload-amount 20
npx -y scaledthought@0.3 billing auto-reload setup --below 5 --amount 20 # no purchase: they save a card
npx -y scaledthought@0.3 billing auto-reload off通知与 Webhook
响应可能带有 x-st-notice,内容是以逗号分隔的代码:low_balance(账户余额低于 $5)。看到它的智能体应当告诉人类用户需要批准什么。GET /v1/account、MCP account_status、status 和 doctor 会显示相同的代码,以及应转告的说明文字。
Webhook 会主动推送相同的信号:balance.low、key.expiring 和 budget.exhausted。端点必须是 443 端口上的公开 https URL。每个 POST 都带有 x-st-signature: t=…,v1=…,这是用该端点的签名密钥对 <t>.<raw body> 计算的 HMAC-SHA256,签名密钥只在你添加端点时显示一次。无论你的 URL 托管在哪里,即使在账户所在区域之外,投递都会发送到该 URL,并且只携带 id、type、created_at、region、account_id 和 data:id、以整数微美元表示的金额、天数和时间戳,绝不包含提示词、姓名或邮箱。每个事件的 data:balance.low {balance_micros, threshold_micros},key.expiring {key_id, expires_at},budget.exhausted {scope, key_id, budget_micros, spent_today_micros, resets_at}。投递失败会以退避方式重试约两天。
npx -y scaledthought@0.3 webhooks add https://hooks.example.com/st --events balance.low,budget.exhausted可选的请求头:x-st-app 在用量记录中标注你的应用名称(不会公开),x-st-session 让同一段对话保持在同一个副本上,以便复用其缓存前缀(只在内存中,从不存储)。在加拿大,请求绝不会溢出到其他国家:当某个模型的所有副本都繁忙时,请求会短暂等待,然后收到带 Retry-After 的 429 capacity_exhausted。
批量推理
上传一个包含请求的 JSONL 文件,以正常价格的 50% 获得结果。批处理在 24 小时的完成窗口内运行,通常会在窗口内完成,但不保证按时完成。Files 和 Batches 端点与 OpenAI 的一致,所以 client.batches.create 可以直接使用。每一行都会预先验证,因此有问题的文件会在几秒内失败。
batch_file = client.files.create(file=open("requests.jsonl", "rb"), purpose="batch")
batch = client.batches.create(
input_file_id=batch_file.id,
endpoint="/v1/chat/completions",
completion_window="24h",
)
# later
batch = client.batches.retrieve(batch.id)
results = client.files.content(batch.output_file_id).text嵌入
POST /v1/embeddings,使用一个嵌入模型(用 models --live --modality embedding 查找)。输入可以是字符串或字符串数组。
vecs = client.embeddings.create(model="<embedding-model-id>", input=["open weights", "served hot"])微调
用你自己的示例训练一个 LoRA 适配器。结果是一个只有你的账户能调用的私有模型 id,与其基础模型在相同的副本上提供服务,并按基础模型的 token 单价计费。只有在你所在区域、运行在我们自有 GPU 上的基础模型才能训练,适配器无法下载。训练按每 1M 训练 token(数据集 token × 轮数)计费;任务响应会在任何运行开始之前给出预估费用。从预付额度中支付。参见价格。
f = client.files.create(file=open("examples.jsonl", "rb"), purpose="fine-tune")
job = client.fine_tuning.jobs.create(model="<base-id>", training_file=f.id, suffix="triage")
# poll
job = client.fine_tuning.jobs.retrieve(job.id)
resp = client.chat.completions.create(model=job.fine_tuned_model, messages=[...])MCP 服务器
远程 MCP 位于你所在区域的 API 主机上:https://api.us.scaledthought.com/mcp(加拿大的 https://api.ca.scaledthought.com/mcp 即将推出;Streamable HTTP,2026-07-28 规范)。用你的 API 密钥作为 bearer token 进行认证。MCP 不能创建账户:请先用 npx -y scaledthought@0.3 init 或 POST /v1/accounts 注册,然后 npx -y scaledthought@0.3 mcp 会打印适用于你所在区域的确切命令和配置。智能体会获得以下工具:
npx -y scaledthought@0.3 mcp- account_status
- Region, spend, credit balance, auto-reload, key count and notices (tell your human about each). Call it first.
- account_settings
- Read or change account settings. ad_measurement: false opts the account out of ad measurement; any key can do it.
- keys_manage
- List, create, rotate or revoke keys (action: list | create | rotate | revoke | revoke_self). create and rotate return the full key once; create takes scopes, expires_in, child (a sub-agent key) and lives_in (where it will be stored); rotate takes grace. revoke_self revokes the key in use.
- budget_manage
- Set or clear a key's hard daily budget (USD) and rate limits.
- webhooks
- Signed HTTPS callbacks for balance.low, key.expiring and budget.exhausted (action: add | list | remove). add returns signing_secret once.
- models_search
- Models with prices, context, benchmarks and live status in your region (live_only, category, search).
- benchmarks_get
- Our own per-task scores and speed for one model.
- usage_query
- Requests, tokens and cost over the last N days, by model, day or key.
- billing_topup
- With amount_usd (and optional auto_reload): an approval_url for your human to buy credits. action: status | transactions | auto_reload_off.
- fine_tuning
- List, get, cancel fine-tuning jobs and their events; list your fine-tuned models.
- docs_search
- Where the docs, llms.txt and your base URL are.
| 工具 | 作用 |
|---|---|
| account_status | Region, spend, credit balance, auto-reload, key count and notices (tell your human about each). Call it first. |
| account_settings | Read or change account settings. ad_measurement: false opts the account out of ad measurement; any key can do it. |
| keys_manage | List, create, rotate or revoke keys (action: list | create | rotate | revoke | revoke_self). create and rotate return the full key once; create takes scopes, expires_in, child (a sub-agent key) and lives_in (where it will be stored); rotate takes grace. revoke_self revokes the key in use. |
| budget_manage | Set or clear a key's hard daily budget (USD) and rate limits. |
| webhooks | Signed HTTPS callbacks for balance.low, key.expiring and budget.exhausted (action: add | list | remove). add returns signing_secret once. |
| models_search | Models with prices, context, benchmarks and live status in your region (live_only, category, search). |
| benchmarks_get | Our own per-task scores and speed for one model. |
| usage_query | Requests, tokens and cost over the last N days, by model, day or key. |
| billing_topup | With amount_usd (and optional auto_reload): an approval_url for your human to buy credits. action: status | transactions | auto_reload_off. |
| fine_tuning | List, get, cancel fine-tuning jobs and their events; list your fine-tuned models. |
| docs_search | Where the docs, llms.txt and your base URL are. |
CLI
以 npx -y scaledthought@0.3 <command> 的形式运行。只要 stdout 不是终端(或使用 --json),输出就是 JSON;错误是 stderr 上的一行 JSON,包含 code、message 和 hint。不会出现任何交互式提示。密钥来自 ST_API_KEY 或 ./.env,从不来自命令行参数。
- init --region us
- Account and key in the US. Writes ST_API_KEY and ST_BASE_URL to .env. Safe to re-run. Canada (ca) is coming soon.
- init --account Acme
- In a new folder on a machine with saved accounts: use that account with a new project key (init asks which when there are several). --new-account makes a separate account; --no-save keeps the key out of this machine's credential store.
- login --region us
- Connect to an existing account: prints a code your human types on the dashboard's connect page (opened in their browser). Then run login --wait.
- login --wait
- Waits about 90 s for your human to approve the code, then writes a new key to .env (never printed). Re-run on authorization_pending.
- login --code -
- Use a connect line made on the dashboard (its stl_ code on stdin, out of shell history): already approved, works once for 15 minutes.
- use "Side project"
- Point this folder at another account saved on this machine: a new project key in .env; the folder's old project key is revoked.
- init --region us --source a-rd
- The same, recording the campaign code of the scaledthought.com/go/<code> link that brought you (optional). An invalid code is dropped with a warning.
- models --live
- Models serving in your region now, newest first, with prices. Filter with --category or --search. The US list is also on /pricing.
- models <id>
- Pricing, context, benchmarks and live status for one model.
- chat -m <id> "prompt"
- Send one message to a model id from models --live.
- account
- Region, spend and credit balance.
- account ad-measurement off
- Opt out of ad measurement: nothing about the account is ever sent to an ad platform. on turns it back on.
- keys create --name <name> --budget-usd 5
- New key with a hard daily budget in USD. The key is printed once.
- keys create --name <name> --expires-in 30d --scopes inference,read
- A key that expires (at most 365d) with a subset of your key's scopes.
- keys create --name <name> --child --budget-usd 2
- A sub-agent key: scopes, budget, rate limits and expiry within your key's; revoked when your key is.
- keys list
- Your keys (prefixes only).
- keys rotate <id> --grace 24h
- Replace a key: the new key is printed once; the old one keeps working for the grace period (0 to 7d).
- keys revoke <id>
- Revoke a key and its sub-agent keys. They stop working within about 30 seconds.
- keys revoke-self
- Revoke the key you are using now (and its sub-agent keys), e.g. if it may have leaked. Irreversible.
- keys put github --repo <owner/repo> --budget-usd 2
- Put a new sub-agent key straight into a platform's secret store as ST_API_KEY, through its own CLI with the key on stdin (never printed). Destinations: github, vercel, fly, cloudflare, gcp, aws, k8s, doppler. The key is named after the place and records where it lives (lives_in). If storing fails, the new key is revoked.
- keys rotate --all --push --grace 1h
- Rotate every key that keys put stored somewhere and put each replacement in the same place; the old keys stop after the grace period. Prints no keys. One key: keys rotate <id> --push.
- connect opencode
- Point an OpenAI-compatible tool at ScaledThought: opencode and aider get the base URL and their own sub-agent key in their config (files 0600, key never printed); cursor and continue get steps for your human.
- usage --days 7 --by model
- Requests, tokens and cost by model, day or key.
- billing status
- Credit balance, auto-reload, pending top-ups.
- billing topup --amount-usd 20
- Buy prepaid credits ($20 to $2,000 per top-up, at most $2,000 per 24 hours and 2 open approval links at a time; default 20): opens the funding page in your human's browser, where they confirm the amount, can turn on auto-reload and pay.
- billing wait
- Returns as soon as your human pays the open top-up, with the new balance. Polls about 90 seconds a run; run it again on topup_pending.
- billing topup --amount-usd 20 --auto-reload-below 5 --auto-reload-amount 20
- Top up with auto-reload pre-selected on the funding page (your human can untick it).
- billing auto-reload setup --below 5 --amount 20
- Turn auto-reload on without buying anything: opens a page where your human saves a card. Then billing wait.
- billing auto-reload off
- Turn auto-reload off. No approval needed.
- billing transactions
- The credit ledger: purchases, auto-reloads, usage, batches, fine-tuning, refunds.
- batches create requests.jsonl
- Upload a JSONL file and start a batch at 50% off. Needs prepaid credits.
- fine-tune create examples.jsonl --model <base-id>
- Upload a dataset and start a LoRA job. Needs prepaid credits.
- webhooks add https://hooks.example.com/st --events balance.low,budget.exhausted
- Get a signed POST when the balance is low, a key is about to expire or a budget is spent (default: every event). Prints signing_secret once.
- webhooks list
- Your webhook endpoints.
- webhooks remove <id>
- Delete a webhook endpoint.
- doctor
- Checks the key in .env, its region, the account and its credit, and lists notices to tell your human.
- mcp
- Prints the `claude mcp add` command and JSON config for your region.
- dashboard --page billing
- Opens your human's dashboard (overview, billing, keys, members, connect) in their browser. If they aren't signed in, one click emails them a link.
- members
- Who can sign in to the account's dashboard: email, role (owner or member), status.
- status
- Per-model health in your region over the last hour, plus your account's notices when a key is set.
| 命令 | 作用 |
|---|---|
| init --region us | Account and key in the US. Writes ST_API_KEY and ST_BASE_URL to .env. Safe to re-run. Canada (ca) is coming soon. |
| init --account Acme | In a new folder on a machine with saved accounts: use that account with a new project key (init asks which when there are several). --new-account makes a separate account; --no-save keeps the key out of this machine's credential store. |
| login --region us | Connect to an existing account: prints a code your human types on the dashboard's connect page (opened in their browser). Then run login --wait. |
| login --wait | Waits about 90 s for your human to approve the code, then writes a new key to .env (never printed). Re-run on authorization_pending. |
| login --code - | Use a connect line made on the dashboard (its stl_ code on stdin, out of shell history): already approved, works once for 15 minutes. |
| use "Side project" | Point this folder at another account saved on this machine: a new project key in .env; the folder's old project key is revoked. |
| init --region us --source a-rd | The same, recording the campaign code of the scaledthought.com/go/<code> link that brought you (optional). An invalid code is dropped with a warning. |
| models --live | Models serving in your region now, newest first, with prices. Filter with --category or --search. The US list is also on /pricing. |
| models <id> | Pricing, context, benchmarks and live status for one model. |
| chat -m <id> "prompt" | Send one message to a model id from models --live. |
| account | Region, spend and credit balance. |
| account ad-measurement off | Opt out of ad measurement: nothing about the account is ever sent to an ad platform. on turns it back on. |
| keys create --name <name> --budget-usd 5 | New key with a hard daily budget in USD. The key is printed once. |
| keys create --name <name> --expires-in 30d --scopes inference,read | A key that expires (at most 365d) with a subset of your key's scopes. |
| keys create --name <name> --child --budget-usd 2 | A sub-agent key: scopes, budget, rate limits and expiry within your key's; revoked when your key is. |
| keys list | Your keys (prefixes only). |
| keys rotate <id> --grace 24h | Replace a key: the new key is printed once; the old one keeps working for the grace period (0 to 7d). |
| keys revoke <id> | Revoke a key and its sub-agent keys. They stop working within about 30 seconds. |
| keys revoke-self | Revoke the key you are using now (and its sub-agent keys), e.g. if it may have leaked. Irreversible. |
| keys put github --repo <owner/repo> --budget-usd 2 | Put a new sub-agent key straight into a platform's secret store as ST_API_KEY, through its own CLI with the key on stdin (never printed). Destinations: github, vercel, fly, cloudflare, gcp, aws, k8s, doppler. The key is named after the place and records where it lives (lives_in). If storing fails, the new key is revoked. |
| keys rotate --all --push --grace 1h | Rotate every key that keys put stored somewhere and put each replacement in the same place; the old keys stop after the grace period. Prints no keys. One key: keys rotate <id> --push. |
| connect opencode | Point an OpenAI-compatible tool at ScaledThought: opencode and aider get the base URL and their own sub-agent key in their config (files 0600, key never printed); cursor and continue get steps for your human. |
| usage --days 7 --by model | Requests, tokens and cost by model, day or key. |
| billing status | Credit balance, auto-reload, pending top-ups. |
| billing topup --amount-usd 20 | Buy prepaid credits ($20 to $2,000 per top-up, at most $2,000 per 24 hours and 2 open approval links at a time; default 20): opens the funding page in your human's browser, where they confirm the amount, can turn on auto-reload and pay. |
| billing wait | Returns as soon as your human pays the open top-up, with the new balance. Polls about 90 seconds a run; run it again on topup_pending. |
| billing topup --amount-usd 20 --auto-reload-below 5 --auto-reload-amount 20 | Top up with auto-reload pre-selected on the funding page (your human can untick it). |
| billing auto-reload setup --below 5 --amount 20 | Turn auto-reload on without buying anything: opens a page where your human saves a card. Then billing wait. |
| billing auto-reload off | Turn auto-reload off. No approval needed. |
| billing transactions | The credit ledger: purchases, auto-reloads, usage, batches, fine-tuning, refunds. |
| batches create requests.jsonl | Upload a JSONL file and start a batch at 50% off. Needs prepaid credits. |
| fine-tune create examples.jsonl --model <base-id> | Upload a dataset and start a LoRA job. Needs prepaid credits. |
| webhooks add https://hooks.example.com/st --events balance.low,budget.exhausted | Get a signed POST when the balance is low, a key is about to expire or a budget is spent (default: every event). Prints signing_secret once. |
| webhooks list | Your webhook endpoints. |
| webhooks remove <id> | Delete a webhook endpoint. |
| doctor | Checks the key in .env, its region, the account and its credit, and lists notices to tell your human. |
| mcp | Prints the `claude mcp add` command and JSON config for your region. |
| dashboard --page billing | Opens your human's dashboard (overview, billing, keys, members, connect) in their browser. If they aren't signed in, one click emails them a link. |
| members | Who can sign in to the account's dashboard: email, role (owner or member), status. |
| status | Per-model health in your region over the last hour, plus your account's notices when a key is set. |
API 参考
- POST /v1/accounts
- Create an account in this host's region. Returns api_key (once) and base_url. No auth. Optional source: the campaign code from a /go/<code> link.
- POST /v1/chat/completions
- Chat, tools, JSON output, streaming. OpenAI-compatible.
- POST /v1/responses
- The OpenAI Responses API (Codex): function and custom tools, streaming. Stateless: send the whole conversation each turn; previous_response_id isn't supported.
- POST /v1/completions
- Raw text completion.
- POST /v1/embeddings
- Embeddings for embedding models.
- GET /v1/models
- Model ids live in this region (OpenAI list format). No auth.
- GET /v1/models/{id}
- One model: pricing, context, benchmarks and live_in_region. No auth.
- GET /v1/models/{id}/benchmarks
- Our own per-task scores and speed.
- GET /v1/account
- Plan, region, balance, spend, key count and notices (low_balance) with notice_text to relay to your human.
- PATCH /v1/account
- Account settings: {"ad_measurement": false} opts out of ad measurement (any key); true needs the keys or billing scope.
- GET /v1/keys
- List keys.
- POST /v1/keys
- Create a key: scopes (a subset of yours), daily_budget_usd, rate limits, expires_in or expires_at (max 365d), child: true for a sub-agent key, lives_in (where it will be stored, display only).
- POST /v1/keys/{id}/rotate
- Replace a key. The new key is returned once; the old one works for grace (default 24h, 0 to 7d).
- PATCH /v1/keys/{id}
- Change a key's name, daily budget, rate limits or lives_in (null clears it).
- DELETE /v1/keys/{id}
- Revoke a key and its sub-agent keys.
- DELETE /v1/keys/self
- The calling key revokes itself and its sub-agent keys. No scope needed.
- GET /v1/usage
- Requests, tokens and cost (days, group_by).
- GET /v1/billing
- Credit balance, auto-reload, pending top-ups and recent transactions.
- POST /v1/billing/topup
- Buy credits: {amount_usd, auto_reload?} returns an approval_url for your human.
- GET /v1/billing/topups/{id}
- One top-up's status (open, paid, expired, failed).
- PATCH /v1/billing/auto-reload
- Disable or lower auto-reload. Raising it needs a new top-up approval.
- GET /v1/billing/transactions
- The credit ledger, newest first (cursor).
- POST /v1/webhooks
- Add a webhook: {url (public https, port 443), events}. Returns signing_secret once. Billing scope; at most 5.
- GET /v1/webhooks
- Your webhook endpoints (status, last success and failure).
- DELETE /v1/webhooks/{id}
- Delete a webhook endpoint.
- POST /v1/files
- Upload JSONL (purpose=batch or fine-tune).
- POST /v1/batches
- Start a batch. GET /v1/batches/{id} to poll, POST /v1/batches/{id}/cancel to stop.
- POST /v1/fine_tuning/jobs
- Start a LoRA job from an uploaded purpose=fine-tune file.
- GET /v1/status
- Per-model health in this region, last hour.
- POST /v1/dashboard/link
- A URL for your human's dashboard (optional page), the owners, and a message to relay. billing or keys scope.
- POST /v1/device/codes
- Ask to connect to an existing account. No key. Returns device_code (secret), user_code for your human to type at verification_url, expires_in, interval.
- POST /v1/device/token
- Collect the key once approved: {device_code}, or {connect_code} (stl_…) for a dashboard connect line. 428 authorization_pending until then; one key per code, with the approver's scopes.
- GET /v1/members
- Who can sign in to the dashboard (email, role, status). read scope.
| 端点 | 说明 |
|---|---|
| POST /v1/accounts | Create an account in this host's region. Returns api_key (once) and base_url. No auth. Optional source: the campaign code from a /go/<code> link. |
| POST /v1/chat/completions | Chat, tools, JSON output, streaming. OpenAI-compatible. |
| POST /v1/responses | The OpenAI Responses API (Codex): function and custom tools, streaming. Stateless: send the whole conversation each turn; previous_response_id isn't supported. |
| POST /v1/completions | Raw text completion. |
| POST /v1/embeddings | Embeddings for embedding models. |
| GET /v1/models | Model ids live in this region (OpenAI list format). No auth. |
| GET /v1/models/{id} | One model: pricing, context, benchmarks and live_in_region. No auth. |
| GET /v1/models/{id}/benchmarks | Our own per-task scores and speed. |
| GET /v1/account | Plan, region, balance, spend, key count and notices (low_balance) with notice_text to relay to your human. |
| PATCH /v1/account | Account settings: {"ad_measurement": false} opts out of ad measurement (any key); true needs the keys or billing scope. |
| GET /v1/keys | List keys. |
| POST /v1/keys | Create a key: scopes (a subset of yours), daily_budget_usd, rate limits, expires_in or expires_at (max 365d), child: true for a sub-agent key, lives_in (where it will be stored, display only). |
| POST /v1/keys/{id}/rotate | Replace a key. The new key is returned once; the old one works for grace (default 24h, 0 to 7d). |
| PATCH /v1/keys/{id} | Change a key's name, daily budget, rate limits or lives_in (null clears it). |
| DELETE /v1/keys/{id} | Revoke a key and its sub-agent keys. |
| DELETE /v1/keys/self | The calling key revokes itself and its sub-agent keys. No scope needed. |
| GET /v1/usage | Requests, tokens and cost (days, group_by). |
| GET /v1/billing | Credit balance, auto-reload, pending top-ups and recent transactions. |
| POST /v1/billing/topup | Buy credits: {amount_usd, auto_reload?} returns an approval_url for your human. |
| GET /v1/billing/topups/{id} | One top-up's status (open, paid, expired, failed). |
| PATCH /v1/billing/auto-reload | Disable or lower auto-reload. Raising it needs a new top-up approval. |
| GET /v1/billing/transactions | The credit ledger, newest first (cursor). |
| POST /v1/webhooks | Add a webhook: {url (public https, port 443), events}. Returns signing_secret once. Billing scope; at most 5. |
| GET /v1/webhooks | Your webhook endpoints (status, last success and failure). |
| DELETE /v1/webhooks/{id} | Delete a webhook endpoint. |
| POST /v1/files | Upload JSONL (purpose=batch or fine-tune). |
| POST /v1/batches | Start a batch. GET /v1/batches/{id} to poll, POST /v1/batches/{id}/cancel to stop. |
| POST /v1/fine_tuning/jobs | Start a LoRA job from an uploaded purpose=fine-tune file. |
| GET /v1/status | Per-model health in this region, last hour. |
| POST /v1/dashboard/link | A URL for your human's dashboard (optional page), the owners, and a message to relay. billing or keys scope. |
| POST /v1/device/codes | Ask to connect to an existing account. No key. Returns device_code (secret), user_code for your human to type at verification_url, expires_in, interval. |
| POST /v1/device/token | Collect the key once approved: {device_code}, or {connect_code} (stl_…) for a dashboard connect line. 428 authorization_pending until then; one key per code, with the approver's scopes. |
| GET /v1/members | Who can sign in to the dashboard (email, role, status). read scope. |
速率限制
限制按密钥计算。超过限制时,调用会返回 429 rate_limit_exceeded,并带有以秒为单位的 Retry-After 头。在账户首次购买额度之前,密钥只能调低限制,不能调高。
- 新账户
- 请求 / 分钟: 60
- Token / 分钟: 200,000
- 支出: 首次购买额度之前:最多 5 个密钥
- 预付额度
- 请求 / 分钟: 3,000
- Token / 分钟: 5,000,000
- 支出: 由人类用户购买的额度,每次充值 $20 至 $2,000,每 24 小时上限 $2,000
- 规模化
- 请求 / 分钟: 定制
- Token / 分钟: 定制
- 支出: 联系我们
| 方案 | 请求 / 分钟 | Token / 分钟 | 支出 |
|---|---|---|---|
| 新账户 | 60 | 200,000 | 首次购买额度之前:最多 5 个密钥 |
| 预付额度 | 3,000 | 5,000,000 | 由人类用户购买的额度,每次充值 $20 至 $2,000,每 24 小时上限 $2,000 |
| 规模化 | 定制 | 定制 | 联系我们 |
错误
API 错误的格式为 {"error":{"message","type","code"}}。CLI 错误会额外包含 hint,并以非零状态码退出。
- 400
- 代码: invalid_request
- 处理方式: Fix the field named in message. Don't retry unchanged.
- 400
- 代码: invalid_body
- 处理方式: Fix the field named in message. Don't retry unchanged.
- 400
- 代码: invalid_json
- 处理方式: Send valid JSON with `content-type: application/json`.
- 401
- 代码: invalid_api_key
- 处理方式: Key missing, mistyped or revoked. Load ST_API_KEY from .env; don't create a new account.
- 401
- 代码: missing_api_key
- 处理方式: Send `Authorization: Bearer $ST_API_KEY`.
- 401
- 代码: key_expired
- 处理方式: The key's expires_at has passed. Use another key, or create a new one with a key that has the keys scope.
- 400
- 代码: invalid_expiry
- 处理方式: expires_in or expires_at must be in the future and at most 365 days ahead. Send one, not both.
- 400
- 代码: expiry_exceeds_parent
- 处理方式: A key can't outlive the key that creates it. Ask for at most max_expires_at from the body.
- 403
- 代码: scope_not_allowed
- 处理方式: Ask only for scopes your own key has (allowed_scopes in the body).
- 400
- 代码: budget_exceeds_parent
- 处理方式: A sub-agent key's daily budget must fit in what its parent has left today (max_daily_budget_usd in the body).
- 400
- 代码: limit_exceeds_parent
- 处理方式: A sub-agent key's rate limits and budget can't exceed its parent's (or, when it changes itself, its own).
- 400
- 代码: key_depth_exceeded
- 处理方式: Sub-agent keys nest at most 16 levels. Create the key from a key higher up.
- 404
- 代码: key_not_found
- 处理方式: No such key on this account, or (for a sub-agent key) it's outside the keys you created.
- 409
- 代码: key_not_active
- 处理方式: Only an active key can be rotated. Create a new key instead.
- 402
- 代码: budget_exceeded
- 处理方式: This key's daily budget is spent. Resets 00:00 UTC. Tell your human; don't retry now.
- 402
- 代码: insufficient_credits
- 处理方式: The credit balance can't cover the request (the body has balance_usd and required_usd). Run `billing topup --amount-usd 20` and send your human the approval_url.
- 402
- 代码: daily_cap_exceeded
- 处理方式: An operator-set daily cap on this account is reached. Resets 00:00 UTC. Tell your human.
- 402
- 代码: credits_required_for_batches
- 处理方式: Batches are paid from prepaid credits. Run `billing topup --amount-usd 20`, then retry once your human approves.
- 402
- 代码: credits_required_for_fine_tuning
- 处理方式: Fine-tuning is paid from prepaid credits. Run `billing topup --amount-usd 20`, then retry once your human approves.
- 409
- 代码: too_many_pending_topups
- 处理方式: The account already has 2 unpaid approval links. Ask your human to pay one (`billing status` lists them), or wait for them to expire.
- 409
- 代码: daily_topup_limit
- 处理方式: Top-ups are limited to $2,000 per account per rolling 24 hours, open links and auto-reloads included. Retry with at most available_usd from the body, or wait.
- 403
- 代码: approval_required
- 处理方式: Turning auto-reload on or raising it needs your human. Run `billing auto-reload setup --below <usd> --amount <usd>` (a link your human approves; nothing is bought) and give them the approval_url. Disabling or lowering needs no approval.
- 402
- 代码: free_tier_key_limit
- 处理方式: Accounts that haven't bought credits have 5 active keys. Revoke one (`keys revoke <id>`) or buy credits.
- 402
- 代码: free_tier_limit
- 处理方式: Accounts that haven't bought credits can't raise budgets or rate limits. Buy credits first (`billing topup --amount-usd 20`).
- 409
- 代码: fine_tuning_requires_self_hosted
- 处理方式: This base model isn't served on our own GPUs in your region, so it can't be fine-tuned here. Pick another base model.
- 409
- 代码: model_not_live
- 处理方式: That model isn't served in your region yet. Pick one from `models --live`.
- 400
- 代码: invalid_video_url
- 处理方式: video_url must be a public https URL or a data:video/mp4 (webm, mov) URL within the size limit.
- 403
- 代码: insufficient_scope
- 处理方式: This key lacks the scope. Use the default key from init.
- 403
- 代码: account_suspended
- 处理方式: Stop. Tell your human to email hello@scaledthought.com.
- 404
- 代码: model_not_found
- 处理方式: Not live here. Pick an id from `models --live` or `GET $ST_BASE_URL/models`.
- 404
- 代码: not_found
- 处理方式: Wrong path. ST_BASE_URL already ends in /v1; append /chat/completions.
- 421
- 代码: wrong_region
- 处理方式: The key belongs to the other region. Use the `base_url` in the error body; remove any hard-coded host.
- 429
- 代码: rate_limit_exceeded
- 处理方式: Wait `Retry-After` seconds, then retry.
- 429
- 代码: capacity_exhausted
- 处理方式: Canada: every replica of the model is busy and Canadian requests never overflow to another country. Wait `Retry-After` seconds and retry with backoff, or use another model.
- 400
- 代码: invalid_webhook_url
- 处理方式: Webhook URLs must be public https endpoints on port 443 (no other port, no private, loopback or internal hosts). Fix the URL.
- 409
- 代码: too_many_webhooks
- 处理方式: An account has at most 5 webhook endpoints. Remove one (`webhooks remove <id>`) first.
- 404
- 代码: webhook_not_found
- 处理方式: No such webhook on this account. List them with `webhooks list`.
- 503
- 代码: webhooks_unavailable
- 处理方式: Webhooks aren't enabled in this region yet. Poll `GET /v1/account` for `notices` instead.
- 502
- 代码: upstream_error
- 处理方式: Transient. Retry with backoff, or use another model from `models --live`.
- 503
- 代码: region_not_open
- 处理方式: The Canada region isn't open yet. Check with your human that US hosting is acceptable, then use `init --region us` and the US host.
- 503
- 代码: service_unavailable
- 处理方式: Transient. Retry in a few seconds.
- exit 1
- 代码: no_key
- 处理方式: No ST_API_KEY in the environment or ./.env. For an existing account run `login`; for a new one, `init --region us`.
- exit 1
- 代码: key_exists
- 处理方式: login: this folder already has a key. Use it, or pass --force to replace it.
- 428
- 代码: authorization_pending
- 处理方式: login --wait: your human hasn't typed the code yet. Run it again (codes last 10 minutes).
- 410
- 代码: expired_token
- 处理方式: The connect code expired. Run `login` again for a new one.
- 409
- 代码: already_claimed
- 处理方式: A connect code works once. Run `login` again (or ask for a new connect line).
- 403
- 代码: access_denied
- 处理方式: Your human denied the connection. Ask them before trying again.
- exit 1
- 代码: region_mismatch
- 处理方式: A key from the other region already exists here. Use it, or ask your human before creating a second account elsewhere.
- exit 1
- 代码: wrong_region_endpoint
- 处理方式: ST_BASE_URL / ST_API_URL points at the other region. Unset it. Nothing was sent.
- exit 1
- 代码: network_error
- 处理方式: Couldn't reach the API. Check the network, then retry.
- exit 1
- 代码: bad_region
- 处理方式: Use `--region us`. Canada (`ca`) is coming soon.
- exit 2
- 代码: usage_error
- 处理方式: Unknown command, flag or missing argument. Run the command with --help.
| 状态 | 代码 | 处理方式 |
|---|---|---|
| 400 | invalid_request | Fix the field named in message. Don't retry unchanged. |
| 400 | invalid_body | Fix the field named in message. Don't retry unchanged. |
| 400 | invalid_json | Send valid JSON with `content-type: application/json`. |
| 401 | invalid_api_key | Key missing, mistyped or revoked. Load ST_API_KEY from .env; don't create a new account. |
| 401 | missing_api_key | Send `Authorization: Bearer $ST_API_KEY`. |
| 401 | key_expired | The key's expires_at has passed. Use another key, or create a new one with a key that has the keys scope. |
| 400 | invalid_expiry | expires_in or expires_at must be in the future and at most 365 days ahead. Send one, not both. |
| 400 | expiry_exceeds_parent | A key can't outlive the key that creates it. Ask for at most max_expires_at from the body. |
| 403 | scope_not_allowed | Ask only for scopes your own key has (allowed_scopes in the body). |
| 400 | budget_exceeds_parent | A sub-agent key's daily budget must fit in what its parent has left today (max_daily_budget_usd in the body). |
| 400 | limit_exceeds_parent | A sub-agent key's rate limits and budget can't exceed its parent's (or, when it changes itself, its own). |
| 400 | key_depth_exceeded | Sub-agent keys nest at most 16 levels. Create the key from a key higher up. |
| 404 | key_not_found | No such key on this account, or (for a sub-agent key) it's outside the keys you created. |
| 409 | key_not_active | Only an active key can be rotated. Create a new key instead. |
| 402 | budget_exceeded | This key's daily budget is spent. Resets 00:00 UTC. Tell your human; don't retry now. |
| 402 | insufficient_credits | The credit balance can't cover the request (the body has balance_usd and required_usd). Run `billing topup --amount-usd 20` and send your human the approval_url. |
| 402 | daily_cap_exceeded | An operator-set daily cap on this account is reached. Resets 00:00 UTC. Tell your human. |
| 402 | credits_required_for_batches | Batches are paid from prepaid credits. Run `billing topup --amount-usd 20`, then retry once your human approves. |
| 402 | credits_required_for_fine_tuning | Fine-tuning is paid from prepaid credits. Run `billing topup --amount-usd 20`, then retry once your human approves. |
| 409 | too_many_pending_topups | The account already has 2 unpaid approval links. Ask your human to pay one (`billing status` lists them), or wait for them to expire. |
| 409 | daily_topup_limit | Top-ups are limited to $2,000 per account per rolling 24 hours, open links and auto-reloads included. Retry with at most available_usd from the body, or wait. |
| 403 | approval_required | Turning auto-reload on or raising it needs your human. Run `billing auto-reload setup --below <usd> --amount <usd>` (a link your human approves; nothing is bought) and give them the approval_url. Disabling or lowering needs no approval. |
| 402 | free_tier_key_limit | Accounts that haven't bought credits have 5 active keys. Revoke one (`keys revoke <id>`) or buy credits. |
| 402 | free_tier_limit | Accounts that haven't bought credits can't raise budgets or rate limits. Buy credits first (`billing topup --amount-usd 20`). |
| 409 | fine_tuning_requires_self_hosted | This base model isn't served on our own GPUs in your region, so it can't be fine-tuned here. Pick another base model. |
| 409 | model_not_live | That model isn't served in your region yet. Pick one from `models --live`. |
| 400 | invalid_video_url | video_url must be a public https URL or a data:video/mp4 (webm, mov) URL within the size limit. |
| 403 | insufficient_scope | This key lacks the scope. Use the default key from init. |
| 403 | account_suspended | Stop. Tell your human to email hello@scaledthought.com. |
| 404 | model_not_found | Not live here. Pick an id from `models --live` or `GET $ST_BASE_URL/models`. |
| 404 | not_found | Wrong path. ST_BASE_URL already ends in /v1; append /chat/completions. |
| 421 | wrong_region | The key belongs to the other region. Use the `base_url` in the error body; remove any hard-coded host. |
| 429 | rate_limit_exceeded | Wait `Retry-After` seconds, then retry. |
| 429 | capacity_exhausted | Canada: every replica of the model is busy and Canadian requests never overflow to another country. Wait `Retry-After` seconds and retry with backoff, or use another model. |
| 400 | invalid_webhook_url | Webhook URLs must be public https endpoints on port 443 (no other port, no private, loopback or internal hosts). Fix the URL. |
| 409 | too_many_webhooks | An account has at most 5 webhook endpoints. Remove one (`webhooks remove <id>`) first. |
| 404 | webhook_not_found | No such webhook on this account. List them with `webhooks list`. |
| 503 | webhooks_unavailable | Webhooks aren't enabled in this region yet. Poll `GET /v1/account` for `notices` instead. |
| 502 | upstream_error | Transient. Retry with backoff, or use another model from `models --live`. |
| 503 | region_not_open | The Canada region isn't open yet. Check with your human that US hosting is acceptable, then use `init --region us` and the US host. |
| 503 | service_unavailable | Transient. Retry in a few seconds. |
| exit 1 | no_key | No ST_API_KEY in the environment or ./.env. For an existing account run `login`; for a new one, `init --region us`. |
| exit 1 | key_exists | login: this folder already has a key. Use it, or pass --force to replace it. |
| 428 | authorization_pending | login --wait: your human hasn't typed the code yet. Run it again (codes last 10 minutes). |
| 410 | expired_token | The connect code expired. Run `login` again for a new one. |
| 409 | already_claimed | A connect code works once. Run `login` again (or ask for a new connect line). |
| 403 | access_denied | Your human denied the connection. Ask them before trying again. |
| exit 1 | region_mismatch | A key from the other region already exists here. Use it, or ask your human before creating a second account elsewhere. |
| exit 1 | wrong_region_endpoint | ST_BASE_URL / ST_API_URL points at the other region. Unset it. Nothing was sent. |
| exit 1 | network_error | Couldn't reach the API. Check the network, then retry. |
| exit 1 | bad_region | Use `--region us`. Canada (`ca`) is coming soon. |
| exit 2 | usage_error | Unknown command, flag or missing argument. Run the command with --help. |