Avoid passing response_format to OpenAI's image generation API for the gpt-image-1 model

The API reference for `response_format` says:

> This parameter isn't supported for gpt-image-1 which will always return base64-encoded images.

Related to https://github.com/etkecc/baibot/issues/40
This commit is contained in:
Slavi Pantaleev
2025-05-03 09:40:31 +03:00
parent 256ed05662
commit c94376109c
2 changed files with 5 additions and 0 deletions

View File

@@ -36,6 +36,8 @@ use crate::{
use super::config::Config;
use super::OPENAI_IMAGE_MODEL_GPT_IMAGE_1;
#[derive(Debug, Clone)]
pub struct Controller {
config: Config,
@@ -291,6 +293,7 @@ impl ControllerTrait for Controller {
async_openai::types::ImageModel::DallE2 => Some(async_openai::types::ImageResponseFormat::B64Json),
async_openai::types::ImageModel::DallE3 => Some(async_openai::types::ImageResponseFormat::B64Json),
async_openai::types::ImageModel::Other(model_str) => match model_str.as_str() {
OPENAI_IMAGE_MODEL_GPT_IMAGE_1 => None,
_ => Some(async_openai::types::ImageResponseFormat::B64Json),
},
};

View File

@@ -16,6 +16,8 @@ use super::super::AgentInstantiationResult;
use super::ConfigTrait;
use super::controller::ControllerType;
pub const OPENAI_IMAGE_MODEL_GPT_IMAGE_1: &str = "gpt-image-1";
pub fn create_controller_from_yaml_value_config(
agent_id: &str,
config: serde_yaml::Value,