SpyBara
Go Premium

Reference 2026-08-26 22:57 UTC to 2026-08-27 21:01 UTC

39 files changed +105 −54,802. View all changes and history on the product overview
2026
Mon 31 23:00 Sat 29 07:02 Fri 28 08:02 Thu 27 21:01 Wed 26 22:57 Tue 25 21:02 Mon 24 23:01 Fri 21 21:58 Thu 20 23:59 Wed 19 21:01 Sun 16 16:58 Sat 15 02:02 Fri 14 23:57 Thu 13 22:00 Wed 12 16:01 Mon 10 22:00 Sat 8 00:59 Fri 7 21:59 Thu 6 18:59 Wed 5 02:01 Mon 3 21:58
Details

42 42 

43 Return only events whose `effective_at` (Unix seconds) is less than or equal to this value.43 Return only events whose `effective_at` (Unix seconds) is less than or equal to this value.

44 44 

45- `event_types: optional array of "api_key.created" or "api_key.updated" or "api_key.deleted" or 142 more`45- `event_types: optional array of "api_key.created" or "api_key.updated" or "api_key.deleted" or 144 more`

46 46 

47 Return only events with a `type` in one of these values. For example, `project.created`. For all options, see the documentation for the [audit log object](/docs/api-reference/audit-logs/object).47 Return only events with a `type` in one of these values. For example, `project.created`. For all options, see the documentation for the [audit log object](/docs/api-reference/audit-logs/object).

48 48 


196 196 

197 - `"tenant.project_api_key.created"`197 - `"tenant.project_api_key.created"`

198 198 

199 - `"tenant.trusted_access.business_verification.started"`

200 

201 - `"tenant.trusted_access.application.submitted"`

202 

199 - `"tenant.chatgpt_access_token.revoked"`203 - `"tenant.chatgpt_access_token.revoked"`

200 204 

201 - `"tenant.migration.completed"`205 - `"tenant.migration.completed"`


364 368 

365 The Unix timestamp (in seconds) of the event.369 The Unix timestamp (in seconds) of the event.

366 370 

367 - `type: "api_key.created" or "api_key.updated" or "api_key.deleted" or 142 more`371 - `type: "api_key.created" or "api_key.updated" or "api_key.deleted" or 144 more`

368 372 

369 The event type.373 The event type.

370 374 


518 522 

519 - `"tenant.project_api_key.created"`523 - `"tenant.project_api_key.created"`

520 524 

525 - `"tenant.trusted_access.business_verification.started"`

526 

527 - `"tenant.trusted_access.application.submitted"`

528 

521 - `"tenant.chatgpt_access_token.revoked"`529 - `"tenant.chatgpt_access_token.revoked"`

522 530 

523 - `"tenant.migration.completed"`531 - `"tenant.migration.completed"`

resources/beta/subresources/assistants/methods/create/index.md +0 −732 deleted

File Deleted View Diff

1## Create assistant

2 

3**post** `/assistants`

4 

5Create an assistant with a model and instructions.

6 

7### Body Parameters

8 

9- `model: string or "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 39 more`

10 

11 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

12 

13 - `string`

14 

15 - `AssistantSupportedModels = "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 39 more`

16 

17 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

18 

19 - `"gpt-5"`

20 

21 - `"gpt-5-mini"`

22 

23 - `"gpt-5-nano"`

24 

25 - `"gpt-5-2025-08-07"`

26 

27 - `"gpt-5-mini-2025-08-07"`

28 

29 - `"gpt-5-nano-2025-08-07"`

30 

31 - `"gpt-4.1"`

32 

33 - `"gpt-4.1-mini"`

34 

35 - `"gpt-4.1-nano"`

36 

37 - `"gpt-4.1-2025-04-14"`

38 

39 - `"gpt-4.1-mini-2025-04-14"`

40 

41 - `"gpt-4.1-nano-2025-04-14"`

42 

43 - `"o3-mini"`

44 

45 - `"o3-mini-2025-01-31"`

46 

47 - `"o1"`

48 

49 - `"o1-2024-12-17"`

50 

51 - `"gpt-4o"`

52 

53 - `"gpt-4o-2024-11-20"`

54 

55 - `"gpt-4o-2024-08-06"`

56 

57 - `"gpt-4o-2024-05-13"`

58 

59 - `"gpt-4o-mini"`

60 

61 - `"gpt-4o-mini-2024-07-18"`

62 

63 - `"gpt-4.5-preview"`

64 

65 - `"gpt-4.5-preview-2025-02-27"`

66 

67 - `"gpt-4-turbo"`

68 

69 - `"gpt-4-turbo-2024-04-09"`

70 

71 - `"gpt-4-0125-preview"`

72 

73 - `"gpt-4-turbo-preview"`

74 

75 - `"gpt-4-1106-preview"`

76 

77 - `"gpt-4-vision-preview"`

78 

79 - `"gpt-4"`

80 

81 - `"gpt-4-0314"`

82 

83 - `"gpt-4-0613"`

84 

85 - `"gpt-4-32k"`

86 

87 - `"gpt-4-32k-0314"`

88 

89 - `"gpt-4-32k-0613"`

90 

91 - `"gpt-3.5-turbo"`

92 

93 - `"gpt-3.5-turbo-16k"`

94 

95 - `"gpt-3.5-turbo-0613"`

96 

97 - `"gpt-3.5-turbo-1106"`

98 

99 - `"gpt-3.5-turbo-0125"`

100 

101 - `"gpt-3.5-turbo-16k-0613"`

102 

103- `description: optional string or null`

104 

105 The description of the assistant. The maximum length is 512 characters.

106 

107- `instructions: optional string or null`

108 

109 The system instructions that the assistant uses. The maximum length is 256,000 characters.

110 

111- `metadata: optional Metadata or null`

112 

113 Set of 16 key-value pairs that can be attached to an object. This can be

114 useful for storing additional information about the object in a structured

115 format, and querying for objects via API or the dashboard.

116 

117 Keys are strings with a maximum length of 64 characters. Values are strings

118 with a maximum length of 512 characters.

119 

120- `name: optional string or null`

121 

122 The name of the assistant. The maximum length is 256 characters.

123 

124- `reasoning_effort: optional ReasoningEffort or null`

125 

126 Constrains effort on reasoning for reasoning models. Currently supported

127 values are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.

128 Reducing reasoning effort can result in faster responses and fewer tokens

129 used on reasoning in a response. Not all reasoning models support every

130 value. See the

131 [reasoning guide](https://platform.openai.com/docs/guides/reasoning)

132 for model-specific support.

133 

134 - `"none"`

135 

136 - `"minimal"`

137 

138 - `"low"`

139 

140 - `"medium"`

141 

142 - `"high"`

143 

144 - `"xhigh"`

145 

146 - `"max"`

147 

148- `response_format: optional AssistantResponseFormatOption or null`

149 

150 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

151 

152 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

153 

154 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

155 

156 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

157 

158 - `"auto"`

159 

160 `auto` is the default value

161 

162 - `"auto"`

163 

164 - `ResponseFormatText object { type }`

165 

166 Default response format. Used to generate text responses.

167 

168 - `type: "text"`

169 

170 The type of response format being defined. Always `text`.

171 

172 - `"text"`

173 

174 - `ResponseFormatJSONObject object { type }`

175 

176 JSON object response format. An older method of generating JSON responses.

177 Using `json_schema` is recommended for models that support it. Note that the

178 model will not generate JSON without a system or user message instructing it

179 to do so.

180 

181 - `type: "json_object"`

182 

183 The type of response format being defined. Always `json_object`.

184 

185 - `"json_object"`

186 

187 - `ResponseFormatJSONSchema object { json_schema, type }`

188 

189 JSON Schema response format. Used to generate structured JSON responses.

190 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

191 

192 - `json_schema: object { name, description, schema, strict }`

193 

194 Structured Outputs configuration options, including a JSON Schema.

195 

196 - `name: string`

197 

198 The name of the response format. Must be a-z, A-Z, 0-9, or contain

199 underscores and dashes, with a maximum length of 64.

200 

201 - `description: optional string`

202 

203 A description of what the response format is for, used by the model to

204 determine how to respond in the format.

205 

206 - `schema: optional map[unknown]`

207 

208 The schema for the response format, described as a JSON Schema object.

209 Learn how to build JSON schemas [here](https://json-schema.org/).

210 

211 - `strict: optional boolean or null`

212 

213 Whether to enable strict schema adherence when generating the output.

214 If set to true, the model will always follow the exact schema defined

215 in the `schema` field. Only a subset of JSON Schema is supported when

216 `strict` is `true`. To learn more, read the [Structured Outputs

217 guide](/docs/guides/structured-outputs).

218 

219 - `type: "json_schema"`

220 

221 The type of response format being defined. Always `json_schema`.

222 

223 - `"json_schema"`

224 

225- `temperature: optional number or null`

226 

227 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

228 

229- `tool_resources: optional object { code_interpreter, file_search } or null`

230 

231 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

232 

233 - `code_interpreter: optional object { file_ids }`

234 

235 - `file_ids: optional array of string`

236 

237 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

238 

239 - `file_search: optional object { vector_store_ids, vector_stores }`

240 

241 - `vector_store_ids: optional array of string`

242 

243 The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

244 

245 - `vector_stores: optional array of object { chunking_strategy, file_ids, metadata }`

246 

247 A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.

248 

249 - `chunking_strategy: optional object { type } or object { static, type }`

250 

251 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.

252 

253 - `Auto object { type }`

254 

255 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

256 

257 - `type: "auto"`

258 

259 Always `auto`.

260 

261 - `"auto"`

262 

263 - `Static object { static, type }`

264 

265 - `static: object { chunk_overlap_tokens, max_chunk_size_tokens }`

266 

267 - `chunk_overlap_tokens: number`

268 

269 The number of tokens that overlap between chunks. The default value is `400`.

270 

271 Note that the overlap must not exceed half of `max_chunk_size_tokens`.

272 

273 - `max_chunk_size_tokens: number`

274 

275 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.

276 

277 - `type: "static"`

278 

279 Always `static`.

280 

281 - `"static"`

282 

283 - `file_ids: optional array of string`

284 

285 A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.

286 

287 - `metadata: optional Metadata or null`

288 

289 Set of 16 key-value pairs that can be attached to an object. This can be

290 useful for storing additional information about the object in a structured

291 format, and querying for objects via API or the dashboard.

292 

293 Keys are strings with a maximum length of 64 characters. Values are strings

294 with a maximum length of 512 characters.

295 

296- `tools: optional array of CodeInterpreterTool or FileSearchTool or FunctionTool`

297 

298 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

299 

300 - `CodeInterpreterTool object { type }`

301 

302 - `type: "code_interpreter"`

303 

304 The type of tool being defined: `code_interpreter`

305 

306 - `"code_interpreter"`

307 

308 - `FileSearchTool object { type, file_search }`

309 

310 - `type: "file_search"`

311 

312 The type of tool being defined: `file_search`

313 

314 - `"file_search"`

315 

316 - `file_search: optional object { max_num_results, ranking_options }`

317 

318 Overrides for the file search tool.

319 

320 - `max_num_results: optional number`

321 

322 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

323 

324 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

325 

326 - `ranking_options: optional object { score_threshold, ranker }`

327 

328 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

329 

330 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

331 

332 - `score_threshold: number`

333 

334 The score threshold for the file search. All values must be a floating point number between 0 and 1.

335 

336 - `ranker: optional "auto" or "default_2024_08_21"`

337 

338 The ranker to use for the file search. If not specified will use the `auto` ranker.

339 

340 - `"auto"`

341 

342 - `"default_2024_08_21"`

343 

344 - `FunctionTool object { function, type }`

345 

346 - `function: FunctionDefinition`

347 

348 - `name: string`

349 

350 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

351 

352 - `description: optional string`

353 

354 A description of what the function does, used by the model to choose when and how to call the function.

355 

356 - `parameters: optional FunctionParameters`

357 

358 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

359 

360 Omitting `parameters` defines a function with an empty parameter list.

361 

362 - `strict: optional boolean or null`

363 

364 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

365 

366 - `type: "function"`

367 

368 The type of tool being defined: `function`

369 

370 - `"function"`

371 

372- `top_p: optional number or null`

373 

374 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

375 

376 We generally recommend altering this or temperature but not both.

377 

378### Returns

379 

380- `Assistant object { id, created_at, description, 10 more }`

381 

382 Represents an `assistant` that can call the model and use tools.

383 

384 - `id: string`

385 

386 The identifier, which can be referenced in API endpoints.

387 

388 - `created_at: number`

389 

390 The Unix timestamp (in seconds) for when the assistant was created.

391 

392 - `description: string or null`

393 

394 The description of the assistant. The maximum length is 512 characters.

395 

396 - `instructions: string or null`

397 

398 The system instructions that the assistant uses. The maximum length is 256,000 characters.

399 

400 - `metadata: Metadata or null`

401 

402 Set of 16 key-value pairs that can be attached to an object. This can be

403 useful for storing additional information about the object in a structured

404 format, and querying for objects via API or the dashboard.

405 

406 Keys are strings with a maximum length of 64 characters. Values are strings

407 with a maximum length of 512 characters.

408 

409 - `model: string`

410 

411 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

412 

413 - `name: string or null`

414 

415 The name of the assistant. The maximum length is 256 characters.

416 

417 - `object: "assistant"`

418 

419 The object type, which is always `assistant`.

420 

421 - `"assistant"`

422 

423 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

424 

425 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

426 

427 - `CodeInterpreterTool object { type }`

428 

429 - `type: "code_interpreter"`

430 

431 The type of tool being defined: `code_interpreter`

432 

433 - `"code_interpreter"`

434 

435 - `FileSearchTool object { type, file_search }`

436 

437 - `type: "file_search"`

438 

439 The type of tool being defined: `file_search`

440 

441 - `"file_search"`

442 

443 - `file_search: optional object { max_num_results, ranking_options }`

444 

445 Overrides for the file search tool.

446 

447 - `max_num_results: optional number`

448 

449 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

450 

451 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

452 

453 - `ranking_options: optional object { score_threshold, ranker }`

454 

455 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

456 

457 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

458 

459 - `score_threshold: number`

460 

461 The score threshold for the file search. All values must be a floating point number between 0 and 1.

462 

463 - `ranker: optional "auto" or "default_2024_08_21"`

464 

465 The ranker to use for the file search. If not specified will use the `auto` ranker.

466 

467 - `"auto"`

468 

469 - `"default_2024_08_21"`

470 

471 - `FunctionTool object { function, type }`

472 

473 - `function: FunctionDefinition`

474 

475 - `name: string`

476 

477 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

478 

479 - `description: optional string`

480 

481 A description of what the function does, used by the model to choose when and how to call the function.

482 

483 - `parameters: optional FunctionParameters`

484 

485 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

486 

487 Omitting `parameters` defines a function with an empty parameter list.

488 

489 - `strict: optional boolean or null`

490 

491 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

492 

493 - `type: "function"`

494 

495 The type of tool being defined: `function`

496 

497 - `"function"`

498 

499 - `response_format: optional AssistantResponseFormatOption or null`

500 

501 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

502 

503 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

504 

505 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

506 

507 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

508 

509 - `"auto"`

510 

511 `auto` is the default value

512 

513 - `"auto"`

514 

515 - `ResponseFormatText object { type }`

516 

517 Default response format. Used to generate text responses.

518 

519 - `type: "text"`

520 

521 The type of response format being defined. Always `text`.

522 

523 - `"text"`

524 

525 - `ResponseFormatJSONObject object { type }`

526 

527 JSON object response format. An older method of generating JSON responses.

528 Using `json_schema` is recommended for models that support it. Note that the

529 model will not generate JSON without a system or user message instructing it

530 to do so.

531 

532 - `type: "json_object"`

533 

534 The type of response format being defined. Always `json_object`.

535 

536 - `"json_object"`

537 

538 - `ResponseFormatJSONSchema object { json_schema, type }`

539 

540 JSON Schema response format. Used to generate structured JSON responses.

541 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

542 

543 - `json_schema: object { name, description, schema, strict }`

544 

545 Structured Outputs configuration options, including a JSON Schema.

546 

547 - `name: string`

548 

549 The name of the response format. Must be a-z, A-Z, 0-9, or contain

550 underscores and dashes, with a maximum length of 64.

551 

552 - `description: optional string`

553 

554 A description of what the response format is for, used by the model to

555 determine how to respond in the format.

556 

557 - `schema: optional map[unknown]`

558 

559 The schema for the response format, described as a JSON Schema object.

560 Learn how to build JSON schemas [here](https://json-schema.org/).

561 

562 - `strict: optional boolean or null`

563 

564 Whether to enable strict schema adherence when generating the output.

565 If set to true, the model will always follow the exact schema defined

566 in the `schema` field. Only a subset of JSON Schema is supported when

567 `strict` is `true`. To learn more, read the [Structured Outputs

568 guide](/docs/guides/structured-outputs).

569 

570 - `type: "json_schema"`

571 

572 The type of response format being defined. Always `json_schema`.

573 

574 - `"json_schema"`

575 

576 - `temperature: optional number or null`

577 

578 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

579 

580 - `tool_resources: optional object { code_interpreter, file_search } or null`

581 

582 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

583 

584 - `code_interpreter: optional object { file_ids }`

585 

586 - `file_ids: optional array of string`

587 

588 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

589 

590 - `file_search: optional object { vector_store_ids }`

591 

592 - `vector_store_ids: optional array of string`

593 

594 The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

595 

596 - `top_p: optional number or null`

597 

598 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

599 

600 We generally recommend altering this or temperature but not both.

601 

602### Example

603 

604```http

605curl https://api.openai.com/v1/assistants \

606 -H 'Content-Type: application/json' \

607 -H 'OpenAI-Beta: assistants=v2' \

608 -H "Authorization: Bearer $OPENAI_API_KEY" \

609 -d '{

610 "model": "gpt-4o",

611 "temperature": 1,

612 "top_p": 1

613 }'

614```

615 

616#### Response

617 

618```json

619{

620 "id": "id",

621 "created_at": 0,

622 "description": "description",

623 "instructions": "instructions",

624 "metadata": {

625 "foo": "string"

626 },

627 "model": "model",

628 "name": "name",

629 "object": "assistant",

630 "tools": [

631 {

632 "type": "code_interpreter"

633 }

634 ],

635 "response_format": "auto",

636 "temperature": 1,

637 "tool_resources": {

638 "code_interpreter": {

639 "file_ids": [

640 "string"

641 ]

642 },

643 "file_search": {

644 "vector_store_ids": [

645 "string"

646 ]

647 }

648 },

649 "top_p": 1

650}

651```

652 

653### Code Interpreter

654 

655```http

656curl "https://api.openai.com/v1/assistants" \

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

658 -H "Authorization: Bearer $OPENAI_API_KEY" \

659 -H "OpenAI-Beta: assistants=v2" \

660 -d '{

661 "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",

662 "name": "Math Tutor",

663 "tools": [{"type": "code_interpreter"}],

664 "model": "gpt-4o"

665 }'

666```

667 

668#### Response

669 

670```json

671{

672 "id": "asst_abc123",

673 "object": "assistant",

674 "created_at": 1698984975,

675 "name": "Math Tutor",

676 "description": null,

677 "model": "gpt-4o",

678 "instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",

679 "tools": [

680 {

681 "type": "code_interpreter"

682 }

683 ],

684 "metadata": {},

685 "top_p": 1.0,

686 "temperature": 1.0,

687 "response_format": "auto"

688}

689```

690 

691### Files

692 

693```http

694curl https://api.openai.com/v1/assistants \

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

696 -H "Authorization: Bearer $OPENAI_API_KEY" \

697 -H "OpenAI-Beta: assistants=v2" \

698 -d '{

699 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",

700 "tools": [{"type": "file_search"}],

701 "tool_resources": {"file_search": {"vector_store_ids": ["vs_123"]}},

702 "model": "gpt-4o"

703 }'

704```

705 

706#### Response

707 

708```json

709{

710 "id": "asst_abc123",

711 "object": "assistant",

712 "created_at": 1699009403,

713 "name": "HR Helper",

714 "description": null,

715 "model": "gpt-4o",

716 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",

717 "tools": [

718 {

719 "type": "file_search"

720 }

721 ],

722 "tool_resources": {

723 "file_search": {

724 "vector_store_ids": ["vs_123"]

725 }

726 },

727 "metadata": {},

728 "top_p": 1.0,

729 "temperature": 1.0,

730 "response_format": "auto"

731}

732```

resources/beta/subresources/assistants/methods/delete/index.md +0 −60 deleted

File Deleted View Diff

1## Delete assistant

2 

3**delete** `/assistants/{assistant_id}`

4 

5Delete an assistant.

6 

7### Path Parameters

8 

9- `assistant_id: string`

10 

11### Returns

12 

13- `AssistantDeleted object { id, deleted, object }`

14 

15 - `id: string`

16 

17 - `deleted: boolean`

18 

19 - `object: "assistant.deleted"`

20 

21 - `"assistant.deleted"`

22 

23### Example

24 

25```http

26curl https://api.openai.com/v1/assistants/$ASSISTANT_ID \

27 -X DELETE \

28 -H 'OpenAI-Beta: assistants=v2' \

29 -H "Authorization: Bearer $OPENAI_API_KEY"

30```

31 

32#### Response

33 

34```json

35{

36 "id": "id",

37 "deleted": true,

38 "object": "assistant.deleted"

39}

40```

41 

42### Example

43 

44```http

45curl https://api.openai.com/v1/assistants/asst_abc123 \

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

47 -H "Authorization: Bearer $OPENAI_API_KEY" \

48 -H "OpenAI-Beta: assistants=v2" \

49 -X DELETE

50```

51 

52#### Response

53 

54```json

55{

56 "id": "asst_abc123",

57 "object": "assistant.deleted",

58 "deleted": true

59}

60```

resources/beta/subresources/assistants/methods/list/index.md +0 −377 deleted

File Deleted View Diff

1## List assistants

2 

3**get** `/assistants`

4 

5Returns a list of assistants.

6 

7### Query Parameters

8 

9- `after: optional string`

10 

11 A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

12 

13- `before: optional string`

14 

15 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

16 

17- `limit: optional number`

18 

19 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

20 

21- `order: optional "asc" or "desc"`

22 

23 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

24 

25 - `"asc"`

26 

27 - `"desc"`

28 

29### Returns

30 

31- `data: array of Assistant`

32 

33 - `id: string`

34 

35 The identifier, which can be referenced in API endpoints.

36 

37 - `created_at: number`

38 

39 The Unix timestamp (in seconds) for when the assistant was created.

40 

41 - `description: string or null`

42 

43 The description of the assistant. The maximum length is 512 characters.

44 

45 - `instructions: string or null`

46 

47 The system instructions that the assistant uses. The maximum length is 256,000 characters.

48 

49 - `metadata: Metadata or null`

50 

51 Set of 16 key-value pairs that can be attached to an object. This can be

52 useful for storing additional information about the object in a structured

53 format, and querying for objects via API or the dashboard.

54 

55 Keys are strings with a maximum length of 64 characters. Values are strings

56 with a maximum length of 512 characters.

57 

58 - `model: string`

59 

60 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

61 

62 - `name: string or null`

63 

64 The name of the assistant. The maximum length is 256 characters.

65 

66 - `object: "assistant"`

67 

68 The object type, which is always `assistant`.

69 

70 - `"assistant"`

71 

72 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

73 

74 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

75 

76 - `CodeInterpreterTool object { type }`

77 

78 - `type: "code_interpreter"`

79 

80 The type of tool being defined: `code_interpreter`

81 

82 - `"code_interpreter"`

83 

84 - `FileSearchTool object { type, file_search }`

85 

86 - `type: "file_search"`

87 

88 The type of tool being defined: `file_search`

89 

90 - `"file_search"`

91 

92 - `file_search: optional object { max_num_results, ranking_options }`

93 

94 Overrides for the file search tool.

95 

96 - `max_num_results: optional number`

97 

98 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

99 

100 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

101 

102 - `ranking_options: optional object { score_threshold, ranker }`

103 

104 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

105 

106 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

107 

108 - `score_threshold: number`

109 

110 The score threshold for the file search. All values must be a floating point number between 0 and 1.

111 

112 - `ranker: optional "auto" or "default_2024_08_21"`

113 

114 The ranker to use for the file search. If not specified will use the `auto` ranker.

115 

116 - `"auto"`

117 

118 - `"default_2024_08_21"`

119 

120 - `FunctionTool object { function, type }`

121 

122 - `function: FunctionDefinition`

123 

124 - `name: string`

125 

126 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

127 

128 - `description: optional string`

129 

130 A description of what the function does, used by the model to choose when and how to call the function.

131 

132 - `parameters: optional FunctionParameters`

133 

134 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

135 

136 Omitting `parameters` defines a function with an empty parameter list.

137 

138 - `strict: optional boolean or null`

139 

140 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

141 

142 - `type: "function"`

143 

144 The type of tool being defined: `function`

145 

146 - `"function"`

147 

148 - `response_format: optional AssistantResponseFormatOption or null`

149 

150 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

151 

152 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

153 

154 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

155 

156 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

157 

158 - `"auto"`

159 

160 `auto` is the default value

161 

162 - `"auto"`

163 

164 - `ResponseFormatText object { type }`

165 

166 Default response format. Used to generate text responses.

167 

168 - `type: "text"`

169 

170 The type of response format being defined. Always `text`.

171 

172 - `"text"`

173 

174 - `ResponseFormatJSONObject object { type }`

175 

176 JSON object response format. An older method of generating JSON responses.

177 Using `json_schema` is recommended for models that support it. Note that the

178 model will not generate JSON without a system or user message instructing it

179 to do so.

180 

181 - `type: "json_object"`

182 

183 The type of response format being defined. Always `json_object`.

184 

185 - `"json_object"`

186 

187 - `ResponseFormatJSONSchema object { json_schema, type }`

188 

189 JSON Schema response format. Used to generate structured JSON responses.

190 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

191 

192 - `json_schema: object { name, description, schema, strict }`

193 

194 Structured Outputs configuration options, including a JSON Schema.

195 

196 - `name: string`

197 

198 The name of the response format. Must be a-z, A-Z, 0-9, or contain

199 underscores and dashes, with a maximum length of 64.

200 

201 - `description: optional string`

202 

203 A description of what the response format is for, used by the model to

204 determine how to respond in the format.

205 

206 - `schema: optional map[unknown]`

207 

208 The schema for the response format, described as a JSON Schema object.

209 Learn how to build JSON schemas [here](https://json-schema.org/).

210 

211 - `strict: optional boolean or null`

212 

213 Whether to enable strict schema adherence when generating the output.

214 If set to true, the model will always follow the exact schema defined

215 in the `schema` field. Only a subset of JSON Schema is supported when

216 `strict` is `true`. To learn more, read the [Structured Outputs

217 guide](/docs/guides/structured-outputs).

218 

219 - `type: "json_schema"`

220 

221 The type of response format being defined. Always `json_schema`.

222 

223 - `"json_schema"`

224 

225 - `temperature: optional number or null`

226 

227 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

228 

229 - `tool_resources: optional object { code_interpreter, file_search } or null`

230 

231 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

232 

233 - `code_interpreter: optional object { file_ids }`

234 

235 - `file_ids: optional array of string`

236 

237 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

238 

239 - `file_search: optional object { vector_store_ids }`

240 

241 - `vector_store_ids: optional array of string`

242 

243 The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

244 

245 - `top_p: optional number or null`

246 

247 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

248 

249 We generally recommend altering this or temperature but not both.

250 

251- `first_id: string`

252 

253- `has_more: boolean`

254 

255- `last_id: string`

256 

257- `object: string`

258 

259### Example

260 

261```http

262curl https://api.openai.com/v1/assistants \

263 -H 'OpenAI-Beta: assistants=v2' \

264 -H "Authorization: Bearer $OPENAI_API_KEY"

265```

266 

267#### Response

268 

269```json

270{

271 "data": [

272 {

273 "id": "id",

274 "created_at": 0,

275 "description": "description",

276 "instructions": "instructions",

277 "metadata": {

278 "foo": "string"

279 },

280 "model": "model",

281 "name": "name",

282 "object": "assistant",

283 "tools": [

284 {

285 "type": "code_interpreter"

286 }

287 ],

288 "response_format": "auto",

289 "temperature": 1,

290 "tool_resources": {

291 "code_interpreter": {

292 "file_ids": [

293 "string"

294 ]

295 },

296 "file_search": {

297 "vector_store_ids": [

298 "string"

299 ]

300 }

301 },

302 "top_p": 1

303 }

304 ],

305 "first_id": "asst_abc123",

306 "has_more": false,

307 "last_id": "asst_abc456",

308 "object": "list"

309}

310```

311 

312### Example

313 

314```http

315curl "https://api.openai.com/v1/assistants?order=desc&limit=20" \

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

317 -H "Authorization: Bearer $OPENAI_API_KEY" \

318 -H "OpenAI-Beta: assistants=v2"

319```

320 

321#### Response

322 

323```json

324{

325 "object": "list",

326 "data": [

327 {

328 "id": "asst_abc123",

329 "object": "assistant",

330 "created_at": 1698982736,

331 "name": "Coding Tutor",

332 "description": null,

333 "model": "gpt-4o",

334 "instructions": "You are a helpful assistant designed to make me better at coding!",

335 "tools": [],

336 "tool_resources": {},

337 "metadata": {},

338 "top_p": 1.0,

339 "temperature": 1.0,

340 "response_format": "auto"

341 },

342 {

343 "id": "asst_abc456",

344 "object": "assistant",

345 "created_at": 1698982718,

346 "name": "My Assistant",

347 "description": null,

348 "model": "gpt-4o",

349 "instructions": "You are a helpful assistant designed to make me better at coding!",

350 "tools": [],

351 "tool_resources": {},

352 "metadata": {},

353 "top_p": 1.0,

354 "temperature": 1.0,

355 "response_format": "auto"

356 },

357 {

358 "id": "asst_abc789",

359 "object": "assistant",

360 "created_at": 1698982643,

361 "name": null,

362 "description": null,

363 "model": "gpt-4o",

364 "instructions": null,

365 "tools": [],

366 "tool_resources": {},

367 "metadata": {},

368 "top_p": 1.0,

369 "temperature": 1.0,

370 "response_format": "auto"

371 }

372 ],

373 "first_id": "asst_abc123",

374 "last_id": "asst_abc789",

375 "has_more": false

376}

377```

resources/beta/subresources/assistants/methods/retrieve/index.md +0 −310 deleted

File Deleted View Diff

1## Retrieve assistant

2 

3**get** `/assistants/{assistant_id}`

4 

5Retrieves an assistant.

6 

7### Path Parameters

8 

9- `assistant_id: string`

10 

11### Returns

12 

13- `Assistant object { id, created_at, description, 10 more }`

14 

15 Represents an `assistant` that can call the model and use tools.

16 

17 - `id: string`

18 

19 The identifier, which can be referenced in API endpoints.

20 

21 - `created_at: number`

22 

23 The Unix timestamp (in seconds) for when the assistant was created.

24 

25 - `description: string or null`

26 

27 The description of the assistant. The maximum length is 512 characters.

28 

29 - `instructions: string or null`

30 

31 The system instructions that the assistant uses. The maximum length is 256,000 characters.

32 

33 - `metadata: Metadata or null`

34 

35 Set of 16 key-value pairs that can be attached to an object. This can be

36 useful for storing additional information about the object in a structured

37 format, and querying for objects via API or the dashboard.

38 

39 Keys are strings with a maximum length of 64 characters. Values are strings

40 with a maximum length of 512 characters.

41 

42 - `model: string`

43 

44 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

45 

46 - `name: string or null`

47 

48 The name of the assistant. The maximum length is 256 characters.

49 

50 - `object: "assistant"`

51 

52 The object type, which is always `assistant`.

53 

54 - `"assistant"`

55 

56 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

57 

58 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

59 

60 - `CodeInterpreterTool object { type }`

61 

62 - `type: "code_interpreter"`

63 

64 The type of tool being defined: `code_interpreter`

65 

66 - `"code_interpreter"`

67 

68 - `FileSearchTool object { type, file_search }`

69 

70 - `type: "file_search"`

71 

72 The type of tool being defined: `file_search`

73 

74 - `"file_search"`

75 

76 - `file_search: optional object { max_num_results, ranking_options }`

77 

78 Overrides for the file search tool.

79 

80 - `max_num_results: optional number`

81 

82 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

83 

84 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

85 

86 - `ranking_options: optional object { score_threshold, ranker }`

87 

88 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

89 

90 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

91 

92 - `score_threshold: number`

93 

94 The score threshold for the file search. All values must be a floating point number between 0 and 1.

95 

96 - `ranker: optional "auto" or "default_2024_08_21"`

97 

98 The ranker to use for the file search. If not specified will use the `auto` ranker.

99 

100 - `"auto"`

101 

102 - `"default_2024_08_21"`

103 

104 - `FunctionTool object { function, type }`

105 

106 - `function: FunctionDefinition`

107 

108 - `name: string`

109 

110 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

111 

112 - `description: optional string`

113 

114 A description of what the function does, used by the model to choose when and how to call the function.

115 

116 - `parameters: optional FunctionParameters`

117 

118 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

119 

120 Omitting `parameters` defines a function with an empty parameter list.

121 

122 - `strict: optional boolean or null`

123 

124 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

125 

126 - `type: "function"`

127 

128 The type of tool being defined: `function`

129 

130 - `"function"`

131 

132 - `response_format: optional AssistantResponseFormatOption or null`

133 

134 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

135 

136 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

137 

138 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

139 

140 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

141 

142 - `"auto"`

143 

144 `auto` is the default value

145 

146 - `"auto"`

147 

148 - `ResponseFormatText object { type }`

149 

150 Default response format. Used to generate text responses.

151 

152 - `type: "text"`

153 

154 The type of response format being defined. Always `text`.

155 

156 - `"text"`

157 

158 - `ResponseFormatJSONObject object { type }`

159 

160 JSON object response format. An older method of generating JSON responses.

161 Using `json_schema` is recommended for models that support it. Note that the

162 model will not generate JSON without a system or user message instructing it

163 to do so.

164 

165 - `type: "json_object"`

166 

167 The type of response format being defined. Always `json_object`.

168 

169 - `"json_object"`

170 

171 - `ResponseFormatJSONSchema object { json_schema, type }`

172 

173 JSON Schema response format. Used to generate structured JSON responses.

174 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

175 

176 - `json_schema: object { name, description, schema, strict }`

177 

178 Structured Outputs configuration options, including a JSON Schema.

179 

180 - `name: string`

181 

182 The name of the response format. Must be a-z, A-Z, 0-9, or contain

183 underscores and dashes, with a maximum length of 64.

184 

185 - `description: optional string`

186 

187 A description of what the response format is for, used by the model to

188 determine how to respond in the format.

189 

190 - `schema: optional map[unknown]`

191 

192 The schema for the response format, described as a JSON Schema object.

193 Learn how to build JSON schemas [here](https://json-schema.org/).

194 

195 - `strict: optional boolean or null`

196 

197 Whether to enable strict schema adherence when generating the output.

198 If set to true, the model will always follow the exact schema defined

199 in the `schema` field. Only a subset of JSON Schema is supported when

200 `strict` is `true`. To learn more, read the [Structured Outputs

201 guide](/docs/guides/structured-outputs).

202 

203 - `type: "json_schema"`

204 

205 The type of response format being defined. Always `json_schema`.

206 

207 - `"json_schema"`

208 

209 - `temperature: optional number or null`

210 

211 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

212 

213 - `tool_resources: optional object { code_interpreter, file_search } or null`

214 

215 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

216 

217 - `code_interpreter: optional object { file_ids }`

218 

219 - `file_ids: optional array of string`

220 

221 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

222 

223 - `file_search: optional object { vector_store_ids }`

224 

225 - `vector_store_ids: optional array of string`

226 

227 The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

228 

229 - `top_p: optional number or null`

230 

231 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

232 

233 We generally recommend altering this or temperature but not both.

234 

235### Example

236 

237```http

238curl https://api.openai.com/v1/assistants/$ASSISTANT_ID \

239 -H 'OpenAI-Beta: assistants=v2' \

240 -H "Authorization: Bearer $OPENAI_API_KEY"

241```

242 

243#### Response

244 

245```json

246{

247 "id": "id",

248 "created_at": 0,

249 "description": "description",

250 "instructions": "instructions",

251 "metadata": {

252 "foo": "string"

253 },

254 "model": "model",

255 "name": "name",

256 "object": "assistant",

257 "tools": [

258 {

259 "type": "code_interpreter"

260 }

261 ],

262 "response_format": "auto",

263 "temperature": 1,

264 "tool_resources": {

265 "code_interpreter": {

266 "file_ids": [

267 "string"

268 ]

269 },

270 "file_search": {

271 "vector_store_ids": [

272 "string"

273 ]

274 }

275 },

276 "top_p": 1

277}

278```

279 

280### Example

281 

282```http

283curl https://api.openai.com/v1/assistants/asst_abc123 \

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

285 -H "Authorization: Bearer $OPENAI_API_KEY" \

286 -H "OpenAI-Beta: assistants=v2"

287```

288 

289#### Response

290 

291```json

292{

293 "id": "asst_abc123",

294 "object": "assistant",

295 "created_at": 1699009709,

296 "name": "HR Helper",

297 "description": null,

298 "model": "gpt-4o",

299 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",

300 "tools": [

301 {

302 "type": "file_search"

303 }

304 ],

305 "metadata": {},

306 "top_p": 1.0,

307 "temperature": 1.0,

308 "response_format": "auto"

309}

310```

resources/beta/subresources/assistants/methods/update/index.md +0 −645 deleted

File Deleted View Diff

1## Modify assistant

2 

3**post** `/assistants/{assistant_id}`

4 

5Modifies an assistant.

6 

7### Path Parameters

8 

9- `assistant_id: string`

10 

11### Body Parameters

12 

13- `description: optional string or null`

14 

15 The description of the assistant. The maximum length is 512 characters.

16 

17- `instructions: optional string or null`

18 

19 The system instructions that the assistant uses. The maximum length is 256,000 characters.

20 

21- `metadata: optional Metadata or null`

22 

23 Set of 16 key-value pairs that can be attached to an object. This can be

24 useful for storing additional information about the object in a structured

25 format, and querying for objects via API or the dashboard.

26 

27 Keys are strings with a maximum length of 64 characters. Values are strings

28 with a maximum length of 512 characters.

29 

30- `model: optional string or "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 39 more`

31 

32 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

33 

34 - `string`

35 

36 - `AssistantSupportedModels = "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 39 more`

37 

38 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

39 

40 - `"gpt-5"`

41 

42 - `"gpt-5-mini"`

43 

44 - `"gpt-5-nano"`

45 

46 - `"gpt-5-2025-08-07"`

47 

48 - `"gpt-5-mini-2025-08-07"`

49 

50 - `"gpt-5-nano-2025-08-07"`

51 

52 - `"gpt-4.1"`

53 

54 - `"gpt-4.1-mini"`

55 

56 - `"gpt-4.1-nano"`

57 

58 - `"gpt-4.1-2025-04-14"`

59 

60 - `"gpt-4.1-mini-2025-04-14"`

61 

62 - `"gpt-4.1-nano-2025-04-14"`

63 

64 - `"o3-mini"`

65 

66 - `"o3-mini-2025-01-31"`

67 

68 - `"o1"`

69 

70 - `"o1-2024-12-17"`

71 

72 - `"gpt-4o"`

73 

74 - `"gpt-4o-2024-11-20"`

75 

76 - `"gpt-4o-2024-08-06"`

77 

78 - `"gpt-4o-2024-05-13"`

79 

80 - `"gpt-4o-mini"`

81 

82 - `"gpt-4o-mini-2024-07-18"`

83 

84 - `"gpt-4.5-preview"`

85 

86 - `"gpt-4.5-preview-2025-02-27"`

87 

88 - `"gpt-4-turbo"`

89 

90 - `"gpt-4-turbo-2024-04-09"`

91 

92 - `"gpt-4-0125-preview"`

93 

94 - `"gpt-4-turbo-preview"`

95 

96 - `"gpt-4-1106-preview"`

97 

98 - `"gpt-4-vision-preview"`

99 

100 - `"gpt-4"`

101 

102 - `"gpt-4-0314"`

103 

104 - `"gpt-4-0613"`

105 

106 - `"gpt-4-32k"`

107 

108 - `"gpt-4-32k-0314"`

109 

110 - `"gpt-4-32k-0613"`

111 

112 - `"gpt-3.5-turbo"`

113 

114 - `"gpt-3.5-turbo-16k"`

115 

116 - `"gpt-3.5-turbo-0613"`

117 

118 - `"gpt-3.5-turbo-1106"`

119 

120 - `"gpt-3.5-turbo-0125"`

121 

122 - `"gpt-3.5-turbo-16k-0613"`

123 

124- `name: optional string or null`

125 

126 The name of the assistant. The maximum length is 256 characters.

127 

128- `reasoning_effort: optional ReasoningEffort or null`

129 

130 Constrains effort on reasoning for reasoning models. Currently supported

131 values are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.

132 Reducing reasoning effort can result in faster responses and fewer tokens

133 used on reasoning in a response. Not all reasoning models support every

134 value. See the

135 [reasoning guide](https://platform.openai.com/docs/guides/reasoning)

136 for model-specific support.

137 

138 - `"none"`

139 

140 - `"minimal"`

141 

142 - `"low"`

143 

144 - `"medium"`

145 

146 - `"high"`

147 

148 - `"xhigh"`

149 

150 - `"max"`

151 

152- `response_format: optional AssistantResponseFormatOption or null`

153 

154 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

155 

156 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

157 

158 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

159 

160 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

161 

162 - `"auto"`

163 

164 `auto` is the default value

165 

166 - `"auto"`

167 

168 - `ResponseFormatText object { type }`

169 

170 Default response format. Used to generate text responses.

171 

172 - `type: "text"`

173 

174 The type of response format being defined. Always `text`.

175 

176 - `"text"`

177 

178 - `ResponseFormatJSONObject object { type }`

179 

180 JSON object response format. An older method of generating JSON responses.

181 Using `json_schema` is recommended for models that support it. Note that the

182 model will not generate JSON without a system or user message instructing it

183 to do so.

184 

185 - `type: "json_object"`

186 

187 The type of response format being defined. Always `json_object`.

188 

189 - `"json_object"`

190 

191 - `ResponseFormatJSONSchema object { json_schema, type }`

192 

193 JSON Schema response format. Used to generate structured JSON responses.

194 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

195 

196 - `json_schema: object { name, description, schema, strict }`

197 

198 Structured Outputs configuration options, including a JSON Schema.

199 

200 - `name: string`

201 

202 The name of the response format. Must be a-z, A-Z, 0-9, or contain

203 underscores and dashes, with a maximum length of 64.

204 

205 - `description: optional string`

206 

207 A description of what the response format is for, used by the model to

208 determine how to respond in the format.

209 

210 - `schema: optional map[unknown]`

211 

212 The schema for the response format, described as a JSON Schema object.

213 Learn how to build JSON schemas [here](https://json-schema.org/).

214 

215 - `strict: optional boolean or null`

216 

217 Whether to enable strict schema adherence when generating the output.

218 If set to true, the model will always follow the exact schema defined

219 in the `schema` field. Only a subset of JSON Schema is supported when

220 `strict` is `true`. To learn more, read the [Structured Outputs

221 guide](/docs/guides/structured-outputs).

222 

223 - `type: "json_schema"`

224 

225 The type of response format being defined. Always `json_schema`.

226 

227 - `"json_schema"`

228 

229- `temperature: optional number or null`

230 

231 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

232 

233- `tool_resources: optional object { code_interpreter, file_search } or null`

234 

235 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

236 

237 - `code_interpreter: optional object { file_ids }`

238 

239 - `file_ids: optional array of string`

240 

241 Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

242 

243 - `file_search: optional object { vector_store_ids }`

244 

245 - `vector_store_ids: optional array of string`

246 

247 Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

248 

249- `tools: optional array of CodeInterpreterTool or FileSearchTool or FunctionTool`

250 

251 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

252 

253 - `CodeInterpreterTool object { type }`

254 

255 - `type: "code_interpreter"`

256 

257 The type of tool being defined: `code_interpreter`

258 

259 - `"code_interpreter"`

260 

261 - `FileSearchTool object { type, file_search }`

262 

263 - `type: "file_search"`

264 

265 The type of tool being defined: `file_search`

266 

267 - `"file_search"`

268 

269 - `file_search: optional object { max_num_results, ranking_options }`

270 

271 Overrides for the file search tool.

272 

273 - `max_num_results: optional number`

274 

275 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

276 

277 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

278 

279 - `ranking_options: optional object { score_threshold, ranker }`

280 

281 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

282 

283 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

284 

285 - `score_threshold: number`

286 

287 The score threshold for the file search. All values must be a floating point number between 0 and 1.

288 

289 - `ranker: optional "auto" or "default_2024_08_21"`

290 

291 The ranker to use for the file search. If not specified will use the `auto` ranker.

292 

293 - `"auto"`

294 

295 - `"default_2024_08_21"`

296 

297 - `FunctionTool object { function, type }`

298 

299 - `function: FunctionDefinition`

300 

301 - `name: string`

302 

303 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

304 

305 - `description: optional string`

306 

307 A description of what the function does, used by the model to choose when and how to call the function.

308 

309 - `parameters: optional FunctionParameters`

310 

311 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

312 

313 Omitting `parameters` defines a function with an empty parameter list.

314 

315 - `strict: optional boolean or null`

316 

317 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

318 

319 - `type: "function"`

320 

321 The type of tool being defined: `function`

322 

323 - `"function"`

324 

325- `top_p: optional number or null`

326 

327 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

328 

329 We generally recommend altering this or temperature but not both.

330 

331### Returns

332 

333- `Assistant object { id, created_at, description, 10 more }`

334 

335 Represents an `assistant` that can call the model and use tools.

336 

337 - `id: string`

338 

339 The identifier, which can be referenced in API endpoints.

340 

341 - `created_at: number`

342 

343 The Unix timestamp (in seconds) for when the assistant was created.

344 

345 - `description: string or null`

346 

347 The description of the assistant. The maximum length is 512 characters.

348 

349 - `instructions: string or null`

350 

351 The system instructions that the assistant uses. The maximum length is 256,000 characters.

352 

353 - `metadata: Metadata or null`

354 

355 Set of 16 key-value pairs that can be attached to an object. This can be

356 useful for storing additional information about the object in a structured

357 format, and querying for objects via API or the dashboard.

358 

359 Keys are strings with a maximum length of 64 characters. Values are strings

360 with a maximum length of 512 characters.

361 

362 - `model: string`

363 

364 ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.

365 

366 - `name: string or null`

367 

368 The name of the assistant. The maximum length is 256 characters.

369 

370 - `object: "assistant"`

371 

372 The object type, which is always `assistant`.

373 

374 - `"assistant"`

375 

376 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

377 

378 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

379 

380 - `CodeInterpreterTool object { type }`

381 

382 - `type: "code_interpreter"`

383 

384 The type of tool being defined: `code_interpreter`

385 

386 - `"code_interpreter"`

387 

388 - `FileSearchTool object { type, file_search }`

389 

390 - `type: "file_search"`

391 

392 The type of tool being defined: `file_search`

393 

394 - `"file_search"`

395 

396 - `file_search: optional object { max_num_results, ranking_options }`

397 

398 Overrides for the file search tool.

399 

400 - `max_num_results: optional number`

401 

402 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

403 

404 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

405 

406 - `ranking_options: optional object { score_threshold, ranker }`

407 

408 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

409 

410 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

411 

412 - `score_threshold: number`

413 

414 The score threshold for the file search. All values must be a floating point number between 0 and 1.

415 

416 - `ranker: optional "auto" or "default_2024_08_21"`

417 

418 The ranker to use for the file search. If not specified will use the `auto` ranker.

419 

420 - `"auto"`

421 

422 - `"default_2024_08_21"`

423 

424 - `FunctionTool object { function, type }`

425 

426 - `function: FunctionDefinition`

427 

428 - `name: string`

429 

430 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

431 

432 - `description: optional string`

433 

434 A description of what the function does, used by the model to choose when and how to call the function.

435 

436 - `parameters: optional FunctionParameters`

437 

438 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

439 

440 Omitting `parameters` defines a function with an empty parameter list.

441 

442 - `strict: optional boolean or null`

443 

444 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

445 

446 - `type: "function"`

447 

448 The type of tool being defined: `function`

449 

450 - `"function"`

451 

452 - `response_format: optional AssistantResponseFormatOption or null`

453 

454 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

455 

456 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

457 

458 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

459 

460 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

461 

462 - `"auto"`

463 

464 `auto` is the default value

465 

466 - `"auto"`

467 

468 - `ResponseFormatText object { type }`

469 

470 Default response format. Used to generate text responses.

471 

472 - `type: "text"`

473 

474 The type of response format being defined. Always `text`.

475 

476 - `"text"`

477 

478 - `ResponseFormatJSONObject object { type }`

479 

480 JSON object response format. An older method of generating JSON responses.

481 Using `json_schema` is recommended for models that support it. Note that the

482 model will not generate JSON without a system or user message instructing it

483 to do so.

484 

485 - `type: "json_object"`

486 

487 The type of response format being defined. Always `json_object`.

488 

489 - `"json_object"`

490 

491 - `ResponseFormatJSONSchema object { json_schema, type }`

492 

493 JSON Schema response format. Used to generate structured JSON responses.

494 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

495 

496 - `json_schema: object { name, description, schema, strict }`

497 

498 Structured Outputs configuration options, including a JSON Schema.

499 

500 - `name: string`

501 

502 The name of the response format. Must be a-z, A-Z, 0-9, or contain

503 underscores and dashes, with a maximum length of 64.

504 

505 - `description: optional string`

506 

507 A description of what the response format is for, used by the model to

508 determine how to respond in the format.

509 

510 - `schema: optional map[unknown]`

511 

512 The schema for the response format, described as a JSON Schema object.

513 Learn how to build JSON schemas [here](https://json-schema.org/).

514 

515 - `strict: optional boolean or null`

516 

517 Whether to enable strict schema adherence when generating the output.

518 If set to true, the model will always follow the exact schema defined

519 in the `schema` field. Only a subset of JSON Schema is supported when

520 `strict` is `true`. To learn more, read the [Structured Outputs

521 guide](/docs/guides/structured-outputs).

522 

523 - `type: "json_schema"`

524 

525 The type of response format being defined. Always `json_schema`.

526 

527 - `"json_schema"`

528 

529 - `temperature: optional number or null`

530 

531 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

532 

533 - `tool_resources: optional object { code_interpreter, file_search } or null`

534 

535 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

536 

537 - `code_interpreter: optional object { file_ids }`

538 

539 - `file_ids: optional array of string`

540 

541 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

542 

543 - `file_search: optional object { vector_store_ids }`

544 

545 - `vector_store_ids: optional array of string`

546 

547 The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

548 

549 - `top_p: optional number or null`

550 

551 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

552 

553 We generally recommend altering this or temperature but not both.

554 

555### Example

556 

557```http

558curl https://api.openai.com/v1/assistants/$ASSISTANT_ID \

559 -H 'Content-Type: application/json' \

560 -H 'OpenAI-Beta: assistants=v2' \

561 -H "Authorization: Bearer $OPENAI_API_KEY" \

562 -d '{

563 "temperature": 1,

564 "top_p": 1

565 }'

566```

567 

568#### Response

569 

570```json

571{

572 "id": "id",

573 "created_at": 0,

574 "description": "description",

575 "instructions": "instructions",

576 "metadata": {

577 "foo": "string"

578 },

579 "model": "model",

580 "name": "name",

581 "object": "assistant",

582 "tools": [

583 {

584 "type": "code_interpreter"

585 }

586 ],

587 "response_format": "auto",

588 "temperature": 1,

589 "tool_resources": {

590 "code_interpreter": {

591 "file_ids": [

592 "string"

593 ]

594 },

595 "file_search": {

596 "vector_store_ids": [

597 "string"

598 ]

599 }

600 },

601 "top_p": 1

602}

603```

604 

605### Example

606 

607```http

608curl https://api.openai.com/v1/assistants/asst_abc123 \

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

610 -H "Authorization: Bearer $OPENAI_API_KEY" \

611 -H "OpenAI-Beta: assistants=v2" \

612 -d '{

613 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",

614 "tools": [{"type": "file_search"}],

615 "model": "gpt-4o"

616 }'

617```

618 

619#### Response

620 

621```json

622{

623 "id": "asst_123",

624 "object": "assistant",

625 "created_at": 1699009709,

626 "name": "HR Helper",

627 "description": null,

628 "model": "gpt-4o",

629 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",

630 "tools": [

631 {

632 "type": "file_search"

633 }

634 ],

635 "tool_resources": {

636 "file_search": {

637 "vector_store_ids": []

638 }

639 },

640 "metadata": {},

641 "top_p": 1.0,

642 "temperature": 1.0,

643 "response_format": "auto"

644}

645```

resources/beta/subresources/assistants/streaming-events.md +0 −44146 deleted

Diff Too Large View Raw
Details

10904 10904 

10905 The total number of tokens used.10905 The total number of tokens used.

10906 10906 

10907 - `compute_units: optional number or null`

10908 

10909 Compute units for the request. Currently null when available.

10910 

10907 - `user: optional string`10911 - `user: optional string`

10908 10912 

10909 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.10913 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.


11087 "output_tokens_details": {11091 "output_tokens_details": {

11088 "reasoning_tokens": 011092 "reasoning_tokens": 0

11089 },11093 },

11090 "total_tokens": 011094 "total_tokens": 0,

11095 "compute_units": 0

11091 },11096 },

11092 "user": "user-1234"11097 "user": "user-1234"

11093}11098}

Details

9968 9968 

9969 The total number of tokens used.9969 The total number of tokens used.

9970 9970 

9971 - `compute_units: optional number or null`

9972 

9973 Compute units for the request. Currently null when available.

9974 

9971### Example9975### Example

9972 9976 

9973```http9977```http


10018 "output_tokens_details": {10022 "output_tokens_details": {

10019 "reasoning_tokens": 010023 "reasoning_tokens": 0

10020 },10024 },

10021 "total_tokens": 010025 "total_tokens": 0,

10026 "compute_units": 0

10022 }10027 }

10023}10028}

