diff --git a/hives/openai-server/README.md b/hives/openai-server/README.md index 7c0bac00..65d3513e 100644 --- a/hives/openai-server/README.md +++ b/hives/openai-server/README.md @@ -135,7 +135,14 @@ follows the thread's latest; there is no `/v1/conversations` here. Responses are kept in memory, the latest 2048, so none outlives a restart. A thread is kept only while its latest response is: once that response is deleted or among those forgotten, the thread's next response -starts it over. `background` is refused. +starts it over. `background` is refused, and so is an input item that +holds its words elsewhere, an `item_reference` or a `compaction`, since +dropping it would lose them; a record of a tool only OpenAI runs is left +out. A failed response's `error.code` is one of OpenAI's, and hum's own +code is its `type`. A response says every field both OpenAI and Open +Responses ask of one, an `mcp_call` aside: that item is OpenAI's, kept +for its clients, though Open Responses would want it named with a +prefix of hum's. **Completions.** Each prompt is a bloom of its own, carried as a graft of plain text with no words of its own, so the nurse grows on from where the @@ -245,7 +252,12 @@ bun test The end-to-end tests run the official OpenAI SDK against this server under Node, a humd of their own built from this checkout, a scripted upstream, and an attendant serving one tool; `test/holds.test.ts` adds a -nurse that grows nothing and hears every cancel. `test/claude.live.test.ts` +nurse that grows nothing and hears every cancel. Every request they send +and every answer and stream event they get back is checked against +OpenAI's OpenAPI spec and the Open Responses spec, kept in `spec/` at a +pinned commit (`bun spec/fetch.ts` takes them again), and they send the +HTTP cases of the Open Responses compliance suite as it writes them. Its +WebSocket cases and `/responses/compact` are not served here. `test/claude.live.test.ts` runs only with `HUM_LIVE_CLAUDE=1`: real claude behind this server, through the claude-cli nurse (build it first with `cargo build` in `hives/claude-cli`), signed in and spending as the person's own Claude diff --git a/hives/openai-server/package.json b/hives/openai-server/package.json index 102b866a..1bde4241 100644 --- a/hives/openai-server/package.json +++ b/hives/openai-server/package.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@types/node": "^22.19.17", + "ajv": "8.17.1", "openai": "^6.49.0", "tsup": "^8.5.1", "typescript": "^5.7.0" diff --git a/hives/openai-server/pnpm-lock.yaml b/hives/openai-server/pnpm-lock.yaml index a7e4bf99..39b01095 100644 --- a/hives/openai-server/pnpm-lock.yaml +++ b/hives/openai-server/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@types/node': specifier: ^22.19.17 version: 22.19.19 + ajv: + specifier: 8.17.1 + version: 8.17.1 openai: specifier: ^6.49.0 version: 6.49.0 @@ -341,6 +344,9 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + ajv@8.17.1: + resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} @@ -383,6 +389,12 @@ packages: engines: {node: '>=18'} hasBin: true + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-uri@3.1.9: + resolution: {integrity: sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==} + fdir@6.5.0: resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} engines: {node: '>=12.0.0'} @@ -404,6 +416,9 @@ packages: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} + json-schema-traverse@1.0.0: + resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} + lilconfig@3.1.3: resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==} engines: {node: '>=14'} @@ -490,6 +505,10 @@ packages: resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} engines: {node: '>= 14.18.0'} + require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + resolve-from@5.0.0: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} @@ -736,6 +755,13 @@ snapshots: acorn@8.16.0: {} + ajv@8.17.1: + dependencies: + fast-deep-equal: 3.1.3 + fast-uri: 3.1.9 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + any-promise@1.3.0: {} bundle-require@5.1.0(esbuild@0.27.7): @@ -788,6 +814,10 @@ snapshots: '@esbuild/win32-ia32': 0.27.7 '@esbuild/win32-x64': 0.27.7 + fast-deep-equal@3.1.3: {} + + fast-uri@3.1.9: {} + fdir@6.5.0(picomatch@4.0.4): optionalDependencies: picomatch: 4.0.4 @@ -803,6 +833,8 @@ snapshots: joycon@3.1.1: {} + json-schema-traverse@1.0.0: {} + lilconfig@3.1.3: {} lines-and-columns@1.2.4: {} @@ -852,6 +884,8 @@ snapshots: readdirp@4.1.2: {} + require-from-string@2.0.2: {} + resolve-from@5.0.0: {} rollup@4.60.4: diff --git a/hives/openai-server/spec/fetch.ts b/hives/openai-server/spec/fetch.ts new file mode 100644 index 00000000..836c0cb8 --- /dev/null +++ b/hives/openai-server/spec/fetch.ts @@ -0,0 +1,87 @@ +// The specs this hive is held to, fetched at a pinned commit. +// +// openai.json is OpenAI's OpenAPI cut down to what this hive serves: the +// operations of its routes and every schema they reach, since the whole +// is five megabytes. openresponses.json is the Open Responses spec whole. +// Run with `bun spec/fetch.ts`; move a commit below to take a newer spec. + +import { writeFileSync } from "node:fs"; +import { join } from "node:path"; + +const OPENAI = { repo: "openai/openai-openapi", commit: "26a299159673d20d5cf0faf10e691beed3fed52d", path: "openapi.json" }; +const OPEN_RESPONSES = { repo: "openresponses/openresponses", commit: "8907bc3b7c4300ff5c21fd647cfde9929243afa1", path: "public/openapi/openapi.json" }; + +const SERVED: Array<[string, string]> = [ + ["/chat/completions", "post"], + ["/completions", "post"], + ["/embeddings", "post"], + ["/models", "get"], + ["/models/{model}", "get"], + ["/responses", "post"], + ["/responses/{response_id}", "get"], + ["/responses/{response_id}", "delete"], +]; + +const STREAMED = ["CreateChatCompletionStreamResponse", "CreateCompletionResponse", "ResponseStreamEvent", "ErrorResponse"]; + +type Json = Record; + +async function fetched(source: { repo: string; commit: string; path: string }): Promise { + const url = `https://raw.githubusercontent.com/${source.repo}/${source.commit}/${source.path}`; + const res = await fetch(url); + if (!res.ok) throw new Error(`${url}: ${res.status}`); + return (await res.json()) as Json; +} + +function refsIn(node: unknown, into: Set): void { + if (Array.isArray(node)) { + for (const n of node) refsIn(n, into); + return; + } + if (node === null || typeof node !== "object") return; + for (const [k, v] of Object.entries(node)) { + if (k === "$ref" && typeof v === "string" && v.startsWith("#/components/schemas/")) into.add(v.slice("#/components/schemas/".length)); + else refsIn(v, into); + } +} + +function jsonOnly(op: Json): Json { + const body = (op.requestBody as Json | undefined)?.content as Json | undefined; + const responses: Json = {}; + for (const [code, r] of Object.entries((op.responses ?? {}) as Record)) { + const content = r.content as Record | undefined; + const schema = content?.["application/json"]?.schema ?? content?.["text/event-stream"]?.schema; + if (schema) responses[code] = { content: { "application/json": { schema } } }; + } + return { + ...(body?.["application/json"] ? { requestBody: { content: { "application/json": { schema: (body["application/json"] as Json).schema } } } } : {}), + responses, + }; +} + +function cut(spec: Json): Json { + const paths: Record = {}; + for (const [path, method] of SERVED) { + const op = ((spec.paths as Record)[path] as Record)[method]; + paths[path] = { ...(paths[path] ?? {}), [method]: jsonOnly(op) }; + } + const all = (spec.components as Json).schemas as Record; + const reached = new Set(STREAMED); + refsIn(paths, reached); + const stack = [...reached]; + while (stack.length > 0) { + const name = stack.pop()!; + const found = new Set(); + refsIn(all[name], found); + for (const n of found) if (!reached.has(n)) { + reached.add(n); + stack.push(n); + } + } + const schemas = Object.fromEntries([...reached].sort().map((n) => [n, all[n]])); + return { openapi: spec.openapi, info: spec.info, "x-hum-source": OPENAI, paths, components: { schemas } }; +} + +const here = import.meta.dir; +writeFileSync(join(here, "openai.json"), JSON.stringify(cut(await fetched(OPENAI))) + "\n"); +writeFileSync(join(here, "openresponses.json"), JSON.stringify({ ...(await fetched(OPEN_RESPONSES)), "x-hum-source": OPEN_RESPONSES }) + "\n"); diff --git a/hives/openai-server/spec/openai.json b/hives/openai-server/spec/openai.json new file mode 100644 index 00000000..b8a009c1 --- /dev/null +++ b/hives/openai-server/spec/openai.json @@ -0,0 +1 @@ +{"openapi":"3.1.0","info":{"title":"OpenAI API","description":"The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.","version":"2.3.0","termsOfService":"https://openai.com/policies/terms-of-use","contact":{"name":"OpenAI Support","url":"https://help.openai.com/"},"license":{"name":"MIT","identifier":"MIT"}},"x-hum-source":{"repo":"openai/openai-openapi","commit":"26a299159673d20d5cf0faf10e691beed3fed52d","path":"openapi.json"},"paths":{"/chat/completions":{"post":{"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateChatCompletionRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateChatCompletionResponse"}}}},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/completions":{"post":{"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCompletionRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCompletionResponse"}}}},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/embeddings":{"post":{"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateEmbeddingRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateEmbeddingResponse"}}}},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/models":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListModelsResponse"}}}},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionErrorResponse"}}}}}}},"/models/{model}":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Model"}}}},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionErrorResponse"}}}},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/responses":{"post":{"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateResponse"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/responses/{response_id}":{"get":{"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","enum":["response.deleted"],"default":"response.deleted","x-stainless-const":true},"deleted":{"type":"boolean"},"id":{"type":"string"}},"required":["object","deleted","id"]}}}},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"AccessProgramsBody":{"properties":{"cyber":{"$ref":"#/components/schemas/CyberAccessProgramEnum","description":"The effective Cyber access program used for this response."}},"type":"object","required":["cyber"]},"AccessProgramsParam":{"properties":{"cyber":{"$ref":"#/components/schemas/CyberAccessProgramEnum","description":"The Cyber access program to use for this request. Supported values are `standard`, `daybreak_blue`, and `daybreak_red`. If omitted, the API resolves the program from the model's Cyber tier and your organization and project access, subject to model-specific eligibility restrictions. By default, models without a Cyber tier use Standard. Blue-tier models use Daybreak Blue when authorized; otherwise they fall back to Standard unless the model requires Daybreak access. Red-tier models use Daybreak Red and require authorization. Requests that require unavailable Daybreak access return 403. An implicit Standard fallback is represented by null in the response's access_programs field, rather than an explicit Standard selection."}},"additionalProperties":false,"type":"object","required":[],"description":"Domain-specific access programs to use for this request."},"AdditionalTools":{"properties":{"type":{"type":"string","enum":["additional_tools"],"description":"The type of the item. Always `additional_tools`.","default":"additional_tools","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the additional tools item."},"role":{"$ref":"#/components/schemas/MessageRole","description":"The role that provided the additional tools."},"tools":{"items":{"$ref":"#/components/schemas/Tool"},"type":"array","description":"The additional tool definitions made available at this item."}},"type":"object","required":["type","id","role","tools"]},"AdditionalToolsItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of this additional tools item.","example":"at_123"},{"type":"null"}]},"type":{"type":"string","enum":["additional_tools"],"description":"The item type. Always `additional_tools`.","default":"additional_tools","x-stainless-const":true},"role":{"type":"string","enum":["developer"],"description":"The role that provided the additional tools. Only `developer` is supported.","default":"developer","x-stainless-const":true},"tools":{"items":{"$ref":"#/components/schemas/Tool"},"type":"array","description":"A list of additional tools made available at this item."}},"type":"object","required":["type","role","tools"]},"Annotation":{"oneOf":[{"$ref":"#/components/schemas/FileCitationBody"},{"$ref":"#/components/schemas/UrlCitationBody"},{"$ref":"#/components/schemas/ContainerFileCitationBody"},{"$ref":"#/components/schemas/FilePath"}],"description":"An annotation that applies to a span of output text.","discriminator":{"propertyName":"type"}},"ApplyPatchCallOutputStatus":{"type":"string","enum":["completed","failed"]},"ApplyPatchCallOutputStatusParam":{"type":"string","enum":["completed","failed"],"title":"Apply patch call output status","description":"Outcome values reported for apply_patch tool call outputs."},"ApplyPatchCallStatus":{"type":"string","enum":["in_progress","completed"]},"ApplyPatchCallStatusParam":{"type":"string","enum":["in_progress","completed"],"title":"Apply patch call status","description":"Status values reported for apply_patch tool calls."},"ApplyPatchCreateFileOperation":{"properties":{"type":{"type":"string","enum":["create_file"],"description":"Create a new file with the provided diff.","default":"create_file","x-stainless-const":true},"path":{"type":"string","description":"Path of the file to create."},"diff":{"type":"string","description":"Diff to apply."}},"type":"object","required":["type","path","diff"],"title":"Apply patch create file operation","description":"Instruction describing how to create a file via the apply_patch tool."},"ApplyPatchCreateFileOperationParam":{"properties":{"type":{"type":"string","enum":["create_file"],"description":"The operation type. Always `create_file`.","default":"create_file","x-stainless-const":true},"path":{"type":"string","minLength":1,"description":"Path of the file to create relative to the workspace root."},"diff":{"type":"string","maxLength":10485760,"description":"Unified diff content to apply when creating the file."}},"type":"object","required":["type","path","diff"],"title":"Apply patch create file operation","description":"Instruction for creating a new file via the apply_patch tool."},"ApplyPatchDeleteFileOperation":{"properties":{"type":{"type":"string","enum":["delete_file"],"description":"Delete the specified file.","default":"delete_file","x-stainless-const":true},"path":{"type":"string","description":"Path of the file to delete."}},"type":"object","required":["type","path"],"title":"Apply patch delete file operation","description":"Instruction describing how to delete a file via the apply_patch tool."},"ApplyPatchDeleteFileOperationParam":{"properties":{"type":{"type":"string","enum":["delete_file"],"description":"The operation type. Always `delete_file`.","default":"delete_file","x-stainless-const":true},"path":{"type":"string","minLength":1,"description":"Path of the file to delete relative to the workspace root."}},"type":"object","required":["type","path"],"title":"Apply patch delete file operation","description":"Instruction for deleting an existing file via the apply_patch tool."},"ApplyPatchOperationParam":{"oneOf":[{"$ref":"#/components/schemas/ApplyPatchCreateFileOperationParam"},{"$ref":"#/components/schemas/ApplyPatchDeleteFileOperationParam"},{"$ref":"#/components/schemas/ApplyPatchUpdateFileOperationParam"}],"title":"Apply patch operation","description":"One of the create_file, delete_file, or update_file operations supplied to the apply_patch tool.","discriminator":{"propertyName":"type"}},"ApplyPatchToolCall":{"properties":{"type":{"type":"string","enum":["apply_patch_call"],"description":"The type of the item. Always `apply_patch_call`.","default":"apply_patch_call","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the apply patch tool call. Populated when this item is returned via API."},"call_id":{"type":"string","description":"The unique ID of the apply patch tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCaller","description":"The execution context that produced this tool call."},{"type":"null"}]},"status":{"$ref":"#/components/schemas/ApplyPatchCallStatus","description":"The status of the apply patch tool call. One of `in_progress` or `completed`."},"operation":{"oneOf":[{"$ref":"#/components/schemas/ApplyPatchCreateFileOperation"},{"$ref":"#/components/schemas/ApplyPatchDeleteFileOperation"},{"$ref":"#/components/schemas/ApplyPatchUpdateFileOperation"}],"title":"Apply patch operation","description":"One of the create_file, delete_file, or update_file operations applied via apply_patch.","discriminator":{"propertyName":"type"}},"created_by":{"type":"string","description":"The ID of the entity that created this tool call."}},"type":"object","required":["type","id","call_id","status","operation"],"title":"Apply patch tool call","description":"A tool call that applies file diffs by creating, deleting, or updating files."},"ApplyPatchToolCallItemParam":{"properties":{"type":{"type":"string","enum":["apply_patch_call"],"description":"The type of the item. Always `apply_patch_call`.","default":"apply_patch_call","x-stainless-const":true},"id":{"anyOf":[{"type":"string","description":"The unique ID of the apply patch tool call. Populated when this item is returned via API.","example":"apc_123"},{"type":"null"}]},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the apply patch tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam","description":"The execution context that produced this tool call."},{"type":"null"}]},"status":{"$ref":"#/components/schemas/ApplyPatchCallStatusParam","description":"The status of the apply patch tool call. One of `in_progress` or `completed`."},"operation":{"$ref":"#/components/schemas/ApplyPatchOperationParam","description":"The specific create, delete, or update instruction for the apply_patch tool call."}},"type":"object","required":["type","call_id","status","operation"],"title":"Apply patch tool call","description":"A tool call representing a request to create, delete, or update files using diff patches."},"ApplyPatchToolCallOutput":{"properties":{"type":{"type":"string","enum":["apply_patch_call_output"],"description":"The type of the item. Always `apply_patch_call_output`.","default":"apply_patch_call_output","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the apply patch tool call output. Populated when this item is returned via API."},"call_id":{"type":"string","description":"The unique ID of the apply patch tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCaller","description":"The execution context that produced this tool call."},{"type":"null"}]},"status":{"$ref":"#/components/schemas/ApplyPatchCallOutputStatus","description":"The status of the apply patch tool call output. One of `completed` or `failed`."},"output":{"anyOf":[{"type":"string","description":"Optional textual output returned by the apply patch tool."},{"type":"null"}]},"created_by":{"type":"string","description":"The ID of the entity that created this tool call output."}},"type":"object","required":["type","id","call_id","status"],"title":"Apply patch tool call output","description":"The output emitted by an apply patch tool call."},"ApplyPatchToolCallOutputItemParam":{"properties":{"type":{"type":"string","enum":["apply_patch_call_output"],"description":"The type of the item. Always `apply_patch_call_output`.","default":"apply_patch_call_output","x-stainless-const":true},"id":{"anyOf":[{"type":"string","description":"The unique ID of the apply patch tool call output. Populated when this item is returned via API.","example":"apco_123"},{"type":"null"}]},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the apply patch tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam","description":"The execution context that produced this tool call."},{"type":"null"}]},"status":{"$ref":"#/components/schemas/ApplyPatchCallOutputStatusParam","description":"The status of the apply patch tool call output. One of `completed` or `failed`."},"output":{"anyOf":[{"type":"string","maxLength":10485760,"description":"Optional human-readable log text from the apply patch tool (e.g., patch results or errors)."},{"type":"null"}]}},"type":"object","required":["type","call_id","status"],"title":"Apply patch tool call output","description":"The streamed output emitted by an apply patch tool call."},"ApplyPatchToolParam":{"properties":{"type":{"type":"string","enum":["apply_patch"],"description":"The type of the tool. Always `apply_patch`.","default":"apply_patch","x-stainless-const":true},"allowed_callers":{"anyOf":[{"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"type":"array","minItems":1,"description":"The tool invocation context(s)."},{"type":"null"}]}},"type":"object","required":["type"],"title":"Apply patch tool","description":"Allows the assistant to create, delete, or update files using unified diffs."},"ApplyPatchUpdateFileOperation":{"properties":{"type":{"type":"string","enum":["update_file"],"description":"Update an existing file with the provided diff.","default":"update_file","x-stainless-const":true},"path":{"type":"string","description":"Path of the file to update."},"diff":{"type":"string","description":"Diff to apply."}},"type":"object","required":["type","path","diff"],"title":"Apply patch update file operation","description":"Instruction describing how to update a file via the apply_patch tool."},"ApplyPatchUpdateFileOperationParam":{"properties":{"type":{"type":"string","enum":["update_file"],"description":"The operation type. Always `update_file`.","default":"update_file","x-stainless-const":true},"path":{"type":"string","minLength":1,"description":"Path of the file to update relative to the workspace root."},"diff":{"type":"string","maxLength":10485760,"description":"Unified diff content to apply to the existing file."}},"type":"object","required":["type","path","diff"],"title":"Apply patch update file operation","description":"Instruction for updating an existing file via the apply_patch tool."},"ApproximateLocation":{"properties":{"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always `approximate`.","default":"approximate","x-stainless-const":true},"country":{"anyOf":[{"type":"string","description":"The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`."},{"type":"null"}]},"region":{"anyOf":[{"type":"string","description":"Free text input for the region of the user, e.g. `California`."},{"type":"null"}]},"city":{"anyOf":[{"type":"string","description":"Free text input for the city of the user, e.g. `San Francisco`."},{"type":"null"}]},"timezone":{"anyOf":[{"type":"string","description":"The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`."},{"type":"null"}]}},"type":"object","required":["type"]},"AutoCodeInterpreterToolParam":{"properties":{"type":{"type":"string","enum":["auto"],"description":"Always `auto`.","default":"auto","x-stainless-const":true},"file_ids":{"items":{"type":"string","example":"file-123"},"type":"array","maxItems":50,"description":"An optional list of uploaded files to make available to your code."},"memory_limit":{"anyOf":[{"$ref":"#/components/schemas/ContainerMemoryLimit","description":"The memory limit for the code interpreter container."},{"type":"null"}]},"network_policy":{"oneOf":[{"$ref":"#/components/schemas/ContainerNetworkPolicyDisabledParam"},{"$ref":"#/components/schemas/ContainerNetworkPolicyAllowlistParam"}],"description":"Network access policy for the container.","discriminator":{"propertyName":"type"}}},"type":"object","required":["type"],"title":"CodeInterpreterToolAuto","description":"Configuration for a code interpreter container. Optionally specify the IDs of the files to run the code on."},"CacheMissReasonTypeEnum":{"type":"string","enum":["model_changed","prompt_cache_key_changed","tools_changed","text_format_changed","reasoning_effort_changed","verbosity_changed","context_compacted","input_changed","service_tier_changed"]},"CachedUsageDetails":{"properties":{"cached_text_tokens":{"type":"integer"},"cached_image_tokens":{"type":"integer"}},"type":"object","required":["cached_text_tokens","cached_image_tokens"]},"CallableToolAllowedCaller":{"type":"string","enum":["direct","programmatic"]},"ChatCompletionAllowedTools":{"type":"object","title":"Allowed tools","description":"Constrains the tools available to the model to a pre-defined set.\n","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n"},"tools":{"type":"array","description":"A list of tool definitions that the model should be allowed to call.\n\nFor the Chat Completions API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"function\": { \"name\": \"get_weather\" } },\n { \"type\": \"function\", \"function\": { \"name\": \"get_time\" } }\n]\n```\n","items":{"type":"object","x-oaiExpandable":false,"description":"A tool definition that the model should be allowed to call.\n","additionalProperties":true}}},"required":["mode","tools"]},"ChatCompletionAllowedToolsChoice":{"type":"object","title":"Allowed tools","description":"Constrains the tools available to the model to a pre-defined set.\n","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"Allowed tool configuration type. Always `allowed_tools`.","x-stainless-const":true},"allowed_tools":{"$ref":"#/components/schemas/ChatCompletionAllowedTools"}},"required":["type","allowed_tools"]},"ChatCompletionFunctionCallOption":{"type":"object","description":"Specifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]},"ChatCompletionFunctions":{"type":"object","deprecated":true,"properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"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."},"parameters":{"$ref":"#/components/schemas/FunctionParameters"}},"required":["name"]},"ChatCompletionMessageCustomToolCall":{"type":"object","title":"Custom tool call","description":"A call to a custom tool created by the model.\n","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Always `custom`.","x-stainless-const":true},"custom":{"type":"object","description":"The custom tool that the model called.","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"]}},"required":["id","type","custom"]},"ChatCompletionMessageToolCall":{"type":"object","title":"Function tool call","description":"A call to a function tool created by the model.\n","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only `function` is supported.","x-stainless-const":true},"function":{"type":"object","description":"The function that the model called.","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"]}},"required":["id","type","function"]},"ChatCompletionMessageToolCallChunk":{"type":"object","properties":{"index":{"type":"integer"},"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only `function` is supported.","x-stainless-const":true},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}}}},"required":["index"]},"ChatCompletionMessageToolCalls":{"type":"array","description":"The tool calls generated by the model, such as function calls.","items":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionMessageToolCall"},{"$ref":"#/components/schemas/ChatCompletionMessageCustomToolCall"}],"discriminator":{"propertyName":"type"}}},"ChatCompletionModeration":{"type":"object","description":"Moderation results or errors for the request input and generated output.","properties":{"input":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionModerationResults"},{"$ref":"#/components/schemas/ChatCompletionModerationError"}],"discriminator":{"propertyName":"type"},"description":"Moderation for the request input."},"output":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionModerationResults"},{"$ref":"#/components/schemas/ChatCompletionModerationError"}],"discriminator":{"propertyName":"type"},"description":"Moderation for the generated output."}},"required":["input","output"]},"ChatCompletionModerationError":{"type":"object","description":"An error produced while attempting moderation.","properties":{"type":{"type":"string","enum":["error"],"description":"The object type, which is always `error`.","x-stainless-const":true},"code":{"type":"string","description":"The error code."},"message":{"type":"string","description":"The error message."}},"required":["type","code","message"]},"ChatCompletionModerationResults":{"type":"object","description":"Successful moderation results for the request input or generated output.","properties":{"type":{"type":"string","enum":["moderation_results"],"description":"The object type, which is always `moderation_results`.","x-stainless-const":true},"model":{"type":"string","description":"The moderation model used to generate the results."},"results":{"type":"array","description":"A list of moderation results.","items":{"$ref":"#/components/schemas/ModerationResultBody"}}},"required":["type","model","results"]},"ChatCompletionNamedToolChoice":{"type":"object","title":"Function tool choice","description":"Specifies a tool the model should use. Use to force the model to call a specific function.","properties":{"type":{"type":"string","enum":["function"],"description":"For function calling, the type is always `function`.","x-stainless-const":true},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"]},"ChatCompletionNamedToolChoiceCustom":{"type":"object","title":"Custom tool choice","description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool.","properties":{"type":{"type":"string","enum":["custom"],"description":"For custom tool calling, the type is always `custom`.","x-stainless-const":true},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."}},"required":["name"]}},"required":["type","custom"]},"ChatCompletionRequestAssistantMessage":{"type":"object","title":"Assistant message","description":"Messages sent by the model in response to user messages.\n","properties":{"content":{"anyOf":[{"oneOf":[{"type":"string","description":"The contents of the assistant message.","title":"Text content"},{"type":"array","description":"An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.","title":"Array of content parts","items":{"$ref":"#/components/schemas/ChatCompletionRequestAssistantMessageContentPart"},"minItems":1}],"description":"The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.\n"},{"type":"null"}]},"refusal":{"anyOf":[{"type":"string","description":"The refusal message by the assistant."},{"type":"null"}]},"role":{"type":"string","enum":["assistant"],"description":"The role of the messages author, in this case `assistant`.","x-stainless-const":true},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"audio":{"anyOf":[{"type":"object","description":"Data about a previous audio response from the model.\n[Learn more](https://developers.openai.com/api/docs/guides/audio).\n","required":["id"],"properties":{"id":{"type":"string","description":"Unique identifier for a previous audio response from the model.\n"}}},{"type":"null"}]},"tool_calls":{"$ref":"#/components/schemas/ChatCompletionMessageToolCalls"},"function_call":{"anyOf":[{"type":"object","deprecated":true,"description":"Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.","properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"required":["arguments","name"]},{"type":"null"}]}},"required":["role"]},"ChatCompletionRequestAssistantMessageContentPart":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartText"},{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartRefusal"}],"discriminator":{"propertyName":"type"}},"ChatCompletionRequestDeveloperMessage":{"type":"object","title":"Developer message","description":"Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, `developer` messages\nreplace the previous `system` messages.\n","properties":{"content":{"description":"The contents of the developer message.","oneOf":[{"type":"string","description":"The contents of the developer message.","title":"Text content"},{"type":"array","description":"An array of content parts with a defined type. For developer messages, only type `text` is supported.","title":"Array of content parts","items":{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartText"},"minItems":1}]},"role":{"type":"string","enum":["developer"],"description":"The role of the messages author, in this case `developer`.","x-stainless-const":true},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]},"ChatCompletionRequestFunctionMessage":{"type":"object","title":"Function message","deprecated":true,"properties":{"role":{"type":"string","enum":["function"],"description":"The role of the messages author, in this case `function`.","x-stainless-const":true},"content":{"anyOf":[{"type":"string","description":"The contents of the function message."},{"type":"null"}]},"name":{"type":"string","description":"The name of the function to call."}},"required":["role","content","name"]},"ChatCompletionRequestMessage":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionRequestDeveloperMessage"},{"$ref":"#/components/schemas/ChatCompletionRequestSystemMessage"},{"$ref":"#/components/schemas/ChatCompletionRequestUserMessage"},{"$ref":"#/components/schemas/ChatCompletionRequestAssistantMessage"},{"$ref":"#/components/schemas/ChatCompletionRequestToolMessage"},{"$ref":"#/components/schemas/ChatCompletionRequestFunctionMessage"}],"discriminator":{"propertyName":"role"}},"ChatCompletionRequestMessageContentPartAudio":{"type":"object","title":"Audio content part","description":"Learn about [audio inputs](https://developers.openai.com/api/docs/guides/audio).\n","properties":{"type":{"type":"string","enum":["input_audio"],"description":"The type of the content part. Always `input_audio`.","x-stainless-const":true},"input_audio":{"type":"object","properties":{"data":{"type":"string","description":"Base64 encoded audio data."},"format":{"type":"string","enum":["wav","mp3"],"description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\".\n"}},"required":["data","format"]},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointParam"}},"required":["type","input_audio"]},"ChatCompletionRequestMessageContentPartFile":{"type":"object","title":"File content part","description":"Learn about [file inputs](https://developers.openai.com/api/docs/guides/text) for text generation.\n","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part. Always `file`.","x-stainless-const":true},"file":{"type":"object","properties":{"filename":{"type":"string","description":"The name of the file, used when passing the file to the model as a\nstring.\n"},"file_data":{"type":"string","description":"The base64 encoded file data, used when passing the file to the model\nas a string.\n"},"file_id":{"type":"string","description":"The ID of an uploaded file to use as input.\n"}}},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointParam"}},"required":["type","file"]},"ChatCompletionRequestMessageContentPartImage":{"type":"object","title":"Image content part","description":"Learn about [image inputs](https://developers.openai.com/api/docs/guides/images-vision).\n","properties":{"type":{"type":"string","enum":["image_url"],"description":"The type of the content part.","x-stainless-const":true},"image_url":{"type":"object","properties":{"url":{"type":"string","description":"Either a URL of the image or the base64 encoded image data.","format":"uri"},"detail":{"type":"string","description":"Specifies the detail level of the image. Learn more in the [Vision guide](https://developers.openai.com/api/docs/guides/images-vision#choose-an-image-detail-level).","enum":["auto","low","high","original"],"default":"auto"}},"required":["url"]},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointParam"}},"required":["type","image_url"]},"ChatCompletionRequestMessageContentPartRefusal":{"type":"object","title":"Refusal content part","properties":{"type":{"type":"string","enum":["refusal"],"description":"The type of the content part.","x-stainless-const":true},"refusal":{"type":"string","description":"The refusal message generated by the model."}},"required":["type","refusal"]},"ChatCompletionRequestMessageContentPartText":{"type":"object","title":"Text content part","description":"Learn about [text inputs](https://developers.openai.com/api/docs/guides/text).\n","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part.","x-stainless-const":true},"text":{"type":"string","description":"The text content."},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointParam"}},"required":["type","text"]},"ChatCompletionRequestSystemMessage":{"type":"object","title":"System message","description":"Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, use `developer` messages\nfor this purpose instead.\n","properties":{"content":{"description":"The contents of the system message.","oneOf":[{"type":"string","description":"The contents of the system message.","title":"Text content"},{"type":"array","description":"An array of content parts with a defined type. For system messages, only type `text` is supported.","title":"Array of content parts","items":{"$ref":"#/components/schemas/ChatCompletionRequestSystemMessageContentPart"},"minItems":1}]},"role":{"type":"string","enum":["system"],"description":"The role of the messages author, in this case `system`.","x-stainless-const":true},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]},"ChatCompletionRequestSystemMessageContentPart":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartText"}]},"ChatCompletionRequestToolMessage":{"type":"object","title":"Tool message","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the messages author, in this case `tool`.","x-stainless-const":true},"content":{"oneOf":[{"type":"string","description":"The contents of the tool message.","title":"Text content"},{"type":"array","description":"An array of content parts with a defined type. For tool messages, only type `text` is supported.","title":"Array of content parts","items":{"$ref":"#/components/schemas/ChatCompletionRequestToolMessageContentPart"},"minItems":1}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."}},"required":["role","content","tool_call_id"]},"ChatCompletionRequestToolMessageContentPart":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartText"}]},"ChatCompletionRequestUserMessage":{"type":"object","title":"User message","description":"Messages sent by an end user, containing prompts or additional context\ninformation.\n","properties":{"content":{"description":"The contents of the user message.\n","oneOf":[{"type":"string","description":"The text contents of the message.","title":"Text content"},{"type":"array","description":"An array of content parts with a defined type. Supported options differ based on the [model](https://developers.openai.com/api/docs/models) being used to generate the response. Can contain text, image, or audio inputs.","title":"Array of content parts","items":{"$ref":"#/components/schemas/ChatCompletionRequestUserMessageContentPart"},"minItems":1}]},"role":{"type":"string","enum":["user"],"description":"The role of the messages author, in this case `user`.","x-stainless-const":true},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]},"ChatCompletionRequestUserMessageContentPart":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartText"},{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartImage"},{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartAudio"},{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartFile"}]},"ChatCompletionResponseMessage":{"type":"object","description":"A chat completion message generated by the model.","properties":{"content":{"anyOf":[{"type":"string","description":"The contents of the message."},{"type":"null"}]},"refusal":{"anyOf":[{"type":"string","description":"The refusal message generated by the model."},{"type":"null"}]},"tool_calls":{"anyOf":[{"$ref":"#/components/schemas/ChatCompletionMessageToolCalls"},{"type":"null"}]},"annotations":{"type":"array","description":"Annotations for the message, when applicable, as when using the\n[web search tool](https://developers.openai.com/api/docs/guides/tools-web-search).\n","items":{"type":"object","description":"A URL citation when using web search.\n","required":["type","url_citation"],"properties":{"type":{"type":"string","description":"The type of the URL citation. Always `url_citation`.","enum":["url_citation"],"x-stainless-const":true},"url_citation":{"type":"object","description":"A URL citation when using web search.","required":["end_index","start_index","url","title"],"properties":{"end_index":{"type":"integer","description":"The index of the last character of the URL citation in the message."},"start_index":{"type":"integer","description":"The index of the first character of the URL citation in the message."},"url":{"type":"string","format":"uri","description":"The URL of the web resource."},"title":{"type":"string","description":"The title of the web resource."}}}}}},"role":{"type":"string","enum":["assistant"],"description":"The role of the author of this message.","x-stainless-const":true},"function_call":{"type":["object","null"],"deprecated":true,"description":"Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.","properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"required":["name","arguments"]},"audio":{"anyOf":[{"type":"object","description":"If the audio output modality is requested, this object contains data\nabout the audio response from the model. [Learn more](https://developers.openai.com/api/docs/guides/audio).\n","required":["id","expires_at","data","transcript"],"properties":{"id":{"type":"string","description":"Unique identifier for this audio response."},"expires_at":{"type":"integer","format":"unixtime","description":"The Unix timestamp (in seconds) for when this audio response will\nno longer be accessible on the server for use in multi-turn\nconversations.\n"},"data":{"type":"string","description":"Base64 encoded audio bytes generated by the model, in the format\nspecified in the request.\n"},"transcript":{"type":"string","description":"Transcript of the audio generated by the model."}}},{"type":"null"}]}},"required":["role","content"]},"ChatCompletionStreamOptions":{"anyOf":[{"description":"Options for streaming response. Only set this when you set `stream: true`.\n","type":"object","properties":{"include_usage":{"type":"boolean","description":"If set, an additional chunk will be streamed before the `data: [DONE]`\nmessage. The `usage` field on this chunk shows the token usage statistics\nfor the entire request, and the `choices` field will always be an empty\narray.\n\nAll other chunks will also include a `usage` field, but with a null\nvalue. **NOTE:** If the stream is interrupted, you may not receive the\nfinal usage chunk which contains the total token usage for the request.\n"},"include_obfuscation":{"type":"boolean","description":"When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n"}}},{"type":"null"}]},"ChatCompletionStreamResponseDelta":{"type":"object","description":"A chat completion delta generated by streamed model responses.\nStreamed audio can arrive in partial updates with an ID, base64 data, or\ntranscript text. The final audio update contains only its expiry timestamp.\n","properties":{"audio":{"type":"object","description":"A partial audio response. Audio chunks may carry an ID, base64 data, or\ntranscript text; the final audio update contains only its expiry timestamp.\n","properties":{"id":{"type":"string","description":"Unique identifier for this audio response."},"expires_at":{"type":"integer","format":"unixtime","description":"The Unix timestamp (in seconds) for when this audio response will no\nlonger be accessible on the server for use in multi-turn conversations.\n"},"data":{"type":"string","description":"Base64 encoded audio bytes generated by the model, in the format\nspecified in the request.\n"},"transcript":{"type":"string","description":"Transcript text from this audio chunk."}}},"content":{"anyOf":[{"type":"string","description":"The contents of the chunk message."},{"type":"null"}]},"function_call":{"deprecated":true,"type":"object","description":"Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.","properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}}},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/ChatCompletionMessageToolCallChunk"}},"role":{"type":"string","enum":["developer","system","user","assistant","tool"],"description":"The role of the author of this message."},"refusal":{"anyOf":[{"type":"string","description":"The refusal message generated by the model."},{"type":"null"}]}}},"ChatCompletionTokenLogprob":{"type":"object","properties":{"token":{"description":"The token.","type":"string"},"logprob":{"description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.","type":"number"},"bytes":{"anyOf":[{"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.","type":"array","items":{"type":"integer"}},{"type":"null"}]},"top_logprobs":{"description":"List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.","type":"array","items":{"type":"object","properties":{"token":{"description":"The token.","type":"string"},"logprob":{"description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.","type":"number"},"bytes":{"anyOf":[{"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.","type":"array","items":{"type":"integer"}},{"type":"null"}]}},"required":["token","logprob","bytes"]}}},"required":["token","logprob","bytes","top_logprobs"]},"ChatCompletionTool":{"type":"object","title":"Function tool","description":"A function tool that can be used to generate a response.\n","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only `function` is supported.","x-stainless-const":true},"function":{"$ref":"#/components/schemas/FunctionObject"}},"required":["type","function"]},"ChatCompletionToolChoiceOption":{"description":"Controls which (if any) tool is called by the model.\n`none` means the model will not call any tool and instead generates a message.\n`auto` means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools.\nSpecifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n\n`none` is the default when no tools are present. `auto` is the default if tools are present.\n","oneOf":[{"type":"string","title":"Tool choice mode","description":"`none` means the model will not call any tool 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.\n","enum":["none","auto","required"]},{"$ref":"#/components/schemas/ChatCompletionAllowedToolsChoice"},{"$ref":"#/components/schemas/ChatCompletionNamedToolChoice"},{"$ref":"#/components/schemas/ChatCompletionNamedToolChoiceCustom"}]},"ClickButtonType":{"type":"string","enum":["left","right","wheel","back","forward"]},"ClickParam":{"properties":{"type":{"type":"string","enum":["click"],"description":"Specifies the event type. For a click action, this property is always `click`.","default":"click","x-stainless-const":true},"button":{"$ref":"#/components/schemas/ClickButtonType","description":"Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`."},"x":{"type":"integer","description":"The x-coordinate where the click occurred."},"y":{"type":"integer","description":"The y-coordinate where the click occurred."},"keys":{"anyOf":[{"items":{"type":"string"},"type":"array","description":"The keys being held while clicking."},{"type":"null"}]}},"type":"object","required":["type","button","x","y"],"title":"Click","description":"A click action."},"CodeInterpreterOutputImage":{"properties":{"type":{"type":"string","enum":["image"],"description":"The type of the output. Always `image`.","default":"image","x-stainless-const":true},"url":{"type":"string","format":"uri","description":"The URL of the image output from the code interpreter."}},"type":"object","required":["type","url"],"title":"Code interpreter output image","description":"The image output from the code interpreter."},"CodeInterpreterOutputLogs":{"properties":{"type":{"type":"string","enum":["logs"],"description":"The type of the output. Always `logs`.","default":"logs","x-stainless-const":true},"logs":{"type":"string","description":"The logs output from the code interpreter."}},"type":"object","required":["type","logs"],"title":"Code interpreter output logs","description":"The logs output from the code interpreter."},"CodeInterpreterTool":{"type":"object","title":"Code interpreter","description":"A tool that runs Python code to help generate a response to a prompt.\n","properties":{"type":{"type":"string","enum":["code_interpreter"],"description":"The type of the code interpreter tool. Always `code_interpreter`.\n","x-stainless-const":true},"container":{"description":"The code interpreter container. Can be a container ID or an object that\nspecifies uploaded file IDs to make available to your code, along with an\noptional `memory_limit` setting.\n","oneOf":[{"type":"string","description":"The container ID."},{"$ref":"#/components/schemas/AutoCodeInterpreterToolParam"}]},"allowed_callers":{"anyOf":[{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"description":"The tool invocation context(s)."},{"type":"null"}]}},"required":["type","container"]},"CodeInterpreterToolCall":{"type":"object","title":"Code interpreter tool call","description":"A tool call to run code.\n","properties":{"type":{"type":"string","enum":["code_interpreter_call"],"default":"code_interpreter_call","x-stainless-const":true,"description":"The type of the code interpreter tool call. Always `code_interpreter_call`.\n"},"id":{"type":"string","description":"The unique ID of the code interpreter tool call.\n"},"status":{"type":"string","enum":["in_progress","completed","incomplete","interpreting","failed"],"description":"The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.\n"},"container_id":{"type":"string","description":"The ID of the container used to run the code.\n"},"code":{"anyOf":[{"type":"string","description":"The code to run, or null if not available.\n"},{"type":"null"}]},"outputs":{"anyOf":[{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/CodeInterpreterOutputLogs"},{"$ref":"#/components/schemas/CodeInterpreterOutputImage"}],"discriminator":{"propertyName":"type"}},"discriminator":{"propertyName":"type"},"description":"The outputs generated by the code interpreter, such as logs or images.\nCan be null if no outputs are available.\n"},{"type":"null"}]}},"required":["type","id","status","container_id","code","outputs"]},"CompactionBody":{"properties":{"type":{"type":"string","enum":["compaction"],"description":"The type of the item. Always `compaction`.","default":"compaction","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the compaction item."},"encrypted_content":{"type":"string","description":"The encrypted content that was produced by compaction."},"created_by":{"type":"string","description":"The identifier of the actor that created the item."}},"type":"object","required":["type","id","encrypted_content"],"title":"Compaction item","description":"A compaction item generated by the [`v1/responses/compact` API](https://developers.openai.com/api/reference/resources/responses/methods/compact)."},"CompactionSummaryItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The ID of the compaction item.","example":"cmp_123"},{"type":"null"}]},"type":{"type":"string","enum":["compaction"],"description":"The type of the item. Always `compaction`.","default":"compaction","x-stainless-const":true},"encrypted_content":{"type":"string","maxLength":104857600,"description":"The encrypted content of the compaction summary."}},"type":"object","required":["type","encrypted_content"],"title":"Compaction item","description":"A compaction item generated by the [`v1/responses/compact` API](https://developers.openai.com/api/reference/resources/responses/methods/compact)."},"CompactionTriggerItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of this compaction trigger.","example":"msg_123"},{"type":"null"}]},"type":{"type":"string","enum":["compaction_trigger"],"description":"The type of the item. Always `compaction_trigger`.","default":"compaction_trigger","x-stainless-const":true}},"type":"object","required":["type"],"title":"Compaction trigger","description":"Compacts the current context. Must be the final input item."},"ComparisonFilter":{"type":"object","additionalProperties":false,"title":"Comparison Filter","description":"A filter used to compare a specified attribute key to a given value using a defined comparison operation.\n","properties":{"type":{"type":"string","default":"eq","enum":["eq","ne","gt","gte","lt","lte","in","nin"],"description":"Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.\n- `eq`: equals\n- `ne`: not equal\n- `gt`: greater than\n- `gte`: greater than or equal\n- `lt`: less than\n- `lte`: less than or equal\n- `in`: in\n- `nin`: not in\n"},"key":{"type":"string","description":"The key to compare against the value."},"value":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"number"}]}}],"description":"The value to compare against the attribute key; supports string, number, or boolean types."}},"required":["type","key","value"],"x-oaiMeta":{"name":"ComparisonFilter"}},"CompletionUsage":{"type":"object","description":"Usage statistics for the completion request.","properties":{"completion_tokens":{"type":"integer","default":0,"description":"Number of tokens in the generated completion."},"prompt_tokens":{"type":"integer","default":0,"description":"Number of tokens in the prompt."},"total_tokens":{"type":"integer","default":0,"description":"Total number of tokens used in the request (prompt + completion)."},"completion_tokens_details":{"type":"object","description":"Breakdown of tokens used in a completion.","properties":{"accepted_prediction_tokens":{"type":"integer","default":0,"description":"When using Predicted Outputs, the number of tokens in the\nprediction that appeared in the completion.\n"},"audio_tokens":{"type":"integer","default":0,"description":"Audio input tokens generated by the model."},"reasoning_tokens":{"type":"integer","default":0,"description":"Tokens generated by the model for reasoning."},"text_tokens":{"type":"integer","description":"Text output tokens generated by the model."},"rejected_prediction_tokens":{"type":"integer","default":0,"description":"When using Predicted Outputs, the number of tokens in the\nprediction that did not appear in the completion. However, like\nreasoning tokens, these tokens are still counted in the total\ncompletion tokens for purposes of billing, output, and context window\nlimits.\n"}}},"prompt_tokens_details":{"type":"object","description":"Breakdown of tokens used in the prompt.","properties":{"audio_tokens":{"type":"integer","default":0,"description":"Audio input tokens present in the prompt."},"cached_tokens":{"type":"integer","default":0,"description":"Cached tokens present in the prompt."},"text_tokens":{"type":"integer","description":"Text input tokens present in the prompt."},"image_tokens":{"type":"integer","description":"Image input tokens present in the prompt."},"cache_write_tokens":{"type":"integer","default":0,"description":"The unadjusted number of prompt tokens written to cache."}}}},"required":["prompt_tokens","completion_tokens","total_tokens"]},"CompoundFilter":{"type":"object","additionalProperties":false,"title":"Compound Filter","description":"Combine multiple filters using `and` or `or`.","properties":{"type":{"type":"string","description":"Type of operation: `and` or `or`.","enum":["and","or"]},"filters":{"type":"array","description":"Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`.","items":{"oneOf":[{"$ref":"#/components/schemas/ComparisonFilter"},{"$ref":"#/components/schemas/CompoundFilter"}],"discriminator":{"propertyName":"type"}}}},"required":["type","filters"],"x-oaiMeta":{"name":"CompoundFilter"}},"ComputerAction":{"oneOf":[{"$ref":"#/components/schemas/ClickParam"},{"$ref":"#/components/schemas/DoubleClickAction"},{"$ref":"#/components/schemas/DragParam"},{"$ref":"#/components/schemas/KeyPressAction"},{"$ref":"#/components/schemas/MoveParam"},{"$ref":"#/components/schemas/ScreenshotParam"},{"$ref":"#/components/schemas/ScrollParam"},{"$ref":"#/components/schemas/TypeParam"},{"$ref":"#/components/schemas/WaitParam"}],"discriminator":{"propertyName":"type"}},"ComputerActionList":{"title":"Computer Action List","type":"array","description":"Flattened batched actions for `computer_use`. Each action includes an\n`type` discriminator and action-specific fields.\n","items":{"$ref":"#/components/schemas/ComputerAction"}},"ComputerCallOutputItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The ID of the computer tool call output.","example":"cuo_123"},{"type":"null"}]},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The ID of the computer tool call that produced the output."},"type":{"type":"string","enum":["computer_call_output"],"description":"The type of the computer tool call output. Always `computer_call_output`.","default":"computer_call_output","x-stainless-const":true},"output":{"$ref":"#/components/schemas/ComputerScreenshotImage"},"acknowledged_safety_checks":{"anyOf":[{"items":{"$ref":"#/components/schemas/ComputerCallSafetyCheckParam"},"type":"array","description":"The safety checks reported by the API that have been acknowledged by the developer."},{"type":"null"}]},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionCallItemStatus","description":"The status of the message input. One of `in_progress`, `completed`, or `incomplete`. Populated when input items are returned via API."},{"type":"null"}]}},"type":"object","required":["call_id","type","output"],"title":"Computer tool call output","description":"The output of a computer tool call."},"ComputerCallOutputStatus":{"type":"string","enum":["completed","incomplete","failed"]},"ComputerCallSafetyCheckParam":{"properties":{"id":{"type":"string","description":"The ID of the pending safety check."},"code":{"anyOf":[{"type":"string","description":"The type of the pending safety check."},{"type":"null"}]},"message":{"anyOf":[{"type":"string","description":"Details about the pending safety check."},{"type":"null"}]}},"type":"object","required":["id"],"description":"A pending safety check for the computer call."},"ComputerEnvironment":{"type":"string","enum":["windows","mac","linux","ubuntu","browser"]},"ComputerScreenshotImage":{"type":"object","description":"A computer screenshot image used with the computer use tool.\n","properties":{"type":{"type":"string","enum":["computer_screenshot"],"default":"computer_screenshot","description":"Specifies the event type. For a computer screenshot, this property is \nalways set to `computer_screenshot`.\n","x-stainless-const":true},"image_url":{"type":"string","format":"uri","description":"The URL of the screenshot image."},"file_id":{"type":"string","description":"The identifier of an uploaded file that contains the screenshot."}},"required":["type"]},"ComputerTool":{"properties":{"type":{"type":"string","enum":["computer"],"description":"The type of the computer tool. Always `computer`.","default":"computer","x-stainless-const":true}},"type":"object","required":["type"],"title":"Computer","description":"A tool that controls a virtual computer. Learn more about the [computer tool](https://developers.openai.com/api/docs/guides/tools-computer-use)."},"ComputerToolCall":{"type":"object","title":"Computer tool call","description":"A tool call to a computer use tool. See the\n[computer use guide](https://developers.openai.com/api/docs/guides/tools-computer-use) for more information.\n","properties":{"type":{"type":"string","description":"The type of the computer call. Always `computer_call`.","enum":["computer_call"],"default":"computer_call"},"id":{"type":"string","description":"The unique ID of the computer call."},"call_id":{"type":"string","description":"An identifier used when responding to the tool call with output.\n"},"action":{"$ref":"#/components/schemas/ComputerAction"},"actions":{"$ref":"#/components/schemas/ComputerActionList"},"pending_safety_checks":{"type":"array","items":{"$ref":"#/components/schemas/ComputerCallSafetyCheckParam"},"description":"The pending safety checks for the computer call.\n"},"status":{"type":"string","description":"The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","enum":["in_progress","completed","incomplete"]}},"required":["type","id","call_id","pending_safety_checks","status"]},"ComputerToolCallOutput":{"type":"object","title":"Computer tool call output","description":"The output of a computer tool call.\n","properties":{"type":{"type":"string","description":"The type of the computer tool call output. Always `computer_call_output`.\n","enum":["computer_call_output"],"default":"computer_call_output","x-stainless-const":true},"id":{"type":"string","description":"The ID of the computer tool call output.\n"},"call_id":{"type":"string","description":"The ID of the computer tool call that produced the output.\n"},"acknowledged_safety_checks":{"type":"array","description":"The safety checks reported by the API that have been acknowledged by the\ndeveloper.\n","items":{"$ref":"#/components/schemas/ComputerCallSafetyCheckParam"}},"output":{"$ref":"#/components/schemas/ComputerScreenshotImage"},"status":{"type":"string","description":"The status of the message input. One of `in_progress`, `completed`, or\n`incomplete`. Populated when input items are returned via API.\n","enum":["in_progress","completed","incomplete"]}},"required":["type","call_id","output"]},"ComputerToolCallOutputResource":{"allOf":[{"$ref":"#/components/schemas/ComputerToolCallOutput"},{"type":"object","properties":{"status":{"description":"The status of the message input. One of `in_progress`, `completed`, or\n`incomplete`. Populated when input items are returned via API.\n","$ref":"#/components/schemas/ComputerCallOutputStatus"},"created_by":{"type":"string","description":"The identifier of the actor that created the item.\n"}},"required":["id","status"]}]},"ComputerUsePreviewTool":{"properties":{"type":{"type":"string","enum":["computer_use_preview"],"description":"The type of the computer use tool. Always `computer_use_preview`.","default":"computer_use_preview","x-stainless-const":true},"environment":{"$ref":"#/components/schemas/ComputerEnvironment","description":"The type of computer environment to control."},"display_width":{"type":"integer","description":"The width of the computer display."},"display_height":{"type":"integer","description":"The height of the computer display."}},"type":"object","required":["type","environment","display_width","display_height"],"title":"Computer use preview","description":"A tool that controls a virtual computer. Learn more about the [computer tool](https://developers.openai.com/api/docs/guides/tools-computer-use)."},"ContainerAutoParam":{"properties":{"type":{"type":"string","enum":["container_auto"],"description":"Automatically creates a container for this request","default":"container_auto","x-stainless-const":true},"file_ids":{"items":{"type":"string","example":"file-123"},"type":"array","maxItems":50,"description":"An optional list of uploaded files to make available to your code."},"memory_limit":{"anyOf":[{"$ref":"#/components/schemas/ContainerMemoryLimit","description":"The memory limit for the container."},{"type":"null"}]},"network_policy":{"oneOf":[{"$ref":"#/components/schemas/ContainerNetworkPolicyDisabledParam"},{"$ref":"#/components/schemas/ContainerNetworkPolicyAllowlistParam"}],"description":"Network access policy for the container.","discriminator":{"propertyName":"type"}},"skills":{"items":{"oneOf":[{"$ref":"#/components/schemas/SkillReferenceParam"},{"$ref":"#/components/schemas/InlineSkillParam"}],"discriminator":{"propertyName":"type"}},"type":"array","maxItems":200,"description":"An optional list of skills referenced by id or inline data."}},"type":"object","required":["type"]},"ContainerFileCitationBody":{"properties":{"type":{"type":"string","enum":["container_file_citation"],"description":"The type of the container file citation. Always `container_file_citation`.","default":"container_file_citation","x-stainless-const":true},"container_id":{"type":"string","description":"The ID of the container file."},"file_id":{"type":"string","description":"The ID of the file."},"start_index":{"type":"integer","description":"The index of the first character of the container file citation in the message."},"end_index":{"type":"integer","description":"The index of the last character of the container file citation in the message."},"filename":{"type":"string","description":"The filename of the container file cited."}},"type":"object","required":["type","container_id","file_id","start_index","end_index","filename"],"title":"Container file citation","description":"A citation for a container file used to generate a model response."},"ContainerMemoryLimit":{"type":"string","enum":["1g","4g","16g","64g"]},"ContainerNetworkPolicyAllowlistParam":{"properties":{"type":{"type":"string","enum":["allowlist"],"description":"Allow outbound network access only to specified domains. Always `allowlist`.","default":"allowlist","x-stainless-const":true},"allowed_domains":{"items":{"type":"string"},"type":"array","minItems":1,"description":"A list of allowed domains when type is `allowlist`."},"domain_secrets":{"items":{"$ref":"#/components/schemas/ContainerNetworkPolicyDomainSecretParam"},"type":"array","minItems":1,"description":"Optional domain-scoped secrets for allowlisted domains."}},"type":"object","required":["type","allowed_domains"]},"ContainerNetworkPolicyDisabledParam":{"properties":{"type":{"type":"string","enum":["disabled"],"description":"Disable outbound network access. Always `disabled`.","default":"disabled","x-stainless-const":true}},"type":"object","required":["type"]},"ContainerNetworkPolicyDomainSecretParam":{"properties":{"domain":{"type":"string","minLength":1,"description":"The domain associated with the secret."},"name":{"type":"string","minLength":1,"description":"The name of the secret to inject for the domain."},"value":{"type":"string","maxLength":10485760,"minLength":1,"description":"The secret value to inject for the domain."}},"type":"object","required":["domain","name","value"]},"ContainerReferenceParam":{"properties":{"type":{"type":"string","enum":["container_reference"],"description":"References a container created with the /v1/containers endpoint","default":"container_reference","x-stainless-const":true},"container_id":{"type":"string","description":"The ID of the referenced container.","example":"cntr_123"}},"type":"object","required":["type","container_id"]},"ContainerReferenceResource":{"properties":{"type":{"type":"string","enum":["container_reference"],"description":"The environment type. Always `container_reference`.","default":"container_reference","x-stainless-const":true},"container_id":{"type":"string"}},"type":"object","required":["type","container_id"],"title":"Container Reference","description":"Represents a container created with /v1/containers."},"ContextManagementParam":{"properties":{"type":{"type":"string","description":"The context management entry type. Currently only 'compaction' is supported."},"compact_threshold":{"anyOf":[{"type":"integer","minimum":1000,"description":"Token threshold at which compaction should be triggered for this entry."},{"type":"null"}]}},"type":"object","required":["type"]},"ConversationParam":{"description":"The conversation that this response belongs to. Items from this conversation are prepended to `input_items` for this response request.\nInput items and output items from this response are automatically added to this conversation after this response completes.\n","default":null,"oneOf":[{"type":"string","title":"Conversation ID","description":"The unique ID of the conversation.\n"},{"$ref":"#/components/schemas/ConversationParam-2"}]},"ConversationParam-2":{"properties":{"id":{"type":"string","description":"The unique ID of the conversation.","example":"conv_123"}},"type":"object","required":["id"],"title":"Conversation object","description":"The conversation that this response belongs to."},"CoordParam":{"properties":{"x":{"type":"integer","description":"The x-coordinate."},"y":{"type":"integer","description":"The y-coordinate."}},"type":"object","required":["x","y"],"title":"Coordinate","description":"An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`."},"CreateChatCompletionRequest":{"allOf":[{"$ref":"#/components/schemas/CreateModelResponseProperties"},{"type":"object","properties":{"messages":{"description":"A list of messages comprising the conversation so far. Depending on the\n[model](https://developers.openai.com/api/docs/models) you use, different message types (modalities) are\nsupported, like [text](https://developers.openai.com/api/docs/guides/text),\n[images](https://developers.openai.com/api/docs/guides/images-vision), and [audio](https://developers.openai.com/api/docs/guides/audio).\n","type":"array","minItems":1,"items":{"$ref":"#/components/schemas/ChatCompletionRequestMessage"}},"model":{"description":"Model ID used to generate the response, like `gpt-6-astra` or `o3`. OpenAI\noffers a wide range of models with different capabilities, performance\ncharacteristics, and price points. Refer to the [model guide](https://developers.openai.com/api/docs/models)\nto browse and compare available models.\n","$ref":"#/components/schemas/ModelIdsShared"},"service_tier":{"$ref":"#/components/schemas/ServiceTier"},"modalities":{"$ref":"#/components/schemas/ResponseModalities"},"verbosity":{"$ref":"#/components/schemas/Verbosity"},"reasoning_effort":{"$ref":"#/components/schemas/ReasoningEffort"},"max_completion_tokens":{"description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](https://developers.openai.com/api/docs/guides/reasoning).\n","type":["integer","null"]},"frequency_penalty":{"type":["number","null"],"default":0,"minimum":-2,"maximum":2,"description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on\ntheir existing frequency in the text so far, decreasing the model's\nlikelihood to repeat the same line verbatim.\n"},"presence_penalty":{"type":["number","null"],"default":0,"minimum":-2,"maximum":2,"description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on\nwhether they appear in the text so far, increasing the model's likelihood\nto talk about new topics.\n"},"web_search_options":{"type":"object","title":"Web search","description":"This tool searches the web for relevant results to use in a response.\nLearn more about the [web search tool](https://developers.openai.com/api/docs/guides/tools-web-search).\n","properties":{"user_location":{"type":["object","null"],"required":["type","approximate"],"description":"Approximate location parameters for the search.\n","properties":{"type":{"type":"string","description":"The type of location approximation. Always `approximate`.\n","enum":["approximate"],"x-stainless-const":true},"approximate":{"$ref":"#/components/schemas/WebSearchLocation"}}},"search_context_size":{"$ref":"#/components/schemas/WebSearchContextSize"}}},"top_logprobs":{"description":"An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n`logprobs` must be set to `true` if this parameter is used.\n","type":["integer","null"],"minimum":0,"maximum":20},"response_format":{"description":"An object specifying the format that the model must output.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables\nStructured Outputs which ensures the model will match your supplied JSON\nschema. Learn more in the [Structured Outputs\nguide](https://developers.openai.com/api/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n","oneOf":[{"$ref":"#/components/schemas/ResponseFormatText"},{"$ref":"#/components/schemas/ResponseFormatJsonSchema"},{"$ref":"#/components/schemas/ResponseFormatJsonObject"}],"discriminator":{"propertyName":"type"}},"audio":{"type":["object","null"],"description":"Parameters for audio output. Required when audio output is requested with\n`modalities: [\"audio\"]`. [Learn more](https://developers.openai.com/api/docs/guides/audio).\n","required":["voice","format"],"properties":{"voice":{"$ref":"#/components/schemas/VoiceIdsOrCustomVoice","description":"The voice the model uses to respond. Supported built-in voices are\n`alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`,\n`sage`, `shimmer`, `marin`, and `cedar`. You may also provide a\ncustom voice object with an `id`, for example `{ \"id\": \"voice_1234\" }`.\nCustom voices must be created from audio samples. Voices created from text\nprompts are supported only in Live.\n"},"format":{"type":"string","enum":["wav","aac","mp3","flac","opus","pcm16"],"description":"Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,\n`opus`, or `pcm16`.\n"}}},"store":{"type":["boolean","null"],"default":false,"description":"Whether or not to store the output of this chat completion request for\nuse in our [model distillation](https://developers.openai.com/api/docs/guides/supervised-fine-tuning#distilling-from-a-larger-model) or\n[evals](https://developers.openai.com/api/docs/guides/evals) products.\n\nSupports text and image inputs. Note: image inputs over 8MB will be dropped.\n"},"moderation":{"anyOf":[{"$ref":"#/components/schemas/ModerationParam","description":"Configuration for running moderation on the request input and generated output.\n"},{"type":"null"}]},"stream":{"description":"If set to true, the model response data will be streamed to the client\nas it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).\nSee the [Streaming section below](https://developers.openai.com/api/reference/resources/chat/subresources/completions/streaming-events)\nfor more information, along with the [streaming responses](https://developers.openai.com/api/docs/guides/streaming-responses)\nguide for more information on how to handle the streaming events.\n","type":["boolean","null"],"default":false},"stop":{"$ref":"#/components/schemas/StopConfiguration"},"logit_bias":{"type":["object","null"],"x-oaiTypeLabel":"map","default":null,"additionalProperties":{"type":"integer"},"description":"Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a JSON object that maps tokens (specified by their token ID in the\ntokenizer) to an associated bias value from -100 to 100. Mathematically,\nthe bias is added to the logits generated by the model prior to sampling.\nThe exact effect will vary per model, but values between -1 and 1 should\ndecrease or increase likelihood of selection; values like -100 or 100\nshould result in a ban or exclusive selection of the relevant token.\n"},"logprobs":{"description":"Whether to return log probabilities of the output tokens or not. If true,\nreturns the log probabilities of each output token returned in the\n`content` of `message`.\n","type":["boolean","null"],"default":false},"max_tokens":{"description":"The maximum number of [tokens](https://platform.openai.com/tokenizer) that can be generated in the\nchat completion. This value can be used to control\n[costs](https://openai.com/api/pricing/) for text generated via API.\n\nThis value is now deprecated in favor of `max_completion_tokens`, and is\nnot compatible with [o-series models](https://developers.openai.com/api/docs/guides/reasoning).\n","type":["integer","null"],"deprecated":true},"n":{"type":["integer","null"],"minimum":1,"maximum":128,"default":1,"example":1,"description":"How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs."},"prediction":{"description":"Configuration for a [Predicted Output](https://developers.openai.com/api/docs/guides/predicted-outputs),\nwhich can greatly improve response times when large parts of the model\nresponse are known ahead of time. This is most common when you are\nregenerating a file with only minor changes to most of the content.\n","anyOf":[{"$ref":"#/components/schemas/PredictionContent"},{"type":"null"}]},"seed":{"type":["integer","null"],"format":"int64","minimum":-9223372036854776000,"maximum":9223372036854776000,"deprecated":true,"description":"This feature is in Beta.\nIf specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n","x-oaiMeta":{"beta":true}},"stream_options":{"$ref":"#/components/schemas/ChatCompletionStreamOptions"},"tools":{"type":"array","description":"A list of tools the model may call. You can provide either\n[custom tools](https://developers.openai.com/api/docs/guides/function-calling#custom-tools) or\n[function tools](https://developers.openai.com/api/docs/guides/function-calling).\n","items":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionTool"},{"$ref":"#/components/schemas/CustomToolChatCompletions"}]}},"tool_choice":{"$ref":"#/components/schemas/ChatCompletionToolChoiceOption"},"parallel_tool_calls":{"$ref":"#/components/schemas/ParallelToolCalls"},"function_call":{"deprecated":true,"description":"Deprecated in favor of `tool_choice`.\n\nControls which (if any) function is called by the model.\n\n`none` means the model will not call a function and instead generates a\nmessage.\n\n`auto` means the model can pick between generating a message or calling a\nfunction.\n\nSpecifying a particular function via `{\"name\": \"my_function\"}` forces the\nmodel to call that function.\n\n`none` is the default when no functions are present. `auto` is the default\nif functions are present.\n","oneOf":[{"type":"string","description":"`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.\n","enum":["none","auto"]},{"$ref":"#/components/schemas/ChatCompletionFunctionCallOption"}]},"functions":{"deprecated":true,"description":"Deprecated in favor of `tools`.\n\nA list of functions the model may generate JSON inputs for.\n","type":"array","minItems":1,"maxItems":128,"items":{"$ref":"#/components/schemas/ChatCompletionFunctions"}}},"required":["model","messages"]}]},"CreateChatCompletionResponse":{"type":"object","description":"Represents a chat completion response returned by model, based on the provided input.","properties":{"id":{"type":"string","description":"A unique identifier for the chat completion."},"choices":{"type":"array","description":"A list of chat completion choices. Can be more than one if `n` is greater than 1.","items":{"type":"object","required":["finish_reason","index","message","logprobs"],"properties":{"finish_reason":{"type":"string","description":"The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\nRead the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.\n","enum":["stop","length","tool_calls","content_filter","function_call"]},"index":{"type":"integer","description":"The index of the choice in the list of choices."},"message":{"$ref":"#/components/schemas/ChatCompletionResponseMessage"},"logprobs":{"anyOf":[{"description":"Log probability information for the choice.","type":"object","properties":{"content":{"anyOf":[{"description":"A list of message content tokens with log probability information.","type":"array","items":{"$ref":"#/components/schemas/ChatCompletionTokenLogprob"}},{"type":"null"}]},"refusal":{"anyOf":[{"description":"A list of message refusal tokens with log probability information.","type":"array","items":{"$ref":"#/components/schemas/ChatCompletionTokenLogprob"}},{"type":"null"}]}},"required":["content","refusal"]},{"type":"null"}]}}}},"created":{"type":"integer","format":"unixtime","description":"The Unix timestamp (in seconds) of when the chat completion was created."},"model":{"type":"string","description":"The model used for the chat completion."},"metadata":{"$ref":"#/components/schemas/Metadata"},"service_tier":{"$ref":"#/components/schemas/ServiceTier"},"system_fingerprint":{"type":"string","deprecated":true,"description":"This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n"},"object":{"type":"string","description":"The object type, which is always `chat.completion`.","enum":["chat.completion"],"x-stainless-const":true},"usage":{"$ref":"#/components/schemas/CompletionUsage"},"moderation":{"anyOf":[{"$ref":"#/components/schemas/ChatCompletionModeration","description":"Moderation results for the request input and generated output, if moderated\ncompletions were requested.\n"},{"type":"null"}]}},"required":["choices","created","id","model","object"],"x-oaiMeta":{"name":"The chat completion object","group":"chat","example":"{\n \"id\": \"chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG\",\n \"object\": \"chat.completion\",\n \"created\": 1741570283,\n \"model\": \"gpt-6-astra\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"The image shows a wooden boardwalk path running through a lush green field or meadow. The sky is bright blue with some scattered clouds, giving the scene a serene and peaceful atmosphere. Trees and shrubs are visible in the background.\",\n \"refusal\": null,\n \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 1117,\n \"completion_tokens\": 46,\n \"total_tokens\": 1163,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n \"system_fingerprint\": \"fp_fc9f1d7035\"\n}\n"}},"CreateChatCompletionStreamResponse":{"type":"object","description":"Represents a streamed chunk of a chat completion response returned\nby the model, based on the provided input.\n[Learn more](https://developers.openai.com/api/docs/guides/streaming-responses).\n","properties":{"id":{"type":"string","description":"A unique identifier for the chat completion. Each chunk has the same ID."},"choices":{"type":"array","description":"A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the\nlast chunk if you set `stream_options: {\"include_usage\": true}`.\n","items":{"type":"object","required":["delta","index"],"properties":{"delta":{"$ref":"#/components/schemas/ChatCompletionStreamResponseDelta"},"logprobs":{"description":"Log probability information for the choice.","type":["object","null"],"properties":{"content":{"description":"A list of message content tokens with log probability information.","type":["array","null"],"items":{"$ref":"#/components/schemas/ChatCompletionTokenLogprob"}},"refusal":{"description":"A list of message refusal tokens with log probability information.","type":["array","null"],"items":{"$ref":"#/components/schemas/ChatCompletionTokenLogprob"}}},"required":["content","refusal"]},"finish_reason":{"type":["string","null"],"description":"The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\nOmitted from the final audio update containing only `delta.audio.expires_at`.\n","enum":["stop","length","tool_calls","content_filter","function_call",null]},"index":{"type":"integer","description":"The index of the choice in the list of choices."}}}},"created":{"type":"integer","format":"unixtime","description":"The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp."},"model":{"type":"string","description":"The model to generate the completion."},"obfuscation":{"type":"string","description":"An obfuscation string added to normalize the size of streamed chunks as a\nmitigation to certain side-channel attacks. The field is included by\ndefault and omitted when `stream_options.include_obfuscation` is `false`.\n"},"service_tier":{"$ref":"#/components/schemas/ServiceTier"},"system_fingerprint":{"type":"string","deprecated":true,"description":"This fingerprint represents the backend configuration that the model runs with.\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n"},"object":{"type":"string","description":"The object type, which is always `chat.completion.chunk`.","enum":["chat.completion.chunk"],"x-stainless-const":true},"usage":{"anyOf":[{"$ref":"#/components/schemas/CompletionUsage"},{"type":"null"}],"description":"An optional field that will only be present when you set\n`stream_options: {\"include_usage\": true}` in your request. When present, it\ncontains a null value **except for the last chunk** which contains the\ntoken usage statistics for the entire request.\n\n**NOTE:** If the stream is interrupted or cancelled, you may not\nreceive the final usage chunk which contains the total token usage for\nthe request.\n"},"moderation":{"anyOf":[{"$ref":"#/components/schemas/ChatCompletionModeration","description":"Moderation results for the request input and generated output. Present\non the moderation chunk when moderated completions are requested.\n"},{"type":"null"}]}},"required":["choices","created","id","model","object"],"examples":[{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-6-astra","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"obfuscation":"p9K3xT6w"},{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-6-astra","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"obfuscation":""}],"x-oaiMeta":{"name":"The chat completion chunk object","group":"chat","example":"{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-6-astra\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}],\"obfuscation\":\"r4N7vQ2m\"}\n"}},"CreateCompletionRequest":{"type":"object","properties":{"model":{"description":"ID of the model to use. You can use the [List models](https://developers.openai.com/api/reference/resources/models/methods/list) API to see all of your available models, or see our [Model overview](https://developers.openai.com/api/docs/models) for descriptions of them.\n","anyOf":[{"type":"string"},{"type":"string","enum":["gpt-3.5-turbo-instruct","davinci-002","babbage-002"]}],"x-oaiTypeLabel":"string"},"prompt":{"description":"The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.\n\nNote that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.\n","default":"<|endoftext|>","oneOf":[{"type":"string","default":"","example":"This is a test."},{"type":"array","items":{"type":"string","default":"","example":"This is a test."}},{"type":"array","minItems":1,"items":{"type":"integer"},"example":"[1212, 318, 257, 1332, 13]"},{"type":"array","minItems":1,"items":{"type":"array","minItems":1,"items":{"type":"integer"}},"example":"[[1212, 318, 257, 1332, 13]]"},{"type":"null"}]},"best_of":{"type":["integer","null"],"default":1,"minimum":0,"maximum":20,"description":"Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed.\n\nWhen used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n"},"echo":{"type":["boolean","null"],"default":false,"description":"Echo back the prompt in addition to the completion\n"},"frequency_penalty":{"type":["number","null"],"default":0,"minimum":-2,"maximum":2,"description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](https://developers.openai.com/api/docs/guides/text)\n"},"logit_bias":{"type":["object","null"],"x-oaiTypeLabel":"map","default":null,"additionalProperties":{"type":"integer"},"description":"Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](https://platform.openai.com/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated.\n"},"logprobs":{"type":["integer","null"],"minimum":0,"maximum":5,"default":null,"description":"Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5.\n"},"max_tokens":{"type":["integer","null"],"minimum":0,"default":16,"example":16,"description":"The maximum number of [tokens](https://platform.openai.com/tokenizer) that can be generated in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.\n"},"n":{"type":["integer","null"],"minimum":1,"maximum":128,"default":1,"example":1,"description":"How many completions to generate for each prompt.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n"},"presence_penalty":{"type":["number","null"],"default":0,"minimum":-2,"maximum":2,"description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](https://developers.openai.com/api/docs/guides/text)\n"},"seed":{"type":["integer","null"],"format":"int64","description":"If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\n\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n"},"stop":{"$ref":"#/components/schemas/StopConfiguration"},"stream":{"description":"Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).\n","type":["boolean","null"],"default":false},"stream_options":{"$ref":"#/components/schemas/ChatCompletionStreamOptions"},"suffix":{"description":"The suffix that comes after a completion of inserted text.\n\nThis parameter is only supported for `gpt-3.5-turbo-instruct`.\n","default":null,"type":["string","null"],"example":"test."},"temperature":{"type":["number","null"],"minimum":0,"maximum":2,"default":1,"example":1,"description":"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.\n\nWe generally recommend altering this or `top_p` but not both.\n"},"top_p":{"type":["number","null"],"minimum":0,"maximum":1,"default":1,"example":1,"description":"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.\n\nWe generally recommend altering this or `temperature` but not both.\n"},"user":{"type":"string","example":"user-1234","description":"A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).\n"}},"required":["model","prompt"]},"CreateCompletionResponse":{"type":"object","description":"Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).\n","properties":{"id":{"type":"string","description":"A unique identifier for the completion."},"choices":{"type":"array","description":"The list of completion choices the model generated for the input prompt.","items":{"type":"object","required":["finish_reason","index","logprobs","text"],"properties":{"finish_reason":{"anyOf":[{"type":"string","enum":["stop","length","content_filter"]},{"type":"null"}],"description":"The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\nor `content_filter` if content was omitted due to a flag from our content filters. The value is null while a streamed completion is unfinished.\n"},"index":{"type":"integer"},"logprobs":{"anyOf":[{"type":"object","properties":{"text_offset":{"type":"array","items":{"type":"integer"}},"token_logprobs":{"type":"array","items":{"type":"number"}},"tokens":{"type":"array","items":{"type":"string"}},"top_logprobs":{"type":"array","items":{"type":"object","additionalProperties":{"type":"number"}}}}},{"type":"null"}]},"text":{"type":"string"}}}},"created":{"type":"integer","format":"unixtime","description":"The Unix timestamp (in seconds) of when the completion was created."},"model":{"type":"string","description":"The model used for completion."},"system_fingerprint":{"type":"string","description":"This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n"},"object":{"type":"string","description":"The object type, which is always \"text_completion\"","enum":["text_completion"],"x-stainless-const":true},"usage":{"$ref":"#/components/schemas/CompletionUsage"}},"required":["id","object","created","model","choices"],"x-oaiMeta":{"name":"The completion object","legacy":true,"example":"{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"gpt-3.5-turbo-instruct\",\n \"choices\": [\n {\n \"text\": \"\\n\\nThis is indeed a test\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": \"length\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 5,\n \"completion_tokens\": 7,\n \"total_tokens\": 12\n }\n}\n"}},"CreateEmbeddingRequest":{"type":"object","additionalProperties":false,"properties":{"input":{"description":"Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.\n","example":"The quick brown fox jumped over the lazy dog","oneOf":[{"type":"string","title":"string","description":"The string that will be turned into an embedding.","default":"","example":"This is a test."},{"type":"array","title":"array","description":"The array of strings that will be turned into an embedding.","minItems":1,"maxItems":2048,"items":{"type":"string","default":"","example":"['This is a test.']"}},{"type":"array","title":"array","description":"The array of integers that will be turned into an embedding.","minItems":1,"maxItems":2048,"items":{"type":"integer"},"example":"[1212, 318, 257, 1332, 13]"},{"type":"array","title":"array","description":"The array of arrays containing integers that will be turned into an embedding.","minItems":1,"maxItems":2048,"items":{"type":"array","minItems":1,"items":{"type":"integer"}},"example":"[[1212, 318, 257, 1332, 13]]"}]},"model":{"description":"ID of the model to use. You can use the [List models](https://developers.openai.com/api/reference/resources/models/methods/list) API to see all of your available models, or see our [Model overview](https://developers.openai.com/api/docs/models) for descriptions of them.\n","example":"text-embedding-3-small","anyOf":[{"type":"string"},{"type":"string","enum":["text-embedding-ada-002","text-embedding-3-small","text-embedding-3-large"]}],"x-oaiTypeLabel":"string"},"encoding_format":{"description":"The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).","example":"float","default":"float","type":"string","enum":["float","base64"]},"dimensions":{"description":"The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.\n","type":"integer","minimum":1},"user":{"type":"string","example":"user-1234","description":"A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).\n"}},"required":["model","input"]},"CreateEmbeddingResponse":{"type":"object","properties":{"data":{"type":"array","description":"The list of embeddings generated by the model.","items":{"$ref":"#/components/schemas/Embedding"}},"model":{"type":"string","description":"The name of the model used to generate the embedding."},"object":{"type":"string","description":"The object type, which is always \"list\".","enum":["list"],"x-stainless-const":true},"usage":{"type":"object","description":"The usage information for the request.","properties":{"prompt_tokens":{"type":"integer","description":"The number of tokens used by the prompt."},"total_tokens":{"type":"integer","description":"The total number of tokens used by the request."}},"required":["prompt_tokens","total_tokens"]}},"required":["object","model","data","usage"]},"CreateModelResponseProperties":{"allOf":[{"$ref":"#/components/schemas/ModelResponseProperties"},{"type":"object","properties":{"prompt_cache_options":{"$ref":"#/components/schemas/PromptCacheOptionsParam"},"top_logprobs":{"description":"An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n","type":"integer","minimum":0,"maximum":20}}}]},"CreateResponse":{"allOf":[{"$ref":"#/components/schemas/CreateModelResponseProperties"},{"$ref":"#/components/schemas/ResponseProperties"},{"type":"object","properties":{"access_programs":{"$ref":"#/components/schemas/AccessProgramsParam"},"prompt_cache_options":{"$ref":"#/components/schemas/ResponsePromptCacheOptionsParam"},"service_tier":{"$ref":"#/components/schemas/ServiceTierResponses"},"truncation":{"deprecated":true,"anyOf":[{"type":"string","description":"The truncation strategy to use for the model response.\n- `auto`: If the input to this Response exceeds\n the model's context window size, the model will truncate the\n response to fit the context window by dropping items from the beginning of the conversation.\n- `disabled` (default): If the input size will exceed the context window\n size for a model, the request will fail with a 400 error.\n","enum":["auto","disabled"],"default":"disabled"},{"type":"null"}]},"reasoning":{"anyOf":[{"$ref":"#/components/schemas/Reasoning"},{"type":"null"}]},"input":{"$ref":"#/components/schemas/InputParam"},"include":{"anyOf":[{"type":"array","description":"Specify additional output data to include in the model response. Currently supported values are:\n- `web_search_call.action.sources`: Include the sources of the web search tool call.\n- `code_interpreter_call.outputs`: Includes the outputs of python code execution in code interpreter tool call items.\n- `computer_call_output.output.image_url`: Include image urls from the computer call output.\n- `file_search_call.results`: Include the search results of the file search tool call.\n- `message.input_image.image_url`: Include image urls from the input message.\n- `message.output_text.logprobs`: Include logprobs with assistant messages.\n- `reasoning.encrypted_content`: Includes an encrypted version of reasoning tokens in reasoning item outputs. This enables reasoning items to be used in multi-turn conversations when using the Responses API statelessly (like when the `store` parameter is set to `false`, or when an organization is enrolled in the zero data retention program).","items":{"$ref":"#/components/schemas/IncludeEnum"}},{"type":"null"}]},"parallel_tool_calls":{"anyOf":[{"type":"boolean","description":"Whether to allow the model to run tool calls in parallel.\n","default":true},{"type":"null"}]},"store":{"anyOf":[{"type":"boolean","description":"Whether to store the generated model response for later retrieval via\nAPI.\nDefaults to true when omitted.\nIf set to true, response data will be stored for at least 30 days, subject to the [data retention exceptions](https://developers.openai.com/api/docs/guides/your-data#v1responses).\n","default":true},{"type":"null"}]},"instructions":{"anyOf":[{"type":"string","description":"A system (or developer) message inserted into the model's context.\n\nWhen using along with `previous_response_id`, the instructions from a previous\nresponse will not be carried over to the next response. This makes it simple\nto swap out system (or developer) messages in new responses.\n"},{"type":"null"}]},"moderation":{"anyOf":[{"$ref":"#/components/schemas/ModerationParam","description":"Configuration for running moderation on the input and output of this response.\n"},{"type":"null"}]},"stream":{"anyOf":[{"description":"If set to true, the model response data will be streamed to the client\nas it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).\nSee the [Streaming section below](https://developers.openai.com/api/reference/resources/responses/streaming-events)\nfor more information.\n","type":"boolean","default":false},{"type":"null"}]},"stream_options":{"$ref":"#/components/schemas/ResponseStreamOptions"},"conversation":{"anyOf":[{"$ref":"#/components/schemas/ConversationParam"},{"type":"null"}]},"context_management":{"anyOf":[{"type":"array","example":[{"type":"compaction","compact_threshold":1000}],"description":"Context management configuration for this request.\n","minItems":1,"items":{"$ref":"#/components/schemas/ContextManagementParam"}},{"type":"null"}]},"max_output_tokens":{"anyOf":[{"description":"An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](https://developers.openai.com/api/docs/guides/reasoning).\n","type":"integer","minimum":16},{"type":"null"}]}}}]},"CustomGrammarFormatParam":{"properties":{"type":{"type":"string","enum":["grammar"],"description":"Grammar format. Always `grammar`.","default":"grammar","x-stainless-const":true},"syntax":{"$ref":"#/components/schemas/GrammarSyntax1","description":"The syntax of the grammar definition. One of `lark` or `regex`."},"definition":{"type":"string","description":"The grammar definition."}},"type":"object","required":["type","syntax","definition"],"title":"Grammar format","description":"A grammar defined by the user."},"CustomTextFormatParam":{"properties":{"type":{"type":"string","enum":["text"],"description":"Unconstrained text format. Always `text`.","default":"text","x-stainless-const":true}},"type":"object","required":["type"],"title":"Text format","description":"Unconstrained free-form text."},"CustomToolCall":{"type":"object","title":"Custom tool call","description":"A call to a custom tool created by the model.\n","properties":{"type":{"type":"string","enum":["custom_tool_call"],"x-stainless-const":true,"description":"The type of the custom tool call. Always `custom_tool_call`.\n"},"id":{"type":"string","description":"The unique ID of the custom tool call in the OpenAI platform.\n"},"call_id":{"type":"string","description":"An identifier used to map this custom tool call to a tool call output.\n"},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCaller"},{"type":"null"}]},"namespace":{"type":"string","description":"The namespace of the custom tool being called.\n"},"name":{"type":"string","description":"The name of the custom tool being called.\n"},"input":{"type":"string","description":"The input for the custom tool call generated by the model.\n"},"async":{"type":"boolean","description":"Whether the custom tool call runs asynchronously.\n"}},"required":["type","call_id","name","input"]},"CustomToolCallOutput":{"type":"object","title":"Custom tool call output","description":"The output of a custom tool call from your code, being sent back to the model.\n","properties":{"type":{"type":"string","enum":["custom_tool_call_output"],"x-stainless-const":true,"description":"The type of the custom tool call output. Always `custom_tool_call_output`.\n"},"id":{"type":"string","description":"The unique ID of the custom tool call output in the OpenAI platform.\n"},"call_id":{"type":"string","description":"The call ID, used to map this custom tool call output to a custom tool call.\n"},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam"},{"type":"null"}]},"output":{"description":"The output from the custom tool call generated by your code.\nCan be a string or an list of output content.\n","oneOf":[{"type":"string","description":"A string of the output of the custom tool call.\n","title":"string output"},{"type":"array","items":{"$ref":"#/components/schemas/FunctionAndCustomToolCallOutput"},"title":"output content list","description":"Text, image, or file output of the custom tool call.\n"}]}},"required":["type","call_id","output"]},"CustomToolCallOutputResource":{"title":"ResponseCustomToolCallOutputItem","allOf":[{"$ref":"#/components/schemas/CustomToolCallOutput"},{"type":"object","properties":{"id":{"type":"string","description":"The unique ID of the custom tool call output item.\n"},"status":{"description":"The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","$ref":"#/components/schemas/FunctionCallOutputStatusEnum"},"created_by":{"type":"string","description":"The identifier of the actor that created the item.\n"}},"required":["id","status"]}]},"CustomToolChatCompletions":{"type":"object","title":"Custom tool","description":"A custom tool that processes input using a specified format.\n","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the custom tool. Always `custom`.","x-stainless-const":true},"custom":{"type":"object","title":"Custom tool properties","description":"Properties of the custom tool.\n","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context.\n"},"format":{"description":"The input format for the custom tool. Default is unconstrained text.\n","oneOf":[{"type":"object","title":"Text format","description":"Unconstrained free-form text.","properties":{"type":{"type":"string","enum":["text"],"description":"Unconstrained text format. Always `text`.","x-stainless-const":true}},"required":["type"],"additionalProperties":false},{"type":"object","title":"Grammar format","description":"A grammar defined by the user.","properties":{"type":{"type":"string","enum":["grammar"],"description":"Grammar format. Always `grammar`.","x-stainless-const":true},"grammar":{"type":"object","title":"Grammar format","description":"Your chosen grammar.","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","description":"The syntax of the grammar definition. One of `lark` or `regex`.","enum":["lark","regex"]}},"required":["definition","syntax"]}},"required":["type","grammar"],"additionalProperties":false}]}},"required":["name"]}},"required":["type","custom"]},"CustomToolParam":{"properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the custom tool. Always `custom`.","default":"custom","x-stainless-const":true},"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"async":{"type":"boolean","description":"Whether the tool response can be returned asynchronously versus immediately returned on next response creation."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"$ref":"#/components/schemas/CustomTextFormatParam"},{"$ref":"#/components/schemas/CustomGrammarFormatParam"}],"description":"The input format for the custom tool. Default is unconstrained text.","discriminator":{"propertyName":"type"}},"defer_loading":{"type":"boolean","description":"Whether this tool should be deferred and discovered via tool search."},"allowed_callers":{"anyOf":[{"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"type":"array","minItems":1,"description":"The tool invocation context(s)."},{"type":"null"}]}},"type":"object","required":["type","name"],"title":"Custom tool","description":"A custom tool that processes input using a specified format. Learn more about [custom tools](https://developers.openai.com/api/docs/guides/function-calling#custom-tools)"},"CyberAccessProgramEnum":{"type":"string","enum":["standard","daybreak_blue","daybreak_red"]},"DetailEnum":{"type":"string","enum":["low","high","auto","original"]},"DirectToolCallCaller":{"properties":{"type":{"type":"string","enum":["direct"],"default":"direct","x-stainless-const":true}},"type":"object","required":["type"]},"DirectToolCallCallerParam":{"properties":{"type":{"type":"string","enum":["direct"],"description":"The caller type. Always `direct`.","default":"direct","x-stainless-const":true}},"type":"object","required":["type"]},"DoubleClickAction":{"properties":{"type":{"type":"string","enum":["double_click"],"description":"Specifies the event type. For a double click action, this property is always set to `double_click`.","default":"double_click","x-stainless-const":true},"x":{"type":"integer","description":"The x-coordinate where the double click occurred."},"y":{"type":"integer","description":"The y-coordinate where the double click occurred."},"keys":{"anyOf":[{"items":{"type":"string"},"type":"array","description":"The keys being held while double-clicking."},{"type":"null"}]}},"type":"object","required":["type","x","y","keys"],"title":"DoubleClick","description":"A double click action."},"DragParam":{"properties":{"type":{"type":"string","enum":["drag"],"description":"Specifies the event type. For a drag action, this property is always set to `drag`.","default":"drag","x-stainless-const":true},"path":{"items":{"$ref":"#/components/schemas/CoordParam"},"type":"array","description":"An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg\n```\n[\n { x: 100, y: 200 },\n { x: 200, y: 300 }\n]\n```"},"keys":{"anyOf":[{"items":{"type":"string"},"type":"array","description":"The keys being held while dragging the mouse."},{"type":"null"}]}},"type":"object","required":["type","path"],"title":"Drag","description":"A drag action."},"EasyInputMessage":{"type":"object","title":"Input message","description":"A message input to the model with a role indicating instruction following\nhierarchy. Instructions given with the `developer` or `system` role take\nprecedence over instructions given with the `user` role. Messages with the\n`assistant` role are presumed to have been generated by the model in previous\ninteractions.\n","properties":{"role":{"type":"string","description":"The role of the message input. One of `user`, `assistant`, `system`, or\n`developer`.\n","enum":["user","assistant","system","developer"]},"content":{"description":"Text, image, or audio input to the model, used to generate a response.\nCan also contain previous assistant responses.\n","oneOf":[{"type":"string","title":"Text input","description":"A text input to the model.\n"},{"$ref":"#/components/schemas/InputMessageContentList"}]},"phase":{"anyOf":[{"$ref":"#/components/schemas/MessagePhase"},{"type":"null"}]},"type":{"type":"string","description":"The type of the message input. Always `message`.\n","enum":["message"],"x-stainless-const":true}},"required":["role","content"]},"Embedding":{"type":"object","description":"Represents an embedding vector returned by embedding endpoint.\n","properties":{"index":{"type":"integer","description":"The index of the embedding in the list of embeddings."},"embedding":{"description":"The embedding vector, returned as a list of floats when `encoding_format` is `float` (the default), or as a base64-encoded string when `encoding_format` is `base64`. The length of the vector depends on the model as listed in the [embedding guide](https://developers.openai.com/api/docs/guides/embeddings).\n","anyOf":[{"type":"array","items":{"type":"number","format":"float"}},{"type":"string","contentEncoding":"base64"}]},"object":{"type":"string","description":"The object type, which is always \"embedding\".","enum":["embedding"],"x-stainless-const":true}},"required":["index","object","embedding"],"x-oaiMeta":{"name":"The embedding object","example":"{\n \"object\": \"embedding\",\n \"embedding\": [\n 0.26726124,\n 0.53452248,\n 0.80178373\n ],\n \"index\": 0\n}\n"}},"EmptyModelParam":{"properties":{},"type":"object","required":[]},"Error":{"type":"object","properties":{"code":{"anyOf":[{"type":"string"},{"type":"null"}]},"message":{"type":"string"},"param":{"anyOf":[{"type":"string"},{"type":"null"}]},"type":{"type":"string"},"misalignment":{"$ref":"#/components/schemas/MisalignmentErrorDetailsResource"}},"required":["type","message","param","code"]},"ErrorResponse":{"type":"object","properties":{"error":{"$ref":"#/components/schemas/Error"}},"required":["error"]},"FileCitationBody":{"properties":{"type":{"type":"string","enum":["file_citation"],"description":"The type of the file citation. Always `file_citation`.","default":"file_citation","x-stainless-const":true},"file_id":{"type":"string","description":"The ID of the file."},"index":{"type":"integer","description":"The index in the output text at which to insert the file citation."},"filename":{"type":"string","description":"The filename of the file cited."}},"type":"object","required":["type","file_id","index","filename"],"title":"File citation","description":"A citation to a file."},"FileDetailEnum":{"type":"string","enum":["auto","low","high"]},"FileInputDetail":{"type":"string","enum":["auto","low","high"]},"FilePath":{"type":"object","title":"File path","description":"A path to a file.\n","properties":{"type":{"type":"string","description":"The type of the file path. Always `file_path`.\n","enum":["file_path"],"x-stainless-const":true},"file_id":{"type":"string","description":"The ID of the file.\n"},"index":{"type":"integer","description":"The index of the file in the list of files.\n"}},"required":["type","file_id","index"]},"FileSearchTool":{"properties":{"type":{"type":"string","enum":["file_search"],"description":"The type of the file search tool. Always `file_search`.","default":"file_search","x-stainless-const":true},"vector_store_ids":{"items":{"type":"string"},"type":"array","description":"The IDs of the vector stores to search."},"max_num_results":{"type":"integer","description":"The maximum number of results to return. This number should be between 1 and 50 inclusive."},"ranking_options":{"$ref":"#/components/schemas/RankingOptions","description":"Ranking options for search."},"filters":{"anyOf":[{"$ref":"#/components/schemas/Filters","description":"A filter to apply."},{"type":"null"}]}},"type":"object","required":["type","vector_store_ids"],"title":"File search","description":"A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://developers.openai.com/api/docs/guides/tools-file-search)."},"FileSearchToolCall":{"type":"object","title":"File search tool call","description":"The results of a file search tool call. See the\n[file search guide](https://developers.openai.com/api/docs/guides/tools-file-search) for more information.\n","properties":{"id":{"type":"string","description":"The unique ID of the file search tool call.\n"},"type":{"type":"string","enum":["file_search_call"],"description":"The type of the file search tool call. Always `file_search_call`.\n","x-stainless-const":true},"status":{"type":"string","description":"The status of the file search tool call. One of `in_progress`,\n`searching`, `incomplete` or `failed`,\n","enum":["in_progress","searching","completed","incomplete","failed"]},"queries":{"type":"array","items":{"type":"string"},"description":"The queries used to search for files.\n"},"results":{"anyOf":[{"type":"array","description":"The results of the file search tool call.\n","items":{"type":"object","properties":{"file_id":{"type":"string","description":"The unique ID of the file.\n"},"text":{"type":"string","description":"The text that was retrieved from the file.\n"},"filename":{"type":"string","description":"The name of the file.\n"},"attributes":{"$ref":"#/components/schemas/VectorStoreFileAttributes"},"score":{"type":"number","format":"float","description":"The relevance score of the file - a value between 0 and 1.\n"}}}},{"type":"null"}]}},"required":["id","type","status","queries"]},"Filters":{"anyOf":[{"$ref":"#/components/schemas/ComparisonFilter"},{"$ref":"#/components/schemas/CompoundFilter"}]},"FunctionAndCustomToolCallOutput":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"discriminator":{"propertyName":"type"}},"FunctionCallItemStatus":{"type":"string","enum":["in_progress","completed","incomplete"]},"FunctionCallOutputItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of the function tool call output. Populated when this item is returned via API.","example":"fc_123"},{"type":"null"}]},"call_id":{"anyOf":[{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the function tool call generated by the model."},{"type":"null"}]},"type":{"type":"string","enum":["function_call_output"],"description":"The type of the function tool call output. Always `function_call_output`.","default":"function_call_output","x-stainless-const":true},"output":{"oneOf":[{"type":"string","maxLength":10485760,"description":"A JSON string of the output of the function tool call."},{"items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContentParam"},{"$ref":"#/components/schemas/InputImageContentParamAutoParam"},{"$ref":"#/components/schemas/InputFileContentParam"}],"description":"A piece of message content, such as text, an image, or a file.","discriminator":{"propertyName":"type"}},"type":"array","description":"An array of content outputs (text, image, file) for the function tool call."}],"description":"Text, image, or file output of the function tool call."},"name":{"anyOf":[{"type":"string","maxLength":128,"minLength":1,"description":"The name of the tool that produced the output."},{"type":"null"}]},"namespace":{"anyOf":[{"type":"string","maxLength":64,"minLength":1,"pattern":"^[a-zA-Z0-9_-]+$","description":"The namespace of the tool that produced the output."},{"type":"null"}]},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam","description":"The execution context that produced this tool call."},{"type":"null"}]},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionCallItemStatus","description":"The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API."},{"type":"null"}]}},"type":"object","required":["type","output"],"title":"Function tool call output","description":"The output of a function tool call."},"FunctionCallOutputStatusEnum":{"type":"string","enum":["in_progress","completed","incomplete"]},"FunctionCallStatus":{"type":"string","enum":["in_progress","completed","incomplete"]},"FunctionObject":{"x-openai-structured-output":"function","type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"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."},"parameters":{"$ref":"#/components/schemas/FunctionParameters"},"strict":{"anyOf":[{"type":"boolean","default":false,"description":"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](https://developers.openai.com/api/docs/guides/function-calling)."},{"type":"null"}]}},"required":["name"]},"FunctionParameters":{"type":"object","description":"The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://developers.openai.com/api/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list.","additionalProperties":true},"FunctionShellAction":{"properties":{"commands":{"items":{"type":"string","description":"A list of commands to run."},"type":"array"},"timeout_ms":{"anyOf":[{"type":"integer","description":"Optional timeout in milliseconds for the commands."},{"type":"null"}]},"max_output_length":{"anyOf":[{"type":"integer","description":"Optional maximum number of characters to return from each command."},{"type":"null"}]}},"type":"object","required":["commands","timeout_ms","max_output_length"],"title":"Shell exec action","description":"Execute a shell command."},"FunctionShellActionParam":{"properties":{"commands":{"items":{"type":"string"},"type":"array","description":"Ordered shell commands for the execution environment to run."},"timeout_ms":{"anyOf":[{"type":"integer","description":"Maximum wall-clock time in milliseconds to allow the shell commands to run."},{"type":"null"}]},"max_output_length":{"anyOf":[{"type":"integer","description":"Maximum number of UTF-8 characters to capture from combined stdout and stderr output."},{"type":"null"}]}},"type":"object","required":["commands"],"title":"Shell action","description":"Commands and limits describing how to run the shell tool call."},"FunctionShellCall":{"properties":{"type":{"type":"string","enum":["shell_call"],"description":"The type of the item. Always `shell_call`.","default":"shell_call","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the shell tool call. Populated when this item is returned via API."},"call_id":{"type":"string","description":"The unique ID of the shell tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCaller","description":"The execution context that produced this tool call."},{"type":"null"}]},"action":{"$ref":"#/components/schemas/FunctionShellAction","description":"The shell commands and limits that describe how to run the tool call."},"status":{"$ref":"#/components/schemas/FunctionShellCallStatus","description":"The status of the shell call. One of `in_progress`, `completed`, or `incomplete`."},"environment":{"anyOf":[{"oneOf":[{"$ref":"#/components/schemas/LocalEnvironmentResource"},{"$ref":"#/components/schemas/ContainerReferenceResource"}],"discriminator":{"propertyName":"type"}},{"type":"null"}]},"created_by":{"type":"string","description":"The ID of the entity that created this tool call."}},"type":"object","required":["type","id","call_id","action","status","environment"],"title":"Shell tool call","description":"A tool call that executes one or more shell commands in a managed environment."},"FunctionShellCallItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of the shell tool call. Populated when this item is returned via API.","example":"sh_123"},{"type":"null"}]},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the shell tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam","description":"The execution context that produced this tool call."},{"type":"null"}]},"type":{"type":"string","enum":["shell_call"],"description":"The type of the item. Always `shell_call`.","default":"shell_call","x-stainless-const":true},"action":{"$ref":"#/components/schemas/FunctionShellActionParam","description":"The shell commands and limits that describe how to run the tool call."},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionShellCallItemStatus","description":"The status of the shell call. One of `in_progress`, `completed`, or `incomplete`."},{"type":"null"}]},"environment":{"anyOf":[{"oneOf":[{"$ref":"#/components/schemas/LocalEnvironmentParam"},{"$ref":"#/components/schemas/ContainerReferenceParam"}],"description":"The environment to execute the shell commands in.","discriminator":{"propertyName":"type"}},{"type":"null"}]}},"type":"object","required":["call_id","type","action"],"title":"Shell tool call","description":"A tool representing a request to execute one or more shell commands."},"FunctionShellCallItemStatus":{"type":"string","enum":["in_progress","completed","incomplete"],"title":"Shell call status","description":"Status values reported for shell tool calls."},"FunctionShellCallOutput":{"properties":{"type":{"type":"string","enum":["shell_call_output"],"description":"The type of the shell call output. Always `shell_call_output`.","default":"shell_call_output","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the shell call output. Populated when this item is returned via API."},"call_id":{"type":"string","description":"The unique ID of the shell tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCaller","description":"The execution context that produced this tool call."},{"type":"null"}]},"status":{"$ref":"#/components/schemas/FunctionShellCallOutputStatusEnum","description":"The status of the shell call output. One of `in_progress`, `completed`, or `incomplete`."},"output":{"items":{"$ref":"#/components/schemas/FunctionShellCallOutputContent"},"type":"array","description":"An array of shell call output contents"},"max_output_length":{"anyOf":[{"type":"integer","description":"The maximum length of the shell command output. This is generated by the model and should be passed back with the raw output."},{"type":"null"}]},"created_by":{"type":"string","description":"The identifier of the actor that created the item."}},"type":"object","required":["type","id","call_id","status","output","max_output_length"],"title":"Shell call output","description":"The output of a shell tool call that was emitted."},"FunctionShellCallOutputContent":{"properties":{"stdout":{"type":"string","description":"The standard output that was captured."},"stderr":{"type":"string","description":"The standard error output that was captured."},"outcome":{"oneOf":[{"$ref":"#/components/schemas/FunctionShellCallOutputTimeoutOutcome"},{"$ref":"#/components/schemas/FunctionShellCallOutputExitOutcome"}],"title":"Shell call outcome","description":"Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call output chunk.","discriminator":{"propertyName":"type"}},"created_by":{"type":"string","description":"The identifier of the actor that created the item."}},"type":"object","required":["stdout","stderr","outcome"],"title":"Shell call output content","description":"The content of a shell tool call output that was emitted."},"FunctionShellCallOutputContentParam":{"properties":{"stdout":{"type":"string","maxLength":10485760,"description":"Captured stdout output for the shell call."},"stderr":{"type":"string","maxLength":10485760,"description":"Captured stderr output for the shell call."},"outcome":{"$ref":"#/components/schemas/FunctionShellCallOutputOutcomeParam","description":"The exit or timeout outcome associated with this shell call."}},"type":"object","required":["stdout","stderr","outcome"],"title":"Shell output content","description":"Captured stdout and stderr for a portion of a shell tool call output."},"FunctionShellCallOutputExitOutcome":{"properties":{"type":{"type":"string","enum":["exit"],"description":"The outcome type. Always `exit`.","default":"exit","x-stainless-const":true},"exit_code":{"type":"integer","description":"Exit code from the shell process."}},"type":"object","required":["type","exit_code"],"title":"Shell call exit outcome","description":"Indicates that the shell commands finished and returned an exit code."},"FunctionShellCallOutputExitOutcomeParam":{"properties":{"type":{"type":"string","enum":["exit"],"description":"The outcome type. Always `exit`.","default":"exit","x-stainless-const":true},"exit_code":{"type":"integer","description":"The exit code returned by the shell process."}},"type":"object","required":["type","exit_code"],"title":"Shell call exit outcome","description":"Indicates that the shell commands finished and returned an exit code."},"FunctionShellCallOutputItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of the shell tool call output. Populated when this item is returned via API.","example":"sho_123"},{"type":"null"}]},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the shell tool call generated by the model."},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam","description":"The execution context that produced this tool call."},{"type":"null"}]},"type":{"type":"string","enum":["shell_call_output"],"description":"The type of the item. Always `shell_call_output`.","default":"shell_call_output","x-stainless-const":true},"output":{"items":{"$ref":"#/components/schemas/FunctionShellCallOutputContentParam"},"type":"array","description":"Captured chunks of stdout and stderr output, along with their associated outcomes."},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionShellCallItemStatus","description":"The status of the shell call output."},{"type":"null"}]},"max_output_length":{"anyOf":[{"type":"integer","description":"The maximum number of UTF-8 characters captured for this shell call's combined output."},{"type":"null"}]}},"type":"object","required":["call_id","type","output"],"title":"Shell tool call output","description":"The streamed output items emitted by a shell tool call."},"FunctionShellCallOutputOutcomeParam":{"oneOf":[{"$ref":"#/components/schemas/FunctionShellCallOutputTimeoutOutcomeParam"},{"$ref":"#/components/schemas/FunctionShellCallOutputExitOutcomeParam"}],"title":"Shell call outcome","description":"The exit or timeout outcome associated with this shell call.","discriminator":{"propertyName":"type"}},"FunctionShellCallOutputStatusEnum":{"type":"string","enum":["in_progress","completed","incomplete"]},"FunctionShellCallOutputTimeoutOutcome":{"properties":{"type":{"type":"string","enum":["timeout"],"description":"The outcome type. Always `timeout`.","default":"timeout","x-stainless-const":true}},"type":"object","required":["type"],"title":"Shell call timeout outcome","description":"Indicates that the shell call exceeded its configured time limit."},"FunctionShellCallOutputTimeoutOutcomeParam":{"properties":{"type":{"type":"string","enum":["timeout"],"description":"The outcome type. Always `timeout`.","default":"timeout","x-stainless-const":true}},"type":"object","required":["type"],"title":"Shell call timeout outcome","description":"Indicates that the shell call exceeded its configured time limit."},"FunctionShellCallStatus":{"type":"string","enum":["in_progress","completed","incomplete"]},"FunctionShellToolParam":{"properties":{"type":{"type":"string","enum":["shell"],"description":"The type of the shell tool. Always `shell`.","default":"shell","x-stainless-const":true},"environment":{"anyOf":[{"oneOf":[{"$ref":"#/components/schemas/ContainerAutoParam"},{"$ref":"#/components/schemas/LocalEnvironmentParam"},{"$ref":"#/components/schemas/ContainerReferenceParam"}],"discriminator":{"propertyName":"type"}},{"type":"null"}]},"allowed_callers":{"anyOf":[{"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"type":"array","minItems":1,"description":"The tool invocation context(s)."},{"type":"null"}]}},"type":"object","required":["type"],"title":"Shell tool","description":"A tool that allows the model to execute shell commands."},"FunctionTool":{"properties":{"type":{"type":"string","enum":["function"],"description":"The type of the function tool. Always `function`.","default":"function","x-stainless-const":true},"name":{"type":"string","description":"The name of the function to call."},"async":{"type":"boolean"},"description":{"anyOf":[{"type":"string","description":"A description of the function. Used by the model to determine whether or not to call the function."},{"type":"null"}]},"parameters":{"anyOf":[{"additionalProperties":{},"type":"object","description":"A JSON schema object describing the parameters of the function.","x-oaiTypeLabel":"map"},{"type":"null"}]},"output_schema":{"anyOf":[{"additionalProperties":{},"type":"object","description":"A JSON schema object describing the JSON value encoded in string outputs for this function.","x-oaiTypeLabel":"map"},{"type":"null"}]},"strict":{"anyOf":[{"type":"boolean","description":"Whether strict parameter validation is enforced for this function tool."},{"type":"null"}]},"defer_loading":{"type":"boolean","description":"Whether this function is deferred and loaded via tool search."},"allowed_callers":{"anyOf":[{"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"type":"array","description":"The tool invocation context(s)."},{"type":"null"}]}},"type":"object","required":["type","name","strict","parameters"],"title":"Function","description":"Defines a function in your own code the model can choose to call. Learn more about [function calling](https://developers.openai.com/api/docs/guides/function-calling).","x-openai-structured-output":"function"},"FunctionToolCall":{"type":"object","title":"Function tool call","description":"A tool call to run a function. See the\n[function calling guide](https://developers.openai.com/api/docs/guides/function-calling) for more information.\n","properties":{"id":{"type":"string","description":"The unique ID of the function tool call.\n"},"type":{"type":"string","enum":["function_call"],"description":"The type of the function tool call. Always `function_call`.\n","x-stainless-const":true},"call_id":{"type":"string","description":"The unique ID of the function tool call generated by the model.\n"},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCaller"},{"type":"null"}]},"namespace":{"type":"string","description":"The namespace of the function to run.\n"},"name":{"type":"string","description":"The name of the function to run.\n"},"arguments":{"type":"string","description":"A JSON string of the arguments to pass to the function.\n"},"status":{"type":"string","description":"The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","enum":["in_progress","completed","incomplete"]},"async":{"type":"boolean","description":"Whether the function tool call runs asynchronously.\n"}},"required":["type","call_id","name","arguments"]},"FunctionToolCallOutput":{"type":"object","title":"Function tool call output","description":"The output of a function tool call.\n","properties":{"id":{"type":"string","description":"The unique ID of the function tool call output. Populated when this item\nis returned via API.\n"},"type":{"type":"string","enum":["function_call_output"],"description":"The type of the function tool call output. Always `function_call_output`.\n","x-stainless-const":true},"call_id":{"type":"string","description":"The unique ID of the function tool call generated by the model.\n"},"name":{"type":"string","description":"The name of the tool that produced the output.\n"},"namespace":{"type":"string","description":"The namespace of the tool that produced the output.\n"},"caller":{"anyOf":[{"$ref":"#/components/schemas/ToolCallCallerParam"},{"type":"null"}]},"output":{"description":"The output from the function call generated by your code.\nCan be a string or an list of output content.\n","oneOf":[{"type":"string","description":"A string of the output of the function call.\n","title":"string output"},{"type":"array","items":{"$ref":"#/components/schemas/FunctionAndCustomToolCallOutput"},"title":"output content list","description":"Text, image, or file output of the function call.\n"}]},"status":{"type":"string","description":"The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","enum":["in_progress","completed","incomplete"]}},"required":["type","output"]},"FunctionToolCallOutputResource":{"allOf":[{"$ref":"#/components/schemas/FunctionToolCallOutput"},{"type":"object","properties":{"id":{"type":"string","description":"The unique ID of the function call tool output.\n"},"status":{"description":"The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","$ref":"#/components/schemas/FunctionCallOutputStatusEnum"},"created_by":{"type":"string","description":"The identifier of the actor that created the item.\n"}},"required":["id","status"]}]},"FunctionToolParam":{"properties":{"name":{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-zA-Z0-9_-]+$"},"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"parameters":{"anyOf":[{"$ref":"#/components/schemas/EmptyModelParam"},{"type":"null"}]},"strict":{"anyOf":[{"type":"boolean","description":"Whether to enforce strict parameter validation. If omitted, Responses attempts to use strict validation when the schema is compatible, and falls back to non-strict validation otherwise."},{"type":"null"}]},"type":{"type":"string","enum":["function"],"default":"function","x-stainless-const":true},"async":{"type":"boolean","description":"Whether the tool response can be returned asynchronously versus immediately returned on next response creation."},"output_schema":{"anyOf":[{"additionalProperties":{},"type":"object","description":"A JSON Schema describing the JSON value encoded in string outputs for this function tool. This does not describe content-array outputs.","x-oaiTypeLabel":"map"},{"type":"null"}]},"defer_loading":{"type":"boolean","description":"Whether this function should be deferred and discovered via tool search."},"allowed_callers":{"anyOf":[{"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"type":"array","minItems":1,"description":"The tool invocation context(s)."},{"type":"null"}]}},"type":"object","required":["name","type"],"x-openai-structured-output":"function"},"GrammarSyntax1":{"type":"string","enum":["lark","regex"]},"HTTPError":{"properties":{"type":{"type":"string","enum":["http_error"],"default":"http_error","x-stainless-const":true},"code":{"type":"integer"},"message":{"type":"string"}},"type":"object","required":["type","code","message"]},"HybridSearchOptions":{"properties":{"embedding_weight":{"type":"number","description":"The weight of the embedding in the reciprocal ranking fusion."},"text_weight":{"type":"number","description":"The weight of the text in the reciprocal ranking fusion."}},"type":"object","required":["embedding_weight","text_weight"]},"ImageBackground":{"type":"string","enum":["transparent","opaque","auto"]},"ImageDetail":{"type":"string","enum":["low","high","auto","original"]},"ImageGenActionEnum":{"type":"string","enum":["generate","edit","auto"]},"ImageGenInputUsageDetails":{"properties":{"text_tokens":{"type":"integer","description":"The number of text tokens in the input prompt."},"image_tokens":{"type":"integer","description":"The number of image tokens in the input prompt."}},"type":"object","required":["text_tokens","image_tokens"],"title":"Input usage details","description":"The input tokens detailed information for the image generation."},"ImageGenOutputTokensDetails":{"properties":{"image_tokens":{"type":"integer","description":"The number of image output tokens generated by the model."},"text_tokens":{"type":"integer","description":"The number of text output tokens generated by the model."}},"type":"object","required":["image_tokens","text_tokens"],"title":"Image generation output token details","description":"The output token details for the image generation."},"ImageGenTool":{"type":"object","title":"Image generation tool","description":"A tool that generates images using the GPT image models.\n","properties":{"type":{"type":"string","enum":["image_generation"],"description":"The type of the image generation tool. Always `image_generation`.\n","x-stainless-const":true},"model":{"anyOf":[{"type":"string"},{"type":"string","enum":["gpt-image-1","gpt-image-1-mini","gpt-image-1.5","gpt-image-2","gpt-image-2-2026-04-21","gpt-image-2.5-sunburst","gpt-image-2.5-sunburst-2026-09-08","gpt-image-2.5-flare","gpt-image-2.5-flare-2026-09-08"],"x-openai-enum-deprecations":{"gpt-image-1":{"message":"GPT Image 1 was shut down on October 23, 2026. Use gpt-image-2.5-sunburst or gpt-image-2.5-flare instead."}},"description":"The image generation model to use. One of `gpt-image-1-mini`,\n`gpt-image-1.5`, `gpt-image-2`,\n`gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`,\n`gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`,\n`gpt-image-2.5-flare-2026-09-08`, or `chatgpt-image-latest`. Default:\n`gpt-image-2`.\n\n`gpt-image-1` was shut down on October 23, 2026. Use\n`gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` instead.\n","default":"gpt-image-2"}]},"quality":{"type":"string","enum":["low","medium","high","xhigh","max","auto"],"description":"The quality of the generated image. The GPT image models support `low`,\n`medium`, and `high`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`,\nincluding their `2026-09-08` snapshots, also support `xhigh` and `max`.\nDefault: `auto`.\n","default":"auto"},"size":{"anyOf":[{"type":"string"},{"type":"string","enum":["1024x1024","1024x1536","1536x1024","auto"]}],"description":"The size of the generated images. For `gpt-image-2`, `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing.","default":"auto"},"output_format":{"type":"string","enum":["png","webp","jpeg"],"description":"The output format of the generated image. One of `png`, `webp`, or\n`jpeg`. Default: `png`.\n","default":"png"},"output_compression":{"type":"integer","minimum":0,"maximum":100,"description":"Compression level for the output image. Default: 100.\n","default":100},"moderation":{"type":"string","enum":["auto","low"],"description":"Moderation level for the generated image. Default: `auto`.\n","default":"auto"},"background":{"type":"string","enum":["transparent","opaque","auto"],"description":"Set the background of the generated image. One of `transparent`, `opaque`,\nor `auto`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including\ntheir `2026-09-08` snapshots, support `opaque` and `transparent`\nbackgrounds. Transparent backgrounds are available for supported GPT Image\nmodels. For `gpt-image-2` and `gpt-image-2-2026-04-21`, this support is in\npreview. When using `transparent`, set the output format to `png` or `webp`.\nDefault: `auto`.\n","default":"auto"},"input_fidelity":{"anyOf":[{"$ref":"#/components/schemas/InputFidelity"},{"type":"null"}]},"input_image_mask":{"type":"object","description":"Optional mask for inpainting. Contains `image_url`\n(string, optional) and `file_id` (string, optional).\n","properties":{"image_url":{"type":"string","description":"Base64-encoded mask image.\n"},"file_id":{"type":"string","description":"File ID for the mask image.\n"}},"required":[],"additionalProperties":false},"partial_images":{"type":"integer","minimum":0,"maximum":3,"description":"Number of partial images to generate in streaming mode, from 0 (default value) to 3.\n","default":0},"action":{"description":"Whether to generate a new image or edit an existing image. Default: `auto`.\n","$ref":"#/components/schemas/ImageGenActionEnum"}},"required":["type"]},"ImageGenToolCall":{"properties":{"type":{"type":"string","enum":["image_generation_call"],"description":"The type of the image generation call. Always `image_generation_call`.","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the image generation call."},"status":{"type":"string","enum":["in_progress","completed","generating","failed"],"description":"The status of the image generation call."},"result":{"anyOf":[{"type":"string","description":"The generated image encoded in base64."},{"type":"null"}]},"error":{"$ref":"#/components/schemas/ImageGenToolCallError","description":"Details of a moderation failure, when available."},"size":{"anyOf":[{"anyOf":[{"type":"string"},{"type":"string","enum":["1024x1024","1024x1536","1536x1024"]}],"description":"The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`."},{"type":"null"}]},"quality":{"anyOf":[{"type":"string","enum":["low","medium","high","xhigh","max","auto"],"description":"The quality of the image generated by the image generation tool call. One of `low`, `medium`, `high`, `xhigh`, `max`, or `auto`."},{"type":"null"}]},"action":{"anyOf":[{"$ref":"#/components/schemas/ImageGenActionEnum","description":"The action used for image generation."},{"type":"null"}],"x-openai-go-optional-enum":true},"background":{"anyOf":[{"$ref":"#/components/schemas/ImageBackground","description":"The background setting used for generation."},{"type":"null"}],"x-openai-go-optional-enum":true},"output_format":{"anyOf":[{"$ref":"#/components/schemas/ImageOutputFormat","description":"The output format used for generation."},{"type":"null"}],"x-openai-go-optional-enum":true},"revised_prompt":{"anyOf":[{"type":"string","description":"The prompt that was used after any model prompt rewriting."},{"type":"null"}]}},"type":"object","required":["type","id","status","result"],"title":"Image generation call","description":"An image generation request made by the model."},"ImageGenToolCallError":{"properties":{"code":{"anyOf":[{"type":"string","description":"The error code."},{"type":"null"}]},"type":{"type":"string","description":"The error type."},"message":{"type":"string","description":"A description of the error."},"param":{"anyOf":[{"type":"string","description":"The related request parameter."},{"type":"null"}]},"moderation_details":{"$ref":"#/components/schemas/ImageGenToolCallModerationDetails","description":"Public details for a `moderation_blocked` error, when available."}},"type":"object","required":["code","type","message","param"]},"ImageGenToolCallModerationDetails":{"properties":{"moderation_stage":{"type":"string","enum":["input","output","unknown"],"description":"The stage where moderation blocked the image generation call."},"categories":{"items":{"type":"string"},"type":"array","description":"Public moderation categories. New category values may be added over time."}},"type":"object","required":["moderation_stage","categories"]},"ImageGenToolUsage":{"properties":{"input_tokens":{"type":"integer","description":"The number of tokens (images and text) in the input prompt."},"total_tokens":{"type":"integer","description":"The total number of tokens (images and text) used for the image generation."},"output_tokens":{"type":"integer","description":"The number of output tokens generated by the model."},"output_tokens_details":{"$ref":"#/components/schemas/ImageGenOutputTokensDetails"},"input_tokens_details":{"$ref":"#/components/schemas/ImageGenInputUsageDetails"},"cached_tokens":{"type":"integer"},"cached_tokens_details":{"$ref":"#/components/schemas/CachedUsageDetails"}},"type":"object","required":["input_tokens","total_tokens","output_tokens","input_tokens_details"],"title":"Image generation tool usage","description":"Token usage for image generation tool calls in a response."},"ImageOutputFormat":{"type":"string","enum":["png","webp","jpeg"]},"IncludeEnum":{"type":"string","enum":["file_search_call.results","web_search_call.results","web_search_call.action.sources","message.input_image.image_url","computer_call_output.output.image_url","code_interpreter_call.outputs","reasoning.encrypted_content","message.output_text.logprobs"],"description":"Specify additional output data to include in the model response. Currently supported values are:\n- `web_search_call.results`: Include the search results of the web search tool call.\n- `web_search_call.action.sources`: Include the sources of the web search tool call.\n- `code_interpreter_call.outputs`: Includes the outputs of python code execution in code interpreter tool call items.\n- `computer_call_output.output.image_url`: Include image urls from the computer call output.\n- `file_search_call.results`: Include the search results of the file search tool call.\n- `message.input_image.image_url`: Include image urls from the input message.\n- `message.output_text.logprobs`: Include logprobs with assistant messages.\n- `reasoning.encrypted_content`: Includes an encrypted version of reasoning tokens in reasoning item outputs. This enables reasoning items to be used in multi-turn conversations when using the Responses API statelessly (like when the `store` parameter is set to `false`, or when an organization is enrolled in the zero data retention program)."},"InlineSkillParam":{"properties":{"type":{"type":"string","enum":["inline"],"description":"Defines an inline skill for this request.","default":"inline","x-stainless-const":true},"name":{"type":"string","description":"The name of the skill."},"description":{"type":"string","description":"The description of the skill."},"source":{"$ref":"#/components/schemas/InlineSkillSourceParam","description":"Inline skill payload"}},"type":"object","required":["type","name","description","source"]},"InlineSkillSourceParam":{"properties":{"type":{"type":"string","enum":["base64"],"description":"The type of the inline skill source. Must be `base64`.","default":"base64","x-stainless-const":true},"media_type":{"type":"string","enum":["application/zip"],"description":"The media type of the inline skill payload. Must be `application/zip`.","default":"application/zip","x-stainless-const":true},"data":{"type":"string","maxLength":70254592,"minLength":1,"description":"Base64-encoded skill zip bundle."}},"type":"object","required":["type","media_type","data"],"description":"Inline skill payload"},"InputContent":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"discriminator":{"propertyName":"type"}},"InputFidelity":{"type":"string","enum":["high","low"],"description":"Control how much effort the model will exert to match the style and features, especially facial features, of input images. Supports `high` and `low` on `gpt-image-1.5`; `gpt-image-1-mini` supports only `low`. For `gpt-image-2`, omit this parameter. Defaults to `low` on supported models."},"InputFileContent":{"properties":{"type":{"type":"string","enum":["input_file"],"description":"The type of the input item. Always `input_file`.","default":"input_file","x-stainless-const":true},"file_id":{"anyOf":[{"type":"string","description":"The ID of the file to be sent to the model."},{"type":"null"}]},"filename":{"type":"string","description":"The name of the file to be sent to the model."},"file_data":{"type":"string","description":"The content of the file to be sent to the model.\n"},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointConfig"},"file_url":{"type":"string","format":"uri","description":"The URL of the file to be sent to the model."},"detail":{"$ref":"#/components/schemas/FileInputDetail","description":"The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`."}},"type":"object","required":["type"],"title":"Input file","description":"A file input to the model."},"InputFileContentParam":{"properties":{"type":{"type":"string","enum":["input_file"],"description":"The type of the input item. Always `input_file`.","default":"input_file","x-stainless-const":true},"file_id":{"anyOf":[{"type":"string","description":"The ID of the file to be sent to the model.","example":"file-123"},{"type":"null"}]},"filename":{"anyOf":[{"type":"string","description":"The name of the file to be sent to the model."},{"type":"null"}]},"file_data":{"anyOf":[{"type":"string","maxLength":73400320,"description":"The base64-encoded data of the file to be sent to the model."},{"type":"null"}]},"file_url":{"anyOf":[{"type":"string","format":"uri","description":"The URL of the file to be sent to the model."},{"type":"null"}]},"detail":{"$ref":"#/components/schemas/FileDetailEnum","description":"The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`."},"prompt_cache_breakpoint":{"anyOf":[{"$ref":"#/components/schemas/PromptCacheBreakpointParam"},{"type":"null"}]}},"type":"object","required":["type"],"title":"Input file","description":"A file input to the model."},"InputImageContent":{"properties":{"type":{"type":"string","enum":["input_image"],"description":"The type of the input item. Always `input_image`.","default":"input_image","x-stainless-const":true},"image_url":{"anyOf":[{"type":"string","format":"uri","description":"The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL."},{"type":"null"}]},"file_id":{"anyOf":[{"type":"string","description":"The ID of the file to be sent to the model."},{"type":"null"}]},"detail":{"$ref":"#/components/schemas/ImageDetail","description":"The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`."},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointConfig"}},"type":"object","required":["type","detail"],"title":"Input image","description":"An image input to the model. Learn about [image inputs](https://developers.openai.com/api/docs/guides/images-vision)."},"InputImageContentParamAutoParam":{"properties":{"type":{"type":"string","enum":["input_image"],"description":"The type of the input item. Always `input_image`.","default":"input_image","x-stainless-const":true},"image_url":{"anyOf":[{"type":"string","maxLength":20971520,"format":"uri","description":"The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL."},{"type":"null"}]},"file_id":{"anyOf":[{"type":"string","description":"The ID of the file to be sent to the model.","example":"file-123"},{"type":"null"}]},"detail":{"anyOf":[{"$ref":"#/components/schemas/DetailEnum","description":"The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`."},{"type":"null"}]},"prompt_cache_breakpoint":{"anyOf":[{"$ref":"#/components/schemas/PromptCacheBreakpointParam"},{"type":"null"}]}},"type":"object","required":["type"],"title":"Input image","description":"An image input to the model. Learn about [image inputs](https://developers.openai.com/api/docs/guides/images-vision)"},"InputItem":{"oneOf":[{"$ref":"#/components/schemas/EasyInputMessage"},{"type":"object","title":"Item","description":"An item representing part of the context for the response to be\ngenerated by the model. Can contain text, images, and audio inputs,\nas well as previous assistant responses and tool call outputs.\n","$ref":"#/components/schemas/Item"},{"$ref":"#/components/schemas/CompactionTriggerItemParam"},{"$ref":"#/components/schemas/ItemReferenceParam"},{"$ref":"#/components/schemas/ProgramItemParam"},{"$ref":"#/components/schemas/ProgramOutputItemParam"}],"discriminator":{"propertyName":"type"}},"InputMessage":{"type":"object","title":"Input message","description":"A message input to the model with a role indicating instruction following\nhierarchy. Instructions given with the `developer` or `system` role take\nprecedence over instructions given with the `user` role.\n","properties":{"type":{"type":"string","description":"The type of the message input. Always set to `message`.\n","enum":["message"],"x-stainless-const":true},"role":{"type":"string","description":"The role of the message input. One of `user`, `system`, or `developer`.\n","enum":["user","system","developer"]},"status":{"type":"string","description":"The status of item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","enum":["in_progress","completed","incomplete"]},"content":{"$ref":"#/components/schemas/InputMessageContentList"}},"required":["role","content"]},"InputMessageContentList":{"type":"array","title":"Input item content list","description":"A list of one or many input items to the model, containing different content \ntypes.\n","items":{"$ref":"#/components/schemas/InputContent"}},"InputParam":{"description":"Text, image, or file inputs to the model, used to generate a response.\n\nLearn more:\n- [Text inputs and outputs](https://developers.openai.com/api/docs/guides/text)\n- [Image inputs](https://developers.openai.com/api/docs/guides/images-vision)\n- [File inputs](https://developers.openai.com/api/docs/guides/file-inputs)\n- [Conversation state](https://developers.openai.com/api/docs/guides/conversation-state)\n- [Function calling](https://developers.openai.com/api/docs/guides/function-calling)\n","oneOf":[{"type":"string","title":"Text input","description":"A text input to the model, equivalent to a text input with the\n`user` role.\n"},{"type":"array","title":"Input item list","description":"A list of one or many input items to the model, containing\ndifferent content types.\n","items":{"$ref":"#/components/schemas/InputItem"}}]},"InputTextContent":{"properties":{"type":{"type":"string","enum":["input_text"],"description":"The type of the input item. Always `input_text`.","default":"input_text","x-stainless-const":true},"text":{"type":"string","description":"The text input to the model."},"prompt_cache_breakpoint":{"$ref":"#/components/schemas/PromptCacheBreakpointConfig"}},"type":"object","required":["type","text"],"title":"Input text","description":"A text input to the model."},"InputTextContentParam":{"properties":{"type":{"type":"string","enum":["input_text"],"description":"The type of the input item. Always `input_text`.","default":"input_text","x-stainless-const":true},"text":{"type":"string","maxLength":10485760,"description":"The text input to the model."},"prompt_cache_breakpoint":{"anyOf":[{"$ref":"#/components/schemas/PromptCacheBreakpointParam"},{"type":"null"}]}},"type":"object","required":["type","text"],"title":"Input text","description":"A text input to the model."},"Item":{"type":"object","description":"Content item used to generate a response.\n","oneOf":[{"$ref":"#/components/schemas/InputMessage"},{"$ref":"#/components/schemas/OutputMessage"},{"$ref":"#/components/schemas/FileSearchToolCall"},{"$ref":"#/components/schemas/ComputerToolCall"},{"$ref":"#/components/schemas/ComputerCallOutputItemParam"},{"$ref":"#/components/schemas/WebSearchToolCall"},{"$ref":"#/components/schemas/FunctionToolCall"},{"$ref":"#/components/schemas/FunctionCallOutputItemParam"},{"$ref":"#/components/schemas/ToolSearchCallItemParam"},{"$ref":"#/components/schemas/ToolSearchOutputItemParam"},{"$ref":"#/components/schemas/AdditionalToolsItemParam"},{"$ref":"#/components/schemas/ResponseConfigurationUpdateItemParam"},{"$ref":"#/components/schemas/ReasoningItem"},{"$ref":"#/components/schemas/CompactionSummaryItemParam"},{"$ref":"#/components/schemas/ImageGenToolCall"},{"$ref":"#/components/schemas/CodeInterpreterToolCall"},{"$ref":"#/components/schemas/LocalShellToolCall"},{"$ref":"#/components/schemas/LocalShellToolCallOutput"},{"$ref":"#/components/schemas/FunctionShellCallItemParam"},{"$ref":"#/components/schemas/FunctionShellCallOutputItemParam"},{"$ref":"#/components/schemas/ApplyPatchToolCallItemParam"},{"$ref":"#/components/schemas/ApplyPatchToolCallOutputItemParam"},{"$ref":"#/components/schemas/MCPListTools"},{"$ref":"#/components/schemas/MCPApprovalRequest"},{"$ref":"#/components/schemas/MCPApprovalResponse"},{"$ref":"#/components/schemas/MCPToolCall"},{"$ref":"#/components/schemas/CustomToolCallOutput"},{"$ref":"#/components/schemas/CustomToolCall"}],"discriminator":{"propertyName":"type"}},"ItemReferenceParam":{"properties":{"type":{"anyOf":[{"type":"string","enum":["item_reference"],"description":"The type of item to reference. Always `item_reference`.","default":"item_reference","x-stainless-const":true},{"type":"null"}]},"id":{"type":"string","description":"The ID of the item to reference."}},"type":"object","required":["id"],"title":"Item reference","description":"An internal identifier for an item to reference."},"KeyPressAction":{"properties":{"type":{"type":"string","enum":["keypress"],"description":"Specifies the event type. For a keypress action, this property is always set to `keypress`.","default":"keypress","x-stainless-const":true},"keys":{"items":{"type":"string","description":"One of the keys the model is requesting to be pressed."},"type":"array","description":"The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key."}},"type":"object","required":["type","keys"],"title":"KeyPress","description":"A collection of keypresses the model would like to perform."},"ListModelsResponse":{"type":"object","properties":{"object":{"type":"string","enum":["list"],"x-stainless-const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/Model"}}},"required":["object","data"]},"LocalEnvironmentParam":{"properties":{"type":{"type":"string","enum":["local"],"description":"Use a local computer environment.","default":"local","x-stainless-const":true},"skills":{"items":{"$ref":"#/components/schemas/LocalSkillParam"},"type":"array","maxItems":200,"description":"An optional list of skills."}},"type":"object","required":["type"]},"LocalEnvironmentResource":{"properties":{"type":{"type":"string","enum":["local"],"description":"The environment type. Always `local`.","default":"local","x-stainless-const":true}},"type":"object","required":["type"],"title":"Local Environment","description":"Represents the use of a local environment to perform shell actions."},"LocalShellExecAction":{"properties":{"type":{"type":"string","enum":["exec"],"description":"The type of the local shell action. Always `exec`.","default":"exec","x-stainless-const":true},"command":{"items":{"type":"string"},"type":"array","description":"The command to run."},"timeout_ms":{"anyOf":[{"type":"integer","description":"Optional timeout in milliseconds for the command."},{"type":"null"}]},"working_directory":{"anyOf":[{"type":"string","description":"Optional working directory to run the command in."},{"type":"null"}]},"env":{"additionalProperties":{"type":"string"},"type":"object","description":"Environment variables to set for the command.","x-oaiTypeLabel":"map"},"user":{"anyOf":[{"type":"string","description":"Optional user to run the command as."},{"type":"null"}]}},"type":"object","required":["type","command","env"],"title":"Local shell exec action","description":"Execute a shell command on the server."},"LocalShellToolCall":{"type":"object","title":"Local shell call","description":"A tool call to run a command on the local shell.\n","properties":{"type":{"type":"string","enum":["local_shell_call"],"description":"The type of the local shell call. Always `local_shell_call`.\n","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the local shell call.\n"},"call_id":{"type":"string","description":"The unique ID of the local shell tool call generated by the model.\n"},"action":{"$ref":"#/components/schemas/LocalShellExecAction"},"status":{"type":"string","enum":["in_progress","completed","incomplete"],"description":"The status of the local shell call.\n"}},"required":["type","id","call_id","action","status"]},"LocalShellToolCallOutput":{"type":"object","title":"Local shell call output","description":"The output of a local shell tool call.\n","properties":{"type":{"type":"string","enum":["local_shell_call_output"],"description":"The type of the local shell tool call output. Always `local_shell_call_output`.\n","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the local shell tool call generated by the model.\n"},"output":{"type":"string","description":"A JSON string of the output of the local shell tool call.\n"},"status":{"anyOf":[{"type":"string","enum":["in_progress","completed","incomplete"],"description":"The status of the item. One of `in_progress`, `completed`, or `incomplete`.\n"},{"type":"null"}]}},"required":["id","type","call_id","output"]},"LocalShellToolParam":{"properties":{"type":{"type":"string","enum":["local_shell"],"description":"The type of the local shell tool. Always `local_shell`.","default":"local_shell","x-stainless-const":true}},"type":"object","required":["type"],"title":"Local shell tool","description":"A tool that allows the model to execute shell commands in a local environment."},"LocalSkillParam":{"properties":{"name":{"type":"string","description":"The name of the skill."},"description":{"type":"string","description":"The description of the skill."},"path":{"type":"string","description":"The path to the directory containing the skill."}},"type":"object","required":["name","description","path"]},"LogProb":{"properties":{"token":{"type":"string"},"logprob":{"type":"number"},"bytes":{"items":{"type":"integer"},"type":"array"},"top_logprobs":{"items":{"$ref":"#/components/schemas/TopLogProb"},"type":"array"}},"type":"object","required":["token","logprob","bytes","top_logprobs"],"title":"Log probability","description":"The log probability of a token."},"MCPApprovalRequest":{"type":"object","title":"MCP approval request","description":"A request for human approval of a tool invocation.\n","properties":{"type":{"type":"string","enum":["mcp_approval_request"],"description":"The type of the item. Always `mcp_approval_request`.\n","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the approval request.\n"},"server_label":{"type":"string","description":"The label of the MCP server making the request.\n"},"name":{"type":"string","description":"The name of the tool to run.\n"},"arguments":{"type":"string","description":"A JSON string of arguments for the tool.\n"}},"required":["type","id","server_label","name","arguments"]},"MCPApprovalResponse":{"type":"object","title":"MCP approval response","description":"A response to an MCP approval request.\n","properties":{"type":{"type":"string","enum":["mcp_approval_response"],"description":"The type of the item. Always `mcp_approval_response`.\n","x-stainless-const":true},"id":{"anyOf":[{"type":"string","description":"The unique ID of the approval response\n"},{"type":"null"}]},"approval_request_id":{"type":"string","description":"The ID of the approval request being answered.\n"},"approve":{"type":"boolean","description":"Whether the request was approved.\n"},"reason":{"anyOf":[{"type":"string","description":"Optional reason for the decision.\n"},{"type":"null"}]}},"required":["type","request_id","approve","approval_request_id"]},"MCPApprovalResponseResource":{"type":"object","title":"MCP approval response","description":"A response to an MCP approval request.\n","properties":{"type":{"type":"string","enum":["mcp_approval_response"],"description":"The type of the item. Always `mcp_approval_response`.\n","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the approval response\n"},"approval_request_id":{"type":"string","description":"The ID of the approval request being answered.\n"},"approve":{"type":"boolean","description":"Whether the request was approved.\n"},"reason":{"anyOf":[{"type":"string","description":"Optional reason for the decision.\n"},{"type":"null"}]}},"required":["type","id","request_id","approve","approval_request_id"]},"MCPListTools":{"type":"object","title":"MCP list tools","description":"A list of tools available on an MCP server.\n","properties":{"type":{"type":"string","enum":["mcp_list_tools"],"description":"The type of the item. Always `mcp_list_tools`.\n","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the list.\n"},"server_label":{"type":"string","description":"The label of the MCP server.\n"},"tools":{"type":"array","items":{"$ref":"#/components/schemas/MCPListToolsTool"},"description":"The tools available on the server.\n"},"error":{"anyOf":[{"type":"string","description":"Error message if the server could not list tools.\n"},{"type":"null"}]}},"required":["type","id","server_label","tools"]},"MCPListToolsTool":{"type":"object","title":"MCP list tools tool","description":"A tool available on an MCP server.\n","properties":{"name":{"type":"string","description":"The name of the tool.\n"},"description":{"anyOf":[{"type":"string","description":"The description of the tool.\n"},{"type":"null"}]},"input_schema":{"type":"object","description":"The JSON schema describing the tool's input.\n"},"annotations":{"anyOf":[{"type":"object","description":"Additional annotations about the tool.\n"},{"type":"null"}]}},"required":["name","input_schema"]},"MCPProtocolError":{"properties":{"type":{"type":"string","enum":["mcp_protocol_error"],"default":"mcp_protocol_error","x-stainless-const":true},"code":{"type":"integer"},"message":{"type":"string"}},"type":"object","required":["type","code","message"]},"MCPTool":{"type":"object","title":"MCP tool","description":"Give the model access to additional tools via remote Model Context Protocol\n(MCP) servers. [Learn more about MCP](https://developers.openai.com/api/docs/guides/tools-connectors-mcp).\n","properties":{"type":{"type":"string","enum":["mcp"],"description":"The type of the MCP tool. Always `mcp`.","x-stainless-const":true},"server_label":{"type":"string","description":"A label for this MCP server, used to identify it in tool calls.\n"},"server_url":{"type":"string","format":"uri","description":"The URL for the MCP server. One of `server_url`, `connector_id`, or\n`tunnel_id` must be provided.\n"},"connector_id":{"type":"string","deprecated":true,"enum":["connector_dropbox","connector_gmail","connector_googlecalendar","connector_googledrive","connector_microsoftteams","connector_outlookcalendar","connector_outlookemail","connector_sharepoint"],"description":"Identifier for service connectors, like those available in ChatGPT. One of\n`server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more\nabout service connectors [here](https://developers.openai.com/api/docs/guides/tools-connectors-mcp#connectors).\n\nThis field is deprecated for models released after September 1, 2026.\nUse `server_url` to connect to a remote MCP server, or `tunnel_id` to\nconnect through a Secure MCP Tunnel.\n\nCurrently supported `connector_id` values are:\n\n- Dropbox: `connector_dropbox`\n- Gmail: `connector_gmail`\n- Google Calendar: `connector_googlecalendar`\n- Google Drive: `connector_googledrive`\n- Microsoft Teams: `connector_microsoftteams`\n- Outlook Calendar: `connector_outlookcalendar`\n- Outlook Email: `connector_outlookemail`\n- SharePoint: `connector_sharepoint`\n"},"tunnel_id":{"type":"string","pattern":"^tunnel_[a-z0-9]{32}$","description":"The Secure MCP Tunnel ID to use instead of a direct server URL. One of\n`server_url`, `connector_id`, or `tunnel_id` must be provided.\n"},"authorization":{"type":"string","description":"An OAuth access token that can be used with a remote MCP server, either\nwith a custom MCP server URL or a service connector. Your application\nmust handle the OAuth authorization flow and provide the token here.\n"},"server_description":{"type":"string","description":"Optional description of the MCP server, used to provide more context.\n"},"headers":{"anyOf":[{"type":"object","additionalProperties":{"type":"string"},"description":"Optional HTTP headers to send to the MCP server. Use for authentication\nor other purposes.\n"},{"type":"null"}]},"allowed_tools":{"anyOf":[{"description":"List of allowed tool names or a filter object.\n","oneOf":[{"type":"array","title":"MCP allowed tools","description":"A string array of allowed tool names","items":{"type":"string"}},{"$ref":"#/components/schemas/MCPToolFilter"}]},{"type":"null"}]},"allowed_callers":{"anyOf":[{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"description":"The tool invocation context(s)."},{"type":"null"}]},"require_approval":{"anyOf":[{"description":"Specify which of the MCP server's tools require approval.","oneOf":[{"type":"object","title":"MCP tool approval filter","description":"Specify which of the MCP server's tools require approval. Can be\n`always`, `never`, or a filter object associated with tools\nthat require approval.\n","properties":{"always":{"$ref":"#/components/schemas/MCPToolFilter"},"never":{"$ref":"#/components/schemas/MCPToolFilter"}},"additionalProperties":false},{"type":"string","title":"MCP tool approval setting","description":"Specify a single approval policy for all tools. One of `always` or\n`never`. When set to `always`, all tools will require approval. When\nset to `never`, all tools will not require approval.\n","enum":["always","never"]}],"default":"always"},{"type":"null"}]},"defer_loading":{"type":"boolean","description":"Whether this MCP tool is deferred and discovered via tool search.\n"}},"required":["type","server_label"]},"MCPToolCall":{"type":"object","title":"MCP tool call","description":"An invocation of a tool on an MCP server.\n","properties":{"type":{"type":"string","enum":["mcp_call"],"description":"The type of the item. Always `mcp_call`.\n","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the tool call.\n"},"server_label":{"type":"string","description":"The label of the MCP server running the tool.\n"},"name":{"type":"string","description":"The name of the tool that was run.\n"},"arguments":{"type":"string","description":"A JSON string of the arguments passed to the tool.\n"},"output":{"anyOf":[{"type":"string","description":"The output from the tool call.\n"},{"type":"null"}]},"error":{"description":"The error from the tool call, if any.","anyOf":[{"$ref":"#/components/schemas/MCPToolCallError"},{"type":"null"}]},"status":{"$ref":"#/components/schemas/MCPToolCallStatus","description":"The status of the tool call. One of `in_progress`, `completed`, `incomplete`, `calling`, or `failed`.\n"},"approval_request_id":{"anyOf":[{"type":"string","description":"Unique identifier for the MCP tool call approval request.\nInclude this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.\n"},{"type":"null"}]}},"required":["type","id","server_label","name","arguments"]},"MCPToolCallError":{"oneOf":[{"$ref":"#/components/schemas/MCPProtocolError"},{"$ref":"#/components/schemas/MCPToolExecutionError"},{"$ref":"#/components/schemas/HTTPError"}],"discriminator":{"propertyName":"type"}},"MCPToolCallStatus":{"type":"string","enum":["in_progress","completed","incomplete","calling","failed"]},"MCPToolExecutionError":{"properties":{"type":{"type":"string","enum":["mcp_tool_execution_error"],"default":"mcp_tool_execution_error","x-stainless-const":true},"content":{}},"type":"object","required":["type","content"]},"MCPToolFilter":{"type":"object","title":"MCP tool filter","description":"A filter object to specify which tools are allowed.\n","properties":{"tool_names":{"type":"array","title":"MCP allowed tools","items":{"type":"string"},"description":"List of allowed tool names."},"read_only":{"type":"boolean","description":"Indicates whether or not a tool modifies data or is read-only. If an\nMCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),\nit will match this filter.\n"}},"required":[],"additionalProperties":false},"MessagePhase":{"type":"string","description":"Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`).\nFor models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend\nphase on all assistant messages — dropping it can degrade performance. Not used for user messages.\n","enum":["commentary","final_answer"]},"MessageRole":{"type":"string","enum":["unknown","user","assistant","system","critic","discriminator","developer","tool"]},"Metadata":{"anyOf":[{"type":"object","description":"Set of 16 key-value pairs that can be attached to an object. This can be\nuseful for storing additional information about the object in a structured\nformat, and querying for objects via API or the dashboard.\n\nKeys are strings with a maximum length of 64 characters. Values are strings\nwith a maximum length of 512 characters.\n","additionalProperties":{"type":"string"},"x-oaiTypeLabel":"map"},{"type":"null"}]},"MisalignmentErrorDetailsResource":{"properties":{"review_target":{"anyOf":[{"not":{"pattern":"[^A-Za-z0-9._~:-]"},"type":"string","maxLength":96,"minLength":1,"pattern":"^[A-Za-z0-9._~:-]+$","description":"An opaque target for explicitly continuing this review, or null when unavailable."},{"type":"null"}]},"error_type":{"$ref":"#/components/schemas/_MisalignmentErrorType","description":"An optional classification; clients must accept additional values."},"detailed_explanation":{"type":"string","description":"The public explanation for this block."},"steer":{"$ref":"#/components/schemas/_MisalignmentSteer","description":"An optional public continuation instruction."}},"type":"object","required":[]},"Model":{"title":"Model","description":"Describes an OpenAI model offering that can be used with the API.","properties":{"id":{"type":"string","description":"The model identifier, which can be referenced in the API endpoints."},"created":{"type":"integer","format":"unixtime","description":"The Unix timestamp (in seconds) when the model was created."},"object":{"type":"string","description":"The object type, which is always \"model\".","enum":["model"],"x-stainless-const":true},"owned_by":{"type":"string","description":"The organization that owns the model."},"shutdown_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"description":"The date when the model will shut down, or null if not announced."}},"required":["id","object","created","owned_by"],"x-oaiMeta":{"name":"The model object","example":"{\n \"id\": \"gpt-6-astra\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"openai\",\n \"shutdown_date\": \"2026-10-23\"\n}\n"}},"ModelIdsResponses":{"example":"gpt-6-astra","anyOf":[{"$ref":"#/components/schemas/ModelIdsShared"},{"type":"string","title":"ResponsesOnlyModel","enum":["o1-pro","o1-pro-2025-03-19","o3-pro","o3-pro-2025-06-10","o3-deep-research","o3-deep-research-2025-06-26","o4-mini-deep-research","o4-mini-deep-research-2025-06-26","computer-use-preview","computer-use-preview-2025-03-11","gpt-5.5-pro","gpt-5.5-pro-2026-04-23","gpt-5-codex","gpt-5-pro","gpt-5-pro-2025-10-06","gpt-5.1-codex-max","gpt-daybreak-blue-latest","gpt-daybreak-red-latest","gpt-5.6-cyber","gpt-rosalind-research"],"x-openai-enum-deprecations":{"o1-pro":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1-pro-2025-03-19":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-pro-2025-06-10":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-deep-research":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-deep-research-2025-06-26":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o4-mini-deep-research":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o4-mini-deep-research-2025-06-26":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"computer-use-preview":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"computer-use-preview-2025-03-11":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-codex":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-pro-2025-10-06":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.1-codex-max":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-pro":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-pro":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."}}}]},"ModelIdsShared":{"example":"gpt-6-astra","anyOf":[{"type":"string"},{"type":"string","enum":["gpt-6-astra","gpt-6.1-sol","gpt-6.1-terra","gpt-6-sol","gpt-6-luna","gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","gpt-5.5","gpt-5.5-2026-04-23","gpt-5.4","gpt-5.4-mini","gpt-5.4-nano","gpt-5.4-mini-2026-03-17","gpt-5.4-nano-2026-03-17","gpt-5.3-chat-latest","gpt-5.2","gpt-5.2-2025-12-11","gpt-5.2-chat-latest","gpt-5.2-pro","gpt-5.2-pro-2025-12-11","gpt-5.1","gpt-5.1-2025-11-13","gpt-5.1-codex","gpt-5.1-mini","gpt-5.1-chat-latest","gpt-5","gpt-5-mini","gpt-5-nano","gpt-5-2025-08-07","gpt-5-mini-2025-08-07","gpt-5-nano-2025-08-07","gpt-5-chat-latest","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","gpt-4.1-2025-04-14","gpt-4.1-mini-2025-04-14","gpt-4.1-nano-2025-04-14","o4-mini","o4-mini-2025-04-16","o3","o3-2025-04-16","o3-mini","o3-mini-2025-01-31","o1","o1-2024-12-17","o1-preview","o1-preview-2024-09-12","o1-mini","o1-mini-2024-09-12","gpt-4o","gpt-4o-2024-11-20","gpt-4o-2024-08-06","gpt-4o-2024-05-13","gpt-audio-mini","gpt-audio-mini-2025-12-15","gpt-4o-audio-preview","gpt-4o-audio-preview-2024-10-01","gpt-4o-audio-preview-2024-12-17","gpt-4o-audio-preview-2025-06-03","gpt-4o-mini-audio-preview","gpt-4o-mini-audio-preview-2024-12-17","gpt-4o-search-preview","gpt-4o-mini-search-preview","gpt-4o-search-preview-2025-03-11","gpt-4o-mini-search-preview-2025-03-11","chatgpt-4o-latest","codex-mini-latest","gpt-4o-mini","gpt-4o-mini-2024-07-18","gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4","gpt-4-0314","gpt-4-0613","gpt-4-32k","gpt-4-32k-0314","gpt-4-32k-0613","gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-3.5-turbo-0301","gpt-3.5-turbo-0613","gpt-3.5-turbo-1106","gpt-3.5-turbo-0125","gpt-3.5-turbo-16k-0613"],"x-openai-enum-deprecations":{"gpt-5.4-nano":{"message":"Announced shutdown date: 2027-04-01. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.1":{"message":"Announced shutdown date: 2027-04-01. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.1-2025-11-13":{"message":"Announced shutdown date: 2027-04-01. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.4-nano-2026-03-17":{"message":"Announced shutdown date: 2027-04-01. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4.1-2025-04-14":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4.1":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4.1-mini":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4.1-mini-2025-04-14":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-2024-08-06":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-2024-11-20":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-mini":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-mini-2024-07-18":{"message":"Announced shutdown date: 2027-01-14. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.3-chat-latest":{"message":"Announced shutdown date: 2026-08-10. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.2-chat-latest":{"message":"Announced shutdown date: 2026-08-10. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.1-codex":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.1-chat-latest":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-2025-08-07":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-mini-2025-08-07":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-nano-2025-08-07":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-chat-latest":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4.1-nano":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4.1-nano-2025-04-14":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o4-mini":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o4-mini-2025-04-16":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-2025-04-16":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-mini":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3-mini-2025-01-31":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1-2024-12-17":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-2024-05-13":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-audio-mini":{"message":"Announced shutdown date: 2027-01-20. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-search-preview-2025-03-11":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-mini-search-preview-2025-03-11":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-turbo":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-turbo-2024-04-09":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-0125-preview":{"message":"Announced shutdown date: 2026-03-26. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-turbo-preview":{"message":"Announced shutdown date: 2026-03-26. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-1106-preview":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-0314":{"message":"Announced shutdown date: 2026-03-26. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-0613":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo-1106":{"message":"Announced shutdown date: 2026-09-28. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo-0125":{"message":"Announced shutdown date: 2026-10-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo-0301":{"message":"Announced shutdown date: 2024-09-13. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo-0613":{"message":"Announced shutdown date: 2024-09-13. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo-16k":{"message":"Announced shutdown date: 2024-09-13. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-3.5-turbo-16k-0613":{"message":"Announced shutdown date: 2024-09-13. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-vision-preview":{"message":"Announced shutdown date: 2024-12-06. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-32k":{"message":"Announced shutdown date: 2025-06-06. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-32k-0314":{"message":"Announced shutdown date: 2025-06-06. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4-32k-0613":{"message":"Announced shutdown date: 2025-06-06. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1-preview":{"message":"Announced shutdown date: 2025-07-28. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1-preview-2024-09-12":{"message":"Announced shutdown date: 2025-07-28. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-audio-preview-2024-10-01":{"message":"Announced shutdown date: 2025-10-10. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1-mini":{"message":"Announced shutdown date: 2025-10-27. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o1-mini-2024-09-12":{"message":"Announced shutdown date: 2025-10-27. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"codex-mini-latest":{"message":"Announced shutdown date: 2026-02-12. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"chatgpt-4o-latest":{"message":"Announced shutdown date: 2026-02-17. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-audio-preview":{"message":"Announced shutdown date: 2026-05-07. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-mini-audio-preview":{"message":"Announced shutdown date: 2026-05-07. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-audio-preview-2024-12-17":{"message":"Announced shutdown date: 2026-05-07. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-audio-preview-2025-06-03":{"message":"Announced shutdown date: 2026-05-07. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-mini-audio-preview-2024-12-17":{"message":"Announced shutdown date: 2026-05-07. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-search-preview":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-4o-mini-search-preview":{"message":"Announced shutdown date: 2026-07-23. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-mini":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5-nano":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"o3":{"message":"Announced shutdown date: 2026-12-11. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-audio-mini-2025-12-15":{"message":"Announced shutdown date: 2027-01-20. See https://developers.openai.com/api/docs/deprecations for details and recommended replacements."},"gpt-5.1-mini":{"message":"Not a supported model ID. Retained for SDK compatibility."}}}]},"ModelResponseProperties":{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/Metadata"},"top_logprobs":{"anyOf":[{"description":"An integer between 0 and 20 specifying the maximum number of most likely\ntokens to return at each token position, each with an associated log\nprobability. In some cases, the number of returned tokens may be fewer than\nrequested.\n","type":"integer","minimum":0,"maximum":20},{"type":"null"}]},"temperature":{"anyOf":[{"type":"number","minimum":0,"maximum":2,"default":1,"example":1,"description":"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.\nWe generally recommend altering this or `top_p` but not both.\n"},{"type":"null"}]},"top_p":{"anyOf":[{"type":"number","minimum":0,"maximum":1,"default":1,"example":1,"description":"An alternative to sampling with temperature, called nucleus sampling,\nwhere the model considers the results of the tokens with top_p probability\nmass. So 0.1 means only the tokens comprising the top 10% probability mass\nare considered.\n\nWe generally recommend altering this or `temperature` but not both.\n"},{"type":"null"}]},"user":{"type":["string","null"],"example":"user-1234","deprecated":true,"description":"This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.\nA stable identifier for your end-users.\nUsed to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).\n"},"safety_identifier":{"anyOf":[{"type":"string","maxLength":128,"example":"safety-identifier-1234","description":"A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.\nThe IDs should be a string that uniquely identifies each user, with a maximum length of 128 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).\n"},{"type":"null"}]},"prompt_cache_key":{"anyOf":[{"type":"string","example":"prompt-cache-key-1234","description":"Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](https://developers.openai.com/api/docs/guides/prompt-caching).\n"},{"type":"null"}]},"prompt_cache_retention":{"deprecated":true,"anyOf":[{"type":"string","enum":["in_memory","24h"],"description":"Deprecated. Use `prompt_cache_options.ttl` instead.\n\nThe retention policy for the prompt cache. Set to `24h` to enable extended prompt caching, which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn more](https://developers.openai.com/api/docs/guides/prompt-caching#prompt-cache-retention).\nThis field expresses a maximum retention policy, while\n`prompt_cache_options.ttl` expresses a minimum cache lifetime. The two\nfields are independent and do not interact.\nFor `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.\n\nFor older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:\n - Organizations without ZDR enabled default to `24h`.\n - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.\n"},{"type":"null"}]}}},"Moderation":{"properties":{"input":{"oneOf":[{"$ref":"#/components/schemas/ModerationResultBody"},{"$ref":"#/components/schemas/ModerationErrorBody"}],"description":"Moderation for the response input.","discriminator":{"propertyName":"type"}},"output":{"oneOf":[{"$ref":"#/components/schemas/ModerationResultBody"},{"$ref":"#/components/schemas/ModerationErrorBody"}],"description":"Moderation for the response output.","discriminator":{"propertyName":"type"}}},"type":"object","required":["input","output"],"title":"Moderation","description":"Moderation results or errors for the response input and output."},"ModerationConfigParam":{"properties":{"mode":{"$ref":"#/components/schemas/ModerationMode"}},"type":"object","required":["mode"],"description":"The moderation policy for the response input."},"ModerationErrorBody":{"properties":{"type":{"type":"string","enum":["error"],"description":"The object type, which was always `error` for moderation failures.","default":"error","x-stainless-const":true},"code":{"type":"string","description":"The error code."},"message":{"type":"string","description":"The error message."}},"type":"object","required":["type","code","message"],"title":"Moderation error","description":"An error produced while attempting moderation for the response input or output."},"ModerationInputType":{"type":"string","enum":["text","image"]},"ModerationMode":{"type":"string","enum":["score","block"]},"ModerationParam":{"properties":{"model":{"type":"string","description":"The moderation model to use for moderated completions, e.g. 'omni-moderation-latest'."},"policy":{"anyOf":[{"$ref":"#/components/schemas/ModerationPolicyParam","description":"The policy to apply to moderated response input and output."},{"type":"null"}]}},"type":"object","required":["model"],"description":"Configuration for running moderation on the input and output of this response."},"ModerationPolicyParam":{"properties":{"input":{"anyOf":[{"$ref":"#/components/schemas/ModerationConfigParam","description":"The moderation policy for the response input."},{"type":"null"}]},"output":{"anyOf":[{"$ref":"#/components/schemas/ModerationConfigParam","description":"The moderation policy for the response output."},{"type":"null"}]}},"type":"object","required":[],"description":"The policy to apply to moderated response input and output."},"ModerationResultBody":{"properties":{"type":{"type":"string","enum":["moderation_result"],"description":"The object type, which was always `moderation_result` for successful moderation results.","default":"moderation_result","x-stainless-const":true},"model":{"type":"string","description":"The moderation model that produced this result."},"flagged":{"type":"boolean","description":"A boolean indicating whether the content was flagged by any category."},"categories":{"additionalProperties":{"type":"boolean"},"type":"object","description":"A dictionary of moderation categories to booleans, True if the input is flagged under this category.","x-oaiTypeLabel":"map"},"category_scores":{"additionalProperties":{"type":"number"},"type":"object","description":"A dictionary of moderation categories to scores.","x-oaiTypeLabel":"map"},"category_applied_input_types":{"additionalProperties":{"items":{"$ref":"#/components/schemas/ModerationInputType"},"type":"array"},"type":"object","description":"Which modalities of input are reflected by the score for each category.","x-oaiTypeLabel":"map"}},"type":"object","required":["type","model","flagged","categories","category_scores","category_applied_input_types"],"title":"Moderation result","description":"A moderation result produced for the response input or output."},"MoveParam":{"properties":{"type":{"type":"string","enum":["move"],"description":"Specifies the event type. For a move action, this property is always set to `move`.","default":"move","x-stainless-const":true},"x":{"type":"integer","description":"The x-coordinate to move to."},"y":{"type":"integer","description":"The y-coordinate to move to."},"keys":{"anyOf":[{"items":{"type":"string"},"type":"array","description":"The keys being held while moving the mouse."},{"type":"null"}]}},"type":"object","required":["type","x","y"],"title":"Move","description":"A mouse move action."},"NamespaceToolParam":{"properties":{"type":{"type":"string","enum":["namespace"],"description":"The type of the tool. Always `namespace`.","default":"namespace","x-stainless-const":true},"name":{"type":"string","minLength":1,"description":"The namespace name used in tool calls (for example, `crm`)."},"description":{"type":"string","description":"A description of the namespace shown to the model."},"tools":{"items":{"oneOf":[{"$ref":"#/components/schemas/FunctionToolParam"},{"$ref":"#/components/schemas/CustomToolParam"}],"description":"A function or custom tool that belongs to a namespace.","discriminator":{"propertyName":"type"}},"type":"array","minItems":1,"description":"The function/custom tools available inside this namespace."}},"type":"object","required":["type","name","description","tools"],"title":"Namespace","description":"Groups function/custom tools under a shared namespace."},"OutputContent":{"oneOf":[{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/ReasoningTextContent"}],"discriminator":{"propertyName":"type"}},"OutputItem":{"oneOf":[{"$ref":"#/components/schemas/OutputMessage"},{"$ref":"#/components/schemas/FileSearchToolCall"},{"$ref":"#/components/schemas/FunctionToolCall"},{"$ref":"#/components/schemas/FunctionToolCallOutputResource"},{"$ref":"#/components/schemas/WebSearchToolCall"},{"$ref":"#/components/schemas/ComputerToolCall"},{"$ref":"#/components/schemas/ComputerToolCallOutputResource"},{"$ref":"#/components/schemas/ReasoningItem"},{"$ref":"#/components/schemas/Program"},{"$ref":"#/components/schemas/ProgramOutput"},{"$ref":"#/components/schemas/ToolSearchCall"},{"$ref":"#/components/schemas/ToolSearchOutput"},{"$ref":"#/components/schemas/AdditionalTools"},{"$ref":"#/components/schemas/CompactionBody"},{"$ref":"#/components/schemas/ImageGenToolCall"},{"$ref":"#/components/schemas/CodeInterpreterToolCall"},{"$ref":"#/components/schemas/LocalShellToolCall"},{"$ref":"#/components/schemas/LocalShellToolCallOutput"},{"$ref":"#/components/schemas/FunctionShellCall"},{"$ref":"#/components/schemas/FunctionShellCallOutput"},{"$ref":"#/components/schemas/ApplyPatchToolCall"},{"$ref":"#/components/schemas/ApplyPatchToolCallOutput"},{"$ref":"#/components/schemas/MCPToolCall"},{"$ref":"#/components/schemas/MCPListTools"},{"$ref":"#/components/schemas/MCPApprovalRequest"},{"$ref":"#/components/schemas/MCPApprovalResponseResource"},{"$ref":"#/components/schemas/CustomToolCall"},{"$ref":"#/components/schemas/CustomToolCallOutputResource"}],"discriminator":{"propertyName":"type"}},"OutputMessage":{"type":"object","title":"Output message","description":"An output message from the model.\n","properties":{"id":{"type":"string","description":"The unique ID of the output message.\n"},"type":{"type":"string","description":"The type of the output message. Always `message`.\n","enum":["message"],"x-stainless-const":true},"role":{"type":"string","description":"The role of the output message. Always `assistant`.\n","enum":["assistant"],"x-stainless-const":true},"content":{"type":"array","description":"The content of the output message.\n","items":{"$ref":"#/components/schemas/OutputMessageContent"}},"phase":{"anyOf":[{"$ref":"#/components/schemas/MessagePhase"},{"type":"null"}]},"status":{"type":"string","description":"The status of the message input. One of `in_progress`, `completed`, or\n`incomplete`. Populated when input items are returned via API.\n","enum":["in_progress","completed","incomplete"]}},"required":["id","type","role","content","status"]},"OutputMessageContent":{"oneOf":[{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/RefusalContent"}],"discriminator":{"propertyName":"type"}},"OutputTextContent":{"properties":{"type":{"type":"string","enum":["output_text"],"description":"The type of the output text. Always `output_text`.","default":"output_text","x-stainless-const":true},"text":{"type":"string","description":"The text output from the model."},"annotations":{"items":{"$ref":"#/components/schemas/Annotation"},"type":"array","description":"The annotations of the text output."},"logprobs":{"items":{"$ref":"#/components/schemas/LogProb"},"type":"array"}},"type":"object","required":["type","text","annotations","logprobs"],"title":"Output text","description":"A text output from the model."},"ParallelToolCalls":{"description":"Whether to enable [parallel function calling](https://developers.openai.com/api/docs/guides/function-calling#parallel-function-calling) during tool use.","type":"boolean","default":true},"PermissionErrorResponse":{"type":"object","properties":{"error":{"description":"Details about the permission error.","anyOf":[{"$ref":"#/components/schemas/Error"},{"type":"string","description":"An explanation of the missing API permissions."}]}},"required":["error"]},"PredictionContent":{"type":"object","title":"Static Content","description":"Static predicted output content, such as the content of a text file that is\nbeing regenerated.\n","required":["type","content"],"properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content you want to provide. This type is\ncurrently always `content`.\n","x-stainless-const":true},"content":{"description":"The content that should be matched when generating a model response.\nIf generated tokens would match this content, the entire model response\ncan be returned much more quickly.\n","oneOf":[{"type":"string","title":"Text content","description":"The content used for a Predicted Output. This is often the\ntext of a file you are regenerating with minor changes.\n"},{"type":"array","description":"An array of content parts with a defined type. Supported options differ based on the [model](https://developers.openai.com/api/docs/models) being used to generate the response. Can contain text inputs.","title":"Array of content parts","items":{"$ref":"#/components/schemas/ChatCompletionRequestMessageContentPartText"},"minItems":1}]}}},"Program":{"properties":{"type":{"type":"string","enum":["program"],"description":"The type of the item. Always `program`.","default":"program","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the program item."},"call_id":{"type":"string","description":"The stable call ID of the program item."},"code":{"type":"string","description":"The JavaScript source executed by programmatic tool calling."},"fingerprint":{"type":"string","description":"Opaque program replay fingerprint that must be round-tripped."}},"type":"object","required":["type","id","call_id","code","fingerprint"]},"ProgramItemParam":{"properties":{"id":{"type":"string","description":"The unique ID of this program item.","example":"cm_123"},"type":{"type":"string","enum":["program"],"description":"The item type. Always `program`.","default":"program","x-stainless-const":true},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The stable call ID of the program item."},"code":{"type":"string","maxLength":10485760,"description":"The JavaScript source executed by programmatic tool calling."},"fingerprint":{"type":"string","maxLength":10485760,"description":"Opaque program replay fingerprint that must be round-tripped."}},"type":"object","required":["id","type","call_id","code","fingerprint"]},"ProgramOutput":{"properties":{"type":{"type":"string","enum":["program_output"],"description":"The type of the item. Always `program_output`.","default":"program_output","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the program output item."},"call_id":{"type":"string","description":"The call ID of the program item."},"result":{"type":"string","description":"The result produced by the program item."},"status":{"$ref":"#/components/schemas/ProgramOutputStatus","description":"The terminal status of the program output item."}},"type":"object","required":["type","id","call_id","result","status"]},"ProgramOutputItemParam":{"properties":{"id":{"type":"string","description":"The unique ID of this program output item.","example":"cmo_123"},"type":{"type":"string","enum":["program_output"],"description":"The item type. Always `program_output`.","default":"program_output","x-stainless-const":true},"call_id":{"type":"string","maxLength":64,"minLength":1,"description":"The call ID of the program item."},"result":{"type":"string","maxLength":10485760,"description":"The result produced by the program item."},"status":{"$ref":"#/components/schemas/ProgramOutputItemStatus","description":"The terminal status of the program output."}},"type":"object","required":["id","type","call_id","result","status"]},"ProgramOutputItemStatus":{"type":"string","enum":["completed","incomplete"]},"ProgramOutputStatus":{"type":"string","enum":["completed","incomplete"]},"ProgramToolCallCaller":{"properties":{"type":{"type":"string","enum":["program"],"default":"program","x-stainless-const":true},"caller_id":{"type":"string","description":"The call ID of the program item that produced this tool call."}},"type":"object","required":["type","caller_id"]},"ProgramToolCallCallerParam":{"properties":{"type":{"type":"string","enum":["program"],"description":"The caller type. Always `program`.","default":"program","x-stainless-const":true},"caller_id":{"type":"string","maxLength":64,"minLength":1,"description":"The call ID of the program item that produced this tool call."}},"type":"object","required":["type","caller_id"]},"ProgrammaticToolCallingParam":{"properties":{"type":{"type":"string","enum":["programmatic_tool_calling"],"description":"The type of the tool. Always `programmatic_tool_calling`.","default":"programmatic_tool_calling","x-stainless-const":true}},"type":"object","required":["type"]},"Prompt":{"anyOf":[{"type":"object","description":"Reference to a prompt template and its variables.\n[Learn more](https://developers.openai.com/api/docs/guides/text?api-mode=responses#version-prompts-in-code).\n","required":["id"],"properties":{"id":{"type":"string","description":"The unique identifier of the prompt template to use."},"version":{"anyOf":[{"type":"string","description":"Optional version of the prompt template."},{"type":"null"}]},"variables":{"$ref":"#/components/schemas/ResponsePromptVariables"}}},{"type":"null"}]},"PromptCacheBreakpointConfig":{"properties":{"mode":{"type":"string","enum":["explicit"],"description":"The breakpoint mode. Always `explicit`.","default":"explicit","x-stainless-const":true},"ttl":{"type":"string","enum":["30m","12h"],"description":"The minimum lifetime of this cache breakpoint. Defaults to the request TTL."}},"type":"object","required":["mode"],"title":"Prompt cache breakpoint","description":"Marks the exact end of a reusable prompt prefix. When `ttl` is omitted, the breakpoint inherits the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block."},"PromptCacheBreakpointParam":{"properties":{"mode":{"type":"string","enum":["explicit"],"description":"The breakpoint mode. Always `explicit`.","default":"explicit","x-stainless-const":true},"ttl":{"type":"string","enum":["30m","12h"],"description":"The minimum lifetime of this cache breakpoint. Defaults to the request TTL."}},"type":"object","required":["mode"],"title":"Prompt cache breakpoint","description":"Marks the exact end of a reusable prompt prefix. When `ttl` is omitted, the breakpoint inherits the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block."},"PromptCacheComparisonResponseNotFoundDiagnosticsBody":{"properties":{"type":{"type":"string","enum":["comparison_response_not_found"],"default":"comparison_response_not_found","x-stainless-const":true}},"type":"object","required":["type"]},"PromptCacheDiagnostics":{"oneOf":[{"$ref":"#/components/schemas/PromptCacheMissDiagnosticsBody"},{"$ref":"#/components/schemas/PromptCacheHitDiagnosticsBody"},{"$ref":"#/components/schemas/PromptCacheComparisonResponseNotFoundDiagnosticsBody"},{"$ref":"#/components/schemas/PromptCacheUnavailableDiagnosticsBody"}],"description":"Prompt cache diagnostics requested for this response.","discriminator":{"propertyName":"type"}},"PromptCacheHitDiagnosticsBody":{"properties":{"type":{"type":"string","enum":["cache_hit"],"default":"cache_hit","x-stainless-const":true}},"type":"object","required":["type"]},"PromptCacheMissDiagnosticsBody":{"properties":{"type":{"type":"string","enum":["cache_miss"],"default":"cache_miss","x-stainless-const":true},"reason":{"$ref":"#/components/schemas/CacheMissReasonTypeEnum","description":"The reason prompt cache reuse did not occur."},"cache_missed_tokens":{"type":"integer","description":"The estimated number of input tokens affected after the first detected divergence."},"comparison_reusable_tokens":{"type":"integer","description":"The raw token count of the reusable prefix in the compared response."}},"type":"object","required":["type","reason","cache_missed_tokens"]},"PromptCacheModeEnum":{"type":"string","enum":["implicit","explicit"]},"PromptCacheOptions":{"properties":{"ttl":{"$ref":"#/components/schemas/PromptCacheTTLEnum","description":"The minimum lifetime applied to each cache breakpoint."},"mode":{"$ref":"#/components/schemas/PromptCacheModeEnum","description":"Whether implicit prompt-cache breakpoints were enabled."},"comparison_response_id":{"anyOf":[{"type":"string","description":"The response ID supplied as the prompt cache diagnostics comparison."},{"type":"null"}]}},"type":"object","required":["ttl","mode"],"title":"Prompt cache options","description":"The prompt-caching options that were applied to the response. Supported for `gpt-5.6` and later models."},"PromptCacheOptionsParam":{"properties":{"ttl":{"$ref":"#/components/schemas/PromptCacheTTLEnum","description":"The minimum lifetime applied to every implicit and explicit cache breakpoint written by the request. Defaults to `30m`, which is currently the only supported value. The backend may retain cache entries for longer."},"mode":{"$ref":"#/components/schemas/PromptCacheModeEnum","description":"Controls whether OpenAI automatically creates an implicit cache breakpoint. Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint and writes up to the latest three explicit breakpoints in the request. With `explicit`, OpenAI does not create an implicit breakpoint and writes up to the latest four explicit breakpoints. If there are no explicit breakpoints, the request does not use prompt caching."}},"type":"object","required":[],"title":"Prompt cache options","description":"Options for prompt caching. Supported for `gpt-5.6` and later models. By default, OpenAI automatically chooses one implicit cache breakpoint. You can add explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each request can write up to four breakpoints. For cache matching, OpenAI considers up to the latest 80 breakpoints in the conversation, without a content-block lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The `ttl` defaults to `30m`, which is currently the only supported value. See the [prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching) for current details."},"PromptCacheTTLEnum":{"type":"string","enum":["30m"]},"PromptCacheUnavailableDiagnosticsBody":{"properties":{"type":{"type":"string","enum":["unavailable"],"default":"unavailable","x-stainless-const":true}},"type":"object","required":["type"]},"RankerVersionType":{"type":"string","enum":["auto","default-2024-11-15"]},"RankingOptions":{"properties":{"ranker":{"$ref":"#/components/schemas/RankerVersionType","description":"The ranker to use for the file search."},"score_threshold":{"type":"number","description":"The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results."},"hybrid_search":{"$ref":"#/components/schemas/HybridSearchOptions","description":"Weights that control how reciprocal rank fusion balances semantic embedding matches versus sparse keyword matches when hybrid search is enabled."}},"type":"object","required":[]},"Reasoning":{"type":"object","description":"Configuration options for\n[reasoning models](https://developers.openai.com/api/docs/guides/reasoning).\n","title":"Reasoning","properties":{"mode":{"$ref":"#/components/schemas/ReasoningModeEnum","description":"Controls the reasoning execution mode for the request.\n\nWhen returned on a response, this is the effective execution mode.\n"},"effort":{"$ref":"#/components/schemas/ReasoningEffort"},"summary":{"anyOf":[{"type":"string","description":"A summary of the reasoning performed by the model. This can be\nuseful for debugging and understanding the model's reasoning process.\nOne of `auto`, `concise`, or `detailed`.\n\n`concise` is supported for `computer-use-preview` models and all reasoning models after `gpt-5`.\n","enum":["auto","concise","detailed"]},{"type":"null"}]},"context":{"anyOf":[{"type":"string","description":"Controls which reasoning items are rendered back to the model on later turns.\nIf omitted or set to `auto`, the model determines the context mode. The\n`gpt-5.6` model family defaults to `all_turns`; earlier models default to\n`current_turn`.\n\nWhen returned on a response, this is the effective reasoning context mode\nused for the response.\n","enum":["auto","current_turn","all_turns"]},{"type":"null"}]},"generate_summary":{"anyOf":[{"type":"string","deprecated":true,"description":"**Deprecated:** use `summary` instead.\n\nA summary of the reasoning performed by the model. This can be\nuseful for debugging and understanding the model's reasoning process.\nOne of `auto`, `concise`, or `detailed`.\n","enum":["auto","concise","detailed"]},{"type":"null"}]}}},"ReasoningEffort":{"anyOf":[{"type":"string","enum":["none","minimal","low","medium","high","xhigh","max"],"default":"medium","description":"Constrains effort on reasoning for reasoning models. Currently supported\nvalues are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.\nReducing reasoning effort can result in faster responses and fewer tokens\nused on reasoning in a response. Not all reasoning models support every\nvalue. See the\n[reasoning guide](https://developers.openai.com/api/docs/guides/reasoning)\nfor model-specific support.\n"},{"type":"null"}]},"ReasoningItem":{"type":"object","description":"A description of the chain of thought used by a reasoning model while generating\na response. Be sure to include these items in your `input` to the Responses API\nfor subsequent turns of a conversation if you are manually\n[managing context](https://developers.openai.com/api/docs/guides/conversation-state).\n","title":"Reasoning","properties":{"type":{"type":"string","description":"The type of the object. Always `reasoning`.\n","enum":["reasoning"],"x-stainless-const":true},"id":{"type":"string","description":"The unique identifier of the reasoning content.\n"},"encrypted_content":{"anyOf":[{"type":"string","description":"The encrypted content of the reasoning item. This is populated by default\nfor reasoning items returned by `POST /v1/responses` and WebSocket\n`response.create` requests.\n\nWhen streaming, use the completed reasoning item and its\n`encrypted_content` from the `response.output_item.done` event in\nsubsequent requests. The `encrypted_content` in\n`response.output_item.added` may be incomplete. This is especially\nimportant when `store` is `false` or when using Zero Data Retention.\n"},{"type":"null"}]},"summary":{"type":"array","description":"Reasoning summary content.\n","items":{"$ref":"#/components/schemas/SummaryTextContent"}},"content":{"type":"array","description":"Reasoning text content.\n","items":{"$ref":"#/components/schemas/ReasoningTextContent"}},"status":{"type":"string","description":"The status of the item. One of `in_progress`, `completed`, or\n`incomplete`. Populated when items are returned via API.\n","enum":["in_progress","completed","incomplete"]}},"required":["id","summary","type"]},"ReasoningModeEnum":{"anyOf":[{"type":"string"},{"type":"string","enum":["standard","pro"]}]},"ReasoningTextContent":{"properties":{"type":{"type":"string","enum":["reasoning_text"],"description":"The type of the reasoning text. Always `reasoning_text`.","default":"reasoning_text","x-stainless-const":true},"text":{"type":"string","description":"The reasoning text from the model."}},"type":"object","required":["type","text"],"title":"Reasoning text","description":"Reasoning text from the model."},"RefusalContent":{"properties":{"type":{"type":"string","enum":["refusal"],"description":"The type of the refusal. Always `refusal`.","default":"refusal","x-stainless-const":true},"refusal":{"type":"string","description":"The refusal explanation from the model."}},"type":"object","required":["type","refusal"],"title":"Refusal","description":"A refusal from the model."},"Response":{"title":"The response object","allOf":[{"$ref":"#/components/schemas/ModelResponseProperties"},{"$ref":"#/components/schemas/ResponseProperties"},{"type":"object","properties":{"service_tier":{"$ref":"#/components/schemas/ServiceTierResponses"},"truncation":{"anyOf":[{"type":"string","description":"The truncation strategy to use for the model response.\n- `auto`: If the input to this Response exceeds\n the model's context window size, the model will truncate the\n response to fit the context window by dropping items from the beginning of the conversation.\n- `disabled` (default): If the input size will exceed the context window\n size for a model, the request will fail with a 400 error.\n","enum":["auto","disabled"],"default":"disabled"},{"type":"null"}]},"id":{"type":"string","description":"Unique identifier for this Response.\n"},"object":{"type":"string","description":"The object type of this resource - always set to `response`.\n","enum":["response"],"x-stainless-const":true},"status":{"type":"string","description":"The status of the response generation. One of `completed`, `failed`,\n`in_progress`, `cancelled`, `queued`, or `incomplete`.\n","enum":["completed","failed","in_progress","cancelled","queued","incomplete"]},"access_programs":{"anyOf":[{"$ref":"#/components/schemas/AccessProgramsBody"},{"type":"null"}]},"created_at":{"type":"number","format":"unixtime","description":"Unix timestamp (in seconds) of when this Response was created.\n"},"completed_at":{"anyOf":[{"type":"number","format":"unixtime","description":"Unix timestamp (in seconds) of when this Response was completed.\nOnly present when the status is `completed`.\n"},{"type":"null"}]},"error":{"$ref":"#/components/schemas/ResponseError"},"incomplete_details":{"anyOf":[{"type":"object","description":"Details about why the response is incomplete.\n","properties":{"reason":{"type":"string","description":"The reason why the response is incomplete. `steered` means\nthe response stopped at a safe output boundary after a\nWebSocket `response.steer` event. The server can then create\na successor response automatically with the queued input.\n","enum":["max_output_tokens","max_messages","content_filter","steered"]}}},{"type":"null"}]},"output":{"type":"array","description":"An array of content items generated by the model.\n\n- The length and order of items in the `output` array is dependent\n on the model's response.\n- Rather than accessing the first item in the `output` array and\n assuming it's an `assistant` message with the content generated by\n the model, you might consider using the `output_text` property where\n supported in SDKs.\n","items":{"$ref":"#/components/schemas/OutputItem"}},"reasoning":{"anyOf":[{"$ref":"#/components/schemas/Reasoning"},{"type":"null"}]},"instructions":{"anyOf":[{"description":"A system (or developer) message inserted into the model's context.\n\nWhen using along with `previous_response_id`, the instructions from a previous\nresponse will not be carried over to the next response. This makes it simple\nto swap out system (or developer) messages in new responses.\n","oneOf":[{"type":"string","description":"A text input to the model, equivalent to a text input with the\n`developer` role.\n"},{"type":"array","title":"Input item list","description":"A list of one or many input items to the model, containing\ndifferent content types.\n","items":{"$ref":"#/components/schemas/InputItem"}}]},{"type":"null"}]},"output_text":{"anyOf":[{"type":"string","description":"SDK-only convenience property that contains the aggregated text output\nfrom all `output_text` items in the `output` array, if any are present.\nSupported in the Python and JavaScript SDKs.\n","x-oaiSupportedSDKs":["python","javascript"]},{"type":"null"}]},"usage":{"anyOf":[{"$ref":"#/components/schemas/ResponseUsage"},{"type":"null"}]},"tool_usage":{"$ref":"#/components/schemas/ResponseToolUsage","description":"Usage reported by hosted tools, separate from base model `usage`. The field\ncan be omitted when tool usage is unavailable. When present, tool families\nwith no recorded usage have zero counts.\n\n`image_gen` sums available token counts across image generation calls.\nCalls with missing or incomplete usage records may be skipped. Output\ntoken details and cached input counts can be omitted. An omitted cache\ncount means cache usage is unknown.\n\n`web_search.num_requests` counts billable searches. Discounted searches\nand actions such as opening a page are excluded. Use billing records to\nreconcile final charges.\n"},"prompt_cache_options":{"$ref":"#/components/schemas/PromptCacheOptions"},"prompt_cache_diagnostics":{"$ref":"#/components/schemas/PromptCacheDiagnostics"},"moderation":{"anyOf":[{"$ref":"#/components/schemas/Moderation","description":"Moderation results for the response input and output, if moderated completions were requested.\n"},{"type":"null"}]},"parallel_tool_calls":{"type":"boolean","description":"Whether to allow the model to run tool calls in parallel.\n","default":true},"conversation":{"anyOf":[{"default":null,"$ref":"#/components/schemas/ResponseConversation"},{"type":"null"}]},"max_output_tokens":{"anyOf":[{"description":"An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](https://developers.openai.com/api/docs/guides/reasoning).\n","type":"integer"},{"type":"null"}]}},"required":["access_programs","id","object","created_at","error","incomplete_details","instructions","model","tools","output","parallel_tool_calls","metadata","tool_choice","temperature","top_p"]}],"example":{"id":"resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41","object":"response","access_programs":null,"created_at":1741476777,"status":"completed","completed_at":1741476778,"error":null,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"model":"gpt-6-astra","output":[{"type":"message","id":"msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41","status":"completed","role":"assistant","content":[{"type":"output_text","text":"The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.","annotations":[],"logprobs":[]}]}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null,"context":null},"store":true,"temperature":1,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1,"truncation":"disabled","usage":{"input_tokens":328,"input_tokens_details":{"cached_tokens":0,"cache_write_tokens":0},"output_tokens":52,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":380},"tool_usage":{"image_gen":{"input_tokens":0,"input_tokens_details":{"text_tokens":0,"image_tokens":0},"output_tokens":0,"output_tokens_details":{"text_tokens":0,"image_tokens":0},"total_tokens":0},"web_search":{"num_requests":0}},"user":null,"metadata":{}}},"ResponseAudioDeltaEvent":{"type":"object","description":"Emitted when there is a partial audio response.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.audio.delta`.\n","enum":["response.audio.delta"],"x-stainless-const":true},"sequence_number":{"type":"integer","description":"A sequence number for this chunk of the stream response.\n"},"delta":{"type":"string","description":"A chunk of Base64 encoded response audio bytes.\n"}},"required":["type","delta","sequence_number"],"x-oaiMeta":{"name":"response.audio.delta","group":"responses","example":"{\n \"type\": \"response.audio.delta\",\n \"response_id\": \"resp_123\",\n \"delta\": \"base64encoded...\",\n \"sequence_number\": 1\n}\n"}},"ResponseAudioDoneEvent":{"type":"object","description":"Emitted when the audio response is complete.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.audio.done`.\n","enum":["response.audio.done"],"x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the delta.\n"}},"required":["type","sequence_number","response_id"],"x-oaiMeta":{"name":"response.audio.done","group":"responses","example":"{\n \"type\": \"response.audio.done\",\n \"response_id\": \"resp-123\",\n \"sequence_number\": 1\n}\n"}},"ResponseAudioTranscriptDeltaEvent":{"type":"object","description":"Emitted when there is a partial transcript of audio.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.audio.transcript.delta`.\n","enum":["response.audio.transcript.delta"],"x-stainless-const":true},"delta":{"type":"string","description":"The partial transcript of the audio response.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","response_id","delta","sequence_number"],"x-oaiMeta":{"name":"response.audio.transcript.delta","group":"responses","example":"{\n \"type\": \"response.audio.transcript.delta\",\n \"response_id\": \"resp_123\",\n \"delta\": \" ... partial transcript ... \",\n \"sequence_number\": 1\n}\n"}},"ResponseAudioTranscriptDoneEvent":{"type":"object","description":"Emitted when the full audio transcript is completed.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.audio.transcript.done`.\n","enum":["response.audio.transcript.done"],"x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","response_id","sequence_number"],"x-oaiMeta":{"name":"response.audio.transcript.done","group":"responses","example":"{\n \"type\": \"response.audio.transcript.done\",\n \"response_id\": \"resp_123\",\n \"sequence_number\": 1\n}\n"}},"ResponseCodeInterpreterCallCodeDeltaEvent":{"type":"object","description":"Emitted when a partial code snippet is streamed by the code interpreter.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.code_interpreter_call_code.delta`.","enum":["response.code_interpreter_call_code.delta"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response for which the code is being streamed."},"item_id":{"type":"string","description":"The unique identifier of the code interpreter tool call item."},"delta":{"type":"string","description":"The partial code snippet being streamed by the code interpreter."},"sequence_number":{"type":"integer","description":"The sequence number of this event, used to order streaming events."}},"required":["type","output_index","item_id","delta","sequence_number"],"x-oaiMeta":{"name":"response.code_interpreter_call_code.delta","group":"responses","example":"{\n \"type\": \"response.code_interpreter_call_code.delta\",\n \"output_index\": 0,\n \"item_id\": \"ci_12345\",\n \"delta\": \"print('Hello, world')\",\n \"sequence_number\": 1\n}\n"}},"ResponseCodeInterpreterCallCodeDoneEvent":{"type":"object","description":"Emitted when the code snippet is finalized by the code interpreter.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.code_interpreter_call_code.done`.","enum":["response.code_interpreter_call_code.done"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response for which the code is finalized."},"item_id":{"type":"string","description":"The unique identifier of the code interpreter tool call item."},"code":{"type":"string","description":"The final code snippet output by the code interpreter."},"sequence_number":{"type":"integer","description":"The sequence number of this event, used to order streaming events."}},"required":["type","output_index","item_id","code","sequence_number"],"x-oaiMeta":{"name":"response.code_interpreter_call_code.done","group":"responses","example":"{\n \"type\": \"response.code_interpreter_call_code.done\",\n \"output_index\": 3,\n \"item_id\": \"ci_12345\",\n \"code\": \"print('done')\",\n \"sequence_number\": 1\n}\n"}},"ResponseCodeInterpreterCallCompletedEvent":{"type":"object","description":"Emitted when the code interpreter call is completed.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.code_interpreter_call.completed`.","enum":["response.code_interpreter_call.completed"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response for which the code interpreter call is completed."},"item_id":{"type":"string","description":"The unique identifier of the code interpreter tool call item."},"sequence_number":{"type":"integer","description":"The sequence number of this event, used to order streaming events."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.code_interpreter_call.completed","group":"responses","example":"{\n \"type\": \"response.code_interpreter_call.completed\",\n \"output_index\": 5,\n \"item_id\": \"ci_12345\",\n \"sequence_number\": 1\n}\n"}},"ResponseCodeInterpreterCallInProgressEvent":{"type":"object","description":"Emitted when a code interpreter call is in progress.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.code_interpreter_call.in_progress`.","enum":["response.code_interpreter_call.in_progress"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response for which the code interpreter call is in progress."},"item_id":{"type":"string","description":"The unique identifier of the code interpreter tool call item."},"sequence_number":{"type":"integer","description":"The sequence number of this event, used to order streaming events."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.code_interpreter_call.in_progress","group":"responses","example":"{\n \"type\": \"response.code_interpreter_call.in_progress\",\n \"output_index\": 0,\n \"item_id\": \"ci_12345\",\n \"sequence_number\": 1\n}\n"}},"ResponseCodeInterpreterCallInterpretingEvent":{"type":"object","description":"Emitted when the code interpreter is actively interpreting the code snippet.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.code_interpreter_call.interpreting`.","enum":["response.code_interpreter_call.interpreting"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response for which the code interpreter is interpreting code."},"item_id":{"type":"string","description":"The unique identifier of the code interpreter tool call item."},"sequence_number":{"type":"integer","description":"The sequence number of this event, used to order streaming events."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.code_interpreter_call.interpreting","group":"responses","example":"{\n \"type\": \"response.code_interpreter_call.interpreting\",\n \"output_index\": 4,\n \"item_id\": \"ci_12345\",\n \"sequence_number\": 1\n}\n"}},"ResponseCompactionCompactingStreamingEvent":{"properties":{"type":{"type":"string","enum":["response.compaction.compacting"],"description":"The type of the event, always `response.compaction.compacting`.","default":"response.compaction.compacting","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"output_index":{"type":"integer","description":"The index of the compaction output item."},"item_id":{"type":"string","description":"The ID of the compaction output item."}},"type":"object","required":["type","sequence_number","output_index","item_id"],"title":"Response compaction compacting event","description":"Emitted when new summary content is sampled for a compaction trigger. Contains no summary content."},"ResponseCompletedEvent":{"type":"object","description":"Emitted when the model response is complete.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.completed`.\n","enum":["response.completed"],"x-stainless-const":true},"response":{"$ref":"#/components/schemas/Response","description":"Properties of the completed response.\n"},"sequence_number":{"type":"integer","description":"The sequence number for this event."}},"required":["type","response","sequence_number"],"x-oaiMeta":{"name":"response.completed","group":"responses","example":"{\n \"type\": \"response.completed\",\n \"response\": {\n \"id\": \"resp_123\",\n \"object\": \"response\",\n \"access_programs\": null,\n \"created_at\": 1740855869,\n \"status\": \"completed\",\n \"completed_at\": 1740855870,\n \"error\": null,\n \"incomplete_details\": null,\n \"input\": [],\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"model\": \"gpt-6-astra\",\n \"output\": [\n {\n \"id\": \"msg_123\",\n \"type\": \"message\",\n \"role\": \"assistant\",\n \"content\": [\n {\n \"type\": \"output_text\",\n \"text\": \"In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.\",\n \"annotations\": [],\n \"logprobs\": []\n }\n ],\n \"status\": \"completed\"\n }\n ],\n \"previous_response_id\": null,\n \"reasoning_effort\": null,\n \"store\": false,\n \"temperature\": 1,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n }\n },\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_p\": 1,\n \"truncation\": \"disabled\",\n \"usage\": {\n \"input_tokens\": 0,\n \"output_tokens\": 0,\n \"output_tokens_details\": {\n \"reasoning_tokens\": 0\n },\n \"total_tokens\": 0,\n \"input_tokens_details\": {\n \"cached_tokens\": 0,\n \"cache_write_tokens\": 0\n }\n },\n \"user\": null,\n \"metadata\": {},\n \"parallel_tool_calls\": true\n },\n \"sequence_number\": 1\n}\n"}},"ResponseConfigurationUpdateItemParam":{"type":"object","description":"An update to the conversation's response configuration. The configuration\nremains in effect for subsequent responses until it is replaced by another\nconfiguration update.\n","properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of the configuration update item.","example":"cnfu_123"},{"type":"null"}]},"type":{"type":"string","enum":["configuration_update"],"description":"The item type. Always `configuration_update`.","default":"configuration_update","x-stainless-const":true},"reasoning":{"type":"object","description":"Updates to reasoning configuration. Only effort is supported.","properties":{"effort":{"$ref":"#/components/schemas/ReasoningEffort","description":"The reasoning effort to use for subsequent responses until another\nconfiguration update replaces it.\n"}}}},"required":["type"]},"ResponseContentPartAddedEvent":{"type":"object","description":"Emitted when a new content part is added.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.content_part.added`.\n","enum":["response.content_part.added"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the content part was added to.\n"},"output_index":{"type":"integer","description":"The index of the output item that the content part was added to.\n"},"content_index":{"type":"integer","description":"The index of the content part that was added.\n"},"part":{"$ref":"#/components/schemas/OutputContent","description":"The content part that was added.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","item_id","output_index","content_index","part","sequence_number"],"x-oaiMeta":{"name":"response.content_part.added","group":"responses","example":"{\n \"type\": \"response.content_part.added\",\n \"item_id\": \"msg_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"part\": {\n \"type\": \"output_text\",\n \"text\": \"\",\n \"annotations\": [],\n \"logprobs\": []\n },\n \"sequence_number\": 1\n}\n"}},"ResponseContentPartDoneEvent":{"type":"object","description":"Emitted when a content part is done.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.content_part.done`.\n","enum":["response.content_part.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the content part was added to.\n"},"output_index":{"type":"integer","description":"The index of the output item that the content part was added to.\n"},"content_index":{"type":"integer","description":"The index of the content part that is done.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"part":{"$ref":"#/components/schemas/OutputContent","description":"The content part that is done.\n"}},"required":["type","item_id","output_index","content_index","part","sequence_number"],"x-oaiMeta":{"name":"response.content_part.done","group":"responses","example":"{\n \"type\": \"response.content_part.done\",\n \"item_id\": \"msg_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"sequence_number\": 1,\n \"part\": {\n \"type\": \"output_text\",\n \"text\": \"In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.\",\n \"annotations\": [],\n \"logprobs\": []\n }\n}\n"}},"ResponseConversation":{"properties":{"id":{"type":"string","description":"The unique ID of the conversation that this response was associated with."}},"type":"object","required":["id"],"title":"Conversation","description":"The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation."},"ResponseCreatedEvent":{"type":"object","description":"An event that is emitted when a response is created.\n","properties":{"type":{"type":"string","description":"The type of the event. Always `response.created`.\n","enum":["response.created"],"x-stainless-const":true},"response":{"$ref":"#/components/schemas/Response","description":"The response that was created.\n"},"sequence_number":{"type":"integer","description":"The sequence number for this event."}},"required":["type","response","sequence_number"],"x-oaiMeta":{"name":"response.created","group":"responses","example":"{\n \"type\": \"response.created\",\n \"response\": {\n \"id\": \"resp_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c\",\n \"object\": \"response\",\n \"access_programs\": null,\n \"created_at\": 1741487325,\n \"status\": \"in_progress\",\n \"completed_at\": null,\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"model\": \"gpt-6-astra\",\n \"output\": [],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"store\": true,\n \"temperature\": 1,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n }\n },\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_p\": 1,\n \"truncation\": \"disabled\",\n \"usage\": null,\n \"user\": null,\n \"metadata\": {}\n },\n \"sequence_number\": 1\n}\n"}},"ResponseCustomToolCallInputDeltaEvent":{"title":"ResponseCustomToolCallInputDelta","type":"object","description":"Event representing a delta (partial update) to the input of a custom tool call.\n","properties":{"type":{"type":"string","enum":["response.custom_tool_call_input.delta"],"description":"The event type identifier.","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"output_index":{"type":"integer","description":"The index of the output this delta applies to."},"item_id":{"type":"string","description":"Unique identifier for the API item associated with this event."},"delta":{"type":"string","description":"The incremental input data (delta) for the custom tool call."}},"required":["type","output_index","item_id","delta","sequence_number"],"x-oaiMeta":{"name":"response.custom_tool_call_input.delta","group":"responses","example":"{\n \"type\": \"response.custom_tool_call_input.delta\",\n \"sequence_number\": 1,\n \"output_index\": 0,\n \"item_id\": \"ctc_1234567890abcdef\",\n \"delta\": \"partial input text\"\n}\n"}},"ResponseCustomToolCallInputDoneEvent":{"title":"ResponseCustomToolCallInputDone","type":"object","description":"Event indicating that input for a custom tool call is complete.\n","properties":{"type":{"type":"string","enum":["response.custom_tool_call_input.done"],"description":"The event type identifier.","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"output_index":{"type":"integer","description":"The index of the output this event applies to."},"item_id":{"type":"string","description":"Unique identifier for the API item associated with this event."},"input":{"type":"string","description":"The complete input data for the custom tool call."}},"required":["type","output_index","item_id","input","sequence_number"],"x-oaiMeta":{"name":"response.custom_tool_call_input.done","group":"responses","example":"{\n \"type\": \"response.custom_tool_call_input.done\",\n \"sequence_number\": 1,\n \"output_index\": 0,\n \"item_id\": \"ctc_1234567890abcdef\",\n \"input\": \"final complete input text\"\n}\n"}},"ResponseError":{"anyOf":[{"type":"object","description":"An error object returned when the model fails to generate a Response.\n","properties":{"type":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The original error type, or null if it was not recorded."},"param":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The request parameter associated with the error, or null if none was recorded."},"code":{"$ref":"#/components/schemas/ResponseErrorCode"},"message":{"type":"string","description":"A human-readable description of the error.\n"},"misalignment":{"$ref":"#/components/schemas/MisalignmentErrorDetailsResource"}},"required":["code","message"]},{"type":"null"}]},"ResponseErrorCode":{"type":"string","description":"The error code for the response.\n","enum":["server_error","rate_limit_exceeded","invalid_prompt","data_residency_mismatch","bio_policy","misalignment_policy_violation","vector_store_timeout","invalid_image","invalid_image_format","invalid_base64_image","invalid_image_url","image_too_large","image_too_small","image_parse_error","image_content_policy_violation","invalid_image_mode","image_file_too_large","unsupported_image_media_type","empty_image_file","failed_to_download_image","image_file_not_found"]},"ResponseErrorEvent":{"type":"object","description":"Emitted when an error occurs.","properties":{"type":{"type":"string","description":"The type of the event. Always `error`.\n","enum":["error"],"x-stainless-const":true},"code":{"anyOf":[{"type":"string","description":"The error code.\n"},{"type":"null"}]},"message":{"type":"string","description":"The error message.\n"},"param":{"anyOf":[{"type":"string","description":"The error parameter.\n"},{"type":"null"}]},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","code","message","param","sequence_number"],"x-oaiMeta":{"name":"error","group":"responses","example":"{\n \"type\": \"error\",\n \"code\": \"ERR_SOMETHING\",\n \"message\": \"Something went wrong\",\n \"param\": null,\n \"sequence_number\": 1\n}\n"}},"ResponseFailedEvent":{"type":"object","description":"An event that is emitted when a response fails.\n","properties":{"type":{"type":"string","description":"The type of the event. Always `response.failed`.\n","enum":["response.failed"],"x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"response":{"$ref":"#/components/schemas/Response","description":"The response that failed.\n"}},"required":["type","response","sequence_number"],"x-oaiMeta":{"name":"response.failed","group":"responses","example":"{\n \"type\": \"response.failed\",\n \"response\": {\n \"id\": \"resp_123\",\n \"object\": \"response\",\n \"access_programs\": null,\n \"created_at\": 1740855869,\n \"status\": \"failed\",\n \"completed_at\": null,\n \"error\": {\n \"code\": \"server_error\",\n \"message\": \"The model failed to generate a response.\"\n },\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"model\": \"gpt-6-astra\",\n \"output\": [],\n \"previous_response_id\": null,\n \"reasoning_effort\": null,\n \"store\": false,\n \"temperature\": 1,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n }\n },\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_p\": 1,\n \"truncation\": \"disabled\",\n \"usage\": null,\n \"user\": null,\n \"metadata\": {},\n \"parallel_tool_calls\": true\n },\n \"sequence_number\": 1\n}\n"}},"ResponseFileSearchCallCompletedEvent":{"type":"object","description":"Emitted when a file search call is completed (results found).","properties":{"type":{"type":"string","description":"The type of the event. Always `response.file_search_call.completed`.\n","enum":["response.file_search_call.completed"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that the file search call is initiated.\n"},"item_id":{"type":"string","description":"The ID of the output item that the file search call is initiated.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.file_search_call.completed","group":"responses","example":"{\n \"type\": \"response.file_search_call.completed\",\n \"output_index\": 0,\n \"item_id\": \"fs_123\",\n \"sequence_number\": 1\n}\n"}},"ResponseFileSearchCallInProgressEvent":{"type":"object","description":"Emitted when a file search call is initiated.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.file_search_call.in_progress`.\n","enum":["response.file_search_call.in_progress"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that the file search call is initiated.\n"},"item_id":{"type":"string","description":"The ID of the output item that the file search call is initiated.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.file_search_call.in_progress","group":"responses","example":"{\n \"type\": \"response.file_search_call.in_progress\",\n \"output_index\": 0,\n \"item_id\": \"fs_123\",\n \"sequence_number\": 1\n}\n"}},"ResponseFileSearchCallSearchingEvent":{"type":"object","description":"Emitted when a file search is currently searching.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.file_search_call.searching`.\n","enum":["response.file_search_call.searching"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that the file search call is searching.\n"},"item_id":{"type":"string","description":"The ID of the output item that the file search call is initiated.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.file_search_call.searching","group":"responses","example":"{\n \"type\": \"response.file_search_call.searching\",\n \"output_index\": 0,\n \"item_id\": \"fs_123\",\n \"sequence_number\": 1\n}\n"}},"ResponseFormatJsonObject":{"type":"object","title":"JSON object","description":"JSON object response format. An older method of generating JSON responses.\nUsing `json_schema` is recommended for models that support it. Note that the\nmodel will not generate JSON without a system or user message instructing it\nto do so.\n","properties":{"type":{"type":"string","description":"The type of response format being defined. Always `json_object`.","enum":["json_object"],"x-stainless-const":true}},"required":["type"]},"ResponseFormatJsonSchema":{"type":"object","title":"JSON schema","description":"JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs).\n","properties":{"type":{"type":"string","description":"The type of response format being defined. Always `json_schema`.","enum":["json_schema"],"x-stainless-const":true},"json_schema":{"x-openai-structured-output":"json_schema","type":"object","title":"JSON schema","description":"Structured Outputs configuration options, including a JSON Schema.\n","properties":{"description":{"type":"string","description":"A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n"},"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n"},"schema":{"$ref":"#/components/schemas/ResponseFormatJsonSchemaSchema"},"strict":{"anyOf":[{"type":"boolean","default":false,"description":"Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](https://developers.openai.com/api/docs/guides/structured-outputs).\n"},{"type":"null"}]}},"required":["name"]}},"required":["type","json_schema"]},"ResponseFormatJsonSchemaSchema":{"type":"object","title":"JSON schema","description":"The schema for the response format, described as a JSON Schema object.\nLearn how to build JSON schemas [here](https://json-schema.org/).\n","additionalProperties":true},"ResponseFormatText":{"type":"object","title":"Text","description":"Default response format. Used to generate text responses.\n","properties":{"type":{"type":"string","description":"The type of response format being defined. Always `text`.","enum":["text"],"x-stainless-const":true}},"required":["type"]},"ResponseFunctionCallArgumentsDeltaEvent":{"type":"object","description":"Emitted when there is a partial function-call arguments delta.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.function_call_arguments.delta`.\n","enum":["response.function_call_arguments.delta"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the function-call arguments delta is added to.\n"},"output_index":{"type":"integer","description":"The index of the output item that the function-call arguments delta is added to.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"delta":{"type":"string","description":"The function-call arguments delta that is added.\n"}},"required":["type","item_id","output_index","delta","sequence_number"],"x-oaiMeta":{"name":"response.function_call_arguments.delta","group":"responses","example":"{\n \"type\": \"response.function_call_arguments.delta\",\n \"item_id\": \"item-abc\",\n \"output_index\": 0,\n \"delta\": \"{ \\\"arg\\\":\",\n \"sequence_number\": 1\n}\n"}},"ResponseFunctionCallArgumentsDoneEvent":{"type":"object","description":"Emitted when function-call arguments are finalized.","properties":{"type":{"type":"string","enum":["response.function_call_arguments.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item."},"output_index":{"type":"integer","description":"The index of the output item."},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"arguments":{"type":"string","description":"The function-call arguments."}},"required":["type","item_id","output_index","arguments","sequence_number"],"x-oaiMeta":{"name":"response.function_call_arguments.done","group":"responses","example":"{\n \"type\": \"response.function_call_arguments.done\",\n \"item_id\": \"item-abc\",\n \"output_index\": 1,\n \"arguments\": \"{ \\\"arg\\\": 123 }\",\n \"sequence_number\": 1\n}\n"}},"ResponseImageGenCallCompletedEvent":{"type":"object","title":"ResponseImageGenCallCompletedEvent","description":"Emitted when an image generation tool call has completed and the final image is available.\n","properties":{"type":{"type":"string","enum":["response.image_generation_call.completed"],"description":"The type of the event. Always 'response.image_generation_call.completed'.","x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"item_id":{"type":"string","description":"The unique identifier of the image generation item being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.image_generation_call.completed","group":"responses","example":"{\n \"type\": \"response.image_generation_call.completed\",\n \"output_index\": 0,\n \"item_id\": \"item-123\",\n \"sequence_number\": 1\n}\n"}},"ResponseImageGenCallGeneratingEvent":{"type":"object","title":"ResponseImageGenCallGeneratingEvent","description":"Emitted when an image generation tool call is actively generating an image (intermediate state).\n","properties":{"type":{"type":"string","enum":["response.image_generation_call.generating"],"description":"The type of the event. Always 'response.image_generation_call.generating'.","x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"item_id":{"type":"string","description":"The unique identifier of the image generation item being processed."},"sequence_number":{"type":"integer","description":"The sequence number of the image generation item being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.image_generation_call.generating","group":"responses","example":"{\n \"type\": \"response.image_generation_call.generating\",\n \"output_index\": 0,\n \"item_id\": \"item-123\",\n \"sequence_number\": 0\n}\n"}},"ResponseImageGenCallInProgressEvent":{"type":"object","title":"ResponseImageGenCallInProgressEvent","description":"Emitted when an image generation tool call is in progress.\n","properties":{"type":{"type":"string","enum":["response.image_generation_call.in_progress"],"description":"The type of the event. Always 'response.image_generation_call.in_progress'.","x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"item_id":{"type":"string","description":"The unique identifier of the image generation item being processed."},"sequence_number":{"type":"integer","description":"The sequence number of the image generation item being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.image_generation_call.in_progress","group":"responses","example":"{\n \"type\": \"response.image_generation_call.in_progress\",\n \"output_index\": 0,\n \"item_id\": \"item-123\",\n \"sequence_number\": 0\n}\n"}},"ResponseImageGenCallPartialImageEvent":{"type":"object","title":"ResponseImageGenCallPartialImageEvent","description":"Emitted when a partial image is available during image generation streaming.\n","properties":{"type":{"type":"string","enum":["response.image_generation_call.partial_image"],"description":"The type of the event. Always 'response.image_generation_call.partial_image'.","x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"item_id":{"type":"string","description":"The unique identifier of the image generation item being processed."},"sequence_number":{"type":"integer","description":"The sequence number of the image generation item being processed."},"partial_image_index":{"type":"integer","description":"0-based index for the partial image (backend is 1-based, but this is 0-based for the user)."},"partial_image_b64":{"type":"string","description":"Base64-encoded partial image data, suitable for rendering as an image."},"size":{"type":"string","description":"The image size that was used."},"quality":{"type":"string","description":"The image quality that was used."},"background":{"type":"string","description":"The background setting that was used."},"output_format":{"type":"string","description":"The output format that was used."}},"required":["type","output_index","item_id","sequence_number","partial_image_index","partial_image_b64"],"x-oaiMeta":{"name":"response.image_generation_call.partial_image","group":"responses","example":"{\n \"type\": \"response.image_generation_call.partial_image\",\n \"output_index\": 0,\n \"item_id\": \"item-123\",\n \"sequence_number\": 0,\n \"partial_image_index\": 0,\n \"partial_image_b64\": \"...\"\n}\n"}},"ResponseInProgressEvent":{"type":"object","description":"Emitted when the response is in progress.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.in_progress`.\n","enum":["response.in_progress"],"x-stainless-const":true},"response":{"$ref":"#/components/schemas/Response","description":"The response that is in progress.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","response","sequence_number"],"x-oaiMeta":{"name":"response.in_progress","group":"responses","example":"{\n \"type\": \"response.in_progress\",\n \"response\": {\n \"id\": \"resp_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c\",\n \"object\": \"response\",\n \"access_programs\": null,\n \"created_at\": 1741487325,\n \"status\": \"in_progress\",\n \"completed_at\": null,\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"model\": \"gpt-6-astra\",\n \"output\": [],\n \"parallel_tool_calls\": true,\n \"previous_response_id\": null,\n \"reasoning\": {\n \"effort\": null,\n \"summary\": null\n },\n \"store\": true,\n \"temperature\": 1,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n }\n },\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_p\": 1,\n \"truncation\": \"disabled\",\n \"usage\": null,\n \"user\": null,\n \"metadata\": {}\n },\n \"sequence_number\": 1\n}\n"}},"ResponseIncompleteEvent":{"type":"object","description":"An event that is emitted when a response finishes as incomplete.\n\nOver WebSocket, steering can finish a response with\n`response.incomplete_details.reason` set to `steered`, followed automatically\nby a successor `response.created` that commits the queued steering input.\n","properties":{"type":{"type":"string","description":"The type of the event. Always `response.incomplete`.\n","enum":["response.incomplete"],"x-stainless-const":true},"response":{"$ref":"#/components/schemas/Response","description":"The response that was incomplete.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","response","sequence_number"],"x-oaiMeta":{"name":"response.incomplete","group":"responses","example":"{\n \"type\": \"response.incomplete\",\n \"response\": {\n \"id\": \"resp_123\",\n \"object\": \"response\",\n \"access_programs\": null,\n \"created_at\": 1740855869,\n \"status\": \"incomplete\",\n \"completed_at\": null,\n \"error\": null,\n \"incomplete_details\": {\n \"reason\": \"max_output_tokens\"\n },\n \"instructions\": null,\n \"max_output_tokens\": null,\n \"model\": \"gpt-6-astra\",\n \"output\": [],\n \"previous_response_id\": null,\n \"reasoning_effort\": null,\n \"store\": false,\n \"temperature\": 1,\n \"text\": {\n \"format\": {\n \"type\": \"text\"\n }\n },\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_p\": 1,\n \"truncation\": \"disabled\",\n \"usage\": null,\n \"user\": null,\n \"metadata\": {},\n \"parallel_tool_calls\": true\n },\n \"sequence_number\": 1\n}\n"}},"ResponseLogProb":{"type":"object","description":"A logprob is the logarithmic probability that the model assigns to producing \na particular token at a given position in the sequence. Less-negative (higher) \nlogprob values indicate greater model confidence in that token choice.\n","properties":{"token":{"description":"A possible text token.","type":"string"},"logprob":{"description":"The log probability of this token.\n","type":"number"},"top_logprobs":{"description":"The log probabilities of up to 20 of the most likely tokens.\n","type":"array","items":{"type":"object","properties":{"token":{"description":"A possible text token.","type":"string"},"logprob":{"description":"The log probability of this token.","type":"number"}}}}},"required":["token","logprob"]},"ResponseMCPCallArgumentsDeltaEvent":{"type":"object","title":"ResponseMCPCallArgumentsDeltaEvent","description":"Emitted when there is a delta (partial update) to the arguments of an MCP tool call.\n","properties":{"type":{"type":"string","enum":["response.mcp_call_arguments.delta"],"description":"The type of the event. Always 'response.mcp_call_arguments.delta'.","x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"item_id":{"type":"string","description":"The unique identifier of the MCP tool call item being processed."},"delta":{"type":"string","description":"A JSON string containing the partial update to the arguments for the MCP tool call.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","output_index","item_id","delta","sequence_number"],"x-oaiMeta":{"name":"response.mcp_call_arguments.delta","group":"responses","example":"{\n \"type\": \"response.mcp_call_arguments.delta\",\n \"output_index\": 0,\n \"item_id\": \"item-abc\",\n \"delta\": \"{\",\n \"sequence_number\": 1\n}\n"}},"ResponseMCPCallArgumentsDoneEvent":{"type":"object","title":"ResponseMCPCallArgumentsDoneEvent","description":"Emitted when the arguments for an MCP tool call are finalized.\n","properties":{"type":{"type":"string","enum":["response.mcp_call_arguments.done"],"description":"The type of the event. Always 'response.mcp_call_arguments.done'.","x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"item_id":{"type":"string","description":"The unique identifier of the MCP tool call item being processed."},"arguments":{"type":"string","description":"A JSON string containing the finalized arguments for the MCP tool call.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","output_index","item_id","arguments","sequence_number"],"x-oaiMeta":{"name":"response.mcp_call_arguments.done","group":"responses","example":"{\n \"type\": \"response.mcp_call_arguments.done\",\n \"output_index\": 0,\n \"item_id\": \"item-abc\",\n \"arguments\": \"{\\\"arg1\\\": \\\"value1\\\", \\\"arg2\\\": \\\"value2\\\"}\",\n \"sequence_number\": 1\n}\n"}},"ResponseMCPCallCompletedEvent":{"type":"object","title":"ResponseMCPCallCompletedEvent","description":"Emitted when an MCP tool call has completed successfully.\n","properties":{"type":{"type":"string","enum":["response.mcp_call.completed"],"description":"The type of the event. Always 'response.mcp_call.completed'.","x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the MCP tool call item that completed."},"output_index":{"type":"integer","description":"The index of the output item that completed."},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","item_id","output_index","sequence_number"],"x-oaiMeta":{"name":"response.mcp_call.completed","group":"responses","example":"{\n \"type\": \"response.mcp_call.completed\",\n \"sequence_number\": 1,\n \"item_id\": \"mcp_682d437d90a88191bf88cd03aae0c3e503937d5f622d7a90\",\n \"output_index\": 0\n}\n"}},"ResponseMCPCallFailedEvent":{"type":"object","title":"ResponseMCPCallFailedEvent","description":"Emitted when an MCP tool call has failed.\n","properties":{"type":{"type":"string","enum":["response.mcp_call.failed"],"description":"The type of the event. Always 'response.mcp_call.failed'.","x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the MCP tool call item that failed."},"output_index":{"type":"integer","description":"The index of the output item that failed."},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","item_id","output_index","sequence_number"],"x-oaiMeta":{"name":"response.mcp_call.failed","group":"responses","example":"{\n \"type\": \"response.mcp_call.failed\",\n \"sequence_number\": 1,\n \"item_id\": \"mcp_682d437d90a88191bf88cd03aae0c3e503937d5f622d7a90\",\n \"output_index\": 0\n}\n"}},"ResponseMCPCallInProgressEvent":{"type":"object","title":"ResponseMCPCallInProgressEvent","description":"Emitted when an MCP tool call is in progress.\n","properties":{"type":{"type":"string","enum":["response.mcp_call.in_progress"],"description":"The type of the event. Always 'response.mcp_call.in_progress'.","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"item_id":{"type":"string","description":"The unique identifier of the MCP tool call item being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.mcp_call.in_progress","group":"responses","example":"{\n \"type\": \"response.mcp_call.in_progress\",\n \"sequence_number\": 1,\n \"output_index\": 0,\n \"item_id\": \"mcp_682d437d90a88191bf88cd03aae0c3e503937d5f622d7a90\"\n}\n"}},"ResponseMCPListToolsCompletedEvent":{"type":"object","title":"ResponseMCPListToolsCompletedEvent","description":"Emitted when the list of available MCP tools has been successfully retrieved.\n","properties":{"type":{"type":"string","enum":["response.mcp_list_tools.completed"],"description":"The type of the event. Always 'response.mcp_list_tools.completed'.","x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the MCP tool call item that produced this output."},"output_index":{"type":"integer","description":"The index of the output item that was processed."},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","item_id","output_index","sequence_number"],"x-oaiMeta":{"name":"response.mcp_list_tools.completed","group":"responses","example":"{\n \"type\": \"response.mcp_list_tools.completed\",\n \"sequence_number\": 1,\n \"output_index\": 0,\n \"item_id\": \"mcpl_682d4379df088191886b70f4ec39f90403937d5f622d7a90\"\n}\n"}},"ResponseMCPListToolsFailedEvent":{"type":"object","title":"ResponseMCPListToolsFailedEvent","description":"Emitted when the attempt to list available MCP tools has failed.\n","properties":{"type":{"type":"string","enum":["response.mcp_list_tools.failed"],"description":"The type of the event. Always 'response.mcp_list_tools.failed'.","x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the MCP tool call item that failed."},"output_index":{"type":"integer","description":"The index of the output item that failed."},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","item_id","output_index","sequence_number"],"x-oaiMeta":{"name":"response.mcp_list_tools.failed","group":"responses","example":"{\n \"type\": \"response.mcp_list_tools.failed\",\n \"sequence_number\": 1,\n \"output_index\": 0,\n \"item_id\": \"mcpl_682d4379df088191886b70f4ec39f90403937d5f622d7a90\"\n}\n"}},"ResponseMCPListToolsInProgressEvent":{"type":"object","title":"ResponseMCPListToolsInProgressEvent","description":"Emitted when the system is in the process of retrieving the list of available MCP tools.\n","properties":{"type":{"type":"string","enum":["response.mcp_list_tools.in_progress"],"description":"The type of the event. Always 'response.mcp_list_tools.in_progress'.","x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the MCP tool call item that is being processed."},"output_index":{"type":"integer","description":"The index of the output item that is being processed."},"sequence_number":{"type":"integer","description":"The sequence number of this event."}},"required":["type","item_id","output_index","sequence_number"],"x-oaiMeta":{"name":"response.mcp_list_tools.in_progress","group":"responses","example":"{\n \"type\": \"response.mcp_list_tools.in_progress\",\n \"sequence_number\": 1,\n \"output_index\": 0,\n \"item_id\": \"mcpl_682d4379df088191886b70f4ec39f90403937d5f622d7a90\"\n}\n"}},"ResponseModalities":{"anyOf":[{"type":"array","description":"Output types that you would like the model to generate.\nMost models are capable of generating text, which is the default:\n\n`[\"text\"]`\n\nThe `gpt-4o-audio-preview` model can also be used to\n[generate audio](https://developers.openai.com/api/docs/guides/audio). To request that this model generate\nboth text and audio responses, you can use:\n\n`[\"text\", \"audio\"]`\n","items":{"type":"string","enum":["text","audio"]}},{"type":"null"}]},"ResponseOutputItemAddedEvent":{"type":"object","description":"Emitted when a new output item is added.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.output_item.added`.\n","enum":["response.output_item.added"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that was added.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"},"item":{"$ref":"#/components/schemas/OutputItem","description":"The output item that was added. For reasoning items, `encrypted_content`\nmay be incomplete while the item is in progress. Use the reasoning item\nfrom the corresponding `response.output_item.done` event when passing it\nas input to a subsequent request.\n"}},"required":["type","output_index","item","sequence_number"],"x-oaiMeta":{"name":"response.output_item.added","group":"responses","example":"{\n \"type\": \"response.output_item.added\",\n \"output_index\": 0,\n \"item\": {\n \"id\": \"msg_123\",\n \"status\": \"in_progress\",\n \"type\": \"message\",\n \"role\": \"assistant\",\n \"content\": []\n },\n \"sequence_number\": 1\n}\n"}},"ResponseOutputItemDoneEvent":{"type":"object","description":"Emitted when an output item is marked done.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.output_item.done`.\n","enum":["response.output_item.done"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that was marked done.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"},"item":{"$ref":"#/components/schemas/OutputItem","description":"The output item that was marked done.\n"}},"required":["type","output_index","item","sequence_number"],"x-oaiMeta":{"name":"response.output_item.done","group":"responses","example":"{\n \"type\": \"response.output_item.done\",\n \"output_index\": 0,\n \"item\": {\n \"id\": \"msg_123\",\n \"status\": \"completed\",\n \"type\": \"message\",\n \"role\": \"assistant\",\n \"content\": [\n {\n \"type\": \"output_text\",\n \"text\": \"In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.\",\n \"annotations\": [],\n \"logprobs\": []\n }\n ]\n },\n \"sequence_number\": 1\n}\n"}},"ResponseOutputTextAnnotationAddedEvent":{"type":"object","title":"ResponseOutputTextAnnotationAddedEvent","description":"Emitted when an annotation is added to output text content.\n","properties":{"type":{"type":"string","enum":["response.output_text.annotation.added"],"description":"The type of the event. Always 'response.output_text.annotation.added'.","x-stainless-const":true},"item_id":{"type":"string","description":"The unique identifier of the item to which the annotation is being added."},"output_index":{"type":"integer","description":"The index of the output item in the response's output array."},"content_index":{"type":"integer","description":"The index of the content part within the output item."},"annotation_index":{"type":"integer","description":"The index of the annotation within the content part."},"sequence_number":{"type":"integer","description":"The sequence number of this event."},"annotation":{"anyOf":[{"$ref":"#/components/schemas/Annotation"},{"type":"null"}],"description":"The annotation object being added. (See annotation schema for details.)"}},"required":["type","item_id","output_index","content_index","annotation_index","annotation","sequence_number"],"x-oaiMeta":{"name":"response.output_text.annotation.added","group":"responses","example":"{\n \"type\": \"response.output_text.annotation.added\",\n \"item_id\": \"item-abc\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"annotation_index\": 0,\n \"annotation\": {\n \"type\": \"file_citation\",\n \"file_id\": \"file-abc\",\n \"index\": 0,\n \"filename\": \"example.txt\"\n },\n \"sequence_number\": 1\n}\n"}},"ResponsePromptCacheOptionsParam":{"properties":{"ttl":{"$ref":"#/components/schemas/PromptCacheTTLEnum","description":"The minimum lifetime applied to every implicit and explicit cache breakpoint written by the request. Defaults to `30m`, which is currently the only supported value. The backend may retain cache entries for longer."},"mode":{"$ref":"#/components/schemas/PromptCacheModeEnum","description":"Controls whether OpenAI automatically creates an implicit cache breakpoint. Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint and writes up to the latest three explicit breakpoints in the request. With `explicit`, OpenAI does not create an implicit breakpoint and writes up to the latest four explicit breakpoints. If there are no explicit breakpoints, the request does not use prompt caching."},"prewarm":{"type":"boolean","description":"Prepares the prompt cache without generating output. Defaults to `false`. When set to `true`, overrides the `generate` field to `false`."},"comparison_response_id":{"anyOf":[{"type":"string","description":"The ID of a response to compare when diagnosing prompt cache reuse. Supplying this field requests prompt cache diagnostics when the feature is enabled.","example":"resp_123"},{"type":"null"}]}},"type":"object","required":[],"title":"Prompt cache options","description":"Options for prompt caching. Supported for `gpt-5.6` and later models. By default, OpenAI automatically chooses one implicit cache breakpoint. You can add explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each request can write up to four breakpoints. For cache matching, OpenAI considers up to the latest 80 breakpoints in the conversation, without a content-block lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The `ttl` defaults to `30m`, which is currently the only supported value. See the [prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching) for current details."},"ResponsePromptVariables":{"anyOf":[{"type":"object","title":"Prompt Variables","description":"Optional map of values to substitute in for variables in your\nprompt. The substitution values can either be strings, or other\nResponse input types like images or files.\n","x-oaiExpandable":true,"x-oaiTypeLabel":"map","additionalProperties":{"x-oaiExpandable":true,"x-oaiTypeLabel":"map","oneOf":[{"type":"string"},{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}]}},{"type":"null"}]},"ResponseProperties":{"type":"object","properties":{"previous_response_id":{"anyOf":[{"type":"string","description":"The unique ID of the previous response to the model. Use this to\ncreate multi-turn conversations. Learn more about\n[conversation state](https://developers.openai.com/api/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`.\n"},{"type":"null"}]},"model":{"description":"Model ID used to generate the response, like `gpt-6-astra`. OpenAI\noffers a wide range of models with different capabilities, performance\ncharacteristics, and price points. Refer to the [model guide](https://developers.openai.com/api/docs/models)\nto browse and compare available models.\n","$ref":"#/components/schemas/ModelIdsResponses"},"background":{"anyOf":[{"type":"boolean","description":"Whether to run the model response in the background.\n[Learn more](https://developers.openai.com/api/docs/guides/background).\n","default":false},{"type":"null"}]},"max_tool_calls":{"anyOf":[{"description":"The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored.\n","type":"integer"},{"type":"null"}]},"text":{"$ref":"#/components/schemas/ResponseTextParam"},"tools":{"$ref":"#/components/schemas/ToolsArray"},"tool_choice":{"$ref":"#/components/schemas/ToolChoiceParam"},"prompt":{"$ref":"#/components/schemas/Prompt"}}},"ResponseQueuedEvent":{"type":"object","title":"ResponseQueuedEvent","description":"Emitted when a response is queued and waiting to be processed.\n","properties":{"type":{"type":"string","enum":["response.queued"],"description":"The type of the event. Always 'response.queued'.","x-stainless-const":true},"response":{"$ref":"#/components/schemas/Response","description":"The full response object that is queued."},"sequence_number":{"type":"integer","description":"The sequence number for this event."}},"required":["type","response","sequence_number"],"x-oaiMeta":{"name":"response.queued","group":"responses","example":"{\n \"type\": \"response.queued\",\n \"response\": {\n \"id\": \"resp_123\",\n \"object\": \"response\",\n \"access_programs\": null,\n \"created_at\": 1609459200,\n \"status\": \"queued\",\n \"error\": null,\n \"incomplete_details\": null,\n \"instructions\": null,\n \"model\": \"gpt-6-astra\",\n \"output\": [],\n \"parallel_tool_calls\": true,\n \"temperature\": 1,\n \"tool_choice\": \"auto\",\n \"tools\": [],\n \"top_p\": 1,\n \"metadata\": {}\n },\n \"sequence_number\": 1\n}\n"}},"ResponseReasoningSummaryPartAddedEvent":{"type":"object","description":"Emitted when a new reasoning summary part is added.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.reasoning_summary_part.added`.\n","enum":["response.reasoning_summary_part.added"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item this summary part is associated with.\n"},"output_index":{"type":"integer","description":"The index of the output item this summary part is associated with.\n"},"summary_index":{"type":"integer","description":"The index of the summary part within the reasoning summary.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"},"part":{"type":"object","description":"The summary part that was added.\n","properties":{"type":{"type":"string","description":"The type of the summary part. Always `summary_text`.","enum":["summary_text"],"x-stainless-const":true},"text":{"type":"string","description":"The text of the summary part."}},"required":["type","text"]}},"required":["type","item_id","output_index","summary_index","part","sequence_number"],"x-oaiMeta":{"name":"response.reasoning_summary_part.added","group":"responses","example":"{\n \"type\": \"response.reasoning_summary_part.added\",\n \"item_id\": \"rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476\",\n \"output_index\": 0,\n \"summary_index\": 0,\n \"part\": {\n \"type\": \"summary_text\",\n \"text\": \"\"\n },\n \"sequence_number\": 1\n}\n"}},"ResponseReasoningSummaryPartDoneEvent":{"type":"object","description":"Emitted when a reasoning summary part is completed.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.reasoning_summary_part.done`.\n","enum":["response.reasoning_summary_part.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item this summary part is associated with.\n"},"output_index":{"type":"integer","description":"The index of the output item this summary part is associated with.\n"},"summary_index":{"type":"integer","description":"The index of the summary part within the reasoning summary.\n"},"status":{"type":"string","description":"The completion status of the summary part. Omitted when the part completed\nnormally and set to `incomplete` when generation was interrupted.\n","enum":["incomplete"]},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"},"part":{"type":"object","description":"The completed summary part.\n","properties":{"type":{"type":"string","description":"The type of the summary part. Always `summary_text`.","enum":["summary_text"],"x-stainless-const":true},"text":{"type":"string","description":"The text of the summary part."}},"required":["type","text"]}},"required":["type","item_id","output_index","summary_index","part","sequence_number"],"x-oaiMeta":{"name":"response.reasoning_summary_part.done","group":"responses","example":"{\n \"type\": \"response.reasoning_summary_part.done\",\n \"item_id\": \"rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476\",\n \"output_index\": 0,\n \"summary_index\": 0,\n \"part\": {\n \"type\": \"summary_text\",\n \"text\": \"**Responding to a greeting**\\n\\nThe user just said, \\\"Hello!\\\" So, it seems I need to engage. I'll greet them back and offer help since they're looking to chat. I could say something like, \\\"Hello! How can I assist you today?\\\" That feels friendly and open. They didn't ask a specific question, so this approach will work well for starting a conversation. Let's see where it goes from there!\"\n },\n \"sequence_number\": 1\n}\n"}},"ResponseReasoningSummaryTextDeltaEvent":{"type":"object","description":"Emitted when a delta is added to a reasoning summary text.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.reasoning_summary_text.delta`.\n","enum":["response.reasoning_summary_text.delta"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item this summary text delta is associated with.\n"},"output_index":{"type":"integer","description":"The index of the output item this summary text delta is associated with.\n"},"summary_index":{"type":"integer","description":"The index of the summary part within the reasoning summary.\n"},"delta":{"type":"string","description":"The text delta that was added to the summary.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"}},"required":["type","item_id","output_index","summary_index","delta","sequence_number"],"x-oaiMeta":{"name":"response.reasoning_summary_text.delta","group":"responses","example":"{\n \"type\": \"response.reasoning_summary_text.delta\",\n \"item_id\": \"rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476\",\n \"output_index\": 0,\n \"summary_index\": 0,\n \"delta\": \"**Responding to a greeting**\\n\\nThe user just said, \\\"Hello!\\\" So, it seems I need to engage. I'll greet them back and offer help since they're looking to chat. I could say something like, \\\"Hello! How can I assist you today?\\\" That feels friendly and open. They didn't ask a specific question, so this approach will work well for starting a conversation. Let's see where it goes from there!\",\n \"sequence_number\": 1\n}\n"}},"ResponseReasoningSummaryTextDoneEvent":{"type":"object","description":"Emitted when a reasoning summary text is completed.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.reasoning_summary_text.done`.\n","enum":["response.reasoning_summary_text.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item this summary text is associated with.\n"},"output_index":{"type":"integer","description":"The index of the output item this summary text is associated with.\n"},"summary_index":{"type":"integer","description":"The index of the summary part within the reasoning summary.\n"},"text":{"type":"string","description":"The full text of the completed reasoning summary.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"}},"required":["type","item_id","output_index","summary_index","text","sequence_number"],"x-oaiMeta":{"name":"response.reasoning_summary_text.done","group":"responses","example":"{\n \"type\": \"response.reasoning_summary_text.done\",\n \"item_id\": \"rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476\",\n \"output_index\": 0,\n \"summary_index\": 0,\n \"text\": \"**Responding to a greeting**\\n\\nThe user just said, \\\"Hello!\\\" So, it seems I need to engage. I'll greet them back and offer help since they're looking to chat. I could say something like, \\\"Hello! How can I assist you today?\\\" That feels friendly and open. They didn't ask a specific question, so this approach will work well for starting a conversation. Let's see where it goes from there!\",\n \"sequence_number\": 1\n}\n"}},"ResponseReasoningTextDeltaEvent":{"type":"object","description":"Emitted when a delta is added to a reasoning text.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.reasoning_text.delta`.\n","enum":["response.reasoning_text.delta"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item this reasoning text delta is associated with.\n"},"output_index":{"type":"integer","description":"The index of the output item this reasoning text delta is associated with.\n"},"content_index":{"type":"integer","description":"The index of the reasoning content part this delta is associated with.\n"},"delta":{"type":"string","description":"The text delta that was added to the reasoning content.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"}},"required":["type","item_id","output_index","content_index","delta","sequence_number"],"x-oaiMeta":{"name":"response.reasoning_text.delta","group":"responses","example":"{\n \"type\": \"response.reasoning_text.delta\",\n \"item_id\": \"rs_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"delta\": \"The\",\n \"sequence_number\": 1\n}\n"}},"ResponseReasoningTextDoneEvent":{"type":"object","description":"Emitted when a reasoning text is completed.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.reasoning_text.done`.\n","enum":["response.reasoning_text.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the item this reasoning text is associated with.\n"},"output_index":{"type":"integer","description":"The index of the output item this reasoning text is associated with.\n"},"content_index":{"type":"integer","description":"The index of the reasoning content part.\n"},"text":{"type":"string","description":"The full text of the completed reasoning content.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"}},"required":["type","item_id","output_index","content_index","text","sequence_number"],"x-oaiMeta":{"name":"response.reasoning_text.done","group":"responses","example":"{\n \"type\": \"response.reasoning_text.done\",\n \"item_id\": \"rs_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"text\": \"The user is asking...\",\n \"sequence_number\": 4\n}\n"}},"ResponseRefusalDeltaEvent":{"type":"object","description":"Emitted when there is a partial refusal text.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.refusal.delta`.\n","enum":["response.refusal.delta"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the refusal text is added to.\n"},"output_index":{"type":"integer","description":"The index of the output item that the refusal text is added to.\n"},"content_index":{"type":"integer","description":"The index of the content part that the refusal text is added to.\n"},"delta":{"type":"string","description":"The refusal text that is added.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"}},"required":["type","item_id","output_index","content_index","delta","sequence_number"],"x-oaiMeta":{"name":"response.refusal.delta","group":"responses","example":"{\n \"type\": \"response.refusal.delta\",\n \"item_id\": \"msg_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"delta\": \"refusal text so far\",\n \"sequence_number\": 1\n}\n"}},"ResponseRefusalDoneEvent":{"type":"object","description":"Emitted when refusal text is finalized.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.refusal.done`.\n","enum":["response.refusal.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the refusal text is finalized.\n"},"output_index":{"type":"integer","description":"The index of the output item that the refusal text is finalized.\n"},"content_index":{"type":"integer","description":"The index of the content part that the refusal text is finalized.\n"},"refusal":{"type":"string","description":"The refusal text that is finalized.\n"},"sequence_number":{"type":"integer","description":"The sequence number of this event.\n"}},"required":["type","item_id","output_index","content_index","refusal","sequence_number"],"x-oaiMeta":{"name":"response.refusal.done","group":"responses","example":"{\n \"type\": \"response.refusal.done\",\n \"item_id\": \"item-abc\",\n \"output_index\": 1,\n \"content_index\": 2,\n \"refusal\": \"final refusal text\",\n \"sequence_number\": 1\n}\n"}},"ResponseShellCallCommandAddedStreamingEvent":{"properties":{"type":{"type":"string","enum":["response.shell_call_command.added"],"description":"The type of the event, always `response.shell_call_command.added`.","default":"response.shell_call_command.added","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"command_index":{"type":"integer","description":"The index of the shell command that was added."},"command":{"type":"string","description":"The shell command that was added."}},"type":"object","required":["type","sequence_number","output_index","command_index","command"],"title":"Response shell command added event","description":"A streaming event that indicated a shell command was added to a tool call."},"ResponseShellCallCommandDeltaStreamingEvent":{"properties":{"type":{"type":"string","enum":["response.shell_call_command.delta"],"description":"The type of the event, always `response.shell_call_command.delta`.","default":"response.shell_call_command.delta","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"command_index":{"type":"integer","description":"The index of the shell command that was updated."},"delta":{"type":"string","description":"The shell command delta that was appended."},"obfuscation":{"type":"string","description":"An obfuscation string that was added to pad the event payload."}},"type":"object","required":["type","sequence_number","output_index","command_index","delta"],"title":"Response shell command delta event","description":"A streaming event that indicated a shell command was incrementally updated."},"ResponseShellCallCommandDoneStreamingEvent":{"properties":{"type":{"type":"string","enum":["response.shell_call_command.done"],"description":"The type of the event, always `response.shell_call_command.done`.","default":"response.shell_call_command.done","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"command_index":{"type":"integer","description":"The index of the shell command that was completed."},"command":{"type":"string","description":"The final shell command that was emitted."}},"type":"object","required":["type","sequence_number","output_index","command_index","command"],"title":"Response shell command done event","description":"A streaming event that indicated a shell command was completed."},"ResponseShellCallOutputContentDeltaStreamingEvent":{"properties":{"type":{"type":"string","enum":["response.shell_call_output_content.delta"],"description":"The type of the event, always `response.shell_call_output_content.delta`.","default":"response.shell_call_output_content.delta","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the output item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"command_index":{"type":"integer","description":"The index of the shell command that produced output."},"delta":{"$ref":"#/components/schemas/ShellCallOutputDelta","description":"The stdout/stderr delta that was emitted."}},"type":"object","required":["type","sequence_number","item_id","output_index","command_index","delta"],"title":"Response shell call output content delta event","description":"A streaming event that indicated shell call output was incrementally added."},"ResponseShellCallOutputContentDoneStreamingEvent":{"properties":{"type":{"type":"string","enum":["response.shell_call_output_content.done"],"description":"The type of the event, always `response.shell_call_output_content.done`.","default":"response.shell_call_output_content.done","x-stainless-const":true},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the output item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"command_index":{"type":"integer","description":"The index of the shell command that produced output."},"output":{"items":{"$ref":"#/components/schemas/FunctionShellCallOutputContent"},"type":"array","description":"The output contents emitted for the shell command."}},"type":"object","required":["type","sequence_number","item_id","output_index","command_index","output"],"title":"Response shell call output content done event","description":"A streaming event that indicated shell call output was completed."},"ResponseStreamEvent":{"description":"Event emitted while a response is streamed.","anyOf":[{"$ref":"#/components/schemas/ResponseAudioDeltaEvent"},{"$ref":"#/components/schemas/ResponseAudioDoneEvent"},{"$ref":"#/components/schemas/ResponseAudioTranscriptDeltaEvent"},{"$ref":"#/components/schemas/ResponseAudioTranscriptDoneEvent"},{"$ref":"#/components/schemas/ResponseCodeInterpreterCallCodeDeltaEvent"},{"$ref":"#/components/schemas/ResponseCodeInterpreterCallCodeDoneEvent"},{"$ref":"#/components/schemas/ResponseCodeInterpreterCallCompletedEvent"},{"$ref":"#/components/schemas/ResponseCodeInterpreterCallInProgressEvent"},{"$ref":"#/components/schemas/ResponseCodeInterpreterCallInterpretingEvent"},{"$ref":"#/components/schemas/ResponseCompactionCompactingStreamingEvent"},{"$ref":"#/components/schemas/ResponseCompletedEvent"},{"$ref":"#/components/schemas/ResponseContentPartAddedEvent"},{"$ref":"#/components/schemas/ResponseContentPartDoneEvent"},{"$ref":"#/components/schemas/ResponseCreatedEvent"},{"$ref":"#/components/schemas/ResponseErrorEvent"},{"$ref":"#/components/schemas/ResponseFileSearchCallCompletedEvent"},{"$ref":"#/components/schemas/ResponseFileSearchCallInProgressEvent"},{"$ref":"#/components/schemas/ResponseFileSearchCallSearchingEvent"},{"$ref":"#/components/schemas/ResponseFunctionCallArgumentsDeltaEvent"},{"$ref":"#/components/schemas/ResponseFunctionCallArgumentsDoneEvent"},{"$ref":"#/components/schemas/ResponseShellCallCommandAddedStreamingEvent"},{"$ref":"#/components/schemas/ResponseShellCallCommandDeltaStreamingEvent"},{"$ref":"#/components/schemas/ResponseShellCallCommandDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseShellCallOutputContentDeltaStreamingEvent","x-stainless-skip":["go"]},{"$ref":"#/components/schemas/ResponseShellCallOutputContentDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseInProgressEvent"},{"$ref":"#/components/schemas/ResponseFailedEvent"},{"$ref":"#/components/schemas/ResponseIncompleteEvent"},{"$ref":"#/components/schemas/ResponseOutputItemAddedEvent"},{"$ref":"#/components/schemas/ResponseOutputItemDoneEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryPartAddedEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryPartDoneEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryTextDeltaEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryTextDoneEvent"},{"$ref":"#/components/schemas/ResponseReasoningTextDeltaEvent"},{"$ref":"#/components/schemas/ResponseReasoningTextDoneEvent"},{"$ref":"#/components/schemas/ResponseRefusalDeltaEvent"},{"$ref":"#/components/schemas/ResponseRefusalDoneEvent"},{"$ref":"#/components/schemas/ResponseTextDeltaEvent"},{"$ref":"#/components/schemas/ResponseTextDoneEvent"},{"$ref":"#/components/schemas/ResponseWebSearchCallCompletedEvent"},{"$ref":"#/components/schemas/ResponseWebSearchCallInProgressEvent"},{"$ref":"#/components/schemas/ResponseWebSearchCallSearchingEvent"},{"$ref":"#/components/schemas/ResponseImageGenCallCompletedEvent"},{"$ref":"#/components/schemas/ResponseImageGenCallGeneratingEvent"},{"$ref":"#/components/schemas/ResponseImageGenCallInProgressEvent"},{"$ref":"#/components/schemas/ResponseImageGenCallPartialImageEvent"},{"$ref":"#/components/schemas/ResponseMCPCallArgumentsDeltaEvent"},{"$ref":"#/components/schemas/ResponseMCPCallArgumentsDoneEvent"},{"$ref":"#/components/schemas/ResponseMCPCallCompletedEvent"},{"$ref":"#/components/schemas/ResponseMCPCallFailedEvent"},{"$ref":"#/components/schemas/ResponseMCPCallInProgressEvent"},{"$ref":"#/components/schemas/ResponseMCPListToolsCompletedEvent"},{"$ref":"#/components/schemas/ResponseMCPListToolsFailedEvent"},{"$ref":"#/components/schemas/ResponseMCPListToolsInProgressEvent"},{"$ref":"#/components/schemas/ResponseOutputTextAnnotationAddedEvent"},{"$ref":"#/components/schemas/ResponseQueuedEvent"},{"$ref":"#/components/schemas/ResponseCustomToolCallInputDeltaEvent"},{"$ref":"#/components/schemas/ResponseCustomToolCallInputDoneEvent"}],"discriminator":{"propertyName":"type"}},"ResponseStreamOptions":{"anyOf":[{"description":"Options for streaming responses. Only set this when you set `stream: true`.\n","type":"object","properties":{"include_obfuscation":{"type":"boolean","description":"When true, stream obfuscation will be enabled. Stream obfuscation adds\nrandom characters to an `obfuscation` field on streaming delta events to\nnormalize payload sizes as a mitigation to certain side-channel attacks.\nThese obfuscation fields are included by default, but add a small amount\nof overhead to the data stream. You can set `include_obfuscation` to\nfalse to optimize for bandwidth if you trust the network links between\nyour application and the OpenAI API.\n"}}},{"type":"null"}]},"ResponseTextDeltaEvent":{"type":"object","description":"Emitted when there is an additional text delta.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.output_text.delta`.\n","enum":["response.output_text.delta"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the text delta was added to.\n"},"output_index":{"type":"integer","description":"The index of the output item that the text delta was added to.\n"},"content_index":{"type":"integer","description":"The index of the content part that the text delta was added to.\n"},"delta":{"type":"string","description":"The text delta that was added.\n"},"sequence_number":{"type":"integer","description":"The sequence number for this event."},"logprobs":{"type":"array","description":"The log probabilities of the tokens in the delta.\n","items":{"$ref":"#/components/schemas/ResponseLogProb"}}},"required":["type","item_id","output_index","content_index","delta","sequence_number","logprobs"],"x-oaiMeta":{"name":"response.output_text.delta","group":"responses","example":"{\n \"type\": \"response.output_text.delta\",\n \"item_id\": \"msg_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"delta\": \"In\",\n \"sequence_number\": 1,\n \"logprobs\": []\n}\n"}},"ResponseTextDoneEvent":{"type":"object","description":"Emitted when text content is finalized.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.output_text.done`.\n","enum":["response.output_text.done"],"x-stainless-const":true},"item_id":{"type":"string","description":"The ID of the output item that the text content is finalized.\n"},"output_index":{"type":"integer","description":"The index of the output item that the text content is finalized.\n"},"content_index":{"type":"integer","description":"The index of the content part that the text content is finalized.\n"},"text":{"type":"string","description":"The text content that is finalized.\n"},"sequence_number":{"type":"integer","description":"The sequence number for this event."},"logprobs":{"type":"array","description":"The log probabilities of the tokens in the delta.\n","items":{"$ref":"#/components/schemas/ResponseLogProb"}}},"required":["type","item_id","output_index","content_index","text","sequence_number","logprobs"],"x-oaiMeta":{"name":"response.output_text.done","group":"responses","example":"{\n \"type\": \"response.output_text.done\",\n \"item_id\": \"msg_123\",\n \"output_index\": 0,\n \"content_index\": 0,\n \"text\": \"In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.\",\n \"sequence_number\": 1,\n \"logprobs\": []\n}\n"}},"ResponseTextParam":{"type":"object","description":"Configuration options for a text response from the model. Can be plain\ntext or structured JSON data. Learn more:\n- [Text inputs and outputs](https://developers.openai.com/api/docs/guides/text)\n- [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs)\n","properties":{"format":{"$ref":"#/components/schemas/TextResponseFormatConfiguration"},"verbosity":{"$ref":"#/components/schemas/Verbosity"}}},"ResponseToolUsage":{"properties":{"image_gen":{"$ref":"#/components/schemas/ImageGenToolUsage","description":"Aggregated usage statistics for image generation tool calls."},"web_search":{"$ref":"#/components/schemas/WebSearchUsage","description":"Aggregated billable usage statistics for web search tool calls."}},"type":"object","required":["image_gen","web_search"],"title":"Response tool usage","description":"Aggregated usage details for billable tools that ran while generating the response."},"ResponseUsage":{"type":"object","description":"Represents token usage details including input tokens, output tokens,\na breakdown of output tokens, and the total tokens used.\n","properties":{"input_tokens":{"type":"integer","description":"The number of input tokens."},"input_tokens_details":{"type":"object","description":"A detailed breakdown of the input tokens.","properties":{"cached_tokens":{"type":"integer","description":"The number of tokens that were retrieved from the cache.\n[More on prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching).\n"},"cache_write_tokens":{"type":"integer","description":"The number of input tokens that were written to the cache."}},"required":["cached_tokens","cache_write_tokens"]},"output_tokens":{"type":"integer","description":"The number of output tokens."},"output_tokens_details":{"type":"object","description":"A detailed breakdown of the output tokens.","properties":{"reasoning_tokens":{"type":"integer","description":"The number of reasoning tokens."}},"required":["reasoning_tokens"]},"total_tokens":{"type":"integer","description":"The total number of tokens used."}},"required":["input_tokens","input_tokens_details","output_tokens","output_tokens_details","total_tokens"]},"ResponseWebSearchCallCompletedEvent":{"type":"object","description":"Emitted when a web search call is completed.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.web_search_call.completed`.\n","enum":["response.web_search_call.completed"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that the web search call is associated with.\n"},"item_id":{"type":"string","description":"Unique ID for the output item associated with the web search call.\n"},"sequence_number":{"type":"integer","description":"The sequence number of the web search call being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.web_search_call.completed","group":"responses","example":"{\n \"type\": \"response.web_search_call.completed\",\n \"output_index\": 0,\n \"item_id\": \"ws_123\",\n \"sequence_number\": 0\n}\n"}},"ResponseWebSearchCallInProgressEvent":{"type":"object","description":"Emitted when a web search call is initiated.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.web_search_call.in_progress`.\n","enum":["response.web_search_call.in_progress"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that the web search call is associated with.\n"},"item_id":{"type":"string","description":"Unique ID for the output item associated with the web search call.\n"},"sequence_number":{"type":"integer","description":"The sequence number of the web search call being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.web_search_call.in_progress","group":"responses","example":"{\n \"type\": \"response.web_search_call.in_progress\",\n \"output_index\": 0,\n \"item_id\": \"ws_123\",\n \"sequence_number\": 0\n}\n"}},"ResponseWebSearchCallSearchingEvent":{"type":"object","description":"Emitted when a web search call is executing.","properties":{"type":{"type":"string","description":"The type of the event. Always `response.web_search_call.searching`.\n","enum":["response.web_search_call.searching"],"x-stainless-const":true},"output_index":{"type":"integer","description":"The index of the output item that the web search call is associated with.\n"},"item_id":{"type":"string","description":"Unique ID for the output item associated with the web search call.\n"},"sequence_number":{"type":"integer","description":"The sequence number of the web search call being processed."}},"required":["type","output_index","item_id","sequence_number"],"x-oaiMeta":{"name":"response.web_search_call.searching","group":"responses","example":"{\n \"type\": \"response.web_search_call.searching\",\n \"output_index\": 0,\n \"item_id\": \"ws_123\",\n \"sequence_number\": 0\n}\n"}},"ScreenshotParam":{"properties":{"type":{"type":"string","enum":["screenshot"],"description":"Specifies the event type. For a screenshot action, this property is always set to `screenshot`.","default":"screenshot","x-stainless-const":true}},"type":"object","required":["type"],"title":"Screenshot","description":"A screenshot action."},"ScrollParam":{"properties":{"type":{"type":"string","enum":["scroll"],"description":"Specifies the event type. For a scroll action, this property is always set to `scroll`.","default":"scroll","x-stainless-const":true},"x":{"type":"integer","description":"The x-coordinate where the scroll occurred."},"y":{"type":"integer","description":"The y-coordinate where the scroll occurred."},"scroll_x":{"type":"integer","description":"The horizontal scroll distance."},"scroll_y":{"type":"integer","description":"The vertical scroll distance."},"keys":{"anyOf":[{"items":{"type":"string"},"type":"array","description":"The keys being held while scrolling."},{"type":"null"}]}},"type":"object","required":["type","x","y","scroll_x","scroll_y"],"title":"Scroll","description":"A scroll action."},"SearchContentType":{"type":"string","enum":["text","image"]},"SearchContextSize":{"type":"string","enum":["low","medium","high"]},"ServiceTier":{"anyOf":[{"type":"string","description":"Specifies the processing type used for serving the request.\n - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.\n - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.\n - If set to '[flex](https://developers.openai.com/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.\n - To opt-in to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request.\n - When not set, the default behavior is 'auto'.\n\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.\n","enum":["auto","default","flex","scale","priority","fast"],"default":"auto"},{"type":"null"}]},"ServiceTierResponses":{"anyOf":[{"type":"string","description":"Specifies the processing type used for serving the request.\n - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.\n - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.\n - If set to '[flex](https://developers.openai.com/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.\n - To opt-in to [Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request.\n - If set to 'ultrafast', then the request will be processed with the access-controlled Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a response served through it will show `service_tier=ultrafast`.\n - When not set, the default behavior is 'auto'.\n\n When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.\n","enum":["auto","default","flex","scale","priority","fast","ultrafast"],"default":"auto"},{"type":"null"}]},"ShellCallOutputDelta":{"properties":{"stdout":{"type":"string","description":"The stdout delta that was emitted."},"stderr":{"type":"string","description":"The stderr delta that was emitted."}},"type":"object","required":[],"title":"Shell call output delta","description":"A delta of stdout/stderr emitted while a shell call was running."},"SkillReferenceParam":{"properties":{"type":{"type":"string","enum":["skill_reference"],"description":"References a skill created with the /v1/skills endpoint.","default":"skill_reference","x-stainless-const":true},"skill_id":{"type":"string","maxLength":64,"minLength":1,"description":"The ID of the referenced skill."},"version":{"type":"string","description":"Optional skill version. Use a positive integer or 'latest'. Omit for default."}},"type":"object","required":["type","skill_id"]},"SpecificApplyPatchParam":{"properties":{"type":{"type":"string","enum":["apply_patch"],"description":"The tool to call. Always `apply_patch`.","default":"apply_patch","x-stainless-const":true}},"type":"object","required":["type"],"title":"Specific apply patch tool choice","description":"Forces the model to call the apply_patch tool when executing a tool call."},"SpecificFunctionShellParam":{"properties":{"type":{"type":"string","enum":["shell"],"description":"The tool to call. Always `shell`.","default":"shell","x-stainless-const":true}},"type":"object","required":["type"],"title":"Specific shell tool choice","description":"Forces the model to call the shell tool when a tool call is required."},"SpecificProgrammaticToolCallingParam":{"properties":{"type":{"type":"string","enum":["programmatic_tool_calling"],"description":"The tool to call. Always `programmatic_tool_calling`.","default":"programmatic_tool_calling","x-stainless-const":true}},"type":"object","required":["type"]},"StopConfiguration":{"description":"Not supported with latest reasoning models `o3` and `o4-mini`.\n\nUp to 4 sequences where the API will stop generating further tokens. The\nreturned text will not contain the stop sequence.\n","default":null,"oneOf":[{"type":"string","default":"<|endoftext|>","example":"\n"},{"type":"array","minItems":1,"maxItems":4,"items":{"type":"string","example":"[\"\\n\"]"}},{"type":"null"}]},"SummaryTextContent":{"properties":{"type":{"type":"string","enum":["summary_text"],"description":"The type of the object. Always `summary_text`.","default":"summary_text","x-stainless-const":true},"text":{"type":"string","description":"A summary of the reasoning output from the model so far."}},"type":"object","required":["type","text"],"title":"Summary text","description":"A summary text from the model."},"TextResponseFormatConfiguration":{"description":"An object specifying the format that the model must output.\n\nConfiguring `{ \"type\": \"json_schema\" }` enables Structured Outputs,\nwhich ensures the model will match your supplied JSON schema. Learn more in the\n[Structured Outputs guide](https://developers.openai.com/api/docs/guides/structured-outputs).\n\nThe default format is `{ \"type\": \"text\" }` with no additional options.\n\n**Not recommended for gpt-4o and newer models:**\n\nSetting to `{ \"type\": \"json_object\" }` enables the older JSON mode, which\nensures the message the model generates is valid JSON. Using `json_schema`\nis preferred for models that support it.\n","oneOf":[{"$ref":"#/components/schemas/ResponseFormatText"},{"$ref":"#/components/schemas/TextResponseFormatJsonSchema"},{"$ref":"#/components/schemas/ResponseFormatJsonObject"}]},"TextResponseFormatJsonSchema":{"x-openai-structured-output":"json_schema_default_strict","type":"object","title":"JSON schema","description":"JSON Schema response format. Used to generate structured JSON responses.\nLearn more about [Structured Outputs](https://developers.openai.com/api/docs/guides/structured-outputs).\n","properties":{"type":{"type":"string","description":"The type of response format being defined. Always `json_schema`.","enum":["json_schema"],"x-stainless-const":true},"description":{"type":"string","description":"A description of what the response format is for, used by the model to\ndetermine how to respond in the format.\n"},"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain\nunderscores and dashes, with a maximum length of 64.\n"},"schema":{"$ref":"#/components/schemas/ResponseFormatJsonSchemaSchema"},"strict":{"anyOf":[{"type":"boolean","default":false,"description":"Whether to enable strict schema adherence when generating the output.\nIf set to true, the model will always follow the exact schema defined\nin the `schema` field. Only a subset of JSON Schema is supported when\n`strict` is `true`. To learn more, read the [Structured Outputs\nguide](https://developers.openai.com/api/docs/guides/structured-outputs).\n"},{"type":"null"}]}},"required":["type","schema","name"]},"Tool":{"description":"A tool that can be used to generate a response.\n","discriminator":{"propertyName":"type"},"oneOf":[{"$ref":"#/components/schemas/FunctionTool"},{"$ref":"#/components/schemas/FileSearchTool"},{"$ref":"#/components/schemas/ComputerTool"},{"$ref":"#/components/schemas/ComputerUsePreviewTool"},{"$ref":"#/components/schemas/WebSearchTool"},{"$ref":"#/components/schemas/MCPTool"},{"$ref":"#/components/schemas/CodeInterpreterTool"},{"$ref":"#/components/schemas/ProgrammaticToolCallingParam"},{"$ref":"#/components/schemas/ImageGenTool"},{"$ref":"#/components/schemas/LocalShellToolParam"},{"$ref":"#/components/schemas/FunctionShellToolParam"},{"$ref":"#/components/schemas/CustomToolParam"},{"$ref":"#/components/schemas/NamespaceToolParam"},{"$ref":"#/components/schemas/ToolSearchToolParam"},{"$ref":"#/components/schemas/WebSearchPreviewTool"},{"$ref":"#/components/schemas/ApplyPatchToolParam"}]},"ToolCallCaller":{"oneOf":[{"$ref":"#/components/schemas/DirectToolCallCaller"},{"$ref":"#/components/schemas/ProgramToolCallCaller"}],"description":"The execution context that produced this tool call.","discriminator":{"propertyName":"type"}},"ToolCallCallerParam":{"oneOf":[{"$ref":"#/components/schemas/DirectToolCallCallerParam"},{"$ref":"#/components/schemas/ProgramToolCallCallerParam"}],"description":"The execution context that produced this tool call.","discriminator":{"propertyName":"type"}},"ToolChoiceAllowed":{"type":"object","title":"Allowed tools","description":"Constrains the tools available to the model to a pre-defined set.\n","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"Allowed tool configuration type. Always `allowed_tools`.","x-stainless-const":true},"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n\n`auto` allows the model to pick from among the allowed tools and generate a\nmessage.\n\n`required` requires the model to call one or more of the allowed tools.\n"},"tools":{"type":"array","description":"A list of tool definitions that the model should be allowed to call.\n\nFor the Responses API, the list of tool definitions might look like:\n```json\n[\n { \"type\": \"function\", \"name\": \"get_weather\" },\n { \"type\": \"mcp\", \"server_label\": \"deepwiki\" },\n { \"type\": \"image_generation\" }\n]\n```\n","items":{"type":"object","description":"A tool definition that the model should be allowed to call.\n","additionalProperties":true,"x-oaiExpandable":false}}},"required":["type","mode","tools"]},"ToolChoiceCustom":{"type":"object","title":"Custom tool","description":"Use this option to force the model to call a specific custom tool.\n","properties":{"type":{"type":"string","enum":["custom"],"description":"For custom tool calling, the type is always `custom`.","x-stainless-const":true},"name":{"type":"string","description":"The name of the custom tool to call."}},"required":["type","name"]},"ToolChoiceFunction":{"type":"object","title":"Function tool","description":"Use this option to force the model to call a specific function.\n","properties":{"type":{"type":"string","enum":["function"],"description":"For function calling, the type is always `function`.","x-stainless-const":true},"name":{"type":"string","description":"The name of the function to call."}},"required":["type","name"]},"ToolChoiceMCP":{"type":"object","title":"MCP tool","description":"Use this option to force the model to call a specific tool on a remote MCP server.\n","properties":{"type":{"type":"string","enum":["mcp"],"description":"For MCP tools, the type is always `mcp`.","x-stainless-const":true},"server_label":{"type":"string","description":"The label of the MCP server to use.\n"},"name":{"anyOf":[{"type":"string","description":"The name of the tool to call on the server.\n"},{"type":"null"}]}},"required":["type","server_label"]},"ToolChoiceOptions":{"type":"string","title":"Tool choice mode","description":"Controls which (if any) tool is called by the model.\n\n`none` means the model will not call any tool and instead generates a message.\n\n`auto` means the model can pick between generating a message or calling one or\nmore tools.\n\n`required` means the model must call one or more tools.\n","enum":["none","auto","required"]},"ToolChoiceParam":{"description":"How the model should select which tool (or tools) to use when generating\na response. See the `tools` parameter to see how to specify which tools\nthe model can call.\n","oneOf":[{"$ref":"#/components/schemas/ToolChoiceOptions"},{"$ref":"#/components/schemas/ToolChoiceAllowed"},{"$ref":"#/components/schemas/ToolChoiceTypes"},{"$ref":"#/components/schemas/ToolChoiceFunction"},{"$ref":"#/components/schemas/ToolChoiceMCP"},{"$ref":"#/components/schemas/ToolChoiceCustom"},{"$ref":"#/components/schemas/SpecificProgrammaticToolCallingParam"},{"$ref":"#/components/schemas/SpecificApplyPatchParam"},{"$ref":"#/components/schemas/SpecificFunctionShellParam"}]},"ToolChoiceTypes":{"type":"object","title":"Hosted tool","description":"Indicates that the model should use a built-in tool to generate a response.\n[Learn more about built-in tools](https://developers.openai.com/api/docs/guides/tools).\n","properties":{"type":{"type":"string","description":"The type of hosted tool the model should to use. Learn more about\n[built-in tools](https://developers.openai.com/api/docs/guides/tools).\n\nAllowed values are:\n- `file_search`\n- `web_search_preview`\n- `computer`\n- `computer_use_preview`\n- `computer_use`\n- `code_interpreter`\n- `image_generation`\n","enum":["file_search","web_search_preview","computer","computer_use_preview","computer_use","web_search_preview_2025_03_11","image_generation","code_interpreter"]}},"required":["type"]},"ToolSearchCall":{"properties":{"type":{"type":"string","enum":["tool_search_call"],"description":"The type of the item. Always `tool_search_call`.","default":"tool_search_call","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the tool search call item."},"call_id":{"anyOf":[{"type":"string","description":"The unique ID of the tool search call generated by the model."},{"type":"null"}]},"execution":{"$ref":"#/components/schemas/ToolSearchExecutionType","description":"Whether tool search was executed by the server or by the client."},"arguments":{"description":"Arguments used for the tool search call."},"status":{"$ref":"#/components/schemas/FunctionCallStatus","description":"The status of the tool search call item that was recorded."},"created_by":{"type":"string","description":"The identifier of the actor that created the item."}},"type":"object","required":["type","id","call_id","execution","arguments","status"]},"ToolSearchCallItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of this tool search call.","example":"tsc_123"},{"type":"null"}]},"call_id":{"anyOf":[{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the tool search call generated by the model."},{"type":"null"}]},"type":{"type":"string","enum":["tool_search_call"],"description":"The item type. Always `tool_search_call`.","default":"tool_search_call","x-stainless-const":true},"execution":{"$ref":"#/components/schemas/ToolSearchExecutionType","description":"Whether tool search was executed by the server or by the client."},"arguments":{"$ref":"#/components/schemas/EmptyModelParam","description":"The arguments supplied to the tool search call."},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionCallItemStatus","description":"The status of the tool search call."},{"type":"null"}]}},"type":"object","required":["type","arguments"]},"ToolSearchExecutionType":{"type":"string","enum":["server","client"]},"ToolSearchOutput":{"properties":{"type":{"type":"string","enum":["tool_search_output"],"description":"The type of the item. Always `tool_search_output`.","default":"tool_search_output","x-stainless-const":true},"id":{"type":"string","description":"The unique ID of the tool search output item."},"call_id":{"anyOf":[{"type":"string","description":"The unique ID of the tool search call generated by the model."},{"type":"null"}]},"execution":{"$ref":"#/components/schemas/ToolSearchExecutionType","description":"Whether tool search was executed by the server or by the client."},"tools":{"items":{"$ref":"#/components/schemas/Tool"},"type":"array","description":"The loaded tool definitions returned by tool search."},"status":{"$ref":"#/components/schemas/FunctionCallOutputStatusEnum","description":"The status of the tool search output item that was recorded."},"created_by":{"type":"string","description":"The identifier of the actor that created the item."}},"type":"object","required":["type","id","call_id","execution","tools","status"]},"ToolSearchOutputFunctionToolParam":{"properties":{"name":{"type":"string","maxLength":128,"minLength":1,"pattern":"^(?![\\s\\S]*[\\r\\n])[a-zA-Z0-9_.-]+$","description":"The name of the loaded function tool."},"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"parameters":{"anyOf":[{"$ref":"#/components/schemas/EmptyModelParam"},{"type":"null"}]},"strict":{"anyOf":[{"type":"boolean","description":"Whether to enforce strict parameter validation. If omitted, Responses attempts to use strict validation when the schema is compatible, and falls back to non-strict validation otherwise."},{"type":"null"}]},"type":{"type":"string","enum":["function"],"default":"function","x-stainless-const":true},"async":{"type":"boolean","description":"Whether the tool response can be returned asynchronously versus immediately returned on next response creation."},"output_schema":{"anyOf":[{"additionalProperties":{},"type":"object","description":"A JSON Schema describing the JSON value encoded in string outputs for this function tool. This does not describe content-array outputs.","x-oaiTypeLabel":"map"},{"type":"null"}]},"defer_loading":{"type":"boolean","description":"Whether this function should be deferred and discovered via tool search."},"allowed_callers":{"anyOf":[{"items":{"$ref":"#/components/schemas/CallableToolAllowedCaller"},"type":"array","minItems":1,"description":"The tool invocation context(s)."},{"type":"null"}]}},"type":"object","required":["name","type"],"x-openai-structured-output":"function"},"ToolSearchOutputItemParam":{"properties":{"id":{"anyOf":[{"type":"string","description":"The unique ID of this tool search output.","example":"tso_123"},{"type":"null"}]},"call_id":{"anyOf":[{"type":"string","maxLength":64,"minLength":1,"description":"The unique ID of the tool search call generated by the model."},{"type":"null"}]},"type":{"type":"string","enum":["tool_search_output"],"description":"The item type. Always `tool_search_output`.","default":"tool_search_output","x-stainless-const":true},"execution":{"$ref":"#/components/schemas/ToolSearchExecutionType","description":"Whether tool search was executed by the server or by the client."},"tools":{"items":{"$ref":"#/components/schemas/ToolSearchOutputTool"},"type":"array","description":"The loaded tool definitions returned by the tool search output."},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionCallItemStatus","description":"The status of the tool search output."},{"type":"null"}]}},"type":"object","required":["type","tools"]},"ToolSearchOutputNamespaceToolParam":{"properties":{"type":{"type":"string","enum":["namespace"],"description":"The type of the tool. Always `namespace`.","default":"namespace","x-stainless-const":true},"name":{"type":"string","minLength":1,"description":"The namespace name used in tool calls (for example, `crm`)."},"description":{"type":"string","description":"A description of the namespace shown to the model."},"tools":{"items":{"oneOf":[{"$ref":"#/components/schemas/ToolSearchOutputFunctionToolParam"},{"$ref":"#/components/schemas/CustomToolParam"}],"description":"A function or custom tool loaded into a namespace by tool search.","discriminator":{"propertyName":"type"}},"type":"array","minItems":1,"description":"The function/custom tools loaded inside this namespace."}},"type":"object","required":["type","name","description","tools"],"title":"Namespace","description":"Groups function/custom tools under a shared namespace."},"ToolSearchOutputTool":{"description":"A tool definition returned by a tool search output.\n","discriminator":{"propertyName":"type"},"oneOf":[{"$ref":"#/components/schemas/FunctionTool"},{"$ref":"#/components/schemas/FileSearchTool"},{"$ref":"#/components/schemas/ComputerTool"},{"$ref":"#/components/schemas/ComputerUsePreviewTool"},{"$ref":"#/components/schemas/WebSearchTool"},{"$ref":"#/components/schemas/MCPTool"},{"$ref":"#/components/schemas/CodeInterpreterTool"},{"$ref":"#/components/schemas/ProgrammaticToolCallingParam"},{"$ref":"#/components/schemas/ImageGenTool"},{"$ref":"#/components/schemas/LocalShellToolParam"},{"$ref":"#/components/schemas/FunctionShellToolParam"},{"$ref":"#/components/schemas/CustomToolParam"},{"$ref":"#/components/schemas/ToolSearchOutputNamespaceToolParam"},{"$ref":"#/components/schemas/ToolSearchToolParam"},{"$ref":"#/components/schemas/WebSearchPreviewTool"},{"$ref":"#/components/schemas/ApplyPatchToolParam"}]},"ToolSearchToolParam":{"properties":{"type":{"type":"string","enum":["tool_search"],"description":"The type of the tool. Always `tool_search`.","default":"tool_search","x-stainless-const":true},"execution":{"$ref":"#/components/schemas/ToolSearchExecutionType","description":"Whether tool search is executed by the server or by the client."},"description":{"anyOf":[{"type":"string","description":"Description shown to the model for a client-executed tool search tool."},{"type":"null"}]},"parameters":{"anyOf":[{"$ref":"#/components/schemas/EmptyModelParam","description":"Parameter schema for a client-executed tool search tool."},{"type":"null"}]}},"type":"object","required":["type"],"title":"Tool search tool","description":"Hosted or BYOT tool search configuration for deferred tools."},"ToolsArray":{"type":"array","description":"An array of tools the model may call while generating a response. You\ncan specify which tool to use by setting the `tool_choice` parameter.\n\nWe support the following categories of tools:\n- **Built-in tools**: Tools that are provided by OpenAI that extend the\n model's capabilities, like [web search](https://developers.openai.com/api/docs/guides/tools-web-search)\n or [file search](https://developers.openai.com/api/docs/guides/tools-file-search). Learn more about\n [built-in tools](https://developers.openai.com/api/docs/guides/tools).\n- **MCP Tools**: Integrations with third-party systems via custom MCP servers\n or predefined connectors such as Google Drive and SharePoint. Learn more about\n [MCP Tools](https://developers.openai.com/api/docs/guides/tools-connectors-mcp).\n- **Function calls (custom tools)**: Functions that are defined by you,\n enabling the model to call your own code with strongly typed arguments\n and outputs. Learn more about\n [function calling](https://developers.openai.com/api/docs/guides/function-calling). You can also use\n custom tools to call your own code.\n","items":{"$ref":"#/components/schemas/Tool"}},"TopLogProb":{"properties":{"token":{"type":"string"},"logprob":{"type":"number"},"bytes":{"items":{"type":"integer"},"type":"array"}},"type":"object","required":["token","logprob","bytes"],"title":"Top log probability","description":"The top log probability of a token."},"TypeParam":{"properties":{"type":{"type":"string","enum":["type"],"description":"Specifies the event type. For a type action, this property is always set to `type`.","default":"type","x-stainless-const":true},"text":{"type":"string","description":"The text to type."}},"type":"object","required":["type","text"],"title":"Type","description":"An action to type in text."},"UrlCitationBody":{"properties":{"type":{"type":"string","enum":["url_citation"],"description":"The type of the URL citation. Always `url_citation`.","default":"url_citation","x-stainless-const":true},"url":{"type":"string","format":"uri","description":"The URL of the web resource."},"start_index":{"type":"integer","description":"The index of the first character of the URL citation in the message."},"end_index":{"type":"integer","description":"The index of the last character of the URL citation in the message."},"title":{"type":"string","description":"The title of the web resource."}},"type":"object","required":["type","url","start_index","end_index","title"],"title":"URL citation","description":"A citation for a web resource used to generate a model response."},"VectorStoreFileAttributes":{"anyOf":[{"type":"object","description":"Set of 16 key-value pairs that can be attached to an object. This can be\nuseful for storing additional information about the object in a structured\nformat, and querying for objects via API or the dashboard. Keys are strings\nwith a maximum length of 64 characters. Values are strings with a maximum\nlength of 512 characters, booleans, or numbers.\n","maxProperties":16,"propertyNames":{"type":"string","maxLength":64},"additionalProperties":{"oneOf":[{"type":"string","maxLength":512},{"type":"number"},{"type":"boolean"}]},"x-oaiTypeLabel":"map"},{"type":"null"}]},"Verbosity":{"anyOf":[{"type":"string","enum":["low","medium","high"],"default":"medium","description":"Constrains the verbosity of the model's response. Lower values will result in\nmore concise responses, while higher values will result in more verbose responses.\nCurrently supported values are `low`, `medium`, and `high`. The default is\n`medium`.\n"},{"type":"null"}]},"VoiceIdsOrCustomVoice":{"title":"Voice","description":"A built-in voice name or a custom voice reference.\n","anyOf":[{"$ref":"#/components/schemas/VoiceIdsShared"},{"type":"object","description":"Custom voice reference.","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","description":"The custom voice ID, e.g. `voice_1234`.","example":"voice_1234"}}}]},"VoiceIdsShared":{"example":"ash","anyOf":[{"type":"string"},{"type":"string","enum":["alloy","ash","ballad","coral","echo","sage","shimmer","verse","marin","cedar"]}]},"WaitParam":{"properties":{"type":{"type":"string","enum":["wait"],"description":"Specifies the event type. For a wait action, this property is always set to `wait`.","default":"wait","x-stainless-const":true}},"type":"object","required":["type"],"title":"Wait","description":"A wait action."},"WebSearchActionFind":{"type":"object","title":"Find action","description":"Action type \"find_in_page\": Searches for a pattern within a loaded page.\n","properties":{"type":{"type":"string","enum":["find_in_page"],"description":"The action type.\n","x-stainless-const":true},"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}],"description":"The URL of the page searched for the pattern, when available.\n"},"pattern":{"type":"string","description":"The pattern or text to search for within the page.\n"}},"required":["type","pattern"]},"WebSearchActionOpenPage":{"type":"object","title":"Open page action","description":"Action type \"open_page\" - Opens a specific URL from search results.\n","properties":{"type":{"type":"string","enum":["open_page"],"description":"The action type.\n","x-stainless-const":true},"url":{"description":"The URL opened by the model.\n","anyOf":[{"type":"string","format":"uri"},{"type":"null"}]}},"required":["type"]},"WebSearchActionSearch":{"type":"object","title":"Search action","description":"Action type \"search\" - Performs a web search query.\n","properties":{"type":{"type":"string","enum":["search"],"description":"The action type.\n","x-stainless-const":true},"query":{"type":"string","deprecated":true,"description":"The search query.\n"},"queries":{"type":"array","title":"Search queries","description":"The search queries.\n","items":{"type":"string","description":"A search query.\n"}},"sources":{"type":"array","title":"Web search sources","description":"The sources used in the search.\n","items":{"type":"object","title":"Web search source","description":"A source used in the search.\n","properties":{"type":{"type":"string","enum":["url"],"description":"The type of source. Always `url`.\n","x-stainless-const":true},"url":{"type":"string","format":"uri","description":"The URL of the source.\n"}},"required":["type","url"]}}},"required":["type"]},"WebSearchApproximateLocation":{"anyOf":[{"type":"object","title":"Web search approximate location","description":"The approximate location of the user.\n","properties":{"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always `approximate`.","default":"approximate","x-stainless-const":true},"country":{"anyOf":[{"type":"string","description":"The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`."},{"type":"null"}]},"region":{"anyOf":[{"type":"string","description":"Free text input for the region of the user, e.g. `California`."},{"type":"null"}]},"city":{"anyOf":[{"type":"string","description":"Free text input for the city of the user, e.g. `San Francisco`."},{"type":"null"}]},"timezone":{"anyOf":[{"type":"string","description":"The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`."},{"type":"null"}]}}},{"type":"null"}]},"WebSearchCallStatus":{"type":"string","enum":["in_progress","searching","completed","failed","incomplete"]},"WebSearchContextSize":{"type":"string","description":"High level guidance for the amount of context window space to use for the \nsearch. One of `low`, `medium`, or `high`. `medium` is the default.\n","enum":["low","medium","high"],"default":"medium"},"WebSearchLocation":{"type":"object","title":"Web search location","description":"Approximate location parameters for the search.","properties":{"country":{"type":"string","description":"The two-letter \n[ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,\ne.g. `US`.\n"},"region":{"type":"string","description":"Free text input for the region of the user, e.g. `California`.\n"},"city":{"type":"string","description":"Free text input for the city of the user, e.g. `San Francisco`.\n"},"timezone":{"type":"string","description":"The [IANA timezone](https://timeapi.io/documentation/iana-timezones) \nof the user, e.g. `America/Los_Angeles`.\n"}}},"WebSearchPreviewTool":{"properties":{"type":{"type":"string","enum":["web_search_preview","web_search_preview_2025_03_11"],"description":"The type of the web search tool. One of `web_search_preview` or `web_search_preview_2025_03_11`.","default":"web_search_preview","x-stainless-const":true},"user_location":{"anyOf":[{"$ref":"#/components/schemas/ApproximateLocation","description":"The approximate location of the user. If omitted or null, defaults to the United States. To avoid this fallback, pass `{\"type\": \"approximate\"}` without location fields. To localize results, provide the relevant location fields."},{"type":"null"}]},"search_context_size":{"$ref":"#/components/schemas/SearchContextSize","description":"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_content_types":{"items":{"$ref":"#/components/schemas/SearchContentType"},"type":"array"}},"type":"object","required":["type"],"title":"Web search preview","description":"This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://developers.openai.com/api/docs/guides/tools-web-search)."},"WebSearchTool":{"type":"object","title":"Web search","description":"Search the Internet for sources related to the prompt. Learn more about the\n[web search tool](https://developers.openai.com/api/docs/guides/tools-web-search).\n","properties":{"type":{"type":"string","enum":["web_search","web_search_2025_08_26"],"description":"The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.","default":"web_search"},"external_web_access":{"type":"boolean","default":true,"description":"Allow live internet access for web search. Defaults to true when omitted. When false, the web search tool runs in offline/cache-only mode and will not fetch new external content."},"filters":{"anyOf":[{"type":"object","description":"Filters for the search.\n","properties":{"allowed_domains":{"anyOf":[{"type":"array","title":"Allowed domains for the search.","description":"Allowed domains for the search. If not provided, all domains are allowed.\nSubdomains of the provided domains are allowed as well.\n\nExample: `[\"pubmed.ncbi.nlm.nih.gov\"]`\n","items":{"type":"string","description":"Allowed domain for the search."},"default":[]},{"type":"null"}]}}},{"type":"null"}]},"user_location":{"$ref":"#/components/schemas/WebSearchApproximateLocation","description":"The approximate location of the user. If omitted or null, defaults to the\nUnited States. To avoid this fallback, pass `{\"type\": \"approximate\"}` without\nlocation fields. To localize results, provide the relevant location fields.\n"},"search_context_size":{"type":"string","enum":["low","medium","high"],"default":"medium","description":"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."}},"required":["type"]},"WebSearchToolCall":{"type":"object","title":"Web search tool call","description":"The results of a web search tool call. See the\n[web search guide](https://developers.openai.com/api/docs/guides/tools-web-search) for more information.\n","properties":{"id":{"type":"string","description":"The unique ID of the web search tool call.\n"},"type":{"type":"string","enum":["web_search_call"],"description":"The type of the web search tool call. Always `web_search_call`.\n","x-stainless-const":true},"status":{"description":"The status of the web search tool call.\n","$ref":"#/components/schemas/WebSearchCallStatus"},"action":{"type":"object","description":"An object describing the specific action taken in this web search call.\nIncludes details on how the model used the web (search, open_page, find_in_page).\n","oneOf":[{"$ref":"#/components/schemas/WebSearchActionSearch"},{"$ref":"#/components/schemas/WebSearchActionOpenPage"},{"$ref":"#/components/schemas/WebSearchActionFind"}],"discriminator":{"propertyName":"type"}}},"required":["id","type","status"]},"WebSearchUsage":{"properties":{"num_requests":{"type":"integer","description":"The number of billable web search requests issued."}},"type":"object","required":["num_requests"],"title":"Web search usage","description":"Usage details for web search requests that ran while generating the response."},"_MisalignmentErrorType":{"anyOf":[{"type":"string"},{"type":"string","enum":["potentially_unintended_data_transfer","potentially_unintended_data_access","potentially_unintended_destructive_activity","other"]}]},"_MisalignmentSteer":{"properties":{"message":{"type":"string","description":"The public continuation instruction."}},"type":"object","required":["message"]}}}} diff --git a/hives/openai-server/spec/openresponses.json b/hives/openai-server/spec/openresponses.json new file mode 100644 index 00000000..e46cadb1 --- /dev/null +++ b/hives/openai-server/spec/openresponses.json @@ -0,0 +1 @@ +{"openapi":"3.1.0","info":{"title":"Open Responses","version":"2026-04-24"},"tags":[],"paths":{"/responses":{"post":{"operationId":"createResponse","summary":"Create response","description":"Creates a response.","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseResource"}},"text/event-stream":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ResponseCreatedStreamingEvent"},{"$ref":"#/components/schemas/ResponseQueuedStreamingEvent"},{"$ref":"#/components/schemas/ResponseInProgressStreamingEvent"},{"$ref":"#/components/schemas/ResponseCompletedStreamingEvent"},{"$ref":"#/components/schemas/ResponseFailedStreamingEvent"},{"$ref":"#/components/schemas/ResponseIncompleteStreamingEvent"},{"$ref":"#/components/schemas/ResponseOutputItemAddedStreamingEvent"},{"$ref":"#/components/schemas/ResponseOutputItemDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryPartAddedStreamingEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryPartDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseContentPartAddedStreamingEvent"},{"$ref":"#/components/schemas/ResponseContentPartDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseOutputTextDeltaStreamingEvent"},{"$ref":"#/components/schemas/ResponseOutputTextDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseRefusalDeltaStreamingEvent"},{"$ref":"#/components/schemas/ResponseRefusalDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseReasoningDeltaStreamingEvent"},{"$ref":"#/components/schemas/ResponseReasoningDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryDeltaStreamingEvent"},{"$ref":"#/components/schemas/ResponseReasoningSummaryDoneStreamingEvent"},{"$ref":"#/components/schemas/ResponseOutputTextAnnotationAddedStreamingEvent"},{"$ref":"#/components/schemas/ResponseFunctionCallArgumentsDeltaStreamingEvent"},{"$ref":"#/components/schemas/ResponseFunctionCallArgumentsDoneStreamingEvent"},{"$ref":"#/components/schemas/ErrorStreamingEvent"}],"discriminator":{"propertyName":"type"}}}}}},"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateResponseBody"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/CreateResponseBody"}}}}},"x-openresponses-websocket":{"description":"Open a WebSocket connection to `/v1/responses`. Send client events using the WebSocketResponseCreateEvent schema. Server progress messages use the same streaming event schemas as `text/event-stream` responses. WebSocket failures use the WebSocketErrorEvent schema.","clientMessage":{"$ref":"#/components/schemas/WebSocketResponseCreateEvent"},"errorMessage":{"$ref":"#/components/schemas/WebSocketErrorEvent"},"x-openresponses-added-in":"2026-04-24"}},"/responses/compact":{"post":{"operationId":"compactResponse","summary":"Compact a response","description":"Compact a conversation. Returns a compacted response object.","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompactResource"}}}}},"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompactResponseMethodPublicBody"}}}},"x-openresponses-added-in":"2026-04-24"}}},"components":{"schemas":{"IncompleteDetails":{"type":"object","required":["reason"],"properties":{"reason":{"type":"string","description":"The reason the response could not be completed."}},"description":"Details about why the response was incomplete.","title":"Incomplete details"},"MessageStatus":{"type":"string","enum":["in_progress","completed","incomplete"],"x-enumDescriptions":{"completed":"Model has finished sampling this item.","in_progress":"Model is currently sampling this item.","incomplete":"Model was interrupted from sampling this item partway through. This can occur, for example, if the model encounters a stop token or exhausts its output_token budget."}},"MessageRole":{"type":"string","enum":["user","assistant","system","developer"],"x-enumDescriptions":{"assistant":"Model-generated content in the conversation.","developer":"Developer-supplied guidance that shapes the assistant’s behavior.","system":"System-level instructions that set global behavior.","user":"End‑user input in the conversation."}},"InputTextContent":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["input_text"],"description":"The type of the input item. Always `input_text`.","default":"input_text"},"text":{"type":"string","description":"The text input to the model."}},"description":"A text input to the model.","title":"Input text"},"UrlCitationBody":{"type":"object","required":["type","url","start_index","end_index","title"],"properties":{"type":{"type":"string","enum":["url_citation"],"description":"The type of the URL citation. Always `url_citation`.","default":"url_citation"},"url":{"type":"string","description":"The URL of the web resource."},"start_index":{"type":"integer","description":"The index of the first character of the URL citation in the message."},"end_index":{"type":"integer","description":"The index of the last character of the URL citation in the message."},"title":{"type":"string","description":"The title of the web resource."}},"description":"A citation for a web resource used to generate a model response.","title":"URL citation"},"Annotation":{"$ref":"#/components/schemas/UrlCitationBody","description":"An annotation that applies to a span of output text.","discriminator":{"propertyName":"type"}},"TopLogProb":{"type":"object","required":["token","logprob","bytes"],"properties":{"token":{"type":"string"},"logprob":{"type":"number"},"bytes":{"type":"array","items":{"type":"integer"}}},"description":"The top log probability of a token.","title":"Top log probability"},"LogProb":{"type":"object","required":["token","logprob","bytes","top_logprobs"],"properties":{"token":{"type":"string"},"logprob":{"type":"number"},"bytes":{"type":"array","items":{"type":"integer"}},"top_logprobs":{"type":"array","items":{"$ref":"#/components/schemas/TopLogProb"}}},"description":"The log probability of a token.","title":"Log probability"},"OutputTextContent":{"type":"object","required":["type","text","annotations"],"properties":{"type":{"type":"string","enum":["output_text"],"description":"The type of the output text. Always `output_text`.","default":"output_text"},"text":{"type":"string","description":"The text output from the model."},"annotations":{"type":"array","items":{"$ref":"#/components/schemas/Annotation"},"description":"The annotations of the text output."},"logprobs":{"type":"array","items":{"$ref":"#/components/schemas/LogProb"}}},"description":"A text output from the model.","title":"Output text"},"TextContent":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["text"],"default":"text"},"text":{"type":"string"}},"description":"A text content.","title":"Text Content"},"SummaryTextContent":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["summary_text"],"description":"The type of the object. Always `summary_text`.","default":"summary_text"},"text":{"type":"string","description":"A summary of the reasoning output from the model so far."}},"description":"A summary text from the model.","title":"Summary text"},"ReasoningTextContent":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["reasoning_text"],"description":"The type of the reasoning text. Always `reasoning_text`.","default":"reasoning_text"},"text":{"type":"string","description":"The reasoning text from the model."}},"description":"Reasoning text from the model.","title":"Reasoning text"},"RefusalContent":{"type":"object","required":["type","refusal"],"properties":{"type":{"type":"string","enum":["refusal"],"description":"The type of the refusal. Always `refusal`.","default":"refusal"},"refusal":{"type":"string","description":"The refusal explanation from the model."}},"description":"A refusal from the model.","title":"Refusal"},"ImageDetail":{"type":"string","enum":["low","high","auto"],"x-enumDescriptions":{"auto":"Choose the detail level automatically.","high":"Allows the model to \"see\" a higher-resolution version of the image, usually increasing input token costs.","low":"Restricts the model to a lower-resolution version of the image."}},"InputImageContent":{"type":"object","required":["type","image_url","detail"],"properties":{"type":{"type":"string","enum":["input_image"],"description":"The type of the input item. Always `input_image`.","default":"input_image"},"image_url":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The URL of the image to be sent to the model. A fully qualified URL or base64\nencoded image in a data URL."},"detail":{"$ref":"#/components/schemas/ImageDetail","description":"The detail level of the image to be sent to the model. One of `high`, `low`, or\n`auto`. Defaults to `auto`."}},"description":"An image input to the model. Learn about [image inputs](/docs/guides/vision).","title":"Input image"},"InputFileContent":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["input_file"],"description":"The type of the input item. Always `input_file`.","default":"input_file"},"filename":{"type":"string","description":"The name of the file to be sent to the model."},"file_url":{"type":"string","description":"The URL of the file to be sent to the model."}},"description":"A file input to the model.","title":"Input file"},"InputVideoContent":{"type":"object","required":["type","video_url"],"properties":{"type":{"type":"string","enum":["input_video"],"description":"The type of the input content. Always `input_video`."},"video_url":{"type":"string","description":"A base64 or remote url that resolves to a video file."}},"description":"A content block representing a video input to the model."},"Message":{"type":"object","required":["type","id","status","role","content"],"properties":{"type":{"type":"string","enum":["message"],"description":"The type of the message. Always set to `message`.","default":"message"},"id":{"type":"string","description":"The unique ID of the message."},"status":{"$ref":"#/components/schemas/MessageStatus","description":"The status of item. One of `in_progress`, `completed`, or `incomplete`. Populated\nwhen items are returned via API."},"role":{"$ref":"#/components/schemas/MessageRole","description":"The role of the message. One of `unknown`, `user`, `assistant`, `system`, `critic`,\n`discriminator`, `developer`, or `tool`."},"content":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"},{"$ref":"#/components/schemas/InputVideoContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}},"description":"The content of the message"},"phase":{"type":"string","enum":["commentary","final_answer"],"description":"Labels an `assistant` message as intermediate commentary (`commentary`) or the\nfinal answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when\nsending follow-up requests, preserve and resend phase on all assistant messages.\nOmitting it can degrade performance. Not used for user messages.","x-openresponses-added-in":"2026-04-24"}},"description":"A message to or from the model.","title":"Message"},"FunctionCallStatus":{"type":"string","enum":["in_progress","completed","incomplete"],"x-enumDescriptions":{"completed":"Model has finished sampling this item.","in_progress":"Model is currently sampling this item.","incomplete":"Model was interrupted from sampling this item partway through. This can occur, for example, if the model encounters a stop token or exhausts its output_token budget."}},"FunctionCall":{"type":"object","required":["type","id","call_id","name","arguments","status"],"properties":{"type":{"type":"string","enum":["function_call"],"description":"The type of the item. Always `function_call`.","default":"function_call"},"id":{"type":"string","description":"The unique ID of the function call item."},"call_id":{"type":"string","description":"The unique ID of the function tool call that was generated."},"name":{"type":"string","description":"The name of the function that was called."},"arguments":{"type":"string","description":"The arguments JSON string that was generated."},"status":{"$ref":"#/components/schemas/FunctionCallStatus","description":"The status of the function call item that was recorded."}},"description":"A function tool call that was generated by the model.","title":"Function call"},"FunctionCallOutputStatusEnum":{"type":"string","enum":["in_progress","completed","incomplete"],"description":"Similar to `FunctionCallStatus`. All three options are allowed here for\ncompatibility, but because in practice these items will be provided by developers,\nonly `completed` should be used."},"FunctionCallOutput":{"type":"object","required":["type","id","call_id","output","status"],"properties":{"type":{"type":"string","enum":["function_call_output"],"description":"The type of the function tool call output. Always `function_call_output`.","default":"function_call_output"},"id":{"type":"string","description":"The unique ID of the function tool call output. Populated when this item is\nreturned via API."},"call_id":{"type":"string","description":"The unique ID of the function tool call generated by the model."},"output":{"oneOf":[{"type":"string"},{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}}}],"description":"The function tool call output, as a JSON string or an array of text, image,\nor file content."},"status":{"$ref":"#/components/schemas/FunctionCallOutputStatusEnum","description":"The status of the item. One of `in_progress`, `completed`, or `incomplete`.\nPopulated when items are returned via API."}},"description":"A function tool call output that was returned by the tool.","title":"Function call output"},"ReasoningBody":{"type":"object","required":["type","id","summary"],"properties":{"type":{"type":"string","enum":["reasoning"],"description":"The type of the item. Always `reasoning`.","default":"reasoning"},"id":{"type":"string","description":"The unique ID of the reasoning item."},"content":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}},"description":"The reasoning content that was generated."},"summary":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}},"description":"The reasoning summary content that was generated."},"encrypted_content":{"type":"string","description":"The encrypted reasoning content that was generated."}},"description":"A reasoning item that was generated by the model.","title":"Reasoning item"},"CompactionBody":{"type":"object","required":["type","id","encrypted_content"],"properties":{"type":{"type":"string","enum":["compaction"],"description":"The type of the item. Always `compaction`.","default":"compaction"},"id":{"type":"string","description":"The unique ID of the compaction item."},"encrypted_content":{"type":"string","description":"The encrypted content that was produced by compaction."},"created_by":{"type":"string","description":"The identifier of the actor that created the item."}},"description":"A compaction item generated by the [`v1/responses/compact`\nAPI](/docs/api-reference/responses/compact).","title":"Compaction item","x-openresponses-added-in":"2026-04-24"},"ItemField":{"oneOf":[{"$ref":"#/components/schemas/Message"},{"$ref":"#/components/schemas/FunctionCall"},{"$ref":"#/components/schemas/FunctionCallOutput"},{"$ref":"#/components/schemas/ReasoningBody"},{"$ref":"#/components/schemas/CompactionBody"}],"description":"An item representing a message, tool call, tool output, reasoning, or other response\nelement.","discriminator":{"propertyName":"type"}},"Error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"A machine-readable error code that was returned."},"message":{"type":"string","description":"A human-readable description of the error that was returned."}},"description":"An error that occurred while generating the response.","title":"Error"},"FunctionTool":{"type":"object","required":["type","name","description","parameters","strict"],"properties":{"type":{"type":"string","enum":["function"],"description":"The type of the function tool. Always `function`.","default":"function"},"name":{"type":"string","description":"The name of the function to call."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"A description of the function. Used by the model to determine whether or not to\ncall the function."},"parameters":{"anyOf":[{"type":"object","additionalProperties":{}},{"type":"null"}],"description":"A JSON schema object describing the parameters of the function."},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Whether to enforce strict parameter validation. Default `true`."}},"description":"Defines a function in your own code the model can choose to call. Learn more about\n[function calling](https://platform.openai.com/docs/guides/function-calling).","title":"Function"},"Tool":{"$ref":"#/components/schemas/FunctionTool","description":"A tool that can be used to generate a response.","discriminator":{"propertyName":"type"}},"FunctionToolChoice":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["function"],"default":"function"},"name":{"type":"string"}}},"ToolChoiceValueEnum":{"type":"string","enum":["none","auto","required"],"x-enumDescriptions":{"auto":"Let the model choose the tools from among the provided set.","none":"Restrict the model from calling any tools.","required":"Require the model to call a tool."}},"AllowedToolChoice":{"type":"object","required":["type","tools","mode"],"properties":{"type":{"type":"string","enum":["allowed_tools"],"default":"allowed_tools"},"tools":{"type":"array","items":{"$ref":"#/components/schemas/FunctionToolChoice"}},"mode":{"$ref":"#/components/schemas/ToolChoiceValueEnum"}}},"TruncationEnum":{"type":"string","enum":["auto","disabled"],"x-enumDescriptions":{"auto":"Let the service decide how to truncate.","disabled":"Disable service truncation. Context over the model's context limit will result in a 400 error."}},"TextResponseFormat":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"],"default":"text"}}},"JsonObjectResponseFormat":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["json_object"],"default":"json_object"}}},"JsonSchemaResponseFormat":{"type":"object","required":["type","name","description","schema","strict"],"properties":{"type":{"type":"string","enum":["json_schema"],"default":"json_schema"},"name":{"type":"string"},"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"schema":{"type":"null"},"strict":{"type":"boolean"}}},"VerbosityEnum":{"type":"string","enum":["low","medium","high"],"x-enumDescriptions":{"high":"Instruct the model to emit more verbose final responses.","low":"Instruct the model to emit less verbose final responses.","medium":"Use the model's default verbosity setting."}},"TextField":{"type":"object","required":["format"],"properties":{"format":{"oneOf":[{"$ref":"#/components/schemas/TextResponseFormat"},{"$ref":"#/components/schemas/JsonObjectResponseFormat"},{"$ref":"#/components/schemas/JsonSchemaResponseFormat"}]},"verbosity":{"$ref":"#/components/schemas/VerbosityEnum"}}},"ReasoningEffortEnum":{"type":"string","enum":["none","low","medium","high","xhigh"],"x-enumDescriptions":{"high":"Use a higher reasoning effort to improve answer quality.","medium":"Use a balanced reasoning effort.","low":"Use a lower reasoning effort for faster responses.","minimal":"Use the lowest non-zero reasoning effort.","none":"Restrict the model from performing any reasoning before emitting a final answer.","xhigh":"Use the maximum reasoning effort available."}},"ReasoningSummaryEnum":{"type":"string","enum":["concise","detailed","auto"],"x-enumDescriptions":{"auto":"Allow the model to decide when to summarize.","concise":"Emit concise summaries of reasoning content.","detailed":"Emit details summaries of reasoning content."}},"Reasoning":{"type":"object","required":["effort","summary"],"properties":{"effort":{"anyOf":[{"$ref":"#/components/schemas/ReasoningEffortEnum"},{"type":"null"}],"description":"The reasoning effort that was requested for the model, if specified."},"summary":{"anyOf":[{"$ref":"#/components/schemas/ReasoningSummaryEnum"},{"type":"null"}],"description":"A model-generated summary of its reasoning that was produced, if available."}},"description":"Reasoning configuration and metadata that were used for the response.","title":"Reasoning"},"InputTokensDetails":{"type":"object","required":["cached_tokens"],"properties":{"cached_tokens":{"type":"integer","description":"The number of input tokens that were served from cache."}},"description":"A breakdown of input token usage that was recorded.","title":"Input tokens details"},"OutputTokensDetails":{"type":"object","required":["reasoning_tokens"],"properties":{"reasoning_tokens":{"type":"integer","description":"The number of output tokens that were attributed to reasoning."}},"description":"A breakdown of output token usage that was recorded.","title":"Output tokens details"},"Usage":{"type":"object","required":["input_tokens","output_tokens","total_tokens","input_tokens_details","output_tokens_details"],"properties":{"input_tokens":{"type":"integer","description":"The number of input tokens that were used to generate the response."},"output_tokens":{"type":"integer","description":"The number of output tokens that were generated by the model."},"total_tokens":{"type":"integer","description":"The total number of tokens that were used."},"input_tokens_details":{"$ref":"#/components/schemas/InputTokensDetails","description":"A breakdown of input token usage that was recorded."},"output_tokens_details":{"$ref":"#/components/schemas/OutputTokensDetails","description":"A breakdown of output token usage that was recorded."}},"description":"Token usage statistics that were recorded for the response.","title":"Usage"},"ResponseResource":{"type":"object","required":["id","object","created_at","completed_at","status","incomplete_details","model","previous_response_id","instructions","output","error","tools","tool_choice","truncation","parallel_tool_calls","text","top_p","presence_penalty","frequency_penalty","top_logprobs","temperature","reasoning","usage","max_output_tokens","max_tool_calls","store","background","service_tier","metadata","safety_identifier","prompt_cache_key"],"properties":{"id":{"type":"string","description":"The unique ID of the response that was created."},"object":{"type":"string","enum":["response"],"description":"The object type, which was always `response`.","default":"response"},"created_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the response was created."},"completed_at":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"The Unix timestamp (in seconds) for when the response was completed, if it was\ncompleted."},"status":{"type":"string","description":"The status that was set for the response."},"incomplete_details":{"anyOf":[{"$ref":"#/components/schemas/IncompleteDetails"},{"type":"null"}],"description":"Details about why the response was incomplete, if applicable."},"model":{"type":"string","description":"The model that generated this response."},"previous_response_id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The ID of the previous response in the chain that was referenced, if any."},"instructions":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Additional instructions that were used to guide the model for this response."},"output":{"type":"array","items":{"$ref":"#/components/schemas/ItemField"},"description":"The output items that were generated by the model."},"error":{"anyOf":[{"$ref":"#/components/schemas/Error"},{"type":"null"}],"description":"The error that occurred, if the response failed."},"tools":{"type":"array","items":{"$ref":"#/components/schemas/Tool"},"description":"The tools that were available to the model during response generation."},"tool_choice":{"oneOf":[{"$ref":"#/components/schemas/FunctionToolChoice"},{"$ref":"#/components/schemas/ToolChoiceValueEnum"},{"$ref":"#/components/schemas/AllowedToolChoice"}]},"truncation":{"$ref":"#/components/schemas/TruncationEnum","description":"How the input was truncated by the service when it exceeded the model context\nwindow."},"parallel_tool_calls":{"type":"boolean","description":"Whether the model was allowed to call multiple tools in parallel."},"text":{"$ref":"#/components/schemas/TextField","description":"Configuration options for text output that were used."},"top_p":{"type":"number","description":"The nucleus sampling parameter that was used for this response."},"presence_penalty":{"type":"number","description":"The presence penalty that was used to penalize new tokens based on whether they\nappear in the text so far."},"frequency_penalty":{"type":"number","description":"The frequency penalty that was used to penalize new tokens based on their frequency\nin the text so far."},"top_logprobs":{"type":"integer","description":"The number of most likely tokens that were returned at each position, along with\ntheir log probabilities."},"temperature":{"type":"number","description":"The sampling temperature that was used for this response."},"reasoning":{"anyOf":[{"$ref":"#/components/schemas/Reasoning"},{"type":"null"}],"description":"Reasoning configuration and outputs that were produced for this response."},"usage":{"anyOf":[{"$ref":"#/components/schemas/Usage"},{"type":"null"}],"description":"Token usage statistics that were recorded for the response, if available."},"max_output_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"The maximum number of tokens the model was allowed to generate for this response."},"max_tool_calls":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"The maximum number of tool calls the model was allowed to make while generating the\nresponse."},"store":{"type":"boolean","description":"Whether this response was stored so it can be retrieved later."},"background":{"type":"boolean","description":"Whether this request was run in the background."},"service_tier":{"type":"string","description":"The service tier that was used for this response."},"metadata":{"description":"Developer-defined metadata that was associated with the response."},"safety_identifier":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"A stable identifier that was used for safety monitoring and abuse detection."},"prompt_cache_key":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"A key that was used to read from or write to the prompt cache."}},"description":"The complete response object that was returned by the Responses API.","title":"The response object","example":{"id":"resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41","object":"response","created_at":1741476777,"status":"completed","completed_at":1741476778,"model":"gpt-4o-2024-08-06","output":[{"type":"message","id":"msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41","status":"completed","role":"assistant","content":[{"type":"output_text","text":"The image depicts a scenic landscape with a wooden boardwalk or pathway leading through lush, green grass under a blue sky with some clouds. The setting suggests a peaceful natural area, possibly a park or nature reserve. There are trees and shrubs in the background.","annotations":[]}]}],"parallel_tool_calls":true,"reasoning":{},"store":true,"background":false,"temperature":1,"presence_penalty":0,"frequency_penalty":0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1,"truncation":"disabled","usage":{"input_tokens":328,"input_tokens_details":{"cached_tokens":0},"output_tokens":52,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":380},"metadata":{},"service_tier":"default","top_logprobs":0}},"ResponseCreatedStreamingEvent":{"type":"object","required":["type","sequence_number","response"],"properties":{"type":{"type":"string","enum":["response.created"],"description":"The type of the event, always `response.created`.","default":"response.created"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"response":{"$ref":"#/components/schemas/ResponseResource","description":"The response snapshot that was emitted with the event."}},"description":"A streaming event that indicated the response was created.","title":"Response created event"},"ResponseQueuedStreamingEvent":{"type":"object","required":["type","sequence_number","response"],"properties":{"type":{"type":"string","enum":["response.queued"],"description":"The type of the event, always `response.queued`.","default":"response.queued"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"response":{"$ref":"#/components/schemas/ResponseResource","description":"The response snapshot that was emitted with the event."}},"description":"A streaming event that indicated the response was queued.","title":"Response queued event"},"ResponseInProgressStreamingEvent":{"type":"object","required":["type","sequence_number","response"],"properties":{"type":{"type":"string","enum":["response.in_progress"],"description":"The type of the event, always `response.in_progress`.","default":"response.in_progress"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"response":{"$ref":"#/components/schemas/ResponseResource","description":"The response snapshot that was emitted with the event."}},"description":"A streaming event that indicated the response was in progress.","title":"Response in progress event"},"ResponseCompletedStreamingEvent":{"type":"object","required":["type","sequence_number","response"],"properties":{"type":{"type":"string","enum":["response.completed"],"description":"The type of the event, always `response.completed`.","default":"response.completed"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"response":{"$ref":"#/components/schemas/ResponseResource","description":"The response snapshot that was emitted with the event."}},"description":"A streaming event that indicated the response was completed.","title":"Response completed event"},"ResponseFailedStreamingEvent":{"type":"object","required":["type","sequence_number","response"],"properties":{"type":{"type":"string","enum":["response.failed"],"description":"The type of the event, always `response.failed`.","default":"response.failed"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"response":{"$ref":"#/components/schemas/ResponseResource","description":"The response snapshot that was emitted with the event."}},"description":"A streaming event that indicated the response had failed.","title":"Response failed event"},"ResponseIncompleteStreamingEvent":{"type":"object","required":["type","sequence_number","response"],"properties":{"type":{"type":"string","enum":["response.incomplete"],"description":"The type of the event, always `response.incomplete`.","default":"response.incomplete"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"response":{"$ref":"#/components/schemas/ResponseResource","description":"The response snapshot that was emitted with the event."}},"description":"A streaming event that indicated the response was incomplete.","title":"Response incomplete event"},"ResponseOutputItemAddedStreamingEvent":{"type":"object","required":["type","sequence_number","output_index","item"],"properties":{"type":{"type":"string","enum":["response.output_item.added"],"description":"The type of the event, always `response.output_item.added`.","default":"response.output_item.added"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"output_index":{"type":"integer","description":"The index of the output item that was added."},"item":{"anyOf":[{"$ref":"#/components/schemas/ItemField"},{"type":"null"}],"description":"An item representing a message, tool call, tool output, reasoning, or other\nresponse element."}},"description":"A streaming event that indicated an output item was added to the response.","title":"Response output item added event"},"ResponseOutputItemDoneStreamingEvent":{"type":"object","required":["type","sequence_number","output_index","item"],"properties":{"type":{"type":"string","enum":["response.output_item.done"],"description":"The type of the event, always `response.output_item.done`.","default":"response.output_item.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"output_index":{"type":"integer","description":"The index of the output item that was completed."},"item":{"anyOf":[{"$ref":"#/components/schemas/ItemField"},{"type":"null"}],"description":"An item representing a message, tool call, tool output, reasoning, or other\nresponse element."}},"description":"A streaming event that indicated an output item was completed.","title":"Response output item done event"},"ResponseReasoningSummaryPartAddedStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","summary_index","part"],"properties":{"type":{"type":"string","enum":["response.reasoning_summary_part.added"],"description":"The type of the event, always `response.reasoning_summary_part.added`.","default":"response.reasoning_summary_part.added"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"summary_index":{"type":"integer","description":"The index of the summary part that was added."},"part":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}}},"description":"A streaming event that indicated a reasoning summary part was added.","title":"Response reasoning summary part added event"},"ResponseReasoningSummaryPartDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","summary_index","part"],"properties":{"type":{"type":"string","enum":["response.reasoning_summary_part.done"],"description":"The type of the event, always `response.reasoning_summary_part.done`.","default":"response.reasoning_summary_part.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"summary_index":{"type":"integer","description":"The index of the summary part that was completed."},"part":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}}},"description":"A streaming event that indicated a reasoning summary part was completed.","title":"Response reasoning summary part done event"},"ResponseContentPartAddedStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","part"],"properties":{"type":{"type":"string","enum":["response.content_part.added"],"description":"The type of the event, always `response.content_part.added`.","default":"response.content_part.added"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the content part that was added."},"part":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}}},"description":"A streaming event that indicated a content part was added.","title":"Response content part added event"},"ResponseContentPartDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","part"],"properties":{"type":{"type":"string","enum":["response.content_part.done"],"description":"The type of the event, always `response.content_part.done`.","default":"response.content_part.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the content part that was completed."},"part":{"oneOf":[{"$ref":"#/components/schemas/InputTextContent"},{"$ref":"#/components/schemas/OutputTextContent"},{"$ref":"#/components/schemas/TextContent"},{"$ref":"#/components/schemas/SummaryTextContent"},{"$ref":"#/components/schemas/ReasoningTextContent"},{"$ref":"#/components/schemas/RefusalContent"},{"$ref":"#/components/schemas/InputImageContent"},{"$ref":"#/components/schemas/InputFileContent"}],"description":"A content part that makes up an input or output item.","discriminator":{"propertyName":"type"}}},"description":"A streaming event that indicated a content part was completed.","title":"Response content part done event"},"ResponseOutputTextDeltaStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","delta"],"properties":{"type":{"type":"string","enum":["response.output_text.delta"],"description":"The type of the event, always `response.output_text.delta`.","default":"response.output_text.delta"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the content part that was updated."},"delta":{"type":"string","description":"The text delta that was appended."},"logprobs":{"type":"array","items":{"$ref":"#/components/schemas/LogProb"},"description":"The token log probabilities that were emitted with the delta, if any."},"obfuscation":{"type":"string","description":"An obfuscation string that was added to pad the event payload."}},"description":"A streaming event that indicated output text was incrementally added.","title":"Response output text delta event"},"ResponseOutputTextDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","text"],"properties":{"type":{"type":"string","enum":["response.output_text.done"],"description":"The type of the event, always `response.output_text.done`.","default":"response.output_text.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the content part that was completed."},"text":{"type":"string","description":"The final text that was emitted."},"logprobs":{"type":"array","items":{"$ref":"#/components/schemas/LogProb"},"description":"The token log probabilities that were emitted with the final text, if any."}},"description":"A streaming event that indicated output text was completed.","title":"Response output text done event"},"ResponseRefusalDeltaStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","delta"],"properties":{"type":{"type":"string","enum":["response.refusal.delta"],"description":"The type of the event, always `response.refusal.delta`.","default":"response.refusal.delta"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the refusal content that was updated."},"delta":{"type":"string","description":"The refusal text delta that was appended."}},"description":"A streaming event that indicated refusal text was incrementally added.","title":"Response refusal delta event"},"ResponseRefusalDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","refusal"],"properties":{"type":{"type":"string","enum":["response.refusal.done"],"description":"The type of the event, always `response.refusal.done`.","default":"response.refusal.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the refusal content that was completed."},"refusal":{"type":"string","description":"The final refusal text that was emitted."}},"description":"A streaming event that indicated refusal text was completed.","title":"Response refusal done event"},"ResponseReasoningDeltaStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","delta"],"properties":{"type":{"type":"string","enum":["response.reasoning.delta"],"description":"The type of the event, always `response.reasoning.delta`.","default":"response.reasoning.delta"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the reasoning content that was updated."},"delta":{"type":"string","description":"The reasoning text delta that was appended."},"obfuscation":{"type":"string","description":"An obfuscation string that was added to pad the event payload."}},"description":"A streaming event that indicated reasoning text was incrementally added.","title":"Response reasoning delta event"},"ResponseReasoningDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","text"],"properties":{"type":{"type":"string","enum":["response.reasoning.done"],"description":"The type of the event, always `response.reasoning.done`.","default":"response.reasoning.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the reasoning content that was completed."},"text":{"type":"string","description":"The final reasoning text that was emitted."}},"description":"A streaming event that indicated reasoning text was completed.","title":"Response reasoning done event"},"ResponseReasoningSummaryDeltaStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","summary_index","delta"],"properties":{"type":{"type":"string","enum":["response.reasoning_summary_text.delta"],"description":"The type of the event, always `response.reasoning_summary.delta`.","default":"response.reasoning_summary_text.delta"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"summary_index":{"type":"integer","description":"The index of the summary content that was updated."},"delta":{"type":"string","description":"The summary text delta that was appended."},"obfuscation":{"type":"string","description":"An obfuscation string that was added to pad the event payload."}},"description":"A streaming event that indicated a reasoning summary was incrementally added.","title":"Response reasoning summary delta event"},"ResponseReasoningSummaryDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","summary_index","text"],"properties":{"type":{"type":"string","enum":["response.reasoning_summary_text.done"],"description":"The type of the event, always `response.reasoning_summary.done`.","default":"response.reasoning_summary_text.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"summary_index":{"type":"integer","description":"The index of the summary content that was completed."},"text":{"type":"string","description":"The final summary text that was emitted."}},"description":"A streaming event that indicated a reasoning summary was completed.","title":"Response reasoning summary done event"},"ResponseOutputTextAnnotationAddedStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","content_index","annotation_index","annotation"],"properties":{"type":{"type":"string","enum":["response.output_text.annotation.added"],"description":"The type of the event, always `response.output_text.annotation.added`.","default":"response.output_text.annotation.added"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"content_index":{"type":"integer","description":"The index of the output text content that was updated."},"annotation_index":{"type":"integer","description":"The index of the annotation that was added."},"annotation":{"anyOf":[{"$ref":"#/components/schemas/Annotation"},{"type":"null"}],"description":"An annotation that applies to a span of output text."}},"description":"A streaming event that indicated an output text annotation was added.","title":"Response output text annotation added event"},"ResponseFunctionCallArgumentsDeltaStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","delta"],"properties":{"type":{"type":"string","enum":["response.function_call_arguments.delta"],"description":"The type of the event, always `response.function_call_arguments.delta`.","default":"response.function_call_arguments.delta"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the tool call item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"delta":{"type":"string","description":"The arguments delta that was appended."},"obfuscation":{"type":"string","description":"An obfuscation string that was added to pad the event payload."}},"description":"A streaming event that indicated function call arguments were incrementally added.","title":"Response function call arguments delta event"},"ResponseFunctionCallArgumentsDoneStreamingEvent":{"type":"object","required":["type","sequence_number","item_id","output_index","arguments"],"properties":{"type":{"type":"string","enum":["response.function_call_arguments.done"],"description":"The type of the event, always `response.function_call_arguments.done`.","default":"response.function_call_arguments.done"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"item_id":{"type":"string","description":"The ID of the tool call item that was updated."},"output_index":{"type":"integer","description":"The index of the output item that was updated."},"arguments":{"type":"string","description":"The final arguments string that was emitted."}},"description":"A streaming event that indicated function call arguments were completed.","title":"Response function call arguments done event"},"ErrorPayload":{"type":"object","required":["type","code","message","param"],"properties":{"type":{"type":"string","description":"The error type that was emitted."},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The error code that was emitted, if any."},"message":{"type":"string","description":"The human-readable error message that was emitted."},"param":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The parameter name that was associated with the error, if any."},"headers":{"type":"object","description":"The response headers that were emitted with the error, if any.","additionalProperties":{"type":"string"}}},"description":"An error payload that was emitted for a streaming error event.","title":"Error payload"},"ErrorStreamingEvent":{"type":"object","required":["type","sequence_number","error"],"properties":{"type":{"type":"string","enum":["error"],"description":"The type of the event, always `error`.","default":"error"},"sequence_number":{"type":"integer","description":"The sequence number of the event that was emitted."},"error":{"$ref":"#/components/schemas/ErrorPayload","description":"The error payload that was emitted."}},"description":"A streaming event that indicated an error was emitted.","title":"Error event"},"ItemReferenceParam":{"type":"object","required":["id"],"properties":{"type":{"anyOf":[{"type":"string","default":"item_reference","enum":["item_reference"]},{"type":"null"}],"description":"The type of item to reference. Always `item_reference`."},"id":{"type":"string","description":"The ID of the item to reference."}},"description":"An internal identifier for an item to reference.","title":"Item reference"},"ReasoningSummaryContentParam":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["summary_text"],"description":"The content type. Always `summary_text`.","default":"summary_text"},"text":{"type":"string","maxLength":10485760,"description":"The reasoning summary text."}}},"ReasoningItemParam":{"type":"object","required":["type","summary"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of this reasoning item.","example":"rs_123"},"type":{"type":"string","enum":["reasoning"],"description":"The item type. Always `reasoning`.","default":"reasoning"},"summary":{"type":"array","items":{"$ref":"#/components/schemas/ReasoningSummaryContentParam"},"description":"Reasoning summary content associated with this item."},"content":{"type":"null"},"encrypted_content":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"An encrypted representation of the reasoning content."}}},"CompactionSummaryItemParam":{"type":"object","required":["type","encrypted_content"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The ID of the compaction item.","example":"cmp_123"},"type":{"type":"string","enum":["compaction"],"description":"The type of the item. Always `compaction`.","default":"compaction"},"encrypted_content":{"type":"string","maxLength":10485760,"description":"The encrypted content of the compaction summary."}},"description":"A compaction item generated by the [`v1/responses/compact`\nAPI](/docs/api-reference/responses/compact).","title":"Compaction item","x-openresponses-added-in":"2026-04-24"},"InputTextContentParam":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["input_text"],"description":"The type of the input item. Always `input_text`.","default":"input_text"},"text":{"type":"string","maxLength":10485760,"description":"The text input to the model."}},"description":"A text input to the model.","title":"Input text","x-unionTitle":"Content Type","x-unionDisplay":"section"},"InputImageContentParamAutoParam":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["input_image"],"description":"The type of the input item. Always `input_image`.","default":"input_image"},"image_url":{"anyOf":[{"type":"string","maxLength":20971520},{"type":"null"}],"description":"The URL of the image to be sent to the model. A fully qualified URL or base64\nencoded image in a data URL."},"detail":{"anyOf":[{"$ref":"#/components/schemas/ImageDetail"},{"type":"null"}],"description":"The detail level of the image to be sent to the model. One of `high`, `low`, or\n`auto`. Defaults to `auto`."}},"description":"An image input to the model. Learn about [image inputs](/docs/guides/vision)","title":"Input image"},"InputFileContentParam":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["input_file"],"description":"The type of the input item. Always `input_file`.","default":"input_file"},"filename":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The name of the file to be sent to the model."},"file_data":{"anyOf":[{"type":"string","maxLength":33554432},{"type":"null"}],"description":"The base64-encoded data of the file to be sent to the model."},"file_url":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The URL of the file to be sent to the model."}},"description":"A file input to the model.","title":"Input file"},"UserMessageItemParam":{"type":"object","required":["type","role","content"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of this message item.","example":"msg_123"},"type":{"type":"string","enum":["message"],"description":"The item type. Always `message`.","default":"message"},"role":{"type":"string","enum":["user"],"description":"The message role. Always `user`.","default":"user"},"content":{"oneOf":[{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContentParam"},{"$ref":"#/components/schemas/InputImageContentParamAutoParam"},{"$ref":"#/components/schemas/InputFileContentParam"}],"description":"A piece of message content, such as text, an image, or a file.","discriminator":{"propertyName":"type"}}},{"type":"string","maxLength":10485760}],"description":"The message content, as a string or an array of content parts."},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The status of the message item."}}},"SystemMessageItemParam":{"type":"object","required":["type","role","content"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of this message item.","example":"msg_123"},"type":{"type":"string","enum":["message"],"description":"The item type. Always `message`.","default":"message"},"role":{"type":"string","enum":["system"],"description":"The message role. Always `system`.","default":"system"},"content":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/InputTextContentParam","discriminator":{"propertyName":"type"}}},{"type":"string","maxLength":10485760}],"description":"The message content, as a string or an array of content parts."},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The status of the message item."}}},"DeveloperMessageItemParam":{"type":"object","required":["type","role","content"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of this message item.","example":"msg_123"},"type":{"type":"string","enum":["message"],"description":"The item type. Always `message`.","default":"message"},"role":{"type":"string","enum":["developer"],"description":"The message role. Always `developer`.","default":"developer"},"content":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/InputTextContentParam","discriminator":{"propertyName":"type"}}},{"type":"string","maxLength":10485760}],"description":"The message content, as a string or an array of content parts."},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The status of the message item."}}},"UrlCitationParam":{"type":"object","required":["type","start_index","end_index","url","title"],"properties":{"type":{"type":"string","enum":["url_citation"],"description":"The citation type. Always `url_citation`.","default":"url_citation"},"start_index":{"type":"integer","minimum":0,"description":"The index of the first character of the citation in the message."},"end_index":{"type":"integer","minimum":0,"description":"The index of the last character of the citation in the message."},"url":{"type":"string","description":"The URL of the cited resource."},"title":{"type":"string","description":"The title of the cited resource."}}},"OutputTextContentParam":{"type":"object","required":["type","text"],"properties":{"type":{"type":"string","enum":["output_text"],"description":"The content type. Always `output_text`.","default":"output_text"},"text":{"type":"string","maxLength":10485760,"description":"The text content."},"annotations":{"type":"array","items":{"$ref":"#/components/schemas/UrlCitationParam"},"description":"Citations associated with the text content."}}},"RefusalContentParam":{"type":"object","required":["type","refusal"],"properties":{"type":{"type":"string","enum":["refusal"],"description":"The content type. Always `refusal`.","default":"refusal"},"refusal":{"type":"string","maxLength":10485760,"description":"The refusal text."}}},"AssistantMessageItemParam":{"type":"object","required":["type","role","content"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of this message item.","example":"msg_123"},"type":{"type":"string","enum":["message"],"description":"The item type. Always `message`.","default":"message"},"role":{"type":"string","enum":["assistant"],"description":"The role of the message author. Always `assistant`.","default":"assistant"},"content":{"oneOf":[{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/OutputTextContentParam"},{"$ref":"#/components/schemas/RefusalContentParam"}],"description":"A piece of assistant message content, such as text or a refusal.","discriminator":{"propertyName":"type"}}},{"type":"string","maxLength":10485760}],"description":"The message content, as a string or an array of content parts."},"phase":{"type":"string","enum":["commentary","final_answer"],"description":"Labels an `assistant` message as intermediate commentary (`commentary`) or the\nfinal answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when\nsending follow-up requests, preserve and resend phase on all assistant messages.\nOmitting it can degrade performance. Not used for user messages.","x-openresponses-added-in":"2026-04-24"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The status of the message item."}}},"FunctionCallItemParam":{"type":"object","required":["call_id","type","name","arguments"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of this function tool call.","example":"fc_123"},"call_id":{"type":"string","minLength":1,"maxLength":64,"description":"The unique ID of the function tool call generated by the model."},"type":{"type":"string","enum":["function_call"],"description":"The item type. Always `function_call`.","default":"function_call"},"name":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-zA-Z0-9_-]+$","description":"The name of the function to call."},"arguments":{"type":"string","description":"The function arguments as a JSON string."},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionCallStatus"},{"type":"null"}],"description":"The status of the function tool call."}}},"FunctionCallOutputItemParam":{"type":"object","required":["call_id","type","output"],"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of the function tool call output. Populated when this item is\nreturned via API.","example":"fc_123"},"call_id":{"type":"string","minLength":1,"maxLength":64,"description":"The unique ID of the function tool call generated by the model."},"type":{"type":"string","enum":["function_call_output"],"description":"The type of the function tool call output. Always `function_call_output`.","default":"function_call_output"},"output":{"oneOf":[{"type":"string","maxLength":10485760},{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/InputTextContentParam"},{"$ref":"#/components/schemas/InputImageContentParamAutoParam"},{"$ref":"#/components/schemas/InputFileContentParam"},{"$ref":"#/components/schemas/InputVideoContent"}],"description":"A piece of message content, such as text, an image, or a file.","discriminator":{"propertyName":"type"}}}],"description":"The function tool call output, as a JSON string or an array of text, image,\nor file content."},"status":{"anyOf":[{"$ref":"#/components/schemas/FunctionCallStatus"},{"type":"null"}],"description":"The status of the item. One of `in_progress`, `completed`, or `incomplete`.\nPopulated when items are returned via API."}},"description":"The output of a function tool call.","title":"Function tool call output"},"ItemParam":{"oneOf":[{"$ref":"#/components/schemas/ItemReferenceParam"},{"$ref":"#/components/schemas/ReasoningItemParam"},{"$ref":"#/components/schemas/CompactionSummaryItemParam"},{"$ref":"#/components/schemas/UserMessageItemParam"},{"$ref":"#/components/schemas/SystemMessageItemParam"},{"$ref":"#/components/schemas/DeveloperMessageItemParam"},{"$ref":"#/components/schemas/AssistantMessageItemParam"},{"$ref":"#/components/schemas/FunctionCallItemParam"},{"$ref":"#/components/schemas/FunctionCallOutputItemParam"}],"x-unionTitle":"Input Item Types","x-unionDisplay":"section","discriminator":{"propertyName":"type"}},"IncludeEnum":{"type":"string","enum":["reasoning.encrypted_content","message.output_text.logprobs"],"x-enumDescriptions":{"message.output_text.logprobs":"includes sampled logprobs in assistant messages.","reasoning.encrypted_content":"includes encrypted reasoning content so that it may be rehydrated on a subsequent request."}},"EmptyModelParam":{"type":"object"},"FunctionToolParam":{"type":"object","required":["name","type"],"properties":{"name":{"type":"string","minLength":1,"maxLength":64,"pattern":"^[a-zA-Z0-9_-]+$"},"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"parameters":{"anyOf":[{"$ref":"#/components/schemas/EmptyModelParam"},{"type":"null"}]},"strict":{"type":"boolean"},"type":{"type":"string","enum":["function"],"default":"function"}}},"ResponsesToolParam":{"$ref":"#/components/schemas/FunctionToolParam","x-unionTitle":"Tool Types","x-unionDisplay":"section","discriminator":{"propertyName":"type"}},"SpecificFunctionParam":{"type":"object","required":["type","name"],"properties":{"type":{"type":"string","enum":["function"],"description":"The tool to call. Always `function`.","default":"function"},"name":{"type":"string","description":"The name of the function tool to call."}}},"SpecificToolChoiceParam":{"$ref":"#/components/schemas/SpecificFunctionParam"},"AllowedToolsParam":{"type":"object","required":["type","tools"],"properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The tool choice type. Always `allowed_tools`.","default":"allowed_tools"},"tools":{"type":"array","items":{"$ref":"#/components/schemas/SpecificToolChoiceParam"},"minItems":1,"maxItems":128,"description":"The list of tools that are permitted for this request."},"mode":{"$ref":"#/components/schemas/ToolChoiceValueEnum","description":"How to select a tool from the allowed set."}}},"ToolChoiceParam":{"oneOf":[{"$ref":"#/components/schemas/SpecificToolChoiceParam"},{"$ref":"#/components/schemas/ToolChoiceValueEnum"},{"$ref":"#/components/schemas/AllowedToolsParam"}],"description":"Controls which tool the model should use, if any."},"MetadataParam":{"type":"object","description":"Set of 16 key-value pairs that can be attached to an object. This can be useful for\nstoring additional information about the object in a structured format, and querying\nfor objects via API or the dashboard. Keys are strings with a maximum length of 64\ncharacters. Values are strings with a maximum length of 512 characters.","maxProperties":16,"additionalProperties":{"type":"string","maxLength":512}},"JsonSchemaResponseFormatParam":{"type":"object","properties":{"type":{"type":"string","enum":["json_schema"],"description":"The type of response format being defined. Always `json_schema`."},"description":{"type":"string","description":"A description of what the response format is for, used by the model to determine\nhow to respond in the format."},"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and\ndashes, with a maximum length of 64."},"schema":{"type":"object","description":"The schema for the response format, described as a JSON Schema object.","title":"JSON schema","additionalProperties":{}},"strict":{"anyOf":[{"type":"boolean","default":false},{"type":"null"}],"description":"Whether to enable strict schema adherence when generating the output. If set to\ntrue, the model will always follow the exact schema defined in the `schema` field.\nOnly a subset of JSON Schema is supported when `strict` is `true`."}}},"TextFormatParam":{"oneOf":[{"$ref":"#/components/schemas/TextResponseFormat"},{"$ref":"#/components/schemas/JsonSchemaResponseFormatParam"}]},"TextParam":{"type":"object","properties":{"format":{"oneOf":[{"$ref":"#/components/schemas/TextFormatParam"},{"type":"null"}],"description":"The format configuration for text output."},"verbosity":{"$ref":"#/components/schemas/VerbosityEnum","description":"Controls the level of detail in generated text output."}}},"StreamOptionsParam":{"type":"object","properties":{"include_obfuscation":{"type":"boolean","description":"Whether to obfuscate sensitive information in streamed output. Defaults to `true`."}},"description":"Options that control streamed response behavior."},"ReasoningParam":{"type":"object","properties":{"effort":{"anyOf":[{"$ref":"#/components/schemas/ReasoningEffortEnum"},{"type":"null"}],"description":"Controls the level of reasoning effort the model should apply. Higher effort may\nincrease latency and cost."},"summary":{"anyOf":[{"$ref":"#/components/schemas/ReasoningSummaryEnum"},{"type":"null"}],"description":"Controls whether the response includes a reasoning summary."}},"description":"**gpt-5 and o-series models only** Configuration options for [reasoning\nmodels](https://platform.openai.com/docs/guides/reasoning)."},"ServiceTierEnum":{"type":"string","enum":["auto","default","flex","priority"],"x-enumDescriptions":{"auto":"Choose a service tier automatically based on current account state.","default":"Choose the default service tier.","flex":"Choose the flex service tier.","priority":"Choose the priority service tier."}},"CreateResponseBody":{"type":"object","properties":{"model":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The model to use for this request, e.g. 'gpt-5.2'."},"input":{"anyOf":[{"oneOf":[{"type":"string","maxLength":10485760},{"type":"array","items":{"$ref":"#/components/schemas/ItemParam"}}]},{"type":"null"}],"description":"Context to provide to the model for the scope of this request. May either be a\nstring or an array of input items. If a string is provided, it is interpreted as a\nuser message."},"previous_response_id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The ID of the response to use as the prior turn for this request.","example":"resp_123"},"include":{"type":"array","items":{"$ref":"#/components/schemas/IncludeEnum"}},"tools":{"anyOf":[{"type":"array","items":{"$ref":"#/components/schemas/ResponsesToolParam"}},{"type":"null"}],"description":"A list of tools that the model may call while generating the response."},"tool_choice":{"anyOf":[{"$ref":"#/components/schemas/ToolChoiceParam"},{"type":"null"}],"description":"Controls which tool the model should use, if any.","x-unionTitle":"ToolChoiceParam"},"metadata":{"anyOf":[{"$ref":"#/components/schemas/MetadataParam"},{"type":"null"}],"description":"Set of 16 key-value pairs that can be attached to an object. This can be useful for\nstoring additional information about the object in a structured format, and\nquerying for objects via API or the dashboard. Keys are strings with a maximum\nlength of 64 characters. Values are strings with a maximum length of 512\ncharacters."},"text":{"anyOf":[{"$ref":"#/components/schemas/TextParam"},{"type":"null"}],"description":"Configuration options for text output."},"temperature":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Sampling temperature to use, between 0 and 2. Higher values make the output more\nrandom."},"top_p":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Nucleus sampling parameter, between 0 and 1. The model considers only the tokens\nwith the top cumulative probability."},"presence_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Penalizes new tokens based on whether they appear in the text so far."},"frequency_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Penalizes new tokens based on their frequency in the text so far."},"parallel_tool_calls":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Whether the model may call multiple tools in parallel."},"stream":{"type":"boolean","description":"Whether to stream response events as server-sent events."},"stream_options":{"anyOf":[{"$ref":"#/components/schemas/StreamOptionsParam"},{"type":"null"}],"description":"Options that control streamed response behavior."},"background":{"type":"boolean","description":"Whether to run the request in the background and return immediately."},"max_output_tokens":{"anyOf":[{"type":"integer","minimum":16},{"type":"null"}],"description":"The maximum number of tokens the model may generate for this response."},"max_tool_calls":{"anyOf":[{"type":"integer","minimum":1},{"type":"null"}],"description":"The maximum number of tool calls the model may make while generating the response."},"reasoning":{"anyOf":[{"$ref":"#/components/schemas/ReasoningParam"},{"type":"null"}],"description":"Configuration options for reasoning behavior."},"safety_identifier":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"description":"A stable identifier used for safety monitoring and abuse detection."},"prompt_cache_key":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"description":"A key to use when reading from or writing to the prompt cache."},"truncation":{"$ref":"#/components/schemas/TruncationEnum","description":"Controls how the service truncates the input when it exceeds the model context\nwindow."},"instructions":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Additional instructions to guide the model for this request."},"store":{"type":"boolean","description":"Whether to store the response so it can be retrieved later."},"service_tier":{"$ref":"#/components/schemas/ServiceTierEnum","description":"The service tier to use for this request."},"top_logprobs":{"anyOf":[{"type":"integer","minimum":0,"maximum":20},{"type":"null"}],"description":"The number of most likely tokens to return at each position, along with their log\nprobabilities."}}},"CompactResource":{"type":"object","required":["id","object","output","created_at","usage"],"properties":{"id":{"type":"string","description":"The unique identifier for the compacted response."},"object":{"type":"string","enum":["response.compaction"],"description":"The object type. Always `response.compaction`.","default":"response.compaction"},"output":{"type":"array","items":{"$ref":"#/components/schemas/ItemField"},"description":"The compacted list of output items."},"created_at":{"type":"integer","description":"Unix timestamp (in seconds) when the compacted conversation was created."},"usage":{"$ref":"#/components/schemas/Usage","description":"Token accounting for the compaction pass, including cached, reasoning, and total\ntokens."}},"title":"The compacted response object","x-openresponses-added-in":"2026-04-24","example":{"id":"resp_001","object":"response.compaction","created_at":1764967971,"output":[{"id":"msg_000","type":"message","status":"completed","content":[{"type":"input_text","text":"Create a simple landing page for a dog petting cafe."}],"role":"user"},{"id":"cmp_001","type":"compaction","encrypted_content":"gAAAAABpM0Yj-...="}],"usage":{"input_tokens":139,"input_tokens_details":{"cached_tokens":0},"output_tokens":438,"output_tokens_details":{"reasoning_tokens":64},"total_tokens":577}}},"CompactResponseMethodPublicBody":{"type":"object","required":["model"],"properties":{"model":{"type":"string","description":"Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide\nrange of models with different capabilities, performance characteristics, and price\npoints. Refer to the [model guide](/docs/models) to browse and compare available\nmodels."},"input":{"anyOf":[{"oneOf":[{"type":"string","maxLength":10485760},{"type":"array","items":{"$ref":"#/components/schemas/ItemParam"}}]},{"type":"null"}],"description":"Text, image, or file inputs to the model, used to generate a response.\nA string is treated as text input with the `user` role. An array can contain\none or more input items with different content types."},"previous_response_id":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unique ID of the previous response to the model. Use this to create multi-turn\nconversations. Learn more about [conversation\nstate](/docs/guides/conversation-state). Cannot be used in conjunction with\n`conversation`.","example":"resp_123"},"instructions":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"A system (or developer) message inserted into the model's context. When used along\nwith `previous_response_id`, the instructions from a previous response will not be\ncarried over to the next response. This makes it simple to swap out system (or\ndeveloper) messages in new responses."},"prompt_cache_key":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"description":"A key to use when reading from or writing to the prompt cache."}},"x-openresponses-added-in":"2026-04-24"},"WebSocketResponseCreateEvent":{"allOf":[{"type":"object","properties":{"type":{"type":"string","enum":["response.create"],"description":"The client event type. Always `response.create`.","default":"response.create"},"stream":{"type":"string","description":"This HTTP streaming field MUST NOT be sent in WebSocket `response.create` messages.","maxLength":0,"minLength":1,"x-openresponses-disallowed":true},"stream_options":{"type":"string","description":"This HTTP streaming options field MUST NOT be sent in WebSocket `response.create`\nmessages.","maxLength":0,"minLength":1,"x-openresponses-disallowed":true},"background":{"type":"string","description":"This HTTP background-mode field MUST NOT be sent in WebSocket `response.create`\nmessages.","maxLength":0,"minLength":1,"x-openresponses-disallowed":true}},"required":["type"]},{"$ref":"#/components/schemas/CreateResponseBody"}],"description":"A client-sent WebSocket event that starts a Responses turn. It uses the normal\nresponse-create body plus a required `type` field.","title":"WebSocket response create event","x-openresponses-added-in":"2026-04-24"},"WebSocketErrorEvent":{"type":"object","required":["type","status","error"],"properties":{"type":{"type":"string","enum":["error"],"description":"The event type. Always `error`.","default":"error"},"status":{"type":"integer","description":"The HTTP-style status code for the WebSocket error."},"error":{"type":"object","properties":{"type":{"type":"string","description":"The error type, when supplied."},"code":{"type":"string","description":"A machine-readable error code."},"message":{"type":"string","description":"A human-readable error message."},"param":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The request parameter associated with the error, when supplied."}},"required":["code","message"],"description":"The WebSocket error payload.","additionalProperties":{}}},"description":"A WebSocket error envelope returned for Responses WebSocket mode failures.","title":"WebSocket error event","x-openresponses-added-in":"2026-04-24"},"DetailEnum":{"type":"string","enum":["low","high","auto"],"x-enumDescriptions":{"auto":"Choose the detail level automatically.","high":"Allows the model to \"see\" a higher-resolution version of the image, usually increasing input token costs.","low":"Restricts the model to a lower-resolution version of the image."}},"FunctionCallItemStatus":{"type":"string","enum":["in_progress","completed","incomplete"]}},"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","in":"header"}}},"servers":[{"url":"https://api.openai.com/v1","description":"","variables":{}}],"x-hum-source":{"repo":"openresponses/openresponses","commit":"8907bc3b7c4300ff5c21fd647cfde9929243afa1","path":"public/openapi/openapi.json"}} diff --git a/hives/openai-server/src/chat.ts b/hives/openai-server/src/chat.ts index 944478ce..005b600a 100644 --- a/hives/openai-server/src/chat.ts +++ b/hives/openai-server/src/chat.ts @@ -92,7 +92,7 @@ export async function chat(ctx: Ctx, who: Caller, req: IncomingMessage, res: Ser const stream = body.stream === true; const sse = stream ? new Sse(res) : undefined; const chunk = (delta: Record, finish: string | null = null) => ({ - id, object: "chat.completion.chunk", created, model: echoed, system_fingerprint: null, + id, object: "chat.completion.chunk", created, model: echoed, choices: [{ index: 0, delta, logprobs: null, finish_reason: finish }], }); let spoke = false; @@ -142,7 +142,7 @@ export async function chat(ctx: Ctx, who: Caller, req: IncomingMessage, res: Ser if (!spoke) sse.data(chunk({ role: "assistant", content: "" })); sse.data(chunk({}, grown.finish)); if (body.stream_options?.include_usage === true) { - sse.data({ id, object: "chat.completion.chunk", created, model: echoed, system_fingerprint: null, choices: [], usage }); + sse.data({ id, object: "chat.completion.chunk", created, model: echoed, choices: [], usage }); } sse.data("[DONE]"); sse.end(); @@ -153,7 +153,6 @@ export async function chat(ctx: Ctx, who: Caller, req: IncomingMessage, res: Ser object: "chat.completion", created, model: echoed, - system_fingerprint: null, choices: [{ index: 0, message: { diff --git a/hives/openai-server/src/conversation.ts b/hives/openai-server/src/conversation.ts index 332d17d6..a460503a 100644 --- a/hives/openai-server/src/conversation.ts +++ b/hives/openai-server/src/conversation.ts @@ -112,10 +112,16 @@ function partsOf(content: unknown): Petal[] { return out; } +function failureOf(error: unknown): unknown { + if (!error || typeof error !== "object") return error; + const e = error as { message?: unknown; content?: unknown }; + return e.message ?? e.content ?? error; +} + function servedPetals(id: string, name: string, args: unknown, output: unknown, error: unknown): Petal[] { return [ { kind: PetalKind.tendril, callId: id, name, args: argsOf(args) }, - { kind: PetalKind.grasp, callId: id, result: resultOf(output ?? error), isError: Boolean(error) }, + { kind: PetalKind.grasp, callId: id, result: resultOf(output ?? failureOf(error)), isError: Boolean(error) }, ]; } diff --git a/hives/openai-server/src/growth.ts b/hives/openai-server/src/growth.ts index 475fafdc..a7a44c86 100644 --- a/hives/openai-server/src/growth.ts +++ b/hives/openai-server/src/growth.ts @@ -69,10 +69,11 @@ export interface Opening { answers?: Answer[]; } -export function usageOf(nectar: Nectar | undefined): { prompt: number; completion: number; cached: number } { +export function usageOf(nectar: Nectar | undefined): { prompt: number; completion: number; cached: number; written: number } { const cached = nectar?.cache_read_input_tokens ?? 0; - const prompt = (nectar?.input_tokens ?? 0) + cached + (nectar?.cache_creation_input_tokens ?? 0); - return { prompt, completion: nectar?.output_tokens ?? 0, cached }; + const written = nectar?.cache_creation_input_tokens ?? 0; + const prompt = (nectar?.input_tokens ?? 0) + cached + written; + return { prompt, completion: nectar?.output_tokens ?? 0, cached, written }; } export function finishOf(reason: string | undefined): Finish { @@ -226,7 +227,7 @@ export function mcpCallOf(s: Served): Record { server_label: "hum", name: s.name, arguments: s.args, - output: s.result, - error: s.isError ? s.result : null, + output: s.isError ? null : s.result, + error: s.isError ? { type: "mcp_tool_execution_error", content: [{ type: "text", text: s.result }] } : null, }; } diff --git a/hives/openai-server/src/responses.ts b/hives/openai-server/src/responses.ts index 75c0f99b..684ab925 100644 --- a/hives/openai-server/src/responses.ts +++ b/hives/openai-server/src/responses.ts @@ -42,13 +42,24 @@ interface Body { max_output_tokens?: number; temperature?: number; top_p?: number; + top_logprobs?: number; + max_tool_calls?: number; metadata?: Record; truncation?: string; user?: string; + safety_identifier?: string; + prompt_cache_key?: string; + service_tier?: string; frequency_penalty?: number; presence_penalty?: number; } +function echoedTool(tool: unknown): unknown { + const t = tool as Record | null; + if (!t || t.type !== "function") return tool; + return { ...t, description: t.description ?? null, parameters: t.parameters ?? null, strict: t.strict ?? null }; +} + export interface Kept { label: string; sid: string; @@ -121,6 +132,8 @@ export async function responses(ctx: Ctx, who: Caller, req: IncomingMessage, res } else if (conversation) { before = kept.latest(rq.label, conversation); } + const unread = (Array.isArray(body.input) ? body.input : []).map((i) => (i as { type?: string })?.type).find((t) => t === "item_reference" || t === "compaction"); + if (unread) throw bad(`an input item of type ${unread} is not read here, since its words are kept elsewhere; send the items themselves, or previous_response_id`, "input"); const said = fromResponses(body.input, body.instructions, before?.said); if (said.tail === "none") throw bad("input holds nothing to answer", "input"); @@ -170,18 +183,28 @@ export async function responses(ctx: Ctx, who: Caller, req: IncomingMessage, res output, instructions: body.instructions ?? null, previous_response_id: body.previous_response_id ?? null, - tools: body.tools ?? [], + tools: (body.tools ?? []).map(echoedTool), tool_choice: body.tool_choice ?? "auto", parallel_tool_calls: body.parallel_tool_calls ?? true, - temperature: body.temperature ?? null, - top_p: body.top_p ?? null, + temperature: body.temperature ?? 1, + top_p: body.top_p ?? 1, + top_logprobs: body.top_logprobs ?? 0, + frequency_penalty: body.frequency_penalty ?? 0, + presence_penalty: body.presence_penalty ?? 0, max_output_tokens: body.max_output_tokens ?? null, + max_tool_calls: body.max_tool_calls ?? null, reasoning: { effort: body.reasoning?.effort ?? null, summary: body.reasoning?.summary ?? null }, text: { format: format ?? { type: "text" } }, truncation: body.truncation ?? "disabled", metadata: body.metadata ?? {}, store: body.store !== false, + background: false, + service_tier: body.service_tier ?? "default", user: body.user ?? null, + safety_identifier: body.safety_identifier ?? null, + prompt_cache_key: body.prompt_cache_key ?? null, + access_programs: null, + completed_at: null, error: null, incomplete_details: null, usage: null, @@ -268,7 +291,8 @@ export async function responses(ctx: Ctx, who: Caller, req: IncomingMessage, res ctx.sigils.end(sid); const err = e instanceof HttpError ? e : new HttpError(500, String(e)); if (sse?.begun) { - emit("response.failed", { response: shape("failed", output, { error: { code: err.code ?? "server_error", message: err.message } }) }); + const code = err.status === 429 ? "rate_limit_exceeded" : err.status === 400 ? "invalid_prompt" : "server_error"; + emit("response.failed", { response: shape("failed", output, { error: { code, message: err.message, type: err.code ?? err.type, param: err.param } }) }); sse.end(); } else if (sse) { sse.fail(err); @@ -289,7 +313,7 @@ export async function responses(ctx: Ctx, who: Caller, req: IncomingMessage, res ctx.usage.track(who.key, used.prompt, used.completion); const usage = { input_tokens: used.prompt, - input_tokens_details: { cached_tokens: used.cached }, + input_tokens_details: { cached_tokens: used.cached, cache_write_tokens: used.written }, output_tokens: used.completion, output_tokens_details: { reasoning_tokens: 0 }, total_tokens: used.prompt + used.completion, @@ -297,6 +321,7 @@ export async function responses(ctx: Ctx, who: Caller, req: IncomingMessage, res const incomplete = grown.finish === "length"; const final = shape(incomplete ? "incomplete" : "completed", output, { usage, + completed_at: Math.floor(Date.now() / 1000), ...(incomplete ? { incomplete_details: { reason: "max_output_tokens" } } : {}), }); if (body.store !== false) kept.put(id, { label: rq.label, sid, said: { ...said, blooms: after, tail: "assistant" }, response: final }, conversation); @@ -317,5 +342,5 @@ export function readResponse(who: Caller, id: string, res: ServerResponse): void export function dropResponse(who: Caller, id: string, res: ServerResponse): void { if (!kept.drop(who.rq.label, id)) throw new HttpError(404, `No response found with id '${id}'.`, "response_not_found"); - sendJson(res, 200, { id, object: "response", deleted: true }); + sendJson(res, 200, { id, object: "response.deleted", deleted: true }); } diff --git a/hives/openai-server/test/e2e.test.ts b/hives/openai-server/test/e2e.test.ts index dc2cfef6..01438a6f 100644 --- a/hives/openai-server/test/e2e.test.ts +++ b/hives/openai-server/test/e2e.test.ts @@ -11,13 +11,18 @@ // the server runs rides on a chat message as `mcp_calls` and shows in a // response; failures carry their status; a caller that hangs up stops the // model; and the Responses API, legacy completions, embeddings and keys -// all hold. +// all hold. Every exchange is held to OpenAI's spec and the Open Responses +// spec (spec.ts), and the Open Responses compliance suite's HTTP cases are +// sent as it writes them, from its commit 8907bc3b7c43. -import { afterAll, beforeAll, describe, expect, test } from "bun:test"; +import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test"; import OpenAI from "openai"; import { hum, type Hum } from "./hum.ts"; +import { wire } from "./spec.ts"; import { upstream, type Upstream } from "./upstream.ts"; +const offSpec: string[] = []; + let up: Upstream; let h: Hum; let ai: OpenAI; @@ -30,9 +35,13 @@ const readFile = { type: "function" as const, function: { name: "readFile", para beforeAll(async () => { up = await upstream(); h = await hum(up.url, { keys: ["lab"] }); - ai = new OpenAI({ baseURL: h.base, apiKey: h.keys.lab, maxRetries: 0, timeout: 20_000 }); + ai = new OpenAI({ baseURL: h.base, apiKey: h.keys.lab, maxRetries: 0, timeout: 20_000, fetch: wire(offSpec) }); }, 120_000); +afterEach(() => { + expect(offSpec.splice(0)).toEqual([]); +}); + afterAll(async () => { await h?.close(); await up?.close(); @@ -207,6 +216,17 @@ describe("chat completions", () => { expect((embedder as InstanceType).status).toBe(400); }, 30_000); + test("a streamed tool call and a failure are told as the spec tells them", async () => { + const deltas: string[] = []; + for await (const c of await ai.chat.completions.create({ model: "gpt-lab", tools: [readFile], stream: true, messages: [{ role: "user", content: `ONE ${tag()}` }] })) { + for (const t of c.choices[0]?.delta.tool_calls ?? []) deltas.push(t.function?.name ?? ""); + if (c.choices[0]?.finish_reason) deltas.push(c.choices[0].finish_reason); + } + expect(deltas).toEqual(["readFile", "tool_calls"]); + const broke = await ai.chat.completions.create({ model: "gpt-lab", stream: true, messages: [{ role: "user", content: `FAIL ${tag()}` }] }).catch((e) => e); + expect((broke as InstanceType).status).toBe(502); + }); + test("a bloom cut short says length", async () => { const r = await ai.chat.completions.create({ model: "gpt-lab", messages: [{ role: "user", content: `LEN ${tag()}` }] }); expect(r.choices[0].finish_reason).toBe("length"); @@ -240,6 +260,38 @@ describe("responses", () => { expect(types.at(-1)).toBe("response.completed"); }); + test("every kind of response streams as the spec tells it, and a deleted one says so", async () => { + const typesOf = async (body: OpenAI.Responses.ResponseCreateParamsStreaming) => { + const types: string[] = []; + try { + for await (const ev of await ai.responses.create(body)) types.push(ev.type); + } catch (e) { + types.push(`threw ${(e as Error).constructor.name}`); + } + return types; + }; + const tools = [{ type: "function" as const, name: "readFile", parameters: { type: "object", properties: {} }, strict: false }]; + const called = await typesOf({ model: "gpt-lab", tools, input: `ONE ${tag()}`, stream: true }); + expect(called).toContain("response.function_call_arguments.done"); + const served = await typesOf({ model: "gpt-lab", input: `LOOKUP ${tag()}`, stream: true }); + expect(served).toContain("response.output_item.done"); + expect(served.at(-1)).toBe("response.completed"); + const cut = await typesOf({ model: "gpt-lab", input: `LEN ${tag()}`, stream: true }); + expect(cut.at(-1)).toBe("response.incomplete"); + const failed = await typesOf({ model: "gpt-lab", input: `FAIL ${tag()}`, stream: true }); + expect(failed.some((t) => t === "response.failed" || t.startsWith("threw"))).toBe(true); + + const kept = await ai.responses.create({ model: "gpt-lab", input: `keep ${tag()}` }); + await ai.responses.delete(kept.id); + const gone = await ai.responses.retrieve(kept.id).catch((e) => e); + expect(gone).toBeInstanceOf(OpenAI.NotFoundError); + }); + + test("an input item that holds its words elsewhere is refused, not dropped", async () => { + const refused = await ai.responses.create({ model: "gpt-lab", input: [{ type: "item_reference", id: "msg_elsewhere" }, { role: "user", content: `go ${tag()}` }] }).catch((e) => e); + expect((refused as InstanceType).status).toBe(400); + }); + test("instructions and developer words are the system prompt", async () => { const n = (await heard()).length; await ai.responses.create({ model: "gpt-lab", instructions: "RULES-A", input: [{ role: "developer", content: "RULES-B" }, { role: "user", content: `hi ${tag()}` }] }); @@ -272,6 +324,18 @@ describe("responses", () => { expect(r.output_text).toBe("after tools: found bees"); }); + test("a tool the server ran that failed shows as a failed mcp_call, its error as the spec shapes it", async () => { + const r = await ai.responses.create({ model: "gpt-lab", input: `NOTFOUND ${tag()}` }); + const failed = r.output.find((o) => o.type === "mcp_call") as { status: string; output: string | null; error: { type: string; content: Array<{ text: string }> } } | undefined; + expect(failed?.status).toBe("failed"); + expect(failed?.output).toBeNull(); + expect(failed?.error.type).toBe("mcp_tool_execution_error"); + expect(failed?.error.content[0].text).toBe("nothing found"); + const chat = await ai.chat.completions.create({ model: "gpt-lab", messages: [{ role: "user", content: `NOTFOUND ${tag()}` }] }); + const rode = (chat.choices[0].message as { mcp_calls?: Array<{ error: { type: string } }> }).mcp_calls; + expect(rode?.[0].error.type).toBe("mcp_tool_execution_error"); + }); + test("a response follows the one before it", async () => { const t = tag(); const n = (await heard()).length; @@ -282,6 +346,96 @@ describe("responses", () => { }); }); +describe("the Open Responses compliance cases, over HTTP", () => { + type Case = { id: string; body: Record; streaming?: boolean; outputType?: string }; + const RED_HEART = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAABmklEQVR42tyWAaTyUBzFew/eG4AHz+MBSAHKBiJRGFKwIgQQJKLUIioBIhCAiCAAEizAQIAECaASqFFJq84nudjnaqvuPnxzgP9xfrq5938csPn7PwHTKSoViCIEAYEAMhmoKsU2mUCWEQqB5xEMIp/HaGQG2G6RSuH9HQ7H34rFrtPbdz4jl6PbwmEsl3QA1mt4vcRKk8dz9eg6IpF7tt9fzGY0gCgafFRFo5Blc5vLhf3eCOj1yNhM5GRMVK0aATxPZoz09YXjkQDmczJgquGQAPp9WwCNBgG027YACgUC6HRsAZRKBDAY2AJoNv/ZnwzA6WScznG3p4UAymXGAEkyXrTFAh8fLAGqagQAyGaZpYsi7bHTNPz8MEj//LxuFPo+UBS8vb0KaLXubrRa7aX0RMLCykwmn0z3+XA4WACcTpCkh9MFAZpmuVXo+mO/w+/HZvNgbblcUCxaSo/Hyck80Yu6XXDcvfVZr79cvMZjuN2U9O9vKAqjZrfbIZ0mV4TUi9Xqz6jddNy//7+e3n8Fhf/Llo2kxi8AQyGRoDkmAhAAAAAASUVORK5CYII="; + const cases: Case[] = [ + { id: "basic-response", body: { input: [{ type: "message", role: "user", content: "Say hello in exactly 3 words." }] } }, + { + id: "assistant-phase", + body: { + input: [ + { type: "message", role: "assistant", phase: "commentary", content: "I should answer with the saved number." }, + { type: "message", role: "assistant", phase: "final_answer", content: "The number is four." }, + { type: "message", role: "user", content: "Repeat only the number." }, + ], + }, + }, + { id: "streaming-response", streaming: true, body: { input: [{ type: "message", role: "user", content: "Count from 1 to 5." }] } }, + { + id: "system-prompt", + body: { + input: [ + { type: "message", role: "system", content: "You are a pirate. Always respond in pirate speak." }, + { type: "message", role: "user", content: "Say hello." }, + ], + }, + }, + { + id: "tool-calling", + outputType: "function_call", + body: { + input: [{ type: "message", role: "user", content: "What's the weather like in San Francisco?" }], + tools: [{ + type: "function", + name: "get_weather", + description: "Get the current weather for a location", + parameters: { type: "object", properties: { location: { type: "string", description: "The city and state, e.g. San Francisco, CA" } }, required: ["location"] }, + }], + }, + }, + { + id: "image-input", + body: { + input: [{ + type: "message", + role: "user", + content: [ + { type: "input_text", text: "What do you see in this image? Answer in one sentence." }, + { type: "input_image", image_url: RED_HEART }, + ], + }], + }, + }, + { + id: "multi-turn", + body: { + input: [ + { type: "message", role: "user", content: "My name is Alice." }, + { type: "message", role: "assistant", content: "Hello Alice! Nice to meet you. How can I help you today?" }, + { type: "message", role: "user", content: "What is my name?" }, + ], + }, + }, + ]; + + let open: OpenAI; + beforeAll(() => { + open = new OpenAI({ baseURL: h.base, apiKey: h.keys.lab, maxRetries: 0, timeout: 20_000, fetch: wire(offSpec, "openresponses") }); + }); + + for (const c of cases) { + test(c.id, async () => { + const ai = open; + const body = { model: "gpt-lab", ...c.body, input: c.body.input } as OpenAI.Responses.ResponseCreateParams; + let response: OpenAI.Responses.Response | undefined; + if (c.streaming) { + const types: string[] = []; + for await (const ev of await ai.responses.create({ ...body, stream: true } as OpenAI.Responses.ResponseCreateParamsStreaming)) { + types.push(ev.type); + if (ev.type === "response.completed") response = ev.response; + } + expect(types.length).toBeGreaterThan(0); + } else { + response = await ai.responses.create({ ...body, stream: false } as OpenAI.Responses.ResponseCreateParamsNonStreaming); + } + expect(response?.output.length ?? 0).toBeGreaterThan(0); + if (c.outputType) expect(response?.output.some((o) => o.type === c.outputType)).toBe(true); + else expect(response?.status).toBe("completed"); + }); + } +}); + describe("completions and embeddings", () => { test("legacy completions grow on from the text, and meet the suffix", async () => { const n = (await heard()).length; diff --git a/hives/openai-server/test/lookup-bee.ts b/hives/openai-server/test/lookup-bee.ts index 70edcfcc..dcb41d04 100644 --- a/hives/openai-server/test/lookup-bee.ts +++ b/hives/openai-server/test/lookup-bee.ts @@ -1,5 +1,5 @@ -// An attendant for the end-to-end tests: one tool, `lookup`, that always -// finds what it is asked for. +// An attendant for the end-to-end tests: one tool, `lookup`, that finds +// what it is asked for, and fails to find "nothing". import { Bee, Chi, Role } from "../../../thrum-clients/ts/index.ts"; @@ -11,7 +11,8 @@ const bee = new Bee({ }); bee.on(Chi.tendrilReach, (t) => { const q = (t.args as { q?: string } | undefined)?.q ?? ""; - bee.send({ chi: "tendril-result", callId: t.callId, ...(t.sid ? { sid: t.sid } : {}), output: `found ${q}` }); + const found = q === "nothing" ? { output: "nothing found", isError: true } : { output: `found ${q}` }; + bee.send({ chi: "tendril-result", callId: t.callId, ...(t.sid ? { sid: t.sid } : {}), ...found }); }); await bee.start(); console.log("lookup nestled"); diff --git a/hives/openai-server/test/spec.ts b/hives/openai-server/test/spec.ts new file mode 100644 index 00000000..ef44f305 --- /dev/null +++ b/hives/openai-server/test/spec.ts @@ -0,0 +1,174 @@ +// What OpenAI's spec and the Open Responses spec say, as checks. +// +// The specs are the vendored ones in spec/ (spec/fetch.ts). A wire is +// checked by its route: a request body against the spec its client wrote +// to, OpenAI's unless said, since the two ask different things of a +// request (Open Responses a `type` on every message, OpenAI a `detail` on +// every image and `strict` on every function); a JSON answer against the +// schema its status names; and each event of a stream against the event +// schema of its route, a Responses event against both specs by its `type`. +// +// An `mcp_call` item is OpenAI's, and OpenAI's clients read it, so it is +// kept, though Open Responses wants an item it does not define named with +// an implementor's prefix; against Open Responses it is set aside. + +import Ajv2020 from "ajv/dist/2020.js"; +import openai from "../spec/openai.json" with { type: "json" }; +import openresponses from "../spec/openresponses.json" with { type: "json" }; + +const ajv = new Ajv2020({ strict: false, validateFormats: false, allErrors: true }); +ajv.addSchema(openai as object, "openai"); +ajv.addSchema(openresponses as object, "openresponses"); + +type Spec = "openai" | "openresponses"; + +const pointer = (...parts: string[]) => parts.map((p) => encodeURIComponent(p.replace(/~/g, "~0").replace(/\//g, "~1"))).join("/"); + +function against(spec: Spec, ref: string, value: unknown): string[] { + const validate = ajv.getSchema(`${spec}#${ref}`); + if (!validate) return [`${spec} has no ${decodeURIComponent(ref)}`]; + if (validate(value)) return []; + return (validate.errors ?? []).map((e) => `${spec} ${decodeURIComponent(ref)}: ${e.instancePath || "/"} ${e.message}${e.params ? ` ${JSON.stringify(e.params)}` : ""}`); +} + +export function schema(spec: Spec, name: string, value: unknown): string[] { + return against(spec, `/components/schemas/${pointer(name)}`, value); +} + +const ROUTES: Array<[RegExp, string]> = [ + [/^\/chat\/completions$/, "/chat/completions"], + [/^\/completions$/, "/completions"], + [/^\/embeddings$/, "/embeddings"], + [/^\/models$/, "/models"], + [/^\/models\/[^/]+$/, "/models/{model}"], + [/^\/responses$/, "/responses"], + [/^\/responses\/[^/]+$/, "/responses/{response_id}"], +]; + +export function routeOf(url: string): string | undefined { + const path = new URL(url).pathname.replace(/^\/v1/, ""); + return ROUTES.find(([re]) => re.test(path))?.[1]; +} + +export function asked(route: string, method: string, body: unknown, spec: Spec = "openai"): string[] { + const op = `/paths/${pointer(route, method.toLowerCase())}`; + if (spec === "openresponses") return route === "/responses" ? schema("openresponses", "CreateResponseBody", body) : []; + return against("openai", `${op}/requestBody/content/${pointer("application/json")}/schema`, body); +} + +const OPENAI_ONLY_ITEMS = new Set(["mcp_call"]); + +function openOnly(value: unknown): unknown { + if (!value || typeof value !== "object") return value; + const v = value as Record; + const response = v.response as Record | undefined; + if (Array.isArray(v.output)) return { ...v, output: v.output.filter((i) => !OPENAI_ONLY_ITEMS.has((i as { type?: string })?.type ?? "")) }; + if (response && Array.isArray(response.output)) return { ...v, response: openOnly(response) }; + return v; +} + +const openAside = (event: Record) => OPENAI_ONLY_ITEMS.has(String((event.item as { type?: string } | undefined)?.type)); + +export function answered(route: string, method: string, status: number, body: unknown): string[] { + const at = status >= 400 ? "ErrorResponse" : undefined; + if (at) return schema("openai", at, body); + const findings = against("openai", `/paths/${pointer(route, method.toLowerCase(), "responses", String(status), "content", "application/json", "schema")}`, body); + if (route.startsWith("/responses") && method.toUpperCase() !== "DELETE") findings.push(...schema("openresponses", "ResponseResource", openOnly(body))); + return findings; +} + +const OPEN_EVENTS: Record = { + "response.created": "ResponseCreatedStreamingEvent", + "response.queued": "ResponseQueuedStreamingEvent", + "response.in_progress": "ResponseInProgressStreamingEvent", + "response.completed": "ResponseCompletedStreamingEvent", + "response.failed": "ResponseFailedStreamingEvent", + "response.incomplete": "ResponseIncompleteStreamingEvent", + "response.output_item.added": "ResponseOutputItemAddedStreamingEvent", + "response.output_item.done": "ResponseOutputItemDoneStreamingEvent", + "response.content_part.added": "ResponseContentPartAddedStreamingEvent", + "response.content_part.done": "ResponseContentPartDoneStreamingEvent", + "response.output_text.delta": "ResponseOutputTextDeltaStreamingEvent", + "response.output_text.done": "ResponseOutputTextDoneStreamingEvent", + "response.output_text.annotation.added": "ResponseOutputTextAnnotationAddedStreamingEvent", + "response.refusal.delta": "ResponseRefusalDeltaStreamingEvent", + "response.refusal.done": "ResponseRefusalDoneStreamingEvent", + "response.reasoning.delta": "ResponseReasoningDeltaStreamingEvent", + "response.reasoning.done": "ResponseReasoningDoneStreamingEvent", + "response.reasoning_summary_part.added": "ResponseReasoningSummaryPartAddedStreamingEvent", + "response.reasoning_summary_part.done": "ResponseReasoningSummaryPartDoneStreamingEvent", + "response.reasoning_summary_text.delta": "ResponseReasoningSummaryDeltaStreamingEvent", + "response.reasoning_summary_text.done": "ResponseReasoningSummaryDoneStreamingEvent", + "response.function_call_arguments.delta": "ResponseFunctionCallArgumentsDeltaStreamingEvent", + "response.function_call_arguments.done": "ResponseFunctionCallArgumentsDoneStreamingEvent", + error: "ErrorStreamingEvent", +}; + +const schemas = (openai as { components: { schemas: Record> } }).components.schemas; + +const OPENAI_EVENTS: Record = Object.fromEntries( + ((schemas.ResponseStreamEvent.anyOf ?? schemas.ResponseStreamEvent.oneOf ?? []) as Array<{ $ref?: string }>) + .map((m) => m.$ref?.split("/").pop() ?? "") + .flatMap((name) => { + const type = (schemas[name]?.properties as Record | undefined)?.type; + const tag = type?.const ?? type?.enum?.[0]; + return tag ? [[tag, name]] : []; + }), +); + +export function streamed(route: string, event: Record): string[] { + if (route === "/chat/completions") return "error" in event ? schema("openai", "ErrorResponse", event) : schema("openai", "CreateChatCompletionStreamResponse", event); + if (route === "/completions") return "error" in event ? schema("openai", "ErrorResponse", event) : schema("openai", "CreateCompletionResponse", event); + const own = OPENAI_EVENTS[String(event.type)]; + const findings = own ? schema("openai", own, event) : [`openai has no Responses event of type ${String(event.type)}`]; + const open = OPEN_EVENTS[String(event.type)]; + if (open && !openAside(event)) findings.push(...schema("openresponses", open, openOnly(event))); + return findings; +} + +export function eventsOf(text: string): Array<{ event?: string; data: string }> { + return text + .split(/\n\n/) + .map((block) => block.split("\n").filter((l) => !l.startsWith(":"))) + .filter((lines) => lines.some((l) => l.startsWith("data:"))) + .map((lines) => ({ + event: lines.find((l) => l.startsWith("event:"))?.slice(6).trim(), + data: lines.filter((l) => l.startsWith("data:")).map((l) => l.slice(5).replace(/^ /, "")).join("\n"), + })); +} + +export function wire(found: string[], askedOf: Spec = "openai"): typeof fetch { + return (async (input: string | URL | Request, init?: RequestInit) => { + const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; + const method = init?.method ?? (input instanceof Request ? input.method : "GET"); + const route = routeOf(url); + if (route && typeof init?.body === "string" && init.body.length > 0) { + found.push(...asked(route, method, JSON.parse(init.body), askedOf).map((f) => `${method} ${route} asked: ${f}`)); + } + const res = await fetch(input, init); + if (!route || !res.body) return res; + const type = res.headers.get("content-type") ?? ""; + const heard = (text: string) => { + if (type.includes("text/event-stream")) { + for (const { data } of eventsOf(text)) { + if (data === "[DONE]") continue; + found.push(...streamed(route, JSON.parse(data)).map((f) => `${method} ${route} streamed: ${f}`)); + } + } else if (type.includes("application/json") && text.length > 0) { + found.push(...answered(route, method, res.status, JSON.parse(text)).map((f) => `${method} ${route} ${res.status}: ${f}`)); + } + }; + const decoder = new TextDecoder(); + let text = ""; + const body = res.body.pipeThrough(new TransformStream({ + transform(chunk, out) { + text += decoder.decode(chunk, { stream: true }); + out.enqueue(chunk); + }, + flush() { + heard(text + decoder.decode()); + }, + })); + return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers }); + }) as typeof fetch; +} diff --git a/hives/openai-server/test/upstream.ts b/hives/openai-server/test/upstream.ts index c9478f70..450a5a8e 100644 --- a/hives/openai-server/test/upstream.ts +++ b/hives/openai-server/test/upstream.ts @@ -4,12 +4,14 @@ // // It lists two chat models and an embedding model, records every request // it is sent, and answers by what the last user turn says: ONE calls -// readFile once, PAR calls it twice at once, LOOKUP calls lookup, SLOW -// streams twenty ticks slowly, LEN stops for length, FAIL answers 500. -// Anything else is echoed back, or, after tool answers, the answers are. -// It refuses a conversation with a tool call nobody answered, as OpenAI -// does. /embeddings scores each text by its length and its vowels, and -// /completions completes a prompt with a marker and its suffix. +// readFile once, PAR calls it twice at once, LOOKUP calls lookup, NOTFOUND +// calls it for nothing, which it fails to find, a question about the +// weather calls the weather tool it was offered, SLOW streams twenty ticks +// slowly, LEN stops for length, FAIL answers 500. Anything else is echoed +// back, or, after tool answers, the answers are. It refuses a conversation +// with a tool call nobody answered, as OpenAI does. /embeddings scores +// each text by its length and its vowels, and /completions completes a +// prompt with a marker and its suffix. import { spawn } from "node:child_process"; import { createServer, type Server } from "node:http"; @@ -111,9 +113,16 @@ export async function serve(at = 0): Promise<{ url: string; heard: Heard[]; abor } else if (tooling && said.includes("ONE")) { call(0, "call_one", "readFile", '{"path":"x"}'); res.write(mk({ choices: [{ index: 0, delta: {}, finish_reason: "tool_calls" }] })); + } else if (tooling && said.includes("NOTFOUND")) { + call(0, "call_none", "lookup", '{"q":"nothing"}'); + res.write(mk({ choices: [{ index: 0, delta: {}, finish_reason: "tool_calls" }] })); } else if (tooling && said.includes("LOOKUP")) { call(0, "call_look", "lookup", '{"q":"bees"}'); res.write(mk({ choices: [{ index: 0, delta: {}, finish_reason: "tool_calls" }] })); + } else if (tooling && /weather/i.test(said) && body.tools?.length > 0) { + const tool = body.tools.find((t: any) => /weather/i.test(t.function?.name ?? "")) ?? body.tools[0]; + call(0, "call_weather", tool.function.name, '{"location":"San Francisco, CA"}'); + res.write(mk({ choices: [{ index: 0, delta: {}, finish_reason: "tool_calls" }] })); } else if (said.includes("SLOW")) { for (let i = 0; i < 20 && !gone; i++) { res.write(mk({ choices: [{ index: 0, delta: { content: `tick${i} ` } }] }));