From 259102275e5c2ca7c524ca0250c3299c5d6af52e Mon Sep 17 00:00:00 2001 From: haotian <865700600@qq.com> Date: Sat, 9 May 2026 23:57:00 +0800 Subject: [PATCH] @ fix(tongyi): remove Bearer prefix from DashScope authorization headers The Alibaba Bailian (DashScope/Tongyi) API expects the apiKey to be passed directly in the Authorization header without a "Bearer " prefix. This differs from OpenAI-compatible and Doubao (Volcengine ARK) APIs which still require the "Bearer " scheme. All 9 occurrences in TongyiImageService and TongyiVideoService are updated. DoubaoImageService, DoubaoVideoService, and OpenAICompatImageService are intentionally left unchanged. @ --- packages/core/src/services/assetImageService.ts | 14 +++++++------- packages/core/src/services/assetVideoService.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/core/src/services/assetImageService.ts b/packages/core/src/services/assetImageService.ts index ad2ad2b..fa7c854 100644 --- a/packages/core/src/services/assetImageService.ts +++ b/packages/core/src/services/assetImageService.ts @@ -59,7 +59,7 @@ export class TongyiImageService extends BaseService { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, 'X-DashScope-Async': 'enable', }, body: JSON.stringify(payload), @@ -84,7 +84,7 @@ export class TongyiImageService extends BaseService { const taskUrl = `${this.config.baseUrl}/api/v1/tasks/${taskId}`; const result = await this.pollTaskStatus(taskUrl, { - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, }); const resultUrl = result.output?.results?.[0]?.url; @@ -122,7 +122,7 @@ export class TongyiImageService extends BaseService { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, }, body: JSON.stringify(payload), }); @@ -208,7 +208,7 @@ export class TongyiImageService extends BaseService { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, 'X-DashScope-Async': 'enable', }, body: JSON.stringify(payload), @@ -233,7 +233,7 @@ export class TongyiImageService extends BaseService { const taskUrl = `${this.config.baseUrl}/api/v1/tasks/${taskId}`; const result = await this.pollTaskStatus(taskUrl, { - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, }); const resultUrl = result.output?.results?.[0]?.url; @@ -272,7 +272,7 @@ export class TongyiImageService extends BaseService { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, 'X-DashScope-Async': 'enable', }, body: JSON.stringify(payload), @@ -295,7 +295,7 @@ export class TongyiImageService extends BaseService { const taskUrl = `${this.config.baseUrl}/api/v1/tasks/${taskId}`; const result = await this.pollTaskStatus(taskUrl, { - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, }); const resultUrl = result.output?.results?.[0]?.url; diff --git a/packages/core/src/services/assetVideoService.ts b/packages/core/src/services/assetVideoService.ts index fafffe1..79afdcf 100644 --- a/packages/core/src/services/assetVideoService.ts +++ b/packages/core/src/services/assetVideoService.ts @@ -75,7 +75,7 @@ export class TongyiVideoService extends BaseService { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, 'X-DashScope-Async': 'enable', }, body: JSON.stringify(payload), @@ -102,7 +102,7 @@ export class TongyiVideoService extends BaseService { const result = await this.pollTaskStatus( taskUrl, { - Authorization: `Bearer ${this.config.apiKey}`, + Authorization: `${this.config.apiKey}`, }, 600000, 10000,