diff --git a/src/services/_url.ts b/src/services/_url.ts index d8d0d56e058a..f01e23290e18 100644 --- a/src/services/_url.ts +++ b/src/services/_url.ts @@ -36,7 +36,7 @@ export const API_ENDPOINTS = mapWithBasePath({ trace: '/webapi/trace', // image - images: '/webapi/text-to-image/openai', + images: (provider: string) => `/webapi/text-to-image/${provider}`, // STT stt: '/webapi/stt/openai', diff --git a/src/services/textToImage.ts b/src/services/textToImage.ts index f60eb9afc4be..3de461a41052 100644 --- a/src/services/textToImage.ts +++ b/src/services/textToImage.ts @@ -12,12 +12,14 @@ class ImageGenerationService { async generateImage(params: Omit, options?: FetchOptions) { const payload: OpenAIImagePayload = { ...params, model: 'dall-e-3', n: 1 }; + const provider = ModelProvider.OpenAI; + const headers = await createHeaderWithAuth({ headers: { 'Content-Type': 'application/json' }, - provider: ModelProvider.OpenAI, + provider, }); - const res = await fetch(API_ENDPOINTS.images, { + const res = await fetch(API_ENDPOINTS.images(provider), { body: JSON.stringify(payload), headers: headers, method: 'POST',