10024```10029```

Details

17690 17690 

17691 The total number of tokens used.17691 The total number of tokens used.

17692 17692 

17693 - `compute_units: optional number or null`

17694 

17695 Compute units for the request. Currently null when available.

17696 

17693 - `user: optional string`17697 - `user: optional string`

17694 17698 

17695 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.17699 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.


17881 "output_tokens_details": {17885 "output_tokens_details": {

17882 "reasoning_tokens": 017886 "reasoning_tokens": 0

17883 },17887 },

17884 "total_tokens": 017888 "total_tokens": 0,

17889 "compute_units": 0

17885 },17890 },

17886 "user": "user-1234"17891 "user": "user-1234"

17887}17892}

Details

10948 10948 

10949 The total number of tokens used.10949 The total number of tokens used.

10950 10950 

10951 - `compute_units: optional number or null`

10952 

10953 Compute units for the request. Currently null when available.

10954 

10951 - `user: optional string`10955 - `user: optional string`

10952 10956 

10953 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.10957 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.


11130 "output_tokens_details": {11134 "output_tokens_details": {

11131 "reasoning_tokens": 011135 "reasoning_tokens": 0

11132 },11136 },

11133 "total_tokens": 011137 "total_tokens": 0,

11138 "compute_units": 0

11134 },11139 },

11135 "user": "user-1234"11140 "user": "user-1234"

11136}11141}

resources/beta/subresources/threads/methods/create/index.md +0 −344 deleted

File Deleted View Diff

1## Create thread

2 

3**post** `/threads`

4 

5Create a thread.

6 

7### Body Parameters

8 

9- `messages: optional array of object { content, role, attachments, metadata }`

10 

11 A list of [messages](/docs/api-reference/messages) to start the thread with.

12 

13 - `content: string or array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

14 

15 The text contents of the message.

16 

17 - `TextContent = string`

18 

19 The text contents of the message.

20 

21 - `ArrayOfContentParts = array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

22 

23 An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models).

24 

25 - `ImageFileContentBlock object { image_file, type }`

26 

27 References an image [File](/docs/api-reference/files) in the content of a message.

28 

29 - `image_file: ImageFile`

30 

31 - `file_id: string`

32 

33 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

34 

35 - `detail: optional "auto" or "low" or "high"`

36 

37 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

38 

39 - `"auto"`

40 

41 - `"low"`

42 

43 - `"high"`

44 

45 - `type: "image_file"`

46 

47 Always `image_file`.

48 

49 - `"image_file"`

50 

51 - `ImageURLContentBlock object { image_url, type }`

52 

53 References an image URL in the content of a message.

54 

55 - `image_url: ImageURL`

56 

57 - `url: string`

58 

59 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

60 

61 - `detail: optional "auto" or "low" or "high"`

62 

63 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

64 

65 - `"auto"`

66 

67 - `"low"`

68 

69 - `"high"`

70 

71 - `type: "image_url"`

72 

73 The type of the content part.

74 

75 - `"image_url"`

76 

77 - `TextContentBlockParam object { text, type }`

78 

79 The text content that is part of a message.

80 

81 - `text: string`

82 

83 Text content to be sent to the model

84 

85 - `type: "text"`

86 

87 Always `text`.

88 

89 - `"text"`

90 

91 - `role: "user" or "assistant"`

92 

93 The role of the entity that is creating the message. Allowed values include:

94 

95 - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.

96 - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

97 

98 - `"user"`

99 

100 - `"assistant"`

101 

102 - `attachments: optional array of object { file_id, tools } or null`

103 

104 A list of files attached to the message, and the tools they should be added to.

105 

106 - `file_id: optional string`

107 

108 The ID of the file to attach to the message.

109 

110 - `tools: optional array of CodeInterpreterTool or object { type }`

111 

112 The tools to add this file to.

113 

114 - `CodeInterpreterTool object { type }`

115 

116 - `type: "code_interpreter"`

117 

118 The type of tool being defined: `code_interpreter`

119 

120 - `"code_interpreter"`

121 

122 - `FileSearchTool object { type }`

123 

124 - `type: "file_search"`

125 

126 The type of tool being defined: `file_search`

127 

128 - `"file_search"`

129 

130 - `metadata: optional Metadata or null`

131 

132 Set of 16 key-value pairs that can be attached to an object. This can be

133 useful for storing additional information about the object in a structured

134 format, and querying for objects via API or the dashboard.

135 

136 Keys are strings with a maximum length of 64 characters. Values are strings

137 with a maximum length of 512 characters.

138 

139- `metadata: optional Metadata or null`

140 

141 Set of 16 key-value pairs that can be attached to an object. This can be

142 useful for storing additional information about the object in a structured

143 format, and querying for objects via API or the dashboard.

144 

145 Keys are strings with a maximum length of 64 characters. Values are strings

146 with a maximum length of 512 characters.

147 

148- `tool_resources: optional object { code_interpreter, file_search } or null`

149 

150 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

151 

152 - `code_interpreter: optional object { file_ids }`

153 

154 - `file_ids: optional array of string`

155 

156 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

157 

158 - `file_search: optional object { vector_store_ids, vector_stores }`

159 

160 - `vector_store_ids: optional array of string`

161 

162 The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

163 

164 - `vector_stores: optional array of object { chunking_strategy, file_ids, metadata }`

165 

166 A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.

167 

168 - `chunking_strategy: optional object { type } or object { static, type }`

169 

170 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.

171 

172 - `Auto object { type }`

173 

174 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

175 

176 - `type: "auto"`

177 

178 Always `auto`.

179 

180 - `"auto"`

181 

182 - `Static object { static, type }`

183 

184 - `static: object { chunk_overlap_tokens, max_chunk_size_tokens }`

185 

186 - `chunk_overlap_tokens: number`

187 

188 The number of tokens that overlap between chunks. The default value is `400`.

189 

190 Note that the overlap must not exceed half of `max_chunk_size_tokens`.

191 

192 - `max_chunk_size_tokens: number`

193 

194 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.

195 

196 - `type: "static"`

197 

198 Always `static`.

199 

200 - `"static"`

201 

202 - `file_ids: optional array of string`

203 

204 A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.

205 

206 - `metadata: optional Metadata or null`

207 

208 Set of 16 key-value pairs that can be attached to an object. This can be

209 useful for storing additional information about the object in a structured

210 format, and querying for objects via API or the dashboard.

211 

212 Keys are strings with a maximum length of 64 characters. Values are strings

213 with a maximum length of 512 characters.

214 

215### Returns

216 

217- `Thread object { id, created_at, metadata, 2 more }`

218 

219 Represents a thread that contains [messages](/docs/api-reference/messages).

220 

221 - `id: string`

222 

223 The identifier, which can be referenced in API endpoints.

224 

225 - `created_at: number`

226 

227 The Unix timestamp (in seconds) for when the thread was created.

228 

229 - `metadata: Metadata or null`

230 

231 Set of 16 key-value pairs that can be attached to an object. This can be

232 useful for storing additional information about the object in a structured

233 format, and querying for objects via API or the dashboard.

234 

235 Keys are strings with a maximum length of 64 characters. Values are strings

236 with a maximum length of 512 characters.

237 

238 - `object: "thread"`

239 

240 The object type, which is always `thread`.

241 

242 - `"thread"`

243 

244 - `tool_resources: object { code_interpreter, file_search } or null`

245 

246 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

247 

248 - `code_interpreter: optional object { file_ids }`

249 

250 - `file_ids: optional array of string`

251 

252 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

253 

254 - `file_search: optional object { vector_store_ids }`

255 

256 - `vector_store_ids: optional array of string`

257 

258 The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

259 

260### Example

261 

262```http

263curl https://api.openai.com/v1/threads \

264 -X POST \

265 -H 'OpenAI-Beta: assistants=v2' \

266 -H "Authorization: Bearer $OPENAI_API_KEY"

267```

268 

269#### Response

270 

271```json

272{

273 "id": "id",

274 "created_at": 0,

275 "metadata": {

276 "foo": "string"

277 },

278 "object": "thread",

279 "tool_resources": {

280 "code_interpreter": {

281 "file_ids": [

282 "string"

283 ]

284 },

285 "file_search": {

286 "vector_store_ids": [

287 "string"

288 ]

289 }

290 }

291}

292```

293 

294### Empty

295 

296```http

297curl https://api.openai.com/v1/threads \

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

299 -H "Authorization: Bearer $OPENAI_API_KEY" \

300 -H "OpenAI-Beta: assistants=v2" \

301 -d ''

302```

303 

304#### Response

305 

306```json

307{

308 "id": "thread_abc123",

309 "object": "thread",

310 "created_at": 1699012949,

311 "metadata": {},

312 "tool_resources": {}

313}

314```

315 

316### Messages

317 

318```http

319curl https://api.openai.com/v1/threads \

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

321-H "Authorization: Bearer $OPENAI_API_KEY" \

322-H "OpenAI-Beta: assistants=v2" \

323-d '{

324 "messages": [{

325 "role": "user",

326 "content": "Hello, what is AI?"

327 }, {

328 "role": "user",

329 "content": "How does AI work? Explain it in simple terms."

330 }]

331 }'

332```

333 

334#### Response

335 

336```json

337{

338 "id": "thread_abc123",

339 "object": "thread",

340 "created_at": 1699014083,

341 "metadata": {},

342 "tool_resources": {}

343}

344```

resources/beta/subresources/threads/methods/create_and_run/index.md +0 −1254 deleted

File Deleted View Diff

1## Create thread and run

2 

3**post** `/threads/runs`

4 

5Create a thread and run it in one request.

6 

7### Body Parameters

8 

9- `assistant_id: string`

10 

11 The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.

12 

13- `instructions: optional string or null`

14 

15 Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.

16 

17- `max_completion_tokens: optional number or null`

18 

19 The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

20 

21- `max_prompt_tokens: optional number or null`

22 

23 The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

24 

25- `metadata: optional Metadata or null`

26 

27 Set of 16 key-value pairs that can be attached to an object. This can be

28 useful for storing additional information about the object in a structured

29 format, and querying for objects via API or the dashboard.

30 

31 Keys are strings with a maximum length of 64 characters. Values are strings

32 with a maximum length of 512 characters.

33 

34- `model: optional string or "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 35 more or null`

35 

36 The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

37 

38 - `string`

39 

40 - `"gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 35 more`

41 

42 The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

43 

44 - `"gpt-5"`

45 

46 - `"gpt-5-mini"`

47 

48 - `"gpt-5-nano"`

49 

50 - `"gpt-5-2025-08-07"`

51 

52 - `"gpt-5-mini-2025-08-07"`

53 

54 - `"gpt-5-nano-2025-08-07"`

55 

56 - `"gpt-4.1"`

57 

58 - `"gpt-4.1-mini"`

59 

60 - `"gpt-4.1-nano"`

61 

62 - `"gpt-4.1-2025-04-14"`

63 

