Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { ChatCompletionMessage } from '@shared/types/api/routes/shared/messages';
import {
ReasoningEffort,
ReasoningSummary,
} from '@shared/types/api/routes/shared/thinking';
import { z } from 'zod';
import {
McpApprovalRequest,
McpCall,
McpListTools,
ResponsesAPIFunctionCall,
ResponsesAPIOutputWithRefusal,
ResponsesAPIReasoningOutput,
ResponseTextConfig,
} from './response';
/**
* A custom tool that processes input using a specified format. Learn more about
* [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools).
*/
export const CustomTool = z.object({
/**
* The name of the custom tool, used to identify it in tool calls.
*/
name: z.string(),
/**
* The type of the custom tool. Always `custom`.
*/
type: z.literal('custom'),
/**
* Optional description of the custom tool, used to provide more context.
*/
description: z.string().optional(),
/**
* The input format for the custom tool. Default is unconstrained text.
*/
format: z.unknown().optional(),
});
export type CustomTool = z.infer<typeof CustomTool>;
// Placeholder schemas for Shared types since they're not defined in the provided code
const ComparisonFilter = z.object({
// Define based on your actual ComparisonFilter structure
field: z.string(),
operator: z.string(),
value: z.unknown(),
});
const CompoundFilter = z.object({
// Define based on your actual CompoundFilter structure
type: z.union([z.literal('and'), z.literal('or')]),
filters: z.array(z.unknown()),
});
/**
* A tool that searches for relevant content from uploaded files. Learn more about
* the
* [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
*/
export const FileSearchTool = z.object({
/**
* The type of the file search tool. Always `file_search`.
*/
type: z.literal('file_search'),
/**
* The IDs of the vector stores to search.
*/
vector_store_ids: z.array(z.string()),
/**
* A filter to apply.
*/
filters: z.union([ComparisonFilter, CompoundFilter, z.null()]).optional(),
/**
* The maximum number of results to return. This number should be between 1 and 50
* inclusive.
*/
max_num_results: z.number().min(1).max(50).optional(),
/**
* Ranking options for search.
*/
ranking_options: z
.object({
ranker: z
.union([z.literal('auto'), z.literal('default-2024-11-15')])
.optional(),
score_threshold: z.number().optional(),
})
.optional(),
});
export type FileSearchTool = z.infer<typeof FileSearchTool>;
/**
* A tool that allows the model to execute shell commands in a local environment.
*/
export const LocalShell = z.object({
/**
* The type of the local shell tool. Always `local_shell`.
*/
type: z.literal('local_shell'),
});
export type LocalShell = z.infer<typeof LocalShell>;
/**
* A tool that controls a virtual computer. Learn more about the
* [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
*/
export const ComputerTool = z.object({
/**
* The height of the computer display.
*/
display_height: z.number(),
/**
* The width of the computer display.
*/
display_width: z.number(),
/**
* The type of computer environment to control.
*/
environment: z.union([
z.literal('windows'),
z.literal('mac'),
z.literal('linux'),
z.literal('ubuntu'),
z.literal('browser'),
]),
/**
* The type of the computer use tool. Always `computer_use_preview`.
*/
type: z.literal('computer_use_preview'),
});
export type ComputerTool = z.infer<typeof ComputerTool>;
/**
* The user's location.
*/
export const UserLocation = z.object({
/**
* The type of location approximation. Always `approximate`.
*/
type: z.literal('approximate'),
/**
* Free text input for the city of the user, e.g. `San Francisco`.
*/
city: z.string().nullable().optional(),
/**
* The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
* the user, e.g. `US`.
*/
country: z.string().nullable().optional(),
/**
* Free text input for the region of the user, e.g. `California`.
*/
region: z.string().nullable().optional(),
/**
* The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
* user, e.g. `America/Los_Angeles`.
*/
timezone: z.string().nullable().optional(),
});
export type UserLocation = z.infer<typeof UserLocation>;
/**
* This tool searches the web for relevant results to use in a response. Learn more
* about the
* [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
*/
export const WebSearchTool = z.object({
/**
* The type of the web search tool. One of `web_search_preview` or
* `web_search_preview_2025_03_11`.
*/
type: z.union([
z.literal('web_search_preview'),
z.literal('web_search_preview_2025_03_11'),
]),
/**
* High level guidance for the amount of context window space to use for the
* search. One of `low`, `medium`, or `high`. `medium` is the default.
*/
search_context_size: z
.union([z.literal('low'), z.literal('medium'), z.literal('high')])
.optional(),
/**
* The user's location.
*/
user_location: UserLocation.nullable().optional(),
});
export type WebSearchTool = z.infer<typeof WebSearchTool>;
// Note: These types need to be defined since they were referenced in the interface
const McpToolFilter = z.object({
// Define the structure based on your actual McpToolFilter type
// This is a placeholder - adjust according to your actual type
pattern: z.string().optional(),
exclude: z.array(z.string()).optional(),
});
const McpToolApprovalFilter = z.object({
// Define the structure based on your actual McpToolApprovalFilter type
// This is a placeholder - adjust according to your actual type
tools: z.array(z.string()).optional(),
pattern: z.string().optional(),
});
export const Mcp = z.object({
/**
* A label for this MCP server, used to identify it in tool calls.
*/
server_label: z.string(),
/**
* The type of the MCP tool. Always `mcp`.
*/
type: z.literal('mcp'),
/**
* List of allowed tool names or a filter object.
*/
allowed_tools: z
.union([z.array(z.string()), McpToolFilter, z.null()])
.optional(),
/**
* An OAuth access token that can be used with a remote MCP server, either with a
* custom MCP server URL or a service connector. Your application must handle the
* OAuth authorization flow and provide the token here.
*/
authorization: z.string().optional(),
/**
* Identifier for service connectors, like those available in ChatGPT. One of
* `server_url` or `connector_id` must be provided. Learn more about service
* connectors
* [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
*
* Currently supported `connector_id` values are:
*
* - Dropbox: `connector_dropbox`
* - Gmail: `connector_gmail`
* - Google Calendar: `connector_googlecalendar`
* - Google Drive: `connector_googledrive`
* - Microsoft Teams: `connector_microsoftteams`
* - Outlook Calendar: `connector_outlookcalendar`
* - Outlook Email: `connector_outlookemail`
* - SharePoint: `connector_sharepoint`
*/
connector_id: z
.union([
z.literal('connector_dropbox'),
z.literal('connector_gmail'),
z.literal('connector_googlecalendar'),
z.literal('connector_googledrive'),
z.literal('connector_microsoftteams'),
z.literal('connector_outlookcalendar'),
z.literal('connector_outlookemail'),
z.literal('connector_sharepoint'),
])
.optional(),
/**
* Optional HTTP headers to send to the MCP server. Use for authentication or other
* purposes.
*/
headers: z.record(z.string(), z.string()).nullable().optional(),
/**
* Specify which of the MCP server's tools require approval.
*/
require_approval: z
.union([
McpToolApprovalFilter,
z.literal('always'),
z.literal('never'),
z.null(),
])
.optional(),
/**
* Optional description of the MCP server, used to provide more context.
*/
server_description: z.string().optional(),
/**
* The URL for the MCP server. One of `server_url` or `connector_id` must be
* provided.
*/
server_url: z.string().optional(),
});
export type Mcp = z.infer<typeof Mcp>;
/**
* A tool that runs Python code to help generate a response to a prompt.
*/
export const CodeInterpreter = z.object({
/**
* The code interpreter container. Can be a container ID or an object that
* specifies uploaded file IDs to make available to your code.
*/
container: z.union([
z.string(),
z.object({
type: z.literal('auto'),
file_ids: z.array(z.string()).optional(),
}),
]),
/**
* The type of the code interpreter tool. Always `code_interpreter`.
*/
type: z.literal('code_interpreter'),
});
export type CodeInterpreter = z.infer<typeof CodeInterpreter>;
/**
* A tool that generates images using a model like `gpt-image-1`.
*/
export const ImageGeneration = z.object({
/**
* The type of the image generation tool. Always `image_generation`.
*/
type: z.literal('image_generation'),
/**
* Background type for the generated image. One of `transparent`, `opaque`, or
* `auto`. Default: `auto`.
*/
background: z
.union([z.literal('transparent'), z.literal('opaque'), z.literal('auto')])
.optional(),
/**
* Control how much effort the model will exert to match the style and features,
* especially facial features, of input images. This parameter is only supported
* for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
*/
input_fidelity: z
.union([z.literal('high'), z.literal('low'), z.null()])
.optional(),
/**
* Optional mask for inpainting. Contains `image_url` (string, optional) and
* `file_id` (string, optional).
*/
input_image_mask: z
.object({
image_url: z.string().optional(),
file_id: z.string().optional(),
})
.optional(),
/**
* The image generation model to use. Default: `gpt-image-1`.
*/
model: z.literal('gpt-image-1').optional(),
/**
* Moderation level for the generated image. Default: `auto`.
*/
moderation: z.union([z.literal('auto'), z.literal('low')]).optional(),
/**
* Compression level for the output image. Default: 100.
*/
output_compression: z.number().optional(),
/**
* The output format of the generated image. One of `png`, `webp`, or `jpeg`.
* Default: `png`.
*/
output_format: z
.union([z.literal('png'), z.literal('webp'), z.literal('jpeg')])
.optional(),
/**
* Number of partial images to generate in streaming mode, from 0 (default value)
* to 3.
*/
partial_images: z.number().optional(),
/**
* The quality of the generated image. One of `low`, `medium`, `high`, or `auto`.
* Default: `auto`.
*/
quality: z
.union([
z.literal('low'),
z.literal('medium'),
z.literal('high'),
z.literal('auto'),
])
.optional(),
/**
* The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`,
* or `auto`. Default: `auto`.
*/
size: z
.union([
z.literal('1024x1024'),
z.literal('1024x1536'),
z.literal('1536x1024'),
z.literal('auto'),
])
.optional(),
});
export type ImageGeneration = z.infer<typeof ImageGeneration>;
/**
* Defines a function in your own code the model can choose to call. Learn more
* about
* [function calling](https://platform.openai.com/docs/guides/function-calling).
*/
export const FunctionTool = z.object({
/**
* The name of the function to call.
*/
name: z.string(),
/**
* A JSON schema object describing the parameters of the function.
*/
parameters: z.record(z.string(), z.unknown()).nullable(),
/**
* Whether to enforce strict parameter validation. Default `true`.
*/
strict: z.boolean().nullable(),
/**
* The type of the function tool. Always `function`.
*/
type: z.literal('function'),
/**
* A description of the function. Used by the model to determine whether or not to
* call the function.
*/
description: z.string().nullable().optional(),
});
export type FunctionTool = z.infer<typeof FunctionTool>;
/**
* A response to an MCP approval request.
*/
export const McpApprovalResponse = z.object({
/**
* The ID of the approval request being answered.
*/
approval_request_id: z.string(),
/**
* Whether the request was approved.
*/
approve: z.boolean(),
/**
* The type of the item. Always `mcp_approval_response`.
*/
type: z.literal('mcp_approval_response'),
/**
* The unique ID of the approval response
*/
id: z.string().nullable().optional(),
/**
* Optional reason for the decision.
*/
reason: z.string().nullable().optional(),
});
export type McpApprovalResponse = z.infer<typeof McpApprovalResponse>;
/**
* A description of the chain of thought used by a reasoning model while generating
* a response. Be sure to include these items in your `input` to the Responses API
* for subsequent turns of a conversation if you are manually
* [managing context](https://platform.openai.com/docs/guides/conversation-state).
*/
export const ResponseReasoningItem = z.object({
/**
* The unique identifier of the reasoning content.
*/
id: z.string(),
/**
* Reasoning summary content.
*/
summary: z.array(z.unknown()),
/**
* The type of the object. Always `reasoning`.
*/
type: z.literal('reasoning'),
/**
* Reasoning text content.
*/
content: z.array(z.unknown()).optional(),
/**
* The encrypted content of the reasoning item - populated when a response is
* generated with `reasoning.encrypted_content` in the `include` parameter.
*/
encrypted_content: z.string().nullable().optional(),
/**
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
* Populated when items are returned via API.
*/
status: z
.union([
z.literal('in_progress'),
z.literal('completed'),
z.literal('incomplete'),
])
.optional(),
});
/**
* The output of a function tool call.
*/
export const ResponsesAPIFunctionCallOutput = z.object({
/**
* The unique ID of the function tool call generated by the model.
*/
call_id: z.string(),
/**
* A JSON string of the output of the function tool call.
*/
output: z.string(),
/**
* The type of the function tool call output.
*/
type: z.string(),
/**
* The unique ID of the function tool call output. Populated when this item is
* returned via API.
*/
id: z.string().optional(),
/**
* The status of the item. One of `in_progress`, `completed`, or `incomplete`.
* Populated when items are returned via API.
*/
status: z
.union([
z.literal('in_progress'),
z.literal('completed'),
z.literal('incomplete'),
])
.optional(),
});
export type ResponsesAPIFunctionCallOutput = z.infer<
typeof ResponsesAPIFunctionCallOutput
>;
export const ResponsesAPITool = z.object({
id: z.string(),
name: z.string(),
description: z.string(),
input: z.string(),
output: z.string(),
});
export const ReasoningConfig = z.object({
/**
* The effort level of the reasoning process. One of minimal, low, medium, or high.
*/
effort: z.enum(ReasoningEffort).optional().default(ReasoningEffort.MEDIUM),
/** Deprecated. Use `summary` instead. */
generate_summary: z.enum(ReasoningSummary).optional(),
/**
* The level of detail in the summary. One of auto, concise, or detailed.
*/
summary: z.enum(ReasoningSummary).optional().default(ReasoningSummary.AUTO),
});
export const ResponsesRequestBody = z.object({
input: z.union([
z.string(),
z.array(
z.union([
ChatCompletionMessage,
ResponsesAPIReasoningOutput,
ResponsesAPIFunctionCall,
ResponsesAPIFunctionCallOutput,
ResponsesAPIOutputWithRefusal,
McpListTools,
McpApprovalRequest,
McpApprovalResponse,
McpCall,
]),
),
]),
model: z.string(),
background: z.boolean().optional(),
include: z.array(z.string()).optional(),
instructions: z.string().optional(),
max_output_tokens: z.number().optional(),
metadata: z
.record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
.optional(),
modalities: z.array(z.string()).optional(),
parallel_tool_calls: z.boolean().optional(),
previous_response_id: z.string().optional(),
reasoning: ReasoningConfig.optional(),
reasoning_effort: z.enum(ReasoningEffort).optional(),
store: z.boolean().optional(),
stream: z.boolean().optional(),
temperature: z.number().optional(),
/**
* Configuration options for a text response from the model. Can be plain text or
* structured JSON data. Learn more:
*
* - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
* - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
*/
text: ResponseTextConfig.optional(),
tool_choice: z
.union([
z.literal('none'),
z.literal('auto'),
z.literal('required'),
z.object({
type: z.string(),
name: z.string().optional(),
}),
])
.optional(),
tools: z
.array(
z.union([
FunctionTool,
FileSearchTool,
WebSearchTool,
ComputerTool,
Mcp,
CodeInterpreter,
ImageGeneration,
LocalShell,
CustomTool,
]),
)
.optional(),
top_p: z.number().optional(),
truncation: z.union([z.literal('auto'), z.literal('disabled')]).optional(),
user: z.string().optional(),
});
export type ResponsesRequestBody = z.infer<typeof ResponsesRequestBody>;
export const ListResponsesRequestBody = z.object({
after: z.string().optional(),
before: z.string().optional(),
limit: z.number().int().min(1).max(100).optional().default(20),
order: z.enum(['asc', 'desc']).optional().default('desc'),
});
export type ListResponsesRequestBody = z.infer<typeof ListResponsesRequestBody>;
export const ListResponseInputItemsRequestBody = z.object({
after: z.string().optional(),
before: z.string().optional(),
limit: z.number().int().min(1).max(100).optional().default(20),
order: z.enum(['asc', 'desc']).optional().default('desc'),
});
export type ListResponseInputItemsRequestBody = z.infer<
typeof ListResponseInputItemsRequestBody
>;
export const GetResponseRequestBody = z.object({
include: z.array(z.string()).optional(),
});
export type GetResponseRequestBody = z.infer<typeof GetResponseRequestBody>;
|