diff --git a/src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx b/src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx index bd18fa2fb39a548..8931c75192fe631 100644 --- a/src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx +++ b/src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx @@ -35,6 +35,18 @@ const anthropic = createAnthropic({ }); ``` +### Google AI Studio + +If you're using the Google AI Studio provider in AI SDK, you need to append `/v1beta` to your Google AI Studio-compatible AI Gateway URL to avoid errors. The `/v1beta` path is required because Google AI Studio's API includes this in its endpoint structure, and the AI SDK sets the model name separately. This ensures compatibility with Google's API versioning. + +```typescript +import { createGoogleGenerativeAI } from '@ai-sdk/google'; + +const google = createGoogleGenerativeAI({ + baseURL: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-ai-studio/v1beta`, +}); +``` + ### Other providers For other providers that are not listed above, you can follow a similar pattern by creating a custom instance for any AI provider, and passing your AI Gateway URL. For help finding your provider-specific AI Gateway URL, refer to the [Supported providers page](/ai-gateway/providers).