From db42098fb28395f32fbd4a34c392e3ec537d3061 Mon Sep 17 00:00:00 2001 From: Matt Yan Date: Wed, 9 Jul 2025 08:38:30 +0900 Subject: [PATCH] feat: update image generation API to match latest OpenAI specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add ImageModeration enum with 'auto' (default) and 'low' values - Add moderation parameter to CreateImageRequest for gpt-image-1 - Extend ImageQuality enum to support 'high', 'medium', 'low' for gpt-image-1 These changes align with the latest OpenAI API documentation for image generation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- async-openai/src/types/image.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/async-openai/src/types/image.rs b/async-openai/src/types/image.rs index 86169c46..207dc85d 100644 --- a/async-openai/src/types/image.rs +++ b/async-openai/src/types/image.rs @@ -57,6 +57,9 @@ pub enum ImageQuality { #[default] Standard, HD, + High, + Medium, + Low, } #[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq)] @@ -67,6 +70,14 @@ pub enum ImageStyle { Natural, } +#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq)] +#[serde(rename_all = "lowercase")] +pub enum ImageModeration { + #[default] + Auto, + Low, +} + #[derive(Debug, Clone, Serialize, Deserialize, Default, Builder, PartialEq)] #[builder(name = "CreateImageRequestArgs")] #[builder(pattern = "mutable")] @@ -110,6 +121,11 @@ pub struct CreateImageRequest { /// A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/usage-policies/end-user-ids). #[serde(skip_serializing_if = "Option::is_none")] pub user: Option, + + /// Control the content-moderation level for images generated by gpt-image-1. + /// Must be either `low` for less restrictive filtering or `auto` (default value). + #[serde(skip_serializing_if = "Option::is_none")] + pub moderation: Option, } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]