Skip to content

Instantly share code, notes, and snippets.

@kamilio
Last active March 20, 2026 14:24
Show Gist options
  • Select an option

  • Save kamilio/0ccd28df2b586a81ada14e220b262651 to your computer and use it in GitHub Desktop.

Select an option

Save kamilio/0ccd28df2b586a81ada14e220b262651 to your computer and use it in GitHub Desktop.
Repro: /v1/responses returns invalid output_text for Google models (missing text field on tool calls)

How to run

npm init -y && npm install ai @ai-sdk/openai zod tsx
POE_API_KEY=your-key npx tsx poe-repro.ts

Bug

/v1/responses returns invalid output_text for Google models when making tool calls:

{"type": "output_text", "annotations": []}

Missing required text field. Should be:

{"type": "output_text", "text": "", "annotations": []}

Also, top-level text is {} instead of {"format": {"type": "text"}}.

Affects: gemini-3.1-pro, gemini-3-flash, gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash. Not affected: OpenAI models (gpt-5.2, o3, etc.) work correctly.

import { generateText, tool } from "ai";
import { createOpenAI } from "@ai-sdk/openai";
import { z } from "zod";
const poe = createOpenAI({
apiKey: process.env.POE_API_KEY,
baseURL: "https://api.poe.com/v1",
});
// Works fine
const ok = await generateText({
model: poe.responses("gemini-3.1-pro"),
prompt: "Say hello in 3 words",
});
console.log("text:", ok.text);
// Fails: AI_TypeValidationError — expected string, received undefined
// at output[0].content[0].text
const fail = await generateText({
model: poe.responses("gemini-3.1-pro"),
prompt: "What is the weather in SF? Use the getWeather tool.",
tools: {
getWeather: tool({
description: "Get weather",
parameters: z.object({ location: z.string() }),
}),
},
});
console.log("tools:", fail.toolCalls.length);
## How to run
```bash
npm init -y && npm install ai @ai-sdk/openai zod
POE_API_KEY=your-key npx tsx poe-repro.ts
```
## Bug
`/v1/responses` returns invalid `output_text` for Google models when making tool calls:
```json
{"type": "output_text", "annotations": []}
```
Missing required `text` field. Should be:
```json
{"type": "output_text", "text": "", "annotations": []}
```
Also, top-level `text` is `{}` instead of `{"format": {"type": "text"}}`.
Affects: gemini-3.1-pro, gemini-3-flash, gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash.
Not affected: OpenAI models (gpt-5.2, o3, etc.) work correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment