Skip to content

Commit c5452af

Browse files
feat(api): expose image tool error and moderation details (#4072)
## Summary Read structured error details on image tool tool calls in Responses and beta Responses. ## Changes - Expose error code, type, message, and related parameter when available. - Expose optional moderation details including input/output stage and category names. Co-authored-by: jbeckwith-oai <[email protected]>
1 parent 1f05e33 commit c5452af

14 files changed

Lines changed: 549 additions & 6 deletions

‎.castiron.stats.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
schema_version: 1
2-
generation_id: 4dbefa31-3327-46e9-8f21-2ba5a07c975b
3-
openapi_spec_hash: 956d02d9e8fbe439b1409c609f26c276
4-
openapi_transformed_spec_hash: 86aa9a172bbb1e2bbc5129c37958862b
2+
generation_id: e6c31719-6ffd-4aa1-89c1-b4bf04550ec0
3+
openapi_spec_hash: 56285f98456d533f1f4454d4417d1b6d
4+
openapi_transformed_spec_hash: 23b8b35c7667416b4c334920011e8922
55
config_hash: 47b922b06d16fe0e7595c5eacbbb5495
6-
codegen_sha: cb4f39401d5099f2a0d769d20f96bb76bac5a46d
7-
codegen_hash: d0f5b556f24fed3f69edaf9d4f181c306948f986b8876fde94f38a0f4511faab
8-
public_codegen_sha: a457b68efa244472e9af2d5f09494c30b184d9d1
6+
codegen_sha: 93772dea1bfb48e44f65dd84a020dfa77086ae38
7+
codegen_hash: 75272a4aa86f558b5e58456cebb6a22d6160898d58376e31470ed32491b462e1
8+
public_codegen_sha: 9f5b2a43e880bd068b672c545916b16416756a4a

‎api_reference/openapi.transformed.yml‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37006,6 +37006,96 @@ webhooks:
3700637006
description: Return any 2xx status code to acknowledge receipt. A 410 Gone response also stops retries; other non-2xx responses are retried.
3700737007
components:
3700837008
schemas:
37009+
ImageGenToolCallError:
37010+
properties:
37011+
code:
37012+
anyOf:
37013+
- type: string
37014+
description: The error code.
37015+
- type: 'null'
37016+
type:
37017+
type: string
37018+
description: The error type.
37019+
message:
37020+
type: string
37021+
description: A description of the error.
37022+
param:
37023+
anyOf:
37024+
- type: string
37025+
description: The related request parameter.
37026+
- type: 'null'
37027+
moderation_details:
37028+
$ref: '#/components/schemas/ImageGenToolCallModerationDetails'
37029+
description: Public details for a `moderation_blocked` error, when available.
37030+
type: object
37031+
required:
37032+
- code
37033+
- type
37034+
- message
37035+
- param
37036+
ImageGenToolCallModerationDetails:
37037+
properties:
37038+
moderation_stage:
37039+
type: string
37040+
enum:
37041+
- input
37042+
- output
37043+
- unknown
37044+
description: The stage where moderation blocked the image generation call.
37045+
categories:
37046+
items:
37047+
type: string
37048+
type: array
37049+
description: Public moderation categories. New category values may be added over time.
37050+
type: object
37051+
required:
37052+
- moderation_stage
37053+
- categories
37054+
BetaImageGenToolCallError:
37055+
properties:
37056+
code:
37057+
anyOf:
37058+
- type: string
37059+
description: The error code.
37060+
- type: 'null'
37061+
type:
37062+
type: string
37063+
description: The error type.
37064+
message:
37065+
type: string
37066+
description: A description of the error.
37067+
param:
37068+
anyOf:
37069+
- type: string
37070+
description: The related request parameter.
37071+
- type: 'null'
37072+
moderation_details:
37073+
$ref: '#/components/schemas/BetaImageGenToolCallModerationDetails'
37074+
description: Public details for a `moderation_blocked` error, when available.
37075+
type: object
37076+
required:
37077+
- code
37078+
- type
37079+
- message
37080+
- param
37081+
BetaImageGenToolCallModerationDetails:
37082+
properties:
37083+
moderation_stage:
37084+
type: string
37085+
enum:
37086+
- input
37087+
- output
37088+
- unknown
37089+
description: The stage where moderation blocked the image generation call.
37090+
categories:
37091+
items:
37092+
type: string
37093+
type: array
37094+
description: Public moderation categories. New category values may be added over time.
37095+
type: object
37096+
required:
37097+
- moderation_stage
37098+
- categories
3700937099
AddUploadPartRequest:
3701037100
type: object
3701137101
additionalProperties: false
@@ -74356,6 +74446,9 @@ components:
7435674446
- jpeg
7435774447
ImageGenToolCall:
7435874448
properties:
74449+
error:
74450+
$ref: '#/components/schemas/ImageGenToolCallError'
74451+
description: Details of a moderation failure, when available.
7435974452
type:
7436074453
type: string
7436174454
enum:
@@ -96694,6 +96787,9 @@ components:
9669496787
description: The logs output from the code interpreter.
9669596788
BetaImageGenToolCall:
9669696789
properties:
96790+
error:
96791+
$ref: '#/components/schemas/BetaImageGenToolCallError'
96792+
description: Details of a moderation failure, when available.
9669796793
agent:
9669896794
anyOf:
9669996795
- $ref: '#/components/schemas/BetaAgentTag'

‎src/openai/types/beta/beta_response_input_item.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"AdditionalToolsAgent",
6161
"ImageGenerationCall",
6262
"ImageGenerationCallAgent",
63+
"ImageGenerationCallError",
64+
"ImageGenerationCallErrorModerationDetails",
6365
"LocalShellCall",
6466
"LocalShellCallAction",
6567
"LocalShellCallAgent",
@@ -497,6 +499,35 @@ class ImageGenerationCallAgent(BaseModel):
497499
"""The canonical name of the agent that produced this item."""
498500

499501

502+
class ImageGenerationCallErrorModerationDetails(BaseModel):
503+
"""Public details for a `moderation_blocked` error, when available."""
504+
505+
categories: List[str]
506+
"""Public moderation categories. New category values may be added over time."""
507+
508+
moderation_stage: Literal["input", "output", "unknown"]
509+
"""The stage where moderation blocked the image generation call."""
510+
511+
512+
class ImageGenerationCallError(BaseModel):
513+
"""Details of a moderation failure, when available."""
514+
515+
code: Optional[str] = None
516+
"""The error code."""
517+
518+
message: str
519+
"""A description of the error."""
520+
521+
param: Optional[str] = None
522+
"""The related request parameter."""
523+
524+
type: str
525+
"""The error type."""
526+
527+
moderation_details: Optional[ImageGenerationCallErrorModerationDetails] = None
528+
"""Public details for a `moderation_blocked` error, when available."""
529+
530+
500531
class ImageGenerationCall(BaseModel):
501532
"""An image generation request made by the model."""
502533

@@ -521,6 +552,9 @@ class ImageGenerationCall(BaseModel):
521552
background: Optional[Literal["transparent", "opaque", "auto"]] = None
522553
"""The background setting used for generation."""
523554

555+
error: Optional[ImageGenerationCallError] = None
556+
"""Details of a moderation failure, when available."""
557+
524558
output_format: Optional[Literal["png", "webp", "jpeg"]] = None
525559
"""The output format used for generation."""
526560

‎src/openai/types/beta/beta_response_input_item_param.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
"AdditionalToolsAgent",
6262
"ImageGenerationCall",
6363
"ImageGenerationCallAgent",
64+
"ImageGenerationCallError",
65+
"ImageGenerationCallErrorModerationDetails",
6466
"LocalShellCall",
6567
"LocalShellCallAction",
6668
"LocalShellCallAgent",
@@ -496,6 +498,35 @@ class ImageGenerationCallAgent(TypedDict, total=False):
496498
"""The canonical name of the agent that produced this item."""
497499

498500

501+
class ImageGenerationCallErrorModerationDetails(TypedDict, total=False):
502+
"""Public details for a `moderation_blocked` error, when available."""
503+
504+
categories: Required[SequenceNotStr[str]]
505+
"""Public moderation categories. New category values may be added over time."""
506+
507+
moderation_stage: Required[Literal["input", "output", "unknown"]]
508+
"""The stage where moderation blocked the image generation call."""
509+
510+
511+
class ImageGenerationCallError(TypedDict, total=False):
512+
"""Details of a moderation failure, when available."""
513+
514+
code: Required[Optional[str]]
515+
"""The error code."""
516+
517+
message: Required[str]
518+
"""A description of the error."""
519+
520+
param: Required[Optional[str]]
521+
"""The related request parameter."""
522+
523+
type: Required[str]
524+
"""The error type."""
525+
526+
moderation_details: ImageGenerationCallErrorModerationDetails
527+
"""Public details for a `moderation_blocked` error, when available."""
528+
529+
499530
class ImageGenerationCall(TypedDict, total=False):
500531
"""An image generation request made by the model."""
501532

@@ -520,6 +551,9 @@ class ImageGenerationCall(TypedDict, total=False):
520551
background: Optional[Literal["transparent", "opaque", "auto"]]
521552
"""The background setting used for generation."""
522553

554+
error: ImageGenerationCallError
555+
"""Details of a moderation failure, when available."""
556+
523557
output_format: Optional[Literal["png", "webp", "jpeg"]]
524558
"""The output format used for generation."""
525559

‎src/openai/types/beta/beta_response_input_param.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
"AdditionalToolsAgent",
6363
"ImageGenerationCall",
6464
"ImageGenerationCallAgent",
65+
"ImageGenerationCallError",
66+
"ImageGenerationCallErrorModerationDetails",
6567
"LocalShellCall",
6668
"LocalShellCallAction",
6769
"LocalShellCallAgent",
@@ -497,6 +499,35 @@ class ImageGenerationCallAgent(TypedDict, total=False):
497499
"""The canonical name of the agent that produced this item."""
498500

499501

502+
class ImageGenerationCallErrorModerationDetails(TypedDict, total=False):
503+
"""Public details for a `moderation_blocked` error, when available."""
504+
505+
categories: Required[SequenceNotStr[str]]
506+
"""Public moderation categories. New category values may be added over time."""
507+
508+
moderation_stage: Required[Literal["input", "output", "unknown"]]
509+
"""The stage where moderation blocked the image generation call."""
510+
511+
512+
class ImageGenerationCallError(TypedDict, total=False):
513+
"""Details of a moderation failure, when available."""
514+
515+
code: Required[Optional[str]]
516+
"""The error code."""
517+
518+
message: Required[str]
519+
"""A description of the error."""
520+
521+
param: Required[Optional[str]]
522+
"""The related request parameter."""
523+
524+
type: Required[str]
525+
"""The error type."""
526+
527+
moderation_details: ImageGenerationCallErrorModerationDetails
528+
"""Public details for a `moderation_blocked` error, when available."""
529+
530+
500531
class ImageGenerationCall(TypedDict, total=False):
501532
"""An image generation request made by the model."""
502533

@@ -521,6 +552,9 @@ class ImageGenerationCall(TypedDict, total=False):
521552
background: Optional[Literal["transparent", "opaque", "auto"]]
522553
"""The background setting used for generation."""
523554

555+
error: ImageGenerationCallError
556+
"""Details of a moderation failure, when available."""
557+
524558
output_format: Optional[Literal["png", "webp", "jpeg"]]
525559
"""The output format used for generation."""
526560

‎src/openai/types/beta/beta_response_item.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
"ProgramOutputAgent",
5858
"ImageGenerationCall",
5959
"ImageGenerationCallAgent",
60+
"ImageGenerationCallError",
61+
"ImageGenerationCallErrorModerationDetails",
6062
"LocalShellCall",
6163
"LocalShellCallAction",
6264
"LocalShellCallAgent",
@@ -336,6 +338,35 @@ class ImageGenerationCallAgent(BaseModel):
336338
"""The canonical name of the agent that produced this item."""
337339

338340

341+
class ImageGenerationCallErrorModerationDetails(BaseModel):
342+
"""Public details for a `moderation_blocked` error, when available."""
343+
344+
categories: List[str]
345+
"""Public moderation categories. New category values may be added over time."""
346+
347+
moderation_stage: Literal["input", "output", "unknown"]
348+
"""The stage where moderation blocked the image generation call."""
349+
350+
351+
class ImageGenerationCallError(BaseModel):
352+
"""Details of a moderation failure, when available."""
353+
354+
code: Optional[str] = None
355+
"""The error code."""
356+
357+
message: str
358+
"""A description of the error."""
359+
360+
param: Optional[str] = None
361+
"""The related request parameter."""
362+
363+
type: str
364+
"""The error type."""
365+
366+
moderation_details: Optional[ImageGenerationCallErrorModerationDetails] = None
367+
"""Public details for a `moderation_blocked` error, when available."""
368+
369+
339370
class ImageGenerationCall(BaseModel):
340371
"""An image generation request made by the model."""
341372

@@ -360,6 +391,9 @@ class ImageGenerationCall(BaseModel):
360391
background: Optional[Literal["transparent", "opaque", "auto"]] = None
361392
"""The background setting used for generation."""
362393

394+
error: Optional[ImageGenerationCallError] = None
395+
"""Details of a moderation failure, when available."""
396+
363397
output_format: Optional[Literal["png", "webp", "jpeg"]] = None
364398
"""The output format used for generation."""
365399

0 commit comments

Comments
 (0)