Ottieni il costo per dimensione
anthropic-beta: analytics-usage-cost-2026-08-24. Learn how to send beta headers.Ottieni il costo in USD in un intervallo di date, suddiviso per dimensione.
Restituisce una riga per ogni combinazione delle dimensioni group_by[] richieste (e dell'intervallo temporale, quando time_bucket_width è impostato) che presenta costi nell'intervallo di date, classificata in base alla spesa o ordinata per intervallo temporale; tutte le combinazioni vengono restituite attraverso le pagine. Senza group_by[] e senza time_bucket_width, una singola riga aggrega l'intero intervallo di date. Include tutti i costi, che siano attribuibili o meno a un utente con licenza. Richiede una chiave API con lo scope read:analytics, oppure una chiave API Admin. Questo endpoint è in beta e non è disponibile per le organizzazioni con la predisposizione HIPAA abilitata: le loro richieste API restituiscono un errore 400. Il report di un'organizzazione padre relativo alle sue organizzazioni figlie esclude le organizzazioni figlie che hanno la predisposizione HIPAA abilitata. Se l'organizzazione padre ha organizzazioni figlie e tutte hanno la predisposizione HIPAA abilitata, la richiesta restituisce un errore 400.
Parameters
Returns
require "anthropic"
anthropic = Anthropic::Client.new(api_key: "my-anthropic-api-key")
page = anthropic.beta.organization.analytics.cost.list(starting_at: Time.parse("2026-09-01T00:00:00Z"))
puts(page){
"data": [
{
"cost": {
"amount": "41280.000000",
"currency": "USD",
"list_amount": "51600.000000",
"requests": 128
},
"ending_at": "2026-10-01T00:00:00Z",
"group": {
"actor": {
"deleted": false,
"email_address": "user@emaildomain.com",
"name": "Jane Doe",
"type": "user_actor",
"user_id": "user_01WxYzAbCdEfGhJkMnPqRsTu"
},
"actor_type": "user_actor",
"agent_id": "agent_01VHd3EAGJ6PLkP9LM7DDu3f",
"api_key_id": "apikey_01BcDeFgHjKmNpQrStUvWxYz",
"claude_tag_category": "dm",
"claude_tag_user_id": "U0123ABCDEF",
"context_window": "0-200k",
"cost_type": "tokens",
"deployment_id": "depl_01JFC6ihzZHtAuyHsaENdJhY",
"environment_id": "env_017oTjuGedHtjhJauVC5xGJD",
"inference_geo": "global",
"model": "claude-opus-5-5",
"organization_id": "12345678-1234-5678-1234-567812345678",
"product": "chat",
"rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
"service_tier": "standard",
"session_id": "sesn_0187kPDyNCwibNNvfaPEApCJ",
"slack_channel_id": "C0123ABCDEF",
"speed": "fast",
"token_type": "cache_creation.ephemeral_1h_input_tokens",
"user_profile_id": "uprof_01M33NeYUQK2WV9PpYcsPHLi",
"workspace_id": "wrkspc_01AbCdEfGhJkLmNpQrStUvWx"
},
"starting_at": "2026-09-01T00:00:00Z"
}
],
"data_refreshed_at": "2026-10-01T04:02:11Z",
"has_more": true,
"next_page": "next_page"
}Returns Examples
{
"data": [
{
"cost": {
"amount": "41280.000000",
"currency": "USD",
"list_amount": "51600.000000",
"requests": 128
},
"ending_at": "2026-10-01T00:00:00Z",
"group": {
"actor": {
"deleted": false,
"email_address": "user@emaildomain.com",
"name": "Jane Doe",
"type": "user_actor",
"user_id": "user_01WxYzAbCdEfGhJkMnPqRsTu"
},
"actor_type": "user_actor",
"agent_id": "agent_01VHd3EAGJ6PLkP9LM7DDu3f",
"api_key_id": "apikey_01BcDeFgHjKmNpQrStUvWxYz",
"claude_tag_category": "dm",
"claude_tag_user_id": "U0123ABCDEF",
"context_window": "0-200k",
"cost_type": "tokens",
"deployment_id": "depl_01JFC6ihzZHtAuyHsaENdJhY",
"environment_id": "env_017oTjuGedHtjhJauVC5xGJD",
"inference_geo": "global",
"model": "claude-opus-5-5",
"organization_id": "12345678-1234-5678-1234-567812345678",
"product": "chat",
"rbac_group_id": "rbac_group_012rppKaSVsmTo6NqRDXQXNF",
"service_tier": "standard",
"session_id": "sesn_0187kPDyNCwibNNvfaPEApCJ",
"slack_channel_id": "C0123ABCDEF",
"speed": "fast",
"token_type": "cache_creation.ephemeral_1h_input_tokens",
"user_profile_id": "uprof_01M33NeYUQK2WV9PpYcsPHLi",
"workspace_id": "wrkspc_01AbCdEfGhJkLmNpQrStUvWx"
},
"starting_at": "2026-09-01T00:00:00Z"
}
],
"data_refreshed_at": "2026-10-01T04:02:11Z",
"has_more": true,
"next_page": "next_page"
}