> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Using OpenAI Responses API with Braintrust SDKs

export const plans_0 = "Any"

export const deployments_0 = "Any"

export const data_plane_version_0 = undefined

export const use_case_0 = "Use case: Developers integrating the OpenAI Responses API with Braintrust tracing and prompt management who need to know what is supported and how to work around current gaps"

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## Summary

**Goal:** Use the OpenAI Responses API with Braintrust tracing, gateway routing, and prompt templates.

**Features:** `wrapOpenAI()` instrumentation, Braintrust gateway, `prompt.build()` workaround.

## Configuration steps

### Step 1: Trace Responses API calls with `wrapOpenAI()`

`wrapOpenAI()` automatically instruments `responses.create()`, `.stream()`, `.parse()`, and `.compact()`. No additional configuration is needed.

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import { initLogger, wrapOpenAI } from "braintrust";
import OpenAI from "openai";

initLogger({ projectName: "my-project", apiKey: process.env.BRAINTRUST_API_KEY });
const client = wrapOpenAI(new OpenAI());

const response = await client.responses.create({
  model: "gpt-4o-mini",
  input: "What is the capital of France?",
});
```

### Step 2: Route Responses API calls through the Braintrust gateway

Point your OpenAI client base URL at the Braintrust gateway. Responses API and Chat Completions calls are both routed correctly.

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const client = wrapOpenAI(new OpenAI({
  baseURL: "https://api.braintrust.dev/v1/proxy",
  apiKey: process.env.BRAINTRUST_API_KEY,
}));
```

### Step 3: Use `prompt.build()` output with `responses.create()`

`prompt.build()` doesn't support a `'responses'` flavor at the time of writing this. Only `'chat'` and `'completion'` are available. As a workaround, use the default chat flavor and pass `compiled.messages` as `input` — the role-based structure is compatible.

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const prompt = await loadPrompt({ projectId, slug });
const compiled = prompt.build(variables); // { messages, model, ... }

const response = await client.responses.create({
  model: compiled.model,
  input: compiled.messages, // same format, different key
});
```
