Applies to:
- Plan - Any
- Deployment - Any
Summary
If you don’t logmetrics.estimated_cost directly on a span, Braintrust falls back to the model registry to estimate cost from token metrics and registered pricing. Custom LLM models need to be registered in Braintrust’s model registry with pricing information for this fallback to produce a cost. Spans that log metrics.estimated_cost explicitly use that value as-is in the trace viewer and in the estimated_cost() SQL function.
Configuration Steps
Step 1: Register your custom model
Register custom model pricing on an organization-level provider. The pricing lookup used byestimated_cost() does not include project-level providers.
Go to Settings > AI providers. Click Organization provider, then choose Custom providers > New. On Setup, configure the provider, then under Models, click Custom model and enter the model identifier recorded in your traces. See Custom providers.
Step 2: Set pricing information
Click the settings icon beside the custom model to open Model options, then configure:- Input cost per million tokens
- Output cost per million tokens
- Cache read/write costs (if using prompt caching)
Step 3: Update span metadata
Ensure your logged spans includemetadata.model matching the exact registered model name.
Step 4: Query costs across projects
Use SQL to aggregate costs across multiple projects:estimated_cost_component(name) to extract a single cost component, or estimated_cost_breakdown() to return all components as a JSON object. See SQL functions for the available component names.