64 - `"gpt-4.1-mini-2025-04-14"`

65 

66 - `"gpt-4.1-nano-2025-04-14"`

67 

68 - `"gpt-4o"`

69 

70 - `"gpt-4o-2024-11-20"`

71 

72 - `"gpt-4o-2024-08-06"`

73 

74 - `"gpt-4o-2024-05-13"`

75 

76 - `"gpt-4o-mini"`

77 

78 - `"gpt-4o-mini-2024-07-18"`

79 

80 - `"gpt-4.5-preview"`

81 

82 - `"gpt-4.5-preview-2025-02-27"`

83 

84 - `"gpt-4-turbo"`

85 

86 - `"gpt-4-turbo-2024-04-09"`

87 

88 - `"gpt-4-0125-preview"`

89 

90 - `"gpt-4-turbo-preview"`

91 

92 - `"gpt-4-1106-preview"`

93 

94 - `"gpt-4-vision-preview"`

95 

96 - `"gpt-4"`

97 

98 - `"gpt-4-0314"`

99 

100 - `"gpt-4-0613"`

101 

102 - `"gpt-4-32k"`

103 

104 - `"gpt-4-32k-0314"`

105 

106 - `"gpt-4-32k-0613"`

107 

108 - `"gpt-3.5-turbo"`

109 

110 - `"gpt-3.5-turbo-16k"`

111 

112 - `"gpt-3.5-turbo-0613"`

113 

114 - `"gpt-3.5-turbo-1106"`

115 

116 - `"gpt-3.5-turbo-0125"`

117 

118 - `"gpt-3.5-turbo-16k-0613"`

119 

120- `parallel_tool_calls: optional boolean`

121 

122 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

123 

124- `response_format: optional AssistantResponseFormatOption or null`

125 

126 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

127 

128 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

129 

130 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

131 

132 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

133 

134 - `"auto"`

135 

136 `auto` is the default value

137 

138 - `"auto"`

139 

140 - `ResponseFormatText object { type }`

141 

142 Default response format. Used to generate text responses.

143 

144 - `type: "text"`

145 

146 The type of response format being defined. Always `text`.

147 

148 - `"text"`

149 

150 - `ResponseFormatJSONObject object { type }`

151 

152 JSON object response format. An older method of generating JSON responses.

153 Using `json_schema` is recommended for models that support it. Note that the

154 model will not generate JSON without a system or user message instructing it

155 to do so.

156 

157 - `type: "json_object"`

158 

159 The type of response format being defined. Always `json_object`.

160 

161 - `"json_object"`

162 

163 - `ResponseFormatJSONSchema object { json_schema, type }`

164 

165 JSON Schema response format. Used to generate structured JSON responses.

166 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

167 

168 - `json_schema: object { name, description, schema, strict }`

169 

170 Structured Outputs configuration options, including a JSON Schema.

171 

172 - `name: string`

173 

174 The name of the response format. Must be a-z, A-Z, 0-9, or contain

175 underscores and dashes, with a maximum length of 64.

176 

177 - `description: optional string`

178 

179 A description of what the response format is for, used by the model to

180 determine how to respond in the format.

181 

182 - `schema: optional map[unknown]`

183 

184 The schema for the response format, described as a JSON Schema object.

185 Learn how to build JSON schemas [here](https://json-schema.org/).

186 

187 - `strict: optional boolean or null`

188 

189 Whether to enable strict schema adherence when generating the output.

190 If set to true, the model will always follow the exact schema defined

191 in the `schema` field. Only a subset of JSON Schema is supported when

192 `strict` is `true`. To learn more, read the [Structured Outputs

193 guide](/docs/guides/structured-outputs).

194 

195 - `type: "json_schema"`

196 

197 The type of response format being defined. Always `json_schema`.

198 

199 - `"json_schema"`

200 

201- `stream: optional boolean or null`

202 

203 If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.

204 

205- `temperature: optional number or null`

206 

207 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

208 

209- `thread: optional object { messages, metadata, tool_resources }`

210 

211 Options to create a new thread. If no thread is provided when running a

212 request, an empty thread will be created.

213 

214 - `messages: optional array of object { content, role, attachments, metadata }`

215 

216 A list of [messages](/docs/api-reference/messages) to start the thread with.

217 

218 - `content: string or array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

219 

220 The text contents of the message.

221 

222 - `TextContent = string`

223 

224 The text contents of the message.

225 

226 - `ArrayOfContentParts = array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

227 

228 An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models).

229 

230 - `ImageFileContentBlock object { image_file, type }`

231 

232 References an image [File](/docs/api-reference/files) in the content of a message.

233 

234 - `image_file: ImageFile`

235 

236 - `file_id: string`

237 

238 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

239 

240 - `detail: optional "auto" or "low" or "high"`

241 

242 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

243 

244 - `"auto"`

245 

246 - `"low"`

247 

248 - `"high"`

249 

250 - `type: "image_file"`

251 

252 Always `image_file`.

253 

254 - `"image_file"`

255 

256 - `ImageURLContentBlock object { image_url, type }`

257 

258 References an image URL in the content of a message.

259 

260 - `image_url: ImageURL`

261 

262 - `url: string`

263 

264 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

265 

266 - `detail: optional "auto" or "low" or "high"`

267 

268 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

269 

270 - `"auto"`

271 

272 - `"low"`

273 

274 - `"high"`

275 

276 - `type: "image_url"`

277 

278 The type of the content part.

279 

280 - `"image_url"`

281 

282 - `TextContentBlockParam object { text, type }`

283 

284 The text content that is part of a message.

285 

286 - `text: string`

287 

288 Text content to be sent to the model

289 

290 - `type: "text"`

291 

292 Always `text`.

293 

294 - `"text"`

295 

296 - `role: "user" or "assistant"`

297 

298 The role of the entity that is creating the message. Allowed values include:

299 

300 - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.

301 - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

302 

303 - `"user"`

304 

305 - `"assistant"`

306 

307 - `attachments: optional array of object { file_id, tools } or null`

308 

309 A list of files attached to the message, and the tools they should be added to.

310 

311 - `file_id: optional string`

312 

313 The ID of the file to attach to the message.

314 

315 - `tools: optional array of CodeInterpreterTool or object { type }`

316 

317 The tools to add this file to.

318 

319 - `CodeInterpreterTool object { type }`

320 

321 - `type: "code_interpreter"`

322 

323 The type of tool being defined: `code_interpreter`

324 

325 - `"code_interpreter"`

326 

327 - `FileSearchTool object { type }`

328 

329 - `type: "file_search"`

330 

331 The type of tool being defined: `file_search`

332 

333 - `"file_search"`

334 

335 - `metadata: optional Metadata or null`

336 

337 Set of 16 key-value pairs that can be attached to an object. This can be

338 useful for storing additional information about the object in a structured

339 format, and querying for objects via API or the dashboard.

340 

341 Keys are strings with a maximum length of 64 characters. Values are strings

342 with a maximum length of 512 characters.

343 

344 - `metadata: optional Metadata or null`

345 

346 Set of 16 key-value pairs that can be attached to an object. This can be

347 useful for storing additional information about the object in a structured

348 format, and querying for objects via API or the dashboard.

349 

350 Keys are strings with a maximum length of 64 characters. Values are strings

351 with a maximum length of 512 characters.

352 

353 - `tool_resources: optional object { code_interpreter, file_search } or null`

354 

355 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

356 

357 - `code_interpreter: optional object { file_ids }`

358 

359 - `file_ids: optional array of string`

360 

361 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

362 

363 - `file_search: optional object { vector_store_ids, vector_stores }`

364 

365 - `vector_store_ids: optional array of string`

366 

367 The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

368 

369 - `vector_stores: optional array of object { chunking_strategy, file_ids, metadata }`

370 

371 A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.

372 

373 - `chunking_strategy: optional object { type } or object { static, type }`

374 

375 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.

376 

377 - `Auto object { type }`

378 

379 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

380 

381 - `type: "auto"`

382 

383 Always `auto`.

384 

385 - `"auto"`

386 

387 - `Static object { static, type }`

388 

389 - `static: object { chunk_overlap_tokens, max_chunk_size_tokens }`

390 

391 - `chunk_overlap_tokens: number`

392 

393 The number of tokens that overlap between chunks. The default value is `400`.

394 

395 Note that the overlap must not exceed half of `max_chunk_size_tokens`.

396 

397 - `max_chunk_size_tokens: number`

398 

399 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.

400 

401 - `type: "static"`

402 

403 Always `static`.

404 

405 - `"static"`

406 

407 - `file_ids: optional array of string`

408 

409 A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.

410 

411 - `metadata: optional Metadata or null`

412 

413 Set of 16 key-value pairs that can be attached to an object. This can be

414 useful for storing additional information about the object in a structured

415 format, and querying for objects via API or the dashboard.

416 

417 Keys are strings with a maximum length of 64 characters. Values are strings

418 with a maximum length of 512 characters.

419 

420- `tool_choice: optional AssistantToolChoiceOption or null`

421 

422 Controls which (if any) tool is called by the model.

423 `none` means the model will not call any tools and instead generates a message.

424 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

425 `required` means the model must call one or more tools before responding to the user.

426 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

427 

428 - `"none" or "auto" or "required"`

429 

430 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

431 

432 - `"none"`

433 

434 - `"auto"`

435 

436 - `"required"`

437 

438 - `AssistantToolChoice object { type, function }`

439 

440 Specifies a tool the model should use. Use to force the model to call a specific tool.

441 

442 - `type: "function" or "code_interpreter" or "file_search"`

443 

444 The type of the tool. If type is `function`, the function name must be set

445 

446 - `"function"`

447 

448 - `"code_interpreter"`

449 

450 - `"file_search"`

451 

452 - `function: optional AssistantToolChoiceFunction`

453 

454 - `name: string`

455 

456 The name of the function to call.

457 

458- `tool_resources: optional object { code_interpreter, file_search } or null`

459 

460 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

461 

462 - `code_interpreter: optional object { file_ids }`

463 

464 - `file_ids: optional array of string`

465 

466 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

467 

468 - `file_search: optional object { vector_store_ids }`

469 

470 - `vector_store_ids: optional array of string`

471 

472 The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

473 

474- `tools: optional array of CodeInterpreterTool or FileSearchTool or FunctionTool or null`

475 

476 Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.

477 

478 - `CodeInterpreterTool object { type }`

479 

480 - `FileSearchTool object { type, file_search }`

481 

482 - `type: "file_search"`

483 

484 The type of tool being defined: `file_search`

485 

486 - `"file_search"`

487 

488 - `file_search: optional object { max_num_results, ranking_options }`

489 

490 Overrides for the file search tool.

491 

492 - `max_num_results: optional number`

493 

494 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

495 

496 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

497 

498 - `ranking_options: optional object { score_threshold, ranker }`

499 

500 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

501 

502 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

503 

504 - `score_threshold: number`

505 

506 The score threshold for the file search. All values must be a floating point number between 0 and 1.

507 

508 - `ranker: optional "auto" or "default_2024_08_21"`

509 

510 The ranker to use for the file search. If not specified will use the `auto` ranker.

511 

512 - `"auto"`

513 

514 - `"default_2024_08_21"`

515 

516 - `FunctionTool object { function, type }`

517 

518 - `function: FunctionDefinition`

519 

520 - `name: string`

521 

522 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

523 

524 - `description: optional string`

525 

526 A description of what the function does, used by the model to choose when and how to call the function.

527 

528 - `parameters: optional FunctionParameters`

529 

530 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

531 

532 Omitting `parameters` defines a function with an empty parameter list.

533 

534 - `strict: optional boolean or null`

535 

536 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

537 

538 - `type: "function"`

539 

540 The type of tool being defined: `function`

541 

542 - `"function"`

543 

544- `top_p: optional number or null`

545 

546 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

547 

548 We generally recommend altering this or temperature but not both.

549 

550- `truncation_strategy: optional object { type, last_messages } or null`

551 

552 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

553 

554 - `type: "auto" or "last_messages"`

555 

556 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

557 

558 - `"auto"`

559 

560 - `"last_messages"`

561 

562 - `last_messages: optional number or null`

563 

564 The number of most recent messages from the thread when constructing the context for the run.

565 

566### Returns

567 

568- `Run object { id, assistant_id, cancelled_at, 24 more }`

569 

570 Represents an execution run on a [thread](/docs/api-reference/threads).

571 

572 - `id: string`

573 

574 The identifier, which can be referenced in API endpoints.

575 

576 - `assistant_id: string`

577 

578 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

579 

580 - `cancelled_at: number or null`

581 

582 The Unix timestamp (in seconds) for when the run was cancelled.

583 

584 - `completed_at: number or null`

585 

586 The Unix timestamp (in seconds) for when the run was completed.

587 

588 - `created_at: number`

589 

590 The Unix timestamp (in seconds) for when the run was created.

591 

592 - `expires_at: number or null`

593 

594 The Unix timestamp (in seconds) for when the run will expire.

595 

596 - `failed_at: number or null`

597 

598 The Unix timestamp (in seconds) for when the run failed.

599 

600 - `incomplete_details: object { reason } or null`

601 

602 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

603 

604 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

605 

606 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

607 

608 - `"max_completion_tokens"`

609 

610 - `"max_prompt_tokens"`

611 

612 - `instructions: string`

613 

614 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

615 

616 - `last_error: object { code, message } or null`

617 

618 The last error associated with this run. Will be `null` if there are no errors.

619 

620 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

621 

622 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

623 

624 - `"server_error"`

625 

626 - `"rate_limit_exceeded"`

627 

628 - `"invalid_prompt"`

629 

630 - `message: string`

631 

632 A human-readable description of the error.

633 

634 - `max_completion_tokens: number or null`

635 

636 The maximum number of completion tokens specified to have been used over the course of the run.

637 

638 - `max_prompt_tokens: number or null`

639 

640 The maximum number of prompt tokens specified to have been used over the course of the run.

641 

642 - `metadata: Metadata or null`

643 

644 Set of 16 key-value pairs that can be attached to an object. This can be

645 useful for storing additional information about the object in a structured

646 format, and querying for objects via API or the dashboard.

647 

648 Keys are strings with a maximum length of 64 characters. Values are strings

649 with a maximum length of 512 characters.

650 

651 - `model: string`

652 

653 The model that the [assistant](/docs/api-reference/assistants) used for this run.

654 

655 - `object: "thread.run"`

656 

657 The object type, which is always `thread.run`.

658 

659 - `"thread.run"`

660 

661 - `parallel_tool_calls: boolean`

662 

663 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

664 

665 - `required_action: object { submit_tool_outputs, type } or null`

666 

667 Details on the action required to continue the run. Will be `null` if no action is required.

668 

669 - `submit_tool_outputs: object { tool_calls }`

670 

671 Details on the tool outputs needed for this run to continue.

672 

673 - `tool_calls: array of RequiredActionFunctionToolCall`

674 

675 A list of the relevant tool calls.

676 

677 - `id: string`

678 

679 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

680 

681 - `function: object { arguments, name }`

682 

683 The function definition.

684 

685 - `arguments: string`

686 

687 The arguments that the model expects you to pass to the function.

688 

689 - `name: string`

690 

691 The name of the function.

692 

693 - `type: "function"`

694 

695 The type of tool call the output is required for. For now, this is always `function`.

696 

697 - `"function"`

698 

699 - `type: "submit_tool_outputs"`

700 

701 For now, this is always `submit_tool_outputs`.

702 

703 - `"submit_tool_outputs"`

704 

705 - `response_format: AssistantResponseFormatOption or null`

706 

707 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

708 

709 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

710 

711 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

712 

713 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

714 

715 - `"auto"`

716 

717 `auto` is the default value

718 

719 - `"auto"`

720 

721 - `ResponseFormatText object { type }`

722 

723 Default response format. Used to generate text responses.

724 

725 - `type: "text"`

726 

727 The type of response format being defined. Always `text`.

728 

729 - `"text"`

730 

731 - `ResponseFormatJSONObject object { type }`

732 

733 JSON object response format. An older method of generating JSON responses.

734 Using `json_schema` is recommended for models that support it. Note that the

735 model will not generate JSON without a system or user message instructing it

736 to do so.

737 

738 - `type: "json_object"`

739 

740 The type of response format being defined. Always `json_object`.

741 

742 - `"json_object"`

743 

744 - `ResponseFormatJSONSchema object { json_schema, type }`

745 

746 JSON Schema response format. Used to generate structured JSON responses.

747 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

748 

749 - `json_schema: object { name, description, schema, strict }`

750 

751 Structured Outputs configuration options, including a JSON Schema.

752 

753 - `name: string`

754 

755 The name of the response format. Must be a-z, A-Z, 0-9, or contain

756 underscores and dashes, with a maximum length of 64.

757 

758 - `description: optional string`

759 

760 A description of what the response format is for, used by the model to

761 determine how to respond in the format.

762 

763 - `schema: optional map[unknown]`

764 

765 The schema for the response format, described as a JSON Schema object.

766 Learn how to build JSON schemas [here](https://json-schema.org/).

767 

768 - `strict: optional boolean or null`

769 

770 Whether to enable strict schema adherence when generating the output.

771 If set to true, the model will always follow the exact schema defined

772 in the `schema` field. Only a subset of JSON Schema is supported when

773 `strict` is `true`. To learn more, read the [Structured Outputs

774 guide](/docs/guides/structured-outputs).

775 

776 - `type: "json_schema"`

777 

778 The type of response format being defined. Always `json_schema`.

779 

780 - `"json_schema"`

781 

782 - `started_at: number or null`

783 

784 The Unix timestamp (in seconds) for when the run was started.

785 

786 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

787 

788 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

789 

790 - `"queued"`

791 

792 - `"in_progress"`

793 

794 - `"requires_action"`

795 

796 - `"cancelling"`

797 

798 - `"cancelled"`

799 

800 - `"failed"`

801 

802 - `"completed"`

803 

804 - `"incomplete"`

805 

806 - `"expired"`

807 

808 - `thread_id: string`

809 

810 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

811 

812 - `tool_choice: AssistantToolChoiceOption or null`

813 

814 Controls which (if any) tool is called by the model.

815 `none` means the model will not call any tools and instead generates a message.

816 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

817 `required` means the model must call one or more tools before responding to the user.

818 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

819 

820 - `"none" or "auto" or "required"`

821 

822 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

823 

824 - `"none"`

825 

826 - `"auto"`

827 

828 - `"required"`

829 

830 - `AssistantToolChoice object { type, function }`

831 

832 Specifies a tool the model should use. Use to force the model to call a specific tool.

833 

834 - `type: "function" or "code_interpreter" or "file_search"`

835 

836 The type of the tool. If type is `function`, the function name must be set

837 

838 - `"function"`

839 

840 - `"code_interpreter"`

841 

842 - `"file_search"`

843 

844 - `function: optional AssistantToolChoiceFunction`

845 

846 - `name: string`

847 

848 The name of the function to call.

849 

850 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

851 

852 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

853 

854 - `CodeInterpreterTool object { type }`

855 

856 - `type: "code_interpreter"`

857 

858 The type of tool being defined: `code_interpreter`

859 

860 - `"code_interpreter"`

861 

862 - `FileSearchTool object { type, file_search }`

863 

864 - `type: "file_search"`

865 

866 The type of tool being defined: `file_search`

867 

868 - `"file_search"`

869 

870 - `file_search: optional object { max_num_results, ranking_options }`

871 

872 Overrides for the file search tool.

873 

874 - `max_num_results: optional number`

875 

876 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

877 

878 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

879 

880 - `ranking_options: optional object { score_threshold, ranker }`

881 

882 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

883 

884 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

885 

886 - `score_threshold: number`

887 

888 The score threshold for the file search. All values must be a floating point number between 0 and 1.

889 

890 - `ranker: optional "auto" or "default_2024_08_21"`

891 

892 The ranker to use for the file search. If not specified will use the `auto` ranker.

893 

894 - `"auto"`

895 

896 - `"default_2024_08_21"`

897 

898 - `FunctionTool object { function, type }`

899 

900 - `function: FunctionDefinition`

901 

902 - `name: string`

903 

904 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

905 

906 - `description: optional string`

907 

908 A description of what the function does, used by the model to choose when and how to call the function.

909 

910 - `parameters: optional FunctionParameters`

911 

912 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

913 

914 Omitting `parameters` defines a function with an empty parameter list.

915 

916 - `strict: optional boolean or null`

917 

918 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

919 

920 - `type: "function"`

921 

922 The type of tool being defined: `function`

923 

924 - `"function"`

925 

926 - `truncation_strategy: object { type, last_messages } or null`

927 

928 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

929 

930 - `type: "auto" or "last_messages"`

931 

932 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

933 

934 - `"auto"`

935 

936 - `"last_messages"`

937 

938 - `last_messages: optional number or null`

939 

940 The number of most recent messages from the thread when constructing the context for the run.

941 

942 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

943 

944 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

945 

946 - `completion_tokens: number`

947 

948 Number of completion tokens used over the course of the run.

949 

950 - `prompt_tokens: number`

951 

952 Number of prompt tokens used over the course of the run.

953 

954 - `total_tokens: number`

955 

956 Total number of tokens used (prompt + completion).

957 

958 - `temperature: optional number or null`

959 

960 The sampling temperature used for this run. If not set, defaults to 1.

961 

962 - `top_p: optional number or null`

963 

964 The nucleus sampling value used for this run. If not set, defaults to 1.

965 

966### Example

967 

968```http

969curl https://api.openai.com/v1/threads/runs \

970 -H 'Content-Type: application/json' \

971 -H 'OpenAI-Beta: assistants=v2' \

972 -H "Authorization: Bearer $OPENAI_API_KEY" \

973 -d '{

974 "assistant_id": "assistant_id",

975 "temperature": 1,

976 "top_p": 1

977 }'

978```

979 

980#### Response

981 

982```json

983{

984 "id": "id",

985 "assistant_id": "assistant_id",

986 "cancelled_at": 0,

987 "completed_at": 0,

988 "created_at": 0,

989 "expires_at": 0,

990 "failed_at": 0,

991 "incomplete_details": {

992 "reason": "max_completion_tokens"

993 },

994 "instructions": "instructions",

995 "last_error": {

996 "code": "server_error",

997 "message": "message"

998 },

999 "max_completion_tokens": 256,

1000 "max_prompt_tokens": 256,

1001 "metadata": {

1002 "foo": "string"

1003 },

1004 "model": "model",

1005 "object": "thread.run",

1006 "parallel_tool_calls": true,

1007 "required_action": {

1008 "submit_tool_outputs": {

1009 "tool_calls": [

1010 {

1011 "id": "id",

1012 "function": {

1013 "arguments": "arguments",

1014 "name": "name"

1015 },

1016 "type": "function"

1017 }

1018 ]

1019 },

1020 "type": "submit_tool_outputs"

1021 },

1022 "response_format": "auto",

1023 "started_at": 0,

1024 "status": "queued",

1025 "thread_id": "thread_id",

1026 "tool_choice": "none",

1027 "tools": [

1028 {

1029 "type": "code_interpreter"

1030 }

1031 ],

1032 "truncation_strategy": {

1033 "type": "auto",

1034 "last_messages": 1

1035 },

1036 "usage": {

1037 "completion_tokens": 0,

1038 "prompt_tokens": 0,

1039 "total_tokens": 0

1040 },

1041 "temperature": 0,

1042 "top_p": 0

1043}

1044```

1045 

1046### Example

1047 

1048```http

1049curl https://api.openai.com/v1/threads/runs \

1050 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

1052 -H "OpenAI-Beta: assistants=v2" \

1053 -d '{

1054 "assistant_id": "asst_abc123",

1055 "thread": {

1056 "messages": [

1057 {"role": "user", "content": "Explain deep learning to a 5 year old."}

1058 ]

1059 }

1060 }'

1061```

1062 

1063#### Response

1064 

1065```json

1066{

1067 "id": "run_abc123",

1068 "object": "thread.run",

1069 "created_at": 1699076792,

1070 "assistant_id": "asst_abc123",

1071 "thread_id": "thread_abc123",

1072 "status": "queued",

1073 "started_at": null,

1074 "expires_at": 1699077392,

1075 "cancelled_at": null,

1076 "failed_at": null,

1077 "completed_at": null,

1078 "required_action": null,

1079 "last_error": null,

1080 "model": "gpt-4o",

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

1082 "tools": [],

1083 "tool_resources": {},

1084 "metadata": {},

1085 "temperature": 1.0,

1086 "top_p": 1.0,

1087 "max_completion_tokens": null,

1088 "max_prompt_tokens": null,

1089 "truncation_strategy": {

1090 "type": "auto",

1091 "last_messages": null

1092 },

1093 "incomplete_details": null,

1094 "usage": null,

1095 "response_format": "auto",

1096 "tool_choice": "auto",

1097 "parallel_tool_calls": true

1098}

1099```

1100 

1101### Streaming

1102 

1103```http

1104curl https://api.openai.com/v1/threads/runs \

1105 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

1107 -H "OpenAI-Beta: assistants=v2" \

1108 -d '{

1109 "assistant_id": "asst_123",

1110 "thread": {

1111 "messages": [

1112 {"role": "user", "content": "Hello"}

1113 ]

1114 },

1115 "stream": true

1116 }'

1117```

1118 

1119#### Response

1120 

1121```json

1122event: thread.created

1123data: {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}}

1124 

1125event: thread.run.created

1126data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}

1127 

1128event: thread.run.queued

1129data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}

1130 

1131event: thread.run.in_progress

1132data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}

1133 

1134event: thread.run.step.created

1135data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

1136 

1137event: thread.run.step.in_progress

1138data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

1139 

1140event: thread.message.created

1141data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}}

1142 

1143event: thread.message.in_progress

1144data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}}

1145 

1146event: thread.message.delta

1147data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}}

1148 

1149...

1150 

1151event: thread.message.delta

1152data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}}

1153 

1154event: thread.message.delta

1155data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}}

1156 

1157event: thread.message.completed

1158data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}], "metadata":{}}

1159 

1160event: thread.run.step.completed

1161data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}}

1162 

1163event: thread.run.completed

1164{"id":"run_123","object":"thread.run","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1713226836,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1713226837,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}

1165 

1166event: done

1167data: [DONE]

1168```

1169 

1170### Streaming with Functions

1171 

1172```http

1173curl https://api.openai.com/v1/threads/runs \

1174 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

1176 -H "OpenAI-Beta: assistants=v2" \

1177 -d '{

1178 "assistant_id": "asst_abc123",

1179 "thread": {

1180 "messages": [

1181 {"role": "user", "content": "What is the weather like in San Francisco?"}

1182 ]

1183 },

1184 "tools": [

1185 {

1186 "type": "function",

1187 "function": {

1188 "name": "get_current_weather",

1189 "description": "Get the current weather in a given location",

1190 "parameters": {

1191 "type": "object",

1192 "properties": {

1193 "location": {

1194 "type": "string",

1195 "description": "The city and state, e.g. San Francisco, CA"

1196 },

1197 "unit": {

1198 "type": "string",

1199 "enum": ["celsius", "fahrenheit"]

1200 }

1201 },

1202 "required": ["location"]

1203 }

1204 }

1205 }

1206 ],

1207 "stream": true

1208 }'

1209```

1210 

1211#### Response

1212 

1213```json

1214event: thread.created

1215data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}}

1216 

1217event: thread.run.created

1218data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1219 

1220event: thread.run.queued

1221data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1222 

1223event: thread.run.in_progress

1224data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1225 

1226event: thread.run.step.created

1227data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null}

1228 

1229event: thread.run.step.in_progress

1230data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null}

1231 

1232event: thread.run.step.delta

1233data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}}

1234 

1235event: thread.run.step.delta

1236data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}}

1237 

1238event: thread.run.step.delta

1239data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}}

1240 

1241...

1242 

1243event: thread.run.step.delta

1244data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}}

1245 

1246event: thread.run.step.delta

1247data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}}

1248 

1249event: thread.run.requires_action

1250data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1251 

1252event: done

1253data: [DONE]

1254```

resources/beta/subresources/threads/methods/delete/index.md +0 −60 deleted

File Deleted View Diff

1## Delete thread

2 

3**delete** `/threads/{thread_id}`

4 

5Delete a thread.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Returns

12 

13- `ThreadDeleted object { id, deleted, object }`

14 

15 - `id: string`

16 

17 - `deleted: boolean`

18 

19 - `object: "thread.deleted"`

20 

21 - `"thread.deleted"`

22 

23### Example

24 

25```http

26curl https://api.openai.com/v1/threads/$THREAD_ID \

27 -X DELETE \

28 -H 'OpenAI-Beta: assistants=v2' \

29 -H "Authorization: Bearer $OPENAI_API_KEY"

30```

31 

32#### Response

33 

34```json

35{

36 "id": "id",

37 "deleted": true,

38 "object": "thread.deleted"

39}

40```

41 

42### Example

43 

44```http

45curl https://api.openai.com/v1/threads/thread_abc123 \

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

47 -H "Authorization: Bearer $OPENAI_API_KEY" \

48 -H "OpenAI-Beta: assistants=v2" \

49 -X DELETE

50```

51 

52#### Response

53 

54```json

55{

56 "id": "thread_abc123",

57 "object": "thread.deleted",

58 "deleted": true

59}

60```

resources/beta/subresources/threads/methods/retrieve/index.md +0 −112 deleted

File Deleted View Diff

1## Retrieve thread

2 

3**get** `/threads/{thread_id}`

4 

5Retrieves a thread.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Returns

12 

13- `Thread object { id, created_at, metadata, 2 more }`

14 

15 Represents a thread that contains [messages](/docs/api-reference/messages).

16 

17 - `id: string`

18 

19 The identifier, which can be referenced in API endpoints.

20 

21 - `created_at: number`

22 

23 The Unix timestamp (in seconds) for when the thread was created.

24 

25 - `metadata: Metadata or null`

26 

27 Set of 16 key-value pairs that can be attached to an object. This can be

28 useful for storing additional information about the object in a structured

29 format, and querying for objects via API or the dashboard.

30 

31 Keys are strings with a maximum length of 64 characters. Values are strings

32 with a maximum length of 512 characters.

33 

34 - `object: "thread"`

35 

36 The object type, which is always `thread`.

37 

38 - `"thread"`

39 

40 - `tool_resources: object { code_interpreter, file_search } or null`

41 

42 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

43 

44 - `code_interpreter: optional object { file_ids }`

45 

46 - `file_ids: optional array of string`

47 

48 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

49 

50 - `file_search: optional object { vector_store_ids }`

51 

52 - `vector_store_ids: optional array of string`

53 

54 The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

55 

56### Example

57 

58```http

59curl https://api.openai.com/v1/threads/$THREAD_ID \

60 -H 'OpenAI-Beta: assistants=v2' \

61 -H "Authorization: Bearer $OPENAI_API_KEY"

62```

63 

64#### Response

65 

66```json

67{

68 "id": "id",

69 "created_at": 0,

70 "metadata": {

71 "foo": "string"

72 },

73 "object": "thread",

74 "tool_resources": {

75 "code_interpreter": {

76 "file_ids": [

77 "string"

78 ]

79 },

80 "file_search": {

81 "vector_store_ids": [

82 "string"

83 ]

84 }

85 }

86}

87```

88 

89### Example

90 

91```http

92curl https://api.openai.com/v1/threads/thread_abc123 \

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

94 -H "Authorization: Bearer $OPENAI_API_KEY" \

95 -H "OpenAI-Beta: assistants=v2"

96```

97 

98#### Response

99 

100```json

101{

102 "id": "thread_abc123",

103 "object": "thread",

104 "created_at": 1699014083,

105 "metadata": {},

106 "tool_resources": {

107 "code_interpreter": {

108 "file_ids": []

109 }

110 }

111}

112```

resources/beta/subresources/threads/methods/update/index.md +0 −146 deleted

File Deleted View Diff

1## Modify thread

2 

3**post** `/threads/{thread_id}`

4 

5Modifies a thread.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Body Parameters

12 

13- `metadata: optional Metadata or null`

14 

15 Set of 16 key-value pairs that can be attached to an object. This can be

16 useful for storing additional information about the object in a structured

17 format, and querying for objects via API or the dashboard.

18 

19 Keys are strings with a maximum length of 64 characters. Values are strings

20 with a maximum length of 512 characters.

21 

22- `tool_resources: optional object { code_interpreter, file_search } or null`

23 

24 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

25 

26 - `code_interpreter: optional object { file_ids }`

27 

28 - `file_ids: optional array of string`

29 

30 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

31 

32 - `file_search: optional object { vector_store_ids }`

33 

34 - `vector_store_ids: optional array of string`

35 

36 The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

37 

38### Returns

39 

40- `Thread object { id, created_at, metadata, 2 more }`

41 

42 Represents a thread that contains [messages](/docs/api-reference/messages).

43 

44 - `id: string`

45 

46 The identifier, which can be referenced in API endpoints.

47 

48 - `created_at: number`

49 

50 The Unix timestamp (in seconds) for when the thread was created.

51 

52 - `metadata: Metadata or null`

53 

54 Set of 16 key-value pairs that can be attached to an object. This can be

55 useful for storing additional information about the object in a structured

56 format, and querying for objects via API or the dashboard.

57 

58 Keys are strings with a maximum length of 64 characters. Values are strings

59 with a maximum length of 512 characters.

60 

61 - `object: "thread"`

62 

63 The object type, which is always `thread`.

64 

65 - `"thread"`

66 

67 - `tool_resources: object { code_interpreter, file_search } or null`

68 

69 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

70 

71 - `code_interpreter: optional object { file_ids }`

72 

73 - `file_ids: optional array of string`

74 

75 A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

76 

77 - `file_search: optional object { vector_store_ids }`

78 

79 - `vector_store_ids: optional array of string`

80 

81 The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

82 

83### Example

84 

85```http

86curl https://api.openai.com/v1/threads/$THREAD_ID \

87 -H 'Content-Type: application/json' \

88 -H 'OpenAI-Beta: assistants=v2' \

89 -H "Authorization: Bearer $OPENAI_API_KEY" \

90 -d '{}'

91```

92 

93#### Response

94 

95```json

96{

97 "id": "id",

98 "created_at": 0,

99 "metadata": {

100 "foo": "string"

101 },

102 "object": "thread",

103 "tool_resources": {

104 "code_interpreter": {

105 "file_ids": [

106 "string"

107 ]

108 },

109 "file_search": {

110 "vector_store_ids": [

111 "string"

112 ]

113 }

114 }

115}

116```

117 

118### Example

119 

120```http

121curl https://api.openai.com/v1/threads/thread_abc123 \

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

123 -H "Authorization: Bearer $OPENAI_API_KEY" \

124 -H "OpenAI-Beta: assistants=v2" \

125 -d '{

126 "metadata": {

127 "modified": "true",

128 "user": "abc123"

129 }

130 }'

131```

132 

133#### Response

134 

135```json

136{

137 "id": "thread_abc123",

138 "object": "thread",

139 "created_at": 1699014083,

140 "metadata": {

141 "modified": "true",

142 "user": "abc123"

143 },

144 "tool_resources": {}

145}

146```

resources/beta/subresources/threads/subresources/messages/methods/create/index.md +0 −477 deleted

File Deleted View Diff

1## Create message

2 

3**post** `/threads/{thread_id}/messages`

4 

5Create a message.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Body Parameters

12 

13- `content: string or array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

14 

15 The text contents of the message.

16 

17 - `TextContent = string`

18 

19 The text contents of the message.

20 

21 - `ArrayOfContentParts = array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

22 

23 An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models).

