Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge remote-tracking branch 'origin/litellm_cost_shard_harness_extensions' into litellm_cost_shard_embeddings_rerank

kerryf038a0558c85
diff --cc tests/integration/contracts.json
index f6353bfe0da,23ec7452583..f0b9f7f158d
--- a/tests/integration/contracts.json
+++ b/tests/integration/contracts.json
@@@ -1321,71 -1321,68 +1321,134 @@@
"tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[us.anthropic.claude-opus-5-v1:0-stream_full_usage]": [
"quota_management.spend_tracking.scripted_wire.logs_cost"
],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[azure-text-embeddings-4-large-deployment]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[bedrock-cohere-embeddings-v4]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[bedrock-cohere-rerank-v4]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[bedrock-embeddings-titan-v2]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[cohere-embeddings-v5]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[cohere-rerank-v4-one]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[cohere-rerank-v4-three]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[cohere-rerank-v4-total-tokens-fallback]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[fireworks-embeddings-v1]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gemini-embeddings-002]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[omni-moderations-next-list]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[omni-moderations-next-single]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-completions-openai-basic]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-completions-openai-n-best]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-completions-openai-stream-usage]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-embeddings-3-large-dimensions]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-embeddings-4-small-batch]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-embeddings-4-small-single]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[text-embeddings-4-small-token-array]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[together-completions-v1]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[together-embeddings-v1]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[vertex-embeddings-text-006]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
++ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_cache_read]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_reasoning]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_stream]": [
+ "quota_management.spend_tracking.scripted_wire.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_stream_cache_read]": [
+ "quota_management.spend_tracking.scripted_wire.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_incomplete]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_previous_response_id]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_web_search_medium]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.3-codex-responses_file_search]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_service_tier_flex]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[gpt-5.6-responses_service_tier_priority]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_input_text]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_cache_read]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_cache_write_5m]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_cache_write_1h]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_web_search]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_stream]": [
+ "quota_management.spend_tracking.scripted_wire.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_stream_cache_read]": [
+ "quota_management.spend_tracking.scripted_wire.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-sonnet-5-messages_tiered_input_above_200k]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[claude-haiku-4-5-messages_input_text]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[us.anthropic.claude-opus-5-v1:0-messages_input_text]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
+ ],
+ "tests/integration/cost_calculation/test_cost_tracking.py::test_case_bills_expected_cost[anthropic.claude-sonnet-5-v1:0-messages_cache_read]": [
+ "quota_management.spend_tracking.cost_matrix.logs_cost"
]
},
"browser": {
diff --cc tests/integration/cost_calculation/cost_tracking_cases.json
index a076381c4e3,ac4c6c125fb..162d52648eb
--- a/tests/integration/cost_calculation/cost_tracking_cases.json
+++ b/tests/integration/cost_calculation/cost_tracking_cases.json
@@@ -25870,850 -25778,1091 +25870,1936 @@@
"completion_tokens": 412
}
},
+ {
+ "name": "text-embeddings-4-small-single",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "text-embedding-4-small",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "one embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ }
+ ],
+ "model": "text-embedding-4-small",
+ "usage": {
+ "prompt_tokens": 7,
+ "total_tokens": 7
+ }
+ }
+ },
+ "expected": {
+ "spend": 7.07e-06,
+ "input_cost": 7.07e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 7,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "text-embeddings-4-small-batch",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "text-embedding-4-small",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": [
+ "one",
+ "two",
+ "three"
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ },
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 1
+ },
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 2
+ }
+ ],
+ "model": "text-embedding-4-small",
+ "usage": {
+ "prompt_tokens": 21,
+ "total_tokens": 21
+ }
+ }
+ },
+ "expected": {
+ "spend": 2.1210000000000002e-05,
+ "input_cost": 2.1210000000000002e-05,
+ "output_cost": 0.0,
+ "prompt_tokens": 21,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "text-embeddings-4-small-token-array",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "text-embedding-4-small",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": [
+ 1,
+ 2,
+ 3,
+ 4
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ }
+ ],
+ "model": "text-embedding-4-small",
+ "usage": {
+ "prompt_tokens": 9,
+ "total_tokens": 9
+ }
+ }
+ },
+ "expected": {
+ "spend": 9.090000000000001e-06,
+ "input_cost": 9.090000000000001e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 9,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "text-embeddings-3-large-dimensions",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "text-embedding-3-large-next",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "large embedding",
+ "dimensions": 3
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ }
+ ],
+ "model": "text-embedding-3-large-next",
+ "usage": {
+ "prompt_tokens": 8,
+ "total_tokens": 8
+ }
+ }
+ },
+ "expected": {
+ "spend": 8.16e-06,
+ "input_cost": 8.16e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 8,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "azure-text-embeddings-4-large-deployment",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "azure/text-embedding-4-large",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "azure embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ }
+ ],
+ "model": "azure/text-embedding-4-large",
+ "usage": {
+ "prompt_tokens": 8,
+ "total_tokens": 8
+ }
+ }
+ },
+ "expected": {
+ "spend": 8.24e-06,
+ "input_cost": 8.24e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 8,
+ "completion_tokens": 0
+ },
+ "deployment": {
+ "model": "azure/cc-pinned-embedding-deployment",
+ "base_model": "azure/text-embedding-4-large"
+ }
+ },
+ {
+ "name": "cohere-embeddings-v5",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "embed-v5",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "cohere embedding",
+ "input_type": "search_query"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "emb-1",
+ "embeddings": {
+ "float": [
+ [
+ 0.1,
+ 0.2,
+ 0.3
+ ]
+ ]
+ },
+ "meta": {
+ "billed_units": {
+ "input_tokens": 11
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 1.144e-05,
+ "input_cost": 1.144e-05,
+ "output_cost": 0.0,
+ "prompt_tokens": 11,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "bedrock-embeddings-titan-v2",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "amazon.titan-embed-text-v2:0",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "titan embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "inputTextTokenCount": 10
+ }
+ },
+ "expected": {
+ "spend": 1.05e-05,
+ "input_cost": 1.05e-05,
+ "output_cost": 0.0,
+ "prompt_tokens": 10,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "bedrock-cohere-embeddings-v4",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "cohere.embed-english-v4",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "bedrock cohere embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "embeddings": [
+ [
+ 0.1,
+ 0.2,
+ 0.3
+ ]
+ ],
+ "id": "emb-bedrock-cohere-1",
+ "response_type": "embeddings_floats",
+ "texts": [
+ "bedrock cohere embedding"
+ ]
+ }
+ },
+ "expected": {
+ "spend": 5.3e-06,
+ "input_cost": 5.3e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 5,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "vertex-embeddings-text-006",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "text-embedding-006",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "vertex embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "predictions": [
+ {
+ "embeddings": {
+ "values": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "statistics": {
+ "token_count": 7,
+ "truncated": false
+ }
+ }
+ }
+ ]
+ }
+ },
+ "expected": {
+ "spend": 7.4899999999999994e-06,
+ "input_cost": 7.4899999999999994e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 7,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "gemini-embeddings-002",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gemini/gemini-embedding-002",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "gemini embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "embeddings": [
+ {
+ "values": [
+ 0.1,
+ 0.2,
+ 0.3
+ ]
+ }
+ ],
+ "usageMetadata": {
+ "promptTokenCount": 7,
+ "totalTokenCount": 7
+ }
+ }
+ },
+ "expected": {
+ "spend": 3.24e-06,
+ "input_cost": 3.24e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 3,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "together-embeddings-v1",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "together_ai/together-embed-v1",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "together embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ }
+ ],
+ "model": "together-embed-v1",
+ "usage": {
+ "prompt_tokens": 7,
+ "total_tokens": 7
+ }
+ }
+ },
+ "expected": {
+ "spend": 7.63e-06,
+ "input_cost": 7.63e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 7,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "fireworks-embeddings-v1",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "fireworks_ai/fireworks-embed-v1",
+ "endpoint": "/v1/embeddings",
+ "request": {
+ "model": "$MODEL",
+ "input": "fireworks embedding"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "object": "list",
+ "data": [
+ {
+ "object": "embedding",
+ "embedding": [
+ 0.1,
+ 0.2,
+ 0.3
+ ],
+ "index": 0
+ }
+ ],
+ "model": "fireworks-embed-v1",
+ "usage": {
+ "prompt_tokens": 7,
+ "total_tokens": 7
+ }
+ }
+ },
+ "expected": {
+ "spend": 7.7e-06,
+ "input_cost": 7.7e-06,
+ "output_cost": 0.0,
+ "prompt_tokens": 7,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "cohere-rerank-v4-one",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "rerank-v4",
+ "endpoint": "/v1/rerank",
+ "request": {
+ "model": "$MODEL",
+ "query": "rank this",
+ "documents": [
+ "a",
+ "b"
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "rr-$REQUEST_ID",
+ "results": [
+ {
+ "index": 0,
+ "relevance_score": 0.9
+ }
+ ],
+ "meta": {
+ "api_version": {
+ "version": "2"
+ },
+ "billed_units": {
+ "search_units": 1
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0021,
+ "input_cost": 0.0021,
+ "output_cost": 0.0,
+ "prompt_tokens": 0,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "cohere-rerank-v4-three",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "rerank-v4",
+ "endpoint": "/v1/rerank",
+ "request": {
+ "model": "$MODEL",
+ "query": "rank this",
+ "documents": [
+ "a long document",
+ "another long document",
+ "third long document"
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "rr-three-$REQUEST_ID",
+ "results": [
+ {
+ "index": 0,
+ "relevance_score": 0.9
+ }
+ ],
+ "meta": {
+ "api_version": {
+ "version": "2"
+ },
+ "billed_units": {
+ "search_units": 3
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0063,
+ "input_cost": 0.0063,
+ "output_cost": 0.0,
+ "prompt_tokens": 0,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "cohere-rerank-v4-total-tokens-fallback",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "rerank-v4",
+ "endpoint": "/v1/rerank",
+ "request": {
+ "model": "$MODEL",
+ "query": "rank this",
+ "documents": [
+ "fallback a",
+ "fallback b"
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "rr-fallback-$REQUEST_ID",
+ "results": [
+ {
+ "index": 0,
+ "relevance_score": 0.8
+ }
+ ],
+ "meta": {
+ "billed_units": {
+ "total_tokens": 99
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0,
+ "input_cost": 0.0,
+ "output_cost": 0.0,
+ "prompt_tokens": 0,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "bedrock-cohere-rerank-v4",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "cohere.rerank-v4:0",
+ "endpoint": "/v1/rerank",
+ "request": {
+ "model": "$MODEL",
+ "query": "rank this",
+ "documents": [
+ "a",
+ "b"
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "results": [
+ {
+ "index": 0,
+ "relevanceScore": 0.9
+ }
+ ],
+ "response_id": "rr-3",
+ "token_count": 1
+ }
+ },
+ "expected": {
+ "spend": 0.0022,
+ "input_cost": 0.0022,
+ "output_cost": 0.0,
+ "prompt_tokens": 0,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "text-completions-openai-basic",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-3.5-turbo-instruct-next",
+ "endpoint": "/v1/completions",
+ "request": {
+ "model": "$MODEL",
+ "prompt": "complete this"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "cmpl-basic-$REQUEST_ID",
+ "object": "text_completion",
+ "choices": [
+ {
+ "text": "done",
+ "index": 0,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 9,
+ "completion_tokens": 4,
+ "total_tokens": 13
+ }
+ }
+ },
+ "expected": {
+ "spend": 1.882e-05,
+ "input_cost": 1.026e-05,
+ "output_cost": 8.56e-06,
+ "prompt_tokens": 9,
+ "completion_tokens": 4
+ }
+ },
+ {
+ "name": "text-completions-openai-stream-usage",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-3.5-turbo-instruct-next",
+ "endpoint": "/v1/completions",
+ "request": {
+ "model": "$MODEL",
+ "prompt": "complete this",
+ "stream": true,
+ "stream_options": {
+ "include_usage": true
+ }
+ },
+ "response": {
+ "content_type": "text/event-stream",
+ "frames": [
+ "data: {\"id\": \"cmpl-$REQUEST_ID\", \"object\": \"text_completion\", \"created\": 1789789000, \"model\": \"gpt-3.5-turbo-instruct-next\", \"choices\": [{\"text\": \"done\", \"index\": 0, \"finish_reason\": null}], \"usage\": null}",
+ "data: {\"id\": \"cmpl-$REQUEST_ID\", \"object\": \"text_completion\", \"created\": 1789789000, \"model\": \"gpt-3.5-turbo-instruct-next\", \"choices\": [], \"usage\": {\"prompt_tokens\": 9, \"completion_tokens\": 4, \"total_tokens\": 13}}",
+ "data: [DONE]"
+ ]
+ },
+ "expected": {
+ "spend": 1.882e-05,
+ "input_cost": 1.026e-05,
+ "output_cost": 8.56e-06,
+ "prompt_tokens": 9,
+ "completion_tokens": 4
+ }
+ },
+ {
+ "name": "text-completions-openai-n-best",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-3.5-turbo-instruct-next",
+ "endpoint": "/v1/completions",
+ "request": {
+ "model": "$MODEL",
+ "prompt": "complete this twice",
+ "n": 2
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "cmpl-n-best-$REQUEST_ID",
+ "object": "text_completion",
+ "choices": [
+ {
+ "text": "done",
+ "index": 0,
+ "finish_reason": "stop"
+ },
+ {
+ "text": "also done",
+ "index": 1,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 9,
+ "completion_tokens": 8,
+ "total_tokens": 17
+ }
+ }
+ },
+ "expected": {
+ "spend": 2.738e-05,
+ "input_cost": 1.026e-05,
+ "output_cost": 1.712e-05,
+ "prompt_tokens": 9,
+ "completion_tokens": 8
+ }
+ },
+ {
+ "name": "together-completions-v1",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "together_ai/meta-llama/Llama-3.3-70B-Instruct-Turbo",
+ "endpoint": "/v1/completions",
+ "request": {
+ "model": "$MODEL",
+ "prompt": "together complete"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "cmpl-together-$REQUEST_ID",
+ "object": "text_completion",
+ "choices": [
+ {
+ "text": "done",
+ "index": 0,
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 9,
+ "completion_tokens": 4,
+ "total_tokens": 13
+ }
+ }
+ },
+ "expected": {
+ "spend": 1.908e-05,
+ "input_cost": 1.0439999999999998e-05,
+ "output_cost": 8.64e-06,
+ "prompt_tokens": 9,
+ "completion_tokens": 4
+ }
+ },
+ {
+ "name": "omni-moderations-next-single",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "omni-moderation-next",
+ "endpoint": "/v1/moderations",
+ "request": {
+ "model": "$MODEL",
+ "input": "safe text"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "modr-single-$REQUEST_ID",
+ "model": "omni-moderation-next",
+ "results": [
+ {
+ "flagged": false,
+ "categories": {},
+ "category_scores": {}
+ }
+ ]
+ }
+ },
+ "expected": {
+ "spend": 0.0,
+ "input_cost": 0.0,
+ "output_cost": 0.0,
+ "prompt_tokens": 0,
+ "completion_tokens": 0
+ }
+ },
+ {
+ "name": "omni-moderations-next-list",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "omni-moderation-next",
+ "endpoint": "/v1/moderations",
+ "request": {
+ "model": "$MODEL",
+ "input": [
+ "safe text",
+ "more safe text"
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "modr-list-$REQUEST_ID",
+ "model": "omni-moderation-next",
+ "results": [
+ {
+ "flagged": false,
+ "categories": {},
+ "category_scores": {}
+ },
+ {
+ "flagged": false,
+ "categories": {},
+ "category_scores": {}
+ }
+ ]
+ }
+ },
+ "expected": {
+ "spend": 0.0,
+ "input_cost": 0.0,
+ "output_cost": 0.0,
+ "prompt_tokens": 0,
+ "completion_tokens": 0
+ }
++ },
+ {
+ "name": "gpt-5.6-responses_cache_read",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "summarize this text"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 12928,
+ "output_tokens": 380,
+ "total_tokens": 13308,
+ "input_tokens_details": {
+ "cached_tokens": 12288
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0085904,
+ "input_cost": 0.0032704,
+ "output_cost": 0.00532,
+ "prompt_tokens": 12928,
+ "completion_tokens": 380,
+ "cache_read_cost": 0.0021504
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_reasoning",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "reason about this text"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "reasoning",
+ "id": "rs_$REQUEST_ID",
+ "status": "completed",
+ "summary": []
+ },
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1240,
+ "output_tokens": 4040,
+ "total_tokens": 5280,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 3480
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.06569,
+ "input_cost": 0.00217,
+ "output_cost": 0.06352,
+ "prompt_tokens": 1240,
+ "completion_tokens": 4040,
+ "reasoning_cost": 0.05568
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_stream",
+ "covers": "quota_management.spend_tracking.scripted_wire.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "stream this text",
+ "stream": true
+ },
+ "response": {
+ "content_type": "text/event-stream",
+ "frames": [
+ "event: response.created\ndata: {\"type\":\"response.created\",\"response\":{\"id\":\"resp_$REQUEST_ID\",\"object\":\"response\",\"created_at\":1700000000,\"status\":\"in_progress\",\"model\":\"gpt-5.6\",\"output\":[{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}]}],\"usage\":null}}",
+ "event: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"output_index\":0,\"item\":{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}",
+ "event: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"content_part\",\"text\":\"\"}}",
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"delta\":\"scripted \"}",
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"delta\":\"response\"}",
+ "event: response.output_text.done\ndata: {\"type\":\"response.output_text.done\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"text\":\"scripted response\"}",
+ "event: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}}",
+ "event: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"output_index\":0,\"item\":{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}]}}",
+ "event: response.completed\ndata: {\"type\":\"response.completed\",\"response\":{\"id\":\"resp_$REQUEST_ID\",\"object\":\"response\",\"created_at\":1700000000,\"status\":\"completed\",\"model\":\"gpt-5.6\",\"output\":[{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":1840,\"output_tokens\":412,\"total_tokens\":2252,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens_details\":{\"reasoning_tokens\":0}}}}"
+ ]
+ },
+ "expected": {
+ "spend": 0.008988,
+ "input_cost": 0.00322,
+ "output_cost": 0.005768,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_stream_cache_read",
+ "covers": "quota_management.spend_tracking.scripted_wire.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "stream cached text",
+ "stream": true
+ },
+ "response": {
+ "content_type": "text/event-stream",
+ "frames": [
+ "event: response.created\ndata: {\"type\":\"response.created\",\"response\":{\"id\":\"resp_$REQUEST_ID\",\"object\":\"response\",\"created_at\":1700000000,\"status\":\"in_progress\",\"model\":\"gpt-5.6\",\"output\":[{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}]}],\"usage\":null}}",
+ "event: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"output_index\":0,\"item\":{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}",
+ "event: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"content_part\",\"text\":\"\"}}",
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"delta\":\"scripted \"}",
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"delta\":\"response\"}",
+ "event: response.output_text.done\ndata: {\"type\":\"response.output_text.done\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"text\":\"scripted response\"}",
+ "event: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"item_id\":\"msg_$REQUEST_ID\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}}",
+ "event: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"output_index\":0,\"item\":{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}]}}",
+ "event: response.completed\ndata: {\"type\":\"response.completed\",\"response\":{\"id\":\"resp_$REQUEST_ID\",\"object\":\"response\",\"created_at\":1700000000,\"status\":\"completed\",\"model\":\"gpt-5.6\",\"output\":[{\"type\":\"message\",\"id\":\"msg_$REQUEST_ID\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"scripted response\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":12928,\"output_tokens\":380,\"total_tokens\":13308,\"input_tokens_details\":{\"cached_tokens\":12288},\"output_tokens_details\":{\"reasoning_tokens\":0}}}}"
+ ]
+ },
+ "expected": {
+ "spend": 0.0085904,
+ "input_cost": 0.0032704,
+ "output_cost": 0.00532,
+ "prompt_tokens": 12928,
+ "completion_tokens": 380,
+ "cache_read_cost": 0.0021504
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_incomplete",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "truncate this text",
+ "max_output_tokens": 100
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "incomplete",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 100,
+ "total_tokens": 1940,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ },
+ "incomplete_details": {
+ "reason": "max_output_tokens"
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.00462,
+ "input_cost": 0.00322,
+ "output_cost": 0.0014,
+ "prompt_tokens": 1840,
+ "completion_tokens": 100
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_previous_response_id",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "continue this text",
+ "previous_response_id": "resp_scripted_prior"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412,
+ "total_tokens": 2252,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.008988,
+ "input_cost": 0.00322,
+ "output_cost": 0.005768,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_web_search_medium",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "search this text",
+ "tools": [
+ {
+ "type": "web_search_preview",
+ "search_context_size": "medium"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "web_search_call",
+ "id": "ws_$REQUEST_ID",
+ "status": "completed",
+ "action": {
+ "type": "search",
+ "query": "scripted query"
+ }
+ },
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412,
+ "total_tokens": 2252,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.021488,
+ "input_cost": 0.00322,
+ "output_cost": 0.005768,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412,
+ "tool_usage_cost": 0.0125
+ }
+ },
+ {
+ "name": "gpt-5.3-codex-responses_file_search",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.3-codex",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "search files",
+ "tools": [
+ {
+ "type": "file_search",
+ "vector_store_ids": [
+ "vs_scripted"
+ ]
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.3-codex",
+ "output": [
+ {
+ "type": "file_search_call",
+ "id": "fs_$REQUEST_ID",
+ "status": "completed",
+ "queries": [
+ "scripted query"
+ ],
+ "results": []
+ },
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412,
+ "total_tokens": 2252,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.010204,
+ "input_cost": 0.00276,
+ "output_cost": 0.004944,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412,
+ "tool_usage_cost": 0.0025
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_service_tier_flex",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "flex text",
+ "service_tier": "flex"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412,
+ "total_tokens": 2252,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ },
+ "service_tier": "flex"
+ },
+ "service_tier": "flex"
+ }
+ },
+ "expected": {
+ "spend": 0.004494,
+ "input_cost": 0.00161,
+ "output_cost": 0.002884,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "gpt-5.6-responses_service_tier_priority",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "gpt-5.6",
+ "endpoint": "/v1/responses",
+ "request": {
+ "model": "$MODEL",
+ "input": "priority text",
+ "service_tier": "priority"
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "resp_$REQUEST_ID",
+ "object": "response",
+ "created_at": 1700000000,
+ "status": "completed",
+ "model": "gpt-5.6",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_$REQUEST_ID",
+ "status": "completed",
+ "role": "assistant",
+ "content": [
+ {
+ "type": "output_text",
+ "text": "scripted response",
+ "annotations": []
+ }
+ ]
+ }
+ ],
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412,
+ "total_tokens": 2252,
+ "input_tokens_details": {
+ "cached_tokens": 0
+ },
+ "output_tokens_details": {
+ "reasoning_tokens": 0
+ },
+ "service_tier": "priority"
+ },
+ "service_tier": "priority"
+ }
+ },
+ "expected": {
+ "spend": 0.017976,
+ "input_cost": 0.00644,
+ "output_cost": 0.011536,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_input_text",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-sonnet-5",
+ "content": [
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0117,
+ "input_cost": 0.00552,
+ "output_cost": 0.00618,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_cache_read",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "cached text",
+ "cache_control": {
+ "type": "ephemeral"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-sonnet-5",
+ "content": [
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 640,
+ "output_tokens": 380,
+ "cache_read_input_tokens": 12288
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0113064,
+ "input_cost": 0.0056064,
+ "output_cost": 0.0057,
+ "prompt_tokens": 12928,
+ "completion_tokens": 380,
+ "cache_read_cost": 0.0036864
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_cache_write_5m",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 350,
+ "messages": [
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "cache this text",
+ "cache_control": {
+ "type": "ephemeral"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-sonnet-5",
+ "content": [
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 512,
+ "output_tokens": 350,
+ "cache_creation_input_tokens": 9216,
+ "cache_creation": {
+ "ephemeral_5m_input_tokens": 9216,
+ "ephemeral_1h_input_tokens": 0
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.041346,
+ "input_cost": 0.036096,
+ "output_cost": 0.00525,
+ "prompt_tokens": 9728,
+ "completion_tokens": 350,
+ "cache_creation_cost": 0.03456
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_cache_write_1h",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 350,
+ "messages": [
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "text",
+ "text": "cache this text for an hour",
+ "cache_control": {
+ "type": "ephemeral",
+ "ttl": "1h"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-sonnet-5",
+ "content": [
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 512,
+ "output_tokens": 350,
+ "cache_creation_input_tokens": 9216,
+ "cache_creation": {
+ "ephemeral_5m_input_tokens": 2048,
+ "ephemeral_1h_input_tokens": 7168
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.057474,
+ "input_cost": 0.052224,
+ "output_cost": 0.00525,
+ "prompt_tokens": 9728,
+ "completion_tokens": 350,
+ "cache_creation_cost": 0.050688
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_web_search",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ],
+ "tools": [
+ {
+ "type": "web_search_20250305",
+ "name": "web_search"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-sonnet-5",
+ "content": [
+ {
+ "type": "server_tool_use",
+ "id": "srv_$REQUEST_ID",
+ "name": "web_search",
+ "input": {
+ "query": "scripted query"
+ }
+ },
+ {
+ "type": "web_search_tool_result",
+ "tool_use_id": "srv_$REQUEST_ID",
+ "content": [
+ {
+ "type": "web_search_result",
+ "title": "scripted result",
+ "url": "https://scripted.example"
+ }
+ ]
+ },
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412,
+ "server_tool_use": {
+ "web_search_requests": 2
+ }
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0317,
+ "input_cost": 0.00552,
+ "output_cost": 0.00618,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412,
+ "tool_usage_cost": 0.02
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_stream",
+ "covers": "quota_management.spend_tracking.scripted_wire.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ],
+ "stream": true
+ },
+ "response": {
+ "content_type": "text/event-stream",
+ "frames": [
+ "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_$REQUEST_ID\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-sonnet-5\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":1840}}}",
+ "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}",
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"scripted \"}}",
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"response\"}}",
+ "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}",
+ "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"output_tokens\":412}}",
+ "event: message_stop\ndata: {\"type\":\"message_stop\"}"
+ ]
+ },
+ "expected": {
+ "spend": 0.0117,
+ "input_cost": 0.00552,
+ "output_cost": 0.00618,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_stream_cache_read",
+ "covers": "quota_management.spend_tracking.scripted_wire.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 380,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ],
+ "stream": true
+ },
+ "response": {
+ "content_type": "text/event-stream",
+ "frames": [
+ "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_$REQUEST_ID\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-sonnet-5\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":640,\"cache_read_input_tokens\":12288}}}",
+ "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}",
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"scripted \"}}",
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"response\"}}",
+ "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}",
+ "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"output_tokens\":380}}",
+ "event: message_stop\ndata: {\"type\":\"message_stop\"}"
+ ]
+ },
+ "expected": {
+ "spend": 0.0113064,
+ "input_cost": 0.0056064,
+ "output_cost": 0.0057,
+ "prompt_tokens": 12928,
+ "completion_tokens": 380,
+ "cache_read_cost": 0.0036864
+ }
+ },
+ {
+ "name": "claude-sonnet-5-messages_tiered_input_above_200k",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-sonnet-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 620,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-sonnet-5",
+ "content": [
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 210000,
+ "output_tokens": 620
+ }
+ }
+ },
+ "expected": {
+ "spend": 1.27395,
+ "input_cost": 1.26,
+ "output_cost": 0.01395,
+ "prompt_tokens": 210000,
+ "completion_tokens": 620
+ }
+ },
+ {
+ "name": "claude-haiku-4-5-messages_input_text",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "claude-haiku-4-5",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "id": "msg_$REQUEST_ID",
+ "type": "message",
+ "role": "assistant",
+ "model": "claude-haiku-4-5",
+ "content": [
+ {
+ "type": "text",
+ "text": "scripted response"
+ }
+ ],
+ "stop_reason": "end_turn",
+ "stop_sequence": null,
+ "usage": {
+ "input_tokens": 1840,
+ "output_tokens": 412
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.0039,
+ "input_cost": 0.00184,
+ "output_cost": 0.00206,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "us.anthropic.claude-opus-5-v1:0-messages_input_text",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "us.anthropic.claude-opus-5-v1:0",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "text": "scripted response"
+ }
+ ]
+ }
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 1840,
+ "outputTokens": 412
+ },
+ "metrics": {
+ "latencyMs": 42
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.02145,
+ "input_cost": 0.01012,
+ "output_cost": 0.01133,
+ "prompt_tokens": 1840,
+ "completion_tokens": 412
+ }
+ },
+ {
+ "name": "anthropic.claude-sonnet-5-v1:0-messages_cache_read",
+ "covers": "quota_management.spend_tracking.cost_matrix.logs_cost",
+ "model": "anthropic.claude-sonnet-5-v1:0",
+ "endpoint": "/v1/messages",
+ "request": {
+ "model": "$MODEL",
+ "max_tokens": 412,
+ "messages": [
+ {
+ "role": "user",
+ "content": "summarize the attached material in one line"
+ }
+ ]
+ },
+ "response": {
+ "content_type": "application/json",
+ "body": {
+ "output": {
+ "message": {
+ "role": "assistant",
+ "content": [
+ {
+ "text": "scripted response"
+ }
+ ]
+ }
+ },
+ "stopReason": "end_turn",
+ "usage": {
+ "inputTokens": 640,
+ "outputTokens": 380,
+ "totalTokens": 13308,
+ "cacheReadInputTokens": 12288
+ },
+ "metrics": {
+ "latencyMs": 42
+ }
+ }
+ },
+ "expected": {
+ "spend": 0.01243704,
+ "input_cost": 0.00616704,
+ "output_cost": 0.00627,
+ "prompt_tokens": 12928,
+ "completion_tokens": 380,
+ "cache_read_cost": 0.00405504
+ }
}
]
}