streamText: tool calls execute but text output is silently dropped with OpenAI-compatible provider (v7, createOpenAI + custom baseURL)#16408
Description
After migrating from AI SDK v6 (ai@6, @ai-sdk/openai@3, @ai-sdk/react@3) to v7 ([email protected], @ai-sdk/[email protected], @ai-sdk/[email protected]), streamText tool calls execute correctly but the assistant's text output is silently dropped — the chat UI renders tool badges (e.g. createJob done, searchJobs done) but no text content.
This affects both streamText + toUIMessageStream and ToolLoopAgent + createAgentUIStreamResponse — same underlying pipeline.
generateText works correctly on the same provider and model.
Environment
ai: 7.0.0@ai-sdk/openai: 4.0.0@ai-sdk/react: 4.0.0- Next.js: 16.2.7
- Node.js: 24.x
- Runtime: Vercel (Node.js)
- Provider: OpenAI-compatible endpoint via
createOpenAI({ apiKey, baseURL })with a custombaseURL(notapi.openai.com)
Reproduction
Server (app/api/chat/route.ts)
import { streamText, isStepCount, convertToModelMessages, toUIMessageStream, createUIMessageStreamResponse } from "ai";
import { createOpenAI } from "@ai-sdk/openai";
const provider = createOpenAI({
apiKey: process.env.AI_API_KEY,
baseURL: process.env.AI_BASE_URL, // custom OpenAI-compatible endpoint
});
const model = provider("gpt-4o-mini"); // or any model the endpoint supports
const myTool = tool({
description: "Create something",
inputSchema: z.object({ name: z.string() }),
execute: async ({ name }) => ({ ok: true, name }),
});
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model,
instructions: "You are a helpful assistant.",
messages: await convertToModelMessages(messages),
tools: { myTool },
stopWhen: isStepCount(5),
});
// BOTH of these produce the same bug:
// Option 1: deprecated instance method
return result.toUIMessageStreamResponse();
// Option 2: standalone v7 pattern
// return createUIMessageStreamResponse({
// stream: toUIMessageStream({ stream: result.stream, tools: { myTool } }),
// });
}