24 

25 - `ImageFileContentBlock object { image_file, type }`

26 

27 References an image [File](/docs/api-reference/files) in the content of a message.

28 

29 - `image_file: ImageFile`

30 

31 - `file_id: string`

32 

33 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

34 

35 - `detail: optional "auto" or "low" or "high"`

36 

37 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

38 

39 - `"auto"`

40 

41 - `"low"`

42 

43 - `"high"`

44 

45 - `type: "image_file"`

46 

47 Always `image_file`.

48 

49 - `"image_file"`

50 

51 - `ImageURLContentBlock object { image_url, type }`

52 

53 References an image URL in the content of a message.

54 

55 - `image_url: ImageURL`

56 

57 - `url: string`

58 

59 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

60 

61 - `detail: optional "auto" or "low" or "high"`

62 

63 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

64 

65 - `"auto"`

66 

67 - `"low"`

68 

69 - `"high"`

70 

71 - `type: "image_url"`

72 

73 The type of the content part.

74 

75 - `"image_url"`

76 

77 - `TextContentBlockParam object { text, type }`

78 

79 The text content that is part of a message.

80 

81 - `text: string`

82 

83 Text content to be sent to the model

84 

85 - `type: "text"`

86 

87 Always `text`.

88 

89 - `"text"`

90 

91- `role: "user" or "assistant"`

92 

93 The role of the entity that is creating the message. Allowed values include:

94 

95 - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.

96 - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

97 

98 - `"user"`

99 

100 - `"assistant"`

101 

102- `attachments: optional array of object { file_id, tools } or null`

103 

104 A list of files attached to the message, and the tools they should be added to.

105 

106 - `file_id: optional string`

107 

108 The ID of the file to attach to the message.

109 

110 - `tools: optional array of CodeInterpreterTool or object { type }`

111 

112 The tools to add this file to.

113 

114 - `CodeInterpreterTool object { type }`

115 

116 - `type: "code_interpreter"`

117 

118 The type of tool being defined: `code_interpreter`

119 

120 - `"code_interpreter"`

121 

122 - `FileSearchTool object { type }`

123 

124 - `type: "file_search"`

125 

126 The type of tool being defined: `file_search`

127 

128 - `"file_search"`

129 

130- `metadata: optional Metadata or null`

131 

132 Set of 16 key-value pairs that can be attached to an object. This can be

133 useful for storing additional information about the object in a structured

134 format, and querying for objects via API or the dashboard.

135 

136 Keys are strings with a maximum length of 64 characters. Values are strings

137 with a maximum length of 512 characters.

138 

139### Returns

140 

141- `Message object { id, assistant_id, attachments, 11 more }`

142 

143 Represents a message within a [thread](/docs/api-reference/threads).

144 

145 - `id: string`

146 

147 The identifier, which can be referenced in API endpoints.

148 

149 - `assistant_id: string or null`

150 

151 If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.

152 

153 - `attachments: array of object { file_id, tools } or null`

154 

155 A list of files attached to the message, and the tools they were added to.

156 

157 - `file_id: optional string`

158 

159 The ID of the file to attach to the message.

160 

161 - `tools: optional array of CodeInterpreterTool or object { type }`

162 

163 The tools to add this file to.

164 

165 - `CodeInterpreterTool object { type }`

166 

167 - `type: "code_interpreter"`

168 

169 The type of tool being defined: `code_interpreter`

170 

171 - `"code_interpreter"`

172 

173 - `FileSearchTool object { type }`

174 

175 - `type: "file_search"`

176 

177 The type of tool being defined: `file_search`

178 

179 - `"file_search"`

180 

181 - `completed_at: number or null`

182 

183 The Unix timestamp (in seconds) for when the message was completed.

184 

185 - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock`

186 

187 The content of the message in array of text and/or images.

188 

189 - `ImageFileContentBlock object { image_file, type }`

190 

191 References an image [File](/docs/api-reference/files) in the content of a message.

192 

193 - `image_file: ImageFile`

194 

195 - `file_id: string`

196 

197 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

198 

199 - `detail: optional "auto" or "low" or "high"`

200 

201 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

202 

203 - `"auto"`

204 

205 - `"low"`

206 

207 - `"high"`

208 

209 - `type: "image_file"`

210 

211 Always `image_file`.

212 

213 - `"image_file"`

214 

215 - `ImageURLContentBlock object { image_url, type }`

216 

217 References an image URL in the content of a message.

218 

219 - `image_url: ImageURL`

220 

221 - `url: string`

222 

223 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

224 

225 - `detail: optional "auto" or "low" or "high"`

226 

227 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

228 

229 - `"auto"`

230 

231 - `"low"`

232 

233 - `"high"`

234 

235 - `type: "image_url"`

236 

237 The type of the content part.

238 

239 - `"image_url"`

240 

241 - `TextContentBlock object { text, type }`

242 

243 The text content that is part of a message.

244 

245 - `text: Text`

246 

247 - `annotations: array of FileCitationAnnotation or FilePathAnnotation`

248 

249 - `FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }`

250 

251 A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.

252 

253 - `end_index: number`

254 

255 - `file_citation: object { file_id }`

256 

257 - `file_id: string`

258 

259 The ID of the specific File the citation is from.

260 

261 - `start_index: number`

262 

263 - `text: string`

264 

265 The text in the message content that needs to be replaced.

266 

267 - `type: "file_citation"`

268 

269 Always `file_citation`.

270 

271 - `"file_citation"`

272 

273 - `FilePathAnnotation object { end_index, file_path, start_index, 2 more }`

274 

275 A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.

276 

277 - `end_index: number`

278 

279 - `file_path: object { file_id }`

280 

281 - `file_id: string`

282 

283 The ID of the file that was generated.

284 

285 - `start_index: number`

286 

287 - `text: string`

288 

289 The text in the message content that needs to be replaced.

290 

291 - `type: "file_path"`

292 

293 Always `file_path`.

294 

295 - `"file_path"`

296 

297 - `value: string`

298 

299 The data that makes up the text.

300 

301 - `type: "text"`

302 

303 Always `text`.

304 

305 - `"text"`

306 

307 - `RefusalContentBlock object { refusal, type }`

308 

309 The refusal content generated by the assistant.

310 

311 - `refusal: string`

312 

313 - `type: "refusal"`

314 

315 Always `refusal`.

316 

317 - `"refusal"`

318 

319 - `created_at: number`

320 

321 The Unix timestamp (in seconds) for when the message was created.

322 

323 - `incomplete_at: number or null`

324 

325 The Unix timestamp (in seconds) for when the message was marked as incomplete.

326 

327 - `incomplete_details: object { reason } or null`

328 

329 On an incomplete message, details about why the message is incomplete.

330 

331 - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more`

332 

333 The reason the message is incomplete.

334 

335 - `"content_filter"`

336 

337 - `"max_tokens"`

338 

339 - `"run_cancelled"`

340 

341 - `"run_expired"`

342 

343 - `"run_failed"`

344 

345 - `metadata: Metadata or null`

346 

347 Set of 16 key-value pairs that can be attached to an object. This can be

348 useful for storing additional information about the object in a structured

349 format, and querying for objects via API or the dashboard.

350 

351 Keys are strings with a maximum length of 64 characters. Values are strings

352 with a maximum length of 512 characters.

353 

354 - `object: "thread.message"`

355 

356 The object type, which is always `thread.message`.

357 

358 - `"thread.message"`

359 

360 - `role: "user" or "assistant"`

361 

362 The entity that produced the message. One of `user` or `assistant`.

363 

364 - `"user"`

365 

366 - `"assistant"`

367 

368 - `run_id: string or null`

369 

370 The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints.

371 

372 - `status: "in_progress" or "incomplete" or "completed"`

373 

374 The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.

375 

376 - `"in_progress"`

377 

378 - `"incomplete"`

379 

380 - `"completed"`

381 

382 - `thread_id: string`

383 

384 The [thread](/docs/api-reference/threads) ID that this message belongs to.

385 

386### Example

387 

388```http

389curl https://api.openai.com/v1/threads/$THREAD_ID/messages \

390 -H 'Content-Type: application/json' \

391 -H 'OpenAI-Beta: assistants=v2' \

392 -H "Authorization: Bearer $OPENAI_API_KEY" \

393 -d '{

394 "content": "string",

395 "role": "user"

396 }'

397```

398 

399#### Response

400 

401```json

402{

403 "id": "id",

404 "assistant_id": "assistant_id",

405 "attachments": [

406 {

407 "file_id": "file_id",

408 "tools": [

409 {

410 "type": "code_interpreter"

411 }

412 ]

413 }

414 ],

415 "completed_at": 0,

416 "content": [

417 {

418 "image_file": {

419 "file_id": "file_id",

420 "detail": "auto"

421 },

422 "type": "image_file"

423 }

424 ],

425 "created_at": 0,

426 "incomplete_at": 0,

427 "incomplete_details": {

428 "reason": "content_filter"

429 },

430 "metadata": {

431 "foo": "string"

432 },

433 "object": "thread.message",

434 "role": "user",

435 "run_id": "run_id",

436 "status": "in_progress",

437 "thread_id": "thread_id"

438}

439```

440 

441### Example

442 

443```http

444curl https://api.openai.com/v1/threads/thread_abc123/messages \

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

446 -H "Authorization: Bearer $OPENAI_API_KEY" \

447 -H "OpenAI-Beta: assistants=v2" \

448 -d '{

449 "role": "user",

450 "content": "How does AI work? Explain it in simple terms."

451 }'

452```

453 

454#### Response

455 

456```json

457{

458 "id": "msg_abc123",

459 "object": "thread.message",

460 "created_at": 1713226573,

461 "assistant_id": null,

462 "thread_id": "thread_abc123",

463 "run_id": null,

464 "role": "user",

465 "content": [

466 {

467 "type": "text",

468 "text": {

469 "value": "How does AI work? Explain it in simple terms.",

470 "annotations": []

471 }

472 }

473 ],

474 "attachments": [],

475 "metadata": {}

476}

477```

resources/beta/subresources/threads/subresources/messages/methods/delete/index.md +0 −61 deleted

File Deleted View Diff

1## Delete message

2 

3**delete** `/threads/{thread_id}/messages/{message_id}`

4 

5Deletes a message.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `message_id: string`

12 

13### Returns

14 

15- `MessageDeleted object { id, deleted, object }`

16 

17 - `id: string`

18 

19 - `deleted: boolean`

20 

21 - `object: "thread.message.deleted"`

22 

23 - `"thread.message.deleted"`

24 

25### Example

26 

27```http

28curl https://api.openai.com/v1/threads/$THREAD_ID/messages/$MESSAGE_ID \

29 -X DELETE \

30 -H 'OpenAI-Beta: assistants=v2' \

31 -H "Authorization: Bearer $OPENAI_API_KEY"

32```

33 

34#### Response

35 

36```json

37{

38 "id": "id",

39 "deleted": true,

40 "object": "thread.message.deleted"

41}

42```

43 

44### Example

45 

46```http

47curl -X DELETE https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \

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

49 -H "Authorization: Bearer $OPENAI_API_KEY" \

50 -H "OpenAI-Beta: assistants=v2"

51```

52 

53#### Response

54 

55```json

56{

57 "id": "msg_abc123",

58 "object": "thread.message.deleted",

59 "deleted": true

60}

61```

resources/beta/subresources/threads/subresources/messages/methods/list/index.md +0 −408 deleted

File Deleted View Diff

1## List messages

2 

3**get** `/threads/{thread_id}/messages`

4 

5Returns a list of messages for a given thread.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Query Parameters

12 

13- `after: optional string`

14 

15 A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

16 

17- `before: optional string`

18 

19 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

20 

21- `limit: optional number`

22 

23 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

24 

25- `order: optional "asc" or "desc"`

26 

27 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

28 

29 - `"asc"`

30 

31 - `"desc"`

32 

33- `run_id: optional string`

34 

35 Filter messages by the run ID that generated them.

36 

37### Returns

38 

39- `data: array of Message`

40 

41 - `id: string`

42 

43 The identifier, which can be referenced in API endpoints.

44 

45 - `assistant_id: string or null`

46 

47 If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.

48 

49 - `attachments: array of object { file_id, tools } or null`

50 

51 A list of files attached to the message, and the tools they were added to.

52 

53 - `file_id: optional string`

54 

55 The ID of the file to attach to the message.

56 

57 - `tools: optional array of CodeInterpreterTool or object { type }`

58 

59 The tools to add this file to.

60 

61 - `CodeInterpreterTool object { type }`

62 

63 - `type: "code_interpreter"`

64 

65 The type of tool being defined: `code_interpreter`

66 

67 - `"code_interpreter"`

68 

69 - `FileSearchTool object { type }`

70 

71 - `type: "file_search"`

72 

73 The type of tool being defined: `file_search`

74 

75 - `"file_search"`

76 

77 - `completed_at: number or null`

78 

79 The Unix timestamp (in seconds) for when the message was completed.

80 

81 - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock`

82 

83 The content of the message in array of text and/or images.

84 

85 - `ImageFileContentBlock object { image_file, type }`

86 

87 References an image [File](/docs/api-reference/files) in the content of a message.

88 

89 - `image_file: ImageFile`

90 

91 - `file_id: string`

92 

93 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

94 

95 - `detail: optional "auto" or "low" or "high"`

96 

97 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

98 

99 - `"auto"`

100 

101 - `"low"`

102 

103 - `"high"`

104 

105 - `type: "image_file"`

106 

107 Always `image_file`.

108 

109 - `"image_file"`

110 

111 - `ImageURLContentBlock object { image_url, type }`

112 

113 References an image URL in the content of a message.

114 

115 - `image_url: ImageURL`

116 

117 - `url: string`

118 

119 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

120 

121 - `detail: optional "auto" or "low" or "high"`

122 

123 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

124 

125 - `"auto"`

126 

127 - `"low"`

128 

129 - `"high"`

130 

131 - `type: "image_url"`

132 

133 The type of the content part.

134 

135 - `"image_url"`

136 

137 - `TextContentBlock object { text, type }`

138 

139 The text content that is part of a message.

140 

141 - `text: Text`

142 

143 - `annotations: array of FileCitationAnnotation or FilePathAnnotation`

144 

145 - `FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }`

146 

147 A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.

148 

149 - `end_index: number`

150 

151 - `file_citation: object { file_id }`

152 

153 - `file_id: string`

154 

155 The ID of the specific File the citation is from.

156 

157 - `start_index: number`

158 

159 - `text: string`

160 

161 The text in the message content that needs to be replaced.

162 

163 - `type: "file_citation"`

164 

165 Always `file_citation`.

166 

167 - `"file_citation"`

168 

169 - `FilePathAnnotation object { end_index, file_path, start_index, 2 more }`

170 

171 A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.

172 

173 - `end_index: number`

174 

175 - `file_path: object { file_id }`

176 

177 - `file_id: string`

178 

179 The ID of the file that was generated.

180 

181 - `start_index: number`

182 

183 - `text: string`

184 

185 The text in the message content that needs to be replaced.

186 

187 - `type: "file_path"`

188 

189 Always `file_path`.

190 

191 - `"file_path"`

192 

193 - `value: string`

194 

195 The data that makes up the text.

196 

197 - `type: "text"`

198 

199 Always `text`.

200 

201 - `"text"`

202 

203 - `RefusalContentBlock object { refusal, type }`

204 

205 The refusal content generated by the assistant.

206 

207 - `refusal: string`

208 

209 - `type: "refusal"`

210 

211 Always `refusal`.

212 

213 - `"refusal"`

214 

215 - `created_at: number`

216 

217 The Unix timestamp (in seconds) for when the message was created.

218 

219 - `incomplete_at: number or null`

220 

221 The Unix timestamp (in seconds) for when the message was marked as incomplete.

222 

223 - `incomplete_details: object { reason } or null`

224 

225 On an incomplete message, details about why the message is incomplete.

226 

227 - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more`

228 

229 The reason the message is incomplete.

230 

231 - `"content_filter"`

232 

233 - `"max_tokens"`

234 

235 - `"run_cancelled"`

236 

237 - `"run_expired"`

238 

239 - `"run_failed"`

240 

241 - `metadata: Metadata or null`

242 

243 Set of 16 key-value pairs that can be attached to an object. This can be

244 useful for storing additional information about the object in a structured

245 format, and querying for objects via API or the dashboard.

246 

247 Keys are strings with a maximum length of 64 characters. Values are strings

248 with a maximum length of 512 characters.

249 

250 - `object: "thread.message"`

251 

252 The object type, which is always `thread.message`.

253 

254 - `"thread.message"`

255 

256 - `role: "user" or "assistant"`

257 

258 The entity that produced the message. One of `user` or `assistant`.

259 

260 - `"user"`

261 

262 - `"assistant"`

263 

264 - `run_id: string or null`

265 

266 The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints.

267 

268 - `status: "in_progress" or "incomplete" or "completed"`

269 

270 The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.

271 

272 - `"in_progress"`

273 

274 - `"incomplete"`

275 

276 - `"completed"`

277 

278 - `thread_id: string`

279 

280 The [thread](/docs/api-reference/threads) ID that this message belongs to.

281 

282- `first_id: string`

283 

284- `has_more: boolean`

285 

286- `last_id: string`

287 

288- `object: string`

289 

290### Example

291 

292```http

293curl https://api.openai.com/v1/threads/$THREAD_ID/messages \

294 -H 'OpenAI-Beta: assistants=v2' \

295 -H "Authorization: Bearer $OPENAI_API_KEY"

296```

297 

298#### Response

299 

300```json

301{

302 "data": [

303 {

304 "id": "id",

305 "assistant_id": "assistant_id",

306 "attachments": [

307 {

308 "file_id": "file_id",

309 "tools": [

310 {

311 "type": "code_interpreter"

312 }

313 ]

314 }

315 ],

316 "completed_at": 0,

317 "content": [

318 {

319 "image_file": {

320 "file_id": "file_id",

321 "detail": "auto"

322 },

323 "type": "image_file"

324 }

325 ],

326 "created_at": 0,

327 "incomplete_at": 0,

328 "incomplete_details": {

329 "reason": "content_filter"

330 },

331 "metadata": {

332 "foo": "string"

333 },

334 "object": "thread.message",

335 "role": "user",

336 "run_id": "run_id",

337 "status": "in_progress",

338 "thread_id": "thread_id"

339 }

340 ],

341 "first_id": "msg_abc123",

342 "has_more": false,

343 "last_id": "msg_abc123",

344 "object": "list"

345}

346```

347 

348### Example

349 

350```http

351curl https://api.openai.com/v1/threads/thread_abc123/messages \

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

353 -H "Authorization: Bearer $OPENAI_API_KEY" \

354 -H "OpenAI-Beta: assistants=v2"

355```

356 

357#### Response

358 

359```json

360{

361 "object": "list",

362 "data": [

363 {

364 "id": "msg_abc123",

365 "object": "thread.message",

366 "created_at": 1699016383,

367 "assistant_id": null,

368 "thread_id": "thread_abc123",

369 "run_id": null,

370 "role": "user",

371 "content": [

372 {

373 "type": "text",

374 "text": {

375 "value": "How does AI work? Explain it in simple terms.",

376 "annotations": []

377 }

378 }

379 ],

380 "attachments": [],

381 "metadata": {}

382 },

383 {

384 "id": "msg_abc456",

385 "object": "thread.message",

386 "created_at": 1699016383,

387 "assistant_id": null,

388 "thread_id": "thread_abc123",

389 "run_id": null,

390 "role": "user",

391 "content": [

392 {

393 "type": "text",

394 "text": {

395 "value": "Hello, what is AI?",

396 "annotations": []

397 }

398 }

399 ],

400 "attachments": [],

401 "metadata": {}

402 }

403 ],

404 "first_id": "msg_abc123",

405 "last_id": "msg_abc456",

406 "has_more": false

407}

408```

resources/beta/subresources/threads/subresources/messages/methods/retrieve/index.md +0 −342 deleted

File Deleted View Diff

1## Retrieve message

2 

3**get** `/threads/{thread_id}/messages/{message_id}`

4 

5Retrieve a message.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `message_id: string`

12 

13### Returns

14 

15- `Message object { id, assistant_id, attachments, 11 more }`

16 

17 Represents a message within a [thread](/docs/api-reference/threads).

18 

19 - `id: string`

20 

21 The identifier, which can be referenced in API endpoints.

22 

23 - `assistant_id: string or null`

24 

25 If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.

26 

27 - `attachments: array of object { file_id, tools } or null`

28 

29 A list of files attached to the message, and the tools they were added to.

30 

31 - `file_id: optional string`

32 

33 The ID of the file to attach to the message.

34 

35 - `tools: optional array of CodeInterpreterTool or object { type }`

36 

37 The tools to add this file to.

38 

39 - `CodeInterpreterTool object { type }`

40 

41 - `type: "code_interpreter"`

42 

43 The type of tool being defined: `code_interpreter`

44 

45 - `"code_interpreter"`

46 

47 - `FileSearchTool object { type }`

48 

49 - `type: "file_search"`

50 

51 The type of tool being defined: `file_search`

52 

53 - `"file_search"`

54 

55 - `completed_at: number or null`

56 

57 The Unix timestamp (in seconds) for when the message was completed.

58 

59 - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock`

60 

61 The content of the message in array of text and/or images.

62 

63 - `ImageFileContentBlock object { image_file, type }`

64 

65 References an image [File](/docs/api-reference/files) in the content of a message.

66 

67 - `image_file: ImageFile`

68 

69 - `file_id: string`

70 

71 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

72 

73 - `detail: optional "auto" or "low" or "high"`

74 

75 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

76 

77 - `"auto"`

78 

79 - `"low"`

80 

81 - `"high"`

82 

83 - `type: "image_file"`

84 

85 Always `image_file`.

86 

87 - `"image_file"`

88 

89 - `ImageURLContentBlock object { image_url, type }`

90 

91 References an image URL in the content of a message.

92 

93 - `image_url: ImageURL`

94 

95 - `url: string`

96 

97 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

98 

99 - `detail: optional "auto" or "low" or "high"`

100 

101 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

102 

103 - `"auto"`

104 

105 - `"low"`

106 

107 - `"high"`

108 

109 - `type: "image_url"`

110 

111 The type of the content part.

112 

113 - `"image_url"`

114 

115 - `TextContentBlock object { text, type }`

116 

117 The text content that is part of a message.

118 

119 - `text: Text`

120 

121 - `annotations: array of FileCitationAnnotation or FilePathAnnotation`

122 

123 - `FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }`

124 

125 A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.

126 

127 - `end_index: number`

128 

129 - `file_citation: object { file_id }`

130 

131 - `file_id: string`

132 

133 The ID of the specific File the citation is from.

134 

135 - `start_index: number`

136 

137 - `text: string`

138 

139 The text in the message content that needs to be replaced.

140 

141 - `type: "file_citation"`

142 

143 Always `file_citation`.

144 

145 - `"file_citation"`

146 

147 - `FilePathAnnotation object { end_index, file_path, start_index, 2 more }`

148 

149 A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.

150 

151 - `end_index: number`

152 

153 - `file_path: object { file_id }`

154 

155 - `file_id: string`

156 

157 The ID of the file that was generated.

158 

159 - `start_index: number`

160 

161 - `text: string`

162 

163 The text in the message content that needs to be replaced.

164 

165 - `type: "file_path"`

166 

167 Always `file_path`.

168 

169 - `"file_path"`

170 

171 - `value: string`

172 

173 The data that makes up the text.

174 

175 - `type: "text"`

176 

177 Always `text`.

178 

179 - `"text"`

180 

181 - `RefusalContentBlock object { refusal, type }`

182 

183 The refusal content generated by the assistant.

184 

185 - `refusal: string`

186 

187 - `type: "refusal"`

188 

189 Always `refusal`.

190 

191 - `"refusal"`

192 

193 - `created_at: number`

194 

195 The Unix timestamp (in seconds) for when the message was created.

196 

197 - `incomplete_at: number or null`

198 

199 The Unix timestamp (in seconds) for when the message was marked as incomplete.

200 

201 - `incomplete_details: object { reason } or null`

202 

203 On an incomplete message, details about why the message is incomplete.

204 

205 - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more`

206 

207 The reason the message is incomplete.

208 

209 - `"content_filter"`

210 

211 - `"max_tokens"`

212 

213 - `"run_cancelled"`

214 

215 - `"run_expired"`

216 

217 - `"run_failed"`

218 

219 - `metadata: Metadata or null`

220 

221 Set of 16 key-value pairs that can be attached to an object. This can be

222 useful for storing additional information about the object in a structured

223 format, and querying for objects via API or the dashboard.

224 

225 Keys are strings with a maximum length of 64 characters. Values are strings

226 with a maximum length of 512 characters.

227 

228 - `object: "thread.message"`

229 

230 The object type, which is always `thread.message`.

231 

232 - `"thread.message"`

233 

234 - `role: "user" or "assistant"`

235 

236 The entity that produced the message. One of `user` or `assistant`.

237 

238 - `"user"`

239 

240 - `"assistant"`

241 

242 - `run_id: string or null`

243 

244 The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints.

245 

246 - `status: "in_progress" or "incomplete" or "completed"`

247 

248 The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.

249 

250 - `"in_progress"`

251 

252 - `"incomplete"`

253 

254 - `"completed"`

255 

256 - `thread_id: string`

257 

258 The [thread](/docs/api-reference/threads) ID that this message belongs to.

259 

260### Example

261 

262```http

263curl https://api.openai.com/v1/threads/$THREAD_ID/messages/$MESSAGE_ID \

264 -H 'OpenAI-Beta: assistants=v2' \

265 -H "Authorization: Bearer $OPENAI_API_KEY"

266```

267 

268#### Response

269 

270```json

271{

272 "id": "id",

273 "assistant_id": "assistant_id",

274 "attachments": [

275 {

276 "file_id": "file_id",

277 "tools": [

278 {

279 "type": "code_interpreter"

280 }

281 ]

282 }

283 ],

284 "completed_at": 0,

285 "content": [

286 {

287 "image_file": {

288 "file_id": "file_id",

289 "detail": "auto"

290 },

291 "type": "image_file"

292 }

293 ],

294 "created_at": 0,

295 "incomplete_at": 0,

296 "incomplete_details": {

297 "reason": "content_filter"

298 },

299 "metadata": {

300 "foo": "string"

301 },

302 "object": "thread.message",

303 "role": "user",

304 "run_id": "run_id",

305 "status": "in_progress",

306 "thread_id": "thread_id"

307}

308```

309 

310### Example

311 

312```http

313curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \

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

315 -H "Authorization: Bearer $OPENAI_API_KEY" \

316 -H "OpenAI-Beta: assistants=v2"

317```

318 

319#### Response

320 

321```json

322{

323 "id": "msg_abc123",

324 "object": "thread.message",

325 "created_at": 1699017614,

326 "assistant_id": null,

327 "thread_id": "thread_abc123",

328 "run_id": null,

329 "role": "user",

330 "content": [

331 {

332 "type": "text",

333 "text": {

334 "value": "How does AI work? Explain it in simple terms.",

335 "annotations": []

336 }

337 }

338 ],

339 "attachments": [],

340 "metadata": {}

341}

342```

resources/beta/subresources/threads/subresources/messages/methods/update/index.md +0 −364 deleted

File Deleted View Diff

1## Modify message

2 

3**post** `/threads/{thread_id}/messages/{message_id}`

4 

5Modifies a message.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `message_id: string`

12 

13### Body Parameters

14 

15- `metadata: optional Metadata or null`

16 

17 Set of 16 key-value pairs that can be attached to an object. This can be

18 useful for storing additional information about the object in a structured

19 format, and querying for objects via API or the dashboard.

20 

21 Keys are strings with a maximum length of 64 characters. Values are strings

22 with a maximum length of 512 characters.

23 

24### Returns

25 

26- `Message object { id, assistant_id, attachments, 11 more }`

27 

28 Represents a message within a [thread](/docs/api-reference/threads).

29 

30 - `id: string`

31 

32 The identifier, which can be referenced in API endpoints.

33 

34 - `assistant_id: string or null`

35 

36 If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.

37 

38 - `attachments: array of object { file_id, tools } or null`

39 

40 A list of files attached to the message, and the tools they were added to.

41 

42 - `file_id: optional string`

43 

44 The ID of the file to attach to the message.

45 

46 - `tools: optional array of CodeInterpreterTool or object { type }`

47 

48 The tools to add this file to.

49 

50 - `CodeInterpreterTool object { type }`

51 

52 - `type: "code_interpreter"`

53 

54 The type of tool being defined: `code_interpreter`

55 

56 - `"code_interpreter"`

57 

58 - `FileSearchTool object { type }`

59 

60 - `type: "file_search"`

61 

62 The type of tool being defined: `file_search`

63 

64 - `"file_search"`

65 

66 - `completed_at: number or null`

67 

68 The Unix timestamp (in seconds) for when the message was completed.

69 

70 - `content: array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlock or RefusalContentBlock`

71 

72 The content of the message in array of text and/or images.

73 

74 - `ImageFileContentBlock object { image_file, type }`

75 

76 References an image [File](/docs/api-reference/files) in the content of a message.

77 

78 - `image_file: ImageFile`

79 

80 - `file_id: string`

81 

82 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

83 

84 - `detail: optional "auto" or "low" or "high"`

85 

86 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

87 

88 - `"auto"`

89 

90 - `"low"`

91 

92 - `"high"`

93 

94 - `type: "image_file"`

95 

96 Always `image_file`.

97 

98 - `"image_file"`

99 

100 - `ImageURLContentBlock object { image_url, type }`

101 

102 References an image URL in the content of a message.

103 

104 - `image_url: ImageURL`

105 

106 - `url: string`

107 

108 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

109 

110 - `detail: optional "auto" or "low" or "high"`

111 

112 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

113 

114 - `"auto"`

