SpyBara
Go Premium

Documentation 2026-06-04 06:52 UTC to 2026-06-05 06:45 UTC

18 files changed +417 −631. View all changes and history on the product overview
2026
Wed 24 22:02 Tue 23 15:59 Mon 22 22:58 Tue 16 21:57 Mon 15 23:02 Fri 12 19:02 Thu 11 08:59 Wed 10 15:48 Tue 9 06:34 Fri 5 06:45 Thu 4 06:52 Wed 3 06:53 Tue 2 06:51 Mon 1 06:53
Details

18### Trace-grading workflow18### Trace-grading workflow

19 19 

201. Open **Logs** > **Traces** in the dashboard.201. Open **Logs** > **Traces** in the dashboard.

212. Inspect a representative workflow trace from Agent Builder or an SDK-based app with tracing enabled.212. Inspect a representative workflow trace from an SDK-based app, or from an existing Agent Builder workflow during the transition window.

223. Create a grader and run it against the selected traces.223. Create a grader and run it against the selected traces.

234. Use the results to refine prompts, tool surfaces, routing logic, or guardrails.234. Use the results to refine prompts, tool surfaces, routing logic, or guardrails.

24 24 

guides/batch.md +1 −1

Details

45- Multipart `input_reference` uploads, including video reference inputs, aren't supported in Batch.45- Multipart `input_reference` uploads, including video reference inputs, aren't supported in Batch.

46- Batch-generated videos are available for download for up to `24` hours after the batch completes.46- Batch-generated videos are available for download for up to `24` hours after the batch completes.

47 47 

48When targeting `/v1/moderations`, include an `input` field in every request body. Batch accepts both plain-text inputs (for `omni-moderation-latest` and `text-moderation-latest`) and multimodal content arrays (for `omni-moderation-latest`). The Batch worker enforces the same non-streaming requirement as the synchronous Moderations API and rejects requests that set `stream=true`.48When targeting `/v1/moderations`, include an `input` field in every request body. Batch accepts plain-text inputs and content arrays with text or image inputs using `omni-moderation-latest`. The Batch worker rejects requests that set `stream=true`, matching the synchronous moderation endpoint.

49 49 

50```jsonl50```jsonl

51{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo-0125", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}51{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo-0125", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}

guides/chatkit.md +20 −10

Details

18 18 

19## Overview19## Overview

20 20 

21There are two ways to implement ChatKit:21Choose between two ChatKit paths:

22 22 

