$npx -y skills add neondatabase/agent-skills --skill neon-ai-gatewayOne API and one credential for frontier and open-source LLMs, built into your Neon branch and powered by Databricks. Use when a user wants to call an LLM, add AI/chat/an agent to their app, route between model providers (OpenAI, Anthropic, Google/Gemini, Meta, Alibaba, DeepSeek),
| 1 | # Neon AI Gateway |
| 2 | |
| 3 | This is a public beta feature and only available in `us-east-2`. The Neon AI Gateway is the LLM inference layer built into your Neon branch: one API and one Neon credential give you access to frontier and open-source models from Anthropic, OpenAI, Google, Meta, Alibaba, DeepSeek, and Databricks — powered by Databricks. Your existing OpenAI/Anthropic/Gemini SDK works by changing only the base URL. |
| 4 | |
| 5 | Use this skill to help the user send model calls through the gateway, wire it into the AI SDK or Mastra, and switch providers without rewiring code. Deliver a working inference request, a configured agent, or a precise answer from the official Neon docs. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | Reach for the AI Gateway whenever an app or agent needs to call an LLM and the user would rather not manage model providers themselves: |
| 10 | |
| 11 | - **One credential instead of many provider accounts.** A single Neon credential reaches the entire model catalog across seven providers. No separate OpenAI / Anthropic / Google billing, keys, or signups to provision and rotate. |
| 12 | - **Switch models without rewiring.** The unified endpoint is OpenAI-compatible and works with every model in the catalog — change one `model` field to move between Claude, GPT, and Gemini. Standard SDKs (OpenAI, Anthropic, google-genai) work with just a base-URL change. |
| 13 | - **AI follows your branches.** Each branch has its own gateway endpoint, scoped with the same lineage as your database. AI requests from a preview/feature branch are isolated to that branch — the same isolation your data already gets — which makes preview, CI, and agent environments self-contained. |
| 14 | - **No extra infrastructure, and it's already next to your data.** The gateway lives inside your Neon project (and is injected into Neon Functions automatically), runs on the same Databricks infrastructure that serves trillions of tokens a month, and supports streaming (SSE) out of the box. |
| 15 | |
| 16 | If the user already has a deep, single-provider integration and no interest in Neon branching or multi-model routing, a direct provider SDK is fine — but the moment they want one credential, model portability, or branch-scoped AI, this is the reason to use it. |
| 17 | |
| 18 | ## What It Does |
| 19 | |
| 20 | - **One API for all models** — Frontier and open-source models behind a single endpoint, addressed by their catalog ID (e.g. `claude-sonnet-4-6`, `gpt-5-mini`, `gemini-2-5-flash`). |
| 21 | - **Standard SDKs, one URL change** — OpenAI SDK and AI SDK (OpenAI-compatible MLflow/Responses routes), Anthropic SDK (native Messages), google-genai (native Gemini). |
| 22 | - **Branch-scoped** — Each branch gets its own gateway host; the Neon credential authorizes requests for that branch and its descendants. |
| 23 | - **Streaming** — Server-sent events work on all endpoints with no extra configuration. |
| 24 | |
| 25 | ## Setup |
| 26 | |
| 27 | The gateway is part of `neon.ts` (see the `neon` skill for the branch-first workflow and `neon.ts` basics). Enable it under `preview.aiGateway`: |
| 28 | |
| 29 | ```typescript |
| 30 | // neon.ts |
| 31 | import { defineConfig } from "@neon/config/v1"; |
| 32 | |
| 33 | export default defineConfig({ |
| 34 | preview: { |
| 35 | aiGateway: true, |
| 36 | }, |
| 37 | }); |
| 38 | ``` |
| 39 | |
| 40 | ```bash |
| 41 | neon deploy # provisions the gateway on the linked branch |
| 42 | ``` |
| 43 | |
| 44 | ## Neon Infrastructure as Code (`neon.ts`) |
| 45 | |
| 46 | The `preview.aiGateway` toggle above is part of `neon.ts`, Neon's infrastructure-as-code file — one TypeScript file declares the gateway alongside every other branch service, in version control (see the `neon` skill for the full reference). Reconcile it against a branch the Terraform way: |
| 47 | |
| 48 | ```bash |
| 49 | neon config status # print the branch's live config (is the gateway on?) |
| 50 | neon config plan # dry-run diff of what apply would change |
| 51 | neon config apply # enable the gateway on the branch (neon deploy is an alias) |
| 52 | ``` |
| 53 | |
| 54 | The gateway is **branch-scoped**: each branch gets its own gateway host. When a `neon.ts` is present, `neon checkout` applies the policy as it _creates_ a branch, so a fresh preview/CI branch comes up with the gateway already enabled. Checking out an _existing_ branch doesn't reconcile it — run `neon deploy` to apply changes. Provisioning (`config apply` / `deploy`), `link`, and `checkout` also pull the branch's gat |