Baseten

Baseten provides scalable infrastructure for deploying and serving machine learning models, including language models and custom AI applications. Braintrust integrates seamlessly with Baseten through direct API access, wrapper functions for automatic tracing, and proxy support.

Setup

To use Baseten models, configure your Baseten API key in Braintrust.

  1. Get a Baseten API key from Baseten Console
  2. Add the Baseten API key to your organization's AI providers
  3. Set the Baseten API key and your Braintrust API key as environment variables
.env
BASETEN_API_KEY=<your-baseten-api-key>
BRAINTRUST_API_KEY=<your-braintrust-api-key>
 
# If you are self-hosting Braintrust, set the URL of your hosted dataplane
# BRAINTRUST_API_URL=<your-braintrust-api-url>

API keys are encrypted using 256-bit AES-GCM encryption and are not stored or logged by Braintrust.

Use Baseten with Braintrust AI proxy

The Braintrust AI Proxy allows you to access Baseten models through a unified OpenAI-compatible interface.

Install the braintrust and openai packages.

pnpm add braintrust openai

Then, initialize the client and make a request to a Baseten model via the Braintrust AI Proxy.

baseten_proxy.ts
import { OpenAI } from "openai";
 
const client = new OpenAI({
  baseURL: "https://api.braintrust.dev/v1/proxy",
  apiKey: process.env.BRAINTRUST_API_KEY,
});
 
const response = await client.chat.completions.create({
  model: "gpt-oss-120b",
  messages: [{ role: "user", content: "Hello, world!" }],
});

Trace logs with Baseten

Trace your Baseten LLM calls for observability and monitoring.

When using the Braintrust AI Proxy, API calls are automatically logged to the specified project.

baseten_trace.ts
import { OpenAI } from "openai";
import { initLogger } from "braintrust";
 
initLogger({
  projectName: "My Project",
  apiKey: process.env.BRAINTRUST_API_KEY,
});
 
const client = new OpenAI({
  baseURL: "https://api.braintrust.dev/v1/proxy",
  apiKey: process.env.BRAINTRUST_API_KEY,
});
 
// All API calls are automatically logged
const result = await client.chat.completions.create({
  model: "gpt-oss-120b",
  messages: [{ role: "user", content: "What is machine learning?" }],
});

The Braintrust AI Proxy is not required to trace Baseten API calls. For more control, learn how to customize traces.

Evaluate with Baseten

Evaluations distill the non-deterministic outputs of Baseten 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, check out the Experiments guide.

eval.ts
import { Eval } from "braintrust";
import { OpenAI } from "openai";
 
const client = new OpenAI({
  baseURL: "https://api.braintrust.dev/v1/proxy",
  apiKey: process.env.BRAINTRUST_API_KEY,
});
 
Eval("Baseten Evaluation", {
  data: () => [
    { input: "What is 2+2?", expected: "4" },
    { input: "What is the capital of France?", expected: "Paris" },
  ],
  task: async (input) => {
    const response = await client.chat.completions.create({
      model: "openai/gpt-oss-120b",
      messages: [{ role: "user", content: input }],
    });
    return response.choices[0].message.content;
  },
  scores: [
    {
      name: "accuracy",
      scorer: (args) => (args.output === args.expected ? 1 : 0),
    },
  ],
});

To learn more about tool use, multimodal support, attachments, and masking sensitive data with Baseten, visit the customize traces guide.

Models and capabilities

ModelMultimodalReasoningMax inputMax outputInput $/1MOutput $/1M
openai/gpt-oss-120b$0.15$0.60
Qwen3-Coder-480B-A35B-Instruct$0.38$1.53
moonshotai/Kimi-K2-Instruct$0.60$2.50
deepseek-ai/DeepSeek-V3-0324$0.77$0.77

On this page

Baseten - Docs - Braintrust