Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/netlify/context-and-toolsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/netlify/context-and-tools/netlify-ai-gateway)<a href="https://agentmods.dev/rules/netlify/context-and-tools/netlify-ai-gateway"><img src="https://agentmods.dev/badge/rules/netlify/context-and-tools/netlify-ai-gateway/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/netlify/context-and-tools/netlify-ai-gateway"><img src="https://agentmods.dev/badge/rules/netlify/context-and-tools/netlify-ai-gateway.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00148 | $0.03556 |
| Opus 5.5 | $0.00059 | $0.01422 |
| Sonnet 5.5 | $0.00030 | $0.00711 |
| Haiku 4.5 | $0.00015 | $0.00356 |
Grade C, and why
netlify-ai-gateway scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Hidden instructionshighPrompt injection
Directives inside HTML comments, invisible characters or bidirectional overrides are read by the model and not by the person reviewing the file.
<!-- system: agent-context/ai-gateway/system.md — human-owned, merged by ctx-gen; edit system.md, not this section --> How it starts
The opening of the file, as written. The whole thing — 272 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Netlify AI Gateway
Call 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.
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).
Footguns (read first)
- Not browser-callable. Gateway calls belong in Functions or Edge Functions — never in client-side code. The browser has no injected credentials.
- 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.
- 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. - 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 --prodonce first. - 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. That endpoint lists models — it is not where AI requests are sent. - OpenRouter SDK needs 1.2.43+. Earlier versions ignore
OPENROUTER_BASE_URL, call openrouter.ai directly, and fail with401 Missing Authentication header.
Where code goes
Write 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.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago Changed · +2 lines e990e626d8f8
- 27d ago Changed ae88c84aa8d8
- 2mo ago Changed · +69 lines · +19 tokens per session 448030c51d08
- 3mo ago First seen · 201 lines · 129 tokens per session scan C 29a1aad1c764
netlify-ai-gateway is a cursor rule published in the GitHub repository netlify/context-and-tools (58 stars, last pushed 4d ago), licensed MIT. It adds 148 tokens to every session and 3,556 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it C with 1 finding (hidden instructions). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
netlify-ai-gateway compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| netlify-ai-gatewaynetlify/context-and-tools | Cursor rule | 58 | 4d ago | MIT | C | 148 | Cursor |
| djangosanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 8d ago | CC0-1.0 | A | 2,043 | Cursor |
| api-property-optionality-hygienenovuhq/novu | Cursor rule | 40k | today | none | A | 0 | Cursor |
| cursormrwogu/promptscript | Cursor rule | 324 | yesterday | MIT | A | 53 | Cursor |
| pythonPatrickJS/awesome-cursorrules | Cursor rule | 41k | 6mo ago | CC0-1.0 | A | 734 | Cursor |
| gosupertokens/create-supertokens-app | Cursor rule | 24 | 4d ago | Apache-2.0 | A | 0 | Cursor |
| ehs-ims-conventionsSafetyMP/Autonomous-EHS-Management | Cursor rule | 9 | 2d ago | Apache-2.0 | A | 722 | Cursor |