OpenAI
OpenAI provides access to GPT models including GPT-5 and other cutting-edge language models. Braintrust integrates seamlessly with OpenAI through direct API access, wrapOpenAI
wrapper functions for automatic tracing, and proxy support.
Setup
To use OpenAI with Braintrust, you'll need an OpenAI API key.
- Visit OpenAI's API platform and create a new API key
- Add the OpenAI API key to your organization's AI providers
- Set the OpenAI API key and your Braintrust API key as environment variables
API keys are encrypted using 256-bit AES-GCM encryption and are not stored or logged by Braintrust.
Install the braintrust
and openai
packages.
pnpm add braintrust openai
Trace with OpenAI
Trace your OpenAI LLM calls for observability and monitoring.
Using the OpenAI Agents SDK? See the OpenAI Agents SDK framework docs.
Trace automatically with wrapOpenAI
Braintrust provides wrapOpenAI
(TypeScript) and wrap_openai
(Python) functions that automatically log OpenAI API calls. To use them, initialize the logger and pass the OpenAI client to the wrapOpenAI
function.
wrapOpenAI
is a convenience function that wraps the OpenAI client with the Braintrust logger. For more control, learn how to customize traces.
Stream OpenAI responses
wrap_openai
/wrapOpenAI
can automatically log metrics like prompt_tokens
, completion_tokens
, and tokens
for streaming LLM calls if the LLM API returns them. Set include_usage
to true
in the stream_options
parameter to receive these metrics from OpenAI.
Evaluate with OpenAI
Evaluations help you distill the non-deterministic outputs of OpenAI 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 OpenAI eval setup
Evaluate the outputs of OpenAI models with Braintrust.
Use OpenAI as an LLM judge
You can use OpenAI models to score the outputs of other AI systems. This example uses the LLMClassifierFromSpec
scorer to score the relevance of the outputs of an AI system.
Install the autoevals
package to use the LLMClassifierFromSpec
scorer.
pnpm add autoevals
Create a scorer that uses the LLMClassifierFromSpec
scorer to score the relevance of the outputs of an AI system. You can then include relevanceScorer
as a scorer in your Eval
function (see above).
Additional features
Structured outputs
OpenAI's structured outputs are supported with the wrapper functions.
Function calling and tools
Braintrust supports OpenAI function calling for building AI agents with tools.
Multimodal content, attachments, errors, and masking sensitive data
To learn more about these topics, check out the customize traces guide.
Use OpenAI with Braintrust AI proxy
You can also access OpenAI models through the Braintrust AI Proxy, which provides a unified interface for multiple providers.
Cookbooks
- Evaluating audio with the OpenAI Realtime API
- Using Python functions to extract text from images
- Using functions to build a RAG agent
Models and capabilities
Model | Multimodal | Reasoning | Max input | Max output | Input $/1M | Output $/1M |
---|---|---|---|---|---|---|
gpt-5 | 400,000 | 128,000 | $1.25 | $10.00 | ||
gpt-5-2025-08-07 | 400,000 | 128,000 | $1.25 | $10.00 | ||
gpt-5-mini | 400,000 | 128,000 | $0.25 | $2.00 | ||
gpt-5-mini-2025-08-07 | 400,000 | 128,000 | $0.25 | $2.00 | ||
gpt-5-nano | 400,000 | 128,000 | $0.05 | $0.40 | ||
gpt-5-nano-2025-08-07 | 400,000 | 128,000 | $0.05 | $0.40 | ||
gpt-5-chat-latest | 400,000 | 128,000 | $1.25 | $10.00 | ||
gpt-4o | 128,000 | 16,384 | $2.50 | $10.00 | ||
gpt-4o-2024-11-20 | 128,000 | 16,384 | $2.50 | $10.00 | ||
gpt-4o-2024-08-06 | 128,000 | 16,384 | $2.50 | $10.00 | ||
gpt-4o-2024-05-13 | 128,000 | 4,096 | $5.00 | $15.00 | ||
gpt-4.1 | 1,047,576 | 32,768 | $2.00 | $8.00 | ||
gpt-4.1-2025-04-14 | 1,047,576 | 32,768 | $2.00 | $8.00 | ||
gpt-4o-mini | 128,000 | 16,384 | $0.15 | $0.60 | ||
gpt-4o-mini-2024-07-18 | 128,000 | 16,384 | $0.15 | $0.60 | ||
gpt-4.1-mini | 1,047,576 | 32,768 | $0.40 | $1.60 | ||
gpt-4.1-mini-2025-04-14 | 1,047,576 | 32,768 | $0.40 | $1.60 | ||
gpt-4.1-nano | 1,047,576 | 32,768 | $0.10 | $0.40 | ||
gpt-4.1-nano-2025-04-14 | 1,047,576 | 32,768 | $0.10 | $0.40 | ||
o4-mini | 200,000 | 100,000 | $1.10 | $4.40 | ||
o4-mini-2025-04-16 | 200,000 | 100,000 | $1.10 | $4.40 | ||
o3-mini | 200,000 | 100,000 | $1.10 | $4.40 | ||
o3-mini-2025-01-31 | 200,000 | 100,000 | $1.10 | $4.40 | ||
o3-pro | 200,000 | 100,000 | $20.00 | $80.00 | ||
o3-pro-2025-06-10 | 200,000 | 100,000 | $20.00 | $80.00 | ||
o3 | 200,000 | 100,000 | $2.00 | $8.00 | ||
o3-2025-04-16 | 200,000 | 100,000 | $2.00 | $8.00 | ||
o1 | 200,000 | 100,000 | $15.00 | $60.00 | ||
o1-2024-12-17 | 200,000 | 100,000 | $15.00 | $60.00 | ||
o1-preview | 128,000 | 32,768 | $15.00 | $60.00 | ||
o1-preview-2024-09-12 | 128,000 | 32,768 | $15.00 | $60.00 | ||
o1-mini | 128,000 | 65,536 | $1.10 | $4.40 | ||
o1-mini-2024-09-12 | 128,000 | 65,536 | $3.00 | $12.00 | ||
o1-pro | 200,000 | 100,000 | $150.00 | $600.00 | ||
o1-pro-2025-03-19 | 200,000 | 100,000 | $150.00 | $600.00 | ||
chatgpt-4o-latest | 128,000 | 4,096 | $5.00 | $15.00 | ||
gpt-4-turbo | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-4-turbo-2024-04-09 | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-4-turbo-preview | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-4 | 8,192 | 4,096 | $30.00 | $60.00 | ||
gpt-4-0125-preview | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-4-1106-preview | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-4-0613 | 8,192 | 4,096 | $30.00 | $60.00 | ||
gpt-4-0314 | 8,192 | 4,096 | $30.00 | $60.00 | ||
gpt-4.5-preview | 128,000 | 16,384 | $75.00 | $150.00 | ||
gpt-4.5-preview-2025-02-27 | 128,000 | 16,384 | $75.00 | $150.00 | ||
gpt-4o-search-preview | 128,000 | 16,384 | $2.50 | $10.00 | ||
gpt-4o-search-preview-2025-03-11 | 128,000 | 16,384 | $2.50 | $10.00 | ||
gpt-4o-mini-search-preview | 128,000 | 16,384 | $0.15 | $0.60 | ||
gpt-4o-mini-search-preview-2025-03-11 | 128,000 | 16,384 | $0.15 | $0.60 | ||
gpt-3.5-turbo-0125 | 16,385 | 4,096 | $0.50 | $1.50 | ||
gpt-3.5-turbo | 16,385 | 4,096 | $1.50 | $2.00 | ||
gpt-3.5-turbo-1106 | 16,385 | 4,096 | $1.00 | $2.00 | ||
gpt-3.5-turbo-instruct | 8,192 | 4,096 | $1.50 | $2.00 | ||
gpt-3.5-turbo-instruct-0914 | 8,192 | 4,097 | $1.50 | $2.00 | ||
gpt-4-32k | 32,768 | 4,096 | $60.00 | $120.00 | ||
gpt-4-32k-0613 | 32,768 | 4,096 | $60.00 | $120.00 | ||
gpt-4-32k-0314 | 32,768 | 4,096 | $60.00 | $120.00 | ||
gpt-4-vision-preview | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-4-1106-vision-preview | 128,000 | 4,096 | $10.00 | $30.00 | ||
gpt-3.5-turbo-16k | 16,385 | 4,096 | $3.00 | $4.00 | ||
gpt-3.5-turbo-16k-0613 | 16,385 | 4,096 | $3.00 | $4.00 | ||
gpt-3.5-turbo-0613 | 4,097 | 4,096 | $1.50 | $2.00 | ||
gpt-3.5-turbo-0301 | 4,097 | 4,096 | $1.50 | $2.00 | ||
text-davinci-003 | ﹣ | ﹣ | $2.00 | $2.00 |