From 8d4e08cd23e796a2dee564eef221112f03c96ed5 Mon Sep 17 00:00:00 2001
From: dpiet-oai <326640584+dpiet-oai@users.noreply.github.com>
Date: Sun, 25 Oct 2026 20:27:54 +0000
Subject: [PATCH] feat(api): expand Live Decision item and question types
Castiron-Internal-PR: https://github.com/openai/openai-python-internal/pull/341
Castiron-Source-SHA: c49eeb71d31a1381909f69abc6dec247aa466779
Castiron-Public-Base-SHA: 718aee979a9c334d37302aeff21cee6cbff4d43c
---
.castiron.stats.yml | 14 +-
.../castiron-custom-code-comment.yml | 23 +-
api.md | 6 -
api_reference/openapi.transformed.yml | 925 ++++++++--
scripts/castiron/custom_code_policy.py | 39 +-
.../castiron/fixtures/github_publisher.cjs | 33 +-
scripts/castiron/generated-files.json | 186 +-
scripts/castiron/test_custom_code_github.py | 10 +-
scripts/castiron/test_custom_code_policy.py | 41 +-
.../test_custom_code_review_revocation.py | 29 +-
src/openai/__init__.py | 3 +-
src/openai/_client.py | 302 ++--
src/openai/resources/audio/transcriptions.py | 601 ++++--
src/openai/resources/audio/translations.py | 74 +-
.../beta/agents/sessions/sessions.py | 228 +--
.../resources/beta/threads/runs/runs.py | 1608 ++++++++---------
src/openai/resources/beta/threads/threads.py | 412 ++---
.../resources/chat/completions/completions.py | 438 +++--
src/openai/resources/embeddings.py | 4 +-
src/openai/resources/images.py | 72 +-
src/openai/resources/live/api.md | 12 +
src/openai/resources/live/forks.py | 6 +-
src/openai/resources/live/live.py | 6 +-
src/openai/resources/live/sideband.py | 6 +-
src/openai/resources/responses/api.md | 2 +-
src/openai/resources/responses/responses.py | 1277 +++++++------
..._response_tool_search_output_item_param.py | 7 +-
...nse_tool_search_output_item_param_param.py | 7 +-
src/openai/types/beta/beta_tool.py | 7 +-
src/openai/types/beta/beta_tool_param.py | 7 +-
.../types/decision_input_image_param.py | 7 +-
.../types/decision_input_message_param.py | 2 +-
src/openai/types/decision_input_text_param.py | 7 +-
.../fine_tuning_job_integration.py | 2 +
src/openai/types/image_edit_params.py | 5 +-
src/openai/types/image_generate_params.py | 7 +-
src/openai/types/image_model.py | 2 +
src/openai/types/live/__init__.py | 20 +
.../types/live/decision_assistant_message.py | 46 +
.../live/decision_assistant_message_param.py | 45 +
.../types/live/decision_choice_option.py | 15 +
.../live/decision_choice_option_param.py | 14 +
.../types/live/decision_developer_message.py | 21 +
.../live/decision_developer_message_param.py | 22 +
src/openai/types/live/decision_input_text.py | 14 +
.../types/live/decision_input_text_param.py | 14 +
.../types/live/decision_item_create_event.py | 141 +-
.../live/decision_item_create_event_param.py | 137 +-
.../types/live/decision_item_created_event.py | 135 +-
src/openai/types/live/decision_json_object.py | 8 +
.../types/live/decision_json_object_param.py | 10 +
src/openai/types/live/decision_question.py | 139 ++
.../types/live/decision_question_param.py | 136 ++
.../live/decision_stored_assistant_message.py | 45 +
.../live/decision_stored_developer_message.py | 20 +
.../live/decision_stored_system_message.py | 20 +
.../live/decision_stored_user_message.py | 59 +
.../types/live/decision_system_message.py | 21 +
.../live/decision_system_message_param.py | 22 +
src/openai/types/live/decision_trigger.py | 86 +-
.../types/live/decision_trigger_param.py | 80 +-
.../types/live/decision_user_message.py | 60 +
.../types/live/decision_user_message_param.py | 58 +
.../types/live/decisions_delegation_config.py | 81 +-
.../live/decisions_delegation_config_param.py | 78 +-
.../decisions_delegation_update_config.py | 81 +-
...ecisions_delegation_update_config_param.py | 78 +-
.../response_tool_search_output_item_param.py | 7 +-
...nse_tool_search_output_item_param_param.py | 7 +-
src/openai/types/responses/tool.py | 7 +-
src/openai/types/responses/tool_param.py | 9 +-
src/openai/types/webhooks/__init__.py | 4 +-
.../live_call_incoming_webhook_event.py | 3 +-
.../types/webhooks/unwrap_webhook_event.py | 4 +-
tests/api_resources/live/test_sessions.py | 24 +-
tests/api_resources/test_live.py | 24 +-
tests/lib/test_assistants.py | 18 +-
77 files changed, 5087 insertions(+), 3143 deletions(-)
create mode 100644 src/openai/types/live/decision_assistant_message.py
create mode 100644 src/openai/types/live/decision_assistant_message_param.py
create mode 100644 src/openai/types/live/decision_choice_option.py
create mode 100644 src/openai/types/live/decision_choice_option_param.py
create mode 100644 src/openai/types/live/decision_developer_message.py
create mode 100644 src/openai/types/live/decision_developer_message_param.py
create mode 100644 src/openai/types/live/decision_input_text.py
create mode 100644 src/openai/types/live/decision_input_text_param.py
create mode 100644 src/openai/types/live/decision_json_object.py
create mode 100644 src/openai/types/live/decision_json_object_param.py
create mode 100644 src/openai/types/live/decision_question.py
create mode 100644 src/openai/types/live/decision_question_param.py
create mode 100644 src/openai/types/live/decision_stored_assistant_message.py
create mode 100644 src/openai/types/live/decision_stored_developer_message.py
create mode 100644 src/openai/types/live/decision_stored_system_message.py
create mode 100644 src/openai/types/live/decision_stored_user_message.py
create mode 100644 src/openai/types/live/decision_system_message.py
create mode 100644 src/openai/types/live/decision_system_message_param.py
create mode 100644 src/openai/types/live/decision_user_message.py
create mode 100644 src/openai/types/live/decision_user_message_param.py
diff --git a/.castiron.stats.yml b/.castiron.stats.yml
index ec8370d25f..9940c0a2f8 100644
--- a/.castiron.stats.yml
+++ b/.castiron.stats.yml
@@ -1,8 +1,8 @@
schema_version: 1
-generation_id: c6c71409-c9d1-487b-ad35-c8973d3274a6
-openapi_spec_hash: 23f0bfa58ad53fef090bea6a72a05dda
-openapi_transformed_spec_hash: 39f2336a30336863627b56624b390f24
-config_hash: 249b5f41fe1b916955299cea75cddfbf
-codegen_sha: 73e15aa409d55f8731c775cab5a85c9e93d66b3c
-codegen_hash: 166545ad5fafe31085bb865842a68c605eea009ccfec4e4247b851e46d7c34fb
-public_codegen_sha: 74fb1f948524997714d02fb52f387e0ab93ce338
+generation_id: a5a7ff8f-541f-4e46-88c8-51581e690980
+openapi_spec_hash: fb762e4e737fb2210a01948c7cf70c31
+openapi_transformed_spec_hash: 60911088041eda7d04c1a205c2f337a9
+config_hash: d356dda7ff9ca3fbc614107eb546de9f
+codegen_sha: 29ea9cdfc0d23a284e49573298b06f55482ce078
+codegen_hash: 4ff0d4017ca05d7692d4bcdc2e471f62bcb681f9e920035d5b7b42e612c37d74
+public_codegen_sha: 9b7555d4163e7448417845732af4bb31f0f51fa7
diff --git a/.github/workflows/castiron-custom-code-comment.yml b/.github/workflows/castiron-custom-code-comment.yml
index c0f9e37ee4..2157f6a87a 100644
--- a/.github/workflows/castiron-custom-code-comment.yml
+++ b/.github/workflows/castiron-custom-code-comment.yml
@@ -29,13 +29,6 @@ jobs:
pull-requests: read
statuses: write
steps:
- # Execute only the helper belonging to this immutable workflow revision.
- - name: Check out the trusted review policy
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.workflow_sha }}
- persist-credentials: false
-
- name: Re-evaluate current PR and queue after review changes
env:
GH_TOKEN: ${{ github.token }}
@@ -70,12 +63,26 @@ jobs:
return sha;
}
async function requiresHuman(pr, mainSha) {
+ if (!/^[0-9a-f]{40}$/.test(mainSha || '')) throw new Error('Invalid authenticated main');
const path = require('node:path');
const fs = require('node:fs');
const root = fs.mkdtempSync(path.join(process.env.RUNNER_TEMP, 'castiron-review-'));
try {
+ // Bind executable policy and its dependency to the authenticated
+ // main snapshot for this decision, including after a retry.
+ for (const name of ['custom_code_policy.py', 'custom_code_report.py']) {
+ const {data: file} = await github.rest.repos.getContent({
+ ...context.repo, path: `scripts/castiron/${name}`, ref: mainSha,
+ });
+ if (file.type !== 'file' || file.encoding !== 'base64' ||
+ !Number.isSafeInteger(file.size) || file.size <= 0 || file.size > 1048576 ||
+ typeof file.content !== 'string') throw new Error('Invalid trusted policy file');
+ const content = Buffer.from(file.content, 'base64');
+ if (content.length !== file.size) throw new Error('Invalid trusted policy content');
+ fs.writeFileSync(path.join(root, name), content, {flag: 'wx'});
+ }
const result = await exec.getExecOutput('python3', ['-I',
- 'scripts/castiron/custom_code_policy.py', 'review-required',
+ path.join(root, 'custom_code_policy.py'), 'review-required',
'--repository', repo, '--repo', path.join(root, 'objects.git'),
'--base', pr.base.sha, '--head', pr.head.sha, '--main', mainSha], {silent: true});
const decision = JSON.parse(result.stdout);
diff --git a/api.md b/api.md
index 9430f4789c..a115e0a0e2 100644
--- a/api.md
+++ b/api.md
@@ -1125,12 +1125,6 @@ Methods:
- client.beta.chatkit.threads.list(\*\*params) -> SyncConversationCursorPage[ChatKitThread]
- client.beta.chatkit.threads.delete(thread_id) -> ThreadDeleteResponse
- client.beta.chatkit.threads.list_items(thread_id, \*\*params) -> SyncConversationCursorPage[Data]
-
-
-
-
-
-## [Realtime](docs/beta-realtime-api.md)
## Assistants
diff --git a/api_reference/openapi.transformed.yml b/api_reference/openapi.transformed.yml
index 7f9682c8a2..1233ae8aa9 100644
--- a/api_reference/openapi.transformed.yml
+++ b/api_reference/openapi.transformed.yml
@@ -44108,12 +44108,22 @@ components:
- chatgpt-image-latest
- dall-e-2
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.
dall-e-2:
message: This model was retired on May 12, 2026. Use a GPT image model instead.
x-stainless-const: true
x-oaiTypeLabel: string
example: gpt-image-1.5
- description: The GPT image model to use for image editing (`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`, or `chatgpt-image-latest`).
+ description: |
+ The GPT image model to use for image editing
+ (`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`, or `chatgpt-image-latest`).
+
+ `gpt-image-1` was shut down on October 23, 2026. Use
+ `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` instead.
nullable: true
n:
type:
@@ -44251,6 +44261,8 @@ components:
- dall-e-2
- dall-e-3
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.
dall-e-2:
message: This model was retired on May 12, 2026. Use a GPT image model instead.
dall-e-3:
@@ -44258,7 +44270,15 @@ components:
x-stainless-nominal: false
x-oaiTypeLabel: string
example: gpt-image-2.5-flare
- description: The GPT image model to use for image generation. Specify a model explicitly. Supported models include `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`, and `chatgpt-image-latest`.
+ description: |
+ The GPT image model to use for image generation. Specify a model explicitly.
+ Supported models include `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`, and `chatgpt-image-latest`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use
+ `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` instead.
nullable: true
n:
type:
@@ -46606,11 +46626,21 @@ components:
- gpt-image-1
- gpt-image-1-mini
- chatgpt-image-latest
+ 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.
- type: 'null'
x-oaiTypeLabel: string
default: gpt-image-2.5-sunburst
example: gpt-image-2.5-sunburst
- description: The GPT image model to use for image editing, including `gpt-image-2`, its dated snapshot `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`. Defaults to `gpt-image-2.5-sunburst`.
+ description: |
+ The GPT image model to use for image editing, including `gpt-image-2`, its dated
+ snapshot `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`. Defaults to `gpt-image-2.5-sunburst`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use
+ `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` instead.
images:
type: array
minItems: 1
@@ -46661,7 +46691,7 @@ components:
- high
- low
- type: 'null'
- 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` and `gpt-image-1.5`; `gpt-image-1-mini` supports only `low`. For `gpt-image-2`, omit this parameter. Defaults to `low` on supported models.
+ 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.
size:
anyOf:
- type: string
@@ -50376,14 +50406,20 @@ components:
- gpt-image-2.5-flare-2026-09-08
- gpt-image-1.5
- chatgpt-image-latest
+ 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`,
- `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ The image generation model to use. One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
- default: gpt-image-1
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use
+ `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` instead.
+ default: gpt-image-2
quality:
type: string
enum:
@@ -79092,6 +79128,73 @@ components:
required:
- type
- responses
+ LiveDecisionInputTextParam:
+ type: object
+ properties:
+ type:
+ default: input_text
+ x-stainless-const: true
+ type: string
+ enum:
+ - input_text
+ text:
+ description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ required:
+ - type
+ - text
+ LiveDetailEnum:
+ type: string
+ enum:
+ - low
+ - high
+ - auto
+ - original
+ LiveDecisionInputImageParam:
+ type: object
+ properties:
+ type:
+ default: input_image
+ x-stainless-const: true
+ type: string
+ enum:
+ - input_image
+ image_url:
+ description: A base64-encoded image data URL or a publicly accessible HTTP(S) image URL.
+ type: string
+ maxLength: 20971520
+ pattern: ^(data:|https?://)
+ detail:
+ anyOf:
+ - description: The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ $ref: '#/components/schemas/LiveDetailEnum'
+ - type: 'null'
+ required:
+ - type
+ - image_url
+ LiveDecisionJsonObject:
+ type: object
+ additionalProperties: true
+ x-stainless-model: live.decision_json_object
+ LiveDecisionInputJsonParam:
+ type: object
+ properties:
+ type:
+ default: input_json
+ x-stainless-const: true
+ type: string
+ enum:
+ - input_json
+ data:
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionJsonObject'
+ - type: array
+ items:
+ $ref: '#/components/schemas/LiveDecisionJsonObject'
+ required:
+ - type
+ - data
LiveDecisionChoiceParam:
type: object
properties:
@@ -79115,13 +79218,30 @@ components:
name:
type: string
instructions:
- type: string
+ anyOf:
+ - type: string
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionInputJsonParam'
+ minItems: 1
+ x-stainless-variantName: parts
+ x-stainless-naming:
+ java:
+ variant_constructor: Parts
choices:
type: array
items:
$ref: '#/components/schemas/LiveDecisionChoiceParam'
minItems: 2
maxItems: 255
+ example:
+ - value: false
+ - value: true
required:
- type
- instructions
@@ -79138,7 +79258,21 @@ components:
name:
type: string
instructions:
- type: string
+ anyOf:
+ - type: string
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionInputJsonParam'
+ minItems: 1
+ x-stainless-variantName: parts
+ x-stainless-naming:
+ java:
+ variant_constructor: Parts
required:
- type
- instructions
@@ -79163,7 +79297,21 @@ components:
name:
type: string
instructions:
- type: string
+ anyOf:
+ - type: string
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionInputJsonParam'
+ minItems: 1
+ x-stainless-variantName: parts
+ x-stainless-naming:
+ java:
+ variant_constructor: Parts
levels:
type: array
items:
@@ -79188,7 +79336,7 @@ components:
description: Native Decision API questions evaluated together, in order.
type: array
items:
- $ref: '#/components/schemas/QuestionParam'
+ $ref: '#/components/schemas/LiveDecisionQuestion'
minItems: 1
maxItems: 64
model:
@@ -79234,7 +79382,7 @@ components:
description: Native Decision API questions evaluated together, in order.
type: array
items:
- $ref: '#/components/schemas/QuestionParam'
+ $ref: '#/components/schemas/LiveDecisionQuestion'
minItems: 1
maxItems: 64
required:
@@ -94589,76 +94737,6 @@ components:
description: The voice used for speech generated by the Live model.
$ref: '#/components/schemas/LiveInitialSessionAudioOutputParam'
required: []
- LiveDecisionsSettingsInputParam-2:
- type: object
- properties:
- questions:
- description: Native Decision API questions evaluated together, in order.
- type: array
- items:
- $ref: '#/components/schemas/QuestionParam'
- minItems: 1
- maxItems: 64
- model:
- type: string
- minLength: 1
- required:
- - questions
- - model
- LiveDecisionsDelegationParam-2:
- type: object
- properties:
- acknowledgement_delay_ms:
- description: Milliseconds to wait before requesting an automatic spoken acknowledgement for a delegation. The model may still speak before this delay. Any commentary or thinking appended to the session cancels all pending acknowledgements, including those for other delegations. Defaults to 400. Updates apply to subsequent delegations.
- type: integer
- minimum: 0
- maximum: 800
- type:
- default: decisions
- x-stainless-const: true
- type: string
- enum:
- - decisions
- decisions:
- $ref: '#/components/schemas/LiveDecisionsSettingsInputParam-2'
- required:
- - type
- - decisions
- LiveDecisionQuestionsInputParam-2:
- description: Questions evaluated using the current transcript and the session's shared Decision items.
- type: object
- properties:
- questions:
- description: Native Decision API questions evaluated together, in order.
- type: array
- items:
- $ref: '#/components/schemas/QuestionParam'
- minItems: 1
- maxItems: 64
- required:
- - questions
- LiveDecisionTriggerInputParam-2:
- type: object
- properties:
- type:
- default: decisions
- x-stainless-const: true
- type: string
- enum:
- - decisions
- event_type:
- type: string
- enum:
- - session.input_transcript.delta
- - session.output_transcript.delta
- decisions:
- description: Questions evaluated using the current transcript and the session's shared Decision items.
- $ref: '#/components/schemas/LiveDecisionQuestionsInputParam-2'
- required:
- - type
- - event_type
- - decisions
- additionalProperties: false
LiveSessionCreateParams:
description: Initial configuration for a Live session, including its model, conversation instructions, audio, and delegated task handling.
type: object
@@ -94765,7 +94843,7 @@ components:
description: Native Decision API questions evaluated together, in order.
type: array
items:
- $ref: '#/components/schemas/QuestionParam'
+ $ref: '#/components/schemas/LiveDecisionQuestion'
minItems: 1
maxItems: 64
required: []
@@ -95109,11 +95187,10 @@ components:
example:
type: decision.create
event_id: decision_1
- LiveDecisionInputTextParam:
+ LiveDecisionUserInputTextParam:
type: object
properties:
type:
- description: The type of the input item. Always `input_text`.
default: input_text
x-stainless-const: true
type: string
@@ -95126,28 +95203,20 @@ components:
required:
- type
- text
- LiveDetailEnum:
- type: string
- enum:
- - low
- - high
- - auto
- - original
- LiveDecisionInputImageParam:
+ LiveDecisionUserInputImageParam:
type: object
properties:
type:
- description: The type of the input item. Always `input_image`.
default: input_image
x-stainless-const: true
type: string
enum:
- input_image
image_url:
- description: An inline image encoded as a data URL.
+ description: A base64-encoded image data URL or a publicly accessible HTTP(S) image URL.
type: string
maxLength: 20971520
- pattern: '^data:'
+ pattern: ^(data:|https?://)
detail:
anyOf:
- description: The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
@@ -95156,7 +95225,7 @@ components:
required:
- type
- image_url
- LiveDecisionInputItemParam:
+ LiveDecisionUserMessageParam:
type: object
properties:
id:
@@ -95187,8 +95256,9 @@ components:
discriminator:
propertyName: type
anyOf:
- - $ref: '#/components/schemas/LiveDecisionInputTextParam'
- - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionUserInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionUserInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionInputJsonParam'
x-stainless-variantName: parts
x-stainless-naming:
java:
@@ -95196,6 +95266,351 @@ components:
required:
- role
- content
+ x-stainless-model: live.decision_user_message
+ LiveDecisionDeveloperMessageParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The unique ID of this message item.
+ type: string
+ - type: 'null'
+ type:
+ default: message
+ x-stainless-const: true
+ type: string
+ enum:
+ - message
+ role:
+ default: developer
+ x-stainless-const: true
+ type: string
+ enum:
+ - developer
+ content:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ x-stainless-variantName: parts
+ required:
+ - role
+ - content
+ x-stainless-model: live.decision_developer_message
+ LiveDecisionSystemMessageParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The unique ID of this message item.
+ type: string
+ - type: 'null'
+ type:
+ default: message
+ x-stainless-const: true
+ type: string
+ enum:
+ - message
+ role:
+ default: system
+ x-stainless-const: true
+ type: string
+ enum:
+ - system
+ content:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ x-stainless-variantName: parts
+ required:
+ - role
+ - content
+ x-stainless-model: live.decision_system_message
+ LiveDecisionOutputTextParam:
+ type: object
+ properties:
+ type:
+ default: output_text
+ x-stainless-const: true
+ type: string
+ enum:
+ - output_text
+ text:
+ description: The text content.
+ type: string
+ maxLength: 10485760
+ required:
+ - type
+ - text
+ LiveDecisionRefusalParam:
+ type: object
+ properties:
+ type:
+ default: refusal
+ x-stainless-const: true
+ type: string
+ enum:
+ - refusal
+ refusal:
+ description: The refusal text.
+ type: string
+ maxLength: 10485760
+ required:
+ - type
+ - refusal
+ LiveMessagePhase:
+ type: string
+ enum:
+ - commentary
+ - final_answer
+ LiveDecisionAssistantMessageParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The unique ID of this message item.
+ type: string
+ - type: 'null'
+ type:
+ default: message
+ x-stainless-const: true
+ type: string
+ enum:
+ - message
+ role:
+ default: assistant
+ x-stainless-const: true
+ type: string
+ enum:
+ - assistant
+ content:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionOutputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionRefusalParam'
+ x-stainless-variantName: parts
+ phase:
+ anyOf:
+ - description: Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend phase on all assistant messages — dropping it can degrade performance. Not used for user messages.
+ $ref: '#/components/schemas/LiveMessagePhase'
+ - type: 'null'
+ required:
+ - role
+ - content
+ x-stainless-model: live.decision_assistant_message
+ LiveFunctionCallItemStatus:
+ type: string
+ enum:
+ - in_progress
+ - completed
+ - incomplete
+ LiveDecisionFunctionCallParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The local Decision item ID.
+ type: string
+ - type: 'null'
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ description: The item type. Always `function_call`.
+ default: function_call
+ x-stainless-const: true
+ type: string
+ enum:
+ - function_call
+ name:
+ type: string
+ minLength: 1
+ maxLength: 128
+ pattern: ^[a-zA-Z0-9_.-]+$
+ namespace:
+ anyOf:
+ - description: The namespace of the function to call.
+ type: string
+ minLength: 1
+ maxLength: 64
+ pattern: ^[a-zA-Z0-9_-]+$
+ - type: 'null'
+ arguments:
+ description: The function arguments as a JSON string.
+ type: string
+ required:
+ - call_id
+ - type
+ - name
+ - arguments
+ LiveDecisionFunctionCallOutputParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The local Decision item ID.
+ type: string
+ - type: 'null'
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ description: The type of the function tool call output. Always `function_call_output`.
+ default: function_call_output
+ x-stainless-const: true
+ type: string
+ enum:
+ - function_call_output
+ output:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ x-stainless-variantName: parts
+ required:
+ - call_id
+ - type
+ - output
+ LiveDecisionCustomToolCallParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The local Decision item ID.
+ type: string
+ - type: 'null'
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ description: The item type. Always `custom_tool_call`.
+ default: custom_tool_call
+ x-stainless-const: true
+ type: string
+ enum:
+ - custom_tool_call
+ name:
+ description: The name of the custom tool to call.
+ type: string
+ minLength: 1
+ maxLength: 64
+ pattern: ^[a-zA-Z0-9_-]+$
+ namespace:
+ anyOf:
+ - description: The namespace of the function to call.
+ type: string
+ minLength: 1
+ maxLength: 64
+ pattern: ^[a-zA-Z0-9_-]+$
+ - type: 'null'
+ input:
+ description: The input to the custom tool call.
+ type: string
+ required:
+ - call_id
+ - type
+ - name
+ - input
+ LiveDecisionCustomToolCallOutputParam:
+ type: object
+ properties:
+ id:
+ anyOf:
+ - description: The local Decision item ID.
+ type: string
+ - type: 'null'
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ default: custom_tool_call_output
+ x-stainless-const: true
+ type: string
+ enum:
+ - custom_tool_call_output
+ output:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ x-stainless-variantName: parts
+ required:
+ - call_id
+ - type
+ - output
+ LiveDecisionInputItemParam:
+ discriminator:
+ propertyName: type
+ x-oai-default-discriminator-value: message
+ anyOf:
+ - discriminator:
+ propertyName: role
+ properties:
+ type:
+ type: string
+ enum:
+ - message
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionUserMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionDeveloperMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionSystemMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionAssistantMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionFunctionCallParam'
+ - $ref: '#/components/schemas/LiveDecisionFunctionCallOutputParam'
+ - $ref: '#/components/schemas/LiveDecisionCustomToolCallParam'
+ - $ref: '#/components/schemas/LiveDecisionCustomToolCallOutputParam'
LiveDecisionItemCreateParam:
description: Append an input item for future decisions without starting an evaluation or changing Live voice context.
example:
@@ -96192,11 +96607,10 @@ components:
output_tokens_details:
reasoning_tokens: 0
total_tokens: 42
- LiveDecisionStoredInputItemParam:
+ LiveDecisionStoredUserMessageParam:
type: object
properties:
id:
- description: The ID of the stored Decision input item.
type: string
type:
default: message
@@ -96221,16 +96635,305 @@ components:
discriminator:
propertyName: type
anyOf:
- - $ref: '#/components/schemas/LiveDecisionInputTextParam'
- - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionUserInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionUserInputImageParam'
+ - $ref: '#/components/schemas/LiveDecisionInputJsonParam'
x-stainless-variantName: parts
x-stainless-naming:
java:
variant_constructor: DecisionItemCreatedEventItemContentItems
required:
+ - role
+ - content
- id
+ x-stainless-model: live.decision_stored_user_message
+ LiveDecisionStoredDeveloperMessageParam:
+ type: object
+ properties:
+ id:
+ type: string
+ type:
+ default: message
+ x-stainless-const: true
+ type: string
+ enum:
+ - message
+ role:
+ default: developer
+ x-stainless-const: true
+ type: string
+ enum:
+ - developer
+ content:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ x-stainless-variantName: parts
+ required:
+ - role
+ - content
+ - id
+ x-stainless-model: live.decision_stored_developer_message
+ LiveDecisionStoredSystemMessageParam:
+ type: object
+ properties:
+ id:
+ type: string
+ type:
+ default: message
+ x-stainless-const: true
+ type: string
+ enum:
+ - message
+ role:
+ default: system
+ x-stainless-const: true
+ type: string
+ enum:
+ - system
+ content:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ x-stainless-variantName: parts
+ required:
+ - role
+ - content
+ - id
+ x-stainless-model: live.decision_stored_system_message
+ LiveDecisionStoredAssistantMessageParam:
+ type: object
+ properties:
+ id:
+ type: string
+ type:
+ default: message
+ x-stainless-const: true
+ type: string
+ enum:
+ - message
+ role:
+ default: assistant
+ x-stainless-const: true
+ type: string
+ enum:
+ - assistant
+ content:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionOutputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionRefusalParam'
+ x-stainless-variantName: parts
+ phase:
+ anyOf:
+ - description: Labels an `assistant` message as intermediate commentary (`commentary`) or the final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when sending follow-up requests, preserve and resend phase on all assistant messages — dropping it can degrade performance. Not used for user messages.
+ $ref: '#/components/schemas/LiveMessagePhase'
+ - type: 'null'
+ required:
- role
- content
+ - id
+ x-stainless-model: live.decision_stored_assistant_message
+ LiveDecisionStoredFunctionCallParam:
+ type: object
+ properties:
+ id:
+ type: string
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ description: The item type. Always `function_call`.
+ default: function_call
+ x-stainless-const: true
+ type: string
+ enum:
+ - function_call
+ name:
+ type: string
+ minLength: 1
+ maxLength: 128
+ pattern: ^[a-zA-Z0-9_.-]+$
+ namespace:
+ anyOf:
+ - description: The namespace of the function to call.
+ type: string
+ minLength: 1
+ maxLength: 64
+ pattern: ^[a-zA-Z0-9_-]+$
+ - type: 'null'
+ arguments:
+ description: The function arguments as a JSON string.
+ type: string
+ required:
+ - call_id
+ - type
+ - name
+ - arguments
+ - id
+ LiveDecisionStoredFunctionCallOutputParam:
+ type: object
+ properties:
+ id:
+ type: string
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ description: The type of the function tool call output. Always `function_call_output`.
+ default: function_call_output
+ x-stainless-const: true
+ type: string
+ enum:
+ - function_call_output
+ output:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ x-stainless-variantName: parts
+ required:
+ - call_id
+ - type
+ - output
+ - id
+ LiveDecisionStoredCustomToolCallParam:
+ type: object
+ properties:
+ id:
+ type: string
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ description: The item type. Always `custom_tool_call`.
+ default: custom_tool_call
+ x-stainless-const: true
+ type: string
+ enum:
+ - custom_tool_call
+ name:
+ description: The name of the custom tool to call.
+ type: string
+ minLength: 1
+ maxLength: 64
+ pattern: ^[a-zA-Z0-9_-]+$
+ namespace:
+ anyOf:
+ - description: The namespace of the function to call.
+ type: string
+ minLength: 1
+ maxLength: 64
+ pattern: ^[a-zA-Z0-9_-]+$
+ - type: 'null'
+ input:
+ description: The input to the custom tool call.
+ type: string
+ required:
+ - call_id
+ - type
+ - name
+ - input
+ - id
+ LiveDecisionStoredCustomToolCallOutputParam:
+ type: object
+ properties:
+ id:
+ type: string
+ call_id:
+ description: The unique ID of the function tool call generated by the model.
+ type: string
+ minLength: 1
+ maxLength: 64
+ status:
+ anyOf:
+ - $ref: '#/components/schemas/LiveFunctionCallItemStatus'
+ - type: 'null'
+ type:
+ default: custom_tool_call_output
+ x-stainless-const: true
+ type: string
+ enum:
+ - custom_tool_call_output
+ output:
+ anyOf:
+ - description: The text input to the model.
+ type: string
+ maxLength: 10485760
+ - type: array
+ items:
+ discriminator:
+ propertyName: type
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionInputTextParam'
+ - $ref: '#/components/schemas/LiveDecisionInputImageParam'
+ x-stainless-variantName: parts
+ required:
+ - call_id
+ - type
+ - output
+ - id
+ LiveDecisionStoredInputItemParam:
+ discriminator:
+ propertyName: type
+ x-oai-default-discriminator-value: message
+ anyOf:
+ - discriminator:
+ propertyName: role
+ properties:
+ type:
+ type: string
+ enum:
+ - message
+ anyOf:
+ - $ref: '#/components/schemas/LiveDecisionStoredUserMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredDeveloperMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredSystemMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredAssistantMessageParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredFunctionCallParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredFunctionCallOutputParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredCustomToolCallParam'
+ - $ref: '#/components/schemas/LiveDecisionStoredCustomToolCallOutputParam'
LiveDecisionItemCreated:
description: An input item was appended for future decisions.
example:
@@ -98100,14 +98803,20 @@ components:
- gpt-image-2.5-flare-2026-09-08
- gpt-image-1.5
- chatgpt-image-latest
+ 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`,
- `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ The image generation model to use. One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
- default: gpt-image-1
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use
+ `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare` instead.
+ default: gpt-image-2
quality:
type: string
enum:
diff --git a/scripts/castiron/custom_code_policy.py b/scripts/castiron/custom_code_policy.py
index 59314c434c..6f26b05ec8 100755
--- a/scripts/castiron/custom_code_policy.py
+++ b/scripts/castiron/custom_code_policy.py
@@ -189,10 +189,14 @@ def has_human_approval(reviews: list[dict[str, Any]], author: str, head: str) ->
)
-def require_human_policy_review(repository: str, head: str) -> int:
+def require_human_policy_review(repository: str, head: str, number: int | None = None) -> int:
"""Only live, exact-head human reviews authorize a next policy activation/update."""
root = f"repos/{repository}"
- pulls = report.api("GET", f"{root}/commits/{head}/pulls?per_page=100")
+ pulls = (
+ [{"number": number}]
+ if number is not None
+ else report.api("GET", f"{root}/commits/{head}/pulls?per_page=100")
+ )
current: list[dict[str, Any]] = []
for item in pulls:
pull = report.api("GET", f"{root}/pulls/{item['number']}")
@@ -285,6 +289,7 @@ def select_policy(
authenticated_main: str,
*,
pull_heads: list[str] | None = None,
+ pull_numbers: dict[str, int] | None = None,
) -> dict[str, Any]:
"""The trusted selector runs before checking out any pinned executable code."""
base, head, authenticated_main = map(report.require_sha, (base, head, authenticated_main))
@@ -342,7 +347,9 @@ def select_policy(
) != {POLICY.encode()}:
raise ValueError("each next policy activation or increase must be policy-only")
if requires_human_policy_review(repo, repository, base, candidate, authenticated_main):
- number = require_human_policy_review(repository, candidate)
+ number = require_human_policy_review(
+ repository, candidate, pull_numbers[candidate] if pull_numbers is not None else None
+ )
policy_reviews.append({"number": number, "head_sha": candidate})
return {
"schema_version": SELECTION_RECEIPT_VERSION,
@@ -398,11 +405,13 @@ def select_github_policy(
):
raise ValueError("policy source run is not the canonical workflow")
head = report.require_sha(run["head_sha"])
+ pull_numbers: dict[str, int] = {}
if run["event"] == "pull_request":
current = report.current_pull(repository, run)
if current is None:
raise ValueError("policy run must identify one current target PR")
- _, branch = current
+ number, branch = current
+ pull_numbers[head] = number
elif run["event"] == "merge_group":
branch = next(
(
@@ -444,18 +453,23 @@ def select_github_policy(
if run["event"] == "merge_group":
if report.git(repo, "merge-base", base, head).decode().strip() != base:
raise ValueError("policy queue does not contain current next base")
- entries = queued_entries(repository, branch)
- if not any(queue == head for _, queue in entries):
+ entries = queued_pull_entries(repository, branch)
+ if not any(queue == head for _, queue, _ in entries):
raise ValueError("policy queue entry is no longer live")
heads = []
- for candidate, queue in entries:
+ for candidate, queue, number in entries:
report.git(repo, "fetch", "--quiet", "--no-tags", "origin", queue)
if report.git(repo, "merge-base", queue, head).decode().strip() == queue:
report.git(repo, "fetch", "--quiet", "--no-tags", "origin", candidate)
+ if candidate in pull_numbers:
+ raise ValueError("policy queue has multiple PRs for one head")
+ pull_numbers[candidate] = number
heads.append(candidate)
if not heads:
raise ValueError("policy queue has no verified constituent PRs")
- return select_policy(repo, repository, branch, base, head, main, pull_heads=heads)
+ return select_policy(
+ repo, repository, branch, base, head, main, pull_heads=heads, pull_numbers=pull_numbers
+ )
def merge_base(repo: Path, base: str, head: str) -> str:
@@ -488,18 +502,22 @@ def changed_paths(repo: Path, base: str, head: str) -> set[bytes]:
def queued_entries(repository: str, branch: str) -> list[tuple[str, str]]:
+ return [(head, queue) for head, queue, _ in queued_pull_entries(repository, branch)]
+
+
+def queued_pull_entries(repository: str, branch: str) -> list[tuple[str, str, int]]:
"""Query the actual queue; never infer PR membership from commit messages."""
owner, name = repository.split("/")
query = """query($owner:String!,$name:String!,$branch:String!,$cursor:String) {
repository(owner:$owner,name:$name) { mergeQueue(branch:$branch) {
entries(first:100,after:$cursor) {
- nodes { pullRequest { headRefOid } headCommit { oid } }
+ nodes { pullRequest { number headRefOid } headCommit { oid } }
pageInfo { hasNextPage endCursor }
}
} }
}"""
cursor = None
- heads: list[tuple[str, str]] = []
+ heads: list[tuple[str, str, int]] = []
while True:
response = report.api(
"POST",
@@ -517,6 +535,7 @@ def queued_entries(repository: str, branch: str) -> list[tuple[str, str]]:
(
report.require_sha(node["pullRequest"]["headRefOid"]),
report.require_sha(node["headCommit"]["oid"]),
+ int(node["pullRequest"]["number"]),
)
)
page = entries["pageInfo"]
diff --git a/scripts/castiron/fixtures/github_publisher.cjs b/scripts/castiron/fixtures/github_publisher.cjs
index f572c33c2d..c831f52970 100644
--- a/scripts/castiron/fixtures/github_publisher.cjs
+++ b/scripts/castiron/fixtures/github_publisher.cjs
@@ -47,6 +47,22 @@ const github = {
}),
},
repos: {
+ getContent: async ({ path, ref }) => {
+ if (
+ !['scripts/castiron/custom_code_policy.py', 'scripts/castiron/custom_code_report.py'].includes(path)
+ )
+ throw new Error('Unexpected trusted policy path');
+ const content = Buffer.from(JSON.stringify({ ref, path }));
+ return {
+ data: {
+ type: 'file',
+ encoding: 'base64',
+ size: content.length,
+ content: content.toString('base64'),
+ ...(data.policy_file_override || {}),
+ },
+ };
+ },
getCommit: async () => ({ data: data.merge_commit }),
compareCommitsWithBasehead: async ({ basehead }) => ({
data: data.comparisons?.[basehead] || {
@@ -119,7 +135,7 @@ const exec = {
if (
command !== 'python3' ||
args[0] !== '-I' ||
- args[1] !== 'scripts/castiron/custom_code_policy.py' ||
+ require('node:path').basename(args[1]) !== 'custom_code_policy.py' ||
args[2] !== 'review-required' ||
args[3] !== '--repository' ||
args[4] !== 'openai/example' ||
@@ -131,8 +147,19 @@ const exec = {
) {
throw new Error('Unexpected trusted policy invocation');
}
- if (data.policy_error_sequence?.shift() || data.policy_error) throw new Error('Trusted policy evaluation failed');
- return { stdout: JSON.stringify({ requires_human: data.requires_human ?? true }) };
+ for (const name of ['custom_code_policy.py', 'custom_code_report.py']) {
+ const file = require('node:path').join(require('node:path').dirname(args[1]), name);
+ const source = JSON.parse(fs.readFileSync(file, 'utf8'));
+ if (source.ref !== args[12] || source.path !== `scripts/castiron/${name}`)
+ throw new Error('Executed stale or mismatched trusted policy');
+ }
+ if (data.policy_error_sequence?.shift() || data.policy_error)
+ throw new Error('Trusted policy evaluation failed');
+ return {
+ stdout: JSON.stringify({
+ requires_human: data.requires_human_by_main?.[args[12]] ?? data.requires_human ?? true,
+ }),
+ };
},
};
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
diff --git a/scripts/castiron/generated-files.json b/scripts/castiron/generated-files.json
index 8ba5d4c672..7d2d1e052b 100644
--- a/scripts/castiron/generated-files.json
+++ b/scripts/castiron/generated-files.json
@@ -3,7 +3,7 @@
"files": {
".github/workflows/castiron-custom-code-comment.yml": {
"mode": "100644",
- "sha256": "db521f2e39d1c39ad2edacedc9903954471308e660e6df5b4ba8ca7615e5a5a8"
+ "sha256": "bdde9eec1ff9c0e842ddc0f69df5611ad4eb0336602489e2dcddfbcf8ad86e37"
},
".github/workflows/castiron-custom-code.yml": {
"mode": "100644",
@@ -11,7 +11,7 @@
},
"api.md": {
"mode": "100644",
- "sha256": "b095fd916ad7f8388af0f336a1f5a210eba3ffcba8beb69ef576e8b76abc7773"
+ "sha256": "82da84d639cb84106f389b001030b0b668eb71122f39c7db598edccc2fcf7b27"
},
"scripts/castiron/CUSTOM_CODE.md": {
"mode": "100644",
@@ -27,7 +27,7 @@
},
"scripts/castiron/custom_code_policy.py": {
"mode": "100755",
- "sha256": "e16c211407c9d236e3bdf0c00a5fe252e4509a14a0fdfe4dacbb891e33a55c57"
+ "sha256": "7dff1ec5cd69deb85e430015d8f379f042eccbedc1786d3c9e4ed8532dfeca9c"
},
"scripts/castiron/custom_code_report.py": {
"mode": "100755",
@@ -39,7 +39,7 @@
},
"scripts/castiron/fixtures/github_publisher.cjs": {
"mode": "100644",
- "sha256": "3f77c368ed668bb6ddcde1f2e806e3f307d64cb68cc45fe4c4968adfe1f7c0fe"
+ "sha256": "162963b9a13c24443ac1a97f852f269fcde5fb011a0871d428f4585cbaac2dab"
},
"scripts/castiron/ruff.toml": {
"mode": "100644",
@@ -51,11 +51,11 @@
},
"scripts/castiron/test_custom_code_github.py": {
"mode": "100644",
- "sha256": "f0f3fa6810ef73b0656d722e65125003a5685b61324dda6c93d1d0dbf619df37"
+ "sha256": "034eecfd80d3236509d2bf32fb6e69f8f13589c170b93f85935adde3d3b58b42"
},
"scripts/castiron/test_custom_code_policy.py": {
"mode": "100644",
- "sha256": "a9b4dcabec71c66e1e280fd54f46f78eea9bc664f8dca500f5da418e27114602"
+ "sha256": "29b8dde7d69cad22fe6757356fa18ef189d7fc8f9349f65aad641005540faa26"
},
"scripts/castiron/test_custom_code_publication.py": {
"mode": "100644",
@@ -67,15 +67,15 @@
},
"scripts/castiron/test_custom_code_review_revocation.py": {
"mode": "100644",
- "sha256": "2ad322e7e7b2cbd425f6647edc1cde98d4354b989dfb0b61f326030292e9c460"
+ "sha256": "6d971965f6b4da770f4d49b3587dbd136c5be549453ae0d220150fc537b2736a"
},
"src/openai/__init__.py": {
"mode": "100644",
- "sha256": "a410d257a94f2c4f6cd0951a178131e8d883e21a69ef6bea245271db215ba196"
+ "sha256": "7cc1c0f0587ac77b0651af9ab2eeb21d6bfd516fe364d883ca11474b0c2a2552"
},
"src/openai/_client.py": {
"mode": "100644",
- "sha256": "616e33f35af68a15cd312d9dc68414f41080a7c6275aa61f56cc1c34dad4fa29"
+ "sha256": "96f6317992c8a8cd8dc66c5e95bb5de6cae7e681e881bc00d12b0e12191d18d2"
},
"src/openai/_data_residency.py": {
"mode": "100644",
@@ -271,11 +271,11 @@
},
"src/openai/resources/audio/transcriptions.py": {
"mode": "100644",
- "sha256": "8bfaa74f7b00a61984e2ee801357dbf29fdda7f7388d245df7458f0c20820ea9"
+ "sha256": "b470fe61944498e74e9bc86c5a74763a49646f0e276e7c96ea339ebe0171b404"
},
"src/openai/resources/audio/translations.py": {
"mode": "100644",
- "sha256": "e9e2fc5ac27461366225c8e6ca352a8db67b789c816bb0074b21c078e99afc05"
+ "sha256": "9643b5ab66d84a9c1e0115e3dcd7e384de371f6eca5c1aac7f5168ce0d7e5245"
},
"src/openai/resources/audio/voice_consents.py": {
"mode": "100644",
@@ -347,7 +347,7 @@
},
"src/openai/resources/beta/agents/sessions/sessions.py": {
"mode": "100644",
- "sha256": "53987b64fb0b775e755a727f91d4486228dc2735947a3935e0073ca132c5a612"
+ "sha256": "65699418bb2e7b847de57b9c2d9c82acf0f94dfb99b46391ab61331580e7032c"
},
"src/openai/resources/beta/agents/sessions/subagents/__init__.py": {
"mode": "100644",
@@ -455,7 +455,7 @@
},
"src/openai/resources/beta/threads/runs/runs.py": {
"mode": "100644",
- "sha256": "a430fe262b62d81ac6e1d8161e2e4d23a16c01c4bcdcc98a900392db5327d97c"
+ "sha256": "254b4c052c8ca7200f7c63d581895feef54f78db0c50b105e1092dd15d391cf6"
},
"src/openai/resources/beta/threads/runs/steps.py": {
"mode": "100644",
@@ -463,7 +463,7 @@
},
"src/openai/resources/beta/threads/threads.py": {
"mode": "100644",
- "sha256": "1a49dcdeb83ce84b16160b2e17cc4cbfee76c8f93267fe22a727bc420dd92c3c"
+ "sha256": "b2834a13b0614f0952168655cc496ff344a766c3e9a92e7ce00b2eea73077430"
},
"src/openai/resources/chat/__init__.py": {
"mode": "100644",
@@ -479,7 +479,7 @@
},
"src/openai/resources/chat/completions/completions.py": {
"mode": "100644",
- "sha256": "0a0d3dfc38a12dff71afba526d745792f33db3e720c04ba755bb966c726f8a16"
+ "sha256": "7bc12b0cff8913fd3229ddb9055fdbb187da497a5f2dd0feda637b41235489dc"
},
"src/openai/resources/chat/completions/messages.py": {
"mode": "100644",
@@ -535,7 +535,7 @@
},
"src/openai/resources/embeddings.py": {
"mode": "100644",
- "sha256": "88aed80308e7ca8280fa29ebbf093a533f4dc327a902ace6467c5b8f52e4b387"
+ "sha256": "06953746a84dcb6483442f18f69580686d616fd10ad26dacbe4fa9ac8b30f0fd"
},
"src/openai/resources/evals/__init__.py": {
"mode": "100644",
@@ -607,7 +607,7 @@
},
"src/openai/resources/images.py": {
"mode": "100644",
- "sha256": "dfbe5ceeda53fd272b99583eaa1f684adf46183b71529c78324e3f2c926fb971"
+ "sha256": "d823e781dc30e74f363760c90a245ba75ae28293514495087239774ecace40c3"
},
"src/openai/resources/live/__init__.py": {
"mode": "100644",
@@ -615,15 +615,15 @@
},
"src/openai/resources/live/api.md": {
"mode": "100644",
- "sha256": "51637687f10e9c213190b7d37d4ba4d05b66365eb7b4b19c284735a1f5c11b28"
+ "sha256": "7a7e403a04290a470bf0919914961d2415fa58243d084ad7872f21e431a8750a"
},
"src/openai/resources/live/forks.py": {
"mode": "100644",
- "sha256": "9fb98f22e70bc172c9027b765d29040ee399906a2bedf6b93e7e9a0467df5fcd"
+ "sha256": "a1154022199862fbcb09a71e2402f15e912934de9e931d254af59bf74f34894c"
},
"src/openai/resources/live/live.py": {
"mode": "100644",
- "sha256": "6f092c04cd1244a28befac92f25a3e4c5bc204d2fe66d52c771704ee98e28b2c"
+ "sha256": "97c244e50d61c93cd6a1952064c14f302b86e85b289e024af1c524093cc76aaf"
},
"src/openai/resources/live/sessions.py": {
"mode": "100644",
@@ -631,7 +631,7 @@
},
"src/openai/resources/live/sideband.py": {
"mode": "100644",
- "sha256": "e3a8635781153cd577ff3b6e95bc949304d9c888e7de60f8aac25b6ef4790022"
+ "sha256": "4ed10b89fadd3aff1e3226cd7e0db9e1463ef834ce3d2c1e437618c7292cbd20"
},
"src/openai/resources/models.py": {
"mode": "100644",
@@ -679,7 +679,7 @@
},
"src/openai/resources/responses/api.md": {
"mode": "100644",
- "sha256": "840e8dc7c7440209ec84924cc82fa028934956e63dbbea5059885d90812da2a3"
+ "sha256": "e7815b1278aa2780bb885ac5a249fe00859dff67d3899b708d25d2968e734785"
},
"src/openai/resources/responses/input_items.py": {
"mode": "100644",
@@ -691,7 +691,7 @@
},
"src/openai/resources/responses/responses.py": {
"mode": "100644",
- "sha256": "0fd253db414975a83148d3ff07b4e5c9c5329a1a6c33c4f2ca99294ef286d7ec"
+ "sha256": "2080a49503c0780cf6f9432831106dc12bbd8e490c1cc913d2343f66a616d34e"
},
"src/openai/resources/safety/__init__.py": {
"mode": "100644",
@@ -3107,11 +3107,11 @@
},
"src/openai/types/beta/beta_response_tool_search_output_item_param.py": {
"mode": "100644",
- "sha256": "8a74fc650255996568a6009ec2001eab9d3fc560dcf3b9fe27db52d3108e7428"
+ "sha256": "626950ea43730bce9543c96bebce1718fd3ccdf303c77f31a4672673fa13121a"
},
"src/openai/types/beta/beta_response_tool_search_output_item_param_param.py": {
"mode": "100644",
- "sha256": "47d59da8c2f9b9833550ab697f3500cf99ecc184e5cb00c6a1e389f7d702e651"
+ "sha256": "7920227dd83b05caaed0b1722cdb602c1c446ba9089d8ca8628f2afacb1b6b3a"
},
"src/openai/types/beta/beta_response_usage.py": {
"mode": "100644",
@@ -3155,7 +3155,7 @@
},
"src/openai/types/beta/beta_tool.py": {
"mode": "100644",
- "sha256": "7fe3cc05cb23c169cb57a34336010224cb3a3ba147d478729a68e2781174963a"
+ "sha256": "b2113bfb482d18476f20a1634735a99a7cdbeecd621737920445041ce1d8d0d4"
},
"src/openai/types/beta/beta_tool_choice_allowed.py": {
"mode": "100644",
@@ -3219,7 +3219,7 @@
},
"src/openai/types/beta/beta_tool_param.py": {
"mode": "100644",
- "sha256": "d9396d2f13b1ded98940adc6c0103211904d42016437b2653a083994f3604642"
+ "sha256": "516583a14fda3b95fea765a4defb65a40ba9ba2499844dab226c49c552bf9ca7"
},
"src/openai/types/beta/beta_tool_search_output_namespace_tool.py": {
"mode": "100644",
@@ -4191,11 +4191,11 @@
},
"src/openai/types/decision_input_image_param.py": {
"mode": "100644",
- "sha256": "347c633b1312fb62ecceffc147d0a250954392a09c07fa680d585dd41a3f8c60"
+ "sha256": "2725722c94f582599f733ccc643da9fee40ac2a49192ce3c56341a957c2fd35f"
},
"src/openai/types/decision_input_message_param.py": {
"mode": "100644",
- "sha256": "22aff1b989c87ee05e3041c1caa9f3dd8540cbb381d96281ee75237b508297aa"
+ "sha256": "e43afa177d646a58dc53627b8284b281fbc7bec5cd1b99f793eabaf250c319a1"
},
"src/openai/types/decision_input_part_union_param.py": {
"mode": "100644",
@@ -4203,7 +4203,7 @@
},
"src/openai/types/decision_input_text_param.py": {
"mode": "100644",
- "sha256": "416864cec231da63e0324268e57192de9902399cf0119d061467c6117a3090c7"
+ "sha256": "004eb61b34a71efa494f8927dc2a501e3a259042dbe64514d6f03c30b9deab29"
},
"src/openai/types/decision_prompt_cache_breakpoint_param.py": {
"mode": "100644",
@@ -4447,7 +4447,7 @@
},
"src/openai/types/fine_tuning/fine_tuning_job_integration.py": {
"mode": "100644",
- "sha256": "add6f540e2493ce1c9e4b18c451669acd44443f84ffc364d03ba5299134c3f85"
+ "sha256": "01be0fb6a90b729e6d8c700539af334344baf908dfa30caec223651109cbf541"
},
"src/openai/types/fine_tuning/fine_tuning_job_wandb_integration.py": {
"mode": "100644",
@@ -4587,7 +4587,7 @@
},
"src/openai/types/image_edit_params.py": {
"mode": "100644",
- "sha256": "f3182c188012e2905ef4e2f192ee368d7ad1199e930698eb6ee1c2e69c5b2887"
+ "sha256": "e6c495ae0269889e18ad6d44bec3855a640ef9d8f916a94cfe4b0967a7b8a739"
},
"src/openai/types/image_edit_partial_image_event.py": {
"mode": "100644",
@@ -4611,7 +4611,7 @@
},
"src/openai/types/image_generate_params.py": {
"mode": "100644",
- "sha256": "ce11e6fc1ad113d96c6d3a275a1906da43d7ea4718fb72d9804559bd9ef60709"
+ "sha256": "a7d4d661d27941a10ce8104d537ce7166d46cc20eb96e17559a0a3dd7beeb3bf"
},
"src/openai/types/image_input_reference_param.py": {
"mode": "100644",
@@ -4619,7 +4619,7 @@
},
"src/openai/types/image_model.py": {
"mode": "100644",
- "sha256": "235a883f7b13f9f9f4532c9e6485f9e5bf3d594742b8b30d29d308aba4956972"
+ "sha256": "ad1d6cf84c36a519f0d95f208f64efbfbe2e847ec3e3820ae5b32fd5b489a42f"
},
"src/openai/types/images_response.py": {
"mode": "100644",
@@ -4627,7 +4627,7 @@
},
"src/openai/types/live/__init__.py": {
"mode": "100644",
- "sha256": "77b3c02ca1cad18baffc045de6175987c738651ac116599018f1595cb74a2791"
+ "sha256": "60346344d2221b21ed97fd02155afc598b3b4b0c001c3e3825681f096f8c94fd"
},
"src/openai/types/live/audio_format.py": {
"mode": "100644",
@@ -4705,6 +4705,22 @@
"mode": "100644",
"sha256": "ef804fb49f4ca242c9244092273958edf5d4c9a42f83575542e47652ac4b9761"
},
+ "src/openai/types/live/decision_assistant_message.py": {
+ "mode": "100644",
+ "sha256": "2bab1757a78f9bd930953298c4a030ccc4b200beb66ca326f6d98733379e4256"
+ },
+ "src/openai/types/live/decision_assistant_message_param.py": {
+ "mode": "100644",
+ "sha256": "4ac618d31d6c5cdaee737e1c95ecba079603d5966144f813d4ce1268c820e86a"
+ },
+ "src/openai/types/live/decision_choice_option.py": {
+ "mode": "100644",
+ "sha256": "33b2f232820cd904216c090b25927655fab54e83e2a093caae1ef77c1c1bb8e7"
+ },
+ "src/openai/types/live/decision_choice_option_param.py": {
+ "mode": "100644",
+ "sha256": "61e3d628d5e0249622a726801b7de85c624f367118b16fe479a361205bc3a273"
+ },
"src/openai/types/live/decision_create_event.py": {
"mode": "100644",
"sha256": "215adcb039f7175de06978786a5712fba980bd5677f35847aca528fb4a6ac6db"
@@ -4713,21 +4729,37 @@
"mode": "100644",
"sha256": "41e524af6ee88586967f8cfeb9ee9efe1d844a8d9f61217ce4c63a8feb3b16b1"
},
+ "src/openai/types/live/decision_developer_message.py": {
+ "mode": "100644",
+ "sha256": "005a471e74f2b6255b90ca670618496a49f159f0e6cfb2bb2d7633beb01239e1"
+ },
+ "src/openai/types/live/decision_developer_message_param.py": {
+ "mode": "100644",
+ "sha256": "9befa2016a18a586148a1836842f5dc891a4114f437df50f6f0e9bb2a5499b7b"
+ },
"src/openai/types/live/decision_event.py": {
"mode": "100644",
"sha256": "245033736fa8307752233cc1dd4665ad549050edf6d2ae48bc8a886b1a6050f3"
},
+ "src/openai/types/live/decision_input_text.py": {
+ "mode": "100644",
+ "sha256": "cf1baf3cd06dfd141340994ee1dda307f8260fdeaf4283492cdc10f715bc6514"
+ },
+ "src/openai/types/live/decision_input_text_param.py": {
+ "mode": "100644",
+ "sha256": "28817021cb56189942760a50b342df2e5d36e53341b5fa3f4ee2a990cac8b684"
+ },
"src/openai/types/live/decision_item_create_event.py": {
"mode": "100644",
- "sha256": "5bac8a2c8ffdccca38e075d4bdea77aad9f67a16da5ec9a6c907fa132f92652c"
+ "sha256": "12d31779732644e4cea1c2b50e268d4efca2f0c17020455c7428d3926af57d03"
},
"src/openai/types/live/decision_item_create_event_param.py": {
"mode": "100644",
- "sha256": "ad09f30351ce585a885704d704ca6a1d406cc7136d4145f28f59cd27c39c13ed"
+ "sha256": "04a7844ff27b26f9bbcea406a550b43484908364705ac2e9457e9eef4878a37e"
},
"src/openai/types/live/decision_item_created_event.py": {
"mode": "100644",
- "sha256": "c45829373168f1ecba570665befa7c0524a59bdc8a9abc4e4655b253a523b2c0"
+ "sha256": "15bbd6f351288f163109475de41ebdc7c2f076f2c4970079ea89532e81a05147"
},
"src/openai/types/live/decision_item_delete_event.py": {
"mode": "100644",
@@ -4741,29 +4773,77 @@
"mode": "100644",
"sha256": "a13cbf7081af65f6f66664c2e36f82f14ae734e7d461c09fbcaf8fe53b99051a"
},
+ "src/openai/types/live/decision_json_object.py": {
+ "mode": "100644",
+ "sha256": "42ceb18a1db58536f02e160e91c76fb25d7441b782f10eea94cea00820c30533"
+ },
+ "src/openai/types/live/decision_json_object_param.py": {
+ "mode": "100644",
+ "sha256": "2cdba6d5bdbf8be381016037104f6461f530079816ba9708de8786c97372c718"
+ },
+ "src/openai/types/live/decision_question.py": {
+ "mode": "100644",
+ "sha256": "ede731090d01e2ca5ee13830caa3b12503be94af0ed77c621dca07224111fbde"
+ },
+ "src/openai/types/live/decision_question_param.py": {
+ "mode": "100644",
+ "sha256": "a68af72b5cb2b1cfbfd0ac210be5b4a0f6ffa1f6cde2d382aacb6e2b0cebcce4"
+ },
+ "src/openai/types/live/decision_stored_assistant_message.py": {
+ "mode": "100644",
+ "sha256": "be2fde1d456634f29c91434e58f402832a750de6251a39aab4dff3d14bb765ee"
+ },
+ "src/openai/types/live/decision_stored_developer_message.py": {
+ "mode": "100644",
+ "sha256": "6470326f7278f4c08987b05140bb9684357bcf4962185732e2bd0610a9abf344"
+ },
+ "src/openai/types/live/decision_stored_system_message.py": {
+ "mode": "100644",
+ "sha256": "95e8e06b37e8c2765b00720e12fdef5b2d63ff07614250c53a4367e65086a249"
+ },
+ "src/openai/types/live/decision_stored_user_message.py": {
+ "mode": "100644",
+ "sha256": "0fdc92999c2c000e17f296ab91bb9dfa3514e26752846fcfd369143c2b019a26"
+ },
+ "src/openai/types/live/decision_system_message.py": {
+ "mode": "100644",
+ "sha256": "04d717dd436409451997f668272da7658789818eb07e89aeb56d88ea14b9b701"
+ },
+ "src/openai/types/live/decision_system_message_param.py": {
+ "mode": "100644",
+ "sha256": "9d353d1c98b23468e17f33b702cc9d9938fbd6709989102067aa6346bf7567c4"
+ },
"src/openai/types/live/decision_trigger.py": {
"mode": "100644",
- "sha256": "72b3fa55c82067c5377ef4c2ec8061f411363eec077cd2393780830fd3fb952b"
+ "sha256": "b3b3c5b3458434d94ce0b612700ee86611e278fc00d5162a1eecfdb23a77598f"
},
"src/openai/types/live/decision_trigger_param.py": {
"mode": "100644",
- "sha256": "9d7338a7f85df1e4e3d2c0184bc73dd35d48ac21584d6c0a11ba02b87397c94b"
+ "sha256": "241efd8413f2aedfc0537b0451512a6d76127958746f7a03035c0b6af553bedb"
+ },
+ "src/openai/types/live/decision_user_message.py": {
+ "mode": "100644",
+ "sha256": "71b106ed0e72585a33dc9819d9a096f0a39c17a8346eba72a4b6b53af045d664"
+ },
+ "src/openai/types/live/decision_user_message_param.py": {
+ "mode": "100644",
+ "sha256": "9b77ce5d858e49d5948b592da3a61944fc277dd7effa46f502dfcadcd2449c6a"
},
"src/openai/types/live/decisions_delegation_config.py": {
"mode": "100644",
- "sha256": "6ad6442388302b3a8bfd4f18b771fe7934396b51fbb9a4b7f1a606303183fea6"
+ "sha256": "d599206eb9aa1a1038bbf1c975ae3b514a8a2df640b68a7c4ad3d3427c249515"
},
"src/openai/types/live/decisions_delegation_config_param.py": {
"mode": "100644",
- "sha256": "a2633c443288cb1962cae2968c43def5053ecc3f541d3f12d690ab05f6faa55b"
+ "sha256": "aea4801c6d09d523695feaa9eceb10707e5ec105701662a5304d9bcf85314c86"
},
"src/openai/types/live/decisions_delegation_update_config.py": {
"mode": "100644",
- "sha256": "1ca4177a723c322ef38ae7861e94328b4cb2fd4baa8caa12ef286b115e44d9a7"
+ "sha256": "e91699a0b15048a3c25abd694359b94f09dd67e455355266d2e565b89d00076d"
},
"src/openai/types/live/decisions_delegation_update_config_param.py": {
"mode": "100644",
- "sha256": "e71336c1bccd68614cac5916a8de7de14bc1d68a3e7d68ac9283a9ef3c595e09"
+ "sha256": "08e86bd18b3b532c94f9f97c7843cae27278e88e1487449dfc75dee19e545888"
},
"src/openai/types/live/delegation_created_event.py": {
"mode": "100644",
@@ -6659,11 +6739,11 @@
},
"src/openai/types/responses/response_tool_search_output_item_param.py": {
"mode": "100644",
- "sha256": "7fb9eba28aae8592bb377ad5eb2be7f253ae7e1ee3c108c753c59f28db99f1fc"
+ "sha256": "d25d614693ca86602106515b1e12f26f55f82282c8ef085a5712ec6d18c4f4cb"
},
"src/openai/types/responses/response_tool_search_output_item_param_param.py": {
"mode": "100644",
- "sha256": "ae0507dc46b58706d9b7dcf00df47e7aa9f1f5a15e6cb2b1c4c0be7aa0390492"
+ "sha256": "a1b20bcb2ccb1e074d2a68a4630c424df7a782063f098ab82cb673e3c877f976"
},
"src/openai/types/responses/response_usage.py": {
"mode": "100644",
@@ -6707,7 +6787,7 @@
},
"src/openai/types/responses/tool.py": {
"mode": "100644",
- "sha256": "3ef27c46ab304c48f7ea43b9bb6df6cdb9e842268536415cd9ef0fcaea02e51f"
+ "sha256": "ace9a6241d641f12f1a2461713f542b68109cf2a74f050e2dc0211cc2c5de8b8"
},
"src/openai/types/responses/tool_choice_allowed.py": {
"mode": "100644",
@@ -6771,7 +6851,7 @@
},
"src/openai/types/responses/tool_param.py": {
"mode": "100644",
- "sha256": "3c9a6d95a41c4870e190679eb6d1c9b7a16440bb32001a3954cbae6ab6e541f5"
+ "sha256": "abfa0b97b8b47844cc51c6400c0eab3086c2eba8aa1673e0f78abcd889a24b27"
},
"src/openai/types/responses/tool_search_output_namespace_tool.py": {
"mode": "100644",
@@ -7207,7 +7287,7 @@
},
"src/openai/types/webhooks/__init__.py": {
"mode": "100644",
- "sha256": "a5774cf8e193a6d9299039fa823adb236b2dbb5cce675ccc9efbed2a613b1aa2"
+ "sha256": "6cd86f449fccb260a2e03c56defd59fbf890063734171c8a9fc0405cf9bb2b7d"
},
"src/openai/types/webhooks/agent_environment_expired_webhook_event.py": {
"mode": "100644",
@@ -7291,7 +7371,7 @@
},
"src/openai/types/webhooks/live_call_incoming_webhook_event.py": {
"mode": "100644",
- "sha256": "2dd3bc70a9df1f12e5333983946e1df037a69f712ce104c75324768034df5c24"
+ "sha256": "98c0194038495649ea8f61edad0fffe95e1ce9b100ce6303b96a2ca37e7fab98"
},
"src/openai/types/webhooks/live_transport_incoming_webhook_event.py": {
"mode": "100644",
@@ -7335,7 +7415,7 @@
},
"src/openai/types/webhooks/unwrap_webhook_event.py": {
"mode": "100644",
- "sha256": "f1285c95b535b806614b4da2b35607fb1c8759dd23520d3b79c2506ef1e69a70"
+ "sha256": "ab0f7c3a5b26ee9df72b53f7084da93dd86e7e38ce25efe13fbcfe9dfcbe4c69"
},
"src/openai/types/webhooks/webhook_create_params.py": {
"mode": "100644",
@@ -7831,7 +7911,7 @@
},
"tests/api_resources/live/test_sessions.py": {
"mode": "100644",
- "sha256": "c8e24169a91d24699b65c4b927afac7dc436cab20acea02d0368721cd7692005"
+ "sha256": "751f651775f0547d6c236d8d6bc44bbe00ab195d0c2202d9d08d29c8ed4a3bfc"
},
"tests/api_resources/live/test_sideband.py": {
"mode": "100644",
@@ -7947,7 +8027,7 @@
},
"tests/api_resources/test_live.py": {
"mode": "100644",
- "sha256": "6fa5e16d2004c3dbb9b9aa8b6c62bf10ce1d0ddc000de4cf1a5f7e8835695c7f"
+ "sha256": "6af26be731b0ae49024e5ad21169396a1cc9b05d94e14f3a061bf377d407d7ca"
},
"tests/api_resources/test_models.py": {
"mode": "100644",
diff --git a/scripts/castiron/test_custom_code_github.py b/scripts/castiron/test_custom_code_github.py
index 1d970a0ffd..5e11fa4f09 100644
--- a/scripts/castiron/test_custom_code_github.py
+++ b/scripts/castiron/test_custom_code_github.py
@@ -901,13 +901,19 @@ def test_queue_pagination(self) -> None:
pages = [
{
"nodes": [
- {"pullRequest": {"headRefOid": "a" * 40}, "headCommit": {"oid": "c" * 40}}
+ {
+ "pullRequest": {"number": 1, "headRefOid": "a" * 40},
+ "headCommit": {"oid": "c" * 40},
+ }
],
"pageInfo": {"hasNextPage": True, "endCursor": "cursor"},
},
{
"nodes": [
- {"pullRequest": {"headRefOid": "b" * 40}, "headCommit": {"oid": "d" * 40}}
+ {
+ "pullRequest": {"number": 2, "headRefOid": "b" * 40},
+ "headCommit": {"oid": "d" * 40},
+ }
],
"pageInfo": {"hasNextPage": False, "endCursor": None},
},
diff --git a/scripts/castiron/test_custom_code_policy.py b/scripts/castiron/test_custom_code_policy.py
index 00517cb549..5368d30ca7 100644
--- a/scripts/castiron/test_custom_code_policy.py
+++ b/scripts/castiron/test_custom_code_policy.py
@@ -131,6 +131,36 @@ def approved(self, **kwargs: Any) -> dict[str, Any]:
**kwargs,
}
+ def test_fork_policy_review_uses_the_discovered_pull(self) -> None:
+ self.git("checkout", "-q", "--detach", self.base)
+ self.write_policy({**self.policy, "next_policy": self.pin, "max_custom_patch_lines": 5000})
+ self.head = self.commit("fork increases policy budget")
+ review = self.review_api([self.approved()])
+ run: dict[str, Any] = {
+ "head_sha": self.head,
+ "head_repository": {"owner": {"login": "forker"}},
+ "head_branch": "policy",
+ "pull_requests": [],
+ }
+
+ def api(method: str, path: str) -> Any:
+ if "/commits/" in path:
+ return []
+ if "/pulls?" in path:
+ self.assertIn("head=forker%3Apolicy", path)
+ return [{"number": 3}]
+ return review(method, path)
+
+ with mock.patch.object(selector.report, "api", side_effect=api):
+ current = selector.report.current_pull(REPO, run)
+ assert current is not None
+ number, branch = current
+ self.assertEqual(branch, "next")
+ result = self.select(base=self.main, pull_numbers={self.head: number})
+ self.assertEqual(result["policy_reviews"], [{"number": 3, "head_sha": self.head}])
+ with self.assertRaisesRegex(ValueError, "one open next PR"):
+ selector.require_human_policy_review(REPO, self.main, number)
+
def test_only_base_pin_selects_checker(self) -> None:
(self.repo / "scripts/castiron/custom_code_budget.py").write_text(
'raise RuntimeError("candidate code must never execute")\n'
@@ -534,7 +564,7 @@ def test_pin_effective_policy_review_for_pr_and_queue(self) -> None:
if needs_proof:
with self.assertRaisesRegex(ValueError, "human"):
self.select(base=base, main=newer, pull_heads=heads)
- review.assert_called_once_with(REPO, self.head)
+ review.assert_called_once_with(REPO, self.head, None)
else:
result = self.select(base=base, main=newer, pull_heads=heads)
review.assert_not_called()
@@ -841,7 +871,14 @@ def test_explicit_ci_uses_same_base_pin_selector(self) -> None:
self.use_ci()
self.assertEqual(self.call(source_workflow=CI_POLICY_WORKFLOW), {"selected": True})
self.select.assert_called_once_with(
- self.repo, REPO, "next", "b" * 40, "a" * 40, "c" * 40, pull_heads=None
+ self.repo,
+ REPO,
+ "next",
+ "b" * 40,
+ "a" * 40,
+ "c" * 40,
+ pull_heads=None,
+ pull_numbers={"a" * 40: 12},
)
def test_candidate_event_cannot_select_ci_adapter(self) -> None:
diff --git a/scripts/castiron/test_custom_code_review_revocation.py b/scripts/castiron/test_custom_code_review_revocation.py
index 5170e6f2af..4baa11512e 100644
--- a/scripts/castiron/test_custom_code_review_revocation.py
+++ b/scripts/castiron/test_custom_code_review_revocation.py
@@ -95,6 +95,30 @@ def test_retries_policy_failure_when_main_advances_before_revocation(self) -> No
self.assertEqual({item["sha"] for item in result[:4]}, {"a" * 40, "c" * 40})
self.assertEqual([item["run_id"] for item in result[4:]], [12, 14])
+ def test_refreshes_executable_policy_when_main_changes_review_requirement(self) -> None:
+ payload = self.payload()
+ payload["main_sha_sequence"] = ["d" * 40, "e" * 40]
+ payload["main_sha"] = "e" * 40
+ payload["requires_human_by_main"] = {"d" * 40: False, "e" * 40: True}
+ result = self.invoke(payload)
+ self.assertEqual([item.get("state") for item in result[:4]], ["pending"] * 4)
+ self.assertEqual({item["sha"] for item in result[:4]}, {"a" * 40, "c" * 40})
+ self.assertEqual([item["run_id"] for item in result[4:]], [12, 14])
+
+ def test_rejects_invalid_trusted_policy_downloads(self) -> None:
+ for override in [
+ {"type": "symlink"},
+ {"encoding": "none"},
+ {"size": 1048577},
+ {"size": 0},
+ {"content": ""},
+ ]:
+ with self.subTest(override=override):
+ payload = self.payload()
+ payload["policy_file_override"] = override
+ with self.assertRaises(subprocess.CalledProcessError):
+ self.invoke(payload)
+
def approval(self) -> dict[str, Any]:
return {
"fullDatabaseId": "101",
@@ -582,10 +606,9 @@ def test_signal_is_unprivileged_and_writers_serialize(self) -> None:
self.assertNotIn("checkout@", signal)
handler = WORKFLOW.read_text()
revoke = handler.split(" review-change:\n", 1)[1].split(" compute:\n", 1)[0]
- self.assertIn("ref: ${{ github.workflow_sha }}", revoke)
- self.assertIn("persist-credentials: false", revoke)
+ self.assertNotIn("checkout@", revoke)
self.assertNotIn("ref: ${{ github.event", revoke)
- self.assertIn("custom_code_policy.py', 'review-required'", revoke)
+ self.assertIn("path.join(root, 'custom_code_policy.py'), 'review-required'", revoke)
self.assertNotIn("download-artifact", revoke)
self.assertEqual(
handler.count("group: castiron-budget-writes-${{ github.repository_id }}"), 2
diff --git a/src/openai/__init__.py b/src/openai/__init__.py
index 74f675aca6..e5c97c758c 100644
--- a/src/openai/__init__.py
+++ b/src/openai/__init__.py
@@ -4,7 +4,6 @@
import os as _os
import typing as _t
-import typing_extensions as _te
from typing_extensions import override
from . import types
@@ -208,7 +207,7 @@ def __dir__() -> list[str]:
http_client: _httpx.Client | None = None
-_ApiType = _te.Literal["openai", "azure", "amazon-bedrock"]
+_ApiType = _t.Literal["openai", "azure", "amazon-bedrock"]
api_type: _ApiType | None = _t.cast(_ApiType, _os.environ.get("OPENAI_API_TYPE"))
diff --git a/src/openai/_client.py b/src/openai/_client.py
index ae17365e6d..2a10cd855a 100644
--- a/src/openai/_client.py
+++ b/src/openai/_client.py
@@ -1,6 +1,6 @@
# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
-from __future__ import annotations
+from __future__ import annotations, annotations as annotations
import os as os
from typing import (
@@ -182,6 +182,81 @@ def base_url(
return syncbase_url_set(self, url)
+ def _send_with_auth_retry(
+ self,
+ request: httpx2.Request,
+ *,
+ stream: bool,
+ retried: bool = False,
+ **kwargs: Unpack[HttpxSendArgs],
+ ) -> httpx2.Response:
+ from typing import Any as _RuntimeAny, cast as _runtime_cast
+
+ from .lib._client_auth import sync_send_with_auth_retry
+
+ return sync_send_with_auth_retry(
+ _runtime_cast(_RuntimeAny, super()).__thisclass__, self, request, stream=stream, retried=retried, **kwargs
+ )
+
+ @override
+ def _send_request(
+ self,
+ request: httpx2.Request,
+ *,
+ stream: bool,
+ **kwargs: Unpack[HttpxSendArgs],
+ ) -> httpx2.Response:
+ from .lib._client_auth import sync_send_request
+
+ return sync_send_request(self, request, stream=stream, **kwargs)
+
+ @property
+ @override
+ def auth_headers(
+ self,
+ ) -> dict[str, str]:
+ from .lib._client_auth import syncauth_headers
+
+ return syncauth_headers(self)
+
+ @override
+ def _prepare_options(
+ self,
+ options: FinalRequestOptions,
+ ) -> FinalRequestOptions:
+ from typing import Any as _RuntimeAny, cast as _runtime_cast
+
+ from .lib._client_auth import sync_prepare_options
+
+ return sync_prepare_options(_runtime_cast(_RuntimeAny, super()).__thisclass__, self, options)
+
+ @override
+ def _prepare_request(
+ self,
+ request: httpx2.Request,
+ ) -> None:
+ from .lib._client_auth import sync_prepare_request
+
+ return sync_prepare_request(self, request)
+
+ @override
+ def _custom_auth(
+ self,
+ security: SecurityOptions,
+ ) -> httpx2.Auth | None:
+ from typing import Any as _RuntimeAny, cast as _runtime_cast
+
+ from .lib._client_auth import sync_custom_auth
+
+ return sync_custom_auth(_runtime_cast(_RuntimeAny, super()).__thisclass__, self, security)
+
+ def _refresh_api_key(
+ self,
+ ) -> str:
+ from .lib._client_auth import sync_refresh_api_key
+
+ return sync_refresh_api_key(self)
+
def _websocket_query_params_fallback(self, url: httpx2.URL, extra_query: Query) -> httpx2.QueryParams:
# Remove replaced logical defaults before encoding nested query values.
overridden = dict.fromkeys(extra_query, omit)
@@ -448,34 +523,6 @@ def with_streaming_response(self) -> OpenAIWithStreamedResponse:
def qs(self) -> Querystring:
return Querystring(array_format="brackets")
- def _send_with_auth_retry(
- self,
- request: httpx2.Request,
- *,
- stream: bool,
- retried: bool = False,
- **kwargs: Unpack[HttpxSendArgs],
- ) -> httpx2.Response:
- from typing import Any as _RuntimeAny, cast as _runtime_cast
-
- from .lib._client_auth import sync_send_with_auth_retry
-
- return sync_send_with_auth_retry(
- _runtime_cast(_RuntimeAny, super()).__thisclass__, self, request, stream=stream, retried=retried, **kwargs
- )
-
- @override
- def _send_request(
- self,
- request: httpx2.Request,
- *,
- stream: bool,
- **kwargs: Unpack[HttpxSendArgs],
- ) -> httpx2.Response:
- from .lib._client_auth import sync_send_request
-
- return sync_send_request(self, request, stream=stream, **kwargs)
-
@override
def _auth_headers(
self,
@@ -493,15 +540,6 @@ def _bearer_auth(
return sync_bearer_auth(self)
- @property
- @override
- def auth_headers(
- self,
- ) -> dict[str, str]:
- from .lib._client_auth import syncauth_headers
-
- return syncauth_headers(self)
-
@property
def _admin_api_key_auth(self) -> dict[str, str]:
admin_api_key = self.admin_api_key
@@ -530,44 +568,6 @@ def _validate_headers(
return sync_validate_headers(self, headers, custom_headers)
- @override
- def _prepare_options(
- self,
- options: FinalRequestOptions,
- ) -> FinalRequestOptions:
- from typing import Any as _RuntimeAny, cast as _runtime_cast
-
- from .lib._client_auth import sync_prepare_options
-
- return sync_prepare_options(_runtime_cast(_RuntimeAny, super()).__thisclass__, self, options)
-
- @override
- def _prepare_request(
- self,
- request: httpx2.Request,
- ) -> None:
- from .lib._client_auth import sync_prepare_request
-
- return sync_prepare_request(self, request)
-
- @override
- def _custom_auth(
- self,
- security: SecurityOptions,
- ) -> httpx2.Auth | None:
- from typing import Any as _RuntimeAny, cast as _runtime_cast
-
- from .lib._client_auth import sync_custom_auth
-
- return sync_custom_auth(_runtime_cast(_RuntimeAny, super()).__thisclass__, self, security)
-
- def _refresh_api_key(
- self,
- ) -> str:
- from .lib._client_auth import sync_refresh_api_key
-
- return sync_refresh_api_key(self)
-
def copy(
self,
*,
@@ -702,6 +702,81 @@ def base_url(
return asyncbase_url_set(self, url)
+ async def _send_with_auth_retry(
+ self,
+ request: httpx2.Request,
+ *,
+ stream: bool,
+ retried: bool = False,
+ **kwargs: Unpack[HttpxSendArgs],
+ ) -> httpx2.Response:
+ from typing import Any as _RuntimeAny, cast as _runtime_cast
+
+ from .lib._client_auth import async_send_with_auth_retry
+
+ return await async_send_with_auth_retry(
+ _runtime_cast(_RuntimeAny, super()).__thisclass__, self, request, stream=stream, retried=retried, **kwargs
+ )
+
+ @override
+ async def _send_request(
+ self,
+ request: httpx2.Request,
+ *,
+ stream: bool,
+ **kwargs: Unpack[HttpxSendArgs],
+ ) -> httpx2.Response:
+ from .lib._client_auth import async_send_request
+
+ return await async_send_request(self, request, stream=stream, **kwargs)
+
+ @property
+ @override
+ def auth_headers(
+ self,
+ ) -> dict[str, str]:
+ from .lib._client_auth import asyncauth_headers
+
+ return asyncauth_headers(self)
+
+ @override
+ async def _prepare_options(
+ self,
+ options: FinalRequestOptions,
+ ) -> FinalRequestOptions:
+ from typing import Any as _RuntimeAny, cast as _runtime_cast
+
+ from .lib._client_auth import async_prepare_options
+
+ return await async_prepare_options(_runtime_cast(_RuntimeAny, super()).__thisclass__, self, options)
+
+ @override
+ async def _prepare_request(
+ self,
+ request: httpx2.Request,
+ ) -> None:
+ from .lib._client_auth import async_prepare_request
+
+ return await async_prepare_request(self, request)
+
+ @property
+ @override
+ def custom_auth(
+ self,
+ ) -> httpx2.Auth | None:
+ from typing import Any as _RuntimeAny, cast as _runtime_cast
+
+ from .lib._client_auth import asynccustom_auth
+
+ return asynccustom_auth(_runtime_cast(_RuntimeAny, super()).__thisclass__, self)
+
+ async def _refresh_api_key(
+ self,
+ ) -> str:
+ from .lib._client_auth import async_refresh_api_key
+
+ return await async_refresh_api_key(self)
+
def _websocket_query_params_fallback(self, url: httpx2.URL, extra_query: Query) -> httpx2.QueryParams:
# Remove replaced logical defaults before encoding nested query values.
overridden = dict.fromkeys(extra_query, omit)
@@ -968,34 +1043,6 @@ def with_streaming_response(self) -> AsyncOpenAIWithStreamedResponse:
def qs(self) -> Querystring:
return Querystring(array_format="brackets")
- async def _send_with_auth_retry(
- self,
- request: httpx2.Request,
- *,
- stream: bool,
- retried: bool = False,
- **kwargs: Unpack[HttpxSendArgs],
- ) -> httpx2.Response:
- from typing import Any as _RuntimeAny, cast as _runtime_cast
-
- from .lib._client_auth import async_send_with_auth_retry
-
- return await async_send_with_auth_retry(
- _runtime_cast(_RuntimeAny, super()).__thisclass__, self, request, stream=stream, retried=retried, **kwargs
- )
-
- @override
- async def _send_request(
- self,
- request: httpx2.Request,
- *,
- stream: bool,
- **kwargs: Unpack[HttpxSendArgs],
- ) -> httpx2.Response:
- from .lib._client_auth import async_send_request
-
- return await async_send_request(self, request, stream=stream, **kwargs)
-
@override
def _auth_headers(
self,
@@ -1013,15 +1060,6 @@ def _bearer_auth(
return async_bearer_auth(self)
- @property
- @override
- def auth_headers(
- self,
- ) -> dict[str, str]:
- from .lib._client_auth import asyncauth_headers
-
- return asyncauth_headers(self)
-
@property
def _admin_api_key_auth(self) -> dict[str, str]:
admin_api_key = self.admin_api_key
@@ -1050,44 +1088,6 @@ def _validate_headers(
return async_validate_headers(self, headers, custom_headers)
- @override
- async def _prepare_options(
- self,
- options: FinalRequestOptions,
- ) -> FinalRequestOptions:
- from typing import Any as _RuntimeAny, cast as _runtime_cast
-
- from .lib._client_auth import async_prepare_options
-
- return await async_prepare_options(_runtime_cast(_RuntimeAny, super()).__thisclass__, self, options)
-
- @override
- async def _prepare_request(
- self,
- request: httpx2.Request,
- ) -> None:
- from .lib._client_auth import async_prepare_request
-
- return await async_prepare_request(self, request)
-
- @property
- @override
- def custom_auth(
- self,
- ) -> httpx2.Auth | None:
- from typing import Any as _RuntimeAny, cast as _runtime_cast
-
- from .lib._client_auth import asynccustom_auth
-
- return asynccustom_auth(_runtime_cast(_RuntimeAny, super()).__thisclass__, self)
-
- async def _refresh_api_key(
- self,
- ) -> str:
- from .lib._client_auth import async_refresh_api_key
-
- return await async_refresh_api_key(self)
-
def copy(
self,
*,
diff --git a/src/openai/resources/audio/transcriptions.py b/src/openai/resources/audio/transcriptions.py
index 584545eca5..d8719c5a72 100644
--- a/src/openai/resources/audio/transcriptions.py
+++ b/src/openai/resources/audio/transcriptions.py
@@ -32,12 +32,12 @@
from ...types.audio import transcription_create_params
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
+from ...lib._parsing._audio import get_transcription_response_format_type as _create_response_format_type
from ...types.audio.transcription import Transcription
from ...types.audio.transcription_include import TranscriptionInclude
from ...types.audio.transcription_verbose import TranscriptionVerbose
from ...types.audio.transcription_diarized import TranscriptionDiarized
from ...types.audio.transcription_stream_event import TranscriptionStreamEvent
-from ...types.audio.transcription_create_response import TranscriptionCreateResponse
__all__ = ["Transcriptions", "AsyncTranscriptions"]
@@ -45,7 +45,8 @@
log: logging.Logger = logging.getLogger("openai.audio.transcriptions")
-def _get_response_format_type(
+# Retained module entry point; callers may live outside generated resources.
+def _get_response_format_type( # pyright: ignore[reportUnusedFunction]
response_format: AudioResponseFormat | Omit,
) -> type[Transcription | TranscriptionVerbose | TranscriptionDiarized | str]:
return openai.lib._parsing._audio.get_transcription_response_format_type(response_format, log=log)
@@ -82,18 +83,126 @@ def create(
chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
include: List[TranscriptionInclude] | Omit = omit,
keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: Literal["json"] | Omit = omit,
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Transcription: ...
+
+ @overload
+ def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: Literal["verbose_json"],
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> TranscriptionVerbose: ...
+
+ @overload
+ def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[Literal["json"], Omit] = omit,
+ response_format: Literal["diarized_json"],
stream: Optional[Literal[False]] | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Transcription:
+ ) -> TranscriptionDiarized: ...
+
+ @overload
+ def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: Literal["text", "srt", "vtt"],
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> str: ...
+
+ @overload
+ def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: AudioResponseFormat | Omit = omit,
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Transcription | TranscriptionVerbose | TranscriptionDiarized | str:
"""
Transcribes audio into the input language.
@@ -112,10 +221,12 @@ def create(
(which is powered by our open source Whisper V2 model), and
`gpt-4o-transcribe-diarize`.
- chunking_strategy: Controls how the audio is cut into chunks. When set to `\"auto\"`, the server
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
first normalizes loudness and then uses voice activity detection (VAD) to choose
boundaries. `server_vad` object can be provided to tweak VAD detection
parameters manually. If unset, the audio is transcribed as a single block.
+ Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30
+ seconds.
include: Additional information to include in the transcription response. `logprobs` will
return the log probabilities of the tokens in the response to understand the
@@ -124,6 +235,18 @@ def create(
`gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is
not supported when using `gpt-4o-transcribe-diarize`.
+ keywords: Words or phrases to guide transcription of the input audio. Supported by
+ `gpt-transcribe`.
+
+ known_speaker_names: Optional list of speaker names that correspond to the audio samples provided in
+ `known_speaker_references[]`. Each entry should be a short identifier (for
+ example `customer` or `agent`). Up to 4 speakers are supported.
+
+ known_speaker_references: Optional list of audio samples (as
+ [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs))
+ that contain known speaker references matching `known_speaker_names[]`. Each
+ sample must be between 2 and 10 seconds, and can use any of the same input audio
+ formats supported by `file`.
language: The language of the input audio. Supplying the input language in
[ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
@@ -140,8 +263,10 @@ def create(
`gpt-4o-transcribe-diarize`.
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
- `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
- the only supported format is `json`.
+ `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and
+ `gpt-4o-mini-transcribe`, the only supported format is `json`. For
+ `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and
+ `diarized_json`, with `diarized_json` required to receive speaker annotations.
stream: If set to true, the model response data will be streamed to the client as it is
generated using
@@ -162,75 +287,18 @@ def create(
`response_format` must be set `verbose_json` to use timestamp granularities.
Either or both of these options are supported: `word`, or `segment`. Note: There
is no additional latency for segment timestamps, but generating word timestamps
- incurs additional latency.
+ incurs additional latency. This option is not available for
+ `gpt-4o-transcribe-diarize`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
- """
-
- @overload
- def create(
- self,
- *,
- file: FileTypes,
- model: Union[str, AudioModel],
- chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
- include: List[TranscriptionInclude] | Omit = omit,
- keywords: SequenceNotStr[str] | Omit = omit,
- response_format: Literal["verbose_json"],
- language: str | Omit = omit,
- languages: SequenceNotStr[str] | Omit = omit,
- prompt: str | Omit = omit,
- temperature: float | Omit = omit,
- timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> TranscriptionVerbose: ...
- @overload
- def create(
- self,
- *,
- file: FileTypes,
- model: Union[str, AudioModel],
- chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
- response_format: Literal["text", "srt", "vtt"],
- include: List[TranscriptionInclude] | Omit = omit,
- keywords: SequenceNotStr[str] | Omit = omit,
- language: str | Omit = omit,
- languages: SequenceNotStr[str] | Omit = omit,
- prompt: str | Omit = omit,
- temperature: float | Omit = omit,
- timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> str: ...
+ extra_body: Add additional JSON properties to the request
- @overload
- def create(
- self,
- *,
- file: FileTypes,
- model: Union[str, AudioModel],
- chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
- response_format: Literal["diarized_json"],
- keywords: SequenceNotStr[str] | Omit = omit,
- known_speaker_names: SequenceNotStr[str] | Omit = omit,
- known_speaker_references: SequenceNotStr[str] | Omit = omit,
- language: str | Omit = omit,
- languages: SequenceNotStr[str] | Omit = omit,
- temperature: float | Omit = omit,
- timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> TranscriptionDiarized: ...
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
@overload
def create(
@@ -247,9 +315,11 @@ def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: AudioResponseFormat | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -282,7 +352,7 @@ def create(
Note: Streaming is not supported for the `whisper-1` model and will be ignored.
- chunking_strategy: Controls how the audio is cut into chunks. When set to `\"auto\"`, the server
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
first normalizes loudness and then uses voice activity detection (VAD) to choose
boundaries. `server_vad` object can be provided to tweak VAD detection
parameters manually. If unset, the audio is transcribed as a single block.
@@ -350,6 +420,7 @@ def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@overload
def create(
@@ -366,14 +437,16 @@ def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: AudioResponseFormat | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> TranscriptionCreateResponse | Stream[TranscriptionStreamEvent]:
+ ) -> Transcription | TranscriptionVerbose | TranscriptionDiarized | str | Stream[TranscriptionStreamEvent]:
"""
Transcribes audio into the input language.
@@ -401,7 +474,7 @@ def create(
Note: Streaming is not supported for the `whisper-1` model and will be ignored.
- chunking_strategy: Controls how the audio is cut into chunks. When set to `\"auto\"`, the server
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
first normalizes loudness and then uses voice activity detection (VAD) to choose
boundaries. `server_vad` object can be provided to tweak VAD detection
parameters manually. If unset, the audio is transcribed as a single block.
@@ -469,6 +542,7 @@ def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@required_args(["file", "model"], ["file", "model", "stream"])
def create(
@@ -484,15 +558,112 @@ def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: AudioResponseFormat | Omit = omit,
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> str | Transcription | TranscriptionDiarized | TranscriptionVerbose | Stream[TranscriptionStreamEvent]:
+ ) -> Transcription | TranscriptionVerbose | TranscriptionDiarized | str | Stream[TranscriptionStreamEvent]:
+ """
+ Transcribes audio into the input language.
+
+ Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ transcript events. Supported formats depend on the model.
+
+ Args:
+ file: The audio file object (not file name) to transcribe, in one of these formats:
+ flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include
+ enough format metadata for the file to be identified. We recommend an
+ extension-bearing filename and an appropriate content type.
+
+ model: ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`,
+ `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1`
+ (which is powered by our open source Whisper V2 model), and
+ `gpt-4o-transcribe-diarize`.
+
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
+ first normalizes loudness and then uses voice activity detection (VAD) to choose
+ boundaries. `server_vad` object can be provided to tweak VAD detection
+ parameters manually. If unset, the audio is transcribed as a single block.
+ Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30
+ seconds.
+
+ include: Additional information to include in the transcription response. `logprobs` will
+ return the log probabilities of the tokens in the response to understand the
+ model's confidence in the transcription. `logprobs` only works with
+ response_format set to `json` and only with the models `gpt-4o-transcribe`,
+ `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is
+ not supported when using `gpt-4o-transcribe-diarize`.
+
+ keywords: Words or phrases to guide transcription of the input audio. Supported by
+ `gpt-transcribe`.
+
+ known_speaker_names: Optional list of speaker names that correspond to the audio samples provided in
+ `known_speaker_references[]`. Each entry should be a short identifier (for
+ example `customer` or `agent`). Up to 4 speakers are supported.
+
+ known_speaker_references: Optional list of audio samples (as
+ [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs))
+ that contain known speaker references matching `known_speaker_names[]`. Each
+ sample must be between 2 and 10 seconds, and can use any of the same input audio
+ formats supported by `file`.
+
+ language: The language of the input audio. Supplying the input language in
+ [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
+ format will improve accuracy and latency.
+
+ languages: Possible languages of the input audio, in
+ [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format.
+ Supported by `gpt-transcribe`.
+
+ prompt: An optional text to guide the model's style or continue a previous audio
+ segment. The
+ [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting)
+ should match the audio language. This field is not supported when using
+ `gpt-4o-transcribe-diarize`.
+
+ response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and
+ `gpt-4o-mini-transcribe`, the only supported format is `json`. For
+ `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and
+ `diarized_json`, with `diarized_json` required to receive speaker annotations.
+
+ stream: If set to true, the model response data will be streamed to the client as 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).
+ See the
+ [Streaming section of the Speech-to-Text guide](https://developers.openai.com/api/docs/guides/speech-to-text?lang=curl#streaming)
+ for more information.
+
+ Note: Streaming is not supported for the `whisper-1` model and will be ignored.
+
+ temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
+ output more random, while lower values like 0.2 will make it more focused and
+ deterministic. If set to 0, the model will use
+ [log probability](https://en.wikipedia.org/wiki/Log_probability) to
+ automatically increase the temperature until certain thresholds are hit.
+
+ timestamp_granularities: The timestamp granularities to populate for this transcription.
+ `response_format` must be set `verbose_json` to use timestamp granularities.
+ Either or both of these options are supported: `word`, or `segment`. Note: There
+ is no additional latency for segment timestamps, but generating word timestamps
+ incurs additional latency. This option is not available for
+ `gpt-4o-transcribe-diarize`.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
body = deepcopy_with_paths(
{
"file": file,
@@ -533,7 +704,7 @@ def create(
timeout=timeout,
security={"bearer_auth": True},
),
- cast_to=_get_response_format_type(response_format),
+ cast_to=_create_response_format_type(response_format, log=logging.getLogger("openai.audio.transcriptions")),
stream=stream or False,
stream_cls=Stream[TranscriptionStreamEvent],
)
@@ -575,15 +746,121 @@ async def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[Literal["json"], Omit] = omit,
+ response_format: Literal["json"] | Omit = omit,
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Transcription: ...
+
+ @overload
+ async def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: Literal["verbose_json"],
stream: Optional[Literal[False]] | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> TranscriptionCreateResponse:
+ ) -> TranscriptionVerbose: ...
+
+ @overload
+ async def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: Literal["diarized_json"],
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> TranscriptionDiarized: ...
+
+ @overload
+ async def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: Literal["text", "srt", "vtt"],
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> str: ...
+
+ @overload
+ async def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
+ include: List[TranscriptionInclude] | Omit = omit,
+ keywords: SequenceNotStr[str] | Omit = omit,
+ known_speaker_names: SequenceNotStr[str] | Omit = omit,
+ known_speaker_references: SequenceNotStr[str] | Omit = omit,
+ language: str | Omit = omit,
+ languages: SequenceNotStr[str] | Omit = omit,
+ prompt: str | Omit = omit,
+ response_format: AudioResponseFormat | Omit = omit,
+ stream: Optional[Literal[False]] | Omit = omit,
+ temperature: float | Omit = omit,
+ timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Transcription | TranscriptionVerbose | TranscriptionDiarized | str:
"""
Transcribes audio into the input language.
@@ -602,7 +879,7 @@ async def create(
(which is powered by our open source Whisper V2 model), and
`gpt-4o-transcribe-diarize`.
- chunking_strategy: Controls how the audio is cut into chunks. When set to `\"auto\"`, the server
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
first normalizes loudness and then uses voice activity detection (VAD) to choose
boundaries. `server_vad` object can be provided to tweak VAD detection
parameters manually. If unset, the audio is transcribed as a single block.
@@ -674,49 +951,12 @@ async def create(
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
- """
- @overload
- async def create(
- self,
- *,
- file: FileTypes,
- model: Union[str, AudioModel],
- chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
- include: List[TranscriptionInclude] | Omit = omit,
- keywords: SequenceNotStr[str] | Omit = omit,
- response_format: Literal["verbose_json"],
- language: str | Omit = omit,
- languages: SequenceNotStr[str] | Omit = omit,
- prompt: str | Omit = omit,
- temperature: float | Omit = omit,
- timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> TranscriptionVerbose: ...
+ extra_body: Add additional JSON properties to the request
- @overload
- async def create(
- self,
- *,
- file: FileTypes,
- model: Union[str, AudioModel],
- chunking_strategy: Optional[transcription_create_params.ChunkingStrategy] | Omit = omit,
- include: List[TranscriptionInclude] | Omit = omit,
- response_format: Literal["text", "srt", "vtt"],
- keywords: SequenceNotStr[str] | Omit = omit,
- language: str | Omit = omit,
- languages: SequenceNotStr[str] | Omit = omit,
- prompt: str | Omit = omit,
- temperature: float | Omit = omit,
- timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> str: ...
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
@overload
async def create(
@@ -733,9 +973,11 @@ async def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: AudioResponseFormat | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -768,7 +1010,7 @@ async def create(
Note: Streaming is not supported for the `whisper-1` model and will be ignored.
- chunking_strategy: Controls how the audio is cut into chunks. When set to `\"auto\"`, the server
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
first normalizes loudness and then uses voice activity detection (VAD) to choose
boundaries. `server_vad` object can be provided to tweak VAD detection
parameters manually. If unset, the audio is transcribed as a single block.
@@ -836,6 +1078,7 @@ async def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@overload
async def create(
@@ -852,14 +1095,16 @@ async def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: AudioResponseFormat | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> TranscriptionCreateResponse | AsyncStream[TranscriptionStreamEvent]:
+ ) -> Transcription | TranscriptionVerbose | TranscriptionDiarized | str | AsyncStream[TranscriptionStreamEvent]:
"""
Transcribes audio into the input language.
@@ -887,7 +1132,7 @@ async def create(
Note: Streaming is not supported for the `whisper-1` model and will be ignored.
- chunking_strategy: Controls how the audio is cut into chunks. When set to `\"auto\"`, the server
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
first normalizes loudness and then uses voice activity detection (VAD) to choose
boundaries. `server_vad` object can be provided to tweak VAD detection
parameters manually. If unset, the audio is transcribed as a single block.
@@ -955,6 +1200,7 @@ async def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@required_args(["file", "model"], ["file", "model", "stream"])
async def create(
@@ -970,15 +1216,112 @@ async def create(
language: str | Omit = omit,
languages: SequenceNotStr[str] | Omit = omit,
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: AudioResponseFormat | Omit = omit,
stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
temperature: float | Omit = omit,
timestamp_granularities: List[Literal["word", "segment"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> Transcription | TranscriptionVerbose | TranscriptionDiarized | str | AsyncStream[TranscriptionStreamEvent]:
+ """
+ Transcribes audio into the input language.
+
+ Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
+ format, plain text in `text`, `srt`, or `vtt` format, or a stream of
+ transcript events. Supported formats depend on the model.
+
+ Args:
+ file: The audio file object (not file name) to transcribe, in one of these formats:
+ flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include
+ enough format metadata for the file to be identified. We recommend an
+ extension-bearing filename and an appropriate content type.
+
+ model: ID of the model to use. The options are `gpt-transcribe`, `gpt-4o-transcribe`,
+ `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1`
+ (which is powered by our open source Whisper V2 model), and
+ `gpt-4o-transcribe-diarize`.
+
+ chunking_strategy: Controls how the audio is cut into chunks. When set to `"auto"`, the server
+ first normalizes loudness and then uses voice activity detection (VAD) to choose
+ boundaries. `server_vad` object can be provided to tweak VAD detection
+ parameters manually. If unset, the audio is transcribed as a single block.
+ Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30
+ seconds.
+
+ include: Additional information to include in the transcription response. `logprobs` will
+ return the log probabilities of the tokens in the response to understand the
+ model's confidence in the transcription. `logprobs` only works with
+ response_format set to `json` and only with the models `gpt-4o-transcribe`,
+ `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is
+ not supported when using `gpt-4o-transcribe-diarize`.
+
+ keywords: Words or phrases to guide transcription of the input audio. Supported by
+ `gpt-transcribe`.
+
+ known_speaker_names: Optional list of speaker names that correspond to the audio samples provided in
+ `known_speaker_references[]`. Each entry should be a short identifier (for
+ example `customer` or `agent`). Up to 4 speakers are supported.
+
+ known_speaker_references: Optional list of audio samples (as
+ [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs))
+ that contain known speaker references matching `known_speaker_names[]`. Each
+ sample must be between 2 and 10 seconds, and can use any of the same input audio
+ formats supported by `file`.
+
+ language: The language of the input audio. Supplying the input language in
+ [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
+ format will improve accuracy and latency.
+
+ languages: Possible languages of the input audio, in
+ [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format.
+ Supported by `gpt-transcribe`.
+
+ prompt: An optional text to guide the model's style or continue a previous audio
+ segment. The
+ [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting)
+ should match the audio language. This field is not supported when using
+ `gpt-4o-transcribe-diarize`.
+
+ response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
+ `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and
+ `gpt-4o-mini-transcribe`, the only supported format is `json`. For
+ `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and
+ `diarized_json`, with `diarized_json` required to receive speaker annotations.
+
+ stream: If set to true, the model response data will be streamed to the client as 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).
+ See the
+ [Streaming section of the Speech-to-Text guide](https://developers.openai.com/api/docs/guides/speech-to-text?lang=curl#streaming)
+ for more information.
+
+ Note: Streaming is not supported for the `whisper-1` model and will be ignored.
+
+ temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
+ output more random, while lower values like 0.2 will make it more focused and
+ deterministic. If set to 0, the model will use
+ [log probability](https://en.wikipedia.org/wiki/Log_probability) to
+ automatically increase the temperature until certain thresholds are hit.
+
+ timestamp_granularities: The timestamp granularities to populate for this transcription.
+ `response_format` must be set `verbose_json` to use timestamp granularities.
+ Either or both of these options are supported: `word`, or `segment`. Note: There
+ is no additional latency for segment timestamps, but generating word timestamps
+ incurs additional latency. This option is not available for
+ `gpt-4o-transcribe-diarize`.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
body = deepcopy_with_paths(
{
"file": file,
@@ -1019,7 +1362,7 @@ async def create(
timeout=timeout,
security={"bearer_auth": True},
),
- cast_to=_get_response_format_type(response_format),
+ cast_to=_create_response_format_type(response_format, log=logging.getLogger("openai.audio.transcriptions")),
stream=stream or False,
stream_cls=AsyncStream[TranscriptionStreamEvent],
)
diff --git a/src/openai/resources/audio/translations.py b/src/openai/resources/audio/translations.py
index f05c9bccd9..779da4e8a4 100644
--- a/src/openai/resources/audio/translations.py
+++ b/src/openai/resources/audio/translations.py
@@ -20,6 +20,7 @@
from ...types.audio import translation_create_params
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
+from ...lib._parsing._audio import get_translation_response_format_type as _create_response_format_type
from ...types.audio.translation import Translation
from ...types.audio_response_format import AudioResponseFormat
from ...types.audio.translation_verbose import TranslationVerbose
@@ -30,7 +31,8 @@
log: logging.Logger = logging.getLogger("openai.audio.transcriptions")
-def _get_response_format_type(
+# Retained module entry point; callers may live outside generated resources.
+def _get_response_format_type( # pyright: ignore[reportUnusedFunction]
response_format: AudioResponseFormat | Omit,
) -> type[Translation | TranslationVerbose | str]:
return openai.lib._parsing._audio.get_translation_response_format_type(response_format, log=log)
@@ -64,9 +66,11 @@ def create(
*,
file: FileTypes,
model: Union[str, AudioModel],
- response_format: Union[Literal["json"], Omit] = omit,
prompt: str | Omit = omit,
+ response_format: Literal["json"] | Omit = omit,
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -79,9 +83,11 @@ def create(
*,
file: FileTypes,
model: Union[str, AudioModel],
- response_format: Literal["verbose_json"],
prompt: str | Omit = omit,
+ response_format: Literal["verbose_json"],
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -94,23 +100,44 @@ def create(
*,
file: FileTypes,
model: Union[str, AudioModel],
- response_format: Literal["text", "srt", "vtt"],
prompt: str | Omit = omit,
+ response_format: Literal["text", "srt", "vtt"],
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> str: ...
+ @overload
+ def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ prompt: str | Omit = omit,
+ response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | Omit = omit,
+ temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Translation | TranslationVerbose | str: ...
+
def create(
self,
*,
file: FileTypes,
model: Union[str, AudioModel],
prompt: str | Omit = omit,
- response_format: Union[Literal["json", "text", "srt", "verbose_json", "vtt"], Omit] = omit,
+ response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | Omit = omit,
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -176,7 +203,7 @@ def create(
timeout=timeout,
security={"bearer_auth": True},
),
- cast_to=_get_response_format_type(response_format),
+ cast_to=_create_response_format_type(response_format, log=logging.getLogger("openai.audio.transcriptions")),
)
@@ -208,9 +235,11 @@ async def create(
*,
file: FileTypes,
model: Union[str, AudioModel],
- response_format: Union[Literal["json"], Omit] = omit,
prompt: str | Omit = omit,
+ response_format: Literal["json"] | Omit = omit,
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -223,9 +252,11 @@ async def create(
*,
file: FileTypes,
model: Union[str, AudioModel],
- response_format: Literal["verbose_json"],
prompt: str | Omit = omit,
+ response_format: Literal["verbose_json"],
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -238,23 +269,44 @@ async def create(
*,
file: FileTypes,
model: Union[str, AudioModel],
- response_format: Literal["text", "srt", "vtt"],
prompt: str | Omit = omit,
+ response_format: Literal["text", "srt", "vtt"],
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> str: ...
+ @overload
+ async def create(
+ self,
+ *,
+ file: FileTypes,
+ model: Union[str, AudioModel],
+ prompt: str | Omit = omit,
+ response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | Omit = omit,
+ temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Translation | TranslationVerbose | str: ...
+
async def create(
self,
*,
file: FileTypes,
model: Union[str, AudioModel],
prompt: str | Omit = omit,
- response_format: Union[AudioResponseFormat, Omit] = omit,
+ response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | Omit = omit,
temperature: float | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -320,7 +372,7 @@ async def create(
timeout=timeout,
security={"bearer_auth": True},
),
- cast_to=_get_response_format_type(response_format),
+ cast_to=_create_response_format_type(response_format, log=logging.getLogger("openai.audio.transcriptions")),
)
diff --git a/src/openai/resources/beta/agents/sessions/sessions.py b/src/openai/resources/beta/agents/sessions/sessions.py
index 6a9658a501..c2d124c5f8 100644
--- a/src/openai/resources/beta/agents/sessions/sessions.py
+++ b/src/openai/resources/beta/agents/sessions/sessions.py
@@ -171,42 +171,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AgentSession:
- """Creates a managed agent session, optionally submits initial input, and returns
- the session or streams its events when stream is true. See
- [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
-
- Args:
- environment: An inline execution environment or a reference to an environment template.
-
- agent: Agent configuration. With `agent_id`, supplied fields override the saved agent
- for this session. Without `agent_id`, `model` is required.
-
- agent_id: The ID of a saved reusable agent. Omit `agent` to use its configuration
- unchanged.
-
- input: Initial input to submit when the session is created. A string is shorthand for a
- single user message. Required when `environment.type` is `none`, or when
- `stream` is `true` for an environment that is not `self_hosted`; optional for
- self-hosted and non-streaming execution environments.
-
- metadata: Up to 16 string key-value pairs, with keys up to 64 and values up to 512
- characters. Omission or null defaults to an empty map.
-
- spend_control: Optional spending limit in USD cents. Omission or null creates an unlimited
- session.
-
- stream: Whether to stream session events as server-sent events. Defaults to `false`.
-
- vault_ids: The IDs of vaults made available to the session.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds"""
+ ) -> AgentSession: ...
@overload
def create(
@@ -226,42 +191,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AgentSessionEventStream[OutputT]:
- """Creates a managed agent session, optionally submits initial input, and returns
- the session or streams its events when stream is true. See
- [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
-
- Args:
- environment: An inline execution environment or a reference to an environment template.
-
- stream: Whether to stream session events as server-sent events. Defaults to `false`.
-
- agent: Agent configuration. With `agent_id`, supplied fields override the saved agent
- for this session. Without `agent_id`, `model` is required.
-
- agent_id: The ID of a saved reusable agent. Omit `agent` to use its configuration
- unchanged.
-
- input: Initial input to submit when the session is created. A string is shorthand for a
- single user message. Required when `environment.type` is `none`, or when
- `stream` is `true` for an environment that is not `self_hosted`; optional for
- self-hosted and non-streaming execution environments.
-
- metadata: Up to 16 string key-value pairs, with keys up to 64 and values up to 512
- characters. Omission or null defaults to an empty map.
-
- spend_control: Optional spending limit in USD cents. Omission or null creates an unlimited
- session.
-
- vault_ids: The IDs of vaults made available to the session.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds"""
+ ) -> AgentSessionEventStream[OutputT]: ...
@overload
def create(
@@ -281,42 +211,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AgentSession | AgentSessionEventStream[OutputT]:
- """Creates a managed agent session, optionally submits initial input, and returns
- the session or streams its events when stream is true. See
- [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
-
- Args:
- environment: An inline execution environment or a reference to an environment template.
-
- stream: Whether to stream session events as server-sent events. Defaults to `false`.
-
- agent: Agent configuration. With `agent_id`, supplied fields override the saved agent
- for this session. Without `agent_id`, `model` is required.
-
- agent_id: The ID of a saved reusable agent. Omit `agent` to use its configuration
- unchanged.
-
- input: Initial input to submit when the session is created. A string is shorthand for a
- single user message. Required when `environment.type` is `none`, or when
- `stream` is `true` for an environment that is not `self_hosted`; optional for
- self-hosted and non-streaming execution environments.
-
- metadata: Up to 16 string key-value pairs, with keys up to 64 and values up to 512
- characters. Omission or null defaults to an empty map.
-
- spend_control: Optional spending limit in USD cents. Omission or null creates an unlimited
- session.
-
- vault_ids: The IDs of vaults made available to the session.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds"""
+ ) -> AgentSession | AgentSessionEventStream[OutputT]: ...
@required_args(["environment"], ["environment", "stream"])
def create(
@@ -599,12 +494,12 @@ def stream(
) -> AsyncAgentSessionStream[OutputT]:
"""Stream one turn of an idle session, subscribing before submitting input.
- Use as an async context manager. Only one caller may submit input to the session
+ Use as a context manager. Only one caller may submit input to the session
while this helper runs. Optional tool handlers receive an arguments dict;
their results are submitted automatically. Use on_tool_error alongside
tool_handlers to log or monitor local argument, handler, and output failures.
- The callback may be async; it does not receive API or stream errors.
- Ordinary observer exceptions are ignored. See AsyncAgentSessionStream for details."""
+ The callback does not receive API or stream errors. Ordinary observer
+ exceptions are ignored. See AgentSessionStream for details."""
return AsyncAgentSessionStream(
self,
session_id,
@@ -678,42 +573,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AgentSession:
- """Creates a managed agent session, optionally submits initial input, and returns
- the session or streams its events when stream is true. See
- [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
-
- Args:
- environment: An inline execution environment or a reference to an environment template.
-
- agent: Agent configuration. With `agent_id`, supplied fields override the saved agent
- for this session. Without `agent_id`, `model` is required.
-
- agent_id: The ID of a saved reusable agent. Omit `agent` to use its configuration
- unchanged.
-
- input: Initial input to submit when the session is created. A string is shorthand for a
- single user message. Required when `environment.type` is `none`, or when
- `stream` is `true` for an environment that is not `self_hosted`; optional for
- self-hosted and non-streaming execution environments.
-
- metadata: Up to 16 string key-value pairs, with keys up to 64 and values up to 512
- characters. Omission or null defaults to an empty map.
-
- spend_control: Optional spending limit in USD cents. Omission or null creates an unlimited
- session.
-
- stream: Whether to stream session events as server-sent events. Defaults to `false`.
-
- vault_ids: The IDs of vaults made available to the session.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds"""
+ ) -> AgentSession: ...
@overload
async def create(
@@ -733,42 +593,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AsyncAgentSessionEventStream[OutputT]:
- """Creates a managed agent session, optionally submits initial input, and returns
- the session or streams its events when stream is true. See
- [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
-
- Args:
- environment: An inline execution environment or a reference to an environment template.
-
- stream: Whether to stream session events as server-sent events. Defaults to `false`.
-
- agent: Agent configuration. With `agent_id`, supplied fields override the saved agent
- for this session. Without `agent_id`, `model` is required.
-
- agent_id: The ID of a saved reusable agent. Omit `agent` to use its configuration
- unchanged.
-
- input: Initial input to submit when the session is created. A string is shorthand for a
- single user message. Required when `environment.type` is `none`, or when
- `stream` is `true` for an environment that is not `self_hosted`; optional for
- self-hosted and non-streaming execution environments.
-
- metadata: Up to 16 string key-value pairs, with keys up to 64 and values up to 512
- characters. Omission or null defaults to an empty map.
-
- spend_control: Optional spending limit in USD cents. Omission or null creates an unlimited
- session.
-
- vault_ids: The IDs of vaults made available to the session.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds"""
+ ) -> AsyncAgentSessionEventStream[OutputT]: ...
@overload
async def create(
@@ -788,42 +613,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AgentSession | AsyncAgentSessionEventStream[OutputT]:
- """Creates a managed agent session, optionally submits initial input, and returns
- the session or streams its events when stream is true. See
- [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
-
- Args:
- environment: An inline execution environment or a reference to an environment template.
-
- stream: Whether to stream session events as server-sent events. Defaults to `false`.
-
- agent: Agent configuration. With `agent_id`, supplied fields override the saved agent
- for this session. Without `agent_id`, `model` is required.
-
- agent_id: The ID of a saved reusable agent. Omit `agent` to use its configuration
- unchanged.
-
- input: Initial input to submit when the session is created. A string is shorthand for a
- single user message. Required when `environment.type` is `none`, or when
- `stream` is `true` for an environment that is not `self_hosted`; optional for
- self-hosted and non-streaming execution environments.
-
- metadata: Up to 16 string key-value pairs, with keys up to 64 and values up to 512
- characters. Omission or null defaults to an empty map.
-
- spend_control: Optional spending limit in USD cents. Omission or null creates an unlimited
- session.
-
- vault_ids: The IDs of vaults made available to the session.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds"""
+ ) -> AgentSession | AsyncAgentSessionEventStream[OutputT]: ...
@required_args(["environment"], ["environment", "stream"])
async def create(
diff --git a/src/openai/resources/beta/threads/runs/runs.py b/src/openai/resources/beta/threads/runs/runs.py
index 93deafc3f9..ad783a9ff3 100644
--- a/src/openai/resources/beta/threads/runs/runs.py
+++ b/src/openai/resources/beta/threads/runs/runs.py
@@ -17,7 +17,7 @@
StepsWithStreamingResponse,
AsyncStepsWithStreamingResponse,
)
-from ....._types import NOT_GIVEN, Body, Omit, Query, Headers, NotGiven, omit, not_given
+from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ....._utils import path_template, required_args, maybe_transform, async_maybe_transform
from ....._compat import cached_property
from ....._resource import SyncAPIResource, AsyncAPIResource
@@ -93,6 +93,410 @@ def with_streaming_response(self) -> RunsWithStreamingResponse:
"""
return RunsWithStreamingResponse(self)
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_poll(
+ self,
+ *,
+ assistant_id: str,
+ include: List[RunStepInclude] | Omit = omit,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ poll_interval_ms: int | Omit = omit,
+ thread_id: str,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run:
+ """A helper to create a run an poll for a terminal state. More information on Run
+ lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+ return runs_create_and_poll(
+ self,
+ assistant_id=assistant_id,
+ include=include,
+ additional_instructions=additional_instructions,
+ additional_messages=additional_messages,
+ instructions=instructions,
+ max_completion_tokens=max_completion_tokens,
+ max_prompt_tokens=max_prompt_tokens,
+ metadata=metadata,
+ model=model,
+ parallel_tool_calls=parallel_tool_calls,
+ reasoning_effort=reasoning_effort,
+ response_format=response_format,
+ temperature=temperature,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_p=top_p,
+ truncation_strategy=truncation_strategy,
+ poll_interval_ms=poll_interval_ms,
+ thread_id=thread_id,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_stream(
+ self,
+ *,
+ assistant_id: str,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ thread_id: str,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler]:
+ """Create a Run stream"""
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_stream(
+ self,
+ *,
+ assistant_id: str,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ thread_id: str,
+ event_handler: AssistantEventHandlerT,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ """Create a Run stream"""
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_stream(
+ self,
+ *,
+ assistant_id: str,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ thread_id: str,
+ event_handler: AssistantEventHandlerT | None = None,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ """Create a Run stream"""
+ return runs_create_and_stream(
+ self,
+ assistant_id=assistant_id,
+ additional_instructions=additional_instructions,
+ additional_messages=additional_messages,
+ instructions=instructions,
+ max_completion_tokens=max_completion_tokens,
+ max_prompt_tokens=max_prompt_tokens,
+ metadata=metadata,
+ model=model,
+ parallel_tool_calls=parallel_tool_calls,
+ reasoning_effort=reasoning_effort,
+ response_format=response_format,
+ temperature=temperature,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_p=top_p,
+ truncation_strategy=truncation_strategy,
+ thread_id=thread_id,
+ event_handler=event_handler,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def poll(
+ self,
+ run_id: str,
+ thread_id: str,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ poll_interval_ms: int | Omit = omit,
+ ) -> Run:
+ """A helper to poll a run status until it reaches a terminal state. More
+ information on Run lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+ return runs_poll(
+ self,
+ run_id=run_id,
+ thread_id=thread_id,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ poll_interval_ms=poll_interval_ms,
+ )
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def stream(
+ self,
+ *,
+ assistant_id: str,
+ include: List[RunStepInclude] | Omit = omit,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ thread_id: str,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler]:
+ """Create a Run stream"""
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def stream(
+ self,
+ *,
+ assistant_id: str,
+ include: List[RunStepInclude] | Omit = omit,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ thread_id: str,
+ event_handler: AssistantEventHandlerT,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ """Create a Run stream"""
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def stream(
+ self,
+ *,
+ assistant_id: str,
+ include: List[RunStepInclude] | Omit = omit,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
+ thread_id: str,
+ event_handler: AssistantEventHandlerT | None = None,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ """Create a Run stream"""
+ return runs_stream(
+ self,
+ assistant_id=assistant_id,
+ include=include,
+ additional_instructions=additional_instructions,
+ additional_messages=additional_messages,
+ instructions=instructions,
+ max_completion_tokens=max_completion_tokens,
+ max_prompt_tokens=max_prompt_tokens,
+ metadata=metadata,
+ model=model,
+ parallel_tool_calls=parallel_tool_calls,
+ reasoning_effort=reasoning_effort,
+ response_format=response_format,
+ temperature=temperature,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_p=top_p,
+ truncation_strategy=truncation_strategy,
+ thread_id=thread_id,
+ event_handler=event_handler,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs_and_poll(
+ self,
+ *,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ run_id: str,
+ thread_id: str,
+ poll_interval_ms: int | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run:
+ """A helper to submit a tool output to a run and poll for a terminal run state.
+ More information on Run lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+ return runs_submit_tool_outputs_and_poll(
+ self,
+ tool_outputs=tool_outputs,
+ run_id=run_id,
+ thread_id=thread_id,
+ poll_interval_ms=poll_interval_ms,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs_stream(
+ self,
+ *,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ run_id: str,
+ thread_id: str,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler]:
+ """Submit the tool outputs from a previous run and stream the run to a terminal
+ state. More information on Run lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs_stream(
+ self,
+ *,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ run_id: str,
+ thread_id: str,
+ event_handler: AssistantEventHandlerT,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ """Submit the tool outputs from a previous run and stream the run to a terminal
+ state. More information on Run lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs_stream(
+ self,
+ *,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ run_id: str,
+ thread_id: str,
+ event_handler: AssistantEventHandlerT | None = None,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ """Submit the tool outputs from a previous run and stream the run to a terminal
+ state. More information on Run lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+ return runs_submit_tool_outputs_stream(
+ self,
+ tool_outputs=tool_outputs,
+ run_id=run_id,
+ thread_id=thread_id,
+ event_handler=event_handler,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
@overload
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create(
@@ -814,19 +1218,210 @@ def cancel(
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
return self._post(
- path_template("/threads/{thread_id}/runs/{run_id}/cancel", thread_id=thread_id, run_id=run_id),
+ path_template("/threads/{thread_id}/runs/{run_id}/cancel", thread_id=thread_id, run_id=run_id),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ security={"bearer_auth": True},
+ ),
+ cast_to=Run,
+ )
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs(
+ self,
+ run_id: str,
+ *,
+ thread_id: str,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ stream: Optional[Literal[False]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run:
+ """
+ When a run has the `status: "requires_action"` and `required_action.type` is
+ `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
+ tool calls once they're all completed. All outputs must be submitted in a single
+ request.
+
+ Args:
+ tool_outputs: A list of tools for which the outputs are being submitted.
+
+ stream: If `true`, returns a stream of events that happen during the Run as server-sent
+ events, terminating when the Run enters a terminal state with a `data: [DONE]`
+ message.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs(
+ self,
+ run_id: str,
+ *,
+ thread_id: str,
+ stream: Literal[True],
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Stream[AssistantStreamEvent]:
+ """
+ When a run has the `status: "requires_action"` and `required_action.type` is
+ `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
+ tool calls once they're all completed. All outputs must be submitted in a single
+ request.
+
+ Args:
+ stream: If `true`, returns a stream of events that happen during the Run as server-sent
+ events, terminating when the Run enters a terminal state with a `data: [DONE]`
+ message.
+
+ tool_outputs: A list of tools for which the outputs are being submitted.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs(
+ self,
+ run_id: str,
+ *,
+ thread_id: str,
+ stream: bool,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run | Stream[AssistantStreamEvent]:
+ """
+ When a run has the `status: "requires_action"` and `required_action.type` is
+ `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
+ tool calls once they're all completed. All outputs must be submitted in a single
+ request.
+
+ Args:
+ stream: If `true`, returns a stream of events that happen during the Run as server-sent
+ events, terminating when the Run enters a terminal state with a `data: [DONE]`
+ message.
+
+ tool_outputs: A list of tools for which the outputs are being submitted.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ @required_args(["thread_id", "tool_outputs"], ["thread_id", "stream", "tool_outputs"])
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def submit_tool_outputs(
+ self,
+ run_id: str,
+ *,
+ thread_id: str,
+ tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
+ stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run | Stream[AssistantStreamEvent]:
+ if not thread_id:
+ raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
+ if not run_id:
+ raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
+ extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
+ return self._post(
+ path_template("/threads/{thread_id}/runs/{run_id}/submit_tool_outputs", thread_id=thread_id, run_id=run_id),
+ body=maybe_transform(
+ {
+ "stream": stream,
+ "tool_outputs": tool_outputs,
+ },
+ run_submit_tool_outputs_params.RunSubmitToolOutputsParamsStreaming
+ if stream
+ else run_submit_tool_outputs_params.RunSubmitToolOutputsParamsNonStreaming,
+ ),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
security={"bearer_auth": True},
+ synthesize_event_and_data=True,
),
cast_to=Run,
+ stream=stream or False,
+ stream_cls=Stream[AssistantStreamEvent],
)
+
+class AsyncRuns(AsyncAPIResource):
+ """Build Assistants that can call models and use tools."""
+
+ @cached_property
+ def steps(self) -> AsyncSteps:
+ """Build Assistants that can call models and use tools."""
+ return AsyncSteps(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AsyncRunsWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
+ """
+ return AsyncRunsWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncRunsWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/openai/openai-python#with_streaming_response
+ """
+ return AsyncRunsWithStreamingResponse(self)
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def create_and_poll(
+ async def create_and_poll(
self,
*,
assistant_id: str,
@@ -851,12 +1446,12 @@ def create_and_poll(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> Run:
"""A helper to create a run an poll for a terminal state. More information on Run
lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return runs_create_and_poll(
+ return await async_runs_create_and_poll(
self,
assistant_id=assistant_id,
include=include,
@@ -884,7 +1479,7 @@ def create_and_poll(
)
@overload
- @typing_extensions.deprecated("use `stream` instead")
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create_and_stream(
self,
*,
@@ -897,7 +1492,6 @@ def create_and_stream(
metadata: Optional[Metadata] | Omit = omit,
model: Union[str, ChatModel, None] | Omit = omit,
parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
temperature: Optional[float] | Omit = omit,
tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
@@ -908,12 +1502,12 @@ def create_and_stream(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
"""Create a Run stream"""
@overload
- @typing_extensions.deprecated("use `stream` instead")
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create_and_stream(
self,
*,
@@ -926,7 +1520,6 @@ def create_and_stream(
metadata: Optional[Metadata] | Omit = omit,
model: Union[str, ChatModel, None] | Omit = omit,
parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
temperature: Optional[float] | Omit = omit,
tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
@@ -934,15 +1527,15 @@ def create_and_stream(
top_p: Optional[float] | Omit = omit,
truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
thread_id: str,
- event_handler: AssistantEventHandlerT,
+ event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
"""Create a Run stream"""
- @typing_extensions.deprecated("use `stream` instead")
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create_and_stream(
self,
*,
@@ -955,7 +1548,6 @@ def create_and_stream(
metadata: Optional[Metadata] | Omit = omit,
model: Union[str, ChatModel, None] | Omit = omit,
parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
temperature: Optional[float] | Omit = omit,
tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
@@ -963,14 +1555,17 @@ def create_and_stream(
top_p: Optional[float] | Omit = omit,
truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
thread_id: str,
- event_handler: AssistantEventHandlerT | None = None,
+ event_handler: AsyncAssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> (
+ AsyncAssistantStreamManager[AsyncAssistantEventHandler]
+ | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
+ ):
"""Create a Run stream"""
- return runs_create_and_stream(
+ return async_runs_create_and_stream(
self,
assistant_id=assistant_id,
additional_instructions=additional_instructions,
@@ -981,7 +1576,6 @@ def create_and_stream(
metadata=metadata,
model=model,
parallel_tool_calls=parallel_tool_calls,
- reasoning_effort=reasoning_effort,
response_format=response_format,
temperature=temperature,
tool_choice=tool_choice,
@@ -997,7 +1591,7 @@ def create_and_stream(
)
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def poll(
+ async def poll(
self,
run_id: str,
thread_id: str,
@@ -1010,7 +1604,7 @@ def poll(
"""A helper to poll a run status until it reaches a terminal state. More
information on Run lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return runs_poll(
+ return await async_runs_poll(
self,
run_id=run_id,
thread_id=thread_id,
@@ -1027,7 +1621,6 @@ def stream(
self,
*,
assistant_id: str,
- include: List[RunStepInclude] | Omit = omit,
additional_instructions: Optional[str] | Omit = omit,
additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
instructions: Optional[str] | Omit = omit,
@@ -1047,8 +1640,8 @@ def stream(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
"""Create a Run stream"""
@overload
@@ -1074,235 +1667,75 @@ def stream(
top_p: Optional[float] | Omit = omit,
truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
thread_id: str,
- event_handler: AssistantEventHandlerT,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandlerT]:
- """Create a Run stream"""
-
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def stream(
- self,
- *,
- assistant_id: str,
- include: List[RunStepInclude] | Omit = omit,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
- thread_id: str,
- event_handler: AssistantEventHandlerT | None = None,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
- """Create a Run stream"""
- return runs_stream(
- self,
- assistant_id=assistant_id,
- include=include,
- additional_instructions=additional_instructions,
- additional_messages=additional_messages,
- instructions=instructions,
- max_completion_tokens=max_completion_tokens,
- max_prompt_tokens=max_prompt_tokens,
- metadata=metadata,
- model=model,
- parallel_tool_calls=parallel_tool_calls,
- reasoning_effort=reasoning_effort,
- response_format=response_format,
- temperature=temperature,
- tool_choice=tool_choice,
- tools=tools,
- top_p=top_p,
- truncation_strategy=truncation_strategy,
- thread_id=thread_id,
- event_handler=event_handler,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs(
- self,
- run_id: str,
- *,
- thread_id: str,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- stream: Optional[Literal[False]] | Omit = omit,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Run:
- """
- When a run has the `status: "requires_action"` and `required_action.type` is
- `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
- tool calls once they're all completed. All outputs must be submitted in a single
- request.
-
- Args:
- tool_outputs: A list of tools for which the outputs are being submitted.
-
- stream: If `true`, returns a stream of events that happen during the Run as server-sent
- events, terminating when the Run enters a terminal state with a `data: [DONE]`
- message.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- ...
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs(
- self,
- run_id: str,
- *,
- thread_id: str,
- stream: Literal[True],
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Stream[AssistantStreamEvent]:
- """
- When a run has the `status: "requires_action"` and `required_action.type` is
- `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
- tool calls once they're all completed. All outputs must be submitted in a single
- request.
-
- Args:
- stream: If `true`, returns a stream of events that happen during the Run as server-sent
- events, terminating when the Run enters a terminal state with a `data: [DONE]`
- message.
-
- tool_outputs: A list of tools for which the outputs are being submitted.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- ...
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs(
- self,
- run_id: str,
- *,
- thread_id: str,
- stream: bool,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
+ event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Run | Stream[AssistantStreamEvent]:
- """
- When a run has the `status: "requires_action"` and `required_action.type` is
- `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
- tool calls once they're all completed. All outputs must be submitted in a single
- request.
-
- Args:
- stream: If `true`, returns a stream of events that happen during the Run as server-sent
- events, terminating when the Run enters a terminal state with a `data: [DONE]`
- message.
-
- tool_outputs: A list of tools for which the outputs are being submitted.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- ...
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
+ """Create a Run stream"""
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- @required_args(["thread_id", "tool_outputs"], ["thread_id", "stream", "tool_outputs"])
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs(
+ def stream(
self,
- run_id: str,
*,
+ assistant_id: str,
+ include: List[RunStepInclude] | Omit = omit,
+ additional_instructions: Optional[str] | Omit = omit,
+ additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
thread_id: str,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
+ event_handler: AsyncAssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Run | Stream[AssistantStreamEvent]:
- if not thread_id:
- raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
- if not run_id:
- raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
- extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
- return self._post(
- path_template("/threads/{thread_id}/runs/{run_id}/submit_tool_outputs", thread_id=thread_id, run_id=run_id),
- body=maybe_transform(
- {
- "stream": stream,
- "tool_outputs": tool_outputs,
- },
- run_submit_tool_outputs_params.RunSubmitToolOutputsParamsStreaming
- if stream
- else run_submit_tool_outputs_params.RunSubmitToolOutputsParamsNonStreaming,
- ),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- security={"bearer_auth": True},
- synthesize_event_and_data=True,
- ),
- cast_to=Run,
- stream=stream or False,
- stream_cls=Stream[AssistantStreamEvent],
+ ) -> (
+ AsyncAssistantStreamManager[AsyncAssistantEventHandler]
+ | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
+ ):
+ """Create a Run stream"""
+ return async_runs_stream(
+ self,
+ assistant_id=assistant_id,
+ include=include,
+ additional_instructions=additional_instructions,
+ additional_messages=additional_messages,
+ instructions=instructions,
+ max_completion_tokens=max_completion_tokens,
+ max_prompt_tokens=max_prompt_tokens,
+ metadata=metadata,
+ model=model,
+ parallel_tool_calls=parallel_tool_calls,
+ reasoning_effort=reasoning_effort,
+ response_format=response_format,
+ temperature=temperature,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_p=top_p,
+ truncation_strategy=truncation_strategy,
+ thread_id=thread_id,
+ event_handler=event_handler,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
)
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs_and_poll(
+ async def submit_tool_outputs_and_poll(
self,
*,
tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
@@ -1312,12 +1745,12 @@ def submit_tool_outputs_and_poll(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> Run:
"""A helper to submit a tool output to a run and poll for a terminal run state.
More information on Run lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return runs_submit_tool_outputs_and_poll(
+ return await async_runs_submit_tool_outputs_and_poll(
self,
tool_outputs=tool_outputs,
run_id=run_id,
@@ -1340,8 +1773,8 @@ def submit_tool_outputs_stream(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
"""Submit the tool outputs from a previous run and stream the run to a terminal
state. More information on Run lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
@@ -1354,12 +1787,12 @@ def submit_tool_outputs_stream(
tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
run_id: str,
thread_id: str,
- event_handler: AssistantEventHandlerT,
+ event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
"""Submit the tool outputs from a previous run and stream the run to a terminal
state. More information on Run lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
@@ -1371,16 +1804,19 @@ def submit_tool_outputs_stream(
tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
run_id: str,
thread_id: str,
- event_handler: AssistantEventHandlerT | None = None,
+ event_handler: AsyncAssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> (
+ AsyncAssistantStreamManager[AsyncAssistantEventHandler]
+ | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
+ ):
"""Submit the tool outputs from a previous run and stream the run to a terminal
state. More information on Run lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return runs_submit_tool_outputs_stream(
+ return async_runs_submit_tool_outputs_stream(
self,
tool_outputs=tool_outputs,
run_id=run_id,
@@ -1392,34 +1828,6 @@ def submit_tool_outputs_stream(
timeout=timeout,
)
-
-class AsyncRuns(AsyncAPIResource):
- """Build Assistants that can call models and use tools."""
-
- @cached_property
- def steps(self) -> AsyncSteps:
- """Build Assistants that can call models and use tools."""
- return AsyncSteps(self._client)
-
- @cached_property
- def with_raw_response(self) -> AsyncRunsWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return
- the raw response object instead of the parsed content.
-
- For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
- """
- return AsyncRunsWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncRunsWithStreamingResponse:
- """
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
-
- For more information, see https://www.github.com/openai/openai-python#with_streaming_response
- """
- return AsyncRunsWithStreamingResponse(self)
-
@overload
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
async def create(
@@ -1959,125 +2367,13 @@ async def retrieve(
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Run:
- """
- Retrieves a run.
-
- Args:
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- if not thread_id:
- raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
- if not run_id:
- raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
- extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
- return await self._get(
- path_template("/threads/{thread_id}/runs/{run_id}", thread_id=thread_id, run_id=run_id),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- security={"bearer_auth": True},
- ),
- cast_to=Run,
- )
-
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- async def update(
- self,
- run_id: str,
- *,
- thread_id: str,
- metadata: Optional[Metadata] | Omit = omit,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Run:
- """
- Modifies a run.
-
- Args:
- metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
- for storing additional information about the object in a structured format, and
- querying for objects via API or the dashboard.
-
- Keys are strings with a maximum length of 64 characters. Values are strings with
- a maximum length of 512 characters.
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- if not thread_id:
- raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
- if not run_id:
- raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
- extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
- return await self._post(
- path_template("/threads/{thread_id}/runs/{run_id}", thread_id=thread_id, run_id=run_id),
- body=await async_maybe_transform({"metadata": metadata}, run_update_params.RunUpdateParams),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- security={"bearer_auth": True},
- ),
- cast_to=Run,
- )
-
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def list(
- self,
- thread_id: str,
- *,
- after: str | Omit = omit,
- before: str | Omit = omit,
- limit: int | Omit = omit,
- order: Literal["asc", "desc"] | Omit = omit,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AsyncPaginator[Run, AsyncCursorPage[Run]]:
- """
- Returns a list of runs belonging to a thread.
-
- Args:
- after: A cursor for use in pagination. `after` is an object ID that defines your place
- in the list. For instance, if you make a list request and receive 100 objects,
- ending with obj_foo, your subsequent call can include after=obj_foo in order to
- fetch the next page of the list.
-
- before: A cursor for use in pagination. `before` is an object ID that defines your place
- in the list. For instance, if you make a list request and receive 100 objects,
- starting with obj_foo, your subsequent call can include before=obj_foo in order
- to fetch the previous page of the list.
-
- limit: A limit on the number of objects to be returned. Limit can range between 1 and
- 100, and the default is 20.
-
- order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
- order and `desc` for descending order.
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run:
+ """
+ Retrieves a run.
+ Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -2088,35 +2384,28 @@ def list(
"""
if not thread_id:
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
+ if not run_id:
+ raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
- return self._get_api_list(
- path_template("/threads/{thread_id}/runs", thread_id=thread_id),
- page=AsyncCursorPage[Run],
+ return await self._get(
+ path_template("/threads/{thread_id}/runs/{run_id}", thread_id=thread_id, run_id=run_id),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=maybe_transform(
- {
- "after": after,
- "before": before,
- "limit": limit,
- "order": order,
- },
- run_list_params.RunListParams,
- ),
security={"bearer_auth": True},
),
- model=Run,
+ cast_to=Run,
)
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- async def cancel(
+ async def update(
self,
run_id: str,
*,
thread_id: str,
+ metadata: Optional[Metadata] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
@@ -2125,9 +2414,16 @@ async def cancel(
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> Run:
"""
- Cancels a run that is `in_progress`.
+ Modifies a run.
Args:
+ metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
+ for storing additional information about the object in a structured format, and
+ querying for objects via API or the dashboard.
+
+ Keys are strings with a maximum length of 64 characters. Values are strings with
+ a maximum length of 512 characters.
+
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -2142,7 +2438,8 @@ async def cancel(
raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
return await self._post(
- path_template("/threads/{thread_id}/runs/{run_id}/cancel", thread_id=thread_id, run_id=run_id),
+ path_template("/threads/{thread_id}/runs/{run_id}", thread_id=thread_id, run_id=run_id),
+ body=await async_maybe_transform({"metadata": metadata}, run_update_params.RunUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -2154,317 +2451,114 @@ async def cancel(
)
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- async def create_and_poll(
- self,
- *,
- assistant_id: str,
- include: List[RunStepInclude] | Omit = omit,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
- poll_interval_ms: int | Omit = omit,
- thread_id: str,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Run:
- """A helper to create a run an poll for a terminal state. More information on Run
- lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return await async_runs_create_and_poll(
- self,
- assistant_id=assistant_id,
- include=include,
- additional_instructions=additional_instructions,
- additional_messages=additional_messages,
- instructions=instructions,
- max_completion_tokens=max_completion_tokens,
- max_prompt_tokens=max_prompt_tokens,
- metadata=metadata,
- model=model,
- parallel_tool_calls=parallel_tool_calls,
- reasoning_effort=reasoning_effort,
- response_format=response_format,
- temperature=temperature,
- tool_choice=tool_choice,
- tools=tools,
- top_p=top_p,
- truncation_strategy=truncation_strategy,
- poll_interval_ms=poll_interval_ms,
- thread_id=thread_id,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- @overload
- @typing_extensions.deprecated("use `stream` instead")
- def create_and_stream(
- self,
- *,
- assistant_id: str,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
- thread_id: str,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
- """Create a Run stream"""
-
- @overload
- @typing_extensions.deprecated("use `stream` instead")
- def create_and_stream(
- self,
- *,
- assistant_id: str,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
- thread_id: str,
- event_handler: AsyncAssistantEventHandlerT,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
- """Create a Run stream"""
-
- @typing_extensions.deprecated("use `stream` instead")
- def create_and_stream(
- self,
- *,
- assistant_id: str,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
- thread_id: str,
- event_handler: AsyncAssistantEventHandlerT | None = None,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> (
- AsyncAssistantStreamManager[AsyncAssistantEventHandler]
- | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
- ):
- """Create a Run stream"""
- return async_runs_create_and_stream(
- self,
- assistant_id=assistant_id,
- additional_instructions=additional_instructions,
- additional_messages=additional_messages,
- instructions=instructions,
- max_completion_tokens=max_completion_tokens,
- max_prompt_tokens=max_prompt_tokens,
- metadata=metadata,
- model=model,
- parallel_tool_calls=parallel_tool_calls,
- response_format=response_format,
- temperature=temperature,
- tool_choice=tool_choice,
- tools=tools,
- top_p=top_p,
- truncation_strategy=truncation_strategy,
- thread_id=thread_id,
- event_handler=event_handler,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- async def poll(
- self,
- run_id: str,
- thread_id: str,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- poll_interval_ms: int | Omit = omit,
- ) -> Run:
- """A helper to poll a run status until it reaches a terminal state. More
- information on Run lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return await async_runs_poll(
- self,
- run_id=run_id,
- thread_id=thread_id,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- poll_interval_ms=poll_interval_ms,
- )
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def stream(
- self,
- *,
- assistant_id: str,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
- thread_id: str,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
- """Create a Run stream"""
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def stream(
+ def list(
self,
- *,
- assistant_id: str,
- include: List[RunStepInclude] | Omit = omit,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
thread_id: str,
- event_handler: AsyncAssistantEventHandlerT,
+ *,
+ after: str | Omit = omit,
+ before: str | Omit = omit,
+ limit: int | Omit = omit,
+ order: Literal["asc", "desc"] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
- """Create a Run stream"""
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncPaginator[Run, AsyncCursorPage[Run]]:
+ """
+ Returns a list of runs belonging to a thread.
+
+ Args:
+ after: A cursor for use in pagination. `after` is an object ID that defines your place
+ in the list. For instance, if you make a list request and receive 100 objects,
+ ending with obj_foo, your subsequent call can include after=obj_foo in order to
+ fetch the next page of the list.
+
+ before: A cursor for use in pagination. `before` is an object ID that defines your place
+ in the list. For instance, if you make a list request and receive 100 objects,
+ starting with obj_foo, your subsequent call can include before=obj_foo in order
+ to fetch the previous page of the list.
+
+ limit: A limit on the number of objects to be returned. Limit can range between 1 and
+ 100, and the default is 20.
+
+ order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
+ order and `desc` for descending order.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not thread_id:
+ raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
+ extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
+ return self._get_api_list(
+ path_template("/threads/{thread_id}/runs", thread_id=thread_id),
+ page=AsyncCursorPage[Run],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "after": after,
+ "before": before,
+ "limit": limit,
+ "order": order,
+ },
+ run_list_params.RunListParams,
+ ),
+ security={"bearer_auth": True},
+ ),
+ model=Run,
+ )
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def stream(
+ async def cancel(
self,
+ run_id: str,
*,
- assistant_id: str,
- include: List[RunStepInclude] | Omit = omit,
- additional_instructions: Optional[str] | Omit = omit,
- additional_messages: Optional[Iterable[run_create_params.AdditionalMessage]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[run_create_params.TruncationStrategy] | Omit = omit,
thread_id: str,
- event_handler: AsyncAssistantEventHandlerT | None = None,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> (
- AsyncAssistantStreamManager[AsyncAssistantEventHandler]
- | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
- ):
- """Create a Run stream"""
- return async_runs_stream(
- self,
- assistant_id=assistant_id,
- include=include,
- additional_instructions=additional_instructions,
- additional_messages=additional_messages,
- instructions=instructions,
- max_completion_tokens=max_completion_tokens,
- max_prompt_tokens=max_prompt_tokens,
- metadata=metadata,
- model=model,
- parallel_tool_calls=parallel_tool_calls,
- reasoning_effort=reasoning_effort,
- response_format=response_format,
- temperature=temperature,
- tool_choice=tool_choice,
- tools=tools,
- top_p=top_p,
- truncation_strategy=truncation_strategy,
- thread_id=thread_id,
- event_handler=event_handler,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run:
+ """
+ Cancels a run that is `in_progress`.
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not thread_id:
+ raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
+ if not run_id:
+ raise ValueError(f"Expected a non-empty value for `run_id` but received {run_id!r}")
+ extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
+ return await self._post(
+ path_template("/threads/{thread_id}/runs/{run_id}/cancel", thread_id=thread_id, run_id=run_id),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ security={"bearer_auth": True},
+ ),
+ cast_to=Run,
)
@overload
@@ -2630,100 +2724,6 @@ async def submit_tool_outputs(
stream_cls=AsyncStream[AssistantStreamEvent],
)
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- async def submit_tool_outputs_and_poll(
- self,
- *,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- run_id: str,
- thread_id: str,
- poll_interval_ms: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Run:
- """A helper to submit a tool output to a run and poll for a terminal run state.
- More information on Run lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return await async_runs_submit_tool_outputs_and_poll(
- self,
- tool_outputs=tool_outputs,
- run_id=run_id,
- thread_id=thread_id,
- poll_interval_ms=poll_interval_ms,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs_stream(
- self,
- *,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- run_id: str,
- thread_id: str,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
- """Submit the tool outputs from a previous run and stream the run to a terminal
- state. More information on Run lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
-
- @overload
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs_stream(
- self,
- *,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- run_id: str,
- thread_id: str,
- event_handler: AsyncAssistantEventHandlerT,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
- """Submit the tool outputs from a previous run and stream the run to a terminal
- state. More information on Run lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
-
- @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
- def submit_tool_outputs_stream(
- self,
- *,
- tool_outputs: Iterable[run_submit_tool_outputs_params.ToolOutput],
- run_id: str,
- thread_id: str,
- event_handler: AsyncAssistantEventHandlerT | None = None,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> (
- AsyncAssistantStreamManager[AsyncAssistantEventHandler]
- | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
- ):
- """Submit the tool outputs from a previous run and stream the run to a terminal
- state. More information on Run lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return async_runs_submit_tool_outputs_stream(
- self,
- tool_outputs=tool_outputs,
- run_id=run_id,
- thread_id=thread_id,
- event_handler=event_handler,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
class RunsWithRawResponse:
def __init__(self, runs: Runs) -> None:
diff --git a/src/openai/resources/beta/threads/threads.py b/src/openai/resources/beta/threads/threads.py
index d2c1ca7fd8..9d1976fb0f 100644
--- a/src/openai/resources/beta/threads/threads.py
+++ b/src/openai/resources/beta/threads/threads.py
@@ -17,7 +17,7 @@
MessagesWithStreamingResponse,
AsyncMessagesWithStreamingResponse,
)
-from ...._types import NOT_GIVEN, Body, Omit, Query, Headers, NotGiven, omit, not_given
+from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ...._utils import path_template, required_args, maybe_transform, async_maybe_transform
from .runs.runs import (
Runs,
@@ -96,6 +96,163 @@ def with_streaming_response(self) -> ThreadsWithStreamingResponse:
"""
return ThreadsWithStreamingResponse(self)
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_run_poll(
+ self,
+ *,
+ assistant_id: str,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ thread: thread_create_and_run_params.Thread | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
+ poll_interval_ms: int | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Run:
+ """A helper to create a thread, start a run and then poll for a terminal state.
+ More information on Run lifecycles can be found here:
+ https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
+ return threads_create_and_run_poll(
+ self,
+ assistant_id=assistant_id,
+ instructions=instructions,
+ max_completion_tokens=max_completion_tokens,
+ max_prompt_tokens=max_prompt_tokens,
+ metadata=metadata,
+ model=model,
+ parallel_tool_calls=parallel_tool_calls,
+ response_format=response_format,
+ temperature=temperature,
+ thread=thread,
+ tool_choice=tool_choice,
+ tool_resources=tool_resources,
+ tools=tools,
+ top_p=top_p,
+ truncation_strategy=truncation_strategy,
+ poll_interval_ms=poll_interval_ms,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_run_stream(
+ self,
+ *,
+ assistant_id: str,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ thread: thread_create_and_run_params.Thread | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler]:
+ """Create a thread and stream the run back"""
+
+ @overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_run_stream(
+ self,
+ *,
+ assistant_id: str,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ thread: thread_create_and_run_params.Thread | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
+ event_handler: AssistantEventHandlerT,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ """Create a thread and stream the run back"""
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ def create_and_run_stream(
+ self,
+ *,
+ assistant_id: str,
+ instructions: Optional[str] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_prompt_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: Union[str, ChatModel, None] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ thread: thread_create_and_run_params.Thread | Omit = omit,
+ tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
+ tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
+ tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
+ event_handler: AssistantEventHandlerT | None = None,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ """Create a thread and stream the run back"""
+ return threads_create_and_run_stream(
+ self,
+ assistant_id=assistant_id,
+ instructions=instructions,
+ max_completion_tokens=max_completion_tokens,
+ max_prompt_tokens=max_prompt_tokens,
+ metadata=metadata,
+ model=model,
+ parallel_tool_calls=parallel_tool_calls,
+ response_format=response_format,
+ temperature=temperature,
+ thread=thread,
+ tool_choice=tool_choice,
+ tool_resources=tool_resources,
+ tools=tools,
+ top_p=top_p,
+ truncation_strategy=truncation_strategy,
+ event_handler=event_handler,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create(
self,
@@ -770,7 +927,41 @@ def create_and_run(
stream_cls=Stream[AssistantStreamEvent],
)
- def create_and_run_poll(
+
+class AsyncThreads(AsyncAPIResource):
+ """Build Assistants that can call models and use tools."""
+
+ @cached_property
+ def runs(self) -> AsyncRuns:
+ """Build Assistants that can call models and use tools."""
+ return AsyncRuns(self._client)
+
+ @cached_property
+ def messages(self) -> AsyncMessages:
+ """Build Assistants that can call models and use tools."""
+ return AsyncMessages(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AsyncThreadsWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
+ """
+ return AsyncThreadsWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncThreadsWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/openai/openai-python#with_streaming_response
+ """
+ return AsyncThreadsWithStreamingResponse(self)
+
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
+ async def create_and_run_poll(
self,
*,
assistant_id: str,
@@ -792,12 +983,12 @@ def create_and_run_poll(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
) -> Run:
"""A helper to create a thread, start a run and then poll for a terminal state.
More information on Run lifecycles can be found here:
https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return threads_create_and_run_poll(
+ return await async_threads_create_and_run_poll(
self,
assistant_id=assistant_id,
instructions=instructions,
@@ -822,6 +1013,7 @@ def create_and_run_poll(
)
@overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create_and_run_stream(
self,
*,
@@ -843,11 +1035,12 @@ def create_and_run_stream(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
"""Create a thread and stream the run back"""
@overload
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create_and_run_stream(
self,
*,
@@ -866,14 +1059,15 @@ def create_and_run_stream(
tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
top_p: Optional[float] | Omit = omit,
truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
- event_handler: AssistantEventHandlerT,
+ event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandlerT]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
"""Create a thread and stream the run back"""
+ @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
def create_and_run_stream(
self,
*,
@@ -892,14 +1086,17 @@ def create_and_run_stream(
tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
top_p: Optional[float] | Omit = omit,
truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
- event_handler: AssistantEventHandlerT | None = None,
+ event_handler: AsyncAssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]:
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> (
+ AsyncAssistantStreamManager[AsyncAssistantEventHandler]
+ | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
+ ):
"""Create a thread and stream the run back"""
- return threads_create_and_run_stream(
+ return async_threads_create_and_run_stream(
self,
assistant_id=assistant_id,
instructions=instructions,
@@ -923,39 +1120,6 @@ def create_and_run_stream(
timeout=timeout,
)
-
-class AsyncThreads(AsyncAPIResource):
- """Build Assistants that can call models and use tools."""
-
- @cached_property
- def runs(self) -> AsyncRuns:
- """Build Assistants that can call models and use tools."""
- return AsyncRuns(self._client)
-
- @cached_property
- def messages(self) -> AsyncMessages:
- """Build Assistants that can call models and use tools."""
- return AsyncMessages(self._client)
-
- @cached_property
- def with_raw_response(self) -> AsyncThreadsWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return
- the raw response object instead of the parsed content.
-
- For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
- """
- return AsyncThreadsWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncThreadsWithStreamingResponse:
- """
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
-
- For more information, see https://www.github.com/openai/openai-python#with_streaming_response
- """
- return AsyncThreadsWithStreamingResponse(self)
-
@typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
async def create(
self,
@@ -1630,162 +1794,6 @@ async def create_and_run(
stream_cls=AsyncStream[AssistantStreamEvent],
)
- async def create_and_run_poll(
- self,
- *,
- assistant_id: str,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- thread: thread_create_and_run_params.Thread | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
- poll_interval_ms: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Run:
- """A helper to create a thread, start a run and then poll for a terminal state.
- More information on Run lifecycles can be found here:
- https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps"""
- return await async_threads_create_and_run_poll(
- self,
- assistant_id=assistant_id,
- instructions=instructions,
- max_completion_tokens=max_completion_tokens,
- max_prompt_tokens=max_prompt_tokens,
- metadata=metadata,
- model=model,
- parallel_tool_calls=parallel_tool_calls,
- response_format=response_format,
- temperature=temperature,
- thread=thread,
- tool_choice=tool_choice,
- tool_resources=tool_resources,
- tools=tools,
- top_p=top_p,
- truncation_strategy=truncation_strategy,
- poll_interval_ms=poll_interval_ms,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- @overload
- def create_and_run_stream(
- self,
- *,
- assistant_id: str,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- thread: thread_create_and_run_params.Thread | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandler]:
- """Create a thread and stream the run back"""
-
- @overload
- def create_and_run_stream(
- self,
- *,
- assistant_id: str,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- thread: thread_create_and_run_params.Thread | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
- event_handler: AsyncAssistantEventHandlerT,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]:
- """Create a thread and stream the run back"""
-
- def create_and_run_stream(
- self,
- *,
- assistant_id: str,
- instructions: Optional[str] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_prompt_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: Union[str, ChatModel, None] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- response_format: Optional[AssistantResponseFormatOptionParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- thread: thread_create_and_run_params.Thread | Omit = omit,
- tool_choice: Optional[AssistantToolChoiceOptionParam] | Omit = omit,
- tool_resources: Optional[thread_create_and_run_params.ToolResources] | Omit = omit,
- tools: Optional[Iterable[AssistantToolParam]] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation_strategy: Optional[thread_create_and_run_params.TruncationStrategy] | Omit = omit,
- event_handler: AsyncAssistantEventHandlerT | None = None,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> (
- AsyncAssistantStreamManager[AsyncAssistantEventHandler]
- | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]
- ):
- """Create a thread and stream the run back"""
- return async_threads_create_and_run_stream(
- self,
- assistant_id=assistant_id,
- instructions=instructions,
- max_completion_tokens=max_completion_tokens,
- max_prompt_tokens=max_prompt_tokens,
- metadata=metadata,
- model=model,
- parallel_tool_calls=parallel_tool_calls,
- response_format=response_format,
- temperature=temperature,
- thread=thread,
- tool_choice=tool_choice,
- tool_resources=tool_resources,
- tools=tools,
- top_p=top_p,
- truncation_strategy=truncation_strategy,
- event_handler=event_handler,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
class ThreadsWithRawResponse:
def __init__(self, threads: Threads) -> None:
diff --git a/src/openai/resources/chat/completions/completions.py b/src/openai/resources/chat/completions/completions.py
index 1b987cf3df..f327f9c601 100644
--- a/src/openai/resources/chat/completions/completions.py
+++ b/src/openai/resources/chat/completions/completions.py
@@ -160,7 +160,7 @@ class MathResponse(BaseModel):
client = OpenAI()
completion = client.chat.completions.parse(
- model=\"gpt-4o-2024-08-06\",
+ model=\"{{models.chat.default}}\",
messages=[
{\"role\": \"system\", \"content\": \"You are a helpful math tutor.\"},
{\"role\": \"user\", \"content\": \"solve 8x + 31 = 2\"},
@@ -172,8 +172,7 @@ class MathResponse(BaseModel):
if message.parsed:
print(message.parsed.steps)
print(\"answer: \", message.parsed.final_answer)
- ```
- """
+ ```"""
return parse(
self,
messages=messages,
@@ -218,6 +217,115 @@ class MathResponse(BaseModel):
timeout=timeout,
)
+ def stream(
+ self,
+ *,
+ messages: Iterable[ChatCompletionMessageParam],
+ model: Union[str, ChatModel],
+ audio: Optional[ChatCompletionAudioParam] | Omit = omit,
+ response_format: completion_create_params.ResponseFormat | type[ResponseFormatT] | Omit = omit,
+ frequency_penalty: Optional[float] | Omit = omit,
+ function_call: completion_create_params.FunctionCall | Omit = omit,
+ functions: Iterable[completion_create_params.Function] | Omit = omit,
+ logit_bias: Optional[Dict[str, int]] | Omit = omit,
+ logprobs: Optional[bool] | Omit = omit,
+ max_completion_tokens: Optional[int] | Omit = omit,
+ max_tokens: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ modalities: Optional[List[Literal["text", "audio"]]] | Omit = omit,
+ moderation: Optional[completion_create_params.Moderation] | Omit = omit,
+ n: Optional[int] | Omit = omit,
+ parallel_tool_calls: bool | Omit = omit,
+ prediction: Optional[ChatCompletionPredictionContentParam] | Omit = omit,
+ presence_penalty: Optional[float] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: completion_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ seed: Optional[int] | Omit = omit,
+ service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority", "fast"]] | Omit = omit,
+ stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream_options: Optional[ChatCompletionStreamOptionsParam] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ tool_choice: ChatCompletionToolChoiceOptionParam | Omit = omit,
+ tools: Iterable[ChatCompletionToolUnionParam] | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ user: str | Omit = omit,
+ verbosity: Optional[Literal["low", "medium", "high"]] | Omit = omit,
+ web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> ChatCompletionStreamManager[ResponseFormatT]:
+ """Wrapper over the `client.chat.completions.create(stream=True)` method that provides a more granular event API
+ and automatic accumulation of each delta.
+
+ This also supports all of the parsing utilities that `.parse()` does.
+
+ Unlike `.create(stream=True)`, the `.stream()` method requires usage within a context manager to prevent accidental leakage of the response:
+
+ ```py
+ with client.chat.completions.stream(
+ model=\"{{models.chat.default}}\",
+ messages=[...],
+ ) as stream:
+ for event in stream:
+ if event.type == \"content.delta\":
+ print(event.delta, flush=True, end=\"\")
+ ```
+
+ When the context manager is entered, a `ChatCompletionStream` instance is returned which, like `.create(stream=True)` is an iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
+
+ When the context manager exits, the response will be closed, however the `stream` instance is still available outside
+ the context manager."""
+ return stream(
+ self,
+ messages=messages,
+ model=model,
+ audio=audio,
+ response_format=response_format,
+ frequency_penalty=frequency_penalty,
+ function_call=function_call,
+ functions=functions,
+ logit_bias=logit_bias,
+ logprobs=logprobs,
+ max_completion_tokens=max_completion_tokens,
+ max_tokens=max_tokens,
+ metadata=metadata,
+ modalities=modalities,
+ moderation=moderation,
+ n=n,
+ parallel_tool_calls=parallel_tool_calls,
+ prediction=prediction,
+ presence_penalty=presence_penalty,
+ prompt_cache_key=prompt_cache_key,
+ prompt_cache_options=prompt_cache_options,
+ prompt_cache_retention=prompt_cache_retention,
+ reasoning_effort=reasoning_effort,
+ safety_identifier=safety_identifier,
+ seed=seed,
+ service_tier=service_tier,
+ stop=stop,
+ store=store,
+ stream_options=stream_options,
+ temperature=temperature,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_logprobs=top_logprobs,
+ top_p=top_p,
+ user=user,
+ verbosity=verbosity,
+ web_search_options=web_search_options,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
@overload
def create(
self,
@@ -1535,13 +1643,45 @@ def delete(
cast_to=ChatCompletionDeleted,
)
- def stream(
+
+class AsyncCompletions(AsyncAPIResource):
+ """
+ Given a list of messages comprising a conversation, the model will return a response.
+ """
+
+ @cached_property
+ def messages(self) -> AsyncMessages:
+ """
+ Given a list of messages comprising a conversation, the model will return a response.
+ """
+ return AsyncMessages(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AsyncCompletionsWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
+ """
+ return AsyncCompletionsWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncCompletionsWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/openai/openai-python#with_streaming_response
+ """
+ return AsyncCompletionsWithStreamingResponse(self)
+
+ async def parse(
self,
*,
messages: Iterable[ChatCompletionMessageParam],
model: Union[str, ChatModel],
audio: Optional[ChatCompletionAudioParam] | Omit = omit,
- response_format: completion_create_params.ResponseFormat | type[ResponseFormatT] | Omit = omit,
+ response_format: type[ResponseFormatT] | Omit = omit,
frequency_penalty: Optional[float] | Omit = omit,
function_call: completion_create_params.FunctionCall | Omit = omit,
functions: Iterable[completion_create_params.Function] | Omit = omit,
@@ -1578,30 +1718,49 @@ def stream(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> ChatCompletionStreamManager[ResponseFormatT]:
- """Wrapper over the `client.chat.completions.create(stream=True)` method that provides a more granular event API
- and automatic accumulation of each delta.
+ ) -> ParsedChatCompletion[ResponseFormatT]:
+ """Wrapper over the `client.chat.completions.create()` method that provides richer integrations with Python specific types
+ & returns a `ParsedChatCompletion` object, which is a subclass of the standard `ChatCompletion` class.
- This also supports all of the parsing utilities that `.parse()` does.
+ You can pass a pydantic model to this method and it will automatically convert the model
+ into a JSON schema, send it to the API and parse the response content back into the given model.
- Unlike `.create(stream=True)`, the `.stream()` method requires usage within a context manager to prevent accidental leakage of the response:
+ This method will also automatically parse `function` tool calls if:
+ - You use the `openai.pydantic_function_tool()` helper method
+ - You mark your tool schema with `\"strict\": True`
+ Example usage:
```py
- with client.chat.completions.stream(
- model=\"gpt-4o-2024-08-06\",
- messages=[...],
- ) as stream:
- for event in stream:
- if event.type == \"content.delta\":
- print(event.delta, flush=True, end=\"\")
- ```
+ from pydantic import BaseModel
+ from openai import OpenAI
- When the context manager is entered, a `ChatCompletionStream` instance is returned which, like `.create(stream=True)` is an iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
- When the context manager exits, the response will be closed, however the `stream` instance is still available outside
- the context manager.
- """
- return stream(
+ class Step(BaseModel):
+ explanation: str
+ output: str
+
+
+ class MathResponse(BaseModel):
+ steps: List[Step]
+ final_answer: str
+
+
+ client = OpenAI()
+ completion = client.chat.completions.parse(
+ model=\"{{models.chat.default}}\",
+ messages=[
+ {\"role\": \"system\", \"content\": \"You are a helpful math tutor.\"},
+ {\"role\": \"user\", \"content\": \"solve 8x + 31 = 2\"},
+ ],
+ response_format=MathResponse,
+ )
+
+ message = completion.choices[0].message
+ if message.parsed:
+ print(message.parsed.steps)
+ print(\"answer: \", message.parsed.final_answer)
+ ```"""
+ return await async_parse(
self,
messages=messages,
model=model,
@@ -1645,45 +1804,13 @@ def stream(
timeout=timeout,
)
-
-class AsyncCompletions(AsyncAPIResource):
- """
- Given a list of messages comprising a conversation, the model will return a response.
- """
-
- @cached_property
- def messages(self) -> AsyncMessages:
- """
- Given a list of messages comprising a conversation, the model will return a response.
- """
- return AsyncMessages(self._client)
-
- @cached_property
- def with_raw_response(self) -> AsyncCompletionsWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return
- the raw response object instead of the parsed content.
-
- For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
- """
- return AsyncCompletionsWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncCompletionsWithStreamingResponse:
- """
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
-
- For more information, see https://www.github.com/openai/openai-python#with_streaming_response
- """
- return AsyncCompletionsWithStreamingResponse(self)
-
- async def parse(
+ def stream(
self,
*,
messages: Iterable[ChatCompletionMessageParam],
model: Union[str, ChatModel],
audio: Optional[ChatCompletionAudioParam] | Omit = omit,
- response_format: type[ResponseFormatT] | Omit = omit,
+ response_format: completion_create_params.ResponseFormat | type[ResponseFormatT] | Omit = omit,
frequency_penalty: Optional[float] | Omit = omit,
function_call: completion_create_params.FunctionCall | Omit = omit,
functions: Iterable[completion_create_params.Function] | Omit = omit,
@@ -1720,50 +1847,29 @@ async def parse(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> ParsedChatCompletion[ResponseFormatT]:
- """Wrapper over the `client.chat.completions.create()` method that provides richer integrations with Python specific types
- & returns a `ParsedChatCompletion` object, which is a subclass of the standard `ChatCompletion` class.
+ ) -> AsyncChatCompletionStreamManager[ResponseFormatT]:
+ """Wrapper over the `client.chat.completions.create(stream=True)` method that provides a more granular event API
+ and automatic accumulation of each delta.
- You can pass a pydantic model to this method and it will automatically convert the model
- into a JSON schema, send it to the API and parse the response content back into the given model.
+ This also supports all of the parsing utilities that `.parse()` does.
- This method will also automatically parse `function` tool calls if:
- - You use the `openai.pydantic_function_tool()` helper method
- - You mark your tool schema with `\"strict\": True`
+ Unlike `.create(stream=True)`, the `.stream()` method requires usage within a context manager to prevent accidental leakage of the response:
- Example usage:
```py
- from pydantic import BaseModel
- from openai import AsyncOpenAI
-
-
- class Step(BaseModel):
- explanation: str
- output: str
-
-
- class MathResponse(BaseModel):
- steps: List[Step]
- final_answer: str
-
+ with client.chat.completions.stream(
+ model=\"{{models.chat.default}}\",
+ messages=[...],
+ ) as stream:
+ for event in stream:
+ if event.type == \"content.delta\":
+ print(event.delta, flush=True, end=\"\")
+ ```
- client = AsyncOpenAI()
- completion = await client.chat.completions.parse(
- model=\"gpt-4o-2024-08-06\",
- messages=[
- {\"role\": \"system\", \"content\": \"You are a helpful math tutor.\"},
- {\"role\": \"user\", \"content\": \"solve 8x + 31 = 2\"},
- ],
- response_format=MathResponse,
- )
+ When the context manager is entered, a `ChatCompletionStream` instance is returned which, like `.create(stream=True)` is an iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
- message = completion.choices[0].message
- if message.parsed:
- print(message.parsed.steps)
- print(\"answer: \", message.parsed.final_answer)
- ```
- """
- return await async_parse(
+ When the context manager exits, the response will be closed, however the `stream` instance is still available outside
+ the context manager."""
+ return async_stream(
self,
messages=messages,
model=model,
@@ -3124,125 +3230,11 @@ async def delete(
cast_to=ChatCompletionDeleted,
)
- def stream(
- self,
- *,
- messages: Iterable[ChatCompletionMessageParam],
- model: Union[str, ChatModel],
- audio: Optional[ChatCompletionAudioParam] | Omit = omit,
- response_format: completion_create_params.ResponseFormat | type[ResponseFormatT] | Omit = omit,
- frequency_penalty: Optional[float] | Omit = omit,
- function_call: completion_create_params.FunctionCall | Omit = omit,
- functions: Iterable[completion_create_params.Function] | Omit = omit,
- logit_bias: Optional[Dict[str, int]] | Omit = omit,
- logprobs: Optional[bool] | Omit = omit,
- max_completion_tokens: Optional[int] | Omit = omit,
- max_tokens: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- modalities: Optional[List[Literal["text", "audio"]]] | Omit = omit,
- moderation: Optional[completion_create_params.Moderation] | Omit = omit,
- n: Optional[int] | Omit = omit,
- parallel_tool_calls: bool | Omit = omit,
- prediction: Optional[ChatCompletionPredictionContentParam] | Omit = omit,
- presence_penalty: Optional[float] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: completion_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning_effort: Optional[ReasoningEffort] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- seed: Optional[int] | Omit = omit,
- service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority", "fast"]] | Omit = omit,
- stop: Union[str, SequenceNotStr[str], None] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream_options: Optional[ChatCompletionStreamOptionsParam] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- tool_choice: ChatCompletionToolChoiceOptionParam | Omit = omit,
- tools: Iterable[ChatCompletionToolUnionParam] | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- user: str | Omit = omit,
- verbosity: Optional[Literal["low", "medium", "high"]] | Omit = omit,
- web_search_options: completion_create_params.WebSearchOptions | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> AsyncChatCompletionStreamManager[ResponseFormatT]:
- """Wrapper over the `client.chat.completions.create(stream=True)` method that provides a more granular event API
- and automatic accumulation of each delta.
-
- This also supports all of the parsing utilities that `.parse()` does.
-
- Unlike `.create(stream=True)`, the `.stream()` method requires usage within a context manager to prevent accidental leakage of the response:
-
- ```py
- async with client.chat.completions.stream(
- model=\"gpt-4o-2024-08-06\",
- messages=[...],
- ) as stream:
- async for event in stream:
- if event.type == \"content.delta\":
- print(event.delta, flush=True, end=\"\")
- ```
-
- When the context manager is entered, an `AsyncChatCompletionStream` instance is returned which, like `.create(stream=True)` is an async iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
-
- When the context manager exits, the response will be closed, however the `stream` instance is still available outside
- the context manager.
- """
- return async_stream(
- self,
- messages=messages,
- model=model,
- audio=audio,
- response_format=response_format,
- frequency_penalty=frequency_penalty,
- function_call=function_call,
- functions=functions,
- logit_bias=logit_bias,
- logprobs=logprobs,
- max_completion_tokens=max_completion_tokens,
- max_tokens=max_tokens,
- metadata=metadata,
- modalities=modalities,
- moderation=moderation,
- n=n,
- parallel_tool_calls=parallel_tool_calls,
- prediction=prediction,
- presence_penalty=presence_penalty,
- prompt_cache_key=prompt_cache_key,
- prompt_cache_options=prompt_cache_options,
- prompt_cache_retention=prompt_cache_retention,
- reasoning_effort=reasoning_effort,
- safety_identifier=safety_identifier,
- seed=seed,
- service_tier=service_tier,
- stop=stop,
- store=store,
- stream_options=stream_options,
- temperature=temperature,
- tool_choice=tool_choice,
- tools=tools,
- top_logprobs=top_logprobs,
- top_p=top_p,
- user=user,
- verbosity=verbosity,
- web_search_options=web_search_options,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
class CompletionsWithRawResponse:
def __init__(self, completions: Completions) -> None:
self._completions = completions
- self.parse = _legacy_response.to_raw_response_wrapper(
- completions.parse,
- )
-
self.create = _legacy_response.to_raw_response_wrapper(
completions.create,
)
@@ -3259,6 +3251,10 @@ def __init__(self, completions: Completions) -> None:
completions.delete,
)
+ self.parse = _legacy_response.to_raw_response_wrapper(
+ completions.parse,
+ )
+
@cached_property
def messages(self) -> MessagesWithRawResponse:
"""
@@ -3271,10 +3267,6 @@ class AsyncCompletionsWithRawResponse:
def __init__(self, completions: AsyncCompletions) -> None:
self._completions = completions
- self.parse = _legacy_response.async_to_raw_response_wrapper(
- completions.parse,
- )
-
self.create = _legacy_response.async_to_raw_response_wrapper(
completions.create,
)
@@ -3291,6 +3283,10 @@ def __init__(self, completions: AsyncCompletions) -> None:
completions.delete,
)
+ self.parse = _legacy_response.async_to_raw_response_wrapper(
+ completions.parse,
+ )
+
@cached_property
def messages(self) -> AsyncMessagesWithRawResponse:
"""
@@ -3303,10 +3299,6 @@ class CompletionsWithStreamingResponse:
def __init__(self, completions: Completions) -> None:
self._completions = completions
- self.parse = to_streamed_response_wrapper(
- completions.parse,
- )
-
self.create = to_streamed_response_wrapper(
completions.create,
)
@@ -3323,6 +3315,10 @@ def __init__(self, completions: Completions) -> None:
completions.delete,
)
+ self.parse = to_streamed_response_wrapper(
+ completions.parse,
+ )
+
@cached_property
def messages(self) -> MessagesWithStreamingResponse:
"""
@@ -3335,10 +3331,6 @@ class AsyncCompletionsWithStreamingResponse:
def __init__(self, completions: AsyncCompletions) -> None:
self._completions = completions
- self.parse = async_to_streamed_response_wrapper(
- completions.parse,
- )
-
self.create = async_to_streamed_response_wrapper(
completions.create,
)
@@ -3355,6 +3347,10 @@ def __init__(self, completions: AsyncCompletions) -> None:
completions.delete,
)
+ self.parse = async_to_streamed_response_wrapper(
+ completions.parse,
+ )
+
@cached_property
def messages(self) -> AsyncMessagesWithStreamingResponse:
"""
diff --git a/src/openai/resources/embeddings.py b/src/openai/resources/embeddings.py
index 8a31689671..25729b2d32 100644
--- a/src/openai/resources/embeddings.py
+++ b/src/openai/resources/embeddings.py
@@ -10,7 +10,7 @@
from .. import _legacy_response
from ..types import embedding_create_params
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
-from .._utils import maybe_transform
+from .._utils import maybe_transform, async_maybe_transform
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
@@ -215,7 +215,7 @@ async def create(
)
return await self._post(
"/embeddings",
- body=maybe_transform(_runtime_context.body, embedding_create_params.EmbeddingCreateParams),
+ body=await async_maybe_transform(_runtime_context.body, embedding_create_params.EmbeddingCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
diff --git a/src/openai/resources/images.py b/src/openai/resources/images.py
index d1f9d330c2..21cb91369f 100644
--- a/src/openai/resources/images.py
+++ b/src/openai/resources/images.py
@@ -195,12 +195,15 @@ def edit(
the mask will be applied on the first image. Must be a valid PNG file, less than
4MB, and have the same dimensions as `image`.
- model: The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ model: The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
n: The number of images to generate. Must be between 1 and 10.
output_compression: The compression level (0-100%) for the generated images. This parameter is only
@@ -334,12 +337,15 @@ def edit(
the mask will be applied on the first image. Must be a valid PNG file, less than
4MB, and have the same dimensions as `image`.
- model: The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ model: The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
n: The number of images to generate. Must be between 1 and 10.
output_compression: The compression level (0-100%) for the generated images. This parameter is only
@@ -469,12 +475,15 @@ def edit(
the mask will be applied on the first image. Must be a valid PNG file, less than
4MB, and have the same dimensions as `image`.
- model: The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ model: The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
n: The number of images to generate. Must be between 1 and 10.
output_compression: The compression level (0-100%) for the generated images. This parameter is only
@@ -657,11 +666,14 @@ def generate(
set the output format to `png` or `webp`.
model: The GPT image model to use for image generation. Specify a model explicitly.
- Supported models include `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`,
+ Supported models include `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`, and `chatgpt-image-latest`.
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
moderation: Control the content-moderation level for images generated by the GPT image
models. Must be either `low` for less restrictive filtering or `auto` (default
value).
@@ -787,11 +799,14 @@ def generate(
set the output format to `png` or `webp`.
model: The GPT image model to use for image generation. Specify a model explicitly.
- Supported models include `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`,
+ Supported models include `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`, and `chatgpt-image-latest`.
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
moderation: Control the content-moderation level for images generated by the GPT image
models. Must be either `low` for less restrictive filtering or `auto` (default
value).
@@ -913,11 +928,14 @@ def generate(
set the output format to `png` or `webp`.
model: The GPT image model to use for image generation. Specify a model explicitly.
- Supported models include `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`,
+ Supported models include `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`, and `chatgpt-image-latest`.
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
moderation: Control the content-moderation level for images generated by the GPT image
models. Must be either `low` for less restrictive filtering or `auto` (default
value).
@@ -1222,12 +1240,15 @@ async def edit(
the mask will be applied on the first image. Must be a valid PNG file, less than
4MB, and have the same dimensions as `image`.
- model: The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ model: The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
n: The number of images to generate. Must be between 1 and 10.
output_compression: The compression level (0-100%) for the generated images. This parameter is only
@@ -1361,12 +1382,15 @@ async def edit(
the mask will be applied on the first image. Must be a valid PNG file, less than
4MB, and have the same dimensions as `image`.
- model: The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ model: The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
n: The number of images to generate. Must be between 1 and 10.
output_compression: The compression level (0-100%) for the generated images. This parameter is only
@@ -1496,12 +1520,15 @@ async def edit(
the mask will be applied on the first image. Must be a valid PNG file, less than
4MB, and have the same dimensions as `image`.
- model: The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ model: The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
n: The number of images to generate. Must be between 1 and 10.
output_compression: The compression level (0-100%) for the generated images. This parameter is only
@@ -1684,11 +1711,14 @@ async def generate(
set the output format to `png` or `webp`.
model: The GPT image model to use for image generation. Specify a model explicitly.
- Supported models include `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`,
+ Supported models include `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`, and `chatgpt-image-latest`.
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
moderation: Control the content-moderation level for images generated by the GPT image
models. Must be either `low` for less restrictive filtering or `auto` (default
value).
@@ -1814,11 +1844,14 @@ async def generate(
set the output format to `png` or `webp`.
model: The GPT image model to use for image generation. Specify a model explicitly.
- Supported models include `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`,
+ Supported models include `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`, and `chatgpt-image-latest`.
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
moderation: Control the content-moderation level for images generated by the GPT image
models. Must be either `low` for less restrictive filtering or `auto` (default
value).
@@ -1940,11 +1973,14 @@ async def generate(
set the output format to `png` or `webp`.
model: The GPT image model to use for image generation. Specify a model explicitly.
- Supported models include `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`,
+ Supported models include `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`, and `chatgpt-image-latest`.
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
+
moderation: Control the content-moderation level for images generated by the GPT image
models. Must be either `low` for less restrictive filtering or `auto` (default
value).
diff --git a/src/openai/resources/live/api.md b/src/openai/resources/live/api.md
index 1b2d729a95..5751ba2c30 100644
--- a/src/openai/resources/live/api.md
+++ b/src/openai/resources/live/api.md
@@ -13,13 +13,25 @@ from openai.types.live import (
CommentaryAppendedEvent,
CustomVoice,
DataChannelConfig,
+ DecisionAssistantMessage,
+ DecisionChoiceOption,
DecisionCreateEvent,
+ DecisionDeveloperMessage,
DecisionEvent,
+ DecisionInputText,
DecisionItemCreateEvent,
DecisionItemCreatedEvent,
DecisionItemDeleteEvent,
DecisionItemDeletedEvent,
+ DecisionJSONObject,
+ DecisionQuestion,
+ DecisionStoredAssistantMessage,
+ DecisionStoredDeveloperMessage,
+ DecisionStoredSystemMessage,
+ DecisionStoredUserMessage,
+ DecisionSystemMessage,
DecisionTrigger,
+ DecisionUserMessage,
DecisionsDelegationConfig,
DecisionsDelegationUpdateConfig,
DelegationCreatedEvent,
diff --git a/src/openai/resources/live/forks.py b/src/openai/resources/live/forks.py
index 9b4818be8f..4472f5b8a9 100644
--- a/src/openai/resources/live/forks.py
+++ b/src/openai/resources/live/forks.py
@@ -1174,7 +1174,9 @@ def delete(self, *, item_id: str, event_id: Optional[str] | Omit = omit) -> None
)
)
- def create(self, *, item: decision_item_create_event_param.Item, event_id: Optional[str] | Omit = omit) -> None:
+ def create(
+ self, *, item: decision_item_create_event_param.ItemUnion, event_id: Optional[str] | Omit = omit
+ ) -> None:
"""
Append an input item for future decisions without starting an evaluation or changing Live voice context.
"""
@@ -1433,7 +1435,7 @@ async def delete(self, *, item_id: str, event_id: Optional[str] | Omit = omit) -
)
async def create(
- self, *, item: decision_item_create_event_param.Item, event_id: Optional[str] | Omit = omit
+ self, *, item: decision_item_create_event_param.ItemUnion, event_id: Optional[str] | Omit = omit
) -> None:
"""
Append an input item for future decisions without starting an evaluation or changing Live voice context.
diff --git a/src/openai/resources/live/live.py b/src/openai/resources/live/live.py
index abc3495e8b..0251b108ce 100644
--- a/src/openai/resources/live/live.py
+++ b/src/openai/resources/live/live.py
@@ -1355,7 +1355,9 @@ def delete(self, *, item_id: str, event_id: Optional[str] | Omit = omit) -> None
)
)
- def create(self, *, item: decision_item_create_event_param.Item, event_id: Optional[str] | Omit = omit) -> None:
+ def create(
+ self, *, item: decision_item_create_event_param.ItemUnion, event_id: Optional[str] | Omit = omit
+ ) -> None:
"""
Append an input item for future decisions without starting an evaluation or changing Live voice context.
"""
@@ -1607,7 +1609,7 @@ async def delete(self, *, item_id: str, event_id: Optional[str] | Omit = omit) -
)
async def create(
- self, *, item: decision_item_create_event_param.Item, event_id: Optional[str] | Omit = omit
+ self, *, item: decision_item_create_event_param.ItemUnion, event_id: Optional[str] | Omit = omit
) -> None:
"""
Append an input item for future decisions without starting an evaluation or changing Live voice context.
diff --git a/src/openai/resources/live/sideband.py b/src/openai/resources/live/sideband.py
index a1d766337d..c916ecfcd4 100644
--- a/src/openai/resources/live/sideband.py
+++ b/src/openai/resources/live/sideband.py
@@ -1149,7 +1149,9 @@ def delete(self, *, item_id: str, event_id: Optional[str] | Omit = omit) -> None
)
)
- def create(self, *, item: decision_item_create_event_param.Item, event_id: Optional[str] | Omit = omit) -> None:
+ def create(
+ self, *, item: decision_item_create_event_param.ItemUnion, event_id: Optional[str] | Omit = omit
+ ) -> None:
"""
Append an input item for future decisions without starting an evaluation or changing Live voice context.
"""
@@ -1383,7 +1385,7 @@ async def delete(self, *, item_id: str, event_id: Optional[str] | Omit = omit) -
)
async def create(
- self, *, item: decision_item_create_event_param.Item, event_id: Optional[str] | Omit = omit
+ self, *, item: decision_item_create_event_param.ItemUnion, event_id: Optional[str] | Omit = omit
) -> None:
"""
Append an input item for future decisions without starting an evaluation or changing Live voice context.
diff --git a/src/openai/resources/responses/api.md b/src/openai/resources/responses/api.md
index df999f9a4b..9ef00fb631 100644
--- a/src/openai/resources/responses/api.md
+++ b/src/openai/resources/responses/api.md
@@ -180,8 +180,8 @@ Methods:
- client.responses.delete(response_id) -> None
- client.responses.cancel(response_id) -> Response
- client.responses.compact(\*\*params) -> CompactedResponse
-- client.responses.stream(\*, response_id=..., input=..., model=..., access_programs=..., background=..., context_management=..., text_format=..., tools=..., conversation=..., include=..., instructions=..., max_output_tokens=..., max_tool_calls=..., metadata=..., parallel_tool_calls=..., moderation=..., previous_response_id=..., prompt=..., prompt_cache_key=..., prompt_cache_options=..., prompt_cache_retention=..., reasoning=..., safety_identifier=..., service_tier=..., store=..., stream_options=..., temperature=..., text=..., tool_choice=..., top_logprobs=..., top_p=..., truncation=..., user=..., starting_after=..., extra_headers=..., extra_query=..., extra_body=..., timeout=...) -> ResponseStreamManager[TextFormatT]
- client.responses.parse(\*, text_format=..., access_programs=..., background=..., context_management=..., conversation=..., include=..., input=..., instructions=..., max_output_tokens=..., max_tool_calls=..., metadata=..., model=..., moderation=..., parallel_tool_calls=..., previous_response_id=..., prompt=..., prompt_cache_key=..., prompt_cache_options=..., prompt_cache_retention=..., reasoning=..., safety_identifier=..., service_tier=..., store=..., stream=..., stream_options=..., temperature=..., text=..., tool_choice=..., tools=..., top_logprobs=..., top_p=..., truncation=..., user=..., verbosity=..., extra_headers=..., extra_query=..., extra_body=..., timeout=...) -> ParsedResponse[TextFormatT]
+- client.responses.stream(\*, response_id=..., input=..., model=..., access_programs=..., background=..., context_management=..., text_format=..., tools=..., conversation=..., include=..., instructions=..., max_output_tokens=..., max_tool_calls=..., metadata=..., parallel_tool_calls=..., moderation=..., previous_response_id=..., prompt=..., prompt_cache_key=..., prompt_cache_options=..., prompt_cache_retention=..., reasoning=..., safety_identifier=..., service_tier=..., store=..., stream_options=..., temperature=..., text=..., tool_choice=..., top_logprobs=..., top_p=..., truncation=..., user=..., starting_after=..., extra_headers=..., extra_query=..., extra_body=..., timeout=...) -> ResponseStreamManager[TextFormatT]
## InputItems
diff --git a/src/openai/resources/responses/responses.py b/src/openai/resources/responses/responses.py
index ca4fdc1002..1a814be39e 100644
--- a/src/openai/resources/responses/responses.py
+++ b/src/openai/resources/responses/responses.py
@@ -11,10 +11,8 @@
import httpx2
from pydantic import BaseModel
-import openai.lib._response_resources
-
from ... import _legacy_response
-from ..._types import NOT_GIVEN, Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
+from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
from ..._utils import is_given, path_template, maybe_transform, strip_not_given, async_maybe_transform
from ..._compat import cached_property
from ..._httpx2 import normalize_httpx_url
@@ -84,13 +82,6 @@
log: logging.Logger = logging.getLogger(__name__)
-# Retained module entry point; callers may live outside generated resources.
-def _make_tools( # pyright: ignore[reportUnusedFunction]
- tools: Iterable[ParseableToolParam] | Omit,
-) -> List[ToolParam] | Omit:
- return openai.lib._response_resources._make_tools(tools)
-
-
class Responses(SyncAPIResource):
"""Create and manage model responses."""
@@ -123,6 +114,234 @@ def with_streaming_response(self) -> ResponsesWithStreamingResponse:
"""
return ResponsesWithStreamingResponse(self)
+ def parse(
+ self,
+ *,
+ text_format: type[TextFormatT] | Omit = omit,
+ access_programs: response_create_params.AccessPrograms | Omit = omit,
+ background: Optional[bool] | Omit = omit,
+ context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
+ conversation: Optional[response_create_params.Conversation] | Omit = omit,
+ include: Optional[List[ResponseIncludable]] | Omit = omit,
+ input: Union[str, ResponseInputParam] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_output_tokens: Optional[int] | Omit = omit,
+ max_tool_calls: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: ResponsesModel | Omit = omit,
+ moderation: Optional[response_create_params.Moderation] | Omit = omit,
+ parallel_tool_calls: Optional[bool] | Omit = omit,
+ previous_response_id: Optional[str] | Omit = omit,
+ prompt: Optional[ResponsePromptParam] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning: Optional[Reasoning] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ service_tier: Optional[ServiceTier] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
+ stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ text: ResponseTextConfigParam | Omit = omit,
+ tool_choice: response_create_params.ToolChoice | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
+ user: str | Omit = omit,
+ verbosity: Optional[Literal["low", "medium", "high"]] | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> ParsedResponse[TextFormatT]:
+ """parse"""
+ return parse(
+ self,
+ text_format=text_format,
+ access_programs=access_programs,
+ background=background,
+ context_management=context_management,
+ conversation=conversation,
+ include=include,
+ input=input,
+ instructions=instructions,
+ max_output_tokens=max_output_tokens,
+ max_tool_calls=max_tool_calls,
+ metadata=metadata,
+ model=model,
+ moderation=moderation,
+ parallel_tool_calls=parallel_tool_calls,
+ previous_response_id=previous_response_id,
+ prompt=prompt,
+ prompt_cache_key=prompt_cache_key,
+ prompt_cache_options=prompt_cache_options,
+ prompt_cache_retention=prompt_cache_retention,
+ reasoning=reasoning,
+ safety_identifier=safety_identifier,
+ service_tier=service_tier,
+ store=store,
+ stream=stream,
+ stream_options=stream_options,
+ temperature=temperature,
+ text=text,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_logprobs=top_logprobs,
+ top_p=top_p,
+ truncation=truncation,
+ user=user,
+ verbosity=verbosity,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @overload
+ def stream(
+ self,
+ *,
+ response_id: str,
+ text_format: type[TextFormatT] | Omit = omit,
+ starting_after: int | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> ResponseStreamManager[TextFormatT]:
+ """stream"""
+
+ @overload
+ def stream(
+ self,
+ *,
+ input: Union[str, ResponseInputParam],
+ model: ResponsesModel,
+ access_programs: response_create_params.AccessPrograms | Omit = omit,
+ background: Optional[bool] | Omit = omit,
+ context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
+ text_format: type[TextFormatT] | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ conversation: Optional[response_create_params.Conversation] | Omit = omit,
+ include: Optional[List[ResponseIncludable]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_output_tokens: Optional[int] | Omit = omit,
+ max_tool_calls: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ parallel_tool_calls: Optional[bool] | Omit = omit,
+ moderation: Optional[response_create_params.Moderation] | Omit = omit,
+ previous_response_id: Optional[str] | Omit = omit,
+ prompt: Optional[ResponsePromptParam] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning: Optional[Reasoning] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ service_tier: Optional[ServiceTier] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ text: ResponseTextConfigParam | Omit = omit,
+ tool_choice: response_create_params.ToolChoice | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
+ user: str | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> ResponseStreamManager[TextFormatT]:
+ """stream"""
+
+ def stream(
+ self,
+ *,
+ response_id: str | Omit = omit,
+ input: Union[str, ResponseInputParam] | Omit = omit,
+ model: ResponsesModel | Omit = omit,
+ access_programs: response_create_params.AccessPrograms | Omit = omit,
+ background: Optional[bool] | Omit = omit,
+ context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
+ text_format: type[TextFormatT] | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ conversation: Optional[response_create_params.Conversation] | Omit = omit,
+ include: Optional[List[ResponseIncludable]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_output_tokens: Optional[int] | Omit = omit,
+ max_tool_calls: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ parallel_tool_calls: Optional[bool] | Omit = omit,
+ moderation: Optional[response_create_params.Moderation] | Omit = omit,
+ previous_response_id: Optional[str] | Omit = omit,
+ prompt: Optional[ResponsePromptParam] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning: Optional[Reasoning] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ service_tier: Optional[ServiceTier] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ text: ResponseTextConfigParam | Omit = omit,
+ tool_choice: response_create_params.ToolChoice | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
+ user: str | Omit = omit,
+ starting_after: int | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> ResponseStreamManager[TextFormatT]:
+ """stream"""
+ return stream(
+ self,
+ response_id=response_id,
+ input=input,
+ model=model,
+ access_programs=access_programs,
+ background=background,
+ context_management=context_management,
+ text_format=text_format,
+ tools=tools,
+ conversation=conversation,
+ include=include,
+ instructions=instructions,
+ max_output_tokens=max_output_tokens,
+ max_tool_calls=max_tool_calls,
+ metadata=metadata,
+ parallel_tool_calls=parallel_tool_calls,
+ moderation=moderation,
+ previous_response_id=previous_response_id,
+ prompt=prompt,
+ prompt_cache_key=prompt_cache_key,
+ prompt_cache_options=prompt_cache_options,
+ prompt_cache_retention=prompt_cache_retention,
+ reasoning=reasoning,
+ safety_identifier=safety_identifier,
+ service_tier=service_tier,
+ store=store,
+ stream_options=stream_options,
+ temperature=temperature,
+ text=text,
+ tool_choice=tool_choice,
+ top_logprobs=top_logprobs,
+ top_p=top_p,
+ truncation=truncation,
+ user=user,
+ starting_after=starting_after,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
@overload
def create(
self,
@@ -1095,287 +1314,23 @@ def create(
)
@overload
- def stream(
+ def retrieve(
self,
- *,
response_id: str,
- text_format: type[TextFormatT] | Omit = omit,
+ *,
+ include: List[ResponseIncludable] | Omit = omit,
+ include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
+ stream: Literal[False] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ResponseStreamManager[TextFormatT]: ...
-
- @overload
- def stream(
- self,
- *,
- input: Union[str, ResponseInputParam],
- model: ResponsesModel,
- access_programs: response_create_params.AccessPrograms | Omit = omit,
- background: Optional[bool] | Omit = omit,
- context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
- text_format: type[TextFormatT] | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
- conversation: Optional[response_create_params.Conversation] | Omit = omit,
- include: Optional[List[ResponseIncludable]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_output_tokens: Optional[int] | Omit = omit,
- max_tool_calls: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- parallel_tool_calls: Optional[bool] | Omit = omit,
- moderation: Optional[response_create_params.Moderation] | Omit = omit,
- previous_response_id: Optional[str] | Omit = omit,
- prompt: Optional[ResponsePromptParam] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning: Optional[Reasoning] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- service_tier: Optional[ServiceTier] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- text: ResponseTextConfigParam | Omit = omit,
- tool_choice: response_create_params.ToolChoice | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
- user: str | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ResponseStreamManager[TextFormatT]: ...
-
- def stream(
- self,
- *,
- response_id: str | Omit = omit,
- input: Union[str, ResponseInputParam] | Omit = omit,
- model: ResponsesModel | Omit = omit,
- access_programs: response_create_params.AccessPrograms | Omit = omit,
- background: Optional[bool] | Omit = omit,
- context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
- text_format: type[TextFormatT] | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
- conversation: Optional[response_create_params.Conversation] | Omit = omit,
- include: Optional[List[ResponseIncludable]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_output_tokens: Optional[int] | Omit = omit,
- max_tool_calls: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- parallel_tool_calls: Optional[bool] | Omit = omit,
- moderation: Optional[response_create_params.Moderation] | Omit = omit,
- previous_response_id: Optional[str] | Omit = omit,
- prompt: Optional[ResponsePromptParam] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning: Optional[Reasoning] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- service_tier: Optional[ServiceTier] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- text: ResponseTextConfigParam | Omit = omit,
- tool_choice: response_create_params.ToolChoice | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
- user: str | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ResponseStreamManager[TextFormatT]:
- return stream(
- self,
- response_id=response_id,
- input=input,
- model=model,
- access_programs=access_programs,
- background=background,
- context_management=context_management,
- text_format=text_format,
- tools=tools,
- conversation=conversation,
- include=include,
- instructions=instructions,
- max_output_tokens=max_output_tokens,
- max_tool_calls=max_tool_calls,
- metadata=metadata,
- parallel_tool_calls=parallel_tool_calls,
- moderation=moderation,
- previous_response_id=previous_response_id,
- prompt=prompt,
- prompt_cache_key=prompt_cache_key,
- prompt_cache_options=prompt_cache_options,
- prompt_cache_retention=prompt_cache_retention,
- reasoning=reasoning,
- safety_identifier=safety_identifier,
- service_tier=service_tier,
- store=store,
- stream_options=stream_options,
- temperature=temperature,
- text=text,
- tool_choice=tool_choice,
- top_logprobs=top_logprobs,
- top_p=top_p,
- truncation=truncation,
- user=user,
- starting_after=starting_after,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- def parse(
- self,
- *,
- text_format: type[TextFormatT] | Omit = omit,
- access_programs: response_create_params.AccessPrograms | Omit = omit,
- background: Optional[bool] | Omit = omit,
- context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
- conversation: Optional[response_create_params.Conversation] | Omit = omit,
- include: Optional[List[ResponseIncludable]] | Omit = omit,
- input: Union[str, ResponseInputParam] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_output_tokens: Optional[int] | Omit = omit,
- max_tool_calls: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: ResponsesModel | Omit = omit,
- moderation: Optional[response_create_params.Moderation] | Omit = omit,
- parallel_tool_calls: Optional[bool] | Omit = omit,
- previous_response_id: Optional[str] | Omit = omit,
- prompt: Optional[ResponsePromptParam] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning: Optional[Reasoning] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- service_tier: Optional[ServiceTier] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
- stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- text: ResponseTextConfigParam | Omit = omit,
- tool_choice: response_create_params.ToolChoice | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
- user: str | Omit = omit,
- verbosity: Optional[Literal["low", "medium", "high"]] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ParsedResponse[TextFormatT]:
- return parse(
- self,
- text_format=text_format,
- access_programs=access_programs,
- background=background,
- context_management=context_management,
- conversation=conversation,
- include=include,
- input=input,
- instructions=instructions,
- max_output_tokens=max_output_tokens,
- max_tool_calls=max_tool_calls,
- metadata=metadata,
- model=model,
- moderation=moderation,
- parallel_tool_calls=parallel_tool_calls,
- previous_response_id=previous_response_id,
- prompt=prompt,
- prompt_cache_key=prompt_cache_key,
- prompt_cache_options=prompt_cache_options,
- prompt_cache_retention=prompt_cache_retention,
- reasoning=reasoning,
- safety_identifier=safety_identifier,
- service_tier=service_tier,
- store=store,
- stream=stream,
- stream_options=stream_options,
- temperature=temperature,
- text=text,
- tool_choice=tool_choice,
- tools=tools,
- top_logprobs=top_logprobs,
- top_p=top_p,
- truncation=truncation,
- user=user,
- verbosity=verbosity,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- @overload
- def retrieve(
- self,
- response_id: str,
- *,
- include: List[ResponseIncludable] | Omit = omit,
- include_obfuscation: bool | Omit = omit,
- starting_after: int | Omit = omit,
- stream: Literal[False] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Response: ...
-
- @overload
- def retrieve(
- self,
- response_id: str,
- *,
- stream: Literal[True],
- include: List[ResponseIncludable] | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Stream[ResponseStreamEvent]: ...
-
- @overload
- def retrieve(
- self,
- response_id: str,
- *,
- stream: bool,
- include: List[ResponseIncludable] | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Response | Stream[ResponseStreamEvent]: ...
-
- @overload
- def retrieve(
- self,
- response_id: str,
- *,
- stream: bool = False,
- include: List[ResponseIncludable] | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Response | Stream[ResponseStreamEvent]:
- """
- Retrieves a model response with the given ID.
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Response:
+ """
+ Retrieves a model response with the given ID.
Args:
include: Additional fields to include in the response. See the `include` parameter for
@@ -1405,6 +1360,7 @@ def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@overload
def retrieve(
@@ -1415,6 +1371,8 @@ def retrieve(
include: List[ResponseIncludable] | Omit = omit,
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -1451,6 +1409,7 @@ def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@overload
def retrieve(
@@ -1461,6 +1420,8 @@ def retrieve(
include: List[ResponseIncludable] | Omit = omit,
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -1497,6 +1458,7 @@ def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
def retrieve(
self,
@@ -1506,6 +1468,8 @@ def retrieve(
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
stream: Literal[False] | Literal[True] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -1898,6 +1862,234 @@ def with_streaming_response(self) -> AsyncResponsesWithStreamingResponse:
"""
return AsyncResponsesWithStreamingResponse(self)
+ async def parse(
+ self,
+ *,
+ text_format: type[TextFormatT] | Omit = omit,
+ access_programs: response_create_params.AccessPrograms | Omit = omit,
+ background: Optional[bool] | Omit = omit,
+ context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
+ conversation: Optional[response_create_params.Conversation] | Omit = omit,
+ include: Optional[List[ResponseIncludable]] | Omit = omit,
+ input: Union[str, ResponseInputParam] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_output_tokens: Optional[int] | Omit = omit,
+ max_tool_calls: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ model: ResponsesModel | Omit = omit,
+ moderation: Optional[response_create_params.Moderation] | Omit = omit,
+ parallel_tool_calls: Optional[bool] | Omit = omit,
+ previous_response_id: Optional[str] | Omit = omit,
+ prompt: Optional[ResponsePromptParam] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning: Optional[Reasoning] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ service_tier: Optional[ServiceTier] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
+ stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ text: ResponseTextConfigParam | Omit = omit,
+ tool_choice: response_create_params.ToolChoice | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
+ user: str | Omit = omit,
+ verbosity: Optional[Literal["low", "medium", "high"]] | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> ParsedResponse[TextFormatT]:
+ """parse"""
+ return await async_parse(
+ self,
+ text_format=text_format,
+ access_programs=access_programs,
+ background=background,
+ context_management=context_management,
+ conversation=conversation,
+ include=include,
+ input=input,
+ instructions=instructions,
+ max_output_tokens=max_output_tokens,
+ max_tool_calls=max_tool_calls,
+ metadata=metadata,
+ model=model,
+ moderation=moderation,
+ parallel_tool_calls=parallel_tool_calls,
+ previous_response_id=previous_response_id,
+ prompt=prompt,
+ prompt_cache_key=prompt_cache_key,
+ prompt_cache_options=prompt_cache_options,
+ prompt_cache_retention=prompt_cache_retention,
+ reasoning=reasoning,
+ safety_identifier=safety_identifier,
+ service_tier=service_tier,
+ store=store,
+ stream=stream,
+ stream_options=stream_options,
+ temperature=temperature,
+ text=text,
+ tool_choice=tool_choice,
+ tools=tools,
+ top_logprobs=top_logprobs,
+ top_p=top_p,
+ truncation=truncation,
+ user=user,
+ verbosity=verbosity,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
+ @overload
+ def stream(
+ self,
+ *,
+ response_id: str,
+ text_format: type[TextFormatT] | Omit = omit,
+ starting_after: int | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncResponseStreamManager[TextFormatT]:
+ """stream"""
+
+ @overload
+ def stream(
+ self,
+ *,
+ input: Union[str, ResponseInputParam],
+ model: ResponsesModel,
+ access_programs: response_create_params.AccessPrograms | Omit = omit,
+ background: Optional[bool] | Omit = omit,
+ context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
+ text_format: type[TextFormatT] | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ conversation: Optional[response_create_params.Conversation] | Omit = omit,
+ include: Optional[List[ResponseIncludable]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_output_tokens: Optional[int] | Omit = omit,
+ max_tool_calls: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ parallel_tool_calls: Optional[bool] | Omit = omit,
+ moderation: Optional[response_create_params.Moderation] | Omit = omit,
+ previous_response_id: Optional[str] | Omit = omit,
+ prompt: Optional[ResponsePromptParam] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning: Optional[Reasoning] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ service_tier: Optional[ServiceTier] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ text: ResponseTextConfigParam | Omit = omit,
+ tool_choice: response_create_params.ToolChoice | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
+ user: str | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncResponseStreamManager[TextFormatT]:
+ """stream"""
+
+ def stream(
+ self,
+ *,
+ response_id: str | Omit = omit,
+ input: Union[str, ResponseInputParam] | Omit = omit,
+ model: ResponsesModel | Omit = omit,
+ access_programs: response_create_params.AccessPrograms | Omit = omit,
+ background: Optional[bool] | Omit = omit,
+ context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
+ text_format: type[TextFormatT] | Omit = omit,
+ tools: Iterable[ParseableToolParam] | Omit = omit,
+ conversation: Optional[response_create_params.Conversation] | Omit = omit,
+ include: Optional[List[ResponseIncludable]] | Omit = omit,
+ instructions: Optional[str] | Omit = omit,
+ max_output_tokens: Optional[int] | Omit = omit,
+ max_tool_calls: Optional[int] | Omit = omit,
+ metadata: Optional[Metadata] | Omit = omit,
+ parallel_tool_calls: Optional[bool] | Omit = omit,
+ moderation: Optional[response_create_params.Moderation] | Omit = omit,
+ previous_response_id: Optional[str] | Omit = omit,
+ prompt: Optional[ResponsePromptParam] | Omit = omit,
+ prompt_cache_key: Optional[str] | Omit = omit,
+ prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
+ prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
+ reasoning: Optional[Reasoning] | Omit = omit,
+ safety_identifier: Optional[str] | Omit = omit,
+ service_tier: Optional[ServiceTier] | Omit = omit,
+ store: Optional[bool] | Omit = omit,
+ stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
+ temperature: Optional[float] | Omit = omit,
+ text: ResponseTextConfigParam | Omit = omit,
+ tool_choice: response_create_params.ToolChoice | Omit = omit,
+ top_logprobs: Optional[int] | Omit = omit,
+ top_p: Optional[float] | Omit = omit,
+ truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
+ user: str | Omit = omit,
+ starting_after: int | Omit = omit,
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> AsyncResponseStreamManager[TextFormatT]:
+ """stream"""
+ return async_stream(
+ self,
+ response_id=response_id,
+ input=input,
+ model=model,
+ access_programs=access_programs,
+ background=background,
+ context_management=context_management,
+ text_format=text_format,
+ tools=tools,
+ conversation=conversation,
+ include=include,
+ instructions=instructions,
+ max_output_tokens=max_output_tokens,
+ max_tool_calls=max_tool_calls,
+ metadata=metadata,
+ parallel_tool_calls=parallel_tool_calls,
+ moderation=moderation,
+ previous_response_id=previous_response_id,
+ prompt=prompt,
+ prompt_cache_key=prompt_cache_key,
+ prompt_cache_options=prompt_cache_options,
+ prompt_cache_retention=prompt_cache_retention,
+ reasoning=reasoning,
+ safety_identifier=safety_identifier,
+ service_tier=service_tier,
+ store=store,
+ stream_options=stream_options,
+ temperature=temperature,
+ text=text,
+ tool_choice=tool_choice,
+ top_logprobs=top_logprobs,
+ top_p=top_p,
+ truncation=truncation,
+ user=user,
+ starting_after=starting_after,
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ )
+
@overload
async def create(
self,
@@ -2758,261 +2950,25 @@ async def create(
- `disabled` (default): If the input size will exceed the context window size
for a model, the request will fail with a 400 error.
- user: This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
- `prompt_cache_key` instead to maintain caching optimizations. A stable
- identifier for your end-users. Used 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).
-
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- ...
-
- async def create(
- self,
- *,
- access_programs: response_create_params.AccessPrograms | Omit = omit,
- background: Optional[bool] | Omit = omit,
- context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
- conversation: Optional[response_create_params.Conversation] | Omit = omit,
- include: Optional[List[ResponseIncludable]] | Omit = omit,
- input: Union[str, ResponseInputParam] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_output_tokens: Optional[int] | Omit = omit,
- max_tool_calls: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- model: ResponsesModel | Omit = omit,
- moderation: Optional[response_create_params.Moderation] | Omit = omit,
- parallel_tool_calls: Optional[bool] | Omit = omit,
- previous_response_id: Optional[str] | Omit = omit,
- prompt: Optional[ResponsePromptParam] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning: Optional[Reasoning] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- service_tier: Optional[ServiceTier] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream: Optional[Literal[False]] | Literal[True] | Omit = omit,
- stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- text: ResponseTextConfigParam | Omit = omit,
- tool_choice: response_create_params.ToolChoice | Omit = omit,
- tools: Iterable[ToolParam] | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
- user: str | Omit = omit,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Response | AsyncStream[ResponseStreamEvent]:
- return await self._post(
- "/responses",
- body=await async_maybe_transform(
- {
- "model": model,
- "stream": stream,
- "service_tier": service_tier,
- "access_programs": access_programs,
- "background": background,
- "context_management": context_management,
- "conversation": conversation,
- "include": include,
- "input": input,
- "instructions": instructions,
- "max_output_tokens": max_output_tokens,
- "max_tool_calls": max_tool_calls,
- "metadata": metadata,
- "moderation": moderation,
- "parallel_tool_calls": parallel_tool_calls,
- "previous_response_id": previous_response_id,
- "prompt": prompt,
- "prompt_cache_key": prompt_cache_key,
- "prompt_cache_options": prompt_cache_options,
- "prompt_cache_retention": prompt_cache_retention,
- "reasoning": reasoning,
- "safety_identifier": safety_identifier,
- "store": store,
- "stream_options": stream_options,
- "temperature": temperature,
- "text": text,
- "tool_choice": tool_choice,
- "tools": tools,
- "top_logprobs": top_logprobs,
- "top_p": top_p,
- "truncation": truncation,
- "user": user,
- },
- response_create_params.ResponseCreateParamsStreaming
- if stream
- else response_create_params.ResponseCreateParamsNonStreaming,
- ),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- security={"bearer_auth": True},
- ),
- cast_to=Response,
- stream=stream or False,
- stream_cls=AsyncStream[ResponseStreamEvent],
- )
-
- @overload
- def stream(
- self,
- *,
- response_id: str,
- text_format: type[TextFormatT] | Omit = omit,
- starting_after: int | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncResponseStreamManager[TextFormatT]: ...
-
- @overload
- def stream(
- self,
- *,
- input: Union[str, ResponseInputParam],
- model: ResponsesModel,
- access_programs: response_create_params.AccessPrograms | Omit = omit,
- background: Optional[bool] | Omit = omit,
- context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
- text_format: type[TextFormatT] | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
- conversation: Optional[response_create_params.Conversation] | Omit = omit,
- include: Optional[List[ResponseIncludable]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_output_tokens: Optional[int] | Omit = omit,
- max_tool_calls: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- parallel_tool_calls: Optional[bool] | Omit = omit,
- moderation: Optional[response_create_params.Moderation] | Omit = omit,
- previous_response_id: Optional[str] | Omit = omit,
- prompt: Optional[ResponsePromptParam] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning: Optional[Reasoning] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- service_tier: Optional[ServiceTier] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- text: ResponseTextConfigParam | Omit = omit,
- tool_choice: response_create_params.ToolChoice | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
- user: str | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncResponseStreamManager[TextFormatT]: ...
-
- def stream(
- self,
- *,
- response_id: str | Omit = omit,
- input: Union[str, ResponseInputParam] | Omit = omit,
- model: ResponsesModel | Omit = omit,
- access_programs: response_create_params.AccessPrograms | Omit = omit,
- background: Optional[bool] | Omit = omit,
- context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
- text_format: type[TextFormatT] | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
- conversation: Optional[response_create_params.Conversation] | Omit = omit,
- include: Optional[List[ResponseIncludable]] | Omit = omit,
- instructions: Optional[str] | Omit = omit,
- max_output_tokens: Optional[int] | Omit = omit,
- max_tool_calls: Optional[int] | Omit = omit,
- metadata: Optional[Metadata] | Omit = omit,
- parallel_tool_calls: Optional[bool] | Omit = omit,
- moderation: Optional[response_create_params.Moderation] | Omit = omit,
- previous_response_id: Optional[str] | Omit = omit,
- prompt: Optional[ResponsePromptParam] | Omit = omit,
- prompt_cache_key: Optional[str] | Omit = omit,
- prompt_cache_options: response_create_params.PromptCacheOptions | Omit = omit,
- prompt_cache_retention: Optional[Literal["in_memory", "24h"]] | Omit = omit,
- reasoning: Optional[Reasoning] | Omit = omit,
- safety_identifier: Optional[str] | Omit = omit,
- service_tier: Optional[ServiceTier] | Omit = omit,
- store: Optional[bool] | Omit = omit,
- stream_options: Optional[response_create_params.StreamOptions] | Omit = omit,
- temperature: Optional[float] | Omit = omit,
- text: ResponseTextConfigParam | Omit = omit,
- tool_choice: response_create_params.ToolChoice | Omit = omit,
- top_logprobs: Optional[int] | Omit = omit,
- top_p: Optional[float] | Omit = omit,
- truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
- user: str | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncResponseStreamManager[TextFormatT]:
- return async_stream(
- self,
- response_id=response_id,
- input=input,
- model=model,
- access_programs=access_programs,
- background=background,
- context_management=context_management,
- text_format=text_format,
- tools=tools,
- conversation=conversation,
- include=include,
- instructions=instructions,
- max_output_tokens=max_output_tokens,
- max_tool_calls=max_tool_calls,
- metadata=metadata,
- parallel_tool_calls=parallel_tool_calls,
- moderation=moderation,
- previous_response_id=previous_response_id,
- prompt=prompt,
- prompt_cache_key=prompt_cache_key,
- prompt_cache_options=prompt_cache_options,
- prompt_cache_retention=prompt_cache_retention,
- reasoning=reasoning,
- safety_identifier=safety_identifier,
- service_tier=service_tier,
- store=store,
- stream_options=stream_options,
- temperature=temperature,
- text=text,
- tool_choice=tool_choice,
- top_logprobs=top_logprobs,
- top_p=top_p,
- truncation=truncation,
- user=user,
- starting_after=starting_after,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- )
-
- async def parse(
+ user: This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
+ `prompt_cache_key` instead to maintain caching optimizations. A stable
+ identifier for your end-users. Used 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).
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ ...
+
+ async def create(
self,
*,
- text_format: type[TextFormatT] | Omit = omit,
access_programs: response_create_params.AccessPrograms | Omit = omit,
background: Optional[bool] | Omit = omit,
context_management: Optional[Iterable[response_create_params.ContextManagement]] | Omit = omit,
@@ -3040,57 +2996,69 @@ async def parse(
temperature: Optional[float] | Omit = omit,
text: ResponseTextConfigParam | Omit = omit,
tool_choice: response_create_params.ToolChoice | Omit = omit,
- tools: Iterable[ParseableToolParam] | Omit = omit,
+ tools: Iterable[ToolParam] | Omit = omit,
top_logprobs: Optional[int] | Omit = omit,
top_p: Optional[float] | Omit = omit,
truncation: Optional[Literal["auto", "disabled"]] | Omit = omit,
user: str | Omit = omit,
- verbosity: Optional[Literal["low", "medium", "high"]] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ParsedResponse[TextFormatT]:
- return await async_parse(
- self,
- text_format=text_format,
- access_programs=access_programs,
- background=background,
- context_management=context_management,
- conversation=conversation,
- include=include,
- input=input,
- instructions=instructions,
- max_output_tokens=max_output_tokens,
- max_tool_calls=max_tool_calls,
- metadata=metadata,
- model=model,
- moderation=moderation,
- parallel_tool_calls=parallel_tool_calls,
- previous_response_id=previous_response_id,
- prompt=prompt,
- prompt_cache_key=prompt_cache_key,
- prompt_cache_options=prompt_cache_options,
- prompt_cache_retention=prompt_cache_retention,
- reasoning=reasoning,
- safety_identifier=safety_identifier,
- service_tier=service_tier,
- store=store,
- stream=stream,
- stream_options=stream_options,
- temperature=temperature,
- text=text,
- tool_choice=tool_choice,
- tools=tools,
- top_logprobs=top_logprobs,
- top_p=top_p,
- truncation=truncation,
- user=user,
- verbosity=verbosity,
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
+ timeout: float | httpx2.Timeout | None | NotGiven = not_given,
+ ) -> Response | AsyncStream[ResponseStreamEvent]:
+ return await self._post(
+ "/responses",
+ body=await async_maybe_transform(
+ {
+ "model": model,
+ "stream": stream,
+ "service_tier": service_tier,
+ "access_programs": access_programs,
+ "background": background,
+ "context_management": context_management,
+ "conversation": conversation,
+ "include": include,
+ "input": input,
+ "instructions": instructions,
+ "max_output_tokens": max_output_tokens,
+ "max_tool_calls": max_tool_calls,
+ "metadata": metadata,
+ "moderation": moderation,
+ "parallel_tool_calls": parallel_tool_calls,
+ "previous_response_id": previous_response_id,
+ "prompt": prompt,
+ "prompt_cache_key": prompt_cache_key,
+ "prompt_cache_options": prompt_cache_options,
+ "prompt_cache_retention": prompt_cache_retention,
+ "reasoning": reasoning,
+ "safety_identifier": safety_identifier,
+ "store": store,
+ "stream_options": stream_options,
+ "temperature": temperature,
+ "text": text,
+ "tool_choice": tool_choice,
+ "tools": tools,
+ "top_logprobs": top_logprobs,
+ "top_p": top_p,
+ "truncation": truncation,
+ "user": user,
+ },
+ response_create_params.ResponseCreateParamsStreaming
+ if stream
+ else response_create_params.ResponseCreateParamsNonStreaming,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ security={"bearer_auth": True},
+ ),
+ cast_to=Response,
+ stream=stream or False,
+ stream_cls=AsyncStream[ResponseStreamEvent],
)
@overload
@@ -3102,53 +3070,13 @@ async def retrieve(
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
stream: Literal[False] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx2.Timeout | None | NotGiven = not_given,
- ) -> Response: ...
-
- @overload
- async def retrieve(
- self,
- response_id: str,
- *,
- stream: Literal[True],
- include: List[ResponseIncludable] | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncStream[ResponseStreamEvent]: ...
-
- @overload
- async def retrieve(
- self,
- response_id: str,
- *,
- stream: bool,
- include: List[ResponseIncludable] | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Response | AsyncStream[ResponseStreamEvent]: ...
-
- @overload
- async def retrieve(
- self,
- response_id: str,
- *,
- stream: bool = False,
- include: List[ResponseIncludable] | Omit = omit,
- starting_after: int | Omit = omit,
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx2.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Response | AsyncStream[ResponseStreamEvent]:
+ ) -> Response:
"""
Retrieves a model response with the given ID.
@@ -3180,6 +3108,7 @@ async def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@overload
async def retrieve(
@@ -3190,6 +3119,8 @@ async def retrieve(
include: List[ResponseIncludable] | Omit = omit,
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -3226,6 +3157,7 @@ async def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
@overload
async def retrieve(
@@ -3236,6 +3168,8 @@ async def retrieve(
include: List[ResponseIncludable] | Omit = omit,
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -3272,6 +3206,7 @@ async def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
async def retrieve(
self,
@@ -3281,6 +3216,8 @@ async def retrieve(
include_obfuscation: bool | Omit = omit,
starting_after: int | Omit = omit,
stream: Literal[False] | Literal[True] | Omit = omit,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
@@ -4604,6 +4541,40 @@ def __init__(self, connection: ResponsesConnection) -> None:
class ResponsesResponseResource(BaseResponsesConnectionResource):
+ def steer(self, *, input: ResponseSteerInputParam, previous_response_id: str) -> None:
+ """Queues user input to steer a response on this WebSocket connection.
+
+ Input
+ can contain text, images, and files. Steering is supported only for
+ single-agent responses on models and execution modes that support steering.
+ Responses bound to a conversation or using automatic compaction do not
+ support steering.
+
+ A `response.steer.accepted` event acknowledges that the server owns the
+ queued input, not that it has been applied. The successor's `response.created`
+ event is the commit point. Input that cannot be committed is returned in
+ `response.steer.failed`.
+
+ Steering may cause the active response to finish at a safe output boundary
+ with `response.incomplete` and `incomplete_details.reason` set to `steered`,
+ followed automatically by a successor `response.created`. Normal completion
+ can also be followed by an automatic successor. Automatic successors inherit
+ the previous response's settings and continue from it with the queued input.
+
+ If the response stops for client-owned tool output or approval, accepted
+ steering input remains queued and `response.steer.pending` is emitted after
+ `response.completed`. Fill the `required_input` stubs from that event with
+ saved tool results or approval decisions, and send one explicit
+ `response.create` per parent with the same `previous_response_id` and
+ WebSocket lane. Do not rerun tools or resend accepted steering input. The
+ queued input is prepended in submission order to that request's input, and
+ the explicit request retains its own settings.
+
+ This event accepts only `type`, `previous_response_id`, and `input`. Do not
+ send `stream_id`; the target response determines the WebSocket lane.
+ """
+ self._connection.send({"type": "response.steer", "input": input, "previous_response_id": previous_response_id})
+
def create(
self,
*,
@@ -4696,7 +4667,14 @@ def create(
)
)
- def steer(self, *, input: ResponseSteerInputParam, previous_response_id: str) -> None:
+
+class BaseAsyncResponsesConnectionResource:
+ def __init__(self, connection: AsyncResponsesConnection) -> None:
+ self._connection = connection
+
+
+class AsyncResponsesResponseResource(BaseAsyncResponsesConnectionResource):
+ async def steer(self, *, input: ResponseSteerInputParam, previous_response_id: str) -> None:
"""Queues user input to steer a response on this WebSocket connection.
Input
@@ -4728,15 +4706,10 @@ def steer(self, *, input: ResponseSteerInputParam, previous_response_id: str) ->
This event accepts only `type`, `previous_response_id`, and `input`. Do not
send `stream_id`; the target response determines the WebSocket lane.
"""
- self._connection.send({"type": "response.steer", "input": input, "previous_response_id": previous_response_id})
-
-
-class BaseAsyncResponsesConnectionResource:
- def __init__(self, connection: AsyncResponsesConnection) -> None:
- self._connection = connection
-
+ await self._connection.send(
+ {"type": "response.steer", "input": input, "previous_response_id": previous_response_id}
+ )
-class AsyncResponsesResponseResource(BaseAsyncResponsesConnectionResource):
async def create(
self,
*,
@@ -4828,39 +4801,3 @@ async def create(
),
)
)
-
- async def steer(self, *, input: ResponseSteerInputParam, previous_response_id: str) -> None:
- """Queues user input to steer a response on this WebSocket connection.
-
- Input
- can contain text, images, and files. Steering is supported only for
- single-agent responses on models and execution modes that support steering.
- Responses bound to a conversation or using automatic compaction do not
- support steering.
-
- A `response.steer.accepted` event acknowledges that the server owns the
- queued input, not that it has been applied. The successor's `response.created`
- event is the commit point. Input that cannot be committed is returned in
- `response.steer.failed`.
-
- Steering may cause the active response to finish at a safe output boundary
- with `response.incomplete` and `incomplete_details.reason` set to `steered`,
- followed automatically by a successor `response.created`. Normal completion
- can also be followed by an automatic successor. Automatic successors inherit
- the previous response's settings and continue from it with the queued input.
-
- If the response stops for client-owned tool output or approval, accepted
- steering input remains queued and `response.steer.pending` is emitted after
- `response.completed`. Fill the `required_input` stubs from that event with
- saved tool results or approval decisions, and send one explicit
- `response.create` per parent with the same `previous_response_id` and
- WebSocket lane. Do not rerun tools or resend accepted steering input. The
- queued input is prepended in submission order to that request's input, and
- the explicit request retains its own settings.
-
- This event accepts only `type`, `previous_response_id`, and `input`. Do not
- send `stream_id`; the target response determines the WebSocket lane.
- """
- await self._connection.send(
- {"type": "response.steer", "input": input, "previous_response_id": previous_response_id}
- )
diff --git a/src/openai/types/beta/beta_response_tool_search_output_item_param.py b/src/openai/types/beta/beta_response_tool_search_output_item_param.py
index 951f955c8d..d582fb3a40 100644
--- a/src/openai/types/beta/beta_response_tool_search_output_item_param.py
+++ b/src/openai/types/beta/beta_response_tool_search_output_item_param.py
@@ -312,11 +312,14 @@ class ToolImageGeneration(BaseModel):
] = None
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Optional[Literal["auto", "low"]] = None
diff --git a/src/openai/types/beta/beta_response_tool_search_output_item_param_param.py b/src/openai/types/beta/beta_response_tool_search_output_item_param_param.py
index f5a76f4f05..66369af289 100644
--- a/src/openai/types/beta/beta_response_tool_search_output_item_param_param.py
+++ b/src/openai/types/beta/beta_response_tool_search_output_item_param_param.py
@@ -310,11 +310,14 @@ class ToolImageGeneration(TypedDict, total=False):
]
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Literal["auto", "low"]
diff --git a/src/openai/types/beta/beta_tool.py b/src/openai/types/beta/beta_tool.py
index 2acf8c1087..486e51ae3e 100644
--- a/src/openai/types/beta/beta_tool.py
+++ b/src/openai/types/beta/beta_tool.py
@@ -310,11 +310,14 @@ class ImageGeneration(BaseModel):
] = None
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Optional[Literal["auto", "low"]] = None
diff --git a/src/openai/types/beta/beta_tool_param.py b/src/openai/types/beta/beta_tool_param.py
index bdcd03b67b..bc85f05ad5 100644
--- a/src/openai/types/beta/beta_tool_param.py
+++ b/src/openai/types/beta/beta_tool_param.py
@@ -308,11 +308,14 @@ class ImageGeneration(TypedDict, total=False):
]
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Literal["auto", "low"]
diff --git a/src/openai/types/decision_input_image_param.py b/src/openai/types/decision_input_image_param.py
index 54fc06ea56..faf1c7f81e 100644
--- a/src/openai/types/decision_input_image_param.py
+++ b/src/openai/types/decision_input_image_param.py
@@ -11,13 +11,10 @@
class PromptCacheBreakpoint(TypedDict, total=False):
- """Marks the exact end of a reusable prompt prefix.
-
- The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.
- """
+ """Marks the exact end of a reusable prompt prefix."""
mode: Required[Literal["explicit"]]
- """The breakpoint mode. Always `explicit`."""
+ """The prompt cache mode."""
class DecisionInputImageParam(TypedDict, total=False):
diff --git a/src/openai/types/decision_input_message_param.py b/src/openai/types/decision_input_message_param.py
index 4cf7e8ee0a..8016121c11 100644
--- a/src/openai/types/decision_input_message_param.py
+++ b/src/openai/types/decision_input_message_param.py
@@ -33,7 +33,7 @@ class DecisionInputUserMessage(TypedDict, total=False):
class DecisionInputMessageParam(DecisionInputUserMessage, total=False):
- """A user message, retained for backwards compatibility."""
+ """A user message containing input text, images, or JSON."""
class DecisionInputDeveloperMessage(TypedDict, total=False):
diff --git a/src/openai/types/decision_input_text_param.py b/src/openai/types/decision_input_text_param.py
index 7398dfcfeb..2aa74d2e82 100644
--- a/src/openai/types/decision_input_text_param.py
+++ b/src/openai/types/decision_input_text_param.py
@@ -11,13 +11,10 @@
class PromptCacheBreakpoint(TypedDict, total=False):
- """Marks the exact end of a reusable prompt prefix.
-
- The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.
- """
+ """Marks the exact end of a reusable prompt prefix."""
mode: Required[Literal["explicit"]]
- """The breakpoint mode. Always `explicit`."""
+ """The prompt cache mode."""
class DecisionInputTextParam(TypedDict, total=False):
diff --git a/src/openai/types/fine_tuning/fine_tuning_job_integration.py b/src/openai/types/fine_tuning/fine_tuning_job_integration.py
index 8fefe8a902..47d1a6940f 100644
--- a/src/openai/types/fine_tuning/fine_tuning_job_integration.py
+++ b/src/openai/types/fine_tuning/fine_tuning_job_integration.py
@@ -2,4 +2,6 @@
from .fine_tuning_job_wandb_integration_object import FineTuningJobWandbIntegrationObject
+__all__ = ["FineTuningJobIntegration"]
+
FineTuningJobIntegration = FineTuningJobWandbIntegrationObject
diff --git a/src/openai/types/image_edit_params.py b/src/openai/types/image_edit_params.py
index 5013d20d9c..dad1464bc8 100644
--- a/src/openai/types/image_edit_params.py
+++ b/src/openai/types/image_edit_params.py
@@ -61,11 +61,14 @@ class ImageEditParamsBase(TypedDict, total=False):
model: Union[str, ImageModel, None]
"""
- The GPT image model to use for image editing (`gpt-image-1`, `gpt-image-1-mini`,
+ The GPT image model to use for image editing (`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`, or
`chatgpt-image-latest`).
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
n: Optional[int]
diff --git a/src/openai/types/image_generate_params.py b/src/openai/types/image_generate_params.py
index f79f888dc0..4960febe4e 100644
--- a/src/openai/types/image_generate_params.py
+++ b/src/openai/types/image_generate_params.py
@@ -34,11 +34,14 @@ class ImageGenerateParamsBase(TypedDict, total=False):
model: Union[str, ImageModel, None]
"""The GPT image model to use for image generation.
- Specify a model explicitly. Supported models include `gpt-image-1`,
- `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`,
+ Specify a model explicitly. Supported models include `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`, and
`chatgpt-image-latest`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Optional[Literal["low", "auto"]]
diff --git a/src/openai/types/image_model.py b/src/openai/types/image_model.py
index 32b28f69cc..d622ee62e5 100644
--- a/src/openai/types/image_model.py
+++ b/src/openai/types/image_model.py
@@ -20,6 +20,8 @@
]
"""Deprecated values:
+- "gpt-image-1": GPT Image 1 was shut down on October 23, 2026. Use
+ gpt-image-2.5-sunburst or gpt-image-2.5-flare instead.
- "dall-e-2", "dall-e-3": This model was retired on May 12, 2026. Use a GPT
image model instead.
"""
diff --git a/src/openai/types/live/__init__.py b/src/openai/types/live/__init__.py
index 062e433435..960cf8c8d4 100644
--- a/src/openai/types/live/__init__.py
+++ b/src/openai/types/live/__init__.py
@@ -20,6 +20,7 @@
from .decision_trigger import DecisionTrigger as DecisionTrigger
from .session_resource import SessionResource as SessionResource
from .client_delegation import ClientDelegation as ClientDelegation
+from .decision_question import DecisionQuestion as DecisionQuestion
from .fork_client_event import ForkClientEvent as ForkClientEvent
from .fork_server_event import ForkServerEvent as ForkServerEvent
from .audio_format_param import AudioFormatParam as AudioFormatParam
@@ -29,6 +30,7 @@
from .live_create_params import LiveCreateParams as LiveCreateParams
from .client_config_param import ClientConfigParam as ClientConfigParam
from .data_channel_config import DataChannelConfig as DataChannelConfig
+from .decision_input_text import DecisionInputText as DecisionInputText
from .fork_session_config import ForkSessionConfig as ForkSessionConfig
from .function_tool_param import FunctionToolParam as FunctionToolParam
from .session_close_event import SessionCloseEvent as SessionCloseEvent
@@ -36,12 +38,14 @@
from .session_start_event import SessionStartEvent as SessionStartEvent
from .connect_client_event import ConnectClientEvent as ConnectClientEvent
from .connect_server_event import ConnectServerEvent as ConnectServerEvent
+from .decision_json_object import DecisionJSONObject as DecisionJSONObject
from .live_create_response import LiveCreateResponse as LiveCreateResponse
from .session_closed_event import SessionClosedEvent as SessionClosedEvent
from .session_config_param import SessionConfigParam as SessionConfigParam
from .session_refer_params import SessionReferParams as SessionReferParams
from .session_update_event import SessionUpdateEvent as SessionUpdateEvent
from .decision_create_event import DecisionCreateEvent as DecisionCreateEvent
+from .decision_user_message import DecisionUserMessage as DecisionUserMessage
from .response_create_event import ResponseCreateEvent as ResponseCreateEvent
from .server_event_selector import ServerEventSelector as ServerEventSelector
from .session_accept_params import SessionAcceptParams as SessionAcceptParams
@@ -51,10 +55,13 @@
from .session_update_config import SessionUpdateConfig as SessionUpdateConfig
from .session_updated_event import SessionUpdatedEvent as SessionUpdatedEvent
from .thinking_append_event import ThinkingAppendEvent as ThinkingAppendEvent
+from .decision_choice_option import DecisionChoiceOption as DecisionChoiceOption
from .decision_trigger_param import DecisionTriggerParam as DecisionTriggerParam
from .input_audio_mute_event import InputAudioMuteEvent as InputAudioMuteEvent
from .client_delegation_param import ClientDelegationParam as ClientDelegationParam
from .commentary_append_event import CommentaryAppendEvent as CommentaryAppendEvent
+from .decision_question_param import DecisionQuestionParam as DecisionQuestionParam
+from .decision_system_message import DecisionSystemMessage as DecisionSystemMessage
from .fork_client_event_param import ForkClientEventParam as ForkClientEventParam
from .input_audio_muted_event import InputAudioMutedEvent as InputAudioMutedEvent
from .sideband_connect_params import SidebandConnectParams as SidebandConnectParams
@@ -66,20 +73,25 @@
from .output_audio_delta_event import OutputAudioDeltaEvent as OutputAudioDeltaEvent
from .commentary_appended_event import CommentaryAppendedEvent as CommentaryAppendedEvent
from .data_channel_config_param import DataChannelConfigParam as DataChannelConfigParam
+from .decision_input_text_param import DecisionInputTextParam as DecisionInputTextParam
from .fork_session_config_param import ForkSessionConfigParam as ForkSessionConfigParam
from .input_audio_unmuted_event import InputAudioUnmutedEvent as InputAudioUnmutedEvent
from .instructions_append_event import InstructionsAppendEvent as InstructionsAppendEvent
from .session_close_event_param import SessionCloseEventParam as SessionCloseEventParam
from .session_start_event_param import SessionStartEventParam as SessionStartEventParam
from .connect_client_event_param import ConnectClientEventParam as ConnectClientEventParam
+from .decision_assistant_message import DecisionAssistantMessage as DecisionAssistantMessage
+from .decision_developer_message import DecisionDeveloperMessage as DecisionDeveloperMessage
from .decision_item_create_event import DecisionItemCreateEvent as DecisionItemCreateEvent
from .decision_item_delete_event import DecisionItemDeleteEvent as DecisionItemDeleteEvent
+from .decision_json_object_param import DecisionJSONObjectParam as DecisionJSONObjectParam
from .media_session_config_param import MediaSessionConfigParam as MediaSessionConfigParam
from .response_item_create_event import ResponseItemCreateEvent as ResponseItemCreateEvent
from .session_update_event_param import SessionUpdateEventParam as SessionUpdateEventParam
from .decision_create_event_param import DecisionCreateEventParam as DecisionCreateEventParam
from .decision_item_created_event import DecisionItemCreatedEvent as DecisionItemCreatedEvent
from .decision_item_deleted_event import DecisionItemDeletedEvent as DecisionItemDeletedEvent
+from .decision_user_message_param import DecisionUserMessageParam as DecisionUserMessageParam
from .decisions_delegation_config import DecisionsDelegationConfig as DecisionsDelegationConfig
from .instructions_appended_event import InstructionsAppendedEvent as InstructionsAppendedEvent
from .response_create_event_param import ResponseCreateEventParam as ResponseCreateEventParam
@@ -88,19 +100,27 @@
from .session_update_config_param import SessionUpdateConfigParam as SessionUpdateConfigParam
from .session_usage_updated_event import SessionUsageUpdatedEvent as SessionUsageUpdatedEvent
from .thinking_append_event_param import ThinkingAppendEventParam as ThinkingAppendEventParam
+from .decision_choice_option_param import DecisionChoiceOptionParam as DecisionChoiceOptionParam
+from .decision_stored_user_message import DecisionStoredUserMessage as DecisionStoredUserMessage
from .input_audio_mute_event_param import InputAudioMuteEventParam as InputAudioMuteEventParam
from .input_transcript_delta_event import InputTranscriptDeltaEvent as InputTranscriptDeltaEvent
from .commentary_append_event_param import CommentaryAppendEventParam as CommentaryAppendEventParam
+from .decision_system_message_param import DecisionSystemMessageParam as DecisionSystemMessageParam
from .output_transcript_delta_event import OutputTranscriptDeltaEvent as OutputTranscriptDeltaEvent
+from .decision_stored_system_message import DecisionStoredSystemMessage as DecisionStoredSystemMessage
from .fork_session_start_event_param import ForkSessionStartEventParam as ForkSessionStartEventParam
from .input_audio_append_event_param import InputAudioAppendEventParam as InputAudioAppendEventParam
from .input_audio_unmute_event_param import InputAudioUnmuteEventParam as InputAudioUnmuteEventParam
from .instructions_append_event_param import InstructionsAppendEventParam as InstructionsAppendEventParam
from .media_session_fork_config_param import MediaSessionForkConfigParam as MediaSessionForkConfigParam
from .output_audio_fixture_play_event import OutputAudioFixturePlayEvent as OutputAudioFixturePlayEvent
+from .decision_assistant_message_param import DecisionAssistantMessageParam as DecisionAssistantMessageParam
+from .decision_developer_message_param import DecisionDeveloperMessageParam as DecisionDeveloperMessageParam
from .decision_item_create_event_param import DecisionItemCreateEventParam as DecisionItemCreateEventParam
from .decision_item_delete_event_param import DecisionItemDeleteEventParam as DecisionItemDeleteEventParam
from .response_item_create_event_param import ResponseItemCreateEventParam as ResponseItemCreateEventParam
+from .decision_stored_assistant_message import DecisionStoredAssistantMessage as DecisionStoredAssistantMessage
+from .decision_stored_developer_message import DecisionStoredDeveloperMessage as DecisionStoredDeveloperMessage
from .decisions_delegation_config_param import DecisionsDelegationConfigParam as DecisionsDelegationConfigParam
from .output_audio_fixture_played_event import OutputAudioFixturePlayedEvent as OutputAudioFixturePlayedEvent
from .responses_delegation_config_param import ResponsesDelegationConfigParam as ResponsesDelegationConfigParam
diff --git a/src/openai/types/live/decision_assistant_message.py b/src/openai/types/live/decision_assistant_message.py
new file mode 100644
index 0000000000..55c0d61811
--- /dev/null
+++ b/src/openai/types/live/decision_assistant_message.py
@@ -0,0 +1,46 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal, Annotated, TypeAlias
+
+from ..._utils import PropertyInfo
+from ..._models import BaseModel
+
+__all__ = ["DecisionAssistantMessage", "ContentPart", "ContentPartOutputText", "ContentPartRefusal"]
+
+
+class ContentPartOutputText(BaseModel):
+ text: str
+ """The text content."""
+
+ type: Literal["output_text"]
+
+
+class ContentPartRefusal(BaseModel):
+ refusal: str
+ """The refusal text."""
+
+ type: Literal["refusal"]
+
+
+ContentPart: TypeAlias = Annotated[Union[ContentPartOutputText, ContentPartRefusal], PropertyInfo(discriminator="type")]
+
+
+class DecisionAssistantMessage(BaseModel):
+ content: Union[str, List[ContentPart]]
+ """The text input to the model."""
+
+ role: Literal["assistant"]
+
+ id: Optional[str] = None
+ """The unique ID of this message item."""
+
+ phase: Optional[Literal["commentary", "final_answer"]] = None
+ """
+ Labels an `assistant` message as intermediate commentary (`commentary`) or the
+ final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
+ sending follow-up requests, preserve and resend phase on all assistant messages
+ — dropping it can degrade performance. Not used for user messages.
+ """
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_assistant_message_param.py b/src/openai/types/live/decision_assistant_message_param.py
new file mode 100644
index 0000000000..a03e5f7346
--- /dev/null
+++ b/src/openai/types/live/decision_assistant_message_param.py
@@ -0,0 +1,45 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union, Iterable, Optional
+from typing_extensions import Literal, Required, TypeAlias, TypedDict
+
+__all__ = ["DecisionAssistantMessageParam", "ContentPart", "ContentPartOutputText", "ContentPartRefusal"]
+
+
+class ContentPartOutputText(TypedDict, total=False):
+ text: Required[str]
+ """The text content."""
+
+ type: Required[Literal["output_text"]]
+
+
+class ContentPartRefusal(TypedDict, total=False):
+ refusal: Required[str]
+ """The refusal text."""
+
+ type: Required[Literal["refusal"]]
+
+
+ContentPart: TypeAlias = Union[ContentPartOutputText, ContentPartRefusal]
+
+
+class DecisionAssistantMessageParam(TypedDict, total=False):
+ content: Required[Union[str, Iterable[ContentPart]]]
+ """The text input to the model."""
+
+ role: Required[Literal["assistant"]]
+
+ id: Optional[str]
+ """The unique ID of this message item."""
+
+ phase: Optional[Literal["commentary", "final_answer"]]
+ """
+ Labels an `assistant` message as intermediate commentary (`commentary`) or the
+ final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
+ sending follow-up requests, preserve and resend phase on all assistant messages
+ — dropping it can degrade performance. Not used for user messages.
+ """
+
+ type: Literal["message"]
diff --git a/src/openai/types/live/decision_choice_option.py b/src/openai/types/live/decision_choice_option.py
new file mode 100644
index 0000000000..d12ea0b9e8
--- /dev/null
+++ b/src/openai/types/live/decision_choice_option.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import Union, Optional
+
+from pydantic import StrictStr, StrictBool
+
+from ..._models import BaseModel
+
+__all__ = ["DecisionChoiceOption"]
+
+
+class DecisionChoiceOption(BaseModel):
+ value: Union[StrictStr, StrictBool]
+
+ description: Optional[str] = None
diff --git a/src/openai/types/live/decision_choice_option_param.py b/src/openai/types/live/decision_choice_option_param.py
new file mode 100644
index 0000000000..6290506e58
--- /dev/null
+++ b/src/openai/types/live/decision_choice_option_param.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union
+from typing_extensions import Required, TypedDict
+
+__all__ = ["DecisionChoiceOptionParam"]
+
+
+class DecisionChoiceOptionParam(TypedDict, total=False):
+ value: Required[Union[str, bool]]
+
+ description: str
diff --git a/src/openai/types/live/decision_developer_message.py b/src/openai/types/live/decision_developer_message.py
new file mode 100644
index 0000000000..1672086c6d
--- /dev/null
+++ b/src/openai/types/live/decision_developer_message.py
@@ -0,0 +1,21 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+
+__all__ = ["DecisionDeveloperMessage"]
+
+
+class DecisionDeveloperMessage(BaseModel):
+ content: Union[str, List[DecisionInputText]]
+ """The text input to the model."""
+
+ role: Literal["developer"]
+
+ id: Optional[str] = None
+ """The unique ID of this message item."""
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_developer_message_param.py b/src/openai/types/live/decision_developer_message_param.py
new file mode 100644
index 0000000000..40b54b7402
--- /dev/null
+++ b/src/openai/types/live/decision_developer_message_param.py
@@ -0,0 +1,22 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union, Iterable, Optional
+from typing_extensions import Literal, Required, TypedDict
+
+from .decision_input_text_param import DecisionInputTextParam
+
+__all__ = ["DecisionDeveloperMessageParam"]
+
+
+class DecisionDeveloperMessageParam(TypedDict, total=False):
+ content: Required[Union[str, Iterable[DecisionInputTextParam]]]
+ """The text input to the model."""
+
+ role: Required[Literal["developer"]]
+
+ id: Optional[str]
+ """The unique ID of this message item."""
+
+ type: Literal["message"]
diff --git a/src/openai/types/live/decision_input_text.py b/src/openai/types/live/decision_input_text.py
new file mode 100644
index 0000000000..9b0838405d
--- /dev/null
+++ b/src/openai/types/live/decision_input_text.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+
+__all__ = ["DecisionInputText"]
+
+
+class DecisionInputText(BaseModel):
+ text: str
+ """The text input to the model."""
+
+ type: Literal["input_text"]
diff --git a/src/openai/types/live/decision_input_text_param.py b/src/openai/types/live/decision_input_text_param.py
new file mode 100644
index 0000000000..c8db76c29b
--- /dev/null
+++ b/src/openai/types/live/decision_input_text_param.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["DecisionInputTextParam"]
+
+
+class DecisionInputTextParam(TypedDict, total=False):
+ text: Required[str]
+ """The text input to the model."""
+
+ type: Required[Literal["input_text"]]
diff --git a/src/openai/types/live/decision_item_create_event.py b/src/openai/types/live/decision_item_create_event.py
index ef62815282..05485440d2 100644
--- a/src/openai/types/live/decision_item_create_event.py
+++ b/src/openai/types/live/decision_item_create_event.py
@@ -5,30 +5,62 @@
from ..._utils import PropertyInfo
from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+from .decision_user_message import (
+ ContentPart as ItemContentParts,
+ DecisionUserMessage,
+ DecisionUserMessage as Item,
+ ContentPartInputText as ItemContentPartsInputText,
+ ContentPartInputImage as ItemContentPartsInputImage,
+)
+from .decision_system_message import DecisionSystemMessage
+from .decision_assistant_message import DecisionAssistantMessage
+from .decision_developer_message import DecisionDeveloperMessage
__all__ = [
"DecisionItemCreateEvent",
+ "ItemUnion",
+ "ItemFunctionCall",
+ "ItemFunctionCallOutput",
+ "ItemFunctionCallOutputOutputParts",
+ "ItemFunctionCallOutputOutputPartsInputImage",
+ "ItemCustomToolCall",
+ "ItemCustomToolCallOutput",
+ "ItemCustomToolCallOutputOutputParts",
+ "ItemCustomToolCallOutputOutputPartsInputImage",
"Item",
"ItemContentParts",
- "ItemContentPartsInputText",
"ItemContentPartsInputImage",
+ "ItemContentPartsInputText",
]
-class ItemContentPartsInputText(BaseModel):
- text: str
- """The text input to the model."""
+class ItemFunctionCall(BaseModel):
+ arguments: str
+ """The function arguments as a JSON string."""
- type: Literal["input_text"]
- """The type of the input item. Always `input_text`."""
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+ name: str
+
+ type: Literal["function_call"]
+ """The item type. Always `function_call`."""
+
+ id: Optional[str] = None
+ """The local Decision item ID."""
-class ItemContentPartsInputImage(BaseModel):
+ namespace: Optional[str] = None
+ """The namespace of the function to call."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
+
+class ItemFunctionCallOutputOutputPartsInputImage(BaseModel):
image_url: str
- """An inline image encoded as a data URL."""
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
type: Literal["input_image"]
- """The type of the input item. Always `input_image`."""
detail: Optional[Literal["low", "high", "auto", "original"]] = None
"""The detail level of the image to be sent to the model.
@@ -37,22 +69,95 @@ class ItemContentPartsInputImage(BaseModel):
"""
-ItemContentParts: TypeAlias = Annotated[
- Union[ItemContentPartsInputText, ItemContentPartsInputImage], PropertyInfo(discriminator="type")
+ItemFunctionCallOutputOutputParts: TypeAlias = Annotated[
+ Union[DecisionInputText, ItemFunctionCallOutputOutputPartsInputImage], PropertyInfo(discriminator="type")
]
-class Item(BaseModel):
- content: Union[str, List[ItemContentParts]]
+class ItemFunctionCallOutput(BaseModel):
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+
+ output: Union[str, List[ItemFunctionCallOutputOutputParts]]
"""The text input to the model."""
- role: Literal["user"]
- """The message role. Always `user`."""
+ type: Literal["function_call_output"]
+ """The type of the function tool call output. Always `function_call_output`."""
id: Optional[str] = None
- """The unique ID of this message item."""
+ """The local Decision item ID."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
+
+class ItemCustomToolCall(BaseModel):
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+
+ input: str
+ """The input to the custom tool call."""
+
+ name: str
+ """The name of the custom tool to call."""
+
+ type: Literal["custom_tool_call"]
+ """The item type. Always `custom_tool_call`."""
+
+ id: Optional[str] = None
+ """The local Decision item ID."""
+
+ namespace: Optional[str] = None
+ """The namespace of the function to call."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
- type: Optional[Literal["message"]] = None
+class ItemCustomToolCallOutputOutputPartsInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+ItemCustomToolCallOutputOutputParts: TypeAlias = Annotated[
+ Union[DecisionInputText, ItemCustomToolCallOutputOutputPartsInputImage], PropertyInfo(discriminator="type")
+]
+
+
+class ItemCustomToolCallOutput(BaseModel):
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+
+ output: Union[str, List[ItemCustomToolCallOutputOutputParts]]
+ """The text input to the model."""
+
+ type: Literal["custom_tool_call_output"]
+
+ id: Optional[str] = None
+ """The local Decision item ID."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
+
+ItemUnion: TypeAlias = Annotated[
+ Union[
+ DecisionUserMessage,
+ DecisionDeveloperMessage,
+ DecisionSystemMessage,
+ DecisionAssistantMessage,
+ ItemFunctionCall,
+ ItemFunctionCallOutput,
+ ItemCustomToolCall,
+ ItemCustomToolCallOutput,
+ ],
+ PropertyInfo(discriminator="type"),
+]
class DecisionItemCreateEvent(BaseModel):
@@ -60,7 +165,7 @@ class DecisionItemCreateEvent(BaseModel):
Append an input item for future decisions without starting an evaluation or changing Live voice context.
"""
- item: Item
+ item: ItemUnion
type: Literal["decision.item.create"]
diff --git a/src/openai/types/live/decision_item_create_event_param.py b/src/openai/types/live/decision_item_create_event_param.py
index 4a879b196e..ab034f8a4c 100644
--- a/src/openai/types/live/decision_item_create_event_param.py
+++ b/src/openai/types/live/decision_item_create_event_param.py
@@ -5,29 +5,118 @@
from typing import Union, Iterable, Optional
from typing_extensions import Literal, Required, TypeAlias, TypedDict
+from .decision_input_text_param import DecisionInputTextParam
+from .decision_user_message_param import (
+ ContentPart as ItemContentParts,
+ ContentPartInputText as ItemContentPartsInputText,
+ ContentPartInputImage as ItemContentPartsInputImage,
+ DecisionUserMessageParam,
+ DecisionUserMessageParam as Item,
+)
+from .decision_system_message_param import DecisionSystemMessageParam
+from .decision_assistant_message_param import DecisionAssistantMessageParam
+from .decision_developer_message_param import DecisionDeveloperMessageParam
+
__all__ = [
"DecisionItemCreateEventParam",
+ "ItemUnion",
+ "ItemFunctionCall",
+ "ItemFunctionCallOutput",
+ "ItemFunctionCallOutputOutputParts",
+ "ItemFunctionCallOutputOutputPartsInputImage",
+ "ItemCustomToolCall",
+ "ItemCustomToolCallOutput",
+ "ItemCustomToolCallOutputOutputParts",
+ "ItemCustomToolCallOutputOutputPartsInputImage",
"Item",
"ItemContentParts",
- "ItemContentPartsInputText",
"ItemContentPartsInputImage",
+ "ItemContentPartsInputText",
+]
+
+
+class ItemFunctionCall(TypedDict, total=False):
+ arguments: Required[str]
+ """The function arguments as a JSON string."""
+
+ call_id: Required[str]
+ """The unique ID of the function tool call generated by the model."""
+
+ name: Required[str]
+
+ type: Required[Literal["function_call"]]
+ """The item type. Always `function_call`."""
+
+ id: Optional[str]
+ """The local Decision item ID."""
+
+ namespace: Optional[str]
+ """The namespace of the function to call."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]]
+
+
+class ItemFunctionCallOutputOutputPartsInputImage(TypedDict, total=False):
+ image_url: Required[str]
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Required[Literal["input_image"]]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]]
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+ItemFunctionCallOutputOutputParts: TypeAlias = Union[
+ DecisionInputTextParam, ItemFunctionCallOutputOutputPartsInputImage
]
-class ItemContentPartsInputText(TypedDict, total=False):
- text: Required[str]
+class ItemFunctionCallOutput(TypedDict, total=False):
+ call_id: Required[str]
+ """The unique ID of the function tool call generated by the model."""
+
+ output: Required[Union[str, Iterable[ItemFunctionCallOutputOutputParts]]]
"""The text input to the model."""
- type: Required[Literal["input_text"]]
- """The type of the input item. Always `input_text`."""
+ type: Required[Literal["function_call_output"]]
+ """The type of the function tool call output. Always `function_call_output`."""
+
+ id: Optional[str]
+ """The local Decision item ID."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]]
+
+
+class ItemCustomToolCall(TypedDict, total=False):
+ call_id: Required[str]
+ """The unique ID of the function tool call generated by the model."""
+
+ input: Required[str]
+ """The input to the custom tool call."""
+ name: Required[str]
+ """The name of the custom tool to call."""
-class ItemContentPartsInputImage(TypedDict, total=False):
+ type: Required[Literal["custom_tool_call"]]
+ """The item type. Always `custom_tool_call`."""
+
+ id: Optional[str]
+ """The local Decision item ID."""
+
+ namespace: Optional[str]
+ """The namespace of the function to call."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]]
+
+
+class ItemCustomToolCallOutputOutputPartsInputImage(TypedDict, total=False):
image_url: Required[str]
- """An inline image encoded as a data URL."""
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
type: Required[Literal["input_image"]]
- """The type of the input item. Always `input_image`."""
detail: Optional[Literal["low", "high", "auto", "original"]]
"""The detail level of the image to be sent to the model.
@@ -36,20 +125,36 @@ class ItemContentPartsInputImage(TypedDict, total=False):
"""
-ItemContentParts: TypeAlias = Union[ItemContentPartsInputText, ItemContentPartsInputImage]
+ItemCustomToolCallOutputOutputParts: TypeAlias = Union[
+ DecisionInputTextParam, ItemCustomToolCallOutputOutputPartsInputImage
+]
+
+class ItemCustomToolCallOutput(TypedDict, total=False):
+ call_id: Required[str]
+ """The unique ID of the function tool call generated by the model."""
-class Item(TypedDict, total=False):
- content: Required[Union[str, Iterable[ItemContentParts]]]
+ output: Required[Union[str, Iterable[ItemCustomToolCallOutputOutputParts]]]
"""The text input to the model."""
- role: Required[Literal["user"]]
- """The message role. Always `user`."""
+ type: Required[Literal["custom_tool_call_output"]]
id: Optional[str]
- """The unique ID of this message item."""
+ """The local Decision item ID."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]]
- type: Literal["message"]
+
+ItemUnion: TypeAlias = Union[
+ DecisionUserMessageParam,
+ DecisionDeveloperMessageParam,
+ DecisionSystemMessageParam,
+ DecisionAssistantMessageParam,
+ ItemFunctionCall,
+ ItemFunctionCallOutput,
+ ItemCustomToolCall,
+ ItemCustomToolCallOutput,
+]
class DecisionItemCreateEventParam(TypedDict, total=False):
@@ -57,7 +162,7 @@ class DecisionItemCreateEventParam(TypedDict, total=False):
Append an input item for future decisions without starting an evaluation or changing Live voice context.
"""
- item: Required[Item]
+ item: Required[ItemUnion]
type: Required[Literal["decision.item.create"]]
diff --git a/src/openai/types/live/decision_item_created_event.py b/src/openai/types/live/decision_item_created_event.py
index 6cc5ccce25..eb5c4a12cf 100644
--- a/src/openai/types/live/decision_item_created_event.py
+++ b/src/openai/types/live/decision_item_created_event.py
@@ -5,30 +5,115 @@
from ..._utils import PropertyInfo
from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+from .decision_stored_user_message import (
+ ContentPart as ItemContentParts,
+ ContentPartInputText as ItemContentPartsInputText,
+ ContentPartInputImage as ItemContentPartsInputImage,
+ DecisionStoredUserMessage,
+ DecisionStoredUserMessage as Item,
+)
+from .decision_stored_system_message import DecisionStoredSystemMessage
+from .decision_stored_assistant_message import DecisionStoredAssistantMessage
+from .decision_stored_developer_message import DecisionStoredDeveloperMessage
__all__ = [
"DecisionItemCreatedEvent",
+ "ItemUnion",
+ "ItemFunctionCall",
+ "ItemFunctionCallOutput",
+ "ItemFunctionCallOutputOutputParts",
+ "ItemFunctionCallOutputOutputPartsInputImage",
+ "ItemCustomToolCall",
+ "ItemCustomToolCallOutput",
+ "ItemCustomToolCallOutputOutputParts",
+ "ItemCustomToolCallOutputOutputPartsInputImage",
"Item",
"ItemContentParts",
- "ItemContentPartsInputText",
"ItemContentPartsInputImage",
+ "ItemContentPartsInputText",
+]
+
+
+class ItemFunctionCall(BaseModel):
+ id: str
+
+ arguments: str
+ """The function arguments as a JSON string."""
+
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+
+ name: str
+
+ type: Literal["function_call"]
+ """The item type. Always `function_call`."""
+
+ namespace: Optional[str] = None
+ """The namespace of the function to call."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
+
+class ItemFunctionCallOutputOutputPartsInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+ItemFunctionCallOutputOutputParts: TypeAlias = Annotated[
+ Union[DecisionInputText, ItemFunctionCallOutputOutputPartsInputImage], PropertyInfo(discriminator="type")
]
-class ItemContentPartsInputText(BaseModel):
- text: str
+class ItemFunctionCallOutput(BaseModel):
+ id: str
+
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+
+ output: Union[str, List[ItemFunctionCallOutputOutputParts]]
"""The text input to the model."""
- type: Literal["input_text"]
- """The type of the input item. Always `input_text`."""
+ type: Literal["function_call_output"]
+ """The type of the function tool call output. Always `function_call_output`."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
+
+class ItemCustomToolCall(BaseModel):
+ id: str
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
-class ItemContentPartsInputImage(BaseModel):
+ input: str
+ """The input to the custom tool call."""
+
+ name: str
+ """The name of the custom tool to call."""
+
+ type: Literal["custom_tool_call"]
+ """The item type. Always `custom_tool_call`."""
+
+ namespace: Optional[str] = None
+ """The namespace of the function to call."""
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+
+
+class ItemCustomToolCallOutputOutputPartsInputImage(BaseModel):
image_url: str
- """An inline image encoded as a data URL."""
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
type: Literal["input_image"]
- """The type of the input item. Always `input_image`."""
detail: Optional[Literal["low", "high", "auto", "original"]] = None
"""The detail level of the image to be sent to the model.
@@ -37,22 +122,38 @@ class ItemContentPartsInputImage(BaseModel):
"""
-ItemContentParts: TypeAlias = Annotated[
- Union[ItemContentPartsInputText, ItemContentPartsInputImage], PropertyInfo(discriminator="type")
+ItemCustomToolCallOutputOutputParts: TypeAlias = Annotated[
+ Union[DecisionInputText, ItemCustomToolCallOutputOutputPartsInputImage], PropertyInfo(discriminator="type")
]
-class Item(BaseModel):
+class ItemCustomToolCallOutput(BaseModel):
id: str
- """The ID of the stored Decision input item."""
- content: Union[str, List[ItemContentParts]]
+ call_id: str
+ """The unique ID of the function tool call generated by the model."""
+
+ output: Union[str, List[ItemCustomToolCallOutputOutputParts]]
"""The text input to the model."""
- role: Literal["user"]
- """The message role. Always `user`."""
+ type: Literal["custom_tool_call_output"]
+
+ status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
- type: Optional[Literal["message"]] = None
+
+ItemUnion: TypeAlias = Annotated[
+ Union[
+ DecisionStoredUserMessage,
+ DecisionStoredDeveloperMessage,
+ DecisionStoredSystemMessage,
+ DecisionStoredAssistantMessage,
+ ItemFunctionCall,
+ ItemFunctionCallOutput,
+ ItemCustomToolCall,
+ ItemCustomToolCallOutput,
+ ],
+ PropertyInfo(discriminator="type"),
+]
class DecisionItemCreatedEvent(BaseModel):
@@ -61,7 +162,7 @@ class DecisionItemCreatedEvent(BaseModel):
event_id: str
"""The unique ID of the Live server event."""
- item: Item
+ item: ItemUnion
type: Literal["decision.item.created"]
diff --git a/src/openai/types/live/decision_json_object.py b/src/openai/types/live/decision_json_object.py
new file mode 100644
index 0000000000..f8cebe4934
--- /dev/null
+++ b/src/openai/types/live/decision_json_object.py
@@ -0,0 +1,8 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import Dict
+from typing_extensions import TypeAlias
+
+__all__ = ["DecisionJSONObject"]
+
+DecisionJSONObject: TypeAlias = Dict[str, object]
diff --git a/src/openai/types/live/decision_json_object_param.py b/src/openai/types/live/decision_json_object_param.py
new file mode 100644
index 0000000000..e594194870
--- /dev/null
+++ b/src/openai/types/live/decision_json_object_param.py
@@ -0,0 +1,10 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Dict
+from typing_extensions import TypeAlias
+
+__all__ = ["DecisionJSONObjectParam"]
+
+DecisionJSONObjectParam: TypeAlias = Dict[str, object]
diff --git a/src/openai/types/live/decision_question.py b/src/openai/types/live/decision_question.py
new file mode 100644
index 0000000000..b139b17229
--- /dev/null
+++ b/src/openai/types/live/decision_question.py
@@ -0,0 +1,139 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal, Annotated, TypeAlias
+
+from ..._utils import PropertyInfo
+from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+from .decision_json_object import DecisionJSONObject
+from .decision_choice_option import DecisionChoiceOption
+
+__all__ = [
+ "DecisionQuestion",
+ "Choice",
+ "ChoiceInstructionsParts",
+ "ChoiceInstructionsPartsInputImage",
+ "ChoiceInstructionsPartsInputJSON",
+ "Predicate",
+ "PredicateInstructionsParts",
+ "PredicateInstructionsPartsInputImage",
+ "PredicateInstructionsPartsInputJSON",
+ "Score",
+ "ScoreInstructionsParts",
+ "ScoreInstructionsPartsInputImage",
+ "ScoreInstructionsPartsInputJSON",
+ "ScoreLevel",
+]
+
+
+class ChoiceInstructionsPartsInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ChoiceInstructionsPartsInputJSON(BaseModel):
+ data: Union[List[DecisionJSONObject], DecisionJSONObject]
+
+ type: Literal["input_json"]
+
+
+ChoiceInstructionsParts: TypeAlias = Annotated[
+ Union[DecisionInputText, ChoiceInstructionsPartsInputImage, ChoiceInstructionsPartsInputJSON],
+ PropertyInfo(discriminator="type"),
+]
+
+
+class Choice(BaseModel):
+ choices: List[DecisionChoiceOption]
+
+ instructions: Union[str, List[ChoiceInstructionsParts]]
+
+ type: Literal["choice"]
+
+ name: Optional[str] = None
+
+
+class PredicateInstructionsPartsInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class PredicateInstructionsPartsInputJSON(BaseModel):
+ data: Union[List[DecisionJSONObject], DecisionJSONObject]
+
+ type: Literal["input_json"]
+
+
+PredicateInstructionsParts: TypeAlias = Annotated[
+ Union[DecisionInputText, PredicateInstructionsPartsInputImage, PredicateInstructionsPartsInputJSON],
+ PropertyInfo(discriminator="type"),
+]
+
+
+class Predicate(BaseModel):
+ instructions: Union[str, List[PredicateInstructionsParts]]
+
+ type: Literal["predicate"]
+
+ name: Optional[str] = None
+
+
+class ScoreInstructionsPartsInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ScoreInstructionsPartsInputJSON(BaseModel):
+ data: Union[List[DecisionJSONObject], DecisionJSONObject]
+
+ type: Literal["input_json"]
+
+
+ScoreInstructionsParts: TypeAlias = Annotated[
+ Union[DecisionInputText, ScoreInstructionsPartsInputImage, ScoreInstructionsPartsInputJSON],
+ PropertyInfo(discriminator="type"),
+]
+
+
+class ScoreLevel(BaseModel):
+ label: str
+
+ description: Optional[str] = None
+
+
+class Score(BaseModel):
+ instructions: Union[str, List[ScoreInstructionsParts]]
+
+ levels: List[ScoreLevel]
+
+ type: Literal["score"]
+
+ name: Optional[str] = None
+
+
+DecisionQuestion: TypeAlias = Annotated[Union[Choice, Predicate, Score], PropertyInfo(discriminator="type")]
diff --git a/src/openai/types/live/decision_question_param.py b/src/openai/types/live/decision_question_param.py
new file mode 100644
index 0000000000..976e9bda50
--- /dev/null
+++ b/src/openai/types/live/decision_question_param.py
@@ -0,0 +1,136 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union, Iterable, Optional
+from typing_extensions import Literal, Required, TypeAlias, TypedDict
+
+from .decision_json_object import DecisionJSONObject
+from .decision_input_text_param import DecisionInputTextParam
+from .decision_choice_option_param import DecisionChoiceOptionParam
+
+__all__ = [
+ "DecisionQuestionParam",
+ "Choice",
+ "ChoiceInstructionsParts",
+ "ChoiceInstructionsPartsInputImage",
+ "ChoiceInstructionsPartsInputJSON",
+ "Predicate",
+ "PredicateInstructionsParts",
+ "PredicateInstructionsPartsInputImage",
+ "PredicateInstructionsPartsInputJSON",
+ "Score",
+ "ScoreInstructionsParts",
+ "ScoreInstructionsPartsInputImage",
+ "ScoreInstructionsPartsInputJSON",
+ "ScoreLevel",
+]
+
+
+class ChoiceInstructionsPartsInputImage(TypedDict, total=False):
+ image_url: Required[str]
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Required[Literal["input_image"]]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]]
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ChoiceInstructionsPartsInputJSON(TypedDict, total=False):
+ data: Required[Union[DecisionJSONObject, Iterable[DecisionJSONObject]]]
+
+ type: Required[Literal["input_json"]]
+
+
+ChoiceInstructionsParts: TypeAlias = Union[
+ DecisionInputTextParam, ChoiceInstructionsPartsInputImage, ChoiceInstructionsPartsInputJSON
+]
+
+
+class Choice(TypedDict, total=False):
+ choices: Required[Iterable[DecisionChoiceOptionParam]]
+
+ instructions: Required[Union[str, Iterable[ChoiceInstructionsParts]]]
+
+ type: Required[Literal["choice"]]
+
+ name: str
+
+
+class PredicateInstructionsPartsInputImage(TypedDict, total=False):
+ image_url: Required[str]
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Required[Literal["input_image"]]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]]
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class PredicateInstructionsPartsInputJSON(TypedDict, total=False):
+ data: Required[Union[DecisionJSONObject, Iterable[DecisionJSONObject]]]
+
+ type: Required[Literal["input_json"]]
+
+
+PredicateInstructionsParts: TypeAlias = Union[
+ DecisionInputTextParam, PredicateInstructionsPartsInputImage, PredicateInstructionsPartsInputJSON
+]
+
+
+class Predicate(TypedDict, total=False):
+ instructions: Required[Union[str, Iterable[PredicateInstructionsParts]]]
+
+ type: Required[Literal["predicate"]]
+
+ name: str
+
+
+class ScoreInstructionsPartsInputImage(TypedDict, total=False):
+ image_url: Required[str]
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Required[Literal["input_image"]]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]]
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ScoreInstructionsPartsInputJSON(TypedDict, total=False):
+ data: Required[Union[DecisionJSONObject, Iterable[DecisionJSONObject]]]
+
+ type: Required[Literal["input_json"]]
+
+
+ScoreInstructionsParts: TypeAlias = Union[
+ DecisionInputTextParam, ScoreInstructionsPartsInputImage, ScoreInstructionsPartsInputJSON
+]
+
+
+class ScoreLevel(TypedDict, total=False):
+ label: Required[str]
+
+ description: str
+
+
+class Score(TypedDict, total=False):
+ instructions: Required[Union[str, Iterable[ScoreInstructionsParts]]]
+
+ levels: Required[Iterable[ScoreLevel]]
+
+ type: Required[Literal["score"]]
+
+ name: str
+
+
+DecisionQuestionParam: TypeAlias = Union[Choice, Predicate, Score]
diff --git a/src/openai/types/live/decision_stored_assistant_message.py b/src/openai/types/live/decision_stored_assistant_message.py
new file mode 100644
index 0000000000..ffb8f90740
--- /dev/null
+++ b/src/openai/types/live/decision_stored_assistant_message.py
@@ -0,0 +1,45 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal, Annotated, TypeAlias
+
+from ..._utils import PropertyInfo
+from ..._models import BaseModel
+
+__all__ = ["DecisionStoredAssistantMessage", "ContentPart", "ContentPartOutputText", "ContentPartRefusal"]
+
+
+class ContentPartOutputText(BaseModel):
+ text: str
+ """The text content."""
+
+ type: Literal["output_text"]
+
+
+class ContentPartRefusal(BaseModel):
+ refusal: str
+ """The refusal text."""
+
+ type: Literal["refusal"]
+
+
+ContentPart: TypeAlias = Annotated[Union[ContentPartOutputText, ContentPartRefusal], PropertyInfo(discriminator="type")]
+
+
+class DecisionStoredAssistantMessage(BaseModel):
+ id: str
+
+ content: Union[str, List[ContentPart]]
+ """The text input to the model."""
+
+ role: Literal["assistant"]
+
+ phase: Optional[Literal["commentary", "final_answer"]] = None
+ """
+ Labels an `assistant` message as intermediate commentary (`commentary`) or the
+ final answer (`final_answer`). For models like `gpt-5.3-codex` and beyond, when
+ sending follow-up requests, preserve and resend phase on all assistant messages
+ — dropping it can degrade performance. Not used for user messages.
+ """
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_stored_developer_message.py b/src/openai/types/live/decision_stored_developer_message.py
new file mode 100644
index 0000000000..93ce5fdf05
--- /dev/null
+++ b/src/openai/types/live/decision_stored_developer_message.py
@@ -0,0 +1,20 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+
+__all__ = ["DecisionStoredDeveloperMessage"]
+
+
+class DecisionStoredDeveloperMessage(BaseModel):
+ id: str
+
+ content: Union[str, List[DecisionInputText]]
+ """The text input to the model."""
+
+ role: Literal["developer"]
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_stored_system_message.py b/src/openai/types/live/decision_stored_system_message.py
new file mode 100644
index 0000000000..6f3dbaa890
--- /dev/null
+++ b/src/openai/types/live/decision_stored_system_message.py
@@ -0,0 +1,20 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+
+__all__ = ["DecisionStoredSystemMessage"]
+
+
+class DecisionStoredSystemMessage(BaseModel):
+ id: str
+
+ content: Union[str, List[DecisionInputText]]
+ """The text input to the model."""
+
+ role: Literal["system"]
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_stored_user_message.py b/src/openai/types/live/decision_stored_user_message.py
new file mode 100644
index 0000000000..361627e685
--- /dev/null
+++ b/src/openai/types/live/decision_stored_user_message.py
@@ -0,0 +1,59 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal, Annotated, TypeAlias
+
+from ..._utils import PropertyInfo
+from ..._models import BaseModel
+from .decision_json_object import DecisionJSONObject
+
+__all__ = [
+ "DecisionStoredUserMessage",
+ "ContentPart",
+ "ContentPartInputText",
+ "ContentPartInputImage",
+ "ContentPartInputJSON",
+]
+
+
+class ContentPartInputText(BaseModel):
+ text: str
+ """The text input to the model."""
+
+ type: Literal["input_text"]
+
+
+class ContentPartInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ContentPartInputJSON(BaseModel):
+ data: Union[List[DecisionJSONObject], DecisionJSONObject]
+
+ type: Literal["input_json"]
+
+
+ContentPart: TypeAlias = Annotated[
+ Union[ContentPartInputText, ContentPartInputImage, ContentPartInputJSON], PropertyInfo(discriminator="type")
+]
+
+
+class DecisionStoredUserMessage(BaseModel):
+ id: str
+
+ content: Union[str, List[ContentPart]]
+ """The text input to the model."""
+
+ role: Literal["user"]
+ """The message role. Always `user`."""
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_system_message.py b/src/openai/types/live/decision_system_message.py
new file mode 100644
index 0000000000..591c77434a
--- /dev/null
+++ b/src/openai/types/live/decision_system_message.py
@@ -0,0 +1,21 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+from .decision_input_text import DecisionInputText
+
+__all__ = ["DecisionSystemMessage"]
+
+
+class DecisionSystemMessage(BaseModel):
+ content: Union[str, List[DecisionInputText]]
+ """The text input to the model."""
+
+ role: Literal["system"]
+
+ id: Optional[str] = None
+ """The unique ID of this message item."""
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_system_message_param.py b/src/openai/types/live/decision_system_message_param.py
new file mode 100644
index 0000000000..767d4b78c0
--- /dev/null
+++ b/src/openai/types/live/decision_system_message_param.py
@@ -0,0 +1,22 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union, Iterable, Optional
+from typing_extensions import Literal, Required, TypedDict
+
+from .decision_input_text_param import DecisionInputTextParam
+
+__all__ = ["DecisionSystemMessageParam"]
+
+
+class DecisionSystemMessageParam(TypedDict, total=False):
+ content: Required[Union[str, Iterable[DecisionInputTextParam]]]
+ """The text input to the model."""
+
+ role: Required[Literal["system"]]
+
+ id: Optional[str]
+ """The unique ID of this message item."""
+
+ type: Literal["message"]
diff --git a/src/openai/types/live/decision_trigger.py b/src/openai/types/live/decision_trigger.py
index 4f53abe79e..d4cc353c8f 100644
--- a/src/openai/types/live/decision_trigger.py
+++ b/src/openai/types/live/decision_trigger.py
@@ -1,86 +1,28 @@
# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
-from typing import List, Union, Optional
-from typing_extensions import Literal, Annotated, TypeAlias
+from typing import List
+from typing_extensions import Literal
-from pydantic import StrictStr, StrictBool
-
-from ..._utils import PropertyInfo
from ..._models import BaseModel
-from ..shared.decision_question_input_part import DecisionQuestionInputPart
+from .decision_question import (
+ Score as DecisionsQuestionQuestionParamScore,
+ Choice as DecisionsQuestionQuestionParamChoice,
+ Predicate as DecisionsQuestionQuestionParamPredicate,
+ ScoreLevel as DecisionsQuestionQuestionParamScoreLevel,
+ DecisionQuestion,
+ DecisionQuestion as DecisionsQuestion,
+)
+from .decision_choice_option import DecisionChoiceOption as DecisionsQuestionQuestionParamChoiceChoice
__all__ = [
"DecisionTrigger",
"Decisions",
"DecisionsQuestion",
- "DecisionsQuestionQuestionParamPredicate",
"DecisionsQuestionQuestionParamChoice",
- "DecisionsQuestionQuestionParamChoiceChoice",
+ "DecisionsQuestionQuestionParamPredicate",
"DecisionsQuestionQuestionParamScore",
"DecisionsQuestionQuestionParamScoreLevel",
-]
-
-
-class DecisionsQuestionQuestionParamPredicate(BaseModel):
- """Estimate how likely it is that a statement about the input is true."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- type: Literal["predicate"]
- """The type of the object. Always `predicate`."""
-
- name: Optional[str] = None
-
-
-class DecisionsQuestionQuestionParamChoiceChoice(BaseModel):
- value: Union[StrictStr, StrictBool]
- """
- Choice values are typed: a string and a boolean with the same text are distinct.
- """
-
- description: Optional[str] = None
-
-
-class DecisionsQuestionQuestionParamChoice(BaseModel):
- """Choose from the supplied options based on the input."""
-
- choices: List[DecisionsQuestionQuestionParamChoiceChoice]
- """Provide between 2 and 255 choices. Each choice must be unique."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- type: Literal["choice"]
- """The type of the object. Always `choice`."""
-
- name: Optional[str] = None
-
-
-class DecisionsQuestionQuestionParamScoreLevel(BaseModel):
- label: str
-
- description: Optional[str] = None
-
-
-class DecisionsQuestionQuestionParamScore(BaseModel):
- """Rate the input against the supplied ordered levels."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- levels: List[DecisionsQuestionQuestionParamScoreLevel]
-
- type: Literal["score"]
- """The type of the object. Always `score`."""
-
- name: Optional[str] = None
-
-
-DecisionsQuestion: TypeAlias = Annotated[
- Union[
- DecisionsQuestionQuestionParamPredicate,
- DecisionsQuestionQuestionParamChoice,
- DecisionsQuestionQuestionParamScore,
- ],
- PropertyInfo(discriminator="type"),
+ "DecisionsQuestionQuestionParamChoiceChoice",
]
@@ -89,7 +31,7 @@ class Decisions(BaseModel):
Questions evaluated using the current transcript and the session's shared Decision items.
"""
- questions: List[DecisionsQuestion]
+ questions: List[DecisionQuestion]
"""Native Decision API questions evaluated together, in order."""
diff --git a/src/openai/types/live/decision_trigger_param.py b/src/openai/types/live/decision_trigger_param.py
index bc68a9099c..b78bb58024 100644
--- a/src/openai/types/live/decision_trigger_param.py
+++ b/src/openai/types/live/decision_trigger_param.py
@@ -2,78 +2,28 @@
from __future__ import annotations
-from typing import Union, Iterable
-from typing_extensions import Literal, Required, TypeAlias, TypedDict
-
-from ..shared_params.decision_question_input_part import DecisionQuestionInputPart
+from typing import Iterable
+from typing_extensions import Literal, Required, TypedDict
+
+from .decision_question_param import (
+ Score as DecisionsQuestionQuestionParamScore,
+ Choice as DecisionsQuestionQuestionParamChoice,
+ Predicate as DecisionsQuestionQuestionParamPredicate,
+ ScoreLevel as DecisionsQuestionQuestionParamScoreLevel,
+ DecisionQuestionParam,
+ DecisionQuestionParam as DecisionsQuestion,
+)
+from .decision_choice_option_param import DecisionChoiceOptionParam as DecisionsQuestionQuestionParamChoiceChoice
__all__ = [
"DecisionTriggerParam",
"Decisions",
"DecisionsQuestion",
- "DecisionsQuestionQuestionParamPredicate",
"DecisionsQuestionQuestionParamChoice",
- "DecisionsQuestionQuestionParamChoiceChoice",
+ "DecisionsQuestionQuestionParamPredicate",
"DecisionsQuestionQuestionParamScore",
"DecisionsQuestionQuestionParamScoreLevel",
-]
-
-
-class DecisionsQuestionQuestionParamPredicate(TypedDict, total=False):
- """Estimate how likely it is that a statement about the input is true."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- type: Required[Literal["predicate"]]
- """The type of the object. Always `predicate`."""
-
- name: str
-
-
-class DecisionsQuestionQuestionParamChoiceChoice(TypedDict, total=False):
- value: Required[Union[str, bool]]
- """
- Choice values are typed: a string and a boolean with the same text are distinct.
- """
-
- description: str
-
-
-class DecisionsQuestionQuestionParamChoice(TypedDict, total=False):
- """Choose from the supplied options based on the input."""
-
- choices: Required[Iterable[DecisionsQuestionQuestionParamChoiceChoice]]
- """Provide between 2 and 255 choices. Each choice must be unique."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- type: Required[Literal["choice"]]
- """The type of the object. Always `choice`."""
-
- name: str
-
-
-class DecisionsQuestionQuestionParamScoreLevel(TypedDict, total=False):
- label: Required[str]
-
- description: str
-
-
-class DecisionsQuestionQuestionParamScore(TypedDict, total=False):
- """Rate the input against the supplied ordered levels."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- levels: Required[Iterable[DecisionsQuestionQuestionParamScoreLevel]]
-
- type: Required[Literal["score"]]
- """The type of the object. Always `score`."""
-
- name: str
-
-
-DecisionsQuestion: TypeAlias = Union[
- DecisionsQuestionQuestionParamPredicate, DecisionsQuestionQuestionParamChoice, DecisionsQuestionQuestionParamScore
+ "DecisionsQuestionQuestionParamChoiceChoice",
]
@@ -82,7 +32,7 @@ class Decisions(TypedDict, total=False):
Questions evaluated using the current transcript and the session's shared Decision items.
"""
- questions: Required[Iterable[DecisionsQuestion]]
+ questions: Required[Iterable[DecisionQuestionParam]]
"""Native Decision API questions evaluated together, in order."""
diff --git a/src/openai/types/live/decision_user_message.py b/src/openai/types/live/decision_user_message.py
new file mode 100644
index 0000000000..9c4b28966f
--- /dev/null
+++ b/src/openai/types/live/decision_user_message.py
@@ -0,0 +1,60 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from typing import List, Union, Optional
+from typing_extensions import Literal, Annotated, TypeAlias
+
+from ..._utils import PropertyInfo
+from ..._models import BaseModel
+from .decision_json_object import DecisionJSONObject
+
+__all__ = [
+ "DecisionUserMessage",
+ "ContentPart",
+ "ContentPartInputText",
+ "ContentPartInputImage",
+ "ContentPartInputJSON",
+]
+
+
+class ContentPartInputText(BaseModel):
+ text: str
+ """The text input to the model."""
+
+ type: Literal["input_text"]
+
+
+class ContentPartInputImage(BaseModel):
+ image_url: str
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Literal["input_image"]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]] = None
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ContentPartInputJSON(BaseModel):
+ data: Union[List[DecisionJSONObject], DecisionJSONObject]
+
+ type: Literal["input_json"]
+
+
+ContentPart: TypeAlias = Annotated[
+ Union[ContentPartInputText, ContentPartInputImage, ContentPartInputJSON], PropertyInfo(discriminator="type")
+]
+
+
+class DecisionUserMessage(BaseModel):
+ content: Union[str, List[ContentPart]]
+ """The text input to the model."""
+
+ role: Literal["user"]
+ """The message role. Always `user`."""
+
+ id: Optional[str] = None
+ """The unique ID of this message item."""
+
+ type: Optional[Literal["message"]] = None
diff --git a/src/openai/types/live/decision_user_message_param.py b/src/openai/types/live/decision_user_message_param.py
new file mode 100644
index 0000000000..b25358b445
--- /dev/null
+++ b/src/openai/types/live/decision_user_message_param.py
@@ -0,0 +1,58 @@
+# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union, Iterable, Optional
+from typing_extensions import Literal, Required, TypeAlias, TypedDict
+
+from .decision_json_object import DecisionJSONObject
+
+__all__ = [
+ "DecisionUserMessageParam",
+ "ContentPart",
+ "ContentPartInputText",
+ "ContentPartInputImage",
+ "ContentPartInputJSON",
+]
+
+
+class ContentPartInputText(TypedDict, total=False):
+ text: Required[str]
+ """The text input to the model."""
+
+ type: Required[Literal["input_text"]]
+
+
+class ContentPartInputImage(TypedDict, total=False):
+ image_url: Required[str]
+ """A base64-encoded image data URL or a publicly accessible HTTP(S) image URL."""
+
+ type: Required[Literal["input_image"]]
+
+ detail: Optional[Literal["low", "high", "auto", "original"]]
+ """The detail level of the image to be sent to the model.
+
+ One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
+ """
+
+
+class ContentPartInputJSON(TypedDict, total=False):
+ data: Required[Union[DecisionJSONObject, Iterable[DecisionJSONObject]]]
+
+ type: Required[Literal["input_json"]]
+
+
+ContentPart: TypeAlias = Union[ContentPartInputText, ContentPartInputImage, ContentPartInputJSON]
+
+
+class DecisionUserMessageParam(TypedDict, total=False):
+ content: Required[Union[str, Iterable[ContentPart]]]
+ """The text input to the model."""
+
+ role: Required[Literal["user"]]
+ """The message role. Always `user`."""
+
+ id: Optional[str]
+ """The unique ID of this message item."""
+
+ type: Literal["message"]
diff --git a/src/openai/types/live/decisions_delegation_config.py b/src/openai/types/live/decisions_delegation_config.py
index 23ec5d4a8a..51f97c0dcf 100644
--- a/src/openai/types/live/decisions_delegation_config.py
+++ b/src/openai/types/live/decisions_delegation_config.py
@@ -1,86 +1,31 @@
# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
-from typing import List, Union, Optional
-from typing_extensions import Literal, Annotated, TypeAlias
+from typing import List
-from pydantic import StrictStr, StrictBool
-
-from ..._utils import PropertyInfo
from ..._models import BaseModel
-from ..shared.decision_question_input_part import DecisionQuestionInputPart
+from .decision_question import (
+ Score as QuestionQuestionParamScore,
+ Choice as QuestionQuestionParamChoice,
+ Predicate as QuestionQuestionParamPredicate,
+ ScoreLevel as QuestionQuestionParamScoreLevel,
+ DecisionQuestion,
+ DecisionQuestion as Question,
+)
+from .decision_choice_option import DecisionChoiceOption as QuestionQuestionParamChoiceChoice
__all__ = [
"DecisionsDelegationConfig",
"Question",
- "QuestionQuestionParamPredicate",
"QuestionQuestionParamChoice",
- "QuestionQuestionParamChoiceChoice",
+ "QuestionQuestionParamPredicate",
"QuestionQuestionParamScore",
"QuestionQuestionParamScoreLevel",
-]
-
-
-class QuestionQuestionParamPredicate(BaseModel):
- """Estimate how likely it is that a statement about the input is true."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- type: Literal["predicate"]
- """The type of the object. Always `predicate`."""
-
- name: Optional[str] = None
-
-
-class QuestionQuestionParamChoiceChoice(BaseModel):
- value: Union[StrictStr, StrictBool]
- """
- Choice values are typed: a string and a boolean with the same text are distinct.
- """
-
- description: Optional[str] = None
-
-
-class QuestionQuestionParamChoice(BaseModel):
- """Choose from the supplied options based on the input."""
-
- choices: List[QuestionQuestionParamChoiceChoice]
- """Provide between 2 and 255 choices. Each choice must be unique."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- type: Literal["choice"]
- """The type of the object. Always `choice`."""
-
- name: Optional[str] = None
-
-
-class QuestionQuestionParamScoreLevel(BaseModel):
- label: str
-
- description: Optional[str] = None
-
-
-class QuestionQuestionParamScore(BaseModel):
- """Rate the input against the supplied ordered levels."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- levels: List[QuestionQuestionParamScoreLevel]
-
- type: Literal["score"]
- """The type of the object. Always `score`."""
-
- name: Optional[str] = None
-
-
-Question: TypeAlias = Annotated[
- Union[QuestionQuestionParamPredicate, QuestionQuestionParamChoice, QuestionQuestionParamScore],
- PropertyInfo(discriminator="type"),
+ "QuestionQuestionParamChoiceChoice",
]
class DecisionsDelegationConfig(BaseModel):
model: str
- questions: List[Question]
+ questions: List[DecisionQuestion]
"""Native Decision API questions evaluated together, in order."""
diff --git a/src/openai/types/live/decisions_delegation_config_param.py b/src/openai/types/live/decisions_delegation_config_param.py
index 5759afad9b..e46fe25b55 100644
--- a/src/openai/types/live/decisions_delegation_config_param.py
+++ b/src/openai/types/live/decisions_delegation_config_param.py
@@ -2,80 +2,32 @@
from __future__ import annotations
-from typing import Union, Iterable
-from typing_extensions import Literal, Required, TypeAlias, TypedDict
-
-from ..shared_params.decision_question_input_part import DecisionQuestionInputPart
+from typing import Iterable
+from typing_extensions import Required, TypedDict
+
+from .decision_question_param import (
+ Score as QuestionQuestionParamScore,
+ Choice as QuestionQuestionParamChoice,
+ Predicate as QuestionQuestionParamPredicate,
+ ScoreLevel as QuestionQuestionParamScoreLevel,
+ DecisionQuestionParam,
+ DecisionQuestionParam as Question,
+)
+from .decision_choice_option_param import DecisionChoiceOptionParam as QuestionQuestionParamChoiceChoice
__all__ = [
"DecisionsDelegationConfigParam",
"Question",
- "QuestionQuestionParamPredicate",
"QuestionQuestionParamChoice",
- "QuestionQuestionParamChoiceChoice",
+ "QuestionQuestionParamPredicate",
"QuestionQuestionParamScore",
"QuestionQuestionParamScoreLevel",
+ "QuestionQuestionParamChoiceChoice",
]
-class QuestionQuestionParamPredicate(TypedDict, total=False):
- """Estimate how likely it is that a statement about the input is true."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- type: Required[Literal["predicate"]]
- """The type of the object. Always `predicate`."""
-
- name: str
-
-
-class QuestionQuestionParamChoiceChoice(TypedDict, total=False):
- value: Required[Union[str, bool]]
- """
- Choice values are typed: a string and a boolean with the same text are distinct.
- """
-
- description: str
-
-
-class QuestionQuestionParamChoice(TypedDict, total=False):
- """Choose from the supplied options based on the input."""
-
- choices: Required[Iterable[QuestionQuestionParamChoiceChoice]]
- """Provide between 2 and 255 choices. Each choice must be unique."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- type: Required[Literal["choice"]]
- """The type of the object. Always `choice`."""
-
- name: str
-
-
-class QuestionQuestionParamScoreLevel(TypedDict, total=False):
- label: Required[str]
-
- description: str
-
-
-class QuestionQuestionParamScore(TypedDict, total=False):
- """Rate the input against the supplied ordered levels."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- levels: Required[Iterable[QuestionQuestionParamScoreLevel]]
-
- type: Required[Literal["score"]]
- """The type of the object. Always `score`."""
-
- name: str
-
-
-Question: TypeAlias = Union[QuestionQuestionParamPredicate, QuestionQuestionParamChoice, QuestionQuestionParamScore]
-
-
class DecisionsDelegationConfigParam(TypedDict, total=False):
model: Required[str]
- questions: Required[Iterable[Question]]
+ questions: Required[Iterable[DecisionQuestionParam]]
"""Native Decision API questions evaluated together, in order."""
diff --git a/src/openai/types/live/decisions_delegation_update_config.py b/src/openai/types/live/decisions_delegation_update_config.py
index 483e192d2c..44b7c44fa5 100644
--- a/src/openai/types/live/decisions_delegation_update_config.py
+++ b/src/openai/types/live/decisions_delegation_update_config.py
@@ -1,86 +1,31 @@
# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
-from typing import List, Union, Optional
-from typing_extensions import Literal, Annotated, TypeAlias
+from typing import List, Optional
-from pydantic import StrictStr, StrictBool
-
-from ..._utils import PropertyInfo
from ..._models import BaseModel
-from ..shared.decision_question_input_part import DecisionQuestionInputPart
+from .decision_question import (
+ Score as QuestionQuestionParamScore,
+ Choice as QuestionQuestionParamChoice,
+ Predicate as QuestionQuestionParamPredicate,
+ ScoreLevel as QuestionQuestionParamScoreLevel,
+ DecisionQuestion,
+ DecisionQuestion as Question,
+)
+from .decision_choice_option import DecisionChoiceOption as QuestionQuestionParamChoiceChoice
__all__ = [
"DecisionsDelegationUpdateConfig",
"Question",
- "QuestionQuestionParamPredicate",
"QuestionQuestionParamChoice",
- "QuestionQuestionParamChoiceChoice",
+ "QuestionQuestionParamPredicate",
"QuestionQuestionParamScore",
"QuestionQuestionParamScoreLevel",
-]
-
-
-class QuestionQuestionParamPredicate(BaseModel):
- """Estimate how likely it is that a statement about the input is true."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- type: Literal["predicate"]
- """The type of the object. Always `predicate`."""
-
- name: Optional[str] = None
-
-
-class QuestionQuestionParamChoiceChoice(BaseModel):
- value: Union[StrictStr, StrictBool]
- """
- Choice values are typed: a string and a boolean with the same text are distinct.
- """
-
- description: Optional[str] = None
-
-
-class QuestionQuestionParamChoice(BaseModel):
- """Choose from the supplied options based on the input."""
-
- choices: List[QuestionQuestionParamChoiceChoice]
- """Provide between 2 and 255 choices. Each choice must be unique."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- type: Literal["choice"]
- """The type of the object. Always `choice`."""
-
- name: Optional[str] = None
-
-
-class QuestionQuestionParamScoreLevel(BaseModel):
- label: str
-
- description: Optional[str] = None
-
-
-class QuestionQuestionParamScore(BaseModel):
- """Rate the input against the supplied ordered levels."""
-
- instructions: Union[str, List[DecisionQuestionInputPart]]
-
- levels: List[QuestionQuestionParamScoreLevel]
-
- type: Literal["score"]
- """The type of the object. Always `score`."""
-
- name: Optional[str] = None
-
-
-Question: TypeAlias = Annotated[
- Union[QuestionQuestionParamPredicate, QuestionQuestionParamChoice, QuestionQuestionParamScore],
- PropertyInfo(discriminator="type"),
+ "QuestionQuestionParamChoiceChoice",
]
class DecisionsDelegationUpdateConfig(BaseModel):
model: Optional[str] = None
- questions: Optional[List[Question]] = None
+ questions: Optional[List[DecisionQuestion]] = None
"""Native Decision API questions evaluated together, in order."""
diff --git a/src/openai/types/live/decisions_delegation_update_config_param.py b/src/openai/types/live/decisions_delegation_update_config_param.py
index 564f5b3cd4..557e871717 100644
--- a/src/openai/types/live/decisions_delegation_update_config_param.py
+++ b/src/openai/types/live/decisions_delegation_update_config_param.py
@@ -2,80 +2,32 @@
from __future__ import annotations
-from typing import Union, Iterable
-from typing_extensions import Literal, Required, TypeAlias, TypedDict
-
-from ..shared_params.decision_question_input_part import DecisionQuestionInputPart
+from typing import Iterable
+from typing_extensions import TypedDict
+
+from .decision_question_param import (
+ Score as QuestionQuestionParamScore,
+ Choice as QuestionQuestionParamChoice,
+ Predicate as QuestionQuestionParamPredicate,
+ ScoreLevel as QuestionQuestionParamScoreLevel,
+ DecisionQuestionParam,
+ DecisionQuestionParam as Question,
+)
+from .decision_choice_option_param import DecisionChoiceOptionParam as QuestionQuestionParamChoiceChoice
__all__ = [
"DecisionsDelegationUpdateConfigParam",
"Question",
- "QuestionQuestionParamPredicate",
"QuestionQuestionParamChoice",
- "QuestionQuestionParamChoiceChoice",
+ "QuestionQuestionParamPredicate",
"QuestionQuestionParamScore",
"QuestionQuestionParamScoreLevel",
+ "QuestionQuestionParamChoiceChoice",
]
-class QuestionQuestionParamPredicate(TypedDict, total=False):
- """Estimate how likely it is that a statement about the input is true."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- type: Required[Literal["predicate"]]
- """The type of the object. Always `predicate`."""
-
- name: str
-
-
-class QuestionQuestionParamChoiceChoice(TypedDict, total=False):
- value: Required[Union[str, bool]]
- """
- Choice values are typed: a string and a boolean with the same text are distinct.
- """
-
- description: str
-
-
-class QuestionQuestionParamChoice(TypedDict, total=False):
- """Choose from the supplied options based on the input."""
-
- choices: Required[Iterable[QuestionQuestionParamChoiceChoice]]
- """Provide between 2 and 255 choices. Each choice must be unique."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- type: Required[Literal["choice"]]
- """The type of the object. Always `choice`."""
-
- name: str
-
-
-class QuestionQuestionParamScoreLevel(TypedDict, total=False):
- label: Required[str]
-
- description: str
-
-
-class QuestionQuestionParamScore(TypedDict, total=False):
- """Rate the input against the supplied ordered levels."""
-
- instructions: Required[Union[str, Iterable[DecisionQuestionInputPart]]]
-
- levels: Required[Iterable[QuestionQuestionParamScoreLevel]]
-
- type: Required[Literal["score"]]
- """The type of the object. Always `score`."""
-
- name: str
-
-
-Question: TypeAlias = Union[QuestionQuestionParamPredicate, QuestionQuestionParamChoice, QuestionQuestionParamScore]
-
-
class DecisionsDelegationUpdateConfigParam(TypedDict, total=False):
model: str
- questions: Iterable[Question]
+ questions: Iterable[DecisionQuestionParam]
"""Native Decision API questions evaluated together, in order."""
diff --git a/src/openai/types/responses/response_tool_search_output_item_param.py b/src/openai/types/responses/response_tool_search_output_item_param.py
index 3e2bd10e66..735e669886 100644
--- a/src/openai/types/responses/response_tool_search_output_item_param.py
+++ b/src/openai/types/responses/response_tool_search_output_item_param.py
@@ -311,11 +311,14 @@ class ToolImageGeneration(BaseModel):
] = None
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Optional[Literal["auto", "low"]] = None
diff --git a/src/openai/types/responses/response_tool_search_output_item_param_param.py b/src/openai/types/responses/response_tool_search_output_item_param_param.py
index a13f6f4b2f..3397eb752d 100644
--- a/src/openai/types/responses/response_tool_search_output_item_param_param.py
+++ b/src/openai/types/responses/response_tool_search_output_item_param_param.py
@@ -309,11 +309,14 @@ class ToolImageGeneration(TypedDict, total=False):
]
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Literal["auto", "low"]
diff --git a/src/openai/types/responses/tool.py b/src/openai/types/responses/tool.py
index 497756bd3c..8837f5208a 100644
--- a/src/openai/types/responses/tool.py
+++ b/src/openai/types/responses/tool.py
@@ -315,11 +315,14 @@ class ImageGeneration(BaseModel):
] = None
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Optional[Literal["auto", "low"]] = None
diff --git a/src/openai/types/responses/tool_param.py b/src/openai/types/responses/tool_param.py
index 0f49f86883..d6df2e51f9 100644
--- a/src/openai/types/responses/tool_param.py
+++ b/src/openai/types/responses/tool_param.py
@@ -5,7 +5,6 @@
from typing import Dict, List, Union, Optional
from typing_extensions import Literal, Required, TypeAlias, TypedDict
-from ..chat import ChatCompletionFunctionToolParam
from ..._types import SequenceNotStr
from .custom_tool_param import CustomToolParam
from .computer_tool_param import ComputerToolParam
@@ -25,6 +24,7 @@
from .computer_use_preview_tool_param import ComputerUsePreviewToolParam
from .container_network_policy_disabled_param import ContainerNetworkPolicyDisabledParam
from .container_network_policy_allowlist_param import ContainerNetworkPolicyAllowlistParam
+from ..chat.chat_completion_function_tool_param import ChatCompletionFunctionToolParam
__all__ = [
"ToolParam",
@@ -314,11 +314,14 @@ class ImageGeneration(TypedDict, total=False):
]
"""The image generation model to use.
- One of `gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`,
+ One of `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`, or `chatgpt-image-latest`. Default:
- `gpt-image-1`.
+ `gpt-image-2`.
+
+ `gpt-image-1` was shut down on October 23, 2026. Use `gpt-image-2.5-sunburst` or
+ `gpt-image-2.5-flare` instead.
"""
moderation: Literal["auto", "low"]
diff --git a/src/openai/types/webhooks/__init__.py b/src/openai/types/webhooks/__init__.py
index cffb48f967..08b79df9ad 100644
--- a/src/openai/types/webhooks/__init__.py
+++ b/src/openai/types/webhooks/__init__.py
@@ -23,9 +23,7 @@
from .eval_run_canceled_webhook_event import EvalRunCanceledWebhookEvent as EvalRunCanceledWebhookEvent
from .agent_session_idle_webhook_event import AgentSessionIdleWebhookEvent as AgentSessionIdleWebhookEvent
from .eval_run_succeeded_webhook_event import EvalRunSucceededWebhookEvent as EvalRunSucceededWebhookEvent
-from .live_call_incoming_webhook_event import (
- LiveCallIncomingWebhookEvent as LiveCallIncomingWebhookEvent, # pyright: ignore[reportDeprecated]
-)
+from .live_call_incoming_webhook_event import LiveCallIncomingWebhookEvent as LiveCallIncomingWebhookEvent
from .response_cancelled_webhook_event import ResponseCancelledWebhookEvent as ResponseCancelledWebhookEvent
from .response_completed_webhook_event import ResponseCompletedWebhookEvent as ResponseCompletedWebhookEvent
from .response_incomplete_webhook_event import ResponseIncompleteWebhookEvent as ResponseIncompleteWebhookEvent
diff --git a/src/openai/types/webhooks/live_call_incoming_webhook_event.py b/src/openai/types/webhooks/live_call_incoming_webhook_event.py
index 2caba71d3e..491ec97596 100644
--- a/src/openai/types/webhooks/live_call_incoming_webhook_event.py
+++ b/src/openai/types/webhooks/live_call_incoming_webhook_event.py
@@ -1,7 +1,7 @@
# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
-from typing_extensions import Literal, deprecated
+from typing_extensions import Literal
from ..._models import BaseModel
@@ -44,7 +44,6 @@ class Data(BaseModel):
"""
-@deprecated("Use LiveTransportIncomingWebhookEvent (live.transport.incoming) instead.", category=None)
class LiveCallIncomingWebhookEvent(BaseModel):
"""Deprecated: use `live.transport.incoming`.
diff --git a/src/openai/types/webhooks/unwrap_webhook_event.py b/src/openai/types/webhooks/unwrap_webhook_event.py
index a5429f046b..4cddc1e477 100644
--- a/src/openai/types/webhooks/unwrap_webhook_event.py
+++ b/src/openai/types/webhooks/unwrap_webhook_event.py
@@ -13,7 +13,7 @@
from .eval_run_canceled_webhook_event import EvalRunCanceledWebhookEvent
from .agent_session_idle_webhook_event import AgentSessionIdleWebhookEvent
from .eval_run_succeeded_webhook_event import EvalRunSucceededWebhookEvent
-from .live_call_incoming_webhook_event import LiveCallIncomingWebhookEvent # pyright: ignore[reportDeprecated]
+from .live_call_incoming_webhook_event import LiveCallIncomingWebhookEvent
from .response_cancelled_webhook_event import ResponseCancelledWebhookEvent
from .response_completed_webhook_event import ResponseCompletedWebhookEvent
from .response_incomplete_webhook_event import ResponseIncompleteWebhookEvent
@@ -58,7 +58,7 @@
FineTuningJobCancelledWebhookEvent,
FineTuningJobFailedWebhookEvent,
FineTuningJobSucceededWebhookEvent,
- LiveCallIncomingWebhookEvent, # pyright: ignore[reportDeprecated]
+ LiveCallIncomingWebhookEvent,
LiveTransportIncomingWebhookEvent,
RealtimeCallIncomingWebhookEvent,
ResponseCancelledWebhookEvent,
diff --git a/tests/api_resources/live/test_sessions.py b/tests/api_resources/live/test_sessions.py
index dfe67c5b67..2e69d6fe3c 100644
--- a/tests/api_resources/live/test_sessions.py
+++ b/tests/api_resources/live/test_sessions.py
@@ -68,8 +68,18 @@ def test_method_accept_with_all_params(self, client: OpenAI) -> None:
"decisions": {
"questions": [
{
+ "choices": [
+ {
+ "value": False,
+ "description": "description",
+ },
+ {
+ "value": True,
+ "description": "description",
+ },
+ ],
"instructions": "string",
- "type": "predicate",
+ "type": "choice",
"name": "name",
}
]
@@ -444,8 +454,18 @@ async def test_method_accept_with_all_params(self, async_client: AsyncOpenAI) ->
"decisions": {
"questions": [
{
+ "choices": [
+ {
+ "value": False,
+ "description": "description",
+ },
+ {
+ "value": True,
+ "description": "description",
+ },
+ ],
"instructions": "string",
- "type": "predicate",
+ "type": "choice",
"name": "name",
}
]
diff --git a/tests/api_resources/test_live.py b/tests/api_resources/test_live.py
index 9d315f9051..ccf47eb930 100644
--- a/tests/api_resources/test_live.py
+++ b/tests/api_resources/test_live.py
@@ -65,8 +65,18 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
"decisions": {
"questions": [
{
+ "choices": [
+ {
+ "value": False,
+ "description": "description",
+ },
+ {
+ "value": True,
+ "description": "description",
+ },
+ ],
"instructions": "string",
- "type": "predicate",
+ "type": "choice",
"name": "name",
}
]
@@ -169,8 +179,18 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
"decisions": {
"questions": [
{
+ "choices": [
+ {
+ "value": False,
+ "description": "description",
+ },
+ {
+ "value": True,
+ "description": "description",
+ },
+ ],
"instructions": "string",
- "type": "predicate",
+ "type": "choice",
"name": "name",
}
]
diff --git a/tests/lib/test_assistants.py b/tests/lib/test_assistants.py
index 08ea9300c3..952e1ddb45 100644
--- a/tests/lib/test_assistants.py
+++ b/tests/lib/test_assistants.py
@@ -7,23 +7,15 @@
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-def test_create_and_run_poll_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
+@pytest.mark.parametrize("method", ["create_and_run_poll", "create_and_run_stream"])
+def test_create_and_run_helper_definition_in_sync(
+ sync: bool, method: str, client: OpenAI, async_client: AsyncOpenAI
+) -> None:
checking_client: OpenAI | AsyncOpenAI = client if sync else async_client
assert_signatures_in_sync(
checking_client.beta.threads.create_and_run, # pyright: ignore[reportDeprecated]
- checking_client.beta.threads.create_and_run_poll,
- exclude_params={"stream"},
- )
-
-
-@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-def test_create_and_run_stream_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
- checking_client: OpenAI | AsyncOpenAI = client if sync else async_client
-
- assert_signatures_in_sync(
- checking_client.beta.threads.create_and_run, # pyright: ignore[reportDeprecated]
- checking_client.beta.threads.create_and_run_stream,
+ getattr(checking_client.beta.threads, method),
exclude_params={"stream"},
)