115 

116 - `"low"`

117 

118 - `"high"`

119 

120 - `type: "image_url"`

121 

122 The type of the content part.

123 

124 - `"image_url"`

125 

126 - `TextContentBlock object { text, type }`

127 

128 The text content that is part of a message.

129 

130 - `text: Text`

131 

132 - `annotations: array of FileCitationAnnotation or FilePathAnnotation`

133 

134 - `FileCitationAnnotation object { end_index, file_citation, start_index, 2 more }`

135 

136 A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.

137 

138 - `end_index: number`

139 

140 - `file_citation: object { file_id }`

141 

142 - `file_id: string`

143 

144 The ID of the specific File the citation is from.

145 

146 - `start_index: number`

147 

148 - `text: string`

149 

150 The text in the message content that needs to be replaced.

151 

152 - `type: "file_citation"`

153 

154 Always `file_citation`.

155 

156 - `"file_citation"`

157 

158 - `FilePathAnnotation object { end_index, file_path, start_index, 2 more }`

159 

160 A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.

161 

162 - `end_index: number`

163 

164 - `file_path: object { file_id }`

165 

166 - `file_id: string`

167 

168 The ID of the file that was generated.

169 

170 - `start_index: number`

171 

172 - `text: string`

173 

174 The text in the message content that needs to be replaced.

175 

176 - `type: "file_path"`

177 

178 Always `file_path`.

179 

180 - `"file_path"`

181 

182 - `value: string`

183 

184 The data that makes up the text.

185 

186 - `type: "text"`

187 

188 Always `text`.

189 

190 - `"text"`

191 

192 - `RefusalContentBlock object { refusal, type }`

193 

194 The refusal content generated by the assistant.

195 

196 - `refusal: string`

197 

198 - `type: "refusal"`

199 

200 Always `refusal`.

201 

202 - `"refusal"`

203 

204 - `created_at: number`

205 

206 The Unix timestamp (in seconds) for when the message was created.

207 

208 - `incomplete_at: number or null`

209 

210 The Unix timestamp (in seconds) for when the message was marked as incomplete.

211 

212 - `incomplete_details: object { reason } or null`

213 

214 On an incomplete message, details about why the message is incomplete.

215 

216 - `reason: "content_filter" or "max_tokens" or "run_cancelled" or 2 more`

217 

218 The reason the message is incomplete.

219 

220 - `"content_filter"`

221 

222 - `"max_tokens"`

223 

224 - `"run_cancelled"`

225 

226 - `"run_expired"`

227 

228 - `"run_failed"`

229 

230 - `metadata: Metadata or null`

231 

232 Set of 16 key-value pairs that can be attached to an object. This can be

233 useful for storing additional information about the object in a structured

234 format, and querying for objects via API or the dashboard.

235 

236 Keys are strings with a maximum length of 64 characters. Values are strings

237 with a maximum length of 512 characters.

238 

239 - `object: "thread.message"`

240 

241 The object type, which is always `thread.message`.

242 

243 - `"thread.message"`

244 

245 - `role: "user" or "assistant"`

246 

247 The entity that produced the message. One of `user` or `assistant`.

248 

249 - `"user"`

250 

251 - `"assistant"`

252 

253 - `run_id: string or null`

254 

255 The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints.

256 

257 - `status: "in_progress" or "incomplete" or "completed"`

258 

259 The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.

260 

261 - `"in_progress"`

262 

263 - `"incomplete"`

264 

265 - `"completed"`

266 

267 - `thread_id: string`

268 

269 The [thread](/docs/api-reference/threads) ID that this message belongs to.

270 

271### Example

272 

273```http

274curl https://api.openai.com/v1/threads/$THREAD_ID/messages/$MESSAGE_ID \

275 -H 'Content-Type: application/json' \

276 -H 'OpenAI-Beta: assistants=v2' \

277 -H "Authorization: Bearer $OPENAI_API_KEY" \

278 -d '{}'

279```

280 

281#### Response

282 

283```json

284{

285 "id": "id",

286 "assistant_id": "assistant_id",

287 "attachments": [

288 {

289 "file_id": "file_id",

290 "tools": [

291 {

292 "type": "code_interpreter"

293 }

294 ]

295 }

296 ],

297 "completed_at": 0,

298 "content": [

299 {

300 "image_file": {

301 "file_id": "file_id",

302 "detail": "auto"

303 },

304 "type": "image_file"

305 }

306 ],

307 "created_at": 0,

308 "incomplete_at": 0,

309 "incomplete_details": {

310 "reason": "content_filter"

311 },

312 "metadata": {

313 "foo": "string"

314 },

315 "object": "thread.message",

316 "role": "user",

317 "run_id": "run_id",

318 "status": "in_progress",

319 "thread_id": "thread_id"

320}

321```

322 

323### Example

324 

325```http

326curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \

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

328 -H "Authorization: Bearer $OPENAI_API_KEY" \

329 -H "OpenAI-Beta: assistants=v2" \

330 -d '{

331 "metadata": {

332 "modified": "true",

333 "user": "abc123"

334 }

335 }'

336```

337 

338#### Response

339 

340```json

341{

342 "id": "msg_abc123",

343 "object": "thread.message",

344 "created_at": 1699017614,

345 "assistant_id": null,

346 "thread_id": "thread_abc123",

347 "run_id": null,

348 "role": "user",

349 "content": [

350 {

351 "type": "text",

352 "text": {

353 "value": "How does AI work? Explain it in simple terms.",

354 "annotations": []

355 }

356 }

357 ],

358 "file_ids": [],

359 "metadata": {

360 "modified": "true",

361 "user": "abc123"

362 }

363}

364```

resources/beta/subresources/threads/subresources/runs/methods/cancel/index.md +0 −533 deleted

File Deleted View Diff

1## Cancel a run

2 

3**post** `/threads/{thread_id}/runs/{run_id}/cancel`

4 

5Cancels a run that is `in_progress`.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `run_id: string`

12 

13### Returns

14 

15- `Run object { id, assistant_id, cancelled_at, 24 more }`

16 

17 Represents an execution run on a [thread](/docs/api-reference/threads).

18 

19 - `id: string`

20 

21 The identifier, which can be referenced in API endpoints.

22 

23 - `assistant_id: string`

24 

25 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

26 

27 - `cancelled_at: number or null`

28 

29 The Unix timestamp (in seconds) for when the run was cancelled.

30 

31 - `completed_at: number or null`

32 

33 The Unix timestamp (in seconds) for when the run was completed.

34 

35 - `created_at: number`

36 

37 The Unix timestamp (in seconds) for when the run was created.

38 

39 - `expires_at: number or null`

40 

41 The Unix timestamp (in seconds) for when the run will expire.

42 

43 - `failed_at: number or null`

44 

45 The Unix timestamp (in seconds) for when the run failed.

46 

47 - `incomplete_details: object { reason } or null`

48 

49 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

50 

51 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

52 

53 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

54 

55 - `"max_completion_tokens"`

56 

57 - `"max_prompt_tokens"`

58 

59 - `instructions: string`

60 

61 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

62 

63 - `last_error: object { code, message } or null`

64 

65 The last error associated with this run. Will be `null` if there are no errors.

66 

67 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

68 

69 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

70 

71 - `"server_error"`

72 

73 - `"rate_limit_exceeded"`

74 

75 - `"invalid_prompt"`

76 

77 - `message: string`

78 

79 A human-readable description of the error.

80 

81 - `max_completion_tokens: number or null`

82 

83 The maximum number of completion tokens specified to have been used over the course of the run.

84 

85 - `max_prompt_tokens: number or null`

86 

87 The maximum number of prompt tokens specified to have been used over the course of the run.

88 

89 - `metadata: Metadata or null`

90 

91 Set of 16 key-value pairs that can be attached to an object. This can be

92 useful for storing additional information about the object in a structured

93 format, and querying for objects via API or the dashboard.

94 

95 Keys are strings with a maximum length of 64 characters. Values are strings

96 with a maximum length of 512 characters.

97 

98 - `model: string`

99 

100 The model that the [assistant](/docs/api-reference/assistants) used for this run.

101 

102 - `object: "thread.run"`

103 

104 The object type, which is always `thread.run`.

105 

106 - `"thread.run"`

107 

108 - `parallel_tool_calls: boolean`

109 

110 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

111 

112 - `required_action: object { submit_tool_outputs, type } or null`

113 

114 Details on the action required to continue the run. Will be `null` if no action is required.

115 

116 - `submit_tool_outputs: object { tool_calls }`

117 

118 Details on the tool outputs needed for this run to continue.

119 

120 - `tool_calls: array of RequiredActionFunctionToolCall`

121 

122 A list of the relevant tool calls.

123 

124 - `id: string`

125 

126 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

127 

128 - `function: object { arguments, name }`

129 

130 The function definition.

131 

132 - `arguments: string`

133 

134 The arguments that the model expects you to pass to the function.

135 

136 - `name: string`

137 

138 The name of the function.

139 

140 - `type: "function"`

141 

142 The type of tool call the output is required for. For now, this is always `function`.

143 

144 - `"function"`

145 

146 - `type: "submit_tool_outputs"`

147 

148 For now, this is always `submit_tool_outputs`.

149 

150 - `"submit_tool_outputs"`

151 

152 - `response_format: AssistantResponseFormatOption or null`

153 

154 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

155 

156 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

157 

158 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

159 

160 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

161 

162 - `"auto"`

163 

164 `auto` is the default value

165 

166 - `"auto"`

167 

168 - `ResponseFormatText object { type }`

169 

170 Default response format. Used to generate text responses.

171 

172 - `type: "text"`

173 

174 The type of response format being defined. Always `text`.

175 

176 - `"text"`

177 

178 - `ResponseFormatJSONObject object { type }`

179 

180 JSON object response format. An older method of generating JSON responses.

181 Using `json_schema` is recommended for models that support it. Note that the

182 model will not generate JSON without a system or user message instructing it

183 to do so.

184 

185 - `type: "json_object"`

186 

187 The type of response format being defined. Always `json_object`.

188 

189 - `"json_object"`

190 

191 - `ResponseFormatJSONSchema object { json_schema, type }`

192 

193 JSON Schema response format. Used to generate structured JSON responses.

194 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

195 

196 - `json_schema: object { name, description, schema, strict }`

197 

198 Structured Outputs configuration options, including a JSON Schema.

199 

200 - `name: string`

201 

202 The name of the response format. Must be a-z, A-Z, 0-9, or contain

203 underscores and dashes, with a maximum length of 64.

204 

205 - `description: optional string`

206 

207 A description of what the response format is for, used by the model to

208 determine how to respond in the format.

209 

210 - `schema: optional map[unknown]`

211 

212 The schema for the response format, described as a JSON Schema object.

