🏞️ feat: Modifiable OpenAI Image Gen Model Environment Variable (#11082)

This commit is contained in:
Dustin Healy 2025-12-25 09:45:38 -08:00 committed by GitHub
parent 6ffb176056
commit b7ea340769
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 167 additions and 2 deletions

View file

@ -78,6 +78,8 @@ function createOpenAIImageTools(fields = {}) {
let apiKey = fields.IMAGE_GEN_OAI_API_KEY ?? getApiKey();
const closureConfig = { apiKey };
const imageModel = process.env.IMAGE_GEN_OAI_MODEL || 'gpt-image-1';
let baseURL = 'https://api.openai.com/v1/';
if (!override && process.env.IMAGE_GEN_OAI_BASEURL) {
baseURL = extractBaseURL(process.env.IMAGE_GEN_OAI_BASEURL);
@ -157,7 +159,7 @@ function createOpenAIImageTools(fields = {}) {
resp = await openai.images.generate(
{
model: 'gpt-image-1',
model: imageModel,
prompt: replaceUnwantedChars(prompt),
n: Math.min(Math.max(1, n), 10),
background,
@ -239,7 +241,7 @@ Error Message: ${error.message}`);
}
const formData = new FormData();
formData.append('model', 'gpt-image-1');
formData.append('model', imageModel);
formData.append('prompt', replaceUnwantedChars(prompt));
// TODO: `mask` support
// TODO: more than 1 image support