deprecate `generateObject()` / `streamObject()` in favor of `generateText({ output })` / `streamText({ output })`
Not sure it's the best place, or if it's better to create a new issue, but should this work in the latest beta versions:
import 'dotenv/config';
import { generateText, Output } from 'ai';
import z from 'zod';
import { experimental_createMCPClient as createMCPClient } from '@ai-sdk/mcp';
import { openai } from '@ai-sdk/openai';
const transport = {
type: 'http',
url: 'https://api.githubcopilot.com/mcp/',
headers: { Authorization: process.env.GITHUB_MCP_API_KEY || '' },
} as const;
const client = await createMCPClient({ transport });
const tools = await client.tools();
const model = openai('gpt-5')
const schema = z.object({
repositories: z.array(z.object({ name: z.string })),
});
const githubProfileName = '...';
await generateText({
model,
tools,
output: Output.object({ schema }),
prompt: `List all repositories owned by the GitHub user "${githubProfileName}" with at least 50 stars.`,
});
I'm currently getting NoOutputGeneratedError [AI_NoOutputGeneratedError]: No output generated. error.
More info here: https://community.vercel.com/t/no-output-when-using-generatetext-with-structured-output-and-mcp-tools/27423.
Please create a separate issue, it's unrelated to the deprecation of generateObject() and streamObject(), it might be a bug with generateText({ output })
How do I consume it in the ui after this deprecation? Before this, we can use useObject; now it seems we need manually extract it?
@songkeys you can still use useObject (with text streams from streamText)
@szimek you need to specify stopWhen since tools require multiple steps