Skip to main content
Braintrust supports custom AI providers, allowing you to integrate any AI model or endpoint into your evaluation and tracing workflows. This includes custom models from existing providers, self-hosted models, or proprietary AI services. Custom providers appear alongside standard providers in model selection dropdowns.

Setup

If you have custom models as part of your OpenAI or other accounts, or if you’re running your own AI endpoints, you can add them to Braintrust by configuring a custom provider.
  1. Go to Settings > AI providers.
  2. Add a new organization or project provider and choose Custom providers > New.
  3. On Setup, choose the Provider type, enter a unique Name, and configure the credentials and endpoint required by your provider.
  4. Under Models, click Custom model and enter the model identifier your endpoint accepts. Click the settings icon beside the model to configure its format, capabilities, and pricing.
  5. Click Create. On Models, you can browse models and copy a Gateway test command.

Configuration options

Specify the following for your custom provider.
  • Name: A unique name for your custom provider
  • Model name: The name of your custom model (e.g., gpt-3.5-acme, my-custom-llama)
  • API base URL: The base URL for your provider (labeled Endpoint URL for Bedrock)
  • Format: The API format (openai, anthropic, google, window, or js). When an endpoint URL is configured, only openai, window, and js are available — the anthropic and google formats route requests directly to their respective first-party APIs rather than to the configured endpoint, so they are incompatible with a custom endpoint URL.
  • Flavor: Whether it’s a chat or completion model (default: chat)
  • Headers: Any custom headers required for authentication or configuration
Endpoint URLs must use http or https. To protect against server-side request forgery (SSRF), Braintrust validates the resolved target of each request.

Custom headers and templating

Custom headers let you send additional authentication or configuration values to your endpoint. Braintrust includes these headers in requests to the custom endpoint. To add a custom header:
  1. Open the provider’s Setup tab.
  2. Under Request configuration, click Additional header and enter its name and value.
  3. Click Create or Update to save the provider.
Header values can also use Mustache templates to include information about the caller or requested model. The supported variables are:
  • {{email}}: Email of the user associated with the Braintrust API key
  • {{model}}: The model name being requested
Example header configuration:
API keys are stored as one-way cryptographic hashes, never in plaintext.

Streaming support

If your endpoint supports streaming natively, enable This endpoint supports streaming. Braintrust will automatically convert the response to streaming format, allowing your models to work in the playground and other streaming contexts.

Model metadata

Model metadata describes a custom model’s capabilities and pricing. You can specify whether the model supports multimodal inputs and provide token prices so Braintrust can estimate usage costs. To configure model metadata:
  1. Open the provider’s Setup tab.
  2. In the Models section, click the settings icon beside the custom model.
  3. Configure the fields below, then click Create or Update to save the provider.
The available metadata fields include:
  • Multimodal: Whether the model supports multimodal inputs
  • Input cost: Cost per million input tokens (for experiment cost estimation)
  • Output cost: Cost per million output tokens (for experiment cost estimation)
  • Input cache read cost: Cost per million cached input tokens read (for experiment cost estimation)
  • Input cache write cost: Cost per million input tokens written to cache (for experiment cost estimation)
Cache cost fields are relevant for models that support prompt caching (e.g., Anthropic’s Claude models, OpenAI’s GPT models with cache_control). These fields help Braintrust accurately estimate costs when using cached prompts in trace logs and evaluations.

Provider failover

If a custom model’s provider fails, Braintrust can retry the request against a fallback model on another provider. To set this up:
  1. In your custom provider’s list of models, click the settings button () next to a model to open its options. Under Fallback models, add one or more models to try if this one fails.
  2. Turn on Enable failover by default to apply failover to every request, or pass the x-bt-fallback-providers header to enable it per request.
Fallback models come from your other configured providers, and failover only reaches a provider whose credentials are configured. See Configure failover for custom models for the full reference, including how the gateway selects and retries providers.

Trace logs with custom providers

Trace custom provider LLM calls for observability and monitoring.

Automatic tracing

Once your custom provider is configured, tracing works automatically.
In the examples below, organizations on the EU data plane should replace api.braintrust.dev with api-eu.braintrust.dev.

Manual tracing

For more control over tracing, you can manually log calls to your custom provider.

Evaluations

Evaluations distill the non-deterministic outputs of custom models into an effective feedback loop that enables you to ship more reliable, higher quality products. Braintrust Eval is a simple function composed of a dataset of user inputs, a task, and a set of scorers. To learn more about evaluations, see the Experiments guide.

Basic evaluation setup

Use your custom models as evaluators in Braintrust experiments.

Use custom providers for LLM-as-a-judge

Custom models can serve as evaluators for other AI systems.

Compare custom models

You can run experiments comparing your custom models against standard providers.

Common use cases

Self-hosted models

For self-hosted models (e.g. using Ollama, vLLM, or custom deployments):
  1. Set the endpoint URL to your self-hosted service
  2. Choose the appropriate format based on your API compatibility
  3. Configure any required authentication headers
  4. Set streaming support based on your implementation

Fine-tuned models

For fine-tuned versions of existing models:
  1. Use the same format as the base model
  2. Set the model name to your fine-tuned model identifier
  3. Configure the endpoint URL if using a custom deployment
  4. Add any provider-specific headers for accessing fine-tuned models

Proprietary AI services

For proprietary or enterprise AI services:
  1. Configure the endpoint URL provided by your AI service
  2. Set up authentication headers as required
  3. Choose the format that best matches your service’s API
  4. Enable or disable streaming based on service capabilities
Before running large-scale evaluations, test a request from the provider’s Models tab or use a Braintrust playground to verify the configuration.