Created
February 3, 2026 16:10
-
-
Save kamilio/051f655ccb42c6e41f25b028a1b76444 to your computer and use it in GitHub Desktop.
Repro: AI SDK Responses via Poe API (google/nano-banana)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Repro: AI SDK (OpenAI Responses) calling Poe API (google/nano-banana) | |
| // | |
| // Install (in an empty repo): | |
| // npm i ai @ai-sdk/openai | |
| // | |
| // Run: | |
| // node --env-file=.env tests/scripts/repro-responses-google-nano-banana.mjs | |
| // or: | |
| // POE_API_KEY=your_key node tests/scripts/repro-responses-google-nano-banana.mjs | |
| import { generateText } from "ai"; | |
| import { createOpenAI } from "@ai-sdk/openai"; | |
| const apiKey = process.env.POE_API_KEY ?? ""; | |
| if (!apiKey) throw new Error("Missing POE_API_KEY env var."); | |
| const baseURL = "https://api.poe.com/v1"; | |
| const modelId = "nano-banana"; | |
| const prompt = "Say hello in exactly 3 words"; | |
| const fetchWithLogging = async (input, init) => { | |
| const response = await fetch(input, init); | |
| const url = | |
| typeof input === "string" | |
| ? input | |
| : input instanceof URL | |
| ? input.toString() | |
| : input.url; | |
| const requestBody = typeof init?.body === "string" ? init.body : undefined; | |
| console.error(`[request] ${init?.method ?? "GET"} ${url}`); | |
| if (requestBody) console.error(`[request body] ${requestBody}`); | |
| console.error(`[response] ${response.status}`); | |
| console.error(`[response body] ${await response.clone().text()}`); | |
| return response; | |
| }; | |
| const openai = createOpenAI({ baseURL, apiKey, fetch: fetchWithLogging }); | |
| const result = await generateText({ | |
| model: openai.responses(modelId), | |
| prompt, | |
| }); | |
| console.log(result.text); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment