Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ type Protocol = "openai" | "anthropic";
const PROVIDERS = new Map<string, { protocol: Protocol; npm: string }>([
["openai", { protocol: "openai", npm: "@ai-sdk/openai" }],
["anthropic", { protocol: "anthropic", npm: "@ai-sdk/anthropic" }],
["deepseek", { protocol: "anthropic", npm: "@ai-sdk/anthropic" }],
// DeepSeek must use Chat Completions, not the Anthropic protocol: the
// Anthropic message format drops reasoning blocks that carry no signature,
// and DeepSeek never issues one. A reasoning-only assistant turn then lowers
// to `content: []` and the API rejects the whole request with "all messages
// must have non-empty content", while `reasoning_content` never survives the
// round-trip that DeepSeek's thinking mode requires.
["deepseek", { protocol: "openai", npm: "@ai-sdk/openai-compatible" }],
["zai", { protocol: "openai", npm: "@ai-sdk/openai-compatible" }],
["moonshotai", { protocol: "openai", npm: "@ai-sdk/openai-compatible" }],
]);
Expand Down
20 changes: 8 additions & 12 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const MODELS_DEV_DATA = {
output: ["text"],
},
cost: { input: 1.5, output: 6, cache_read: 0.15, cache_write: 1.5 },
interleaved: { field: "reasoning_content" },
},
"deepseek-v4-flash": {
id: "deepseek-v4-flash",
Expand All @@ -99,6 +100,7 @@ const MODELS_DEV_DATA = {
cache_read: 0.015,
cache_write: 0.15,
},
interleaved: { field: "reasoning_content" },
},
},
},
Expand Down Expand Up @@ -217,8 +219,8 @@ describe("config hook", () => {
id: "deepseek-v4-pro",
name: "DeepSeek V4 Pro",
provider: {
api: "https://hub.coreinfra.ai/anthropic/api/v1",
npm: "@ai-sdk/anthropic",
api: "https://hub.coreinfra.ai/openai/api/v1",
npm: "@ai-sdk/openai-compatible",
},
attachment: false,
reasoning: true,
Expand All @@ -228,18 +230,15 @@ describe("config hook", () => {
cost: { input: 1.5, output: 6, cache_read: 0.15, cache_write: 1.5 },
limit: { context: 1000000, output: 384000 },
interleaved: { field: "reasoning_content" },
headers: {
"anthropic-beta":
"interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
},
headers: {},
});

expect(models["deepseek-v4-flash"]).toEqual({
id: "deepseek-v4-flash",
name: "DeepSeek V4 Flash",
provider: {
api: "https://hub.coreinfra.ai/anthropic/api/v1",
npm: "@ai-sdk/anthropic",
api: "https://hub.coreinfra.ai/openai/api/v1",
npm: "@ai-sdk/openai-compatible",
},
attachment: false,
reasoning: true,
Expand All @@ -249,10 +248,7 @@ describe("config hook", () => {
cost: { input: 0.15, output: 0.6, cache_read: 0.015, cache_write: 0.15 },
limit: { context: 1000000, output: 384000 },
interleaved: { field: "reasoning_content" },
headers: {
"anthropic-beta":
"interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
},
headers: {},
});
});

Expand Down
20 changes: 8 additions & 12 deletions test/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const MODELS_DEV_FIXTURE = {
output: ["text"],
},
cost: { input: 1.5, output: 6, cache_read: 0.15, cache_write: 1.5 },
interleaved: { field: "reasoning_content" },
},
"deepseek-v4-flash": {
id: "deepseek-v4-flash",
Expand All @@ -86,6 +87,7 @@ const MODELS_DEV_FIXTURE = {
cache_read: 0.015,
cache_write: 0.15,
},
interleaved: { field: "reasoning_content" },
},
},
},
Expand Down Expand Up @@ -174,8 +176,8 @@ describe("buildConfigModels", () => {
id: "deepseek-v4-pro",
name: "DeepSeek V4 Pro",
provider: {
api: "https://hub.coreinfra.ai/anthropic/api/v1",
npm: "@ai-sdk/anthropic",
api: "https://hub.coreinfra.ai/openai/api/v1",
npm: "@ai-sdk/openai-compatible",
},
attachment: false,
reasoning: true,
Expand All @@ -188,19 +190,16 @@ describe("buildConfigModels", () => {
cost: { input: 1.5, output: 6, cache_read: 0.15, cache_write: 1.5 },
limit: { context: 1000000, output: 384000 },
interleaved: { field: "reasoning_content" },
headers: {
"anthropic-beta":
"interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
},
headers: {},
});

const dsFlash = models["deepseek-v4-flash"];
expect(dsFlash).toEqual({
id: "deepseek-v4-flash",
name: "DeepSeek V4 Flash",
provider: {
api: "https://hub.coreinfra.ai/anthropic/api/v1",
npm: "@ai-sdk/anthropic",
api: "https://hub.coreinfra.ai/openai/api/v1",
npm: "@ai-sdk/openai-compatible",
},
attachment: false,
reasoning: true,
Expand All @@ -213,10 +212,7 @@ describe("buildConfigModels", () => {
cost: { input: 0.15, output: 0.6, cache_read: 0.015, cache_write: 0.15 },
limit: { context: 1000000, output: 384000 },
interleaved: { field: "reasoning_content" },
headers: {
"anthropic-beta":
"interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
},
headers: {},
});
});

Expand Down