Skip to main content
Applies to:
  • Plan - Any
  • Deployment - Any

Summary

If you don’t log metrics.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 by estimated_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)
Click Create, or Update if you are editing an existing provider, to save the configuration.

Step 3: Update span metadata

Ensure your logged spans include metadata.model matching the exact registered model name.

Step 4: Query costs across projects

Use SQL to aggregate costs across multiple projects:
Save this query as a custom view for reuse across your organization. For more granular breakdowns — for example, separating cached prompt cost from uncached prompt cost — use 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.