23- **Recommended integration**. Embed ChatKit in your frontend, customize its look and feel, let OpenAI host and scale the backend from [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder). Requires a development server.23- **Custom server integration**. Run ChatKit on your own infrastructure. Use the ChatKit Python SDK and connect to any agentic service, including one built with the [Agents SDK](https://developers.openai.com/api/docs/guides/agents). Use widgets to build the frontend.

24- **Advanced integration**. Run ChatKit on your own infrastructure. Use the ChatKit Python SDK and connect to any agentic backend. Use widgets to build the frontend.24- **Existing Agent Builder-hosted integration**. If you already use ChatKit with an Agent Builder workflow, you can keep using that hosted workflow during the Agent Builder transition window.

25 

26OpenAI is deprecating Agent Builder. Existing users can continue using it

27 during the transition window, and the product is scheduled to shut down on

28 November 30, 2026. ChatKit is still available. For new work or migration

29 planning, use [advanced ChatKit integrations](https://developers.openai.com/api/docs/guides/custom-chatkit)

30 with your own server-side agent implementation, and see [Migrate from Agent

31 Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder) for Agent

32 Builder transition guidance.

25 33 

26## Get started with ChatKit34## Get started with ChatKit

27 35 

28## Embed ChatKit in your frontend36## Embed ChatKit in your frontend

29 37 

30At a high level, setting up ChatKit is a three-step process. Create an agent workflow, hosted on OpenAI servers. Then set up ChatKit and add features to build your chat experience.38Use this path only if you already have an Agent Builder workflow that backs your ChatKit implementation. For new ChatKit apps, or when migrating before Agent Builder shuts down, use the [advanced integration](https://developers.openai.com/api/docs/guides/custom-chatkit) to connect ChatKit to your own server-side agent implementation.

39 

40At a high level, setting up ChatKit with an existing hosted workflow is a three-step process. Open your existing workflow while Agent Builder remains available. Then set up ChatKit and add features to build your chat experience.

31 41 

32<br />42<br />

33![OpenAI-hosted43![OpenAI-hosted

34ChatKit](https://cdn.openai.com/API/docs/images/openai-hosted.png)44ChatKit](https://cdn.openai.com/API/docs/images/openai-hosted.png)

35 45 

36### 1. Create an agent workflow46### 1. Use an existing hosted workflow

37 47 

38Create an agent workflow with [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder). Agent Builder is a visual canvas for designing multi-step agent workflows. You'll get a workflow ID.48Open your existing workflow in [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder). You'll get a workflow ID. For transition planning, see [Migrate from Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder).

39 49 

40The chat embedded in your frontend will point to the workflow you created as the backend.50The chat embedded in your frontend will point to the workflow you select.

41 51 

42### 2. Set up ChatKit in your product52### 2. Set up ChatKit in your product

43 53 


72 82 

732. In your server-side code, pass in your workflow ID and secret key to the session endpoint.832. In your server-side code, pass in your workflow ID and secret key to the session endpoint.

74 84 

75 The client secret is the credential that your ChatKit frontend uses to open or refresh the chat session. You dont store it; you immediately hand it off to the ChatKit client library.85 The client secret is the credential that your ChatKit frontend uses to open or refresh the chat session. You don't store it; you immediately hand it off to the ChatKit client library.

76 86 

77 See the [chatkit-js repo](https://github.com/openai/chatkit-js) on GitHub.87 See the [chatkit-js repo](https://github.com/openai/chatkit-js) on GitHub.

78 88 


120```130```

121 131 

122 132 

1235. Render ChatKit in your UI. This code fetches the client secret from your server and mounts a live chat widget, connected to your workflow as the backend.1335. Render ChatKit in your UI. This code fetches the client secret from your server and mounts a live chat widget connected to your workflow.

124 134 

125 Your frontend code135 Your frontend code

126 136 


269 279 

270## Next steps280## Next steps

271 281 

272When you're happy with your ChatKit implementation, learn how to optimize it with [evals](https://developers.openai.com/api/docs/guides/agent-evals). To run ChatKit on your own infrastructure, see the [advanced integration docs](https://developers.openai.com/api/docs/guides/custom-chatkit).

282When you're happy with your ChatKit implementation, learn how to optimize it with [evals](https://developers.openai.com/api/docs/guides/agent-evals). For new ChatKit apps, or to move an existing ChatKit app off an Agent Builder-hosted workflow, see the [advanced integration docs](https://developers.openai.com/api/docs/guides/custom-chatkit).

Details

141 141 

142## OpenAI APIs for conversation state142## OpenAI APIs for conversation state

143 143 

144Our APIs make it easier to manage conversation state automatically, so you don't have to do pass inputs manually with each turn of a conversation.144Our APIs make it easier to manage conversation state automatically, so you don't have to pass inputs manually with each turn of a conversation.

145 145 

146 146 

147 147 


345- [Receive JSON responses with Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs)345- [Receive JSON responses with Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs)

346- [Extend the models with function calling](https://developers.openai.com/api/docs/guides/function-calling)346- [Extend the models with function calling](https://developers.openai.com/api/docs/guides/function-calling)

347- [Enable streaming for real-time responses](https://developers.openai.com/api/docs/guides/streaming-responses)347- [Enable streaming for real-time responses](https://developers.openai.com/api/docs/guides/streaming-responses)

348- [Build a computer using agent](https://developers.openai.com/api/docs/guides/tools-computer-use)

348- [Build a computer-using agent](https://developers.openai.com/api/docs/guides/tools-computer-use)

Details

2 2 

3When you need full control—custom authentication, data residency, on‑prem deployment, or bespoke agent orchestration—you can run ChatKit on your own infrastructure. Use OpenAI's advanced self‑hosted option to use your own server and customized ChatKit.3When you need full control—custom authentication, data residency, on‑prem deployment, or bespoke agent orchestration—you can run ChatKit on your own infrastructure. Use OpenAI's advanced self‑hosted option to use your own server and customized ChatKit.

4 4 

5Our recommended ChatKit integration helps you get started quickly: embed a5Agent Builder-hosted ChatKit workflows are in a transition window. For new

6 chat widget, customize its look and feel, let OpenAI host and scale the6 ChatKit apps, build on your own server-side agent implementation with the

7 backend. [Use simpler integration →](https://developers.openai.com/api/docs/guides/chatkit)7 ChatKit SDKs and the Agents SDK. See [ChatKit transition guidance

8 →](https://developers.openai.com/api/docs/guides/chatkit)

8 9 

9## Run ChatKit on your own infrastructure10## Run ChatKit on your own infrastructure

10 11 

Details

117 -H "Content-type: application/json" \\117 -H "Content-type: application/json" \\

118 -d '{118 -d '{

119 "model": "gpt-image-2",119 "model": "gpt-image-2",

120 "prompt": "A childrens book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter."120 "prompt": "A children'\\''s book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter."

121 }' | jq -r '.data[0].b64_json' | base64 --decode > otter.png121 }' | jq -r '.data[0].b64_json' | base64 --decode > otter.png

122```122```

123 123 

124```cli124```cli

125openai images generate \\125openai images generate \\

126 --model gpt-image-2 \\126 --model gpt-image-2 \\

127 --prompt "A childrens book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter." \\127 --prompt "A children's book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter." \\

128 --raw-output \\128 --raw-output \\

129 --transform 'data.0.b64_json' | base64 --decode > otter.png129 --transform 'data.0.b64_json' | base64 --decode > otter.png

130```130```


515import fs from "fs";515import fs from "fs";

516const openai = new OpenAI();516const openai = new OpenAI();

517 517 

518function saveBase64Image(filename, imageBase64) {

519 const imageBuffer = Buffer.from(imageBase64, "base64");

520 fs.writeFileSync(filename, imageBuffer);

521}

522 

518const stream = await openai.responses.create({523const stream = await openai.responses.create({

519 model: "gpt-5.5",524 model: "gpt-5.5",

520 input:525 input:


526for await (const event of stream) {531for await (const event of stream) {

527 if (event.type === "response.image_generation_call.partial_image") {532 if (event.type === "response.image_generation_call.partial_image") {

528 const idx = event.partial_image_index;533 const idx = event.partial_image_index;

529 const imageBase64 = event.partial_image_b64;534 saveBase64Image(\`river-partial-\${idx}.png\`, event.partial_image_b64);

530 const imageBuffer = Buffer.from(imageBase64, "base64");535 } else if (event.type === "response.completed") {

531 fs.writeFileSync(\`river\${idx}.png\`, imageBuffer);536 const imageData = event.response.output

537 .filter((output) => output.type === "image_generation_call")

538 .map((output) => output.result);

539 

540 if (imageData.length > 0) {

541 saveBase64Image("river-final.png", imageData[0]);

542 }

532 }543 }

533}544}

534```545```


539 550 

540client = OpenAI()551client = OpenAI()

541 552 

553def save_base64_image(filename, image_base64):

554 image_bytes = base64.b64decode(image_base64)

555 with open(filename, "wb") as f:

556 f.write(image_bytes)

557 

542stream = client.responses.create(558stream = client.responses.create(

543 model="gpt-5.5",559 model="gpt-5.5",

544 input="Draw a gorgeous image of a river made of white owl feathers, snaking its way through a serene winter landscape",560 input="Draw a gorgeous image of a river made of white owl feathers, snaking its way through a serene winter landscape",


549for event in stream:565for event in stream:

550 if event.type == "response.image_generation_call.partial_image":566 if event.type == "response.image_generation_call.partial_image":

551 idx = event.partial_image_index567 idx = event.partial_image_index

552 image_base64 = event.partial_image_b64568 save_base64_image(f"river-partial-{idx}.png", event.partial_image_b64)

553 image_bytes = base64.b64decode(image_base64)569 elif event.type == "response.completed":

554 with open(f"river{idx}.png", "wb") as f:570 image_data = [

555 f.write(image_bytes)571 output.result

572 for output in event.response.output

573 if output.type == "image_generation_call"

574 ]

575 

576 if image_data:

577 save_base64_image("river-final.png", image_data[0])

556```578```

557 579 

558 </div>580 </div>


967<div className="images-examples">989<div className="images-examples">

968 990 

969| Image | Mask | Output |991| Image | Mask | Output |

970| ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |992| ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

971| <img className="images-example-image" src="https://cdn.openai.com/API/docs/images/sunlit_lounge.png" alt="A pink room with a pool" /> | <img className="images-example-image" src="https://cdn.openai.com/API/docs/images/mask.png" alt="A mask in part of the pool" /> | <img className="images-example-image" src="https://cdn.openai.com/API/docs/images/sunlit_lounge_result.png" alt="The original pool with an inflatable flamigo replacing the mask" /> |993| <img className="images-example-image" src="https://cdn.openai.com/API/docs/images/sunlit_lounge.png" alt="A pink room with a pool" /> | <img className="images-example-image" src="https://cdn.openai.com/API/docs/images/mask.png" alt="A mask in part of the pool" /> | <img className="images-example-image" src="https://cdn.openai.com/API/docs/images/sunlit_lounge_result.png" alt="The original pool with an inflatable flamingo replacing the mask" /> |

972 994 

973</div>995</div>

974 996 


1151- `auto` (default): Standard filtering that seeks to limit creating certain categories of potentially age-inappropriate content.1173- `auto` (default): Standard filtering that seeks to limit creating certain categories of potentially age-inappropriate content.

1152- `low`: Less restrictive filtering.1174- `low`: Less restrictive filtering.

1153 1175 

1176### Handling blocked requests and other errors

1177 

1178Handle image generation failures the same way you handle other API errors: check the HTTP status or SDK exception type, log the request ID, and refer to the [error codes guide](https://developers.openai.com/api/docs/guides/error-codes) for authentication, quota, rate-limit, and server failures. Retries are appropriate for transient failures like `429` and `5xx`, but not for image generation user errors that require changing the request.

1179 

1180Some image generation failures are user-correctable and may return `error.type = "image_generation_user_error"`. Don't automatically retry these errors without modifying the prompt or input images. For programmatic handling, use `error.code` as the stable discriminator.

1181 

1182When `error.code = "moderation_blocked"`, the error may also include an optional `error.moderation_details` object:

1183 

1184```json

1185{

1186 "error": {

1187 "type": "image_generation_user_error",

1188 "code": "moderation_blocked",

1189 "moderation_details": {

1190 "moderation_stage": "input",

1191 "categories": ["harassment"]

1192 }

1193 }

1194}

1195```

1196 

1197The `moderation_details` object provides coarse debugging context without exposing internal classifier labels or scores.

1198 

1199`moderation_stage` can be:

1200 

1201- `input`: The block came from the prompt or request inputs.

1202- `output`: The block came from a generated image or downstream output moderation stage.

1203- `unknown`: A rare fallback when provenance is hard to determine.

1204 

1205`categories` contains coarse public labels. For example, you might see values like `harassment`, `self-harm`, `sexual`, or `violence`.

1206 

1207For most apps, keep the primary end-user message generic. Use `moderation_details` for developer logs, support workflows, analytics, and light remediation hints.

1208 

1209For example, if `harassment` appears, suggest removing abusive or targeting language. If the block happened at the `input` stage, guide the user to revise the prompt. If it happened at the `output` stage, treat it as a generated result safety block and distinguish it in your logs. Always branch on `error.code = "moderation_blocked"` first, and treat `moderation_details` as optional extra context.

1210 

1211Handle moderation-blocked image generation errors

1212 

1213```javascript

1214import OpenAI from "openai";

1215 

1216const openai = new OpenAI();

1217 

1218try {

1219 // The same error handling pattern applies to image generation requests,

1220 // image edits, and Responses API tool calls that generate images.

1221 await openai.images.generate({

1222 model: "gpt-image-2",

1223 prompt: "Create a poster humiliating my coworker with insulting captions",

1224 });

1225} catch (error) {

1226 if (error?.code !== "moderation_blocked") {

1227 throw error;

1228 }

1229 

1230 const moderationDetails = error?.moderation_details;

1231 const categories = moderationDetails?.categories ?? [];

1232 const stage = moderationDetails?.moderation_stage;

1233 

1234 let hint =

1235 "This request could not be completed because it did not meet safety requirements.";

1236 

1237 if (categories.includes("harassment")) {

1238 hint =

1239 "Try removing abusive or targeting language and focus on neutral visual details instead.";

1240 } else if (stage === "input") {

1241 hint = "Try revising the prompt or input images and submit the request again.";

1242 } else if (stage === "output") {

1243 hint = "The generated result was blocked by a safety check. Try changing the prompt and generating again.";

1244 }

1245 

1246 console.error("Image generation blocked", {

1247 request_id: error?.request_id,

1248 code: error?.code,

1249 moderation_details: moderationDetails,

1250 });

1251 

1252 console.log(hint);

1253}

1254```

1255 

1256```python

1257import openai

1258from openai import OpenAI

1259 

1260client = OpenAI()

1261 

1262try:

1263 # The same error handling pattern applies to image generation requests,

1264 # image edits, and Responses API tool calls that generate images.

1265 client.images.generate(

1266 model="gpt-image-2",

1267 prompt="Create a poster humiliating my coworker with insulting captions",

1268 )

1269except openai.BadRequestError as error:

1270 if error.code != "moderation_blocked":

1271 raise

1272 

1273 error_body = error.body if isinstance(error.body, dict) else {}

1274 moderation_details = error_body.get("moderation_details") or {}

1275 categories = moderation_details.get("categories") or []

1276 stage = moderation_details.get("moderation_stage")

1277 

1278 hint = "This request could not be completed because it did not meet safety requirements."

1279 

1280 if "harassment" in categories:

1281 hint = "Try removing abusive or targeting language and focus on neutral visual details instead."

1282 elif stage == "input":

1283 hint = "Try revising the prompt or input images and submit the request again."

1284 elif stage == "output":

1285 hint = "The generated result was blocked by a safety check. Try changing the prompt and generating again."

1286 

1287 print(

1288 "Image generation blocked",

1289 {

1290 "request_id": error.request_id,

1291 "code": error.code,

1292 "moderation_details": moderation_details,

1293 },

1294 )

1295 

1296 print(hint)

1297```

1298 

1299 

1154### Supported models1300### Supported models

1155 1301 

1156When using image generation in the Responses API, `gpt-5` and newer models should support the image generation tool. [Check the model detail page for your model](https://developers.openai.com/api/docs/models) to confirm if your desired model can use the image generation tool.1302When using image generation in the Responses API, `gpt-5` and newer models should support the image generation tool. [Check the model detail page for your model](https://developers.openai.com/api/docs/models) to confirm if your desired model can use the image generation tool.

Details

17 17 

18The Responses API is a unified interface for building powerful, agent-like applications. It contains:18The Responses API is a unified interface for building powerful, agent-like applications. It contains:

19 19 

20- Built-in tools like [web search](https://developers.openai.com/api/docs/guides/tools-web-search), [file search](https://developers.openai.com/api/docs/guides/tools-file-search)20- Built-in tools like [web search](https://developers.openai.com/api/docs/guides/tools-web-search), [file search](https://developers.openai.com/api/docs/guides/tools-file-search), [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [code interpreter](https://developers.openai.com/api/docs/guides/tools-code-interpreter), and [remote MCPs](https://developers.openai.com/api/docs/guides/tools-remote-mcp).

21 , [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use), [code interpreter](https://developers.openai.com/api/docs/guides/tools-code-interpreter), and [remote MCPs](https://developers.openai.com/api/docs/guides/tools-remote-mcp).

22- Seamless multi-turn interactions that allow you to pass previous responses for higher accuracy reasoning results.21- Seamless multi-turn interactions that allow you to pass previous responses for higher accuracy reasoning results.

23- Native multimodal support for text and images.22- Native multimodal support for text and images.

24 23 


85 84 

86## Migrating from Chat Completions85## Migrating from Chat Completions

87 86 

87Treat migration as three related changes: send requests to `/v1/responses`, read output from a typed `output` array, and choose how your application will carry state between turns.

88 

88### 1. Update generation endpoints89### 1. Update generation endpoints

89 90 

90Start by updating your generation endpoints from `post /v1/chat/completions` to `post /v1/responses`.91Start by updating your generation endpoints from `post /v1/chat/completions` to `post /v1/responses`.

91 92 

92If you are not using functions or multimodal inputs, then you're done! Simple message inputs are compatible from one API to the other:93If you are not using functions or multimodal inputs, simple message inputs are compatible from one API to the other:

93 94 

94Web search tool95Reuse simple message input

95 96 

96```bash97```bash

97INPUT='[98INPUT='[


155 156 

156<div data-content-switcher-pane data-value="chat-completions">157<div data-content-switcher-pane data-value="chat-completions">

157 <div class="hidden">Chat Completions</div>158 <div class="hidden">Chat Completions</div>

158 <>159 With Chat Completions, you create a `messages` array and read the model text

159 With Chat Completions, you need to create an array of messages that specify different roles and content for each role.160 from `completion.choices[0].message.content`.

160 

161 Generate text from a model161 Generate text from a model

162 162 

163```javascript163```javascript


201 }'201 }'

202```202```

203 203 

204 </>

205 204 

206 </div>205 </div>

207 <div data-content-switcher-pane data-value="responses" hidden>206 <div data-content-switcher-pane data-value="responses" hidden>

208 <div class="hidden">Responses</div>207 <div class="hidden">Responses</div>

209 <>208 With Responses, you can separate `instructions` and `input` at the top level

210 With Responses, you can separate instructions and input at the top-level. The API shape is similar to Chat Completions but has cleaner semantics.209 and read generated text from `response.output_text`.

211 

212 Generate text from a model210 Generate text from a model

213 211 

214```javascript212```javascript


247 }'245 }'

248```246```

249 247 

250 </>

251 

252 </div>

253 

254 

255 

256### 2. Update item definitions

257 

258 

259 

260<div data-content-switcher-pane data-value="chat-completions">

261 <div class="hidden">Chat Completions</div>

262 <>

263 With Chat Completions, you need to create an array of messages that specify different roles and content for each role.

264 

265 Generate text from a model

266 

267```javascript

268import OpenAI from 'openai';

269const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

270 

271const completion = await client.chat.completions.create({

272 model: 'gpt-5.5',

273 messages: [

274 { 'role': 'system', 'content': 'You are a helpful assistant.' },

275 { 'role': 'user', 'content': 'Hello!' }

276 ]

277});

278console.log(completion.choices[0].message.content);

279```

280 

281```python

282from openai import OpenAI

283client = OpenAI()

284 

285completion = client.chat.completions.create(

286 model="gpt-5.5",

287 messages=[

288 {"role": "system", "content": "You are a helpful assistant."},

289 {"role": "user", "content": "Hello!"}

290 ]

291)

292print(completion.choices[0].message.content)

293```

294 

295```bash

296curl https://api.openai.com/v1/chat/completions \\

297 -H "Content-Type: application/json" \\

298 -H "Authorization: Bearer $OPENAI_API_KEY" \\

299 -d '{

300 "model": "gpt-5.5",

301 "messages": [

302 {"role": "system", "content": "You are a helpful assistant."},

303 {"role": "user", "content": "Hello!"}

304 ]

305 }'

306```

307 

308 </>

309 248 

310 </div>249 </div>

311 <div data-content-switcher-pane data-value="responses" hidden>

312 <div class="hidden">Responses</div>

313 <>

314 With Responses, you can separate instructions and input at the top-level. The API shape is similar to Chat Completions but has cleaner semantics.

315 

316 Generate text from a model

317 

318```javascript

319import OpenAI from 'openai';

320const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

321 

322const response = await client.responses.create({

323 model: 'gpt-5.5',

324 instructions: 'You are a helpful assistant.',

325 input: 'Hello!'

326});

327 

328console.log(response.output_text);

329```

330 

331```python

332from openai import OpenAI

333client = OpenAI()

334 250 

335response = client.responses.create(

336 model="gpt-5.5",

337 instructions="You are a helpful assistant.",

338 input="Hello!"

339)

340print(response.output_text)

341```

342 251 

343```bash

344curl https://api.openai.com/v1/responses \\

345 -H "Content-Type: application/json" \\

346 -H "Authorization: Bearer $OPENAI_API_KEY" \\

347 -d '{

348 "model": "gpt-5.5",

349 "instructions": "You are a helpful assistant.",

350 "input": "Hello!"

351 }'

352```

353 252 

354 </>253### 2. Map Messages to Items

355 254 

356 </div>255Chat Completions uses `messages` as both input and output. Responses uses `input` and `output` arrays of typed Items. A `message` is one Item type, alongside Items such as `reasoning`, `function_call`, and `function_call_output`.

357 256 

257| Chat Completions concept | Responses mapping |

258| ----------------------------- | ------------------------------------------------------------------------------------------------------ |

259| `messages[]` | `input`, as a string or an array of input Items |

260| System or developer guidance | Top-level `instructions`, or compatible message Items when you need to preserve an existing transcript |

261| User message | An input message Item with `role: "user"` |

262| Assistant message | An output message Item in `response.output`; pass it back in `input` if you manually manage state |

263| Tool or function call | A `function_call` output Item |

264| Tool or function result | A `function_call_output` input Item linked to the call with `call_id` |

265| Multiple generations with `n` | Not available in Responses; make separate requests if you need multiple candidate outputs |

358 266 

267When you only need the final text, use the SDK `output_text` helper. When your flow uses reasoning, tools, or multimodal output, iterate over `response.output` and handle each Item by its `type`.

359 268 

360### 3. Update multi-turn conversations269### 3. Update multi-turn conversations

361 270 

362If you have multi-turn conversations in your application, update your context logic.271If you have multi-turn conversations in your application, update your context logic. Responses gives you three common state-management options:

272 

273- Use `previous_response_id` when you want OpenAI to manage prior response context. Resend stable `instructions` on each request, because `previous_response_id` does not carry over the previous response's top-level `instructions`.

274- Pass prior `output` Items back into the next request when you need to manage or trim context yourself.

275- Use the [Conversations API](https://developers.openai.com/api/docs/guides/conversation-state?api-mode=responses#using-the-conversations-api) when you need a persistent conversation object.

363 276 

364 277 

365 278 

366<div data-content-switcher-pane data-value="chat-completions">279<div data-content-switcher-pane data-value="chat-completions">

367 <div class="hidden">Chat Completions</div>280 <div class="hidden">Chat Completions</div>

368 <>281 In Chat Completions, you store the transcript and send the accumulated

369 In Chat Completions, you have to store and manage context yourself.282 `messages` array on each request.

370 

371 Multi-turn conversation283 Multi-turn conversation

372 284 

373```javascript285```javascript


402res2 = client.chat.completions.create(model="gpt-5.5", messages=messages)314res2 = client.chat.completions.create(model="gpt-5.5", messages=messages)

403```315```

404 316 

405 </>

406 317 

407 </div>318 </div>

408 <div data-content-switcher-pane data-value="responses" hidden>319 <div data-content-switcher-pane data-value="responses" hidden>

409 <div class="hidden">Responses</div>320 <div class="hidden">Responses</div>

410 <>321 With Responses, you can manually pass outputs from one response into the

411 With responses, the pattern is similar, you can pass outputs from one response to the input of another.322 input of another.

412 

413 Multi-turn conversation323 Multi-turn conversation

414 324 

415```python325```python


457});367});

458```368```

459 369 

460 370 You can also use `previous_response_id` to reference the previous response

461 As a simplification, we've also built a way to simply reference inputs and outputs from a previous response by passing its id.371 and create response chains or forks.

462 You can use `previous_response_id` to form chains of responses that build upon one other or create forks in a history.

463 

464 Multi-turn conversation372 Multi-turn conversation

465 373 

466```javascript374```javascript


493)401)

494```402```

495 403 

496 </>

497 404 

498 </div>405 </div>

499 406 

500 407 

501 408 

502 ### 4. Decide when to use statefulness409Even when using `previous_response_id`, all previous input tokens for responses in the chain are billed as input tokens in the API.

410 

411### 4. Decide when to use statefulness

503 412 

504 Some organizations—such as those with Zero Data Retention (ZDR) requirements—cannot use the Responses API in a stateful way due to compliance or data retention policies. To support these cases, OpenAI offers encrypted reasoning items, allowing you to keep your workflow stateless while still benefiting from reasoning items.413Responses are stored by default. Chat Completions are stored by default for new accounts. To disable storage in either API, set `store: false`.

505 414 

506 To disable statefulness, but still take advantage of reasoning:415Some organizations, such as those with Zero Data Retention (ZDR) requirements, cannot use the Responses API in a stateful way due to compliance or data retention policies. To support these cases, OpenAI offers encrypted reasoning items, allowing you to keep your workflow stateless while still benefiting from reasoning items.

507 - set `store: false` in the [store field](https://developers.openai.com/api/docs/api-reference/responses/create#responses_create-store)

508 - add `["reasoning.encrypted_content"]` to the [include field](https://developers.openai.com/api/docs/api-reference/responses/create#responses_create-include)

509 416 

510 The API will then return an encrypted version of the reasoning tokens, which you can pass back in future requests just like regular reasoning items.417To disable statefulness but still take advantage of reasoning:

511 For ZDR organizations, OpenAI enforces store=false automatically. When a request includes encrypted_content, it is decrypted in-memory (never written to disk), used for generating the next response, and then securely discarded. Any new reasoning tokens are immediately encrypted and returned to you, ensuring no intermediate state is ever persisted.

512 418 

419- Set `store: false` in the [store field](https://developers.openai.com/api/docs/api-reference/responses/create#responses_create-store).

420- Add `["reasoning.encrypted_content"]` to the [include field](https://developers.openai.com/api/docs/api-reference/responses/create#responses_create-include).

513 421 

514 ### 5. Update function definitions422The API will then return an encrypted version of the reasoning tokens, which you can pass back in future requests just like regular reasoning items.

423For ZDR organizations, OpenAI enforces `store: false` automatically. When a request includes `encrypted_content`, it is decrypted in memory, used for generating the next response, and then securely discarded. Any new reasoning tokens are immediately encrypted and returned to you, ensuring no intermediate state is persisted.

515 424 

516 There are two minor, but notable, differences in how functions are defined between Chat Completions and Responses.425### 5. Update function definitions and outputs

517 426 

518 1. In Chat Completions, functions are defined using externally tagged polymorphism, whereas in Responses, they are internally-tagged.427There are two minor, but notable, differences in how functions are defined between Chat Completions and Responses.

519 2. In Chat Completions, functions are non-strict by default, whereas in the Responses API, functions _are_ strict by default.

520 428 

521 The Responses API function example on the right is functionally equivalent to the Chat Completions example on the left.4291. In Chat Completions, function definitions are externally tagged. In Responses, they are internally tagged.

4302. In Chat Completions, functions are non-strict by default. In Responses, function schemas are normalized into strict mode by default. To keep non-strict, best-effort function calling in Responses, explicitly set `strict: false`.

522 431 

523 #### Follow function-calling best practices432The Responses API function example on the right is functionally equivalent to the Chat Completions example on the left.

524 433 

525 In Responses, tool calls and their outputs are two distinct types of Items that are correlated using a `call_id`. See434#### Follow function-calling best practices

526 the [tool calling docs](https://developers.openai.com/api/docs/guides/function-calling#function-tool-example) for more detail on how function calling works in Responses.

527 435 

528 ### 6. Update Structured Outputs definition436In Responses, tool calls and their outputs are two distinct types of Items that are correlated using a `call_id`. See

437the [function calling docs](https://developers.openai.com/api/docs/guides/function-calling#function-tool-example) for more detail on how function calling works in Responses.

529 438 

530 In the Responses API, defining structured outputs have moved from `response_format` to `text.format`:439### 6. Update Structured Outputs definitions

440 

441In the Responses API, Structured Outputs definitions have moved from `response_format` to `text.format`:

531 442 

532 443 

533 444 


769 680 

770 681 

771 682 

772 ### 7. Upgrade to native tools683### 7. Update streaming consumers

684 

685Chat Completions streaming returns incremental chunks with a `delta` field. Responses streaming uses typed server-sent events. Update stream consumers to branch on each event's `type` and handle the events your UI or orchestration layer needs.

686 

687For text streaming, listen for events such as:

773 688 

774 If your application has use cases that would benefit from OpenAI's native [tools](https://developers.openai.com/api/docs/guides/tools), you can update your tool calls to use OpenAI's tools out of the box.689- `response.created`

690- `response.output_text.delta`

691- `response.completed`

692- `error`

693 

694Function-calling streams can also emit events such as `response.function_call_arguments.delta` and `response.function_call_arguments.done`. See the [streaming Responses guide](https://developers.openai.com/api/docs/guides/streaming-responses?api-mode=responses) and [Responses streaming events reference](https://developers.openai.com/api/docs/api-reference/responses-streaming).

695 

696### 8. Upgrade to native tools

697 

698If your application has use cases that would benefit from OpenAI's native [tools](https://developers.openai.com/api/docs/guides/tools), you can update your tool calls to use OpenAI's tools out of the box.

775 699 

776 700 

777 701 

778<div data-content-switcher-pane data-value="chat-completions">702<div data-content-switcher-pane data-value="chat-completions">

779 <div class="hidden">Chat Completions</div>703 <div class="hidden">Chat Completions</div>

780 <>704 With Chat Completions, you cannot use OpenAI-hosted tools natively and have

781 With Chat Completions, you cannot use OpenAI's tools natively and have to write your own.705 to write your own tool integration.

782 Web search tool706 Web search tool

783 707 

784```javascript708```javascript


843 --data-urlencode "key=$SEARCH_API_KEY"\767 --data-urlencode "key=$SEARCH_API_KEY"\

844```768```

845 769 

846 </>

847 </div>770 </div>

848 <div data-content-switcher-pane data-value="responses" hidden>771 <div data-content-switcher-pane data-value="responses" hidden>

849 <div class="hidden">Responses</div>772 <div class="hidden">Responses</div>

850 <>773 With Responses, you can specify the tools that you want the model to use.

851 With Responses, you can simply specify the tools that you are interested in.

852 

853 Web search tool774 Web search tool

854 775 

855```javascript776```javascript


883 }'804 }'

884```805```

885 806 

886 </>

887 807 

888 </div>808 </div>

889 809 

890 810 

891 811 

892## Incremental migration812### 9. Check common migration errors

813 

814Watch for these issues when moving code from Chat Completions to Responses:

815 

816- Reading `choices[0].message.content` instead of `response.output_text` or `response.output`.

817- Treating every `output` entry as a message. Reasoning, tool, and function calls are separate Item types.

818- Dropping reasoning, function call, or function call output Items when manually carrying context into the next response.

819- Sending a function result without the matching `call_id`.

820- Using `response_format` in a Responses request instead of `text.format`.

821- Reusing Chat Completions streaming chunk handlers without handling typed Responses events.

822- Assuming `previous_response_id` removes billing for prior context. Previous input tokens in the response chain are still billed as input tokens.

823 

824## Incremental rollout checklist

893 825 

894The Responses API is a superset of the Chat Completions API, and Chat Completions remains supported. You can migrate one user flow at a time:826Chat Completions remains supported, so you can migrate one user flow at a time.

895 827 

8961. Start with a simple text-generation flow and update the endpoint, input, and output handling.828- [ ] Start with a simple text-generation flow.

8972. Update multi-turn state management, then migrate function calling and Structured Outputs.829- [ ] Update the endpoint, request body, and output handling.

8983. For streaming flows, update consumers to handle typed Responses events such as `response.output_text.delta`. See the [streaming Responses guide](https://developers.openai.com/api/docs/guides/streaming-responses?api-mode=responses).830- [ ] Decide whether the flow uses `previous_response_id`, manual Item replay, or the Conversations API.

8994. Compare behavior, latency, and errors before routing more traffic to Responses.831- [ ] If the flow is stateless or ZDR, add `store: false` and include encrypted reasoning items when reasoning context must continue across turns.

832- [ ] Migrate function definitions and verify function call outputs include the correct `call_id`.

833- [ ] Move Structured Outputs schemas from `response_format` to `text.format`.

834- [ ] Update streaming consumers to handle typed Responses events.

835- [ ] Replace custom orchestration with OpenAI-hosted tools where they fit the workflow.

836- [ ] Compare behavior, latency, token usage, and errors before routing more traffic to Responses.

900 837 

901We recommend migrating all flows to the Responses API over time to take advantage of the latest OpenAI features and improvements.838We recommend migrating all flows to the Responses API over time to take advantage of the latest OpenAI features and improvements.

902 839 


904 841 

905Based on developer feedback from the [Assistants API](https://developers.openai.com/api/docs/api-reference/assistants) beta, we've incorporated key improvements into the Responses API to make it more flexible, faster, and easier to use. The Responses API represents the future direction for building agents on OpenAI.842Based on developer feedback from the [Assistants API](https://developers.openai.com/api/docs/api-reference/assistants) beta, we've incorporated key improvements into the Responses API to make it more flexible, faster, and easier to use. The Responses API represents the future direction for building agents on OpenAI.

906 843 

907We now have Assistant-like and Thread-like objects in the Responses API. Learn more in the [migration guide](https://developers.openai.com/api/docs/guides/assistants/migration). As of August 26th, 2025, we're deprecating the Assistants API, with a sunset date of August 26, 2026.

844We now have Assistant-like and Thread-like objects in the Responses API. Learn more in the [migration guide](https://developers.openai.com/api/docs/guides/assistants/migration). As of August 26, 2025, we're deprecating the Assistants API, with a sunset date of August 26, 2026.

Details

1# Moderation1# Moderation

2 2 

3Use the [moderations](https://developers.openai.com/api/docs/api-reference/moderations) endpoint to check whether text or images are potentially harmful. If harmful content is identified, you can take corrective action, like filtering content or intervening with user accounts creating offending content. The moderation endpoint is free to use. Image files are limited to 20 MB.3Use OpenAI moderation models to detect harmful content in text and images. You can classify standalone inputs with the [moderation endpoint](https://developers.openai.com/api/docs/api-reference/moderations) or request moderation scores alongside a generated response. Use the results to enforce your application's policy, such as filtering content, routing a request for review, or intervening with accounts that submit flagged content.

4 4 

5You can use two models for this endpoint:5The `omni-moderation-latest` model accepts text and image inputs. It doesn't classify audio. The moderation endpoint is free to use, and image files can be up to 20 MB.

6 6 

7- `omni-moderation-latest`: This model and all snapshots support more categorization options and multi-modal inputs.7## Choose a moderation workflow

8- `text-moderation-latest` **(Legacy)**: Older model that supports only text inputs and fewer input categorizations. The newer omni-moderation models will be the best choice for new applications.

9 8 

10## Quickstart9| Workflow | Use when |

10| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |

11| [Moderate generated content](#moderate-generated-content) | Your application generates text with the Responses API or Chat Completions API and needs moderation signals. |

12| [Classify standalone inputs](#classify-standalone-inputs) | Your application needs to classify text or images without generating a model response. |

13| [Understand moderation results](#understand-moderation-results) | Your application needs to interpret flags, categories, scores, or applied input types. |

14| [Review supported categories](#review-supported-categories) | Your application needs to know which harm categories apply to text, images, or both. |

11 15 

12Use the tabs below to see how you can moderate text inputs or image inputs, using our [official SDKs](https://developers.openai.com/api/docs/libraries) and the [omni-moderation-latest model](https://developers.openai.com/api/docs/models#moderation):16## Moderate generated content

17 

18When your application needs generated text and moderation scores together, pass a top-level `moderation` object in the generation request. The API returns moderation scores for the model input and generated output without a separate moderation request.

19 

20The model still generates normally. Review the moderation results before you show the output to a user or take downstream actions.

21 

22 

23 

24Set `moderation.model` when you create a response:

25 

26The Responses API returns an input `moderation_result` object at `response.moderation.input` and an output `moderation_result` object at `response.moderation.output`.

27 

28 

29 

30 

31 

32Inline moderation results use the same category fields as a standalone moderation result. Start with `flagged` for a first-pass decision, then inspect `categories` and `category_scores` for logging, routing, audit trails, or human-review queues. A refusal or other safety-aware response can still trigger a flag if it discusses harmful content. Treat moderation scores as signals for your application's policy, not as an automatic blocking decision.

33 

34Check the moderation result type before you read scores if your application needs to handle moderation failures. If a moderation step can't complete, the corresponding input or output moderation field can contain an error instead of moderation scores.

35 

36For tool-calling requests, moderation covers tool-call arguments and tool outputs when they appear in conversation content. It doesn't cover tool names, tool descriptions, tool schemas, or response-format schemas.

37 

38If you stream a generated response, moderation scores arrive after the full generated output is available. They aren't included with partial output deltas.

39 

40## Classify standalone inputs

41 

42Use the [moderation endpoint](https://developers.openai.com/api/docs/api-reference/moderations) to classify text or image inputs without generating a model response. The tabs below show how to use the [OpenAI libraries](https://developers.openai.com/api/docs/libraries) and the [`omni-moderation-latest` model](https://developers.openai.com/api/docs/models#moderation):

13 43 

14 44 

15 45 


22 52 

23 53 

24 54 

25Here's a full example output, where the input is an image from a single frame of a war movie. The model correctly predicts indicators of violence in the image, with a `violence` category score of greater than 0.8.55## Understand moderation results

56 

57Here's a full example output for an image from a single frame of a war movie. The model identifies indicators of violence in the image, with a `violence` category score greater than 0.8.

26 58 

27```json59```json

28{60{


81}113}

82```114```

83 115 

84The output has several categories in the JSON response, which tell you which (if any) categories of content are present in the inputs, and to what degree the model believes them to be present.116The JSON response includes fields that describe which categories are present in the input and the model's confidence in each category.

85 117 

86<table>118<table>

87 <tr>119 <tr>


106 <tr>138 <tr>

107 <td>`category_scores`</td>139 <td>`category_scores`</td>

108 <td>140 <td>

109 Contains a dictionary of per-category scores output by the model, denoting141 Contains a dictionary of per-category scores. Each score represents the

110 the model's confidence that the input violates the OpenAI's policy for the142 model's confidence that the input contains content in the category. The

111 category. The value is between 0 and 1, where higher values denote higher143 value is between 0 and 1, where higher values denote higher confidence.

112 confidence.

113 </td>144 </td>

114 </tr>145 </tr>

115 <tr>146 <tr>

116 <td>`category_applied_input_types`</td>147 <td>`category_applied_input_types`</td>

117 <td>148 <td>

118 This property contains information on which input types were flagged in149 Contains the input types that the category score applies to. For example,

119 the response, for each category. For example, if the both the image and150 if the `violence/graphic` category applies to both image and text inputs,

120 text inputs to the model are flagged for "violence/graphic", the151 the `violence/graphic` property is set to `["image", "text"]`.

121 `violence/graphic` property will be set to `["image", "text"]`. This is

122 only available on omni models.

123 </td>152 </td>

124 </tr>153 </tr>

125</table>154</table>


128 Therefore, custom policies that rely on `category_scores` may need157 Therefore, custom policies that rely on `category_scores` may need

129 recalibration over time.158 recalibration over time.

130 159 

131## Content classifications160## Review supported categories

132 161 

133The table below describes the types of content that can be detected in the moderation API, along with which models and input types are supported for each category.162The table below describes the content categories that the moderation endpoint can detect and the input types that each category supports.

134 163 

135Categories marked as "Text only" do not support image inputs. If you send only164Categories marked as "Text only" do not support image inputs. If you send only

136 images (without accompanying text) to the `omni-moderation-latest` model, it165 images (without accompanying text) to the `omni-moderation-latest` model, it


145 <th>174 <th>

146 <strong>Description</strong>175 <strong>Description</strong>

147 </th>176 </th>

148 <th>

149 <strong>Models</strong>

150 </th>

151 <th>177 <th>

152 <strong>Inputs</strong>178 <strong>Inputs</strong>

153 </th>179 </th>


158 Content that expresses, incites, or promotes harassing language towards184 Content that expresses, incites, or promotes harassing language towards

159 any target.185 any target.

160 </td>186 </td>

161 <td>All</td>

162 <td>Text only</td>187 <td>Text only</td>

163 </tr>188 </tr>

164 <tr>189 <tr>


167 Harassment content that also includes violence or serious harm towards any192 Harassment content that also includes violence or serious harm towards any

168 target.193 target.

169 </td>194 </td>

170 <td>All</td>

171 <td>Text only</td>195 <td>Text only</td>

172 </tr>196 </tr>

173 <tr>197 <tr>


178 or caste. Hateful content aimed at non-protected groups (e.g., chess202 or caste. Hateful content aimed at non-protected groups (e.g., chess

179 players) is harassment.203 players) is harassment.

180 </td>204 </td>

181 <td>All</td>

182 <td>Text only</td>205 <td>Text only</td>

183 </tr>206 </tr>

184 <tr>207 <tr>


188 targeted group based on race, gender, ethnicity, religion, nationality,211 targeted group based on race, gender, ethnicity, religion, nationality,

189 sexual orientation, disability status, or caste.212 sexual orientation, disability status, or caste.

190 </td>213 </td>

191 <td>All</td>

192 <td>Text only</td>214 <td>Text only</td>

193 </tr>215 </tr>

194 <tr>216 <tr>


197 Content that gives advice or instruction on how to commit illicit acts. A219 Content that gives advice or instruction on how to commit illicit acts. A

198 phrase like "how to shoplift" would fit this category.220 phrase like "how to shoplift" would fit this category.

199 </td>221 </td>

200 <td>Omni only</td>

201 <td>Text only</td>222 <td>Text only</td>

202 </tr>223 </tr>

203 <tr>224 <tr>


206 The same types of content flagged by the `illicit` category, but also227 The same types of content flagged by the `illicit` category, but also

207 includes references to violence or procuring a weapon.228 includes references to violence or procuring a weapon.

208 </td>229 </td>

209 <td>Omni only</td>

210 <td>Text only</td>230 <td>Text only</td>

211 </tr>231 </tr>

212 <tr>232 <tr>


215 Content that promotes, encourages, or depicts acts of self-harm, such as235 Content that promotes, encourages, or depicts acts of self-harm, such as

216 suicide, cutting, and eating disorders.236 suicide, cutting, and eating disorders.

217 </td>237 </td>

218 <td>All</td>

219 <td>Text and images</td>238 <td>Text and images</td>

220 </tr>239 </tr>

221 <tr>240 <tr>


225 engage in acts of self-harm, such as suicide, cutting, and eating244 engage in acts of self-harm, such as suicide, cutting, and eating

226 disorders.245 disorders.

227 </td>246 </td>

228 <td>All</td>

229 <td>Text and images</td>247 <td>Text and images</td>

230 </tr>248 </tr>

231 <tr>249 <tr>


235 cutting, and eating disorders, or that gives instructions or advice on how253 cutting, and eating disorders, or that gives instructions or advice on how

236 to commit such acts.254 to commit such acts.

237 </td>255 </td>

238 <td>All</td>

239 <td>Text and images</td>256 <td>Text and images</td>

240 </tr>257 </tr>

241 <tr>258 <tr>


245 sexual activity, or that promotes sexual services (excluding sex education262 sexual activity, or that promotes sexual services (excluding sex education

246 and wellness).263 and wellness).

247 </td>264 </td>

248 <td>All</td>

249 <td>Text and images</td>265 <td>Text and images</td>

250 </tr>266 </tr>

251 <tr>267 <tr>


253 <td>269 <td>

254 Sexual content that includes an individual who is under 18 years old.270 Sexual content that includes an individual who is under 18 years old.

255 </td>271 </td>

256 <td>All</td>

257 <td>Text only</td>272 <td>Text only</td>

258 </tr>273 </tr>

259 <tr>274 <tr>

260 <td>`violence`</td>275 <td>`violence`</td>

261 <td>Content that depicts death, violence, or physical injury.</td>276 <td>Content that depicts death, violence, or physical injury.</td>

262 <td>All</td>

263 <td>Text and images</td>277 <td>Text and images</td>

264 </tr>278 </tr>

265 <tr>279 <tr>


268 Content that depicts death, violence, or physical injury in graphic282 Content that depicts death, violence, or physical injury in graphic

269 detail.283 detail.

270 </td>284 </td>

271 <td>All</td>

272 <td>Text and images</td>285 <td>Text and images</td>

273 </tr>286 </tr>

274</table>287</table>

Details

54Some prompt engineering techniques work with every model, like using message roles. But different model types (like reasoning versus GPT models) might need to be prompted differently to produce the best results. Even different snapshots of models within the same family could produce different results. So as you build more complex applications, we strongly recommend:54Some prompt engineering techniques work with every model, like using message roles. But different model types (like reasoning versus GPT models) might need to be prompted differently to produce the best results. Even different snapshots of models within the same family could produce different results. So as you build more complex applications, we strongly recommend:

55 55 

56- Pinning your production applications to specific [model snapshots](https://developers.openai.com/api/docs/models) (like `gpt-4.1-2025-04-14` for example) to ensure consistent behavior56- Pinning your production applications to specific [model snapshots](https://developers.openai.com/api/docs/models) (like `gpt-4.1-2025-04-14` for example) to ensure consistent behavior

57- Building [evals](https://developers.openai.com/api/docs/guides/evals) that measure the behavior of your prompts so you can monitor prompt performance as you iterate, or when you change and upgrade model versions57- Building tests and evaluation suites that measure prompt behavior so you can monitor performance as you iterate, or when you change and upgrade model versions

58 58 

59Now, let's examine some tools and techniques available to you to construct prompts.59Now, let's examine some tools and techniques available to you to construct prompts.

60 60 


197- `developer` messages provide the system's rules and business logic, like a function definition.197- `developer` messages provide the system's rules and business logic, like a function definition.

198- `user` messages provide inputs and configuration to which the `developer` message instructions are applied, like arguments to a function.198- `user` messages provide inputs and configuration to which the `developer` message instructions are applied, like arguments to a function.

199 199 

200## Reusable prompts200## Version prompts in code

201 201 

202In the OpenAI dashboard, you can develop reusable [prompts](https://platform.openai.com/chat/edit) that you can use in API requests, rather than specifying the content of prompts in code. This way, you can more easily build and evaluate your prompts, and deploy improved versions of your prompts without changing your integration code.202Store production prompts in your application code instead of creating reusable prompt objects. Code-managed prompts let you use typed inputs, code review, tests, and your normal deployment process to change model behavior.

203 203 

204OpenAI is deprecating reusable prompt objects in the API. Prompt creation will204OpenAI is deprecating reusable prompt objects in the API. Prompt creation will

205 be de-emphasized beginning June 3, 2026, and `v1/prompts` is scheduled to shut205 be de-emphasized beginning June 3, 2026, and `v1/prompts` is scheduled to shut


207 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) for the current207 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) for the current

208 timeline.208 timeline.

209 209 

210For new prompt-engineering work:

210 211 

212- Keep prompt builders in a small module near the feature they support.

213- Use typed function arguments or schemas for dynamic values such as customer data, files, or task options.

214- Pass the generated `instructions` and `input` directly to the [Responses API](https://developers.openai.com/api/docs/api-reference/responses/create).

215- Add representative fixtures, tests, and evaluation checks before changing production prompts.

216- Roll out prompt changes through your deployment system, using feature flags or configuration when you need staged releases.

211 217 

212 218If your integration already calls a saved prompt with a prompt ID or version, use the [prompt object migration guide](https://developers.openai.com/api/docs/guides/prompting/migrate-from-prompt-object) to move that prompt into code.

213 

214Here's how it works:

215 

2161. **Create a reusable prompt** in the [dashboard](https://platform.openai.com/chat/edit) with placeholders like `{{customer_name}}`.

2172. **Use the prompt** in your API request with the `prompt` parameter. The prompt parameter object has three properties you can configure:

218 - `id` — Unique identifier of your prompt, found in the dashboard

219 - `version` — A specific version of your prompt (defaults to the "current" version as specified in the dashboard)

220 - `variables` — A map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input message types like `input_image` or `input_file`. [See the full API reference](https://developers.openai.com/api/docs/api-reference/responses/create).

221 

222 

223 

224<div data-content-switcher-pane data-value="simple">

225 <div class="hidden">String variables</div>

226 Generate text with a prompt template

227 

228```javascript

229import OpenAI from "openai";

230const client = new OpenAI();

231 

232const response = await client.responses.create({

233 model: "gpt-5.5",

234 prompt: {

235 id: "pmpt_abc123",

236 version: "2",

237 variables: {

238 customer_name: "Jane Doe",

239 product: "40oz juice box"

240 }

241 }

242});

243 

244console.log(response.output_text);

245```

246 

247```python

248from openai import OpenAI

249client = OpenAI()

250 

251response = client.responses.create(

252 model="gpt-5.5",

253 prompt={

254 "id": "pmpt_abc123",

255 "version": "2",

256 "variables": {

257 "customer_name": "Jane Doe",

258 "product": "40oz juice box"

259 }

260 }

261)

262 

263print(response.output_text)

264```

265 

266```bash

267curl https://api.openai.com/v1/responses \\

268 -H "Authorization: Bearer $OPENAI_API_KEY" \\

269 -H "Content-Type: application/json" \\

270 -d '{

271 "model": "gpt-5.5",

272 "prompt": {

273 "id": "pmpt_abc123",

274 "version": "2",

275 "variables": {

276 "customer_name": "Jane Doe",

277 "product": "40oz juice box"

278 }

279 }

280 }'

281```

282 

283 </div>

284 <div data-content-switcher-pane data-value="filevar" hidden>

285 <div class="hidden">Variables with file input</div>

286 Prompt template with file input variable

287 

288```javascript

289import fs from "fs";

290import OpenAI from "openai";

291const client = new OpenAI();

292 

293// Upload a PDF we will reference in the prompt variables

294const file = await client.files.create({

295 file: fs.createReadStream("draconomicon.pdf"),

296 purpose: "user_data",

297});

298 

299const response = await client.responses.create({

300 model: "gpt-5.5",

301 prompt: {

302 id: "pmpt_abc123",

303 variables: {

304 topic: "Dragons",

305 reference_pdf: {

306 type: "input_file",

307 file_id: file.id,

308 },

309 },

310 },

311});

312 

313console.log(response.output_text);

314```

315 

316```python

317import openai, pathlib

318 

319client = openai.OpenAI()

320 

321# Upload a PDF we will reference in the variables

322file = client.files.create(

323 file=open("draconomicon.pdf", "rb"),

324 purpose="user_data",

325)

326 

327response = client.responses.create(

328 model="gpt-5.5",

329 prompt={

330 "id": "pmpt_abc123",

331 "variables": {

332 "topic": "Dragons",

333 "reference_pdf": {

334 "type": "input_file",

335 "file_id": file.id,

336 },

337 },

338 },

339)

340 

341print(response.output_text)

342```

343 

344```bash

345# Assume you have already uploaded the PDF and obtained FILE_ID

346curl https://api.openai.com/v1/responses \

347 -H "Authorization: Bearer $OPENAI_API_KEY" \

348 -H "Content-Type: application/json" \

349 -d '{

350 "model": "gpt-5.5",

351 "prompt": {

352 "id": "pmpt_abc123",

353 "variables": {

354 "topic": "Dragons",

355 "reference_pdf": {

356 "type": "input_file",

357 "file_id": "file-abc123"

358 }

359 }

360 }

361 }'

362```

363 

364 </div>

365 

366 

367 

368 

369 219 

370## Message formatting with Markdown and XML220## Message formatting with Markdown and XML

371 221 


630 480 

631## Next steps481## Next steps

632 482 

633Now that you known the basics of text inputs and outputs, you might want to check out one of these resources next.483Now that you know the basics of text inputs and outputs, you might want to check out one of these resources next.

634 484 

635[485[

636 486 

Details

16- Put overall tone or role guidance in the system message; keep task-specific details and examples in user messages.16- Put overall tone or role guidance in the system message; keep task-specific details and examples in user messages.

17- Combine few-shot examples into a concise YAML-style or bulleted block so they’re easy to scan and update.17- Combine few-shot examples into a concise YAML-style or bulleted block so they’re easy to scan and update.

18- Mirror your project structure with clear folder names so teammates can locate prompts quickly.18- Mirror your project structure with clear folder names so teammates can locate prompts quickly.

19- Rerun your linked eval every time you publishcatching issues early is cheaper than fixing them in production.19- Run your prompt tests and evaluation cases every time you publish; catching issues early is cheaper than fixing them in production.

20 20 

21## Prompts in the API21## Prompts in your application

22 22 

23OpenAI provides a long-lived prompt object, with versioning and templating shared by all users in a project. This design lets you manage, test, and reuse prompts across your team, with one central definition across APIs, SDKs, and dashboard.23Treat prompts as application code. Store prompt content in named modules, build dynamic sections with typed function arguments, and review prompt changes in the same pull requests as the product behavior they support.

24 24 

25OpenAI is deprecating reusable prompt objects in the API. Prompt creation will25OpenAI is deprecating reusable prompt objects in the API. Prompt creation will

26 be de-emphasized beginning June 3, 2026, and `v1/prompts` is scheduled to shut26 be de-emphasized beginning June 3, 2026, and `v1/prompts` is scheduled to shut


28 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) for the current28 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) for the current

29 timeline.29 timeline.

30 30 

31Universal prompt IDs give you flexibility to test and build. Variables and prompts share a base prompt, so when you create a new version, you can use that for [evals](https://developers.openai.com/api/docs/guides/evals) and determine whether a prompt performs better or worse.31For new work, don't create reusable prompt objects. Instead:

32 32 

33### Create a prompt33- Keep each production prompt in a code-managed, versioned helper such as `prompts/supportReply.ts`.

34- Replace prompt variables with typed function parameters or validated input objects.

35- Pass generated messages directly to the [Responses API](https://developers.openai.com/api/docs/guides/text?api-mode=responses) through `input` and `instructions`.

36- Cover prompt changes with tests, representative fixtures, and evaluation checks that run with your deployment process.

37- Use git history, PR review, release tags, and feature flags to review, ship, compare, and roll back prompt changes.

34 38 

35Log in and use the OpenAI [dashboard](https://platform.openai.com/chat) to create, save, version, and share your prompts.39If you already use prompt IDs or prompt versions in API requests, follow the [migration guide](https://developers.openai.com/api/docs/guides/prompting/migrate-from-prompt-object) to move those prompts into code.

36 

371. **Start a prompt**

38 

39 In the [Playground](https://platform.openai.com/playground), fill out the fields to create your desired prompt.

40 

41 <br />

42 

431. **Add prompt variables**

44 

45 Variables let you inject dynamic values without changing your prompt. Use them in any message role using `{{variable}}`. For example, when creating a local weather prompt, you might add a `city` variable with the value `San Francisco`.

46 

47 <br />

48 

491. **Use the prompt in your [Responses API](https://developers.openai.com/api/docs/guides/text?api-mode=responses) call**

50 

51 Find your prompt ID and version number in the URL, and pass it as `prompt_id`:

52 

53 ```curl

54 curl -s -X POST "https://api.openai.com/v1/responses" \

55 -H "Content-Type: application/json" \

56 -H "Authorization: Bearer $OPENAI_API_KEY" \

57 -d '{

58 "prompt": {

59 "prompt_id": "pmpt_123",

60 "variables": {

61 "city": "San Francisco"

62 }

63 }

64 }'

65 

66 ```

67 

681. **Create a new prompt version**

69 

70 Versions let you iterate on your prompts without overwriting existing details. You can use all versions in the API and evaluate their performance against each other. The prompt ID points to the latest published version unless you specify a version.

71 

72 To create a new version, edit the prompt and click **Update**. You'll receive a new prompt ID to copy and use in your Responses API calls.

73 

74 <br />

75 

761. **Roll back if needed**

77 

78 In the [prompts dashboard](https://platform.openai.com/chat), select the prompt you want to roll back. On the right, click **History**. Find the version you want to restore, and click **Restore**.

79 40 

80## Next steps41## Next steps

81 42 

Details

33 33 

34OpenAI's [Moderation API](https://developers.openai.com/api/docs/guides/moderation) is free-to-use and can help reduce the frequency of unsafe content in your completions. Alternatively, you may wish to develop your own content filtration system tailored to your use case.34OpenAI's [Moderation API](https://developers.openai.com/api/docs/guides/moderation) is free-to-use and can help reduce the frequency of unsafe content in your completions. Alternatively, you may wish to develop your own content filtration system tailored to your use case.

35 35 

36If your application generates text with the Responses API or Chat Completions,

37you can also [request moderation scores in the generation

38request](https://developers.openai.com/api/docs/guides/moderation#moderate-generated-content).

39 

36### Adversarial testing40### Adversarial testing

37 41 

38We recommend “red-teaming” your application to ensure it's robust to adversarial input. Test your product over a wide range of inputs and user behaviors, both a representative set and those reflective of someone trying to ‘break' your application. Does it wander off topic? Can someone easily redirect the feature via prompt injections, e.g. “ignore the previous instructions and do this instead”?42We recommend “red-teaming” your application to ensure it's robust to adversarial input. Test your product over a wide range of inputs and user behaviors, both a representative set and those reflective of someone trying to ‘break' your application. Does it wander off topic? Can someone easily redirect the feature via prompt injections, e.g. “ignore the previous instructions and do this instead”?

Details

76## Moderation risk76## Moderation risk

77 77 

78Note that streaming the model's output in a production application makes it more difficult to moderate the content of the completions, as partial completions may be more difficult to evaluate. This may have implications for approved usage.78Note that streaming the model's output in a production application makes it more difficult to moderate the content of the completions, as partial completions may be more difficult to evaluate. This may have implications for approved usage.

79 

80If you request [moderation scores with a generation request](https://developers.openai.com/api/docs/guides/moderation#moderate-generated-content), the scores arrive after the full generated output is available. They aren't included with partial output deltas.

guides/text.md +11 −155

Details

38Some prompt engineering techniques work with every model, like using message roles. But different models might need to be prompted differently to produce the best results. Even different snapshots of models within the same family could produce different results. So as you build more complex applications, we strongly recommend:38Some prompt engineering techniques work with every model, like using message roles. But different models might need to be prompted differently to produce the best results. Even different snapshots of models within the same family could produce different results. So as you build more complex applications, we strongly recommend:

39 39 

40- Pinning your production applications to specific [model snapshots](https://developers.openai.com/api/docs/models) (like `gpt-5.5-2026-04-23` for example) to ensure consistent behavior40- Pinning your production applications to specific [model snapshots](https://developers.openai.com/api/docs/models) (like `gpt-5.5-2026-04-23` for example) to ensure consistent behavior

41- Building [evals](https://developers.openai.com/api/docs/guides/evals) that measure the behavior of your prompts so you can monitor prompt performance as you iterate, or when you change and upgrade model versions41- Building tests and evaluation suites that measure prompt behavior so you can monitor performance as you iterate, or when you change and upgrade model versions

42 42 

43Now, let's examine some tools and techniques available to you to construct prompts.43Now, let's examine some tools and techniques available to you to construct prompts.

44 44 


202- `developer` messages provide the system's rules and business logic, like a function definition.202- `developer` messages provide the system's rules and business logic, like a function definition.

203- `user` messages provide inputs and configuration to which the `developer` message instructions are applied, like arguments to a function.203- `user` messages provide inputs and configuration to which the `developer` message instructions are applied, like arguments to a function.

204 204 

205## Reusable prompts205## Version prompts in code

206 206 

207In the OpenAI dashboard, you can develop reusable [prompts](https://platform.openai.com/chat/edit) that you can use in API requests, rather than specifying the content of prompts in code. This way, you can more easily build and evaluate your prompts, and deploy improved versions of your prompts without changing your integration code.207Store production prompts in your application code instead of creating reusable prompt objects. Code-managed prompts let you use typed inputs, code review, tests, and your normal deployment process to change model behavior.

208 208 

209OpenAI is deprecating reusable prompt objects in the API. Prompt creation will209OpenAI is deprecating reusable prompt objects in the API. Prompt creation will

210 be de-emphasized beginning June 3, 2026, and `v1/prompts` is scheduled to shut210 be de-emphasized beginning June 3, 2026, and `v1/prompts` is scheduled to shut


212 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) for the current212 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) for the current

213 timeline.213 timeline.

214 214 

215Here's how it works:215For new text-generation work:

216 

2171. **Create a reusable prompt** in the [dashboard](https://platform.openai.com/chat/edit) with placeholders like `{{customer_name}}`.

2182. **Use the prompt** in your API request with the `prompt` parameter. The prompt parameter object has three properties you can configure:

219 - `id` — Unique identifier of your prompt, found in the dashboard

220 - `version` — A specific version of your prompt (defaults to the "current" version as specified in the dashboard)

221 - `variables` — A map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input message types like `input_image` or `input_file`. [See the full API reference](https://developers.openai.com/api/docs/api-reference/responses/create).

222 

223 

224 

225<div data-content-switcher-pane data-value="simple">

226 <div class="hidden">String variables</div>

227 Generate text with a prompt template

228 

229```javascript

230import OpenAI from "openai";

231const client = new OpenAI();

232 

233const response = await client.responses.create({

234 model: "gpt-5.5",

235 prompt: {

236 id: "pmpt_abc123",

237 version: "2",

238 variables: {

239 customer_name: "Jane Doe",

240 product: "40oz juice box"

241 }

242 }

243});

244 

245console.log(response.output_text);

246```

247 

248```python

249from openai import OpenAI

250client = OpenAI()

251 

252response = client.responses.create(

253 model="gpt-5.5",

254 prompt={

255 "id": "pmpt_abc123",

256 "version": "2",

257 "variables": {

258 "customer_name": "Jane Doe",

259 "product": "40oz juice box"

260 }

261 }

262)

263 

264print(response.output_text)

265```

266 

267```bash

268curl https://api.openai.com/v1/responses \\

269 -H "Authorization: Bearer $OPENAI_API_KEY" \\

270 -H "Content-Type: application/json" \\

271 -d '{

272 "model": "gpt-5.5",

273 "prompt": {

274 "id": "pmpt_abc123",

275 "version": "2",

276 "variables": {

277 "customer_name": "Jane Doe",

278 "product": "40oz juice box"

279 }

280 }

281 }'

282```

283 

284 </div>

285 <div data-content-switcher-pane data-value="filevar" hidden>

286 <div class="hidden">Variables with file input</div>

287 Prompt template with file input variable

288 

289```javascript

290import fs from "fs";

291import OpenAI from "openai";

292const client = new OpenAI();

293 

294// Upload a PDF we will reference in the prompt variables

295const file = await client.files.create({

296 file: fs.createReadStream("draconomicon.pdf"),

297 purpose: "user_data",

298});

299 

300const response = await client.responses.create({

301 model: "gpt-5.5",

302 prompt: {

303 id: "pmpt_abc123",

304 variables: {

305 topic: "Dragons",

306 reference_pdf: {

307 type: "input_file",

308 file_id: file.id,

309 },

310 },

311 },

312});

313 

314console.log(response.output_text);

315```

316 

317```python

318import openai, pathlib

319 

320client = openai.OpenAI()

321 

322# Upload a PDF we will reference in the variables

323file = client.files.create(

324 file=open("draconomicon.pdf", "rb"),

325 purpose="user_data",

326)

327 

328response = client.responses.create(

329 model="gpt-5.5",

330 prompt={

331 "id": "pmpt_abc123",

332 "variables": {

333 "topic": "Dragons",

334 "reference_pdf": {

335 "type": "input_file",

336 "file_id": file.id,

337 },

338 },

339 },

340)

341 

342print(response.output_text)

343```

344 

345```bash

346# Assume you have already uploaded the PDF and obtained FILE_ID

347curl https://api.openai.com/v1/responses \

348 -H "Authorization: Bearer $OPENAI_API_KEY" \

349 -H "Content-Type: application/json" \

350 -d '{

351 "model": "gpt-5.5",

352 "prompt": {

353 "id": "pmpt_abc123",

354 "variables": {

355 "topic": "Dragons",

356 "reference_pdf": {

357 "type": "input_file",

358 "file_id": "file-abc123"

359 }

360 }

361 }

362 }'

363```

364 

365 </div>

366 216 

217- Keep prompt builders in a small module near the feature they support.

218- Use typed function arguments or schemas for dynamic values such as customer data, files, or task options.

219- Pass the generated `instructions` and `input` directly to the [Responses API](https://developers.openai.com/api/docs/api-reference/responses/create).

220- Add representative fixtures, tests, and evaluation checks before changing production prompts.

221- Roll out prompt changes through your deployment system, using feature flags or configuration when you need staged releases.

367 222 

223If your integration already calls a saved prompt with a prompt ID or version, use the [prompt object migration guide](https://developers.openai.com/api/docs/guides/prompting/migrate-from-prompt-object) to move that prompt into code.

368 224 

369## Next steps225## Next steps

370 226 

371Now that you known the basics of text inputs and outputs, you might want to check out one of these resources next.227Now that you know the basics of text inputs and outputs, you might want to check out one of these resources next.

372 228 

373[229[

374 230 

Details

332Stream an image332Stream an image

333 333 

334```javascript334```javascript

335import fs from "fs";

336import OpenAI from "openai";335import OpenAI from "openai";

337 336import fs from "fs";

338const openai = new OpenAI();337const openai = new OpenAI();

339 338 

340const prompt =339function saveBase64Image(filename, imageBase64) {

341 "Draw a gorgeous image of a river made of white owl feathers, snaking its way through a serene winter landscape";340 const imageBuffer = Buffer.from(imageBase64, "base64");

342const stream = await openai.images.generate({341 fs.writeFileSync(filename, imageBuffer);

343 prompt: prompt,342}

344 model: "gpt-image-2",343 

344const stream = await openai.responses.create({

345 model: "gpt-5.5",

346 input:

347 "Draw a gorgeous image of a river made of white owl feathers, snaking its way through a serene winter landscape",

345 stream: true,348 stream: true,

346 partial_images: 2,349 tools: [{ type: "image_generation", partial_images: 2 }],

347});350});

348 351 

349for await (const event of stream) {352for await (const event of stream) {

350 if (event.type === "image_generation.partial_image") {353 if (event.type === "response.image_generation_call.partial_image") {

351 const idx = event.partial_image_index;354 const idx = event.partial_image_index;

352 const imageBase64 = event.b64_json;355 saveBase64Image(\`river-partial-\${idx}.png\`, event.partial_image_b64);

353 const imageBuffer = Buffer.from(imageBase64, "base64");356 } else if (event.type === "response.completed") {

354 fs.writeFileSync(\`river\${idx}.png\`, imageBuffer);357 const imageData = event.response.output

358 .filter((output) => output.type === "image_generation_call")

359 .map((output) => output.result);

360 

361 if (imageData.length > 0) {

362 saveBase64Image("river-final.png", imageData[0]);

363 }

355 }364 }

356}365}

357```366```


362 371 

363client = OpenAI()372client = OpenAI()

364 373 

365stream = client.images.generate(374def save_base64_image(filename, image_base64):

366 prompt="Draw a gorgeous image of a river made of white owl feathers, snaking its way through a serene winter landscape",375 image_bytes = base64.b64decode(image_base64)

367 model="gpt-image-2",376 with open(filename, "wb") as f:

377 f.write(image_bytes)

378 

379stream = client.responses.create(

380 model="gpt-5.5",

381 input="Draw a gorgeous image of a river made of white owl feathers, snaking its way through a serene winter landscape",

368 stream=True,382 stream=True,

369 partial_images=2,383 tools=[{"type": "image_generation", "partial_images": 2}],

370)384)

371 385 

372for event in stream:386for event in stream:

373 if event.type == "image_generation.partial_image":387 if event.type == "response.image_generation_call.partial_image":

374 idx = event.partial_image_index388 idx = event.partial_image_index

375 image_base64 = event.b64_json389 save_base64_image(f"river-partial-{idx}.png", event.partial_image_b64)

376 image_bytes = base64.b64decode(image_base64)390 elif event.type == "response.completed":

377 with open(f"river{idx}.png", "wb") as f:391 image_data = [

378 f.write(image_bytes)392 output.result

393 for output in event.response.output

394 if output.type == "image_generation_call"

395 ]

396 

397 if image_data:

398 save_base64_image("river-final.png", image_data[0])

379```399```

380 400 

381 401 

Details

9## Get started with traces9## Get started with traces

10 10 

111. In the dashboard, navigate to Logs > [Traces](https://platform.openai.com/logs?api=traces).111. In the dashboard, navigate to Logs > [Traces](https://platform.openai.com/logs?api=traces).

121. Select a worfklow. You'll see logs from any workflows you created in [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder).121. Select a workflow. You'll see traces from SDK-based apps, and from existing [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder) workflows during the transition window.

131. Select a trace to inspect your workflow.131. Select a trace to inspect your workflow.

141. Create a grader, and run it to grade your agents' performance against grader criteria.141. Create a grader, and run it to grade your agents' performance against grader criteria.

15 15 

Details

17| Speech-to-speech with live audio sessions | Natural, low-latency conversations | The model handles live audio input and output directly |17| Speech-to-speech with live audio sessions | Natural, low-latency conversations | The model handles live audio input and output directly |

18| Chained voice pipeline | Predictable workflows or extending an existing text agent | Your app keeps explicit control over transcription, text reasoning, and speech output |18| Chained voice pipeline | Predictable workflows or extending an existing text agent | Your app keeps explicit control over transcription, text reasoning, and speech output |

19 19 

20Agent Builder doesn't currently support voice workflows, so voice stays an SDK-first surface.20Voice workflows are an SDK-first surface. If you're migrating a related Agent Builder project, see [Migrate from Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder) for the current transition path.

21 21 

22## Recommended starting points22## Recommended starting points

23 23 

Details

191| /v1/fine_tuning/jobs | gpt-4o-2024-08-06<br />gpt-4o-mini-2024-07-18<br />gpt-4.1-2025-04-14<br />gpt-4.1-mini-2025-04-14 | All |191| /v1/fine_tuning/jobs | gpt-4o-2024-08-06<br />gpt-4o-mini-2024-07-18<br />gpt-4.1-2025-04-14<br />gpt-4.1-mini-2025-04-14 | All |

192| /v1/images/edits | gpt-image-1<br />gpt-image-1.5<br />gpt-image-1-mini | All |192| /v1/images/edits | gpt-image-1<br />gpt-image-1.5<br />gpt-image-1-mini | All |

193| /v1/images/generations | dall-e-3<br />gpt-image-1<br />gpt-image-1.5<br />gpt-image-1-mini | All |193| /v1/images/generations | dall-e-3<br />gpt-image-1<br />gpt-image-1.5<br />gpt-image-1-mini | All |

194| /v1/moderations | text-moderation-latest\*<br />omni-moderation-latest | All |194| /v1/moderations | omni-moderation-latest | All |

195| /v1/realtime | gpt-4o-realtime-preview-2025-06-03<br />gpt-realtime<br />gpt-realtime-1.5<br />gpt-realtime-mini<br />gpt-realtime-2 | US and EU |195| /v1/realtime | gpt-4o-realtime-preview-2025-06-03<br />gpt-realtime<br />gpt-realtime-1.5<br />gpt-realtime-mini<br />gpt-realtime-2 | US and EU |

196| /v1/realtime/transcription_sessions | gpt-realtime-whisper | US and EU |196| /v1/realtime/transcription_sessions | gpt-realtime-whisper | US and EU |

197| /v1/realtime/translations | gpt-realtime-translate | US and EU |197| /v1/realtime/translations | gpt-realtime-translate | US and EU |


225 225 

226Tracing is not currently EU data residency compliant for `/v1/realtime`.226Tracing is not currently EU data residency compliant for `/v1/realtime`.

227 227 

228#### /v1/moderations

229 

230text-moderation-latest is only supported for US/EU.

231 

232## Enterprise Key Management (EKM)228## Enterprise Key Management (EKM)

233 229 

234Enterprise Key Management (EKM) allows you to encrypt your customer content at OpenAI using keys managed by your own external Key Management System (KMS).230Enterprise Key Management (EKM) allows you to encrypt your customer content at OpenAI using keys managed by your own external Key Management System (KMS).

quickstart.md +7 −17

Details

131<div className="mt-2">Congrats on running a free test API request! Start building real applications with higher limits and use <a href="/api/docs/models" target="_blank">our models</a> to generate text, audio, images, videos and more.</div>131<div className="mt-2">Congrats on running a free test API request! Start building real applications with higher limits and use <a href="/api/docs/models" target="_blank">our models</a> to generate text, audio, images, videos and more.</div>

132 132 

133<div className="mt-2">133<div className="mt-2">

134 Access dashboard features designed to help you ship faster:134 Explore tools and docs designed to help you ship faster:

135</div>135</div>

136<a136<a

137 href="https://platform.openai.com/chat"137 href="https://platform.openai.com/chat"


153 153 

154 154 

155</a>155</a>

156<a156[

157 href="https://platform.openai.com/agent-builder"

158 target="_blank"

159 rel="noreferrer"

160 onClick={() =>

161 StatsigClient.logEvent(

162 "quickstart_add_credits_agent_builder_click",

163 null,

164 null

165 )

166 }

167>

168

169 157 

170<span slot="icon">158<span slot="icon">

171 </span>159 </span>

172 Build, deploy, and optimize agent workflows.160 Use the Agents SDK to build, run, and observe agent workflows.

173 161 

174 162](https://developers.openai.com/api/docs/guides/agents)

175</a>

176 163 

177## Analyze images and files164## Analyze images and files

178 165 


220 <div data-content-switcher-pane data-value="file-search" hidden>207 <div data-content-switcher-pane data-value="file-search" hidden>

221 <div class="hidden">File search</div>208 <div class="hidden">File search</div>

222 </div>209 </div>

210 <div data-content-switcher-pane data-value="code-interpreter" hidden>

211 <div class="hidden">Code Interpreter</div>

212 </div>

223 <div data-content-switcher-pane data-value="function-calling" hidden>213 <div data-content-switcher-pane data-value="function-calling" hidden>

224 <div class="hidden">Function calling</div>214 <div class="hidden">Function calling</div>

225 </div>215 </div>