ドキュメント
プロンプトひとつではじめる。
ScaledThoughtはエージェントファーストです。サインアップと作業はエージェントが行い、請求、キー、チームメンバーを管理するダッシュボードは、必要なときにあなたが使えます。ここに書かれていることはすべて、あなたとエージェントの両方に向けたものです。APIはOpenAI-compatible(OpenAI互換)です。OpenAI SDKのコードの多くは、ベース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トークンとして送信します。キーは一つのリージョンに限定され、独自の予算を設定できます。ベースURLはリージョンのホストで、.env に ST_BASE_URL として保存されます: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のリクエスト形式を受け付けます。モデルIDは npx -y scaledthought@0.3 models --live または /pricing で確認してください。
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="")ツール呼び出し
tools をOpenAIの形式で渡します。ツール呼び出しに対応したモデルは、標準の 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)構造化出力
response_format にJSONスキーマを指定します。対応しているモデルでは、デコード時に出力がスキーマに制約されます。結果を使う前に検証してください。
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 を返し、Web検索ツールは無視されます。max_output_tokens のないリクエストには、プロンプトの後に残るモデルのコンテキスト分(最大32,768トークン)の上限が適用されます。
課金はチャット補完と同じです。モデルサーバーが報告する使用量に基づくトークン単位で、クレジットから支払われます。
# ~/.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 をシェルに読み込んでください。wire_api = "responses" は必須です。ScaledThoughtはCodexにResponses API経由で提供しています。
model_catalog_url はCodexに、あなたのリージョンで公開中のモデルのコンテキストウィンドウを伝えるため、長いセッションを適切なタイミングで圧縮でき、編集用の apply_patch ツールも使えるようになります。リクエストのたびに公開中のモデルから生成されます。Codexはこれにキーを付けて送るため、base_url と同じホスト(あなたのリージョンのホスト)に置いてください。
モデルとベンチマーク
GET /v1/models は、あなたのリージョンで公開中のモデルIDをOpenAIの形式で一覧表示します。呼び出せるモデルはこの一覧が正です。GET /v1/models/{id} は一つのモデルの料金、コンテキスト長、リリース日、ベンチマークスコア、公開状況を返すため、エージェントは人間がWebページを読まなくてもモデルを選べます。検索や絞り込みには 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)とプライバシーポリシー (英語)を参照してください。
キーと予算
エージェントは、1日あたりの支出上限を厳密に設けた、スコープ付きのキーを作成できます。予算に達すると、それ以上支出せずに呼び出しは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 を指定すると、新しいキーは呼び出し元のキーを親として記録します。1日の予算は親のその日の残りの範囲内に収まり、レート制限と有効期限は親を超えず、管理できるのは自分のサブキーだけです。キーを失効させると、その下にあるすべてのキーも失効します。
ローテーション: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}。失敗した配信は、バックオフを挟みながら約2日間再試行されます。
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で、ベースモデルと同じレプリカで提供され、ベースモデルのトークン単価で課金されます。学習できるのは、あなたのリージョンにある当社のGPUで動いているベースモデルだけで、アダプターはダウンロードできません。学習は学習トークン1Mあたり(データセットのトークン数 × エポック数)で課金され、ジョブのレスポンスには、実行前に見積もりが含まれます。プリペイドクレジットから支払われます。料金を参照してください。
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トークンとして認証します。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になります。エラーは code、message、hint を持つ一行のJSONとしてstderrに出力されます。対話的な入力は一切求めません。キーは 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. |
レート制限
制限はキーごとです。制限を超えると、呼び出しは秒単位の Retry-After ヘッダー付きで 429 rate_limit_exceeded を返します。アカウントで最初にクレジットを購入するまでは、キーの制限を下げることはできますが、上げることはできません。
- 新規アカウント
- リクエスト / 分: 60
- トークン / 分: 200,000
- 支出: 最初のクレジット購入まで:キーは5個まで
- プリペイドクレジット
- リクエスト / 分: 3,000
- トークン / 分: 5,000,000
- 支出: あなたが購入するクレジット。一回のチャージは$20〜$2,000、24時間あたり$2,000まで
- スケール
- リクエスト / 分: 個別対応
- トークン / 分: 個別対応
- 支出: お問い合わせ
| プラン | リクエスト / 分 | トークン / 分 | 支出 |
|---|---|---|---|
| 新規アカウント | 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. |