diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index 019f1726..2518ea4a 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -167,7 +167,7 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions", OpenA calculateCost(model, output.usage); } - const choice = chunk.choices[0]; + const choice = chunk.choices?.[0]; if (!choice) continue; if (choice.finish_reason) { diff --git a/packages/ai/test/stream.test.ts b/packages/ai/test/stream.test.ts index 3120b559..1582ca7d 100644 --- a/packages/ai/test/stream.test.ts +++ b/packages/ai/test/stream.test.ts @@ -737,32 +737,8 @@ describe("Generate E2E Tests", () => { }, ); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-4.5-air via OpenAI Completions)", () => { - const llm = getModel("zai", "glm-4.5-air"); - - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); - - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); - - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); - - it.skip("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); - - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); - }); - - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-4.5v via OpenAI Completions)", () => { - const llm = getModel("zai", "glm-4.5v"); + describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-5 via OpenAI Completions)", () => { + const llm = getModel("zai", "glm-5"); it("should complete basic text generation", { retry: 3 }, async () => { await basicTextGeneration(llm);