netlify-ai-gateway

Call OpenAI, Anthropic, Gemini, and OpenRouter models from Netlify Functions without managing API keys.

Updated May 19, 2026
One-click install
npx skills add https://github.com/costrict-plugins-repo/anthropic-netlify-skills --skill netlify-ai-gateway-costrict-plugins-repo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: netlify-ai-gateway
Source: https://github.com/costrict-plugins-repo/anthropic-netlify-skills/tree/main/codex/skills/netlify-ai-gateway
Command: npx skills add https://github.com/costrict-plugins-repo/anthropic-netlify-skills --skill netlify-ai-gateway-costrict-plugins-repo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires openai, @anthropic-ai/sdk, @google/genai, @openrouter/sdk, @netlify/vite-plugin.

What problem does it solve? Adding AI capabilities to a Netlify site normally requires creating provider accounts, managing API keys, and configuring credentials for every environment. This Skill shows how to call OpenAI, Anthropic, Google Gemini, and OpenRouter models from Netlify Functions and Edge Functions using each provider's official SDK with zero credential configuration, since the gateway injects API keys and base URLs automatically. ## Core Features & Use Cases - Zero-config provider SDKs: Instantiate OpenAI, Anthropic, Gemini, or OpenRouter clients with no arguments; the gateway injects the environment variables each SDK reads. - Production constraints handled: Covers the 60-second synchronous timeout (stream long generations or use background functions), runtime-only credentials (never call from build scripts or SSG), and the requirement of at least one production deploy. - Cost and rate limit guidance: Documents per-plan credit rate limits, token-to-credit pricing, and Zero Data Retention model availability. - Use Case: Build an AI chatbot endpoint at /api/joke that streams GPT-5 responses, or a function that summarizes Netlify form submissions with Claude, all without storing any provider keys. ## Quick Start Ask the agent to create a Netlify Function that calls the OpenAI SDK with no arguments and returns a JSON response from a routed endpoint.

Frequently Asked Questions about netlify-ai-gateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call OpenAI from a Netlify Function without an API key?

Install the openai package and instantiate the client with no arguments inside a Netlify Function. The AI Gateway injects OPENAI_API_KEY and OPENAI_BASE_URL automatically, so the SDK authenticates without any credential configuration.

Which AI providers does the Netlify AI Gateway support?

The gateway supports OpenAI, Anthropic, Google Gemini, and OpenRouter through their official SDKs. OpenRouter access also unlocks models from xAI, DeepSeek, Meta, Mistral, and Qwen, subject to Zero Data Retention availability.

Can I call the Netlify AI Gateway from browser or client-side code?

No, the gateway is only reachable from Netlify Functions and Edge Functions. Client-side code should fetch a function route such as /api/joke, and the function makes the provider call server-side.

Why does my AI Gateway call fail during build or prerendering?

Gateway credentials are injected only at function runtime, never during builds, prerendering, or SSG. Move AI work to request time, and cache results in Netlify Blobs if the output must appear precomputed.

How do I handle AI generations longer than 60 seconds on Netlify?

Synchronous functions are killed at 60 seconds, so stream long generations using SDK streaming with ReadableStream, or run them in a background function that persists output for the client to fetch later.

Does the Netlify AI Gateway work in local development?

Yes, via netlify dev from the Netlify CLI or the @netlify/vite-plugin in your Vite config. Both paths still require the project to have at least one production deploy before the gateway activates.