- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2026 10:31 AM
I am using Databricks Model Serving as a proxy to connect Claude Code. I established the connection through Integrate coding agents (Connect coding agents to Databricks) by generating the environment configuration:
{
"env": {
"ANTHROPIC_MODEL": "databricks-claude-opus-4-6",
"ANTHROPIC_BASE_URL": "<my_databricks_workspace>",
"ANTHROPIC_AUTH_TOKEN": "<your_token_will_appear_here>",
"ANTHROPIC_CUSTOM_HEADERS": "x-databricks-use-coding-agent-mode: true",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}SELECT
usage.usage_date,
usage.sku_name,
usage.usage_metadata.endpoint_name AS model_name,
SUM(usage.usage_quantity * list_prices.pricing.effective_list.default) AS total_cost
FROM system.billing.usage AS usage
JOIN system.billing.list_prices AS list_prices
ON usage.sku_name = list_prices.sku_name
AND usage.usage_end_time >= list_prices.price_start_time
AND (list_prices.price_end_time IS NULL OR usage.usage_end_time < list_prices.price_end_time)
WHERE
usage.usage_metadata.endpoint_name IS NOT NULL
AND usage.sku_name = 'PREMIUM_ANTHROPIC_MODEL_SERVING'
GROUP BY usage.usage_date, model_name, usage.sku_name
ORDER BY usage.usage_date, total_cost DESCThe result show user as 'null'. How can I check the usage associated with a specific user when using Model Serving as a proxy for Claude Code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2026 03:15 PM
Hi @JoaoPigozzo,
After some investigation, I found that when you use Databricks Model Serving as a proxy for Claude Code, what you see in system.billing.usage is expected. That table is is designed for cost attribution by SKU / endpoint, not per‑user analytics. For foundation models (e.g., PREMIUM_ANTHROPIC_MODEL_SERVING), identity_metadata is often not populated the way you’d expect, so "user = NULL" there is normal.
Unfortunately, there isn’t a single column in system.billing.usage that directly gives "user + $ cost" for Claude Code. The pattern is tokens per user from usage tables + cost per endpoint from billing.
If you want per‑user usage for Claude Code, the supported path is to use AI Gateway coding agents integration
This logs each request to system.ai_gateway.usage with a requester field (user or service principal). You can then do:
SELECT
requester,
endpoint_name,
date_trunc('day', event_time) AS day,
SUM(input_tokens) AS in_tokens,
SUM(output_tokens) AS out_tokens
FROM system.ai_gateway.usage
WHERE endpoint_name = '<your_coding_agent_endpoint>'
GROUP BY ALL
ORDER BY day DESC, in_tokens DESC;
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***