Skip to main content
Applies to:
  • Plan - Any
  • Deployment - Any
  • Use case - Debugging unexpected context length errors when using a model that should support a larger context window, caused by Braintrust routing to a different AI provider

Summary

Issue: Requests to a model with a large context window return a context_length_exceeded error with a smaller token limit than expected. Cause: Multiple providers can be eligible to serve the same model name. If those providers map the name to different underlying deployments, a request may reach a deployment with a smaller context limit. Resolution: Correct the model mappings or remove the affected model from providers that cannot serve it with the required limits. For Gateway requests, you can also specify a particular eligible provider.

Resolution steps

Step 1: Confirm which provider handled the request

Open the failed run’s trace in Braintrust and check:
  • The purple chat completion span (not the root span)
  • metadata.model — confirms which model ID was sent to the provider
If the model ID matches what you expected but the error shows a smaller context limit, the request may have been routed to a provider with a different underlying deployment.

Step 2: Fix provider configuration

Go to Settings > AI providers and do one of the following: Option A — Fix the primary provider: Update the configuration for your providers to match actual limits. Option B — Remove, disable, or restrict additional providers: Remove or disable providers that don’t have the correct model deployed, or that map to older or smaller versions of the model. To keep a provider available for other models, use model restrictions to exclude the affected model. If the mapping is a custom model, remove that custom model entry. Option C — Check custom model mappings: If using custom endpoints or Azure deployments, verify that the deployment name actually corresponds to the model you expect.
Note: Multiple providers may serve the same model name even when their underlying deployments differ. Make sure each eligible provider maps that name to the model you expect.

Step 3: Verify the fix

Re-run your prompt with cache disabled to confirm requests now route to the correct provider and the context length error is resolved.