213 Learn how to build JSON schemas [here](https://json-schema.org/).

214 

215 - `strict: optional boolean or null`

216 

217 Whether to enable strict schema adherence when generating the output.

218 If set to true, the model will always follow the exact schema defined

219 in the `schema` field. Only a subset of JSON Schema is supported when

220 `strict` is `true`. To learn more, read the [Structured Outputs

221 guide](/docs/guides/structured-outputs).

222 

223 - `type: "json_schema"`

224 

225 The type of response format being defined. Always `json_schema`.

226 

227 - `"json_schema"`

228 

229 - `started_at: number or null`

230 

231 The Unix timestamp (in seconds) for when the run was started.

232 

233 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

234 

235 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

236 

237 - `"queued"`

238 

239 - `"in_progress"`

240 

241 - `"requires_action"`

242 

243 - `"cancelling"`

244 

245 - `"cancelled"`

246 

247 - `"failed"`

248 

249 - `"completed"`

250 

251 - `"incomplete"`

252 

253 - `"expired"`

254 

255 - `thread_id: string`

256 

257 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

258 

259 - `tool_choice: AssistantToolChoiceOption or null`

260 

261 Controls which (if any) tool is called by the model.

262 `none` means the model will not call any tools and instead generates a message.

263 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

264 `required` means the model must call one or more tools before responding to the user.

265 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

266 

267 - `"none" or "auto" or "required"`

268 

269 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

270 

271 - `"none"`

272 

273 - `"auto"`

274 

275 - `"required"`

276 

277 - `AssistantToolChoice object { type, function }`

278 

279 Specifies a tool the model should use. Use to force the model to call a specific tool.

280 

281 - `type: "function" or "code_interpreter" or "file_search"`

282 

283 The type of the tool. If type is `function`, the function name must be set

284 

285 - `"function"`

286 

287 - `"code_interpreter"`

288 

289 - `"file_search"`

290 

291 - `function: optional AssistantToolChoiceFunction`

292 

293 - `name: string`

294 

295 The name of the function to call.

296 

297 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

298 

299 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

300 

301 - `CodeInterpreterTool object { type }`

302 

303 - `type: "code_interpreter"`

304 

305 The type of tool being defined: `code_interpreter`

306 

307 - `"code_interpreter"`

308 

309 - `FileSearchTool object { type, file_search }`

310 

311 - `type: "file_search"`

312 

313 The type of tool being defined: `file_search`

314 

315 - `"file_search"`

316 

317 - `file_search: optional object { max_num_results, ranking_options }`

318 

319 Overrides for the file search tool.

320 

321 - `max_num_results: optional number`

322 

323 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

324 

325 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

326 

327 - `ranking_options: optional object { score_threshold, ranker }`

328 

329 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

330 

331 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

332 

333 - `score_threshold: number`

334 

335 The score threshold for the file search. All values must be a floating point number between 0 and 1.

336 

337 - `ranker: optional "auto" or "default_2024_08_21"`

338 

339 The ranker to use for the file search. If not specified will use the `auto` ranker.

340 

341 - `"auto"`

342 

343 - `"default_2024_08_21"`

344 

345 - `FunctionTool object { function, type }`

346 

347 - `function: FunctionDefinition`

348 

349 - `name: string`

350 

351 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

352 

353 - `description: optional string`

354 

355 A description of what the function does, used by the model to choose when and how to call the function.

356 

357 - `parameters: optional FunctionParameters`

358 

359 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

360 

361 Omitting `parameters` defines a function with an empty parameter list.

362 

363 - `strict: optional boolean or null`

364 

365 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

366 

367 - `type: "function"`

368 

369 The type of tool being defined: `function`

370 

371 - `"function"`

372 

373 - `truncation_strategy: object { type, last_messages } or null`

374 

375 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

376 

377 - `type: "auto" or "last_messages"`

378 

379 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

380 

381 - `"auto"`

382 

383 - `"last_messages"`

384 

385 - `last_messages: optional number or null`

386 

387 The number of most recent messages from the thread when constructing the context for the run.

388 

389 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

390 

391 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

392 

393 - `completion_tokens: number`

394 

395 Number of completion tokens used over the course of the run.

396 

397 - `prompt_tokens: number`

398 

399 Number of prompt tokens used over the course of the run.

400 

401 - `total_tokens: number`

402 

403 Total number of tokens used (prompt + completion).

404 

405 - `temperature: optional number or null`

406 

407 The sampling temperature used for this run. If not set, defaults to 1.

408 

409 - `top_p: optional number or null`

410 

411 The nucleus sampling value used for this run. If not set, defaults to 1.

412 

413### Example

414 

415```http

416curl https://api.openai.com/v1/threads/$THREAD_ID/runs/$RUN_ID/cancel \

417 -X POST \

418 -H 'OpenAI-Beta: assistants=v2' \

419 -H "Authorization: Bearer $OPENAI_API_KEY"

420```

421 

422#### Response

423 

424```json

425{

426 "id": "id",

427 "assistant_id": "assistant_id",

428 "cancelled_at": 0,

429 "completed_at": 0,

430 "created_at": 0,

431 "expires_at": 0,

432 "failed_at": 0,

433 "incomplete_details": {

434 "reason": "max_completion_tokens"

435 },

436 "instructions": "instructions",

437 "last_error": {

438 "code": "server_error",

439 "message": "message"

440 },

441 "max_completion_tokens": 256,

442 "max_prompt_tokens": 256,

443 "metadata": {

444 "foo": "string"

445 },

446 "model": "model",

447 "object": "thread.run",

448 "parallel_tool_calls": true,

449 "required_action": {

450 "submit_tool_outputs": {

451 "tool_calls": [

452 {

453 "id": "id",

454 "function": {

455 "arguments": "arguments",

456 "name": "name"

457 },

458 "type": "function"

459 }

460 ]

461 },

462 "type": "submit_tool_outputs"

463 },

464 "response_format": "auto",

465 "started_at": 0,

466 "status": "queued",

467 "thread_id": "thread_id",

468 "tool_choice": "none",

469 "tools": [

470 {

471 "type": "code_interpreter"

472 }

473 ],

474 "truncation_strategy": {

475 "type": "auto",

476 "last_messages": 1

477 },

478 "usage": {

479 "completion_tokens": 0,

480 "prompt_tokens": 0,

481 "total_tokens": 0

482 },

483 "temperature": 0,

484 "top_p": 0

485}

486```

487 

488### Example

489 

490```http

491curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel \

492 -H "Authorization: Bearer $OPENAI_API_KEY" \

493 -H "OpenAI-Beta: assistants=v2" \

494 -X POST

495```

496 

497#### Response

498 

499```json

500{

501 "id": "run_abc123",

502 "object": "thread.run",

503 "created_at": 1699076126,

504 "assistant_id": "asst_abc123",

505 "thread_id": "thread_abc123",

506 "status": "cancelling",

507 "started_at": 1699076126,

508 "expires_at": 1699076726,

509 "cancelled_at": null,

510 "failed_at": null,

511 "completed_at": null,

512 "last_error": null,

513 "model": "gpt-4o",

514 "instructions": "You summarize books.",

515 "tools": [

516 {

517 "type": "file_search"

518 }

519 ],

520 "tool_resources": {

521 "file_search": {

522 "vector_store_ids": ["vs_123"]

523 }

524 },

525 "metadata": {},

526 "usage": null,

527 "temperature": 1.0,

528 "top_p": 1.0,

529 "response_format": "auto",

530 "tool_choice": "auto",

531 "parallel_tool_calls": true

532}

533```

resources/beta/subresources/threads/subresources/runs/methods/create/index.md +0 −1194 deleted

File Deleted View Diff

1## Create run

2 

3**post** `/threads/{thread_id}/runs`

4 

5Create a run.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Query Parameters

12 

13- `include: optional array of RunStepInclude`

14 

15 A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.

16 

17 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

18 

19 - `"step_details.tool_calls[*].file_search.results[*].content"`

20 

21### Body Parameters

22 

23- `assistant_id: string`

24 

25 The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.

26 

27- `additional_instructions: optional string or null`

28 

29 Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.

30 

31- `additional_messages: optional array of object { content, role, attachments, metadata } or null`

32 

33 Adds additional messages to the thread before creating the run.

34 

35 - `content: string or array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

36 

37 The text contents of the message.

38 

39 - `TextContent = string`

40 

41 The text contents of the message.

42 

43 - `ArrayOfContentParts = array of ImageFileContentBlock or ImageURLContentBlock or TextContentBlockParam`

44 

45 An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models).

46 

47 - `ImageFileContentBlock object { image_file, type }`

48 

49 References an image [File](/docs/api-reference/files) in the content of a message.

50 

51 - `image_file: ImageFile`

52 

53 - `file_id: string`

54 

55 The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

56 

57 - `detail: optional "auto" or "low" or "high"`

58 

59 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

60 

61 - `"auto"`

62 

63 - `"low"`

64 

65 - `"high"`

66 

67 - `type: "image_file"`

68 

69 Always `image_file`.

70 

71 - `"image_file"`

72 

73 - `ImageURLContentBlock object { image_url, type }`

74 

75 References an image URL in the content of a message.

76 

77 - `image_url: ImageURL`

78 

79 - `url: string`

80 

81 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

82 

83 - `detail: optional "auto" or "low" or "high"`

84 

85 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

86 

87 - `"auto"`

88 

89 - `"low"`

90 

91 - `"high"`

92 

93 - `type: "image_url"`

94 

95 The type of the content part.

96 

97 - `"image_url"`

98 

99 - `TextContentBlockParam object { text, type }`

100 

101 The text content that is part of a message.

102 

103 - `text: string`

104 

105 Text content to be sent to the model

106 

107 - `type: "text"`

108 

109 Always `text`.

110 

111 - `"text"`

112 

113 - `role: "user" or "assistant"`

114 

115 The role of the entity that is creating the message. Allowed values include:

116 

117 - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.

118 - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

119 

120 - `"user"`

121 

122 - `"assistant"`

123 

124 - `attachments: optional array of object { file_id, tools } or null`

125 

126 A list of files attached to the message, and the tools they should be added to.

127 

128 - `file_id: optional string`

129 

130 The ID of the file to attach to the message.

131 

132 - `tools: optional array of CodeInterpreterTool or object { type }`

133 

134 The tools to add this file to.

135 

136 - `CodeInterpreterTool object { type }`

137 

138 - `type: "code_interpreter"`

139 

140 The type of tool being defined: `code_interpreter`

141 

142 - `"code_interpreter"`

143 

144 - `FileSearchTool object { type }`

145 

146 - `type: "file_search"`

147 

148 The type of tool being defined: `file_search`

149 

150 - `"file_search"`

151 

152 - `metadata: optional Metadata or null`

153 

154 Set of 16 key-value pairs that can be attached to an object. This can be

155 useful for storing additional information about the object in a structured

156 format, and querying for objects via API or the dashboard.

157 

158 Keys are strings with a maximum length of 64 characters. Values are strings

159 with a maximum length of 512 characters.

160 

161- `instructions: optional string or null`

162 

163 Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.

164 

165- `max_completion_tokens: optional number or null`

166 

167 The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

168 

169- `max_prompt_tokens: optional number or null`

170 

171 The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

172 

173- `metadata: optional Metadata or null`

174 

175 Set of 16 key-value pairs that can be attached to an object. This can be

176 useful for storing additional information about the object in a structured

177 format, and querying for objects via API or the dashboard.

178 

179 Keys are strings with a maximum length of 64 characters. Values are strings

180 with a maximum length of 512 characters.

181 

182- `model: optional string or "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 39 more or null`

183 

184 The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

185 

186 - `string`

187 

188 - `AssistantSupportedModels = "gpt-5" or "gpt-5-mini" or "gpt-5-nano" or 39 more`

189 

190 The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

191 

192 - `"gpt-5"`

193 

194 - `"gpt-5-mini"`

195 

196 - `"gpt-5-nano"`

197 

198 - `"gpt-5-2025-08-07"`

199 

200 - `"gpt-5-mini-2025-08-07"`

201 

202 - `"gpt-5-nano-2025-08-07"`

203 

204 - `"gpt-4.1"`

205 

206 - `"gpt-4.1-mini"`

207 

208 - `"gpt-4.1-nano"`

209 

210 - `"gpt-4.1-2025-04-14"`

211 

212 - `"gpt-4.1-mini-2025-04-14"`

213 

214 - `"gpt-4.1-nano-2025-04-14"`

215 

216 - `"o3-mini"`

217 

218 - `"o3-mini-2025-01-31"`

219 

220 - `"o1"`

221 

222 - `"o1-2024-12-17"`

223 

224 - `"gpt-4o"`

225 

226 - `"gpt-4o-2024-11-20"`

227 

228 - `"gpt-4o-2024-08-06"`

229 

230 - `"gpt-4o-2024-05-13"`

231 

232 - `"gpt-4o-mini"`

233 

234 - `"gpt-4o-mini-2024-07-18"`

235 

236 - `"gpt-4.5-preview"`

237 

238 - `"gpt-4.5-preview-2025-02-27"`

239 

240 - `"gpt-4-turbo"`

241 

242 - `"gpt-4-turbo-2024-04-09"`

243 

244 - `"gpt-4-0125-preview"`

245 

246 - `"gpt-4-turbo-preview"`

247 

248 - `"gpt-4-1106-preview"`

249 

250 - `"gpt-4-vision-preview"`

251 

252 - `"gpt-4"`

253 

254 - `"gpt-4-0314"`

255 

256 - `"gpt-4-0613"`

257 

258 - `"gpt-4-32k"`

259 

260 - `"gpt-4-32k-0314"`

261 

262 - `"gpt-4-32k-0613"`

263 

264 - `"gpt-3.5-turbo"`

265 

266 - `"gpt-3.5-turbo-16k"`

267 

268 - `"gpt-3.5-turbo-0613"`

269 

270 - `"gpt-3.5-turbo-1106"`

271 

272 - `"gpt-3.5-turbo-0125"`

273 

274 - `"gpt-3.5-turbo-16k-0613"`

275 

276- `parallel_tool_calls: optional boolean`

277 

278 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

279 

280- `reasoning_effort: optional ReasoningEffort or null`

281 

282 Constrains effort on reasoning for reasoning models. Currently supported

283 values are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.

284 Reducing reasoning effort can result in faster responses and fewer tokens

285 used on reasoning in a response. Not all reasoning models support every

286 value. See the

287 [reasoning guide](https://platform.openai.com/docs/guides/reasoning)

288 for model-specific support.

289 

290 - `"none"`

291 

292 - `"minimal"`

293 

294 - `"low"`

295 

296 - `"medium"`

297 

298 - `"high"`

299 

300 - `"xhigh"`

301 

302 - `"max"`

303 

304- `response_format: optional AssistantResponseFormatOption or null`

305 

306 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

307 

308 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

309 

310 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

311 

312 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

313 

314 - `"auto"`

315 

316 `auto` is the default value

317 

318 - `"auto"`

319 

320 - `ResponseFormatText object { type }`

321 

322 Default response format. Used to generate text responses.

323 

324 - `type: "text"`

325 

326 The type of response format being defined. Always `text`.

327 

328 - `"text"`

329 

330 - `ResponseFormatJSONObject object { type }`

331 

332 JSON object response format. An older method of generating JSON responses.

333 Using `json_schema` is recommended for models that support it. Note that the

334 model will not generate JSON without a system or user message instructing it

335 to do so.

336 

337 - `type: "json_object"`

338 

339 The type of response format being defined. Always `json_object`.

340 

341 - `"json_object"`

342 

343 - `ResponseFormatJSONSchema object { json_schema, type }`

344 

345 JSON Schema response format. Used to generate structured JSON responses.

346 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

347 

348 - `json_schema: object { name, description, schema, strict }`

349 

350 Structured Outputs configuration options, including a JSON Schema.

351 

352 - `name: string`

353 

354 The name of the response format. Must be a-z, A-Z, 0-9, or contain

355 underscores and dashes, with a maximum length of 64.

356 

357 - `description: optional string`

358 

359 A description of what the response format is for, used by the model to

360 determine how to respond in the format.

361 

362 - `schema: optional map[unknown]`

363 

364 The schema for the response format, described as a JSON Schema object.

365 Learn how to build JSON schemas [here](https://json-schema.org/).

366 

367 - `strict: optional boolean or null`

368 

369 Whether to enable strict schema adherence when generating the output.

370 If set to true, the model will always follow the exact schema defined

371 in the `schema` field. Only a subset of JSON Schema is supported when

372 `strict` is `true`. To learn more, read the [Structured Outputs

373 guide](/docs/guides/structured-outputs).

374 

375 - `type: "json_schema"`

376 

377 The type of response format being defined. Always `json_schema`.

378 

379 - `"json_schema"`

380 

381- `stream: optional boolean or null`

382 

383 If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.

384 

385- `temperature: optional number or null`

386 

387 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

388 

389- `tool_choice: optional AssistantToolChoiceOption or null`

390 

391 Controls which (if any) tool is called by the model.

392 `none` means the model will not call any tools and instead generates a message.

393 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

394 `required` means the model must call one or more tools before responding to the user.

395 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

396 

397 - `"none" or "auto" or "required"`

398 

399 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

400 

401 - `"none"`

402 

403 - `"auto"`

404 

405 - `"required"`

406 

407 - `AssistantToolChoice object { type, function }`

408 

409 Specifies a tool the model should use. Use to force the model to call a specific tool.

410 

411 - `type: "function" or "code_interpreter" or "file_search"`

412 

413 The type of the tool. If type is `function`, the function name must be set

414 

415 - `"function"`

416 

417 - `"code_interpreter"`

418 

419 - `"file_search"`

420 

421 - `function: optional AssistantToolChoiceFunction`

422 

423 - `name: string`

424 

425 The name of the function to call.

426 

427- `tools: optional array of CodeInterpreterTool or FileSearchTool or FunctionTool or null`

428 

429 Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.

430 

431 - `CodeInterpreterTool object { type }`

432 

433 - `FileSearchTool object { type, file_search }`

434 

435 - `type: "file_search"`

436 

437 The type of tool being defined: `file_search`

438 

439 - `"file_search"`

440 

441 - `file_search: optional object { max_num_results, ranking_options }`

442 

443 Overrides for the file search tool.

444 

445 - `max_num_results: optional number`

446 

447 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

448 

449 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

450 

451 - `ranking_options: optional object { score_threshold, ranker }`

452 

453 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

454 

455 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

456 

457 - `score_threshold: number`

458 

459 The score threshold for the file search. All values must be a floating point number between 0 and 1.

460 

461 - `ranker: optional "auto" or "default_2024_08_21"`

462 

463 The ranker to use for the file search. If not specified will use the `auto` ranker.

464 

465 - `"auto"`

466 

467 - `"default_2024_08_21"`

468 

469 - `FunctionTool object { function, type }`

470 

471 - `function: FunctionDefinition`

472 

473 - `name: string`

474 

475 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

476 

477 - `description: optional string`

478 

479 A description of what the function does, used by the model to choose when and how to call the function.

480 

481 - `parameters: optional FunctionParameters`

482 

483 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

484 

485 Omitting `parameters` defines a function with an empty parameter list.

486 

487 - `strict: optional boolean or null`

488 

489 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

490 

491 - `type: "function"`

492 

493 The type of tool being defined: `function`

494 

495 - `"function"`

496 

497- `top_p: optional number or null`

498 

499 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

500 

501 We generally recommend altering this or temperature but not both.

502 

503- `truncation_strategy: optional object { type, last_messages } or null`

504 

505 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

506 

507 - `type: "auto" or "last_messages"`

508 

509 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

510 

511 - `"auto"`

512 

513 - `"last_messages"`

514 

515 - `last_messages: optional number or null`

516 

517 The number of most recent messages from the thread when constructing the context for the run.

518 

519### Returns

520 

521- `Run object { id, assistant_id, cancelled_at, 24 more }`

522 

523 Represents an execution run on a [thread](/docs/api-reference/threads).

524 

525 - `id: string`

526 

527 The identifier, which can be referenced in API endpoints.

528 

529 - `assistant_id: string`

530 

531 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

532 

533 - `cancelled_at: number or null`

534 

535 The Unix timestamp (in seconds) for when the run was cancelled.

536 

537 - `completed_at: number or null`

538 

539 The Unix timestamp (in seconds) for when the run was completed.

540 

541 - `created_at: number`

542 

543 The Unix timestamp (in seconds) for when the run was created.

544 

545 - `expires_at: number or null`

546 

547 The Unix timestamp (in seconds) for when the run will expire.

548 

549 - `failed_at: number or null`

550 

551 The Unix timestamp (in seconds) for when the run failed.

552 

553 - `incomplete_details: object { reason } or null`

554 

555 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

556 

557 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

558 

559 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

560 

561 - `"max_completion_tokens"`

562 

563 - `"max_prompt_tokens"`

564 

565 - `instructions: string`

566 

567 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

568 

569 - `last_error: object { code, message } or null`

570 

571 The last error associated with this run. Will be `null` if there are no errors.

572 

573 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

574 

575 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

576 

577 - `"server_error"`

578 

579 - `"rate_limit_exceeded"`

580 

581 - `"invalid_prompt"`

582 

583 - `message: string`

584 

585 A human-readable description of the error.

586 

587 - `max_completion_tokens: number or null`

588 

589 The maximum number of completion tokens specified to have been used over the course of the run.

590 

591 - `max_prompt_tokens: number or null`

592 

593 The maximum number of prompt tokens specified to have been used over the course of the run.

594 

595 - `metadata: Metadata or null`

596 

597 Set of 16 key-value pairs that can be attached to an object. This can be

598 useful for storing additional information about the object in a structured

599 format, and querying for objects via API or the dashboard.

600 

601 Keys are strings with a maximum length of 64 characters. Values are strings

602 with a maximum length of 512 characters.

603 

604 - `model: string`

605 

606 The model that the [assistant](/docs/api-reference/assistants) used for this run.

607 

608 - `object: "thread.run"`

609 

610 The object type, which is always `thread.run`.

611 

612 - `"thread.run"`

613 

614 - `parallel_tool_calls: boolean`

615 

616 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

617 

618 - `required_action: object { submit_tool_outputs, type } or null`

619 

620 Details on the action required to continue the run. Will be `null` if no action is required.

621 

622 - `submit_tool_outputs: object { tool_calls }`

623 

624 Details on the tool outputs needed for this run to continue.

625 

626 - `tool_calls: array of RequiredActionFunctionToolCall`

627 

628 A list of the relevant tool calls.

629 

630 - `id: string`

631 

632 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

633 

634 - `function: object { arguments, name }`

635 

636 The function definition.

637 

638 - `arguments: string`

639 

640 The arguments that the model expects you to pass to the function.

641 

642 - `name: string`

643 

644 The name of the function.

645 

646 - `type: "function"`

647 

648 The type of tool call the output is required for. For now, this is always `function`.

649 

650 - `"function"`

651 

652 - `type: "submit_tool_outputs"`

653 

654 For now, this is always `submit_tool_outputs`.

655 

656 - `"submit_tool_outputs"`

657 

658 - `response_format: AssistantResponseFormatOption or null`

659 

660 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

661 

662 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

663 

664 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

665 

666 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

667 

668 - `"auto"`

669 

670 `auto` is the default value

671 

672 - `"auto"`

673 

674 - `ResponseFormatText object { type }`

675 

676 Default response format. Used to generate text responses.

677 

678 - `type: "text"`

679 

680 The type of response format being defined. Always `text`.

681 

682 - `"text"`

683 

684 - `ResponseFormatJSONObject object { type }`

685 

686 JSON object response format. An older method of generating JSON responses.

687 Using `json_schema` is recommended for models that support it. Note that the

688 model will not generate JSON without a system or user message instructing it

689 to do so.

690 

691 - `type: "json_object"`

692 

693 The type of response format being defined. Always `json_object`.

694 

695 - `"json_object"`

696 

697 - `ResponseFormatJSONSchema object { json_schema, type }`

698 

699 JSON Schema response format. Used to generate structured JSON responses.

700 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

701 

702 - `json_schema: object { name, description, schema, strict }`

703 

704 Structured Outputs configuration options, including a JSON Schema.

705 

706 - `name: string`

707 

708 The name of the response format. Must be a-z, A-Z, 0-9, or contain

709 underscores and dashes, with a maximum length of 64.

710 

711 - `description: optional string`

712 

713 A description of what the response format is for, used by the model to

714 determine how to respond in the format.

715 

716 - `schema: optional map[unknown]`

717 

718 The schema for the response format, described as a JSON Schema object.

719 Learn how to build JSON schemas [here](https://json-schema.org/).

720 

721 - `strict: optional boolean or null`

722 

723 Whether to enable strict schema adherence when generating the output.

724 If set to true, the model will always follow the exact schema defined

725 in the `schema` field. Only a subset of JSON Schema is supported when

726 `strict` is `true`. To learn more, read the [Structured Outputs

727 guide](/docs/guides/structured-outputs).

728 

729 - `type: "json_schema"`

730 

731 The type of response format being defined. Always `json_schema`.

732 

733 - `"json_schema"`

734 

735 - `started_at: number or null`

736 

737 The Unix timestamp (in seconds) for when the run was started.

738 

739 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

740 

741 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

742 

743 - `"queued"`

744 

745 - `"in_progress"`

746 

747 - `"requires_action"`

748 

749 - `"cancelling"`

750 

751 - `"cancelled"`

752 

753 - `"failed"`

754 

755 - `"completed"`

756 

757 - `"incomplete"`

758 

759 - `"expired"`

760 

761 - `thread_id: string`

762 

763 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

764 

765 - `tool_choice: AssistantToolChoiceOption or null`

766 

767 Controls which (if any) tool is called by the model.

768 `none` means the model will not call any tools and instead generates a message.

769 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

770 `required` means the model must call one or more tools before responding to the user.

771 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

772 

773 - `"none" or "auto" or "required"`

774 

775 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

776 

777 - `"none"`

778 

779 - `"auto"`

780 

781 - `"required"`

782 

783 - `AssistantToolChoice object { type, function }`

784 

785 Specifies a tool the model should use. Use to force the model to call a specific tool.

786 

787 - `type: "function" or "code_interpreter" or "file_search"`

788 

789 The type of the tool. If type is `function`, the function name must be set

790 

791 - `"function"`

792 

793 - `"code_interpreter"`

794 

795 - `"file_search"`

796 

797 - `function: optional AssistantToolChoiceFunction`

798 

799 - `name: string`

800 

801 The name of the function to call.

802 

803 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

804 

805 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

806 

807 - `CodeInterpreterTool object { type }`

808 

809 - `type: "code_interpreter"`

810 

811 The type of tool being defined: `code_interpreter`

812 

813 - `"code_interpreter"`

814 

815 - `FileSearchTool object { type, file_search }`

816 

817 - `type: "file_search"`

818 

819 The type of tool being defined: `file_search`

820 

821 - `"file_search"`

822 

823 - `file_search: optional object { max_num_results, ranking_options }`

824 

825 Overrides for the file search tool.

826 

827 - `max_num_results: optional number`

828 

829 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

830 

831 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

832 

833 - `ranking_options: optional object { score_threshold, ranker }`

834 

835 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

836 

837 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

838 

839 - `score_threshold: number`

840 

841 The score threshold for the file search. All values must be a floating point number between 0 and 1.

842 

843 - `ranker: optional "auto" or "default_2024_08_21"`

844 

845 The ranker to use for the file search. If not specified will use the `auto` ranker.

846 

847 - `"auto"`

848 

849 - `"default_2024_08_21"`

850 

851 - `FunctionTool object { function, type }`

852 

853 - `function: FunctionDefinition`

854 

855 - `name: string`

856 

857 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

858 

859 - `description: optional string`

860 

861 A description of what the function does, used by the model to choose when and how to call the function.

862 

863 - `parameters: optional FunctionParameters`

864 

865 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

866 

867 Omitting `parameters` defines a function with an empty parameter list.

868 

869 - `strict: optional boolean or null`

870 

871 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

872 

873 - `type: "function"`

874 

875 The type of tool being defined: `function`

876 

877 - `"function"`

878 

879 - `truncation_strategy: object { type, last_messages } or null`

880 

881 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

882 

883 - `type: "auto" or "last_messages"`

884 

885 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

886 

887 - `"auto"`

888 

889 - `"last_messages"`

890 

891 - `last_messages: optional number or null`

892 

893 The number of most recent messages from the thread when constructing the context for the run.

894 

895 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

896 

897 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

898 

899 - `completion_tokens: number`

900 

901 Number of completion tokens used over the course of the run.

902 

903 - `prompt_tokens: number`

904 

905 Number of prompt tokens used over the course of the run.

906 

907 - `total_tokens: number`

908 

909 Total number of tokens used (prompt + completion).

910 

911 - `temperature: optional number or null`

912 

913 The sampling temperature used for this run. If not set, defaults to 1.

914 

915 - `top_p: optional number or null`

916 

917 The nucleus sampling value used for this run. If not set, defaults to 1.

918 

919### Example

920 

921```http

922curl https://api.openai.com/v1/threads/$THREAD_ID/runs \

923 -H 'Content-Type: application/json' \

924 -H 'OpenAI-Beta: assistants=v2' \

925 -H "Authorization: Bearer $OPENAI_API_KEY" \

926 -d '{

927 "assistant_id": "assistant_id",

928 "temperature": 1,

929 "top_p": 1

930 }'

931```

932 

933#### Response

934 

935```json

936{

937 "id": "id",

938 "assistant_id": "assistant_id",

939 "cancelled_at": 0,

940 "completed_at": 0,

941 "created_at": 0,

942 "expires_at": 0,

943 "failed_at": 0,

944 "incomplete_details": {

945 "reason": "max_completion_tokens"

946 },

947 "instructions": "instructions",

948 "last_error": {

949 "code": "server_error",

950 "message": "message"

951 },

952 "max_completion_tokens": 256,

953 "max_prompt_tokens": 256,

954 "metadata": {

955 "foo": "string"

956 },

957 "model": "model",

958 "object": "thread.run",

959 "parallel_tool_calls": true,

960 "required_action": {

961 "submit_tool_outputs": {

962 "tool_calls": [

963 {

964 "id": "id",

965 "function": {

966 "arguments": "arguments",

967 "name": "name"

968 },

969 "type": "function"

970 }

971 ]

972 },

973 "type": "submit_tool_outputs"

974 },

975 "response_format": "auto",

976 "started_at": 0,

977 "status": "queued",

978 "thread_id": "thread_id",

979 "tool_choice": "none",

980 "tools": [

981 {

982 "type": "code_interpreter"

983 }

984 ],

985 "truncation_strategy": {

986 "type": "auto",

987 "last_messages": 1

988 },

989 "usage": {

990 "completion_tokens": 0,

991 "prompt_tokens": 0,

992 "total_tokens": 0

993 },

994 "temperature": 0,

995 "top_p": 0

996}

997```

998 

999### Example

1000 

1001```http

1002curl https://api.openai.com/v1/threads/thread_abc123/runs \

1003 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

1005 -H "OpenAI-Beta: assistants=v2" \

1006 -d '{

1007 "assistant_id": "asst_abc123"

1008 }'

1009```

1010 

1011#### Response

1012 

1013```json

1014{

1015 "id": "run_abc123",

1016 "object": "thread.run",

1017 "created_at": 1699063290,

1018 "assistant_id": "asst_abc123",

1019 "thread_id": "thread_abc123",

1020 "status": "queued",

1021 "started_at": 1699063290,

1022 "expires_at": null,

1023 "cancelled_at": null,

1024 "failed_at": null,

1025 "completed_at": 1699063291,

1026 "last_error": null,

1027 "model": "gpt-4o",

1028 "instructions": null,

1029 "incomplete_details": null,

1030 "tools": [

1031 {

1032 "type": "code_interpreter"

1033 }

1034 ],

1035 "metadata": {},

1036 "usage": null,

1037 "temperature": 1.0,

1038 "top_p": 1.0,

1039 "max_prompt_tokens": 1000,

1040 "max_completion_tokens": 1000,

1041 "truncation_strategy": {

1042 "type": "auto",

1043 "last_messages": null

1044 },

1045 "response_format": "auto",

1046 "tool_choice": "auto",

1047 "parallel_tool_calls": true

1048}

1049```

1050 

1051### Streaming

1052 

1053```http

1054curl https://api.openai.com/v1/threads/thread_123/runs \

1055 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

1057 -H "OpenAI-Beta: assistants=v2" \

1058 -d '{

1059 "assistant_id": "asst_123",

1060 "stream": true

1061 }'

1062```

1063 

1064#### Response

1065 

1066```json

1067event: thread.run.created

1068data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1069 

1070event: thread.run.queued

1071data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1072 

1073event: thread.run.in_progress

1074data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710330641,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1075 

1076event: thread.run.step.created

1077data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

1078 

1079event: thread.run.step.in_progress

1080data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

1081 

1082event: thread.message.created

1083data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}

1084 

1085event: thread.message.in_progress

1086data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}

1087 

1088event: thread.message.delta

1089data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}}

1090 

1091...

1092 

1093event: thread.message.delta

1094data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}}

1095 

1096event: thread.message.delta

1097data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}}

1098 

1099event: thread.message.completed

1100data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710330642,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}}

1101 

1102event: thread.run.step.completed

1103data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710330642,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}}

1104 

1105event: thread.run.completed

1106data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710330641,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710330642,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1107 

1108event: done

1109data: [DONE]

1110```

1111 

1112### Streaming with Functions

1113 

1114```http

1115curl https://api.openai.com/v1/threads/thread_abc123/runs \

1116 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

1118 -H "OpenAI-Beta: assistants=v2" \

1119 -d '{

1120 "assistant_id": "asst_abc123",

1121 "tools": [

1122 {

1123 "type": "function",

1124 "function": {

1125 "name": "get_current_weather",

1126 "description": "Get the current weather in a given location",

1127 "parameters": {

1128 "type": "object",

1129 "properties": {

1130 "location": {

1131 "type": "string",

1132 "description": "The city and state, e.g. San Francisco, CA"

1133 },

1134 "unit": {

1135 "type": "string",

1136 "enum": ["celsius", "fahrenheit"]

1137 }

1138 },

1139 "required": ["location"]

1140 }

1141 }

1142 }

1143 ],

1144 "stream": true

1145 }'

1146```

1147 

1148#### Response

1149 

1150```json

1151event: thread.run.created

1152data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1153 

1154event: thread.run.queued

1155data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1156 

1157event: thread.run.in_progress

1158data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710348075,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1159 

1160event: thread.run.step.created

1161data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

1162 

1163event: thread.run.step.in_progress

1164data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

1165 

1166event: thread.message.created

1167data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}

1168 

1169event: thread.message.in_progress

1170data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}

1171 

1172event: thread.message.delta

1173data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}}

1174 

1175...

1176 

1177event: thread.message.delta

1178data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}}

1179 

1180event: thread.message.delta

1181data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}}

1182 

1183event: thread.message.completed

1184data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}}

1185 

1186event: thread.run.step.completed

1187data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}}

1188 

1189event: thread.run.completed

1190data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710348075,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710348077,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

1191 

1192event: done

1193data: [DONE]

1194```

resources/beta/subresources/threads/subresources/runs/methods/list/index.md +0 −635 deleted

File Deleted View Diff

1## List runs

2 

3**get** `/threads/{thread_id}/runs`

4 

5Returns a list of runs belonging to a thread.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11### Query Parameters

12 

13- `after: optional string`

14 

15 A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

16 

17- `before: optional string`

18 

19 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

20 

21- `limit: optional number`

22 

23 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

24 

25- `order: optional "asc" or "desc"`

26 

27 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

28 

29 - `"asc"`

30 

31 - `"desc"`

32 

33### Returns

34 

35- `data: array of Run`

36 

37 - `id: string`

38 

39 The identifier, which can be referenced in API endpoints.

40 

41 - `assistant_id: string`

42 

43 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

44 

45 - `cancelled_at: number or null`

46 

47 The Unix timestamp (in seconds) for when the run was cancelled.

48 

49 - `completed_at: number or null`

50 

51 The Unix timestamp (in seconds) for when the run was completed.

52 

53 - `created_at: number`

54 

55 The Unix timestamp (in seconds) for when the run was created.

56 

57 - `expires_at: number or null`

58 

59 The Unix timestamp (in seconds) for when the run will expire.

60 

61 - `failed_at: number or null`

62 

63 The Unix timestamp (in seconds) for when the run failed.

64 

65 - `incomplete_details: object { reason } or null`

66 

67 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

68 

69 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

70 

71 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

72 

73 - `"max_completion_tokens"`

74 

75 - `"max_prompt_tokens"`

76 

77 - `instructions: string`

78 

79 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

80 

81 - `last_error: object { code, message } or null`

82 

83 The last error associated with this run. Will be `null` if there are no errors.

84 

85 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

86 

87 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

88 

89 - `"server_error"`

90 

91 - `"rate_limit_exceeded"`

92 

93 - `"invalid_prompt"`

94 

95 - `message: string`

96 

97 A human-readable description of the error.

98 

99 - `max_completion_tokens: number or null`

100 

101 The maximum number of completion tokens specified to have been used over the course of the run.

102 

103 - `max_prompt_tokens: number or null`

104 

105 The maximum number of prompt tokens specified to have been used over the course of the run.

106 

107 - `metadata: Metadata or null`

108 

109 Set of 16 key-value pairs that can be attached to an object. This can be

110 useful for storing additional information about the object in a structured

111 format, and querying for objects via API or the dashboard.

112 

113 Keys are strings with a maximum length of 64 characters. Values are strings

114 with a maximum length of 512 characters.

115 

116 - `model: string`

117 

118 The model that the [assistant](/docs/api-reference/assistants) used for this run.

119 

120 - `object: "thread.run"`

121 

122 The object type, which is always `thread.run`.

123 

124 - `"thread.run"`

125 

126 - `parallel_tool_calls: boolean`

127 

128 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

129 

130 - `required_action: object { submit_tool_outputs, type } or null`

131 

132 Details on the action required to continue the run. Will be `null` if no action is required.

133 

134 - `submit_tool_outputs: object { tool_calls }`

135 

136 Details on the tool outputs needed for this run to continue.

137 

138 - `tool_calls: array of RequiredActionFunctionToolCall`

139 

140 A list of the relevant tool calls.

141 

142 - `id: string`

143 

144 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

145 

146 - `function: object { arguments, name }`

147 

148 The function definition.

149 

150 - `arguments: string`

151 

152 The arguments that the model expects you to pass to the function.

153 

154 - `name: string`

155 

156 The name of the function.

157 

158 - `type: "function"`

159 

160 The type of tool call the output is required for. For now, this is always `function`.

161 

162 - `"function"`

163 

164 - `type: "submit_tool_outputs"`

165 

166 For now, this is always `submit_tool_outputs`.

167 

168 - `"submit_tool_outputs"`

169 

170 - `response_format: AssistantResponseFormatOption or null`

171 

172 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

173 

174 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

175 

176 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

177 

178 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

179 

180 - `"auto"`

181 

182 `auto` is the default value

183 

184 - `"auto"`

185 

186 - `ResponseFormatText object { type }`

187 

188 Default response format. Used to generate text responses.

189 

190 - `type: "text"`

191 

192 The type of response format being defined. Always `text`.

193 

194 - `"text"`

195 

196 - `ResponseFormatJSONObject object { type }`

197 

198 JSON object response format. An older method of generating JSON responses.

199 Using `json_schema` is recommended for models that support it. Note that the

200 model will not generate JSON without a system or user message instructing it

201 to do so.

202 

203 - `type: "json_object"`

204 

205 The type of response format being defined. Always `json_object`.

206 

207 - `"json_object"`

208 

209 - `ResponseFormatJSONSchema object { json_schema, type }`

210 

211 JSON Schema response format. Used to generate structured JSON responses.

212 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

213 

214 - `json_schema: object { name, description, schema, strict }`

215 

216 Structured Outputs configuration options, including a JSON Schema.

217 

218 - `name: string`

219 

220 The name of the response format. Must be a-z, A-Z, 0-9, or contain

221 underscores and dashes, with a maximum length of 64.

222 

223 - `description: optional string`

224 

225 A description of what the response format is for, used by the model to

226 determine how to respond in the format.

227 

228 - `schema: optional map[unknown]`

229 

230 The schema for the response format, described as a JSON Schema object.

231 Learn how to build JSON schemas [here](https://json-schema.org/).

232 

233 - `strict: optional boolean or null`

234 

235 Whether to enable strict schema adherence when generating the output.

236 If set to true, the model will always follow the exact schema defined

237 in the `schema` field. Only a subset of JSON Schema is supported when

238 `strict` is `true`. To learn more, read the [Structured Outputs

239 guide](/docs/guides/structured-outputs).

240 

241 - `type: "json_schema"`

242 

243 The type of response format being defined. Always `json_schema`.

244 

245 - `"json_schema"`

246 

247 - `started_at: number or null`

248 

249 The Unix timestamp (in seconds) for when the run was started.

250 

251 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

252 

253 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

254 

255 - `"queued"`

256 

257 - `"in_progress"`

258 

259 - `"requires_action"`

260 

261 - `"cancelling"`

262 

263 - `"cancelled"`

264 

265 - `"failed"`

266 

267 - `"completed"`

268 

269 - `"incomplete"`

270 

271 - `"expired"`

272 

273 - `thread_id: string`

274 

275 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

276 

277 - `tool_choice: AssistantToolChoiceOption or null`

278 

279 Controls which (if any) tool is called by the model.

280 `none` means the model will not call any tools and instead generates a message.

281 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

282 `required` means the model must call one or more tools before responding to the user.

283 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

284 

285 - `"none" or "auto" or "required"`

286 

287 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

288 

289 - `"none"`

290 

291 - `"auto"`

292 

293 - `"required"`

294 

295 - `AssistantToolChoice object { type, function }`

296 

297 Specifies a tool the model should use. Use to force the model to call a specific tool.

298 

299 - `type: "function" or "code_interpreter" or "file_search"`

300 

301 The type of the tool. If type is `function`, the function name must be set

302 

303 - `"function"`

304 

305 - `"code_interpreter"`

306 

307 - `"file_search"`

308 

309 - `function: optional AssistantToolChoiceFunction`

310 

311 - `name: string`

312 

313 The name of the function to call.

314 

315 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

316 

317 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

318 

319 - `CodeInterpreterTool object { type }`

320 

321 - `type: "code_interpreter"`

322 

323 The type of tool being defined: `code_interpreter`

324 

325 - `"code_interpreter"`

326 

327 - `FileSearchTool object { type, file_search }`

328 

329 - `type: "file_search"`

330 

331 The type of tool being defined: `file_search`

332 

333 - `"file_search"`

334 

335 - `file_search: optional object { max_num_results, ranking_options }`

336 

337 Overrides for the file search tool.

338 

339 - `max_num_results: optional number`

340 

341 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

342 

343 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

344 

345 - `ranking_options: optional object { score_threshold, ranker }`

346 

347 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

348 

349 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

350 

351 - `score_threshold: number`

352 

353 The score threshold for the file search. All values must be a floating point number between 0 and 1.

354 

355 - `ranker: optional "auto" or "default_2024_08_21"`

356 

357 The ranker to use for the file search. If not specified will use the `auto` ranker.

358 

359 - `"auto"`

360 

361 - `"default_2024_08_21"`

362 

363 - `FunctionTool object { function, type }`

364 

365 - `function: FunctionDefinition`

366 

367 - `name: string`

368 

369 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

370 

371 - `description: optional string`

372 

373 A description of what the function does, used by the model to choose when and how to call the function.

374 

375 - `parameters: optional FunctionParameters`

376 

377 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

378 

379 Omitting `parameters` defines a function with an empty parameter list.

380 

381 - `strict: optional boolean or null`

382 

383 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

384 

385 - `type: "function"`

386 

387 The type of tool being defined: `function`

388 

389 - `"function"`

390 

391 - `truncation_strategy: object { type, last_messages } or null`

392 

393 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

394 

395 - `type: "auto" or "last_messages"`

396 

397 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

398 

399 - `"auto"`

400 

401 - `"last_messages"`

402 

403 - `last_messages: optional number or null`

404 

405 The number of most recent messages from the thread when constructing the context for the run.

406 

407 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

408 

409 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

410 

411 - `completion_tokens: number`

412 

413 Number of completion tokens used over the course of the run.

414 

415 - `prompt_tokens: number`

416 

417 Number of prompt tokens used over the course of the run.

418 

419 - `total_tokens: number`

420 

421 Total number of tokens used (prompt + completion).

422 

423 - `temperature: optional number or null`

424 

425 The sampling temperature used for this run. If not set, defaults to 1.

426 

427 - `top_p: optional number or null`

428 

429 The nucleus sampling value used for this run. If not set, defaults to 1.

430 

431- `first_id: string`

432 

433- `has_more: boolean`

434 

435- `last_id: string`

436 

437- `object: string`

438 

439### Example

440 

441```http

442curl https://api.openai.com/v1/threads/$THREAD_ID/runs \

443 -H 'OpenAI-Beta: assistants=v2' \

444 -H "Authorization: Bearer $OPENAI_API_KEY"

445```

446 

447#### Response

448 

449```json

450{

451 "data": [

452 {

453 "id": "id",

454 "assistant_id": "assistant_id",

455 "cancelled_at": 0,

456 "completed_at": 0,

457 "created_at": 0,

458 "expires_at": 0,

459 "failed_at": 0,

460 "incomplete_details": {

461 "reason": "max_completion_tokens"

462 },

463 "instructions": "instructions",

464 "last_error": {

465 "code": "server_error",

466 "message": "message"

467 },

468 "max_completion_tokens": 256,

469 "max_prompt_tokens": 256,

470 "metadata": {

471 "foo": "string"

472 },

473 "model": "model",

474 "object": "thread.run",

475 "parallel_tool_calls": true,

476 "required_action": {

477 "submit_tool_outputs": {

478 "tool_calls": [

479 {

480 "id": "id",

481 "function": {

482 "arguments": "arguments",

483 "name": "name"

484 },

485 "type": "function"

486 }

487 ]

488 },

489 "type": "submit_tool_outputs"

490 },

491 "response_format": "auto",

492 "started_at": 0,

493 "status": "queued",

494 "thread_id": "thread_id",

495 "tool_choice": "none",

496 "tools": [

497 {

498 "type": "code_interpreter"

499 }

500 ],

501 "truncation_strategy": {

502 "type": "auto",

503 "last_messages": 1

504 },

505 "usage": {

506 "completion_tokens": 0,

507 "prompt_tokens": 0,

508 "total_tokens": 0

509 },

510 "temperature": 0,

511 "top_p": 0

512 }

513 ],

514 "first_id": "run_abc123",

515 "has_more": false,

516 "last_id": "run_abc456",

517 "object": "list"

518}

519```

520 

521### Example

522 

523```http

524curl https://api.openai.com/v1/threads/thread_abc123/runs \

525 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

527 -H "OpenAI-Beta: assistants=v2"

528```

529 

530#### Response

531 

532```json

533{

534 "object": "list",

535 "data": [

536 {

537 "id": "run_abc123",

538 "object": "thread.run",

539 "created_at": 1699075072,

540 "assistant_id": "asst_abc123",

541 "thread_id": "thread_abc123",

542 "status": "completed",

543 "started_at": 1699075072,

544 "expires_at": null,

545 "cancelled_at": null,

546 "failed_at": null,

547 "completed_at": 1699075073,

548 "last_error": null,

549 "model": "gpt-4o",

550 "instructions": null,

551 "incomplete_details": null,

552 "tools": [

553 {

554 "type": "code_interpreter"

555 }

556 ],

557 "tool_resources": {

558 "code_interpreter": {

559 "file_ids": [

560 "file-abc123",

561 "file-abc456"

562 ]

563 }

564 },

565 "metadata": {},

566 "usage": {

567 "prompt_tokens": 123,

568 "completion_tokens": 456,

569 "total_tokens": 579

570 },

571 "temperature": 1.0,

572 "top_p": 1.0,

573 "max_prompt_tokens": 1000,

574 "max_completion_tokens": 1000,

575 "truncation_strategy": {

576 "type": "auto",

577 "last_messages": null

578 },

579 "response_format": "auto",

580 "tool_choice": "auto",

581 "parallel_tool_calls": true

582 },

583 {

584 "id": "run_abc456",

585 "object": "thread.run",

586 "created_at": 1699063290,

587 "assistant_id": "asst_abc123",

588 "thread_id": "thread_abc123",

589 "status": "completed",

590 "started_at": 1699063290,

591 "expires_at": null,

592 "cancelled_at": null,

593 "failed_at": null,

594 "completed_at": 1699063291,

595 "last_error": null,

596 "model": "gpt-4o",

597 "instructions": null,

598 "incomplete_details": null,

599 "tools": [

600 {

601 "type": "code_interpreter"

602 }

603 ],

604 "tool_resources": {

605 "code_interpreter": {

606 "file_ids": [

607 "file-abc123",

608 "file-abc456"

609 ]

610 }

611 },

612 "metadata": {},

613 "usage": {

614 "prompt_tokens": 123,

615 "completion_tokens": 456,

616 "total_tokens": 579

617 },

618 "temperature": 1.0,

619 "top_p": 1.0,

620 "max_prompt_tokens": 1000,

621 "max_completion_tokens": 1000,

622 "truncation_strategy": {

623 "type": "auto",

624 "last_messages": null

625 },

626 "response_format": "auto",

627 "tool_choice": "auto",

628 "parallel_tool_calls": true

629 }

630 ],

631 "first_id": "run_abc123",

632 "last_id": "run_abc456",

633 "has_more": false

634}

635```

resources/beta/subresources/threads/subresources/runs/methods/retrieve/index.md +0 −537 deleted

File Deleted View Diff

1## Retrieve run

2 

3**get** `/threads/{thread_id}/runs/{run_id}`

4 

5Retrieves a run.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `run_id: string`

12 

13### Returns

14 

15- `Run object { id, assistant_id, cancelled_at, 24 more }`

16 

17 Represents an execution run on a [thread](/docs/api-reference/threads).

18 

19 - `id: string`

20 

21 The identifier, which can be referenced in API endpoints.

22 

23 - `assistant_id: string`

24 

25 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

26 

27 - `cancelled_at: number or null`

28 

29 The Unix timestamp (in seconds) for when the run was cancelled.

30 

31 - `completed_at: number or null`

32 

33 The Unix timestamp (in seconds) for when the run was completed.

34 

35 - `created_at: number`

36 

37 The Unix timestamp (in seconds) for when the run was created.

38 

39 - `expires_at: number or null`

40 

41 The Unix timestamp (in seconds) for when the run will expire.

42 

43 - `failed_at: number or null`

44 

45 The Unix timestamp (in seconds) for when the run failed.

46 

47 - `incomplete_details: object { reason } or null`

48 

49 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

50 

51 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

52 

53 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

54 

55 - `"max_completion_tokens"`

56 

57 - `"max_prompt_tokens"`

58 

59 - `instructions: string`

60 

61 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

62 

63 - `last_error: object { code, message } or null`

64 

65 The last error associated with this run. Will be `null` if there are no errors.

66 

67 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

68 

69 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

70 

71 - `"server_error"`

72 

73 - `"rate_limit_exceeded"`

74 

75 - `"invalid_prompt"`

76 

77 - `message: string`

78 

79 A human-readable description of the error.

80 

81 - `max_completion_tokens: number or null`

82 

83 The maximum number of completion tokens specified to have been used over the course of the run.

84 

85 - `max_prompt_tokens: number or null`

86 

87 The maximum number of prompt tokens specified to have been used over the course of the run.

88 

89 - `metadata: Metadata or null`

90 

91 Set of 16 key-value pairs that can be attached to an object. This can be

92 useful for storing additional information about the object in a structured

93 format, and querying for objects via API or the dashboard.

94 

95 Keys are strings with a maximum length of 64 characters. Values are strings

96 with a maximum length of 512 characters.

97 

98 - `model: string`

99 

100 The model that the [assistant](/docs/api-reference/assistants) used for this run.

101 

102 - `object: "thread.run"`

103 

104 The object type, which is always `thread.run`.

105 

106 - `"thread.run"`

107 

108 - `parallel_tool_calls: boolean`

109 

110 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

111 

112 - `required_action: object { submit_tool_outputs, type } or null`

113 

114 Details on the action required to continue the run. Will be `null` if no action is required.

115 

116 - `submit_tool_outputs: object { tool_calls }`

117 

118 Details on the tool outputs needed for this run to continue.

119 

120 - `tool_calls: array of RequiredActionFunctionToolCall`

121 

122 A list of the relevant tool calls.

123 

124 - `id: string`

125 

126 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

127 

128 - `function: object { arguments, name }`

129 

130 The function definition.

131 

132 - `arguments: string`

133 

134 The arguments that the model expects you to pass to the function.

135 

136 - `name: string`

137 

138 The name of the function.

139 

140 - `type: "function"`

141 

142 The type of tool call the output is required for. For now, this is always `function`.

143 

144 - `"function"`

145 

146 - `type: "submit_tool_outputs"`

147 

148 For now, this is always `submit_tool_outputs`.

149 

150 - `"submit_tool_outputs"`

151 

152 - `response_format: AssistantResponseFormatOption or null`

153 

154 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

155 

156 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

157 

158 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

159 

160 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

161 

162 - `"auto"`

163 

164 `auto` is the default value

165 

166 - `"auto"`

167 

168 - `ResponseFormatText object { type }`

169 

170 Default response format. Used to generate text responses.

171 

172 - `type: "text"`

173 

174 The type of response format being defined. Always `text`.

175 

176 - `"text"`

177 

178 - `ResponseFormatJSONObject object { type }`

179 

180 JSON object response format. An older method of generating JSON responses.

181 Using `json_schema` is recommended for models that support it. Note that the

182 model will not generate JSON without a system or user message instructing it

183 to do so.

184 

185 - `type: "json_object"`

186 

187 The type of response format being defined. Always `json_object`.

188 

189 - `"json_object"`

190 

191 - `ResponseFormatJSONSchema object { json_schema, type }`

192 

193 JSON Schema response format. Used to generate structured JSON responses.

194 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

195 

196 - `json_schema: object { name, description, schema, strict }`

197 

198 Structured Outputs configuration options, including a JSON Schema.

199 

200 - `name: string`

201 

202 The name of the response format. Must be a-z, A-Z, 0-9, or contain

203 underscores and dashes, with a maximum length of 64.

204 

205 - `description: optional string`

206 

207 A description of what the response format is for, used by the model to

208 determine how to respond in the format.

209 

210 - `schema: optional map[unknown]`

211 

212 The schema for the response format, described as a JSON Schema object.

213 Learn how to build JSON schemas [here](https://json-schema.org/).

214 

215 - `strict: optional boolean or null`

216 

217 Whether to enable strict schema adherence when generating the output.

218 If set to true, the model will always follow the exact schema defined

219 in the `schema` field. Only a subset of JSON Schema is supported when

220 `strict` is `true`. To learn more, read the [Structured Outputs

221 guide](/docs/guides/structured-outputs).

222 

223 - `type: "json_schema"`

224 

225 The type of response format being defined. Always `json_schema`.

226 

227 - `"json_schema"`

228 

229 - `started_at: number or null`

230 

231 The Unix timestamp (in seconds) for when the run was started.

232 

233 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

234 

235 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

236 

237 - `"queued"`

238 

239 - `"in_progress"`

240 

241 - `"requires_action"`

242 

243 - `"cancelling"`

244 

245 - `"cancelled"`

246 

247 - `"failed"`

248 

249 - `"completed"`

250 

251 - `"incomplete"`

252 

253 - `"expired"`

254 

255 - `thread_id: string`

256 

257 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

258 

259 - `tool_choice: AssistantToolChoiceOption or null`

260 

261 Controls which (if any) tool is called by the model.

262 `none` means the model will not call any tools and instead generates a message.

263 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

264 `required` means the model must call one or more tools before responding to the user.

265 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

266 

267 - `"none" or "auto" or "required"`

268 

269 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

270 

271 - `"none"`

272 

273 - `"auto"`

274 

275 - `"required"`

276 

277 - `AssistantToolChoice object { type, function }`

278 

279 Specifies a tool the model should use. Use to force the model to call a specific tool.

280 

281 - `type: "function" or "code_interpreter" or "file_search"`

282 

283 The type of the tool. If type is `function`, the function name must be set

284 

285 - `"function"`

286 

287 - `"code_interpreter"`

288 

289 - `"file_search"`

290 

291 - `function: optional AssistantToolChoiceFunction`

292 

293 - `name: string`

294 

295 The name of the function to call.

296 

297 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

298 

299 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

300 

301 - `CodeInterpreterTool object { type }`

302 

303 - `type: "code_interpreter"`

304 

305 The type of tool being defined: `code_interpreter`

306 

307 - `"code_interpreter"`

308 

309 - `FileSearchTool object { type, file_search }`

310 

311 - `type: "file_search"`

312 

313 The type of tool being defined: `file_search`

314 

315 - `"file_search"`

316 

317 - `file_search: optional object { max_num_results, ranking_options }`

318 

319 Overrides for the file search tool.

320 

321 - `max_num_results: optional number`

322 

323 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

324 

325 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

326 

327 - `ranking_options: optional object { score_threshold, ranker }`

328 

329 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

330 

331 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

332 

333 - `score_threshold: number`

334 

335 The score threshold for the file search. All values must be a floating point number between 0 and 1.

336 

337 - `ranker: optional "auto" or "default_2024_08_21"`

338 

339 The ranker to use for the file search. If not specified will use the `auto` ranker.

340 

341 - `"auto"`

342 

343 - `"default_2024_08_21"`

344 

345 - `FunctionTool object { function, type }`

346 

347 - `function: FunctionDefinition`

348 

349 - `name: string`

350 

351 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

352 

353 - `description: optional string`

354 

355 A description of what the function does, used by the model to choose when and how to call the function.

356 

357 - `parameters: optional FunctionParameters`

358 

359 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

360 

361 Omitting `parameters` defines a function with an empty parameter list.

362 

363 - `strict: optional boolean or null`

364 

365 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

366 

367 - `type: "function"`

368 

369 The type of tool being defined: `function`

370 

371 - `"function"`

372 

373 - `truncation_strategy: object { type, last_messages } or null`

374 

375 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

376 

377 - `type: "auto" or "last_messages"`

378 

379 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

380 

381 - `"auto"`

382 

383 - `"last_messages"`

384 

385 - `last_messages: optional number or null`

386 

387 The number of most recent messages from the thread when constructing the context for the run.

388 

389 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

390 

391 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

392 

393 - `completion_tokens: number`

394 

395 Number of completion tokens used over the course of the run.

396 

397 - `prompt_tokens: number`

398 

399 Number of prompt tokens used over the course of the run.

400 

401 - `total_tokens: number`

402 

403 Total number of tokens used (prompt + completion).

404 

405 - `temperature: optional number or null`

406 

407 The sampling temperature used for this run. If not set, defaults to 1.

408 

409 - `top_p: optional number or null`

410 

411 The nucleus sampling value used for this run. If not set, defaults to 1.

412 

413### Example

414 

415```http

416curl https://api.openai.com/v1/threads/$THREAD_ID/runs/$RUN_ID \

417 -H 'OpenAI-Beta: assistants=v2' \

418 -H "Authorization: Bearer $OPENAI_API_KEY"

419```

420 

421#### Response

422 

423```json

424{

425 "id": "id",

426 "assistant_id": "assistant_id",

427 "cancelled_at": 0,

428 "completed_at": 0,

429 "created_at": 0,

430 "expires_at": 0,

431 "failed_at": 0,

432 "incomplete_details": {

433 "reason": "max_completion_tokens"

434 },

435 "instructions": "instructions",

436 "last_error": {

437 "code": "server_error",

438 "message": "message"

439 },

440 "max_completion_tokens": 256,

441 "max_prompt_tokens": 256,

442 "metadata": {

443 "foo": "string"

444 },

445 "model": "model",

446 "object": "thread.run",

447 "parallel_tool_calls": true,

448 "required_action": {

449 "submit_tool_outputs": {

450 "tool_calls": [

451 {

452 "id": "id",

453 "function": {

454 "arguments": "arguments",

455 "name": "name"

456 },

457 "type": "function"

458 }

459 ]

460 },

461 "type": "submit_tool_outputs"

462 },

463 "response_format": "auto",

464 "started_at": 0,

465 "status": "queued",

466 "thread_id": "thread_id",

467 "tool_choice": "none",

468 "tools": [

469 {

470 "type": "code_interpreter"

471 }

472 ],

473 "truncation_strategy": {

474 "type": "auto",

475 "last_messages": 1

476 },

477 "usage": {

478 "completion_tokens": 0,

479 "prompt_tokens": 0,

480 "total_tokens": 0

481 },

482 "temperature": 0,

483 "top_p": 0

484}

485```

486 

487### Example

488 

489```http

490curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \

491 -H "Authorization: Bearer $OPENAI_API_KEY" \

492 -H "OpenAI-Beta: assistants=v2"

493```

494 

495#### Response

496 

497```json

498{

499 "id": "run_abc123",

500 "object": "thread.run",

501 "created_at": 1699075072,

502 "assistant_id": "asst_abc123",

503 "thread_id": "thread_abc123",

504 "status": "completed",

505 "started_at": 1699075072,

506 "expires_at": null,

507 "cancelled_at": null,

508 "failed_at": null,

509 "completed_at": 1699075073,

510 "last_error": null,

511 "model": "gpt-4o",

512 "instructions": null,

513 "incomplete_details": null,

514 "tools": [

515 {

516 "type": "code_interpreter"

517 }

518 ],

519 "metadata": {},

520 "usage": {

521 "prompt_tokens": 123,

522 "completion_tokens": 456,

523 "total_tokens": 579

524 },

525 "temperature": 1.0,

526 "top_p": 1.0,

527 "max_prompt_tokens": 1000,

528 "max_completion_tokens": 1000,

529 "truncation_strategy": {

530 "type": "auto",

531 "last_messages": null

532 },

533 "response_format": "auto",

534 "tool_choice": "auto",

535 "parallel_tool_calls": true

536}

537```

resources/beta/subresources/threads/subresources/runs/methods/submit_tool_outputs/index.md +0 −655 deleted

File Deleted View Diff

1## Submit tool outputs to run

2 

3**post** `/threads/{thread_id}/runs/{run_id}/submit_tool_outputs`

4 

5When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `run_id: string`

12 

13### Body Parameters

14 

15- `tool_outputs: array of object { output, tool_call_id }`

16 

17 A list of tools for which the outputs are being submitted.

18 

19 - `output: optional string`

20 

21 The output of the tool call to be submitted to continue the run.

22 

23 - `tool_call_id: optional string`

24 

25 The ID of the tool call in the `required_action` object within the run object the output is being submitted for.

26 

27- `stream: optional boolean or null`

28 

29 If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.

30 

31### Returns

32 

33- `Run object { id, assistant_id, cancelled_at, 24 more }`

34 

35 Represents an execution run on a [thread](/docs/api-reference/threads).

36 

37 - `id: string`

38 

39 The identifier, which can be referenced in API endpoints.

40 

41 - `assistant_id: string`

42 

43 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

44 

45 - `cancelled_at: number or null`

46 

47 The Unix timestamp (in seconds) for when the run was cancelled.

48 

49 - `completed_at: number or null`

50 

51 The Unix timestamp (in seconds) for when the run was completed.

52 

53 - `created_at: number`

54 

55 The Unix timestamp (in seconds) for when the run was created.

56 

57 - `expires_at: number or null`

58 

59 The Unix timestamp (in seconds) for when the run will expire.

60 

61 - `failed_at: number or null`

62 

63 The Unix timestamp (in seconds) for when the run failed.

64 

65 - `incomplete_details: object { reason } or null`

66 

67 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

68 

69 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

70 

71 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

72 

73 - `"max_completion_tokens"`

74 

75 - `"max_prompt_tokens"`

76 

77 - `instructions: string`

78 

79 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

80 

81 - `last_error: object { code, message } or null`

82 

83 The last error associated with this run. Will be `null` if there are no errors.

84 

85 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

86 

87 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

88 

89 - `"server_error"`

90 

91 - `"rate_limit_exceeded"`

92 

93 - `"invalid_prompt"`

94 

95 - `message: string`

96 

97 A human-readable description of the error.

98 

99 - `max_completion_tokens: number or null`

100 

101 The maximum number of completion tokens specified to have been used over the course of the run.

102 

103 - `max_prompt_tokens: number or null`

104 

105 The maximum number of prompt tokens specified to have been used over the course of the run.

106 

107 - `metadata: Metadata or null`

108 

109 Set of 16 key-value pairs that can be attached to an object. This can be

110 useful for storing additional information about the object in a structured

111 format, and querying for objects via API or the dashboard.

112 

113 Keys are strings with a maximum length of 64 characters. Values are strings

114 with a maximum length of 512 characters.

115 

116 - `model: string`

117 

118 The model that the [assistant](/docs/api-reference/assistants) used for this run.

119 

120 - `object: "thread.run"`

121 

122 The object type, which is always `thread.run`.

123 

124 - `"thread.run"`

125 

126 - `parallel_tool_calls: boolean`

127 

128 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

129 

130 - `required_action: object { submit_tool_outputs, type } or null`

131 

132 Details on the action required to continue the run. Will be `null` if no action is required.

133 

134 - `submit_tool_outputs: object { tool_calls }`

135 

136 Details on the tool outputs needed for this run to continue.

137 

138 - `tool_calls: array of RequiredActionFunctionToolCall`

139 

140 A list of the relevant tool calls.

141 

142 - `id: string`

143 

144 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

145 

146 - `function: object { arguments, name }`

147 

148 The function definition.

149 

150 - `arguments: string`

151 

152 The arguments that the model expects you to pass to the function.

153 

154 - `name: string`

155 

156 The name of the function.

157 

158 - `type: "function"`

159 

160 The type of tool call the output is required for. For now, this is always `function`.

161 

162 - `"function"`

163 

164 - `type: "submit_tool_outputs"`

165 

166 For now, this is always `submit_tool_outputs`.

167 

168 - `"submit_tool_outputs"`

169 

170 - `response_format: AssistantResponseFormatOption or null`

171 

172 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

173 

174 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

175 

176 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

177 

178 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

179 

180 - `"auto"`

181 

182 `auto` is the default value

183 

184 - `"auto"`

185 

186 - `ResponseFormatText object { type }`

187 

188 Default response format. Used to generate text responses.

189 

190 - `type: "text"`

191 

192 The type of response format being defined. Always `text`.

193 

194 - `"text"`

195 

196 - `ResponseFormatJSONObject object { type }`

197 

198 JSON object response format. An older method of generating JSON responses.

199 Using `json_schema` is recommended for models that support it. Note that the

200 model will not generate JSON without a system or user message instructing it

201 to do so.

202 

203 - `type: "json_object"`

204 

205 The type of response format being defined. Always `json_object`.

206 

207 - `"json_object"`

208 

209 - `ResponseFormatJSONSchema object { json_schema, type }`

210 

211 JSON Schema response format. Used to generate structured JSON responses.

212 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

213 

214 - `json_schema: object { name, description, schema, strict }`

215 

216 Structured Outputs configuration options, including a JSON Schema.

217 

218 - `name: string`

219 

220 The name of the response format. Must be a-z, A-Z, 0-9, or contain

221 underscores and dashes, with a maximum length of 64.

222 

223 - `description: optional string`

224 

225 A description of what the response format is for, used by the model to

226 determine how to respond in the format.

227 

228 - `schema: optional map[unknown]`

229 

230 The schema for the response format, described as a JSON Schema object.

231 Learn how to build JSON schemas [here](https://json-schema.org/).

232 

233 - `strict: optional boolean or null`

234 

235 Whether to enable strict schema adherence when generating the output.

236 If set to true, the model will always follow the exact schema defined

237 in the `schema` field. Only a subset of JSON Schema is supported when

238 `strict` is `true`. To learn more, read the [Structured Outputs

239 guide](/docs/guides/structured-outputs).

240 

241 - `type: "json_schema"`

242 

243 The type of response format being defined. Always `json_schema`.

244 

245 - `"json_schema"`

246 

247 - `started_at: number or null`

248 

249 The Unix timestamp (in seconds) for when the run was started.

250 

251 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

252 

253 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

254 

255 - `"queued"`

256 

257 - `"in_progress"`

258 

259 - `"requires_action"`

260 

261 - `"cancelling"`

262 

263 - `"cancelled"`

264 

265 - `"failed"`

266 

267 - `"completed"`

268 

269 - `"incomplete"`

270 

271 - `"expired"`

272 

273 - `thread_id: string`

274 

275 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

276 

277 - `tool_choice: AssistantToolChoiceOption or null`

278 

279 Controls which (if any) tool is called by the model.

280 `none` means the model will not call any tools and instead generates a message.

281 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

282 `required` means the model must call one or more tools before responding to the user.

283 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

284 

285 - `"none" or "auto" or "required"`

286 

287 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

288 

289 - `"none"`

290 

291 - `"auto"`

292 

293 - `"required"`

294 

295 - `AssistantToolChoice object { type, function }`

296 

297 Specifies a tool the model should use. Use to force the model to call a specific tool.

298 

299 - `type: "function" or "code_interpreter" or "file_search"`

300 

301 The type of the tool. If type is `function`, the function name must be set

302 

303 - `"function"`

304 

305 - `"code_interpreter"`

306 

307 - `"file_search"`

308 

309 - `function: optional AssistantToolChoiceFunction`

310 

311 - `name: string`

312 

313 The name of the function to call.

314 

315 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

316 

317 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

318 

319 - `CodeInterpreterTool object { type }`

320 

321 - `type: "code_interpreter"`

322 

323 The type of tool being defined: `code_interpreter`

324 

325 - `"code_interpreter"`

326 

327 - `FileSearchTool object { type, file_search }`

328 

329 - `type: "file_search"`

330 

331 The type of tool being defined: `file_search`

332 

333 - `"file_search"`

334 

335 - `file_search: optional object { max_num_results, ranking_options }`

336 

337 Overrides for the file search tool.

338 

339 - `max_num_results: optional number`

340 

341 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

342 

343 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

344 

345 - `ranking_options: optional object { score_threshold, ranker }`

346 

347 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

348 

349 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

350 

351 - `score_threshold: number`

352 

353 The score threshold for the file search. All values must be a floating point number between 0 and 1.

354 

355 - `ranker: optional "auto" or "default_2024_08_21"`

356 

357 The ranker to use for the file search. If not specified will use the `auto` ranker.

358 

359 - `"auto"`

360 

361 - `"default_2024_08_21"`

362 

363 - `FunctionTool object { function, type }`

364 

365 - `function: FunctionDefinition`

366 

367 - `name: string`

368 

369 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

370 

371 - `description: optional string`

372 

373 A description of what the function does, used by the model to choose when and how to call the function.

374 

375 - `parameters: optional FunctionParameters`

376 

377 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

378 

379 Omitting `parameters` defines a function with an empty parameter list.

380 

381 - `strict: optional boolean or null`

382 

383 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

384 

385 - `type: "function"`

386 

387 The type of tool being defined: `function`

388 

389 - `"function"`

390 

391 - `truncation_strategy: object { type, last_messages } or null`

392 

393 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

394 

395 - `type: "auto" or "last_messages"`

396 

397 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

398 

399 - `"auto"`

400 

401 - `"last_messages"`

402 

403 - `last_messages: optional number or null`

404 

405 The number of most recent messages from the thread when constructing the context for the run.

406 

407 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

408 

409 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

410 

411 - `completion_tokens: number`

412 

413 Number of completion tokens used over the course of the run.

414 

415 - `prompt_tokens: number`

416 

417 Number of prompt tokens used over the course of the run.

418 

419 - `total_tokens: number`

420 

421 Total number of tokens used (prompt + completion).

422 

423 - `temperature: optional number or null`

424 

425 The sampling temperature used for this run. If not set, defaults to 1.

426 

427 - `top_p: optional number or null`

428 

429 The nucleus sampling value used for this run. If not set, defaults to 1.

430 

431### Example

432 

433```http

434curl https://api.openai.com/v1/threads/$THREAD_ID/runs/$RUN_ID/submit_tool_outputs \

435 -H 'Content-Type: application/json' \

436 -H 'OpenAI-Beta: assistants=v2' \

437 -H "Authorization: Bearer $OPENAI_API_KEY" \

438 -d '{

439 "tool_outputs": [

440 {}

441 ]

442 }'

443```

444 

445#### Response

446 

447```json

448{

449 "id": "id",

450 "assistant_id": "assistant_id",

451 "cancelled_at": 0,

452 "completed_at": 0,

453 "created_at": 0,

454 "expires_at": 0,

455 "failed_at": 0,

456 "incomplete_details": {

457 "reason": "max_completion_tokens"

458 },

459 "instructions": "instructions",

460 "last_error": {

461 "code": "server_error",

462 "message": "message"

463 },

464 "max_completion_tokens": 256,

465 "max_prompt_tokens": 256,

466 "metadata": {

467 "foo": "string"

468 },

469 "model": "model",

470 "object": "thread.run",

471 "parallel_tool_calls": true,

472 "required_action": {

473 "submit_tool_outputs": {

474 "tool_calls": [

475 {

476 "id": "id",

477 "function": {

478 "arguments": "arguments",

479 "name": "name"

480 },

481 "type": "function"

482 }

483 ]

484 },

485 "type": "submit_tool_outputs"

486 },

487 "response_format": "auto",

488 "started_at": 0,

489 "status": "queued",

490 "thread_id": "thread_id",

491 "tool_choice": "none",

492 "tools": [

493 {

494 "type": "code_interpreter"

495 }

496 ],

497 "truncation_strategy": {

498 "type": "auto",

499 "last_messages": 1

500 },

501 "usage": {

502 "completion_tokens": 0,

503 "prompt_tokens": 0,

504 "total_tokens": 0

505 },

506 "temperature": 0,

507 "top_p": 0

508}

509```

510 

511### Example

512 

513```http

514curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \

515 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

517 -H "OpenAI-Beta: assistants=v2" \

518 -d '{

519 "tool_outputs": [

520 {

521 "tool_call_id": "call_001",

522 "output": "70 degrees and sunny."

523 }

524 ]

525 }'

526```

527 

528#### Response

529 

530```json

531{

532 "id": "run_123",

533 "object": "thread.run",

534 "created_at": 1699075592,

535 "assistant_id": "asst_123",

536 "thread_id": "thread_123",

537 "status": "queued",

538 "started_at": 1699075592,

539 "expires_at": 1699076192,

540 "cancelled_at": null,

541 "failed_at": null,

542 "completed_at": null,

543 "last_error": null,

544 "model": "gpt-4o",

545 "instructions": null,

546 "tools": [

547 {

548 "type": "function",

549 "function": {

550 "name": "get_current_weather",

551 "description": "Get the current weather in a given location",

552 "parameters": {

553 "type": "object",

554 "properties": {

555 "location": {

556 "type": "string",

557 "description": "The city and state, e.g. San Francisco, CA"

558 },

559 "unit": {

560 "type": "string",

561 "enum": ["celsius", "fahrenheit"]

562 }

563 },

564 "required": ["location"]

565 }

566 }

567 }

568 ],

569 "metadata": {},

570 "usage": null,

571 "temperature": 1.0,

572 "top_p": 1.0,

573 "max_prompt_tokens": 1000,

574 "max_completion_tokens": 1000,

575 "truncation_strategy": {

576 "type": "auto",

577 "last_messages": null

578 },

579 "response_format": "auto",

580 "tool_choice": "auto",

581 "parallel_tool_calls": true

582}

583```

584 

585### Streaming

586 

587```http

588curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \

589 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

591 -H "OpenAI-Beta: assistants=v2" \

592 -d '{

593 "tool_outputs": [

594 {

595 "tool_call_id": "call_001",

596 "output": "70 degrees and sunny."

597 }

598 ],

599 "stream": true

600 }'

601```

602 

603#### Response

604 

605```json

606event: thread.run.step.completed

607data: {"id":"step_001","object":"thread.run.step","created_at":1710352449,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"completed","cancelled_at":null,"completed_at":1710352475,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_iWr0kQ2EaYMaxNdl0v3KYkx7","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}","output":"70 degrees and sunny."}}]},"usage":{"prompt_tokens":291,"completion_tokens":24,"total_tokens":315}}

608 

609event: thread.run.queued

610data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":1710352448,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

611 

612event: thread.run.in_progress

613data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710352475,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

614 

615event: thread.run.step.created

616data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null}

617 

618event: thread.run.step.in_progress

619data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null}

620 

621event: thread.message.created

622data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}

623 

624event: thread.message.in_progress

625data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}

626 

627event: thread.message.delta

628data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}}

629 

630event: thread.message.delta

631data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" current"}}]}}

632 

633event: thread.message.delta

634data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" weather"}}]}}

635 

636...

637 

638event: thread.message.delta

639data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" sunny"}}]}}

640 

641event: thread.message.delta

642data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}}

643 

644event: thread.message.completed

645data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710352477,"role":"assistant","content":[{"type":"text","text":{"value":"The current weather in San Francisco, CA is 70 degrees Fahrenheit and sunny.","annotations":[]}}],"metadata":{}}

646 

647event: thread.run.step.completed

648data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710352477,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":{"prompt_tokens":329,"completion_tokens":18,"total_tokens":347}}

649 

650event: thread.run.completed

651data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710352475,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710352477,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}}

652 

653event: done

654data: [DONE]

655```

resources/beta/subresources/threads/subresources/runs/methods/update/index.md +0 −566 deleted

File Deleted View Diff

1## Modify run

2 

3**post** `/threads/{thread_id}/runs/{run_id}`

4 

5Modifies a run.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `run_id: string`

12 

13### Body Parameters

14 

15- `metadata: optional Metadata or null`

16 

17 Set of 16 key-value pairs that can be attached to an object. This can be

18 useful for storing additional information about the object in a structured

19 format, and querying for objects via API or the dashboard.

20 

21 Keys are strings with a maximum length of 64 characters. Values are strings

22 with a maximum length of 512 characters.

23 

24### Returns

25 

26- `Run object { id, assistant_id, cancelled_at, 24 more }`

27 

28 Represents an execution run on a [thread](/docs/api-reference/threads).

29 

30 - `id: string`

31 

32 The identifier, which can be referenced in API endpoints.

33 

34 - `assistant_id: string`

35 

36 The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.

37 

38 - `cancelled_at: number or null`

39 

40 The Unix timestamp (in seconds) for when the run was cancelled.

41 

42 - `completed_at: number or null`

43 

44 The Unix timestamp (in seconds) for when the run was completed.

45 

46 - `created_at: number`

47 

48 The Unix timestamp (in seconds) for when the run was created.

49 

50 - `expires_at: number or null`

51 

52 The Unix timestamp (in seconds) for when the run will expire.

53 

54 - `failed_at: number or null`

55 

56 The Unix timestamp (in seconds) for when the run failed.

57 

58 - `incomplete_details: object { reason } or null`

59 

60 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

61 

62 - `reason: optional "max_completion_tokens" or "max_prompt_tokens"`

63 

64 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

65 

66 - `"max_completion_tokens"`

67 

68 - `"max_prompt_tokens"`

69 

70 - `instructions: string`

71 

72 The instructions that the [assistant](/docs/api-reference/assistants) used for this run.

73 

74 - `last_error: object { code, message } or null`

75 

76 The last error associated with this run. Will be `null` if there are no errors.

77 

78 - `code: "server_error" or "rate_limit_exceeded" or "invalid_prompt"`

79 

80 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

81 

82 - `"server_error"`

83 

84 - `"rate_limit_exceeded"`

85 

86 - `"invalid_prompt"`

87 

88 - `message: string`

89 

90 A human-readable description of the error.

91 

92 - `max_completion_tokens: number or null`

93 

94 The maximum number of completion tokens specified to have been used over the course of the run.

95 

96 - `max_prompt_tokens: number or null`

97 

98 The maximum number of prompt tokens specified to have been used over the course of the run.

99 

100 - `metadata: Metadata or null`

101 

102 Set of 16 key-value pairs that can be attached to an object. This can be

103 useful for storing additional information about the object in a structured

104 format, and querying for objects via API or the dashboard.

105 

106 Keys are strings with a maximum length of 64 characters. Values are strings

107 with a maximum length of 512 characters.

108 

109 - `model: string`

110 

111 The model that the [assistant](/docs/api-reference/assistants) used for this run.

112 

113 - `object: "thread.run"`

114 

115 The object type, which is always `thread.run`.

116 

117 - `"thread.run"`

118 

119 - `parallel_tool_calls: boolean`

120 

121 Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

122 

123 - `required_action: object { submit_tool_outputs, type } or null`

124 

125 Details on the action required to continue the run. Will be `null` if no action is required.

126 

127 - `submit_tool_outputs: object { tool_calls }`

128 

129 Details on the tool outputs needed for this run to continue.

130 

131 - `tool_calls: array of RequiredActionFunctionToolCall`

132 

133 A list of the relevant tool calls.

134 

135 - `id: string`

136 

137 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint.

138 

139 - `function: object { arguments, name }`

140 

141 The function definition.

142 

143 - `arguments: string`

144 

145 The arguments that the model expects you to pass to the function.

146 

147 - `name: string`

148 

149 The name of the function.

150 

151 - `type: "function"`

152 

153 The type of tool call the output is required for. For now, this is always `function`.

154 

155 - `"function"`

156 

157 - `type: "submit_tool_outputs"`

158 

159 For now, this is always `submit_tool_outputs`.

160 

161 - `"submit_tool_outputs"`

162 

163 - `response_format: AssistantResponseFormatOption or null`

164 

165 Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

166 

167 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

168 

169 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

170 

171 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

172 

173 - `"auto"`

174 

175 `auto` is the default value

176 

177 - `"auto"`

178 

179 - `ResponseFormatText object { type }`

180 

181 Default response format. Used to generate text responses.

182 

183 - `type: "text"`

184 

185 The type of response format being defined. Always `text`.

186 

187 - `"text"`

188 

189 - `ResponseFormatJSONObject object { type }`

190 

191 JSON object response format. An older method of generating JSON responses.

192 Using `json_schema` is recommended for models that support it. Note that the

193 model will not generate JSON without a system or user message instructing it

194 to do so.

195 

196 - `type: "json_object"`

197 

198 The type of response format being defined. Always `json_object`.

199 

200 - `"json_object"`

201 

202 - `ResponseFormatJSONSchema object { json_schema, type }`

203 

204 JSON Schema response format. Used to generate structured JSON responses.

205 Learn more about [Structured Outputs](/docs/guides/structured-outputs).

206 

207 - `json_schema: object { name, description, schema, strict }`

208 

209 Structured Outputs configuration options, including a JSON Schema.

210 

211 - `name: string`

212 

213 The name of the response format. Must be a-z, A-Z, 0-9, or contain

214 underscores and dashes, with a maximum length of 64.

215 

216 - `description: optional string`

217 

218 A description of what the response format is for, used by the model to

219 determine how to respond in the format.

220 

221 - `schema: optional map[unknown]`

222 

223 The schema for the response format, described as a JSON Schema object.

224 Learn how to build JSON schemas [here](https://json-schema.org/).

225 

226 - `strict: optional boolean or null`

227 

228 Whether to enable strict schema adherence when generating the output.

229 If set to true, the model will always follow the exact schema defined

230 in the `schema` field. Only a subset of JSON Schema is supported when

231 `strict` is `true`. To learn more, read the [Structured Outputs

232 guide](/docs/guides/structured-outputs).

233 

234 - `type: "json_schema"`

235 

236 The type of response format being defined. Always `json_schema`.

237 

238 - `"json_schema"`

239 

240 - `started_at: number or null`

241 

242 The Unix timestamp (in seconds) for when the run was started.

243 

244 - `status: "queued" or "in_progress" or "requires_action" or 6 more`

245 

246 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

247 

248 - `"queued"`

249 

250 - `"in_progress"`

251 

252 - `"requires_action"`

253 

254 - `"cancelling"`

255 

256 - `"cancelled"`

257 

258 - `"failed"`

259 

260 - `"completed"`

261 

262 - `"incomplete"`

263 

264 - `"expired"`

265 

266 - `thread_id: string`

267 

268 The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.

269 

270 - `tool_choice: AssistantToolChoiceOption or null`

271 

272 Controls which (if any) tool is called by the model.

273 `none` means the model will not call any tools and instead generates a message.

274 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

275 `required` means the model must call one or more tools before responding to the user.

276 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

277 

278 - `"none" or "auto" or "required"`

279 

280 `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

281 

282 - `"none"`

283 

284 - `"auto"`

285 

286 - `"required"`

287 

288 - `AssistantToolChoice object { type, function }`

289 

290 Specifies a tool the model should use. Use to force the model to call a specific tool.

291 

292 - `type: "function" or "code_interpreter" or "file_search"`

293 

294 The type of the tool. If type is `function`, the function name must be set

295 

296 - `"function"`

297 

298 - `"code_interpreter"`

299 

300 - `"file_search"`

301 

302 - `function: optional AssistantToolChoiceFunction`

303 

304 - `name: string`

305 

306 The name of the function to call.

307 

308 - `tools: array of CodeInterpreterTool or FileSearchTool or FunctionTool`

309 

310 The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.

311 

312 - `CodeInterpreterTool object { type }`

313 

314 - `type: "code_interpreter"`

315 

316 The type of tool being defined: `code_interpreter`

317 

318 - `"code_interpreter"`

319 

320 - `FileSearchTool object { type, file_search }`

321 

322 - `type: "file_search"`

323 

324 The type of tool being defined: `file_search`

325 

326 - `"file_search"`

327 

328 - `file_search: optional object { max_num_results, ranking_options }`

329 

330 Overrides for the file search tool.

331 

332 - `max_num_results: optional number`

333 

334 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

335 

336 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

337 

338 - `ranking_options: optional object { score_threshold, ranker }`

339 

340 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

341 

342 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

343 

344 - `score_threshold: number`

345 

346 The score threshold for the file search. All values must be a floating point number between 0 and 1.

347 

348 - `ranker: optional "auto" or "default_2024_08_21"`

349 

350 The ranker to use for the file search. If not specified will use the `auto` ranker.

351 

352 - `"auto"`

353 

354 - `"default_2024_08_21"`

355 

356 - `FunctionTool object { function, type }`

357 

358 - `function: FunctionDefinition`

359 

360 - `name: string`

361 

362 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

363 

364 - `description: optional string`

365 

366 A description of what the function does, used by the model to choose when and how to call the function.

367 

368 - `parameters: optional FunctionParameters`

369 

370 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

371 

372 Omitting `parameters` defines a function with an empty parameter list.

373 

374 - `strict: optional boolean or null`

375 

376 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling).

377 

378 - `type: "function"`

379 

380 The type of tool being defined: `function`

381 

382 - `"function"`

383 

384 - `truncation_strategy: object { type, last_messages } or null`

385 

386 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

387 

388 - `type: "auto" or "last_messages"`

389 

390 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

391 

392 - `"auto"`

393 

394 - `"last_messages"`

395 

396 - `last_messages: optional number or null`

397 

398 The number of most recent messages from the thread when constructing the context for the run.

399 

400 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

401 

402 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

403 

404 - `completion_tokens: number`

405 

406 Number of completion tokens used over the course of the run.

407 

408 - `prompt_tokens: number`

409 

410 Number of prompt tokens used over the course of the run.

411 

412 - `total_tokens: number`

413 

414 Total number of tokens used (prompt + completion).

415 

416 - `temperature: optional number or null`

417 

418 The sampling temperature used for this run. If not set, defaults to 1.

419 

420 - `top_p: optional number or null`

421 

422 The nucleus sampling value used for this run. If not set, defaults to 1.

423 

424### Example

425 

426```http

427curl https://api.openai.com/v1/threads/$THREAD_ID/runs/$RUN_ID \

428 -H 'Content-Type: application/json' \

429 -H 'OpenAI-Beta: assistants=v2' \

430 -H "Authorization: Bearer $OPENAI_API_KEY" \

431 -d '{}'

432```

433 

434#### Response

435 

436```json

437{

438 "id": "id",

439 "assistant_id": "assistant_id",

440 "cancelled_at": 0,

441 "completed_at": 0,

442 "created_at": 0,

443 "expires_at": 0,

444 "failed_at": 0,

445 "incomplete_details": {

446 "reason": "max_completion_tokens"

447 },

448 "instructions": "instructions",

449 "last_error": {

450 "code": "server_error",

451 "message": "message"

452 },

453 "max_completion_tokens": 256,

454 "max_prompt_tokens": 256,

455 "metadata": {

456 "foo": "string"

457 },

458 "model": "model",

459 "object": "thread.run",

460 "parallel_tool_calls": true,

461 "required_action": {

462 "submit_tool_outputs": {

463 "tool_calls": [

464 {

465 "id": "id",

466 "function": {

467 "arguments": "arguments",

468 "name": "name"

469 },

470 "type": "function"

471 }

472 ]

473 },

474 "type": "submit_tool_outputs"

475 },

476 "response_format": "auto",

477 "started_at": 0,

478 "status": "queued",

479 "thread_id": "thread_id",

480 "tool_choice": "none",

481 "tools": [

482 {

483 "type": "code_interpreter"

484 }

485 ],

486 "truncation_strategy": {

487 "type": "auto",

488 "last_messages": 1

489 },

490 "usage": {

491 "completion_tokens": 0,

492 "prompt_tokens": 0,

493 "total_tokens": 0

494 },

495 "temperature": 0,

496 "top_p": 0

497}

498```

499 

500### Example

501 

502```http

503curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \

504 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

506 -H "OpenAI-Beta: assistants=v2" \

507 -d '{

508 "metadata": {

509 "user_id": "user_abc123"

510 }

511 }'

512```

513 

514#### Response

515 

516```json

517{

518 "id": "run_abc123",

519 "object": "thread.run",

520 "created_at": 1699075072,

521 "assistant_id": "asst_abc123",

522 "thread_id": "thread_abc123",

523 "status": "completed",

524 "started_at": 1699075072,

525 "expires_at": null,

526 "cancelled_at": null,

527 "failed_at": null,

528 "completed_at": 1699075073,

529 "last_error": null,

530 "model": "gpt-4o",

531 "instructions": null,

532 "incomplete_details": null,

533 "tools": [

534 {

535 "type": "code_interpreter"

536 }

537 ],

538 "tool_resources": {

539 "code_interpreter": {

540 "file_ids": [

541 "file-abc123",

542 "file-abc456"

543 ]

544 }

545 },

546 "metadata": {

547 "user_id": "user_abc123"

548 },

549 "usage": {

550 "prompt_tokens": 123,

551 "completion_tokens": 456,

552 "total_tokens": 579

553 },

554 "temperature": 1.0,

555 "top_p": 1.0,

556 "max_prompt_tokens": 1000,

557 "max_completion_tokens": 1000,

558 "truncation_strategy": {

559 "type": "auto",

560 "last_messages": null

561 },

562 "response_format": "auto",

563 "tool_choice": "auto",

564 "parallel_tool_calls": true

565}

566```

resources/beta/subresources/threads/subresources/runs/subresources/steps/methods/list/index.md +0 −437 deleted

File Deleted View Diff

1## List run steps

2 

3**get** `/threads/{thread_id}/runs/{run_id}/steps`

4 

5Returns a list of run steps belonging to a run.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `run_id: string`

12 

13### Query Parameters

14 

15- `after: optional string`

16 

17 A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

18 

19- `before: optional string`

20 

21 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

22 

23- `include: optional array of RunStepInclude`

24 

25 A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.

26 

27 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

28 

29 - `"step_details.tool_calls[*].file_search.results[*].content"`

30 

31- `limit: optional number`

32 

33 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

34 

35- `order: optional "asc" or "desc"`

36 

37 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

38 

39 - `"asc"`

40 

41 - `"desc"`

42 

43### Returns

44 

45- `data: array of RunStep`

46 

47 - `id: string`

48 

49 The identifier of the run step, which can be referenced in API endpoints.

50 

51 - `assistant_id: string`

52 

53 The ID of the [assistant](/docs/api-reference/assistants) associated with the run step.

54 

55 - `cancelled_at: number or null`

56 

57 The Unix timestamp (in seconds) for when the run step was cancelled.

58 

59 - `completed_at: number or null`

60 

61 The Unix timestamp (in seconds) for when the run step completed.

62 

63 - `created_at: number`

64 

65 The Unix timestamp (in seconds) for when the run step was created.

66 

67 - `expired_at: number or null`

68 

69 The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

70 

71 - `failed_at: number or null`

72 

73 The Unix timestamp (in seconds) for when the run step failed.

74 

75 - `last_error: object { code, message } or null`

76 

77 The last error associated with this run step. Will be `null` if there are no errors.

78 

79 - `code: "server_error" or "rate_limit_exceeded"`

80 

81 One of `server_error` or `rate_limit_exceeded`.

82 

83 - `"server_error"`

84 

85 - `"rate_limit_exceeded"`

86 

87 - `message: string`

88 

89 A human-readable description of the error.

90 

91 - `metadata: Metadata or null`

92 

93 Set of 16 key-value pairs that can be attached to an object. This can be

94 useful for storing additional information about the object in a structured

95 format, and querying for objects via API or the dashboard.

96 

97 Keys are strings with a maximum length of 64 characters. Values are strings

98 with a maximum length of 512 characters.

99 

100 - `object: "thread.run.step"`

101 

102 The object type, which is always `thread.run.step`.

103 

104 - `"thread.run.step"`

105 

106 - `run_id: string`

107 

108 The ID of the [run](/docs/api-reference/runs) that this run step is a part of.

109 

110 - `status: "in_progress" or "cancelled" or "failed" or 2 more`

111 

112 The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.

113 

114 - `"in_progress"`

115 

116 - `"cancelled"`

117 

118 - `"failed"`

119 

120 - `"completed"`

121 

122 - `"expired"`

123 

124 - `step_details: MessageCreationStepDetails or ToolCallsStepDetails`

125 

126 The details of the run step.

127 

128 - `MessageCreationStepDetails object { message_creation, type }`

129 

130 Details of the message creation by the run step.

131 

132 - `message_creation: object { message_id }`

133 

134 - `message_id: string`

135 

136 The ID of the message that was created by this run step.

137 

138 - `type: "message_creation"`

139 

140 Always `message_creation`.

141 

142 - `"message_creation"`

143 

144 - `ToolCallsStepDetails object { tool_calls, type }`

145 

146 Details of the tool call.

147 

148 - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall`

149 

150 An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.

151 

152 - `CodeInterpreterToolCall object { id, code_interpreter, type }`

153 

154 Details of the Code Interpreter tool call the run step was involved in.

155 

156 - `id: string`

157 

158 The ID of the tool call.

159 

160 - `code_interpreter: object { input, outputs }`

161 

162 The Code Interpreter tool call definition.

163 

164 - `input: string`

165 

166 The input to the Code Interpreter tool call.

167 

168 - `outputs: array of object { logs, type } or object { image, type }`

169 

170 The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type.

171 

172 - `CodeInterpreterLogOutput object { logs, type }`

173 

174 Text output from the Code Interpreter tool call as part of a run step.

175 

176 - `logs: string`

177 

178 The text output from the Code Interpreter tool call.

179 

180 - `type: "logs"`

181 

182 Always `logs`.

183 

184 - `"logs"`

185 

186 - `CodeInterpreterImageOutput object { image, type }`

187 

188 - `image: object { file_id }`

189 

190 - `file_id: string`

191 

192 The [file](/docs/api-reference/files) ID of the image.

193 

194 - `type: "image"`

195 

196 Always `image`.

197 

198 - `"image"`

199 

200 - `type: "code_interpreter"`

201 

202 The type of tool call. This is always going to be `code_interpreter` for this type of tool call.

203 

204 - `"code_interpreter"`

205 

206 - `FileSearchToolCall object { id, file_search, type }`

207 

208 - `id: string`

209 

210 The ID of the tool call object.

211 

212 - `file_search: object { ranking_options, results }`

213 

214 For now, this is always going to be an empty object.

215 

216 - `ranking_options: optional object { ranker, score_threshold }`

217 

218 The ranking options for the file search.

219 

220 - `ranker: "auto" or "default_2024_08_21"`

221 

222 The ranker to use for the file search. If not specified will use the `auto` ranker.

223 

224 - `"auto"`

225 

226 - `"default_2024_08_21"`

227 

228 - `score_threshold: number`

229 

230 The score threshold for the file search. All values must be a floating point number between 0 and 1.

231 

232 - `results: optional array of object { file_id, file_name, score, content }`

233 

234 The results of the file search.

235 

236 - `file_id: string`

237 

238 The ID of the file that result was found in.

239 

240 - `file_name: string`

241 

242 The name of the file that result was found in.

243 

244 - `score: number`

245 

246 The score of the result. All values must be a floating point number between 0 and 1.

247 

248 - `content: optional array of object { text, type }`

249 

250 The content of the result that was found. The content is only included if requested via the include query parameter.

251 

252 - `text: optional string`

253 

254 The text content of the file.

255 

256 - `type: optional "text"`

257 

258 The type of the content.

259 

260 - `"text"`

261 

262 - `type: "file_search"`

263 

264 The type of tool call. This is always going to be `file_search` for this type of tool call.

265 

266 - `"file_search"`

267 

268 - `FunctionToolCall object { id, function, type }`

269 

270 - `id: string`

271 

272 The ID of the tool call object.

273 

274 - `function: object { arguments, name, output }`

275 

276 The definition of the function that was called.

277 

278 - `arguments: string`

279 

280 The arguments passed to the function.

281 

282 - `name: string`

283 

284 The name of the function.

285 

286 - `output: string or null`

287 

288 The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet.

289 

290 - `type: "function"`

291 

292 The type of tool call. This is always going to be `function` for this type of tool call.

293 

294 - `"function"`

295 

296 - `type: "tool_calls"`

297 

298 Always `tool_calls`.

299 

300 - `"tool_calls"`

301 

302 - `thread_id: string`

303 

304 The ID of the [thread](/docs/api-reference/threads) that was run.

305 

306 - `type: "message_creation" or "tool_calls"`

307 

308 The type of run step, which can be either `message_creation` or `tool_calls`.

309 

310 - `"message_creation"`

311 

312 - `"tool_calls"`

313 

314 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

315 

316 Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`.

317 

318 - `completion_tokens: number`

319 

320 Number of completion tokens used over the course of the run step.

321 

322 - `prompt_tokens: number`

323 

324 Number of prompt tokens used over the course of the run step.

325 

326 - `total_tokens: number`

327 

328 Total number of tokens used (prompt + completion).

329 

330- `first_id: string`

331 

332- `has_more: boolean`

333 

334- `last_id: string`

335 

336- `object: string`

337 

338### Example

339 

340```http

341curl https://api.openai.com/v1/threads/$THREAD_ID/runs/$RUN_ID/steps \

342 -H 'OpenAI-Beta: assistants=v2' \

343 -H "Authorization: Bearer $OPENAI_API_KEY"

344```

345 

346#### Response

347 

348```json

349{

350 "data": [

351 {

352 "id": "id",

353 "assistant_id": "assistant_id",

354 "cancelled_at": 0,

355 "completed_at": 0,

356 "created_at": 0,

357 "expired_at": 0,

358 "failed_at": 0,

359 "last_error": {

360 "code": "server_error",

361 "message": "message"

362 },

363 "metadata": {

364 "foo": "string"

365 },

366 "object": "thread.run.step",

367 "run_id": "run_id",

368 "status": "in_progress",

369 "step_details": {

370 "message_creation": {

371 "message_id": "message_id"

372 },

373 "type": "message_creation"

374 },

375 "thread_id": "thread_id",

376 "type": "message_creation",

377 "usage": {

378 "completion_tokens": 0,

379 "prompt_tokens": 0,

380 "total_tokens": 0

381 }

382 }

383 ],

384 "first_id": "step_abc123",

385 "has_more": false,

386 "last_id": "step_abc456",

387 "object": "list"

388}

389```

390 

391### Example

392 

393```http

394curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps \

395 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

397 -H "OpenAI-Beta: assistants=v2"

398```

399 

400#### Response

401 

402```json

403{

404 "object": "list",

405 "data": [

406 {

407 "id": "step_abc123",

408 "object": "thread.run.step",

409 "created_at": 1699063291,

410 "run_id": "run_abc123",

411 "assistant_id": "asst_abc123",

412 "thread_id": "thread_abc123",

413 "type": "message_creation",

414 "status": "completed",

415 "cancelled_at": null,

416 "completed_at": 1699063291,

417 "expired_at": null,

418 "failed_at": null,

419 "last_error": null,

420 "step_details": {

421 "type": "message_creation",

422 "message_creation": {

423 "message_id": "msg_abc123"

424 }

425 },

426 "usage": {

427 "prompt_tokens": 123,

428 "completion_tokens": 456,

429 "total_tokens": 579

430 }

431 }

432 ],

433 "first_id": "step_abc123",

434 "last_id": "step_abc456",

435 "has_more": false

436}

437```

resources/beta/subresources/threads/subresources/runs/subresources/steps/methods/retrieve/index.md +0 −397 deleted

File Deleted View Diff

1## Retrieve run step

2 

3**get** `/threads/{thread_id}/runs/{run_id}/steps/{step_id}`

4 

5Retrieves a run step.

6 

7### Path Parameters

8 

9- `thread_id: string`

10 

11- `run_id: string`

12 

13- `step_id: string`

14 

15### Query Parameters

16 

17- `include: optional array of RunStepInclude`

18 

19 A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.

20 

21 See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

22 

23 - `"step_details.tool_calls[*].file_search.results[*].content"`

24 

25### Returns

26 

27- `RunStep object { id, assistant_id, cancelled_at, 13 more }`

28 

29 Represents a step in execution of a run.

30 

31 - `id: string`

32 

33 The identifier of the run step, which can be referenced in API endpoints.

34 

35 - `assistant_id: string`

36 

37 The ID of the [assistant](/docs/api-reference/assistants) associated with the run step.

38 

39 - `cancelled_at: number or null`

40 

41 The Unix timestamp (in seconds) for when the run step was cancelled.

42 

43 - `completed_at: number or null`

44 

45 The Unix timestamp (in seconds) for when the run step completed.

46 

47 - `created_at: number`

48 

49 The Unix timestamp (in seconds) for when the run step was created.

50 

51 - `expired_at: number or null`

52 

53 The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

54 

55 - `failed_at: number or null`

56 

57 The Unix timestamp (in seconds) for when the run step failed.

58 

59 - `last_error: object { code, message } or null`

60 

61 The last error associated with this run step. Will be `null` if there are no errors.

62 

63 - `code: "server_error" or "rate_limit_exceeded"`

64 

65 One of `server_error` or `rate_limit_exceeded`.

66 

67 - `"server_error"`

68 

69 - `"rate_limit_exceeded"`

70 

71 - `message: string`

72 

73 A human-readable description of the error.

74 

75 - `metadata: Metadata or null`

76 

77 Set of 16 key-value pairs that can be attached to an object. This can be

78 useful for storing additional information about the object in a structured

79 format, and querying for objects via API or the dashboard.

80 

81 Keys are strings with a maximum length of 64 characters. Values are strings

82 with a maximum length of 512 characters.

83 

84 - `object: "thread.run.step"`

85 

86 The object type, which is always `thread.run.step`.

87 

88 - `"thread.run.step"`

89 

90 - `run_id: string`

91 

92 The ID of the [run](/docs/api-reference/runs) that this run step is a part of.

93 

94 - `status: "in_progress" or "cancelled" or "failed" or 2 more`

95 

96 The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.

97 

98 - `"in_progress"`

99 

100 - `"cancelled"`

101 

102 - `"failed"`

103 

104 - `"completed"`

105 

106 - `"expired"`

107 

108 - `step_details: MessageCreationStepDetails or ToolCallsStepDetails`

109 

110 The details of the run step.

111 

112 - `MessageCreationStepDetails object { message_creation, type }`

113 

114 Details of the message creation by the run step.

115 

116 - `message_creation: object { message_id }`

117 

118 - `message_id: string`

119 

120 The ID of the message that was created by this run step.

121 

122 - `type: "message_creation"`

123 

124 Always `message_creation`.

125 

126 - `"message_creation"`

127 

128 - `ToolCallsStepDetails object { tool_calls, type }`

129 

130 Details of the tool call.

131 

132 - `tool_calls: array of CodeInterpreterToolCall or FileSearchToolCall or FunctionToolCall`

133 

134 An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.

135 

136 - `CodeInterpreterToolCall object { id, code_interpreter, type }`

137 

138 Details of the Code Interpreter tool call the run step was involved in.

139 

140 - `id: string`

141 

142 The ID of the tool call.

143 

144 - `code_interpreter: object { input, outputs }`

145 

146 The Code Interpreter tool call definition.

147 

148 - `input: string`

149 

150 The input to the Code Interpreter tool call.

151 

152 - `outputs: array of object { logs, type } or object { image, type }`

153 

154 The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type.

155 

156 - `CodeInterpreterLogOutput object { logs, type }`

157 

158 Text output from the Code Interpreter tool call as part of a run step.

159 

160 - `logs: string`

161 

162 The text output from the Code Interpreter tool call.

163 

164 - `type: "logs"`

165 

166 Always `logs`.

167 

168 - `"logs"`

169 

170 - `CodeInterpreterImageOutput object { image, type }`

171 

172 - `image: object { file_id }`

173 

174 - `file_id: string`

175 

176 The [file](/docs/api-reference/files) ID of the image.

177 

178 - `type: "image"`

179 

180 Always `image`.

181 

182 - `"image"`

183 

184 - `type: "code_interpreter"`

185 

186 The type of tool call. This is always going to be `code_interpreter` for this type of tool call.

187 

188 - `"code_interpreter"`

189 

190 - `FileSearchToolCall object { id, file_search, type }`

191 

192 - `id: string`

193 

194 The ID of the tool call object.

195 

196 - `file_search: object { ranking_options, results }`

197 

198 For now, this is always going to be an empty object.

199 

200 - `ranking_options: optional object { ranker, score_threshold }`

201 

202 The ranking options for the file search.

203 

204 - `ranker: "auto" or "default_2024_08_21"`

205 

206 The ranker to use for the file search. If not specified will use the `auto` ranker.

207 

208 - `"auto"`

209 

210 - `"default_2024_08_21"`

211 

212 - `score_threshold: number`

213 

214 The score threshold for the file search. All values must be a floating point number between 0 and 1.

215 

216 - `results: optional array of object { file_id, file_name, score, content }`

217 

218 The results of the file search.

219 

220 - `file_id: string`

221 

222 The ID of the file that result was found in.

223 

224 - `file_name: string`

225 

226 The name of the file that result was found in.

227 

228 - `score: number`

229 

230 The score of the result. All values must be a floating point number between 0 and 1.

231 

232 - `content: optional array of object { text, type }`

233 

234 The content of the result that was found. The content is only included if requested via the include query parameter.

235 

236 - `text: optional string`

237 

238 The text content of the file.

239 

240 - `type: optional "text"`

241 

242 The type of the content.

243 

244 - `"text"`

245 

246 - `type: "file_search"`

247 

248 The type of tool call. This is always going to be `file_search` for this type of tool call.

249 

250 - `"file_search"`

251 

252 - `FunctionToolCall object { id, function, type }`

253 

254 - `id: string`

255 

256 The ID of the tool call object.

257 

258 - `function: object { arguments, name, output }`

259 

260 The definition of the function that was called.

261 

262 - `arguments: string`

263 

264 The arguments passed to the function.

265 

266 - `name: string`

267 

268 The name of the function.

269 

270 - `output: string or null`

271 

272 The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet.

273 

274 - `type: "function"`

275 

276 The type of tool call. This is always going to be `function` for this type of tool call.

277 

278 - `"function"`

279 

280 - `type: "tool_calls"`

281 

282 Always `tool_calls`.

283 

284 - `"tool_calls"`

285 

286 - `thread_id: string`

287 

288 The ID of the [thread](/docs/api-reference/threads) that was run.

289 

290 - `type: "message_creation" or "tool_calls"`

291 

292 The type of run step, which can be either `message_creation` or `tool_calls`.

293 

294 - `"message_creation"`

295 

296 - `"tool_calls"`

297 

298 - `usage: object { completion_tokens, prompt_tokens, total_tokens } or null`

299 

300 Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`.

301 

302 - `completion_tokens: number`

303 

304 Number of completion tokens used over the course of the run step.

305 

306 - `prompt_tokens: number`

307 

308 Number of prompt tokens used over the course of the run step.

309 

310 - `total_tokens: number`

311 

312 Total number of tokens used (prompt + completion).

313 

314### Example

315 

316```http

317curl https://api.openai.com/v1/threads/$THREAD_ID/runs/$RUN_ID/steps/$STEP_ID \

318 -H 'OpenAI-Beta: assistants=v2' \

319 -H "Authorization: Bearer $OPENAI_API_KEY"

320```

321 

322#### Response

323 

324```json

325{

326 "id": "id",

327 "assistant_id": "assistant_id",

328 "cancelled_at": 0,

329 "completed_at": 0,

330 "created_at": 0,

331 "expired_at": 0,

332 "failed_at": 0,

333 "last_error": {

334 "code": "server_error",

335 "message": "message"

336 },

337 "metadata": {

338 "foo": "string"

339 },

340 "object": "thread.run.step",

341 "run_id": "run_id",

342 "status": "in_progress",

343 "step_details": {

344 "message_creation": {

345 "message_id": "message_id"

346 },

347 "type": "message_creation"

348 },

349 "thread_id": "thread_id",

350 "type": "message_creation",

351 "usage": {

352 "completion_tokens": 0,

353 "prompt_tokens": 0,

354 "total_tokens": 0

355 }

356}

357```

358 

359### Example

360 

361```http

362curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \

363 -H "Authorization: Bearer $OPENAI_API_KEY" \

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

365 -H "OpenAI-Beta: assistants=v2"

366```

367 

368#### Response

369 

370```json

371{

372 "id": "step_abc123",

373 "object": "thread.run.step",

374 "created_at": 1699063291,

375 "run_id": "run_abc123",

376 "assistant_id": "asst_abc123",

377 "thread_id": "thread_abc123",

378 "type": "message_creation",

379 "status": "completed",

380 "cancelled_at": null,

381 "completed_at": 1699063291,

382 "expired_at": null,

383 "failed_at": null,

384 "last_error": null,

385 "step_details": {

386 "type": "message_creation",

387 "message_creation": {

388 "message_id": "msg_abc123"

389 }

390 },

391 "usage": {

392 "prompt_tokens": 123,

393 "completion_tokens": 456,

394 "total_tokens": 579

395 }

396}

397```

Details

1868 1868 

1869 Text output tokens generated by the model.1869 Text output tokens generated by the model.

1870 1870 

1871 - `compute_units: optional number or null`

1872 

1873 Compute units for the request. Currently null when available.

1874 

1871 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`1875 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`

1872 1876 

1873 Breakdown of tokens used in the prompt.1877 Breakdown of tokens used in the prompt.


2065 "rejected_prediction_tokens": 0,2069 "rejected_prediction_tokens": 0,

2066 "text_tokens": 02070 "text_tokens": 0

2067 },2071 },

2072 "compute_units": 0,

2068 "prompt_tokens_details": {2073 "prompt_tokens_details": {

2069 "audio_tokens": 0,2074 "audio_tokens": 0,

2070 "cache_write_tokens": 0,2075 "cache_write_tokens": 0,

Details

509 509 

510 Text output tokens generated by the model.510 Text output tokens generated by the model.

511 511 

512 - `compute_units: optional number or null`

513 

514 Compute units for the request. Currently null when available.

515 

512 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`516 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`

513 517 

514 Breakdown of tokens used in the prompt.518 Breakdown of tokens used in the prompt.


710 "rejected_prediction_tokens": 0,714 "rejected_prediction_tokens": 0,

711 "text_tokens": 0715 "text_tokens": 0

712 },716 },

717 "compute_units": 0,

713 "prompt_tokens_details": {718 "prompt_tokens_details": {

714 "audio_tokens": 0,719 "audio_tokens": 0,

715 "cache_write_tokens": 0,720 "cache_write_tokens": 0,

Details

485 485 

486 Text output tokens generated by the model.486 Text output tokens generated by the model.

487 487 

488 - `compute_units: optional number or null`

489 

490 Compute units for the request. Currently null when available.

491 

488 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`492 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`

489 493 

490 Breakdown of tokens used in the prompt.494 Breakdown of tokens used in the prompt.


666 "rejected_prediction_tokens": 0,670 "rejected_prediction_tokens": 0,

667 "text_tokens": 0671 "text_tokens": 0

668 },672 },

673 "compute_units": 0,

669 "prompt_tokens_details": {674 "prompt_tokens_details": {

670 "audio_tokens": 0,675 "audio_tokens": 0,

671 "cache_write_tokens": 0,676 "cache_write_tokens": 0,

Details

497 497 

498 Text output tokens generated by the model.498 Text output tokens generated by the model.

499 499 

500 - `compute_units: optional number or null`

501 

502 Compute units for the request. Currently null when available.

503 

500 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`504 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`

501 505 

502 Breakdown of tokens used in the prompt.506 Breakdown of tokens used in the prompt.


684 "rejected_prediction_tokens": 0,688 "rejected_prediction_tokens": 0,

685 "text_tokens": 0689 "text_tokens": 0

686 },690 },

691 "compute_units": 0,

687 "prompt_tokens_details": {692 "prompt_tokens_details": {

688 "audio_tokens": 0,693 "audio_tokens": 0,

689 "cache_write_tokens": 0,694 "cache_write_tokens": 0,

Details

305 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens",305 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens",

306 "(resource) completions > (model) completion_usage > (schema) > (property) total_tokens",306 "(resource) completions > (model) completion_usage > (schema) > (property) total_tokens",

307 "(resource) completions > (model) completion_usage > (schema) > (property) completion_tokens_details",307 "(resource) completions > (model) completion_usage > (schema) > (property) completion_tokens_details",

308 "(resource) completions > (model) completion_usage > (schema) > (property) compute_units",

308 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens_details"309 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens_details"

309 ]310 ]

310 },311 },


660 "(resource) completions > (model) completion_usage > (schema) > (property) completion_tokens_details > (property) text_tokens"661 "(resource) completions > (model) completion_usage > (schema) > (property) completion_tokens_details > (property) text_tokens"

661 ]662 ]

662 },663 },

