Skip to main content
Cloudflare AI Gateway provides a unified interface to access multiple AI providers with observability, caching, and rate limiting. Braintrust automatically traces requests through Cloudflare AI Gateway across all supported providers.

Setup

Install the Braintrust SDK and OpenAI client:
Configure your environment variables:
.env

Trace with Cloudflare AI Gateway

Use wrapOpenAI to automatically trace requests through Cloudflare’s unified API endpoint:

Switching providers

Cloudflare AI Gateway’s unified API allows you to easily switch between different AI providers by changing the model parameter and corresponding API key. All requests are automatically traced by Braintrust regardless of which provider you use.
Cloudflare AI Gateway supports OpenAI, Anthropic, Google AI Studio, Groq, Mistral, Cohere, Perplexity, DeepSeek, Cerebras, xAI, and Workers AI. See the Cloudflare documentation for the complete list.

Resources