Kosten im Zeitverlauf abrufen
GET/v1/organizations/analytics/cost_report
Ruft die Kosten in USD im Zeitverlauf über einen Datumsbereich ab.
Gibt die Kosten in Buckets pro Minute, Stunde oder Tag zurück, optional aufgeschlüsselt nach
Produkt, Modell, Kontextfenster, Inferenzregion, Geschwindigkeit, Kostentyp oder
Token-Typ. Verfügbar für Organisationen mit einem Claude Enterprise-Plan.
Erfordert einen API-Key mit dem Scope read:analytics.
Parameters
Returns
Kosten im Zeitverlauf abrufen
import os
from datetime import datetime
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ.get(
"ANTHROPIC_API_KEY"
), # This is the default and can be omitted
)
page = client.beta.organization.analytics.cost_report.list(
starting_at=datetime.fromisoformat("2019-12-27T18:11:19.117"),
)
page = page.data[0]
print(page.ending_at)Response 200
{
"data": [
{
"ending_at": "2019-12-27T18:11:19.117Z",
"results": [
{
"amount": "amount",
"claude_tag_category": "dm",
"claude_tag_user_id": "U0123ABCDEF",
"context_window": "0-200k",
"cost_type": "code_execution",
"currency": "USD",
"inference_geo": "global",
"list_amount": "list_amount",
"model": "claude-opus-5",
"product": "chat",
"rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
"requests": 0,
"slack_channel_id": "C0123ABCDEF",
"speed": "fast",
"token_type": "cache_creation.ephemeral_1h_input_tokens"
}
],
"starting_at": "2019-12-27T18:11:19.117Z"
}
],
"data_refreshed_at": "2019-12-27T18:11:19.117Z",
"has_more": true,
"next_page": "next_page",
"organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"
}Returns Examples
Response 200
{
"data": [
{
"ending_at": "2019-12-27T18:11:19.117Z",
"results": [
{
"amount": "amount",
"claude_tag_category": "dm",
"claude_tag_user_id": "U0123ABCDEF",
"context_window": "0-200k",
"cost_type": "code_execution",
"currency": "USD",
"inference_geo": "global",
"list_amount": "list_amount",
"model": "claude-opus-5",
"product": "chat",
"rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
"requests": 0,
"slack_channel_id": "C0123ABCDEF",
"speed": "fast",
"token_type": "cache_creation.ephemeral_1h_input_tokens"
}
],
"starting_at": "2019-12-27T18:11:19.117Z"
}
],
"data_refreshed_at": "2019-12-27T18:11:19.117Z",
"has_more": true,
"next_page": "next_page",
"organization_id": "org_013FP9SaFPBg7Kw7fetjn6cF"
}