From 116ee6f94bb099f951b7c96ad63f2b90d8b65102 Mon Sep 17 00:00:00 2001 From: Shemol Date: Tue, 6 Jan 2026 22:19:03 +0800 Subject: [PATCH] fix: TokenFlux models list empty in drawing panel (#12326) Use fixed base URL for TokenFlux image API instead of provider.apiHost. After migration 191, apiHost was changed to include /openai/v1 suffix for chat API compatibility, but image API needs the base URL without this suffix, causing /openai/v1/v1/images/models (wrong path). Fixes #12284 Signed-off-by: SherlockShemol --- .../src/pages/paintings/utils/TokenFluxService.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/pages/paintings/utils/TokenFluxService.ts b/src/renderer/src/pages/paintings/utils/TokenFluxService.ts index 4b1e224a8a..ddd362045b 100644 --- a/src/renderer/src/pages/paintings/utils/TokenFluxService.ts +++ b/src/renderer/src/pages/paintings/utils/TokenFluxService.ts @@ -6,6 +6,9 @@ import type { TokenFluxModel } from '../config/tokenFluxConfig' const logger = loggerService.withContext('TokenFluxService') +// 图片 API 使用固定的基础地址,独立于 provider.apiHost(后者是 OpenAI 兼容的聊天 API 地址) +const TOKENFLUX_IMAGE_API_HOST = 'https://api.tokenflux.ai' + export interface TokenFluxGenerationRequest { model: string input: { @@ -66,7 +69,7 @@ export class TokenFluxService { return cachedModels } - const response = await fetch(`${this.apiHost}/v1/images/models`, { + const response = await fetch(`${TOKENFLUX_IMAGE_API_HOST}/v1/images/models`, { headers: { Authorization: `Bearer ${this.apiKey}` } @@ -88,7 +91,7 @@ export class TokenFluxService { * Create a new image generation request */ async createGeneration(request: TokenFluxGenerationRequest, signal?: AbortSignal): Promise { - const response = await fetch(`${this.apiHost}/v1/images/generations`, { + const response = await fetch(`${TOKENFLUX_IMAGE_API_HOST}/v1/images/generations`, { method: 'POST', headers: this.getHeaders(), body: JSON.stringify(request), @@ -108,7 +111,7 @@ export class TokenFluxService { * Get the status and result of a generation */ async getGenerationResult(generationId: string): Promise { - const response = await fetch(`${this.apiHost}/v1/images/generations/${generationId}`, { + const response = await fetch(`${TOKENFLUX_IMAGE_API_HOST}/v1/images/generations/${generationId}`, { headers: { Authorization: `Bearer ${this.apiKey}` }