Output SDKワークフロー実行の実行コストを計算して表示します。 次のような場合に使用: - LLM トークンのコストを確認したい - API サービスのコストを確認したい - 特定のワークフロー実行の総支出を確認したい
Calculate and display the cost of an Output SDK workflow execution run. Use when checking LLM token costs, API service costs, or total spend for a specific workflow run.
このスキルは、Output CLIを使用して完了したワークフロー実行のコストを計算するのに役立ちます。LLMモデル(トークン使用量)と外部APIサービス呼び出しごとにコストを詳細に表示します。
workflow costコマンドには、ワークフロー名ではなくワークフロー実行IDが必要です。
実行IDの例: process_transcripts_2026-03-23T19:35:17.000Z_c2biRk_F9rYktF-wagBf5
方法A — 最近の実行を一覧表示 (スキル使用: output-workflow-runs-list):
npx output workflow runs list <workflowName> --limit 5
最も最近に完了した実行から実行IDをコピーします。
方法B — ワークフローを実行して実行IDを取得:
入力値がわかっている場合は、同期実行すると実行IDが出力に表示されます:
npx output workflow run <workflowName> --input '{"key": "value"}'
非同期実行の場合 (スキル使用: output-workflow-start):
npx output workflow start <workflowName> --input '{"key": "value"}'
# 出力: Workflow ID: <runId>
入力値がわからない場合は、シナリオファイル (スキル使用: output-dev-scenario-file) またはワークフローのtypes.ts内のinputSchemaを確認してください。
注記: ワークフロー名(例:
process_transcripts)はワークフローの種類を識別します。ワークフロー実行ID(例:process_transcripts_2026-03-23T19:35:17.000Z_abc123)は特定の実行を識別します。workflow costは実行IDが必要です。
npx output workflow cost <runId>
npx output workflow cost <runId> path/to/trace.json
npx output workflow cost <runId> --json
npx output workflow cost <runId> --verbose
| フラグ | 説明 | デフォルト |
|---|---|---|
--json |
テキストレポートの代わりに機械可読なJSON形式で出力 | false |
--verbose |
LLM呼び出しごとの詳細な内訳を表示 | false |
価格値は説明用です — 下記のモデルと1トークンあたりのレートは2026年5月4日時点のものです。現在の価格はmodels.devから取得されます。現在のモデルIDについては、
output-dev-model-selectionを参照してください。
各行のコストは2つの数値で表示されます。Originalはトレース属性(llm:generation:cost / http:request:cost、llm:generation:usageとllm:usageが存在する場合)に記録された請求額コストです。Adjustedはcosts.ymlオーバーライドを適用後のコストです(オーバーライドがない場合はOriginalと同じ)。合計行とJSON形式のtotalCostは調整後の合計を表します。
Workflow: process_transcripts
Duration: 12.3s
LLM Costs:
Model | Calls | Original | Adjusted
claude-sonnet-4-6 | 3 | $0.0123 | $0.0123
Subtotal | 3 | $0.0123 | $0.0123
API Costs:
Host | Calls | Original | Adjusted
r.jina.ai | 2 | $0.0040 | $0.0040
Subtotal | 2 | $0.0040 | $0.0040
TOTAL ESTIMATED COST (adjusted) $0.0163
As-charged (from trace) $0.0163
APIコストには、クライアントがaddRequestCostで金額を付与した呼び出しのみが含まれます(output-dev-http-client-createの「リクエストコストの付与(有料API)」を参照)。addRequestCostを呼び出さないHTTP呼び出しはトレースされますが、ここには貢献しません — これは無料サービスや社内サービスでは正常ですが、有料サービスの場合は改善の余地があります。
{
"workflowName": "process_transcripts",
"durationMs": 12300,
"llmOriginalCost": 0.0123,
"llmAdjustedCost": 0.0123,
"totalInputTokens": 1234,
"totalOutputTokens": 567,
"httpCosts": [{ "host": "r.jina.ai", "originalTotalCost": 0.004, "adjustedTotalCost": 0.004 }],
"httpOriginalCost": 0.004,
"httpAdjustedCost": 0.004,
"originalTotalCost": 0.0163,
"totalCost": 0.0163
}
llmCallsとhttpCosts[].calls内の呼び出し単位エントリはoriginalCostとadjustedCostを含みます。(より古いリリースではllmTotalCost、services[]、serviceTotalCost、unknownModelsが公開されていましたが、上記のフィールドで置き換わりました。)
最後の実行のコストを取得:
# まず実行IDを取得
npx output workflow runs list process_transcripts --limit 1 --json
# 次にコストを取得
npx output workflow cost process_transcripts_2026-03-23T19:35:17.000Z_abc123
コストをJSON形式で取得して合計を抽出:
npx output workflow cost <runId> --json | jq '.totalCost'
呼び出しごとの詳細な内訳を表示:
npx output workflow cost <runId> --verbose
output-workflow-runs-list — 実行履歴から実行IDを検索output-workflow-start — ワークフローを開始して実行IDを取得output-workflow-run — ワークフローを同期実行output-dev-scenario-file — ワークフロー入力用のシナリオファイルを作成・検索This skill helps you calculate the cost of a completed workflow execution using the Output CLI. It breaks down costs by LLM model (token usage) and external API service calls.
The workflow cost command requires a workflow run ID — not the workflow name.
A run ID looks like: process_transcripts_2026-03-23T19:35:17.000Z_c2biRk_F9rYktF-wagBf5
Option A — List recent runs (use skill: output-workflow-runs-list):
npx output workflow runs list <workflowName> --limit 5
Copy the run ID from the most recent completed run.
Option B — Run the workflow now and capture the ID:
If you know the input, run it synchronously and the run ID will be in the output:
npx output workflow run <workflowName> --input '{"key": "value"}'
Or asynchronously (use skill: output-workflow-start):
npx output workflow start <workflowName> --input '{"key": "value"}'
# Returns: Workflow ID: <runId>
If you don't know the input, check for a scenario file (use skill: output-dev-scenario-file) or the workflow's inputSchema in its types.ts.
Note: The workflow name (e.g.
process_transcripts) identifies the workflow type. The workflow run ID (e.g.process_transcripts_2026-03-23T19:35:17.000Z_abc123) identifies a specific execution.workflow costrequires the run ID.
npx output workflow cost <runId>
npx output workflow cost <runId> path/to/trace.json
npx output workflow cost <runId> --json
npx output workflow cost <runId> --verbose
| Flag | Description | Default |
|---|---|---|
--json |
Output machine-readable JSON instead of the text report | false |
--verbose |
Show detailed per-LLM-call breakdown | false |
Pricing values are illustrative — the model and per-token rates shown below were current as of 2026-05-04. Live pricing comes from models.dev. For current model IDs, see
output-dev-model-selection.
Costs come in two figures per row: Original is the as-charged cost recorded
in the trace attributes (llm:generation:cost / http:request:cost, with
llm:generation:usage and legacy llm:usage fallbacks), and Adjusted is
the cost after applying any costs.yml override (equal to Original when no
override applies). The bottom line and JSON totalCost are the Adjusted total.
Workflow: process_transcripts
Duration: 12.3s
LLM Costs:
Model | Calls | Original | Adjusted
claude-sonnet-4-6 | 3 | $0.0123 | $0.0123
Subtotal | 3 | $0.0123 | $0.0123
API Costs:
Host | Calls | Original | Adjusted
r.jina.ai | 2 | $0.0040 | $0.0040
Subtotal | 2 | $0.0040 | $0.0040
TOTAL ESTIMATED COST (adjusted) $0.0163
As-charged (from trace) $0.0163
API Costs only include calls where the client attached a dollar amount with addRequestCost (see output-dev-http-client-create, "Attaching Request Cost (Paid APIs)"). An HTTP call that never calls addRequestCost is still traced but contributes nothing here — that's expected for free or internal services, and a gap to fix for paid ones.
{
"workflowName": "process_transcripts",
"durationMs": 12300,
"llmOriginalCost": 0.0123,
"llmAdjustedCost": 0.0123,
"totalInputTokens": 1234,
"totalOutputTokens": 567,
"httpCosts": [{ "host": "r.jina.ai", "originalTotalCost": 0.004, "adjustedTotalCost": 0.004 }],
"httpOriginalCost": 0.004,
"httpAdjustedCost": 0.004,
"originalTotalCost": 0.0163,
"totalCost": 0.0163
}
Per-call entries in llmCalls and httpCosts[].calls carry originalCost and
adjustedCost. (Older releases exposed llmTotalCost, services[],
serviceTotalCost, and unknownModels — replaced by the fields above.)
Get cost of the last run:
# First get the run ID
npx output workflow runs list process_transcripts --limit 1 --json
# Then get the cost
npx output workflow cost process_transcripts_2026-03-23T19:35:17.000Z_abc123
Get cost as JSON and extract total:
npx output workflow cost <runId> --json | jq '.totalCost'
Show full per-call breakdown:
npx output workflow cost <runId> --verbose
output-workflow-runs-list — Find run IDs from execution historyoutput-workflow-start — Start a workflow and capture its run IDoutput-workflow-run — Run a workflow synchronouslyoutput-dev-scenario-file — Create or find scenario files for workflow input原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。