HELP: Runtime Error: A.string is not a function at (@ai-sdk/gateway)

The ai/react import is failing to load in the v0 environment.

Prompt to recreat the issue:

Create a Next.js chatbot app using the Vercel AI SDK with the following:1. A chat interface with a sidebar that displays AI responses2. Use streamText() from the AI SDK in an API route at /api/chat3. Pass model strings like “openai/gpt-4o” directly to streamText (not model objects)4. Also create a component generation feature that uses generateObject() with Zod schemas5. The generateObject should also receive model strings like "anthropic/claude-sonnet-4.5"6. Use the useChat hook from ‘ai/react’ on the client side7. Include error handling that catches and displays AI SDK errorsMake sure to:- Import streamText and generateObject from ‘ai’- Pass model as a string parameter (e.g., model: “openai/gpt-4o”)- Don’t create any provider instances manually- Let the AI SDK handle gateway routing automatically

1 Like

If you’re trying to use the AI SDK react hooks, the correct imports look like this

import { useChat } from '@ai-sdk/react'

1 Like

That is exactly how I have been using it: import { useChat } from “@ai-sdk/react”

It was working fine until yesterday and since this morning, the error message started poppping up.

Hi Jacob, I can share an example with you if that helps

I got the same error while using the Gemini 2.5 Flash model. It has been inoperable since yesterday. It is only able to run when I pull the GitHub repository and run the dev environment on my PC.

Runtime Error: e.number is not a function at (@ai-sdk/google)

I’ve seen this for the last 3 days, on a supabase edge function . It likely appearing from as dependency from some other package, that needs to update.

So you can fixed it by pinning the version of ai-gateway you need by hard-coding the dependency version you want. On the edge function you do this by adding it to the deno.json file.
For the a client app, you’d add it to your npm package.json

Edge Function
supabase/functions/{function-name}/deno.json
```
{
“compilerOptions”: {

“lib”: [“deno.ns”, “dom”],

“imports”: {

“ai”: “https://esm.sh/ai”,

@ai-sdkai-sdkai-sdkai-sdk/anthropic”: “https://esm.sh/@ai-sdk/anthropi@ai-sdkai-sdk”,

@ai-sdk/google”: “https://esm.sh/@ai-sdk@ai-sdkai-sdkgoogle”,

@ai-sdk/openai”: “https://esm.sh/@@ai-sdkai-sdki-sdk/openai”,

@ai-sdk/toget@ai-sdkerai”: “https://@ai-sdksm.sh@ai-sdk@ai-sdk/togetherai”,

@ai-sdk/gateway”: “https://esm.sh/@ai-sdk/gateway@1.0.39”,

}
}
```

This should be fixed now, it was related to a dependency mismatch in a new version of Zod that was released (and used by AI SDK Gateway) that was different from the version used by the rest of v0

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.