Update to Netlify
Snapshot Nov 19, 2026 · 00:11 UTC · version 1.9.0
Collection source: downloaded plugin package.
Instructions updated for netlify-ai-gateway
Skill instructions — Now says: 'claude-sonnet-5-5', model: 'gpt-6.1-sol', model: 'gemini-3.8-flash', Model IDs above (`gpt-6.1-sol`, `claude-sonnet-5-5`, `gemini-3.8-flash`,...
Observed in instructions or declared skills. Runtime behavior has not been tested.
Up to 3 plugins free · no card required.
All fields and original values.
Skill instructions
Oct 7, 2026 · 00:02 UTC
'claude-sonnet-4-5-20250929', model: 'gpt-5', model: 'gemini-2.5-pro', Model IDs above (`gpt-5`, `claude-sonnet-4-5-20250929`, `gemini-2.5-pro`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint. ...
Nov 19, 2026 · 00:11 UTC
'claude-sonnet-5-5', model: 'gpt-6.1-sol', model: 'gemini-3.8-flash', Model IDs above (`gpt-6.1-sol`, `claude-sonnet-5-5`, `gemini-3.8-flash`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint. ...
Compare saved observations
Download comparison JSONSKILL.md text changes
− removed · + added
--- before +++ after @@ -32,7 +32,7 @@ const anthropic = new Anthropic(); // uses ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL const message = await anthropic.messages.create({ - model: 'claude-sonnet-4-5-20250929', + model: 'claude-sonnet-5-5', max_tokens: 1024, messages: [{ role: 'user', content: 'Hello!' }] }); @@ -44,7 +44,7 @@ const openai = new OpenAI(); // uses OPENAI_API_KEY, OPENAI_BASE_URL const completion = await openai.chat.completions.create({ - model: 'gpt-5', + model: 'gpt-6.1-sol', messages: [{ role: 'user', content: 'Hello!' }] }); ``` @@ -55,7 +55,7 @@ const genAI = new GoogleGenAI({}); // uses GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL const result = await genAI.models.generateContent({ - model: 'gemini-2.5-pro', + model: 'gemini-3.8-flash', contents: 'Hello!' }); ``` @@ -104,7 +104,7 @@ Models available through OpenRouter can be called with either the OpenRouter SDK or the OpenAI SDK using OpenRouter model-ID notation (e.g. `deepseek/deepseek-v4-flash-0731`) — just pass the ID as the `model`. -Model IDs above (`gpt-5`, `claude-sonnet-4-5-20250929`, `gemini-2.5-pro`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint. +Model IDs above (`gpt-6.1-sol`, `claude-sonnet-5-5`, `gemini-3.8-flash`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint. ## Env vars — which to use @@ -138,9 +138,9 @@ try { const client = new OpenAI(); const res = await client.responses.create({ - model: "gpt-5-mini", + model: "gpt-6-luna", input: [{ role: "user", content: "Give me a short dad joke about coffee" }], - reasoning: { effort: "minimal" }, + reasoning: { effort: "none" }, }); return Response.json({ joke: res.output_text?.trim() || "Out of jokes",
Full technical diff · 1 changed fields
changed /skill_md_contents
"---\nname: netlify-ai-gateway\ndescription: Use Netlify AI Gateway to call OpenAI, Anthropic Claude, Google Gemini, TypeSafe (Jev), or OpenRouter-hosted models (xAI/DeepSeek/Meta/Mistral/Qwen) from Netlify Functions or Edge Functions without managing provider accounts or API keys. Reach for this when adding an AI feature to a Netlify app — a chatbot, text summarizer, image generator, joke/content generator, form-submission routing or analysis, or any LLM call — or when wiring the OpenAI/Anthropic/Gemini/TypeSafe/OpenRouter SDK into a Netlify Function, choosing which env vars to use, streaming long generations, or debugging why gateway calls fail at build time or return 401.\n---\n\n# Netlify AI Gateway\n\nCall AI models from Netlify compute using the provider's official SDK. The gateway injects provider credentials automatically — instantiate the SDK with no args and it works.\n\n**Use the provider SDK with injected env credentials.** Do not hand-roll a raw `fetch()` against the gateway URL, and do not wire calls to `NETLIFY_AI_GATEWAY_KEY` / `NETLIFY_AI_GATEWAY_URL` as your default path — those are for third-party/unsupported libraries only (see below).\n\n## Footguns (read first)\n\n- **Not browser-callable.** Gateway calls belong in Functions or Edge Functions — never in client-side code. The browser has no injected credentials.\n- **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.\n- **60-second sync timeout.** A gateway call in a synchronous function is bound by the 60s function timeout. Stream long generations (SDK streaming + `ReadableStream`), or use a background function that persists output for the client to fetch. Never leave a slow generation unstreamed.\n- **Requires one production deploy.** The gateway does not activate until a project has at least one production deploy. Even for local dev, run `netlify deploy --prod` once first.\n- **Don't hardcode model lists.** Available models change. Check the live providers endpoint (`https://api.netlify.com/api/v1/ai-gateway/providers/detailed`) rather than baking in a static list.\n- **OpenRouter SDK needs 1.2.43+.** Earlier versions ignore `OPENROUTER_BASE_URL`, call openrouter.ai directly, and fail with `401 Missing Authentication header`.\n\n## Where code goes\n\nWrite normal Function/handler code — there is no AI-specific file type. A function at `netlify/functions/joke.js` exporting `config = { path: \"/api/joke\" }` is served at `/api/joke` under both `netlify dev` and production.\n\n## Provider SDKs (instantiate with no args)\n\nThe gateway injects each provider's own env vars, so the official SDK works with zero config.\n\nAnthropic Claude:\n```js\nimport Anthropic from '@anthropic-ai/sdk';\nconst anthropic = new Anthropic(); // uses ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL\n\nconst message = await anthropic.messages.create({\n model: 'claude-sonnet-4-5-20250929',\n max_tokens: 1024,\n messages: [{ role: 'user', content: 'Hello!' }]\n});\n```\n\nOpenAI:\n```js\nimport OpenAI from 'openai';\nconst openai = new OpenAI(); // uses OPENAI_API_KEY, OPENAI_BASE_URL\n\nconst completion = await openai.chat.completions.create({\n model: 'gpt-5',\n messages: [{ role: 'user', content: 'Hello!' }]\n});\n```\n\nGoogle Gemini:\n```js\nimport { GoogleGenAI } from '@google/genai';\nconst genAI = new GoogleGenAI({}); // uses GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL\n\nconst result = await genAI.models.generateContent({\n model: 'gemini-2.5-pro',\n contents: 'Hello!'\n});\n```\n\nTypeSafe (Jev) — structured decisions (e.g. routing/classifying form submissions):\n```ts\nimport type { Config, Context } from '@netlify/functions';\nimport { choice, TypeSafeClient } from '@typesafe-ai/sdk';\n\nexport default async (req: Request, context: Context) => {\n const body = await req.json().catch(() => undefined);\n if (body === undefined)\n return Response.json({ error: 'Request body must be valid JSON.' }, { status: 400 });\n\n const client = new TypeSafeClient(); // uses TYPESAFE_API_KEY, TYPESAFE_BASE_URL\n const { answers } = await client.systemOne({\n state: body,\n questions: {\n team: choice('Route this contact form submission', {\n sales: null,\n support: null,\n spam: null,\n }),\n },\n });\n\n return Response.json({ team: answers.team.choice, requestId: context.requestId });\n};\n\nexport const config: Config = { path: '/api/route', method: 'POST' };\n```\n`systemOne` defaults to the `jev-latest` model. Each question is a `choice(prompt, options)` mapping named options to `null`; the result is at `answers.<question>.choice`. POST a JSON body (e.g. `{\"message\":\"Can someone help us upgrade to 200 seats?\"}`) with `Content-Type: application/json`.\n\nOpenRouter (SDK 1.2.43+ required — see footguns):\n```js\nimport { OpenRouter } from '@openrouter/sdk';\nconst openRouter = new OpenRouter(); // uses OPENROUTER_API_KEY, OPENROUTER_BASE_URL\n\nconst result = await openRouter.chat.send({\n chatRequest: {\n model: 'x-ai/grok-4.5',\n messages: [{ role: 'user', content: 'Hello!' }]\n }\n});\n```\n\nModels available through OpenRouter can be called with either the OpenRouter SDK or the OpenAI SDK using OpenRouter model-ID notation (e.g. `deepseek/deepseek-v4-flash-0731`) — just pass the ID as the `model`.\n\nModel IDs above (`gpt-5`, `claude-sonnet-4-5-20250929`, `gemini-2.5-pro`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint.\n\n## Env vars — which to use\n\n**Default:** supported provider SDKs consume their injected provider-specific vars automatically. Instantiate the SDK with no args as shown above (`new OpenAI()`, `new Anthropic()`, `new GoogleGenAI({})`, `new TypeSafeClient()`, `new OpenRouter()`) and the corresponding pair is read for you:\n\n- OpenAI: `OPENAI_API_KEY`, `OPENAI_BASE_URL`\n- Anthropic: `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`\n- Google Gemini: `GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL`\n- OpenRouter: `OPENROUTER_API_KEY`, `OPENROUTER_BASE_URL`\n- TypeSafe: `TYPESAFE_API_KEY`, `TYPESAFE_BASE_URL`\n\n**Explicit-config path:** `NETLIFY_AI_GATEWAY_KEY` and `NETLIFY_AI_GATEWAY_URL` are always injected and never collide with user-set provider vars. Use this pair only when a third-party or unsupported library needs explicit key/base-URL configuration — pass them as constructor arguments. It is not the default; supported SDKs should use their provider-specific vars above.\n\n**Precedence:** Netlify never overrides a key or base URL you set at project or team level. If you set your own provider key, the gateway defers to it. For Gemini specifically, injection is skipped if `GOOGLE_API_KEY` or `GOOGLE_VERTEX_BASE_URL` is set (Vertex/Google-API-key setups win).\n\nTo stop all injection, disable AI Features: https://docs.netlify.com/build/build-with-ai/manage-ai-for-your-team/manage-ai-features/#disable-ai-features\n\n## Full example (Vite + React + Function)\n\nDetect gateway availability by checking for an injected var, then call the SDK.\n\nInstall the client first: `npm install openai`. Then create `netlify/functions/joke.js`:\n```js\nimport process from \"process\";\nimport OpenAI from \"openai\";\n\nexport default async () => {\n if (!process.env.OPENAI_BASE_URL)\n return Response.json({ error: \"AI Gateway not active — deploy to prod once on a credit-based plan\" });\n\n try {\n const client = new OpenAI();\n const res = await client.responses.create({\n model: \"gpt-5-mini\",\n input: [{ role: \"user\", content: \"Give me a short dad joke about coffee\" }],\n reasoning: { effort: \"minimal\" },\n });\n return Response.json({\n joke: res.output_text?.trim() || \"Out of jokes\",\n model: res.model,\n tokens: { input: res.usage.input_tokens, output: res.usage.output_tokens },\n });\n } catch (e) {\n return Response.json({ error: `${e}` }, { status: 500 });\n }\n};\n\nexport const config = { path: \"/api/joke\" };\n```\n\n`src/App.jsx` fetches `/api/joke`:\n```jsx\nimport { useState } from \"react\";\n\nexport default function App() {\n const [joke, setJoke] = useState();\n const [loading, setLoading] = useState(false);\n\n const getJoke = async () => {\n setLoading(true);\n try {\n const res = await fetch(\"/api/joke\");\n setJoke(res.ok ? await res.json() : { error: res.status });\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <>\n <button onClick={getJoke} disabled={loading}>\n {loading ? \"Thinking...\" : \"Get joke\"}\n </button>\n <pre>{JSON.stringify(joke, null, 2)}</pre>\n </>\n );\n}\n```\n\n## Local development\n\nTwo options — both need at least one prior production deploy:\n\n1. **Netlify CLI:** `netlify dev` gives full gateway support.\n2. **Vite plugin:** access the gateway locally without `netlify dev`. Add `@netlify/vite-plugin` and run your native dev command (`npm run dev`):\n```js\n// vite.config.js\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\nimport netlify from \"@netlify/vite-plugin\";\n\nexport default defineConfig({ plugins: [react(), netlify()] })\n```\n\nSetup flow:\n```shell\nnpm install -g netlify-cli@latest\nnetlify login\nnpm create vite@latest dad-jokes -- --template react --no-interactive\ncd dad-jokes && npm install\nnetlify init\nnetlify deploy --prod --open # required: activates the gateway\n```\n\n## Billing, limits, constraints\n\n- **Plans:** Credit-based plans only (Free, Personal, Pro). Enterprise: contact your Account Manager. Legacy plans must switch first. Enabled by default unless you disabled AI Features or set your own provider keys.\n- **Cost:** tokens → USD (provider-published rates) → credits. **$1 USD = 180 credits.**\n- **Rate limits** (per minute, per team, across all projects): Free 90, Personal 450, Pro 1,800, Enterprise 9,000 credits.\n- **Context window:** input limited to 200k tokens.\n- **Prompt caching:** Anthropic — only the default 5-min ephemeral cache; OpenAI — per-account `prompt_cache_key` set for you; Gemini — explicit context caching unsupported.\n- **No pass-through headers** (can't enable header-gated experimental features), **no batch inference**, **no OpenAI priority processing**.\n- **OpenRouter ZDR only:** Netlify routes only to providers with a Zero Data Retention policy. A model listed in the OpenRouter directory but with no ZDR-guaranteeing host is not served. Browse ZDR-eligible models: https://openrouter.ai/models?zdr=true\n- **Privacy:** The gateway does not store prompts or model outputs.\n\n**Cost controls:** Set up rate-limiting rules on AI-calling Functions/Edge Functions to prevent visitor abuse and runaway cost: https://docs.netlify.com/manage/security/secure-access-to-sites/rate-limiting/ — and configure auto-recharge or credit packs: https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/configure-auto-recharge/ · https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/buy-credit-packs/\n\nMonitor usage: https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/monitor-usage-for-credit-based-plans\n\n## References\n\n- Overview: https://docs.netlify.com/build/ai-gateway/overview.md\n- Quickstart: https://docs.netlify.com/build/ai-gateway/quickstart-for-ai-gateway.md\n- Examples: https://docs.netlify.com/build/ai-gateway/examples.md — including the AI SEO Image Generator (Gemini image generation): https://github.com/netlify/examples/tree/main/examples/ai-seo-image-generator and a TanStack Start chat app: https://github.com/netlify-templates/tanstack-template\n\n<!-- Gap: exact directly-served model names (Anthropic/OpenAI/Gemini/TypeSafe) are not statically enumerable — rendered at build time from the live providers endpoint. -->\n\n<!-- system: agent-context/ai-gateway/system.md — human-owned, merged by ctx-gen; edit system.md, not this section -->\n# Netlify house rules (ai-gateway)\n\nThese are org conventions, not docs facts — merged into the rendered skill by\nctx-gen and never generated. Owned by the skills maintainer.\n\n1. Use the provider SDK with the injected env credentials — don't hand-roll\n a raw `fetch()` against the gateway, even though raw REST is a supported\n surface. The body must not present raw REST or the\n `NETLIFY_AI_GATEWAY_KEY` / `NETLIFY_AI_GATEWAY_URL` pair as a\n recommended path — but it MUST still document the pair as facts: always\n injected, never collide with user-set provider vars, and the right choice\n when a third-party or unsupported library needs explicit configuration.\n Demote the recommendation; keep the knowledge.\n2. The gateway is not browser-callable: calls belong in functions or edge\n functions, never client-side code.\n3. Model availability changes: don't hardcode model lists; check the live\n providers endpoint.\n4. Gateway credentials are runtime-only: never call the gateway from build\n scripts, prerender/SSG, or build plugins — those calls get no credentials\n and fail. Do AI work at request time and cache the result (e.g. to\n Netlify Blobs) if it must look precomputed.\n5. Gateway calls in a synchronous function are bound by the 60-second\n timeout: stream long generations (SDK streaming + `ReadableStream`), or\n use a background function that persists output for the client to fetch —\n never leave a slow generation unstreamed and assume it finishes.\n6. When asked which env vars to use — even asked explicitly for the gateway\n pair — open with the default before answering the literal question:\n supported provider SDKs consume their injected provider-specific vars\n (`OPENAI_API_KEY`/`OPENAI_BASE_URL`, etc.) using exactly the per-provider\n instantiation the body shows — restate the body's setup, don't invent\n constructor details here. Then give `NETLIFY_AI_GATEWAY_KEY` /\n `NETLIFY_AI_GATEWAY_URL` as the explicit-config path for third-party\n or unsupported libraries. Answering with the gateway pair alone presents\n hand-wiring as the default, which it is not.\n""---\nname: netlify-ai-gateway\ndescription: Use Netlify AI Gateway to call OpenAI, Anthropic Claude, Google Gemini, TypeSafe (Jev), or OpenRouter-hosted models (xAI/DeepSeek/Meta/Mistral/Qwen) from Netlify Functions or Edge Functions without managing provider accounts or API keys. Reach for this when adding an AI feature to a Netlify app — a chatbot, text summarizer, image generator, joke/content generator, form-submission routing or analysis, or any LLM call — or when wiring the OpenAI/Anthropic/Gemini/TypeSafe/OpenRouter SDK into a Netlify Function, choosing which env vars to use, streaming long generations, or debugging why gateway calls fail at build time or return 401.\n---\n\n# Netlify AI Gateway\n\nCall AI models from Netlify compute using the provider's official SDK. The gateway injects provider credentials automatically — instantiate the SDK with no args and it works.\n\n**Use the provider SDK with injected env credentials.** Do not hand-roll a raw `fetch()` against the gateway URL, and do not wire calls to `NETLIFY_AI_GATEWAY_KEY` / `NETLIFY_AI_GATEWAY_URL` as your default path — those are for third-party/unsupported libraries only (see below).\n\n## Footguns (read first)\n\n- **Not browser-callable.** Gateway calls belong in Functions or Edge Functions — never in client-side code. The browser has no injected credentials.\n- **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.\n- **60-second sync timeout.** A gateway call in a synchronous function is bound by the 60s function timeout. Stream long generations (SDK streaming + `ReadableStream`), or use a background function that persists output for the client to fetch. Never leave a slow generation unstreamed.\n- **Requires one production deploy.** The gateway does not activate until a project has at least one production deploy. Even for local dev, run `netlify deploy --prod` once first.\n- **Don't hardcode model lists.** Available models change. Check the live providers endpoint (`https://api.netlify.com/api/v1/ai-gateway/providers/detailed`) rather than baking in a static list.\n- **OpenRouter SDK needs 1.2.43+.** Earlier versions ignore `OPENROUTER_BASE_URL`, call openrouter.ai directly, and fail with `401 Missing Authentication header`.\n\n## Where code goes\n\nWrite normal Function/handler code — there is no AI-specific file type. A function at `netlify/functions/joke.js` exporting `config = { path: \"/api/joke\" }` is served at `/api/joke` under both `netlify dev` and production.\n\n## Provider SDKs (instantiate with no args)\n\nThe gateway injects each provider's own env vars, so the official SDK works with zero config.\n\nAnthropic Claude:\n```js\nimport Anthropic from '@anthropic-ai/sdk';\nconst anthropic = new Anthropic(); // uses ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL\n\nconst message = await anthropic.messages.create({\n model: 'claude-sonnet-5-5',\n max_tokens: 1024,\n messages: [{ role: 'user', content: 'Hello!' }]\n});\n```\n\nOpenAI:\n```js\nimport OpenAI from 'openai';\nconst openai = new OpenAI(); // uses OPENAI_API_KEY, OPENAI_BASE_URL\n\nconst completion = await openai.chat.completions.create({\n model: 'gpt-6.1-sol',\n messages: [{ role: 'user', content: 'Hello!' }]\n});\n```\n\nGoogle Gemini:\n```js\nimport { GoogleGenAI } from '@google/genai';\nconst genAI = new GoogleGenAI({}); // uses GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL\n\nconst result = await genAI.models.generateContent({\n model: 'gemini-3.8-flash',\n contents: 'Hello!'\n});\n```\n\nTypeSafe (Jev) — structured decisions (e.g. routing/classifying form submissions):\n```ts\nimport type { Config, Context } from '@netlify/functions';\nimport { choice, TypeSafeClient } from '@typesafe-ai/sdk';\n\nexport default async (req: Request, context: Context) => {\n const body = await req.json().catch(() => undefined);\n if (body === undefined)\n return Response.json({ error: 'Request body must be valid JSON.' }, { status: 400 });\n\n const client = new TypeSafeClient(); // uses TYPESAFE_API_KEY, TYPESAFE_BASE_URL\n const { answers } = await client.systemOne({\n state: body,\n questions: {\n team: choice('Route this contact form submission', {\n sales: null,\n support: null,\n spam: null,\n }),\n },\n });\n\n return Response.json({ team: answers.team.choice, requestId: context.requestId });\n};\n\nexport const config: Config = { path: '/api/route', method: 'POST' };\n```\n`systemOne` defaults to the `jev-latest` model. Each question is a `choice(prompt, options)` mapping named options to `null`; the result is at `answers.<question>.choice`. POST a JSON body (e.g. `{\"message\":\"Can someone help us upgrade to 200 seats?\"}`) with `Content-Type: application/json`.\n\nOpenRouter (SDK 1.2.43+ required — see footguns):\n```js\nimport { OpenRouter } from '@openrouter/sdk';\nconst openRouter = new OpenRouter(); // uses OPENROUTER_API_KEY, OPENROUTER_BASE_URL\n\nconst result = await openRouter.chat.send({\n chatRequest: {\n model: 'x-ai/grok-4.5',\n messages: [{ role: 'user', content: 'Hello!' }]\n }\n});\n```\n\nModels available through OpenRouter can be called with either the OpenRouter SDK or the OpenAI SDK using OpenRouter model-ID notation (e.g. `deepseek/deepseek-v4-flash-0731`) — just pass the ID as the `model`.\n\nModel IDs above (`gpt-6.1-sol`, `claude-sonnet-5-5`, `gemini-3.8-flash`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint.\n\n## Env vars — which to use\n\n**Default:** supported provider SDKs consume their injected provider-specific vars automatically. Instantiate the SDK with no args as shown above (`new OpenAI()`, `new Anthropic()`, `new GoogleGenAI({})`, `new TypeSafeClient()`, `new OpenRouter()`) and the corresponding pair is read for you:\n\n- OpenAI: `OPENAI_API_KEY`, `OPENAI_BASE_URL`\n- Anthropic: `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`\n- Google Gemini: `GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL`\n- OpenRouter: `OPENROUTER_API_KEY`, `OPENROUTER_BASE_URL`\n- TypeSafe: `TYPESAFE_API_KEY`, `TYPESAFE_BASE_URL`\n\n**Explicit-config path:** `NETLIFY_AI_GATEWAY_KEY` and `NETLIFY_AI_GATEWAY_URL` are always injected and never collide with user-set provider vars. Use this pair only when a third-party or unsupported library needs explicit key/base-URL configuration — pass them as constructor arguments. It is not the default; supported SDKs should use their provider-specific vars above.\n\n**Precedence:** Netlify never overrides a key or base URL you set at project or team level. If you set your own provider key, the gateway defers to it. For Gemini specifically, injection is skipped if `GOOGLE_API_KEY` or `GOOGLE_VERTEX_BASE_URL` is set (Vertex/Google-API-key setups win).\n\nTo stop all injection, disable AI Features: https://docs.netlify.com/build/build-with-ai/manage-ai-for-your-team/manage-ai-features/#disable-ai-features\n\n## Full example (Vite + React + Function)\n\nDetect gateway availability by checking for an injected var, then call the SDK.\n\nInstall the client first: `npm install openai`. Then create `netlify/functions/joke.js`:\n```js\nimport process from \"process\";\nimport OpenAI from \"openai\";\n\nexport default async () => {\n if (!process.env.OPENAI_BASE_URL)\n return Response.json({ error: \"AI Gateway not active — deploy to prod once on a credit-based plan\" });\n\n try {\n const client = new OpenAI();\n const res = await client.responses.create({\n model: \"gpt-6-luna\",\n input: [{ role: \"user\", content: \"Give me a short dad joke about coffee\" }],\n reasoning: { effort: \"none\" },\n });\n return Response.json({\n joke: res.output_text?.trim() || \"Out of jokes\",\n model: res.model,\n tokens: { input: res.usage.input_tokens, output: res.usage.output_tokens },\n });\n } catch (e) {\n return Response.json({ error: `${e}` }, { status: 500 });\n }\n};\n\nexport const config = { path: \"/api/joke\" };\n```\n\n`src/App.jsx` fetches `/api/joke`:\n```jsx\nimport { useState } from \"react\";\n\nexport default function App() {\n const [joke, setJoke] = useState();\n const [loading, setLoading] = useState(false);\n\n const getJoke = async () => {\n setLoading(true);\n try {\n const res = await fetch(\"/api/joke\");\n setJoke(res.ok ? await res.json() : { error: res.status });\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <>\n <button onClick={getJoke} disabled={loading}>\n {loading ? \"Thinking...\" : \"Get joke\"}\n </button>\n <pre>{JSON.stringify(joke, null, 2)}</pre>\n </>\n );\n}\n```\n\n## Local development\n\nTwo options — both need at least one prior production deploy:\n\n1. **Netlify CLI:** `netlify dev` gives full gateway support.\n2. **Vite plugin:** access the gateway locally without `netlify dev`. Add `@netlify/vite-plugin` and run your native dev command (`npm run dev`):\n```js\n// vite.config.js\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\nimport netlify from \"@netlify/vite-plugin\";\n\nexport default defineConfig({ plugins: [react(), netlify()] })\n```\n\nSetup flow:\n```shell\nnpm install -g netlify-cli@latest\nnetlify login\nnpm create vite@latest dad-jokes -- --template react --no-interactive\ncd dad-jokes && npm install\nnetlify init\nnetlify deploy --prod --open # required: activates the gateway\n```\n\n## Billing, limits, constraints\n\n- **Plans:** Credit-based plans only (Free, Personal, Pro). Enterprise: contact your Account Manager. Legacy plans must switch first. Enabled by default unless you disabled AI Features or set your own provider keys.\n- **Cost:** tokens → USD (provider-published rates) → credits. **$1 USD = 180 credits.**\n- **Rate limits** (per minute, per team, across all projects): Free 90, Personal 450, Pro 1,800, Enterprise 9,000 credits.\n- **Context window:** input limited to 200k tokens.\n- **Prompt caching:** Anthropic — only the default 5-min ephemeral cache; OpenAI — per-account `prompt_cache_key` set for you; Gemini — explicit context caching unsupported.\n- **No pass-through headers** (can't enable header-gated experimental features), **no batch inference**, **no OpenAI priority processing**.\n- **OpenRouter ZDR only:** Netlify routes only to providers with a Zero Data Retention policy. A model listed in the OpenRouter directory but with no ZDR-guaranteeing host is not served. Browse ZDR-eligible models: https://openrouter.ai/models?zdr=true\n- **Privacy:** The gateway does not store prompts or model outputs.\n\n**Cost controls:** Set up rate-limiting rules on AI-calling Functions/Edge Functions to prevent visitor abuse and runaway cost: https://docs.netlify.com/manage/security/secure-access-to-sites/rate-limiting/ — and configure auto-recharge or credit packs: https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/configure-auto-recharge/ · https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/buy-credit-packs/\n\nMonitor usage: https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/monitor-usage-for-credit-based-plans\n\n## References\n\n- Overview: https://docs.netlify.com/build/ai-gateway/overview.md\n- Quickstart: https://docs.netlify.com/build/ai-gateway/quickstart-for-ai-gateway.md\n- Examples: https://docs.netlify.com/build/ai-gateway/examples.md — including the AI SEO Image Generator (Gemini image generation): https://github.com/netlify/examples/tree/main/examples/ai-seo-image-generator and a TanStack Start chat app: https://github.com/netlify-templates/tanstack-template\n\n<!-- Gap: exact directly-served model names (Anthropic/OpenAI/Gemini/TypeSafe) are not statically enumerable — rendered at build time from the live providers endpoint. -->\n\n<!-- system: agent-context/ai-gateway/system.md — human-owned, merged by ctx-gen; edit system.md, not this section -->\n# Netlify house rules (ai-gateway)\n\nThese are org conventions, not docs facts — merged into the rendered skill by\nctx-gen and never generated. Owned by the skills maintainer.\n\n1. Use the provider SDK with the injected env credentials — don't hand-roll\n a raw `fetch()` against the gateway, even though raw REST is a supported\n surface. The body must not present raw REST or the\n `NETLIFY_AI_GATEWAY_KEY` / `NETLIFY_AI_GATEWAY_URL` pair as a\n recommended path — but it MUST still document the pair as facts: always\n injected, never collide with user-set provider vars, and the right choice\n when a third-party or unsupported library needs explicit configuration.\n Demote the recommendation; keep the knowledge.\n2. The gateway is not browser-callable: calls belong in functions or edge\n functions, never client-side code.\n3. Model availability changes: don't hardcode model lists; check the live\n providers endpoint.\n4. Gateway credentials are runtime-only: never call the gateway from build\n scripts, prerender/SSG, or build plugins — those calls get no credentials\n and fail. Do AI work at request time and cache the result (e.g. to\n Netlify Blobs) if it must look precomputed.\n5. Gateway calls in a synchronous function are bound by the 60-second\n timeout: stream long generations (SDK streaming + `ReadableStream`), or\n use a background function that persists output for the client to fetch —\n never leave a slow generation unstreamed and assume it finishes.\n6. When asked which env vars to use — even asked explicitly for the gateway\n pair — open with the default before answering the literal question:\n supported provider SDKs consume their injected provider-specific vars\n (`OPENAI_API_KEY`/`OPENAI_BASE_URL`, etc.) using exactly the per-provider\n instantiation the body shows — restate the body's setup, don't invent\n constructor details here. Then give `NETLIFY_AI_GATEWAY_KEY` /\n `NETLIFY_AI_GATEWAY_URL` as the explicit-config path for third-party\n or unsupported libraries. Answering with the gateway pair alone presents\n hand-wiring as the default, which it is not.\n"Full snapshot data
{
"description": "Use Netlify AI Gateway to call OpenAI, Anthropic Claude, Google Gemini, TypeSafe (Jev), or OpenRouter-hosted models (xAI/DeepSeek/Meta/Mistral/Qwen) from Netlify Functions or Edge Functions without managing provider accounts or API keys. Reach for this when adding an AI feature to a Netlify app — a chatbot, text summarizer, image generator, joke/content generator, form-submission routing or analysis, or any LLM call — or when wiring the OpenAI/Anthropic/Gemini/TypeSafe/OpenRouter SDK into a Netlify Function, choosing which env vars to use, streaming long generations, or debugging why gateway calls fail at build time or return 401.",
"included_files": [],
"name": "netlify-ai-gateway",
"skill_md_contents": "---\nname: netlify-ai-gateway\ndescription: Use Netlify AI Gateway to call OpenAI, Anthropic Claude, Google Gemini, TypeSafe (Jev), or OpenRouter-hosted models (xAI/DeepSeek/Meta/Mistral/Qwen) from Netlify Functions or Edge Functions without managing provider accounts or API keys. Reach for this when adding an AI feature to a Netlify app — a chatbot, text summarizer, image generator, joke/content generator, form-submission routing or analysis, or any LLM call — or when wiring the OpenAI/Anthropic/Gemini/TypeSafe/OpenRouter SDK into a Netlify Function, choosing which env vars to use, streaming long generations, or debugging why gateway calls fail at build time or return 401.\n---\n\n# Netlify AI Gateway\n\nCall AI models from Netlify compute using the provider's official SDK. The gateway injects provider credentials automatically — instantiate the SDK with no args and it works.\n\n**Use the provider SDK with injected env credentials.** Do not hand-roll a raw `fetch()` against the gateway URL, and do not wire calls to `NETLIFY_AI_GATEWAY_KEY` / `NETLIFY_AI_GATEWAY_URL` as your default path — those are for third-party/unsupported libraries only (see below).\n\n## Footguns (read first)\n\n- **Not browser-callable.** Gateway calls belong in Functions or Edge Functions — never in client-side code. The browser has no injected credentials.\n- **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.\n- **60-second sync timeout.** A gateway call in a synchronous function is bound by the 60s function timeout. Stream long generations (SDK streaming + `ReadableStream`), or use a background function that persists output for the client to fetch. Never leave a slow generation unstreamed.\n- **Requires one production deploy.** The gateway does not activate until a project has at least one production deploy. Even for local dev, run `netlify deploy --prod` once first.\n- **Don't hardcode model lists.** Available models change. Check the live providers endpoint (`https://api.netlify.com/api/v1/ai-gateway/providers/detailed`) rather than baking in a static list.\n- **OpenRouter SDK needs 1.2.43+.** Earlier versions ignore `OPENROUTER_BASE_URL`, call openrouter.ai directly, and fail with `401 Missing Authentication header`.\n\n## Where code goes\n\nWrite normal Function/handler code — there is no AI-specific file type. A function at `netlify/functions/joke.js` exporting `config = { path: \"/api/joke\" }` is served at `/api/joke` under both `netlify dev` and production.\n\n## Provider SDKs (instantiate with no args)\n\nThe gateway injects each provider's own env vars, so the official SDK works with zero config.\n\nAnthropic Claude:\n```js\nimport Anthropic from '@anthropic-ai/sdk';\nconst anthropic = new Anthropic(); // uses ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL\n\nconst message = await anthropic.messages.create({\n model: 'claude-sonnet-5-5',\n max_tokens: 1024,\n messages: [{ role: 'user', content: 'Hello!' }]\n});\n```\n\nOpenAI:\n```js\nimport OpenAI from 'openai';\nconst openai = new OpenAI(); // uses OPENAI_API_KEY, OPENAI_BASE_URL\n\nconst completion = await openai.chat.completions.create({\n model: 'gpt-6.1-sol',\n messages: [{ role: 'user', content: 'Hello!' }]\n});\n```\n\nGoogle Gemini:\n```js\nimport { GoogleGenAI } from '@google/genai';\nconst genAI = new GoogleGenAI({}); // uses GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL\n\nconst result = await genAI.models.generateContent({\n model: 'gemini-3.8-flash',\n contents: 'Hello!'\n});\n```\n\nTypeSafe (Jev) — structured decisions (e.g. routing/classifying form submissions):\n```ts\nimport type { Config, Context } from '@netlify/functions';\nimport { choice, TypeSafeClient } from '@typesafe-ai/sdk';\n\nexport default async (req: Request, context: Context) => {\n const body = await req.json().catch(() => undefined);\n if (body === undefined)\n return Response.json({ error: 'Request body must be valid JSON.' }, { status: 400 });\n\n const client = new TypeSafeClient(); // uses TYPESAFE_API_KEY, TYPESAFE_BASE_URL\n const { answers } = await client.systemOne({\n state: body,\n questions: {\n team: choice('Route this contact form submission', {\n sales: null,\n support: null,\n spam: null,\n }),\n },\n });\n\n return Response.json({ team: answers.team.choice, requestId: context.requestId });\n};\n\nexport const config: Config = { path: '/api/route', method: 'POST' };\n```\n`systemOne` defaults to the `jev-latest` model. Each question is a `choice(prompt, options)` mapping named options to `null`; the result is at `answers.<question>.choice`. POST a JSON body (e.g. `{\"message\":\"Can someone help us upgrade to 200 seats?\"}`) with `Content-Type: application/json`.\n\nOpenRouter (SDK 1.2.43+ required — see footguns):\n```js\nimport { OpenRouter } from '@openrouter/sdk';\nconst openRouter = new OpenRouter(); // uses OPENROUTER_API_KEY, OPENROUTER_BASE_URL\n\nconst result = await openRouter.chat.send({\n chatRequest: {\n model: 'x-ai/grok-4.5',\n messages: [{ role: 'user', content: 'Hello!' }]\n }\n});\n```\n\nModels available through OpenRouter can be called with either the OpenRouter SDK or the OpenAI SDK using OpenRouter model-ID notation (e.g. `deepseek/deepseek-v4-flash-0731`) — just pass the ID as the `model`.\n\nModel IDs above (`gpt-6.1-sol`, `claude-sonnet-5-5`, `gemini-3.8-flash`, `x-ai/grok-4.5`, etc.) are examples that change — check the live providers endpoint.\n\n## Env vars — which to use\n\n**Default:** supported provider SDKs consume their injected provider-specific vars automatically. Instantiate the SDK with no args as shown above (`new OpenAI()`, `new Anthropic()`, `new GoogleGenAI({})`, `new TypeSafeClient()`, `new OpenRouter()`) and the corresponding pair is read for you:\n\n- OpenAI: `OPENAI_API_KEY`, `OPENAI_BASE_URL`\n- Anthropic: `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`\n- Google Gemini: `GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL`\n- OpenRouter: `OPENROUTER_API_KEY`, `OPENROUTER_BASE_URL`\n- TypeSafe: `TYPESAFE_API_KEY`, `TYPESAFE_BASE_URL`\n\n**Explicit-config path:** `NETLIFY_AI_GATEWAY_KEY` and `NETLIFY_AI_GATEWAY_URL` are always injected and never collide with user-set provider vars. Use this pair only when a third-party or unsupported library needs explicit key/base-URL configuration — pass them as constructor arguments. It is not the default; supported SDKs should use their provider-specific vars above.\n\n**Precedence:** Netlify never overrides a key or base URL you set at project or team level. If you set your own provider key, the gateway defers to it. For Gemini specifically, injection is skipped if `GOOGLE_API_KEY` or `GOOGLE_VERTEX_BASE_URL` is set (Vertex/Google-API-key setups win).\n\nTo stop all injection, disable AI Features: https://docs.netlify.com/build/build-with-ai/manage-ai-for-your-team/manage-ai-features/#disable-ai-features\n\n## Full example (Vite + React + Function)\n\nDetect gateway availability by checking for an injected var, then call the SDK.\n\nInstall the client first: `npm install openai`. Then create `netlify/functions/joke.js`:\n```js\nimport process from \"process\";\nimport OpenAI from \"openai\";\n\nexport default async () => {\n if (!process.env.OPENAI_BASE_URL)\n return Response.json({ error: \"AI Gateway not active — deploy to prod once on a credit-based plan\" });\n\n try {\n const client = new OpenAI();\n const res = await client.responses.create({\n model: \"gpt-6-luna\",\n input: [{ role: \"user\", content: \"Give me a short dad joke about coffee\" }],\n reasoning: { effort: \"none\" },\n });\n return Response.json({\n joke: res.output_text?.trim() || \"Out of jokes\",\n model: res.model,\n tokens: { input: res.usage.input_tokens, output: res.usage.output_tokens },\n });\n } catch (e) {\n return Response.json({ error: `${e}` }, { status: 500 });\n }\n};\n\nexport const config = { path: \"/api/joke\" };\n```\n\n`src/App.jsx` fetches `/api/joke`:\n```jsx\nimport { useState } from \"react\";\n\nexport default function App() {\n const [joke, setJoke] = useState();\n const [loading, setLoading] = useState(false);\n\n const getJoke = async () => {\n setLoading(true);\n try {\n const res = await fetch(\"/api/joke\");\n setJoke(res.ok ? await res.json() : { error: res.status });\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <>\n <button onClick={getJoke} disabled={loading}>\n {loading ? \"Thinking...\" : \"Get joke\"}\n </button>\n <pre>{JSON.stringify(joke, null, 2)}</pre>\n </>\n );\n}\n```\n\n## Local development\n\nTwo options — both need at least one prior production deploy:\n\n1. **Netlify CLI:** `netlify dev` gives full gateway support.\n2. **Vite plugin:** access the gateway locally without `netlify dev`. Add `@netlify/vite-plugin` and run your native dev command (`npm run dev`):\n```js\n// vite.config.js\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\nimport netlify from \"@netlify/vite-plugin\";\n\nexport default defineConfig({ plugins: [react(), netlify()] })\n```\n\nSetup flow:\n```shell\nnpm install -g netlify-cli@latest\nnetlify login\nnpm create vite@latest dad-jokes -- --template react --no-interactive\ncd dad-jokes && npm install\nnetlify init\nnetlify deploy --prod --open # required: activates the gateway\n```\n\n## Billing, limits, constraints\n\n- **Plans:** Credit-based plans only (Free, Personal, Pro). Enterprise: contact your Account Manager. Legacy plans must switch first. Enabled by default unless you disabled AI Features or set your own provider keys.\n- **Cost:** tokens → USD (provider-published rates) → credits. **$1 USD = 180 credits.**\n- **Rate limits** (per minute, per team, across all projects): Free 90, Personal 450, Pro 1,800, Enterprise 9,000 credits.\n- **Context window:** input limited to 200k tokens.\n- **Prompt caching:** Anthropic — only the default 5-min ephemeral cache; OpenAI — per-account `prompt_cache_key` set for you; Gemini — explicit context caching unsupported.\n- **No pass-through headers** (can't enable header-gated experimental features), **no batch inference**, **no OpenAI priority processing**.\n- **OpenRouter ZDR only:** Netlify routes only to providers with a Zero Data Retention policy. A model listed in the OpenRouter directory but with no ZDR-guaranteeing host is not served. Browse ZDR-eligible models: https://openrouter.ai/models?zdr=true\n- **Privacy:** The gateway does not store prompts or model outputs.\n\n**Cost controls:** Set up rate-limiting rules on AI-calling Functions/Edge Functions to prevent visitor abuse and runaway cost: https://docs.netlify.com/manage/security/secure-access-to-sites/rate-limiting/ — and configure auto-recharge or credit packs: https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/configure-auto-recharge/ · https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/buy-credit-packs/\n\nMonitor usage: https://docs.netlify.com/manage/accounts-and-billing/billing/billing-for-credit-based-plans/monitor-usage-for-credit-based-plans\n\n## References\n\n- Overview: https://docs.netlify.com/build/ai-gateway/overview.md\n- Quickstart: https://docs.netlify.com/build/ai-gateway/quickstart-for-ai-gateway.md\n- Examples: https://docs.netlify.com/build/ai-gateway/examples.md — including the AI SEO Image Generator (Gemini image generation): https://github.com/netlify/examples/tree/main/examples/ai-seo-image-generator and a TanStack Start chat app: https://github.com/netlify-templates/tanstack-template\n\n<!-- Gap: exact directly-served model names (Anthropic/OpenAI/Gemini/TypeSafe) are not statically enumerable — rendered at build time from the live providers endpoint. -->\n\n<!-- system: agent-context/ai-gateway/system.md — human-owned, merged by ctx-gen; edit system.md, not this section -->\n# Netlify house rules (ai-gateway)\n\nThese are org conventions, not docs facts — merged into the rendered skill by\nctx-gen and never generated. Owned by the skills maintainer.\n\n1. Use the provider SDK with the injected env credentials — don't hand-roll\n a raw `fetch()` against the gateway, even though raw REST is a supported\n surface. The body must not present raw REST or the\n `NETLIFY_AI_GATEWAY_KEY` / `NETLIFY_AI_GATEWAY_URL` pair as a\n recommended path — but it MUST still document the pair as facts: always\n injected, never collide with user-set provider vars, and the right choice\n when a third-party or unsupported library needs explicit configuration.\n Demote the recommendation; keep the knowledge.\n2. The gateway is not browser-callable: calls belong in functions or edge\n functions, never client-side code.\n3. Model availability changes: don't hardcode model lists; check the live\n providers endpoint.\n4. Gateway credentials are runtime-only: never call the gateway from build\n scripts, prerender/SSG, or build plugins — those calls get no credentials\n and fail. Do AI work at request time and cache the result (e.g. to\n Netlify Blobs) if it must look precomputed.\n5. Gateway calls in a synchronous function are bound by the 60-second\n timeout: stream long generations (SDK streaming + `ReadableStream`), or\n use a background function that persists output for the client to fetch —\n never leave a slow generation unstreamed and assume it finishes.\n6. When asked which env vars to use — even asked explicitly for the gateway\n pair — open with the default before answering the literal question:\n supported provider SDKs consume their injected provider-specific vars\n (`OPENAI_API_KEY`/`OPENAI_BASE_URL`, etc.) using exactly the per-provider\n instantiation the body shows — restate the body's setup, don't invent\n constructor details here. Then give `NETLIFY_AI_GATEWAY_KEY` /\n `NETLIFY_AI_GATEWAY_URL` as the explicit-config path for third-party\n or unsupported libraries. Answering with the gateway pair alone presents\n hand-wiring as the default, which it is not.\n"
}SHA-256 of public snapshot: 6e7838d793e4c9e6523c9246db8b3be7afc114ce8faf8db021cdc332ad13b5de