惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
月光博客
月光博客
人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
Vercel News
Vercel News
MyScale Blog
MyScale Blog
爱范儿
爱范儿
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
H
Help Net Security
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain Blog
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
宝玉的分享
宝玉的分享
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
J
Java Code Geeks
博客园 - 叶小钗
D
Docker

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: normalize openai legacy image sizes · openclaw/openc...
steipete · 2026-04-27 · via Recent Commits to openclaw:main

@@ -7,6 +7,7 @@ import type {

77

ImageGenerationSourceImage,

88

} from "openclaw/plugin-sdk/image-generation";

99

import { createSubsystemLogger } from "openclaw/plugin-sdk/logging-core";

10+

import { resolveClosestSize } from "openclaw/plugin-sdk/media-generation-runtime";

1011

import {

1112

ensureAuthProfileStore,

1213

isProviderApiKeyConfigured,

@@ -45,6 +46,7 @@ const OPENAI_SUPPORTED_SIZES = [

4546

"3840x2160",

4647

"2160x3840",

4748

] as const;

49+

const OPENAI_LEGACY_IMAGE_SIZES = ["1024x1024", "1536x1024", "1024x1536"] as const;

4850

const OPENAI_MAX_INPUT_IMAGES = 5;

4951

const OPENAI_MAX_IMAGE_RESULTS = 4;

5052

const MAX_CODEX_IMAGE_SSE_BYTES = 64 * 1024 * 1024;

@@ -217,6 +219,46 @@ function resolveOpenAIImageRequestModel(

217219

return model;

218220

}

219221222+

function resolveNativeOpenAIImageSizesForModel(model: string): readonly string[] {

223+

switch (model) {

224+

case "gpt-image-1":

225+

case "gpt-image-1-mini":

226+

return OPENAI_LEGACY_IMAGE_SIZES;

227+

default:

228+

return OPENAI_SUPPORTED_SIZES;

229+

}

230+

}

231+232+

function resolveOpenAIImageRequestSize(params: {

233+

model: string;

234+

requestedSize?: string;

235+

applyNativeLimits: boolean;

236+

}): {

237+

size: string;

238+

metadata?: Record<string, string>;

239+

} {

240+

const requestedSize = params.requestedSize ?? DEFAULT_SIZE;

241+

if (!params.applyNativeLimits) {

242+

return { size: requestedSize };

243+

}

244+

const supportedSizes = resolveNativeOpenAIImageSizesForModel(params.model);

245+

const size =

246+

resolveClosestSize({

247+

requestedSize,

248+

supportedSizes,

249+

}) ?? DEFAULT_SIZE;

250+

if (size === requestedSize) {

251+

return { size };

252+

}

253+

return {

254+

size,

255+

metadata: {

256+

requestedSize,

257+

normalizedSize: size,

258+

},

259+

};

260+

}

261+220262

function shouldAllowPrivateImageEndpoint(req: {

221263

provider: string;

222264

cfg: OpenClawConfig | undefined;

@@ -587,7 +629,12 @@ async function generateOpenAICodexImage(params: {

587629

allowTransparentDefaultReroute: true,

588630

});

589631

const count = resolveOpenAIImageCount(req.count);

590-

const size = req.size ?? DEFAULT_SIZE;

632+

const sizeResolution = resolveOpenAIImageRequestSize({

633+

model,

634+

requestedSize: req.size,

635+

applyNativeLimits: true,

636+

});

637+

const size = sizeResolution.size;

591638

const timeoutMs = resolveOpenAIImageTimeoutMs(req.timeoutMs);

592639

const openai = req.providerOptions?.openai;

593640

const background = openai?.background ?? req.background;

@@ -660,6 +707,7 @@ async function generateOpenAICodexImage(params: {

660707

),

661708

model,

662709

metadata: {

710+

...sizeResolution.metadata,

663711

responses: results.map((result) => result.metadata).filter(Boolean),

664712

},

665713

};

@@ -752,8 +800,13 @@ export function buildOpenAIImageGenerationProvider(): ImageGenerationProvider {

752800

allowTransparentDefaultReroute: publicOpenAIBaseUrl,

753801

});

754802

const count = resolveOpenAIImageCount(req.count);

755-

const size = req.size ?? DEFAULT_SIZE;

756803

const timeoutMs = resolveOpenAIImageTimeoutMs(req.timeoutMs, { isAzure });

804+

const sizeResolution = resolveOpenAIImageRequestSize({

805+

model,

806+

requestedSize: req.size,

807+

applyNativeLimits: publicOpenAIBaseUrl || isAzure,

808+

});

809+

const size = sizeResolution.size;

757810

const url = isAzure

758811

? buildAzureImageUrl(rawBaseUrl, model, isEdit ? "edits" : "generations")

759812

: `${baseUrl}/images/${isEdit ? "edits" : "generations"}`;

@@ -842,6 +895,7 @@ export function buildOpenAIImageGenerationProvider(): ImageGenerationProvider {

842895

return {

843896

images,

844897

model,

898+

...(sizeResolution.metadata ? { metadata: sizeResolution.metadata } : {}),

845899

};

846900

} finally {

847901

await release();