Agent skill · practicalswan
netlify-ai-gateway
Use OpenAI, Anthropic, Google Gemini, or OpenRouter models from Netlify Functions or Edge Functions without managing provider API keys or accounts — the gateway injects credentials automatically. Reach for this when you add an AI chatbot or completion endpoint, generate images or text with Gemini/GPT/Claude, summarize form submissions with AI, build an LLM-backed API route, stream a long AI generation, or wire up any server-side AI provider call on Netlify. Covers provider SDK setup, injected env vars, model availability, rate limits, credit costs, streaming for long generations, and local dev with netlify dev or the Vite plugin.
What it needs
About 7k tokens when loaded.
What this skill does
Netlify AI Gateway Call AI providers from Netlify server-side compute using each provider's official SDK with zero credential config — the gateway injects the API keys and base URLs the SDKs already read. Instantiate the client with no args (except OpenRouter, which needs an explicit base URL). Never do these (they silently fail or cost money): Not browser-callable. The gateway lives in Functions/Edge Functions only. Never call it from client-side React/browser code. Runtime-only credentials. Never call the gateway from build scripts, prerender/SSG, or build plugins — those get no credentials and fail. Do AI work at request time; cache to Netlify Blobs if output must look precomputed. 60s sync timeout. A slow generation in a synchronous function is killed at 60s. Stream it (SDK streaming + ReadableStream), or use a background function that persists output for the client to fetch. Requires a production deploy. The gateway does not activate until the project has at least one production deploy — even in local dev. Don't hardcode model lists. Model availability changes; check the live providers endpoint rather than baking in IDs. Function example File: netlify/functions/joke.js (mkdir -p netlify/functions). Install: npm install openai. Client-side fetch just hits the route: Provider SDKs (modern — instantiate with no args) Each SDK auto-reads the injected env vars. OpenRouter is the exception: its base URL must be passed explicitly. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills practicalswan/netlify-ai-gateway