664 "(resource) completions > (model) completion_usage > (schema) > (property) compute_units": {

665 "kind": "HttpDeclProperty",

666 "oasRef": "#/components/schemas/CompletionUsage/properties/compute_units",

667 "deprecated": false,

668 "key": "compute_units",

669 "docstring": "Compute units for the request. Currently null when available.\n",

670 "type": {

671 "kind": "HttpTypeNumber"

672 },

673 "constraints": {

674 "minimum": 0

675 },

676 "optional": true,

677 "nullable": true,

678 "schemaType": "integer",

679 "children": []

680 },

663 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens_details": {681 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens_details": {

664 "kind": "HttpDeclProperty",682 "kind": "HttpDeclProperty",

665 "oasRef": "#/components/schemas/CompletionUsage/properties/prompt_tokens_details",683 "oasRef": "#/components/schemas/CompletionUsage/properties/prompt_tokens_details",


718 {736 {

719 "ident": "completion_tokens_details"737 "ident": "completion_tokens_details"

720 },738 },

739 {

740 "ident": "compute_units"

741 },

721 {742 {

722 "ident": "prompt_tokens_details"743 "ident": "prompt_tokens_details"

723 }744 }


729 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens",750 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens",

730 "(resource) completions > (model) completion_usage > (schema) > (property) total_tokens",751 "(resource) completions > (model) completion_usage > (schema) > (property) total_tokens",

731 "(resource) completions > (model) completion_usage > (schema) > (property) completion_tokens_details",752 "(resource) completions > (model) completion_usage > (schema) > (property) completion_tokens_details",

753 "(resource) completions > (model) completion_usage > (schema) > (property) compute_units",

732 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens_details"754 "(resource) completions > (model) completion_usage > (schema) > (property) prompt_tokens_details"

733 ]755 ]

