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

推荐订阅源

The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
Vercel News
Vercel News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
The Cloudflare Blog
宝玉的分享
宝玉的分享
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog

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(minimax): use dedicated image generation endpoint (#6...
mushuiyu886 · 2026-04-26 · via Recent Commits to openclaw:main

@@ -1,17 +1,22 @@

11

import * as providerAuth from "openclaw/plugin-sdk/provider-auth-runtime";

22

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

33

import { installPinnedHostnameTestHooks } from "../../src/media-understanding/audio.test-helpers.js";

4-

import { buildMinimaxImageGenerationProvider } from "./image-generation-provider.js";

4+

import {

5+

buildMinimaxImageGenerationProvider,

6+

buildMinimaxPortalImageGenerationProvider,

7+

} from "./image-generation-provider.js";

5869

installPinnedHostnameTestHooks();

710811

describe("minimax image-generation provider", () => {

912

beforeEach(() => {

1013

vi.clearAllMocks();

14+

vi.stubEnv("MINIMAX_API_HOST", "");

1115

});

12161317

afterEach(() => {

1418

vi.restoreAllMocks();

19+

vi.unstubAllEnvs();

1520

});

16211722

function mockMinimaxApiKey() {

@@ -41,6 +46,10 @@ describe("minimax image-generation provider", () => {

4146

return fetchMock;

4247

}

434849+

function expectImageGenerationUrl(fetchMock: ReturnType<typeof vi.fn>, url: string) {

50+

expect(fetchMock).toHaveBeenCalledWith(url, expect.any(Object));

51+

}

52+4453

it("generates PNG buffers through the shared provider HTTP path", async () => {

4554

mockMinimaxApiKey();

4655

const fetchMock = mockSuccessfulMinimaxImageResponse();

@@ -81,7 +90,7 @@ describe("minimax image-generation provider", () => {

8190

});

8291

});

839284-

it("uses the configured provider base URL origin", async () => {

93+

it("keeps the dedicated global image endpoint when text config uses the global API host", async () => {

8594

mockMinimaxApiKey();

8695

const fetchMock = mockSuccessfulMinimaxImageResponse();

8796

@@ -102,36 +111,118 @@ describe("minimax image-generation provider", () => {

102111

},

103112

});

104113105-

expect(fetchMock).toHaveBeenCalledWith(

106-

"https://api.minimax.io/v1/image_generation",

107-

expect.any(Object),

108-

);

114+

expectImageGenerationUrl(fetchMock, "https://api.minimax.io/v1/image_generation");

109115

});

110116111-

it("does not allow private-network routing just because a custom base URL is configured", async () => {

117+

it("does not inherit unrelated MiniMax text endpoint hosts for image generation", async () => {

112118

mockMinimaxApiKey();

113-

const fetchMock = vi.fn();

114-

vi.stubGlobal("fetch", fetchMock);

119+

const fetchMock = mockSuccessfulMinimaxImageResponse();

115120116121

const provider = buildMinimaxImageGenerationProvider();

117-

await expect(

118-

provider.generateImage({

119-

provider: "minimax",

120-

model: "image-01",

121-

prompt: "draw a cat",

122-

cfg: {

123-

models: {

124-

providers: {

125-

minimax: {

126-

baseUrl: "http://127.0.0.1:8080/anthropic",

127-

models: [],

128-

},

122+

await provider.generateImage({

123+

provider: "minimax",

124+

model: "image-01",

125+

prompt: "draw a cat",

126+

cfg: {

127+

models: {

128+

providers: {

129+

minimax: {

130+

baseUrl: "https://api.minimax.chat/anthropic",

131+

models: [],

129132

},

130133

},

131134

},

132-

}),

133-

).rejects.toThrow("Blocked hostname or private/internal/special-use IP address");

135+

},

136+

});

137+138+

expectImageGenerationUrl(fetchMock, "https://api.minimax.io/v1/image_generation");

139+

});

140+141+

it("uses the dedicated CN image endpoint when CN API host is configured", async () => {

142+

vi.stubEnv("MINIMAX_API_HOST", "https://api.minimaxi.com/anthropic");

143+

mockMinimaxApiKey();

144+

const fetchMock = mockSuccessfulMinimaxImageResponse();

145+146+

const provider = buildMinimaxImageGenerationProvider();

147+

await provider.generateImage({

148+

provider: "minimax",

149+

model: "image-01",

150+

prompt: "draw a cat",

151+

cfg: {},

152+

});

153+154+

expectImageGenerationUrl(fetchMock, "https://api.minimaxi.com/v1/image_generation");

155+

});

156+157+

it("infers the dedicated CN image endpoint from MiniMax provider config", async () => {

158+

mockMinimaxApiKey();

159+

const fetchMock = mockSuccessfulMinimaxImageResponse();

160+161+

const provider = buildMinimaxImageGenerationProvider();

162+

await provider.generateImage({

163+

provider: "minimax",

164+

model: "image-01",

165+

prompt: "draw a cat",

166+

cfg: {

167+

models: {

168+

providers: {

169+

minimax: {

170+

baseUrl: "https://api.minimaxi.com/anthropic",

171+

models: [],

172+

},

173+

},

174+

},

175+

},

176+

});

177+178+

expectImageGenerationUrl(fetchMock, "https://api.minimaxi.com/v1/image_generation");

179+

});

180+181+

it("infers the dedicated CN image endpoint from MiniMax Portal provider config", async () => {

182+

mockMinimaxApiKey();

183+

const fetchMock = mockSuccessfulMinimaxImageResponse();

184+185+

const provider = buildMinimaxPortalImageGenerationProvider();

186+

await provider.generateImage({

187+

provider: "minimax-portal",

188+

model: "image-01",

189+

prompt: "draw a cat",

190+

cfg: {

191+

models: {

192+

providers: {

193+

"minimax-portal": {

194+

baseUrl: "api.minimaxi.com/anthropic",

195+

models: [],

196+

},

197+

},

198+

},

199+

},

200+

});

201+202+

expectImageGenerationUrl(fetchMock, "https://api.minimaxi.com/v1/image_generation");

203+

});

204+205+

it("ignores private custom text endpoints for image generation", async () => {

206+

mockMinimaxApiKey();

207+

const fetchMock = mockSuccessfulMinimaxImageResponse();

208+209+

const provider = buildMinimaxImageGenerationProvider();

210+

await provider.generateImage({

211+

provider: "minimax",

212+

model: "image-01",

213+

prompt: "draw a cat",

214+

cfg: {

215+

models: {

216+

providers: {

217+

minimax: {

218+

baseUrl: "http://127.0.0.1:8080/anthropic",

219+

models: [],

220+

},

221+

},

222+

},

223+

},

224+

});

134225135-

expect(fetchMock).not.toHaveBeenCalled();

226+

expectImageGenerationUrl(fetchMock, "https://api.minimax.io/v1/image_generation");

136227

});

137228

});