734 },756 },

Details

261 261 

262 Text output tokens generated by the model.262 Text output tokens generated by the model.

263 263 

264 - `compute_units: optional number or null`

265 

266 Compute units for the request. Currently null when available.

267 

264 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`268 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`

265 269 

266 Breakdown of tokens used in the prompt.270 Breakdown of tokens used in the prompt.


346 "rejected_prediction_tokens": 0,350 "rejected_prediction_tokens": 0,

347 "text_tokens": 0351 "text_tokens": 0

348 },352 },

353 "compute_units": 0,

349 "prompt_tokens_details": {354 "prompt_tokens_details": {

350 "audio_tokens": 0,355 "audio_tokens": 0,

351 "cache_write_tokens": 0,356 "cache_write_tokens": 0,

Details

9160 9160 

9161 The total number of tokens used.9161 The total number of tokens used.

9162 9162 

9163 - `compute_units: optional number or null`

9164 

9165 Compute units for the request. Currently null when available.

9166 

9163 - `user: optional string`9167 - `user: optional string`

9164 9168 

9165 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.9169 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.


9340 "output_tokens_details": {9344 "output_tokens_details": {

9341 "reasoning_tokens": 09345 "reasoning_tokens": 0

9342 },9346 },

9343 "total_tokens": 09347 "total_tokens": 0,

9348 "compute_units": 0

9344 },9349 },

9345 "user": "user-1234"9350 "user": "user-1234"

9346}9351}

Details

8484 8484 

8485 The total number of tokens used.8485 The total number of tokens used.

8486 8486 

8487 - `compute_units: optional number or null`

8488 

8489 Compute units for the request. Currently null when available.

8490 

8487### Example8491### Example

8488 8492 

8489```http8493```http


8531 "output_tokens_details": {8535 "output_tokens_details": {

8532 "reasoning_tokens": 08536 "reasoning_tokens": 0

8533 },8537 },

8534 "total_tokens": 08538 "total_tokens": 0,

8539 "compute_units": 0

8535 }8540 }

8536}8541}

8537```8542```

Details

15011 15011 

15012 The total number of tokens used.15012 The total number of tokens used.

15013 15013 

15014 - `compute_units: optional number or null`

15015 

15016 Compute units for the request. Currently null when available.

15017 

15014 - `user: optional string`15018 - `user: optional string`

15015 15019 

15016 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.15020 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.


15199 "output_tokens_details": {15203 "output_tokens_details": {

15200 "reasoning_tokens": 015204 "reasoning_tokens": 0

15201 },15205 },

15202 "total_tokens": 015206 "total_tokens": 0,

15207 "compute_units": 0

15203 },15208 },

15204 "user": "user-1234"15209 "user": "user-1234"

15205}15210}

Details

9204 9204 

9205 The total number of tokens used.9205 The total number of tokens used.

9206 9206 

9207 - `compute_units: optional number or null`

9208 

9209 Compute units for the request. Currently null when available.

9210 

9207 - `user: optional string`9211 - `user: optional string`

9208 9212 

9209 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.9213 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.


9383 "output_tokens_details": {9387 "output_tokens_details": {

9384 "reasoning_tokens": 09388 "reasoning_tokens": 0

9385 },9389 },

9386 "total_tokens": 09390 "total_tokens": 0,

9391 "compute_units": 0

9387 },9392 },

9388 "user": "user-1234"9393 "user": "user-1234"

9389}9394}