Provides a unified API and credential for calling frontier and open-source LLMs and embedding models through Neon, powered by Databricks. Works with OpenAI, Anthropic, Google, and Vercel AI SDKs by changing the base URL. Useful for adding AI/chat/agents to apps, routing between model providers, and generating embeddings or images.
Ships in neon. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
FIRST: Use the parent neon skill for a Neon overview, getting started with Neon, Neon development best practices, and more.
If the neon skill is not installed, fetch it from https://neon.com/docs/ai/skills/neon/SKILL.md or install it with:
neon skills -s neon -y
Currently available in aws-us-east-2, aws-us-east-1, aws-eu-central-1, and aws-ap-southeast-1.
The Neon AI Gateway brings LLM and embedding inference to your Neon branch. One API and one Neon credential give you access to frontier and open-source models from many providers (Anthropic, OpenAI, Google, Meta, and more), plus embedding models, all hosted and powered by Databricks. The catalog shifts over time, so treat /v1/models and the models.dev Neon page as the source of truth rather than a fixed provider list. For embedding model IDs and dimensions, see the embeddings guide. Your existing OpenAI/Anthropic/Gemini SDK works by changing only the base URL.
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.
Reach for the AI Gateway whenever an app or agent needs to call an LLM or generate text embeddings and the user would rather not manage model providers themselves:
model field to move between Claude, GPT, and Gemini. Standard SDKs (OpenAI, Anthropic, google-genai) work with just a base-URL change.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.
claude-sonnet-4-6, gpt-5-mini, gemini-3-flash).Check these preconditions before setting anything up:
The AI Gateway is currently available in aws-us-east-2, aws-us-east-1, aws-eu-central-1, and aws-ap-southeast-1. Confirm the user's project is in one of these regions.
The AI Gateway is available on every Neon plan, including Free, and draws down prepaid AI Gateway credits. On the Free plan, the user adds a payment card and buys credits on the Billing page; the organization stays on Free. Any account with prepaid credits can call every model in the catalog, with no difference in pricing or model access between plans. See https://neon.com/docs/ai-gateway/prepaid-credits.md.
The AI Gateway is credential-gated rather than a provisioning step. On every plan, neon env pull resolves the branch credential and writes NEON_AI_GATEWAY_BASE_URL and NEON_AI_GATEWAY_TOKEN when neon.ts declares aiGateway or there is no neon.ts. With aiGateway declared, neon config apply / deploy, neon link, and neon checkout write them too. Whether the account can serve a model is decided per request:
GET /v1/models with enabled: false, unavailable_reason: "paid_plan_required", and a recovery_url pointing at the organization's Billing page, and a request returns 403 with the same unavailable_reason. Despite the name, the fix is adding a card and buying credits, not upgrading the plan. neon env pull (and the env pull bundled into apply / deploy / checkout) warns when no model is enabled, names the reason, and links the recovery_url.neon env pull also warns when some models are enabled but no flagship model (e.g. Anthropic Opus, OpenAI Codex / *-pro) is among them, and links to the branch's AI Gateway page in the Neon Console (https://console.neon.tech/app/projects/<project-id>/branches/<branch-id>/ai-gateway). That page lists locked models under Some models are restricted, grouped by reason, each with its fix: Add a card and buy credits, Add credits for prepaid credits, or Support for an account restriction or a model not available to the account. After the user buys credits, models unlock once Neon confirms access. No CLI warning does not mean every model is enabled; check the model's enabled value. See https://neon.com/docs/ai-gateway/troubleshooting.md.neon 8.23.3 and earlier refuse aiGateway on a Free plan with "isn't available on the Free plan". Update with npm i -g neon@latest (8.23.4 or later) and re-run.The gateway is part of neon.ts (see the neon skill for the branch-first workflow and neon.ts basics). Enable it with aiGateway:
// neon.ts
import { defineConfig } from "@neon/config/v1";
export default defineConfig({
aiGateway: true,
});
neon deploy # provisions the gateway on the linked branch
neon.ts)The 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:
neon config status # print the branch's live config (is the gateway on?)
neon config plan # dry-run diff of what apply would change
neon config apply # enable the gateway on the branch (neon deploy is an alias)
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. When neon.ts declares aiGateway, provisioning (config apply / deploy), link, and checkout also pull the branch's gateway credentials into your local env file (.env if it exists, otherwise .env.local), so local runs hit the same branch gateway as the deployed function (no manual env pull needed).
When aiGateway is enabled, Neon injects the gateway credentials as Neon-branded env vars. Inside a deployed Neon Function these are injected automatically; locally, neon env pull writes them to .env/.env.local (or use neon-env run -- <cmd> to inject at runtime without a file):
| Variable | Meaning |
|---|---|
NEON_AI_GATEWAY_TOKEN | Gateway bearer token (a Neon credential, nt_live_...) |
NEON_AI_GATEWAY_BASE_URL | Bare branch gateway host (scheme://host, no path — no /ai-gateway): https://<branch-id>-api.ai.<region>.aws.neon.tech |
Neon injects only these two vars — it does not set
OPENAI_API_KEY/OPENAI_BASE_URL. The@neon/ai-sdk-providerand Mastra'sneon/<model>readNEON_AI_GATEWAY_*directly (zero config); for the plain OpenAI SDK /@ai-sdk/openai, build the client'sapiKey+baseURLfrom them (shown below), or set your ownOPENAI_*by hand (env pullleaves user-set vars untouched).
NEON_AI_GATEWAY_BASE_URL is the bare host — you append the dialect path yourself (which is exactly what the @neon/ai-sdk-provider does for you). The routes under the host are:
/v1 — unified, OpenAI Chat Completions-compatible; recommended default, works with every provider (/v1/chat/completions)./openai/v1 — OpenAI Responses API (required for gpt-5-…-codex variants and gpt-5-5-pro); the @ai-sdk/openai provider uses the Responses API by default (/openai/v1/responses)./anthropic — native Anthropic Messages (extended thinking, prompt caching). Give the Anthropic SDK this as its base URL and it appends /v1/messages itself, so the full request path is /anthropic/v1/messages./gemini — native Gemini generateContent. Give google-genai this as its base URL and it appends /v1beta/models/<model>:generateContent itself, so the full request path is /gemini/v1beta/models/<model>:generateContent.So ${NEON_AI_GATEWAY_BASE_URL}/v1 is the chat-completions endpoint and ${NEON_AI_GATEWAY_BASE_URL}/openai/v1 the OpenAI Responses endpoint (both appended by you); for the native Anthropic and Gemini dialects you hand the SDK the shorter /anthropic or /gemini base and it appends the rest. See Use with Plain SDKs below.
For typed, validated access to the injected credentials, pass the same neon.ts config object to parseEnv from @neon/env — it returns an env.aiGateway namespace (apiKey, baseUrl) derived from your config.
The Vercel AI SDK is the recommended way to call the gateway and build agents from TypeScript: one set of primitives (generateText, streamText, tool calling, structured output) over every catalog model, with first-class streaming for the long agent responses Neon Functions are built to host.
The dedicated @neon/ai-sdk-provider reads NEON_AI_GATEWAY_BASE_URL + NEON_AI_GATEWAY_TOKEN from the injected env with zero config and routes each model to the best endpoint (Anthropic → Messages, OpenAI/Codex → Responses, everything else → MLflow). On a Neon Function that streams text and generates images, pick an OpenAI catalog model, since the image tool runs on the Responses route:
import { neon } from "@neon/ai-sdk-provider";
import { streamText } from "ai";
const result = streamText({
model: neon("gpt-5-mini"),
messages,
tools: {
image_generation: neon.tools.imageGeneration({
model: "gpt-image-2",
outputFormat: "jpeg",
size: "1024x1024",
}),
},
});
return result.toUIMessageStreamResponse();
A single completion is the same provider with generateText:
import { neon } from "@neon/ai-sdk-provider";
import { generateText } from "ai";
const { text } = await generateText({
model: neon("claude-haiku-4-5"), // or gpt-5-3-codex, gemini-3-flash, ...
prompt: "Summarize Postgres for me.",
});
Prefer
@neon/ai-sdk-providerover the bare@ai-sdk/openaiopenai(): Neon injects onlyNEON_AI_GATEWAY_*, notOPENAI_*, soopenai()won't pick up the gateway from the env on its own. If you do use@ai-sdk/openai, configure it explicitly withcreateOpenAI({ apiKey: process.env.NEON_AI_GATEWAY_TOKEN, baseURL:${process.env.NEON_AI_GATEWAY_BASE_URL}/openai/v1}).
To build an agent — a model that calls tools in a loop and then answers — add tools and a stopWhen budget. The loop runs in-process, so on a Neon Function it isn't cut off by lambda-style timeouts:
import { neon } from "@neon/ai-sdk-provider";
import { generateText, tool, stepCountIs } from "ai";
import { z } from "zod";
const { text } = await generateText({
model: neon("claude-sonnet-4-6"),
prompt: "How many open todos do I have, and what's the oldest one?",
tools: {
listTodos: tool({
description: "List the user's open todos.",
inputSchema: z.object({}), // AI SDK v5+: `inputSchema`, not `parameters`
execute: async () => db.select().from(todos),
}),
},
stopWhen: stepCountIs(5), // let the model call tools, then summarize
});
For a full AI SDK agent deployed as a Neon Function (streaming, tool calling, image generation, persistence), see the neon-functions skill's references/ai-sdk.md.
Images come from the OpenAI Responses image_generation built-in tool on an OpenAI model, on the /openai/v1/responses route. The gateway has no image model endpoint, so the AI SDK's generateImage() throws NoSuchModelError. Every image request follows two rules:
gpt-image-2, gpt-image-1.5, and gpt-image-1-mini. Set model explicitly on every tool definition, and use gpt-image-2 unless the user asks for another.400: The response content length cannot be greater than 655360 bytes long, and most images are larger than that. Use streamText, never generateText, when the image tool is attached. With the plain OpenAI SDK, pass stream: true to client.responses.create().import { neon } from "@neon/ai-sdk-provider";
import { streamText } from "ai";
const result = streamText({
model: neon("gpt-5-mini"),
prompt: "Generate an image of a red apple on a wooden table",
tools: {
image_generation: neon.tools.imageGeneration({ model: "gpt-image-2" }),
},
});
for await (const part of result.fullStream) {
if (
part.type === "tool-result" &&
!part.dynamic &&
"result" in part.output &&
typeof part.output.result === "string"
) {
const png = Buffer.from(part.output.result, "base64"); // save or upload it
}
}
Use @neon/ai-sdk-provider 1.0.0+ with AI SDK 6+ for embedding calls. neon.embeddingModel() reads the same injected gateway variables as the language models:
import { neon } from "@neon/ai-sdk-provider";
import { embed, embedMany } from "ai";
const model = neon.embeddingModel("qwen3-embedding-0-6b");
const providerOptions = { neon: { dimensions: 1024 } };
const { embeddings } = await embedMany({
model,
values: documentBodies, // unprefixed document text
providerOptions,
maxParallelCalls: 1,
});
const { embedding } = await embed({
model,
value: `Instruct: Given a question about Neon, retrieve documentation passages that answer the question\nQuery: ${queryText}`,
providerOptions,
});
The query instruction is specific to Qwen3 and Neon documentation search; adapt it to the corpus. Documents stay unprefixed. Keep the same model and dimensions for documents and queries, and keep the original query text for BM25. For schema, storage, batch limits, and an OpenAI SDK alternative, follow the neon-postgres skill's vector search guide.
Mastra is the recommended framework when you want batteries-included agents — built-in memory, tools, workflows, and tracing — with the model still pointed at the gateway. With @mastra/core 1.47+, use a neon/<model> magic string; Mastra reads NEON_AI_GATEWAY_BASE_URL and NEON_AI_GATEWAY_TOKEN from the environment (injected by neon deploy when aiGateway is enabled). Use parseEnv only for other declared services (e.g. env.postgres.databaseUrl for @mastra/pg memory):
import { Agent } from "@mastra/core/agent";
import { parseEnv } from "@neon/env";
import config from "../neon";
const env = parseEnv(config);
export const personalAssistant = new Agent({
id: "personal-assistant",
name: "personal-assistant",
instructions:
"You are a warm, concise personal assistant with long-term memory.",
model: "neon/claude-haiku-4-5",
memory, // your Mastra memory store, e.g. @mastra/pg on env.postgres.databaseUrl
});
When you don't need an agent framework — a single completion, an existing provider-SDK integration, or native provider features — call the gateway with the plain SDKs. Neon injects the NEON_AI_GATEWAY_* vars (not OPENAI_*), so set the client's apiKey + baseURL from them. For the OpenAI Responses dialect (/openai/v1):
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
baseURL: `${process.env.NEON_AI_GATEWAY_BASE_URL}/openai/v1`,
});
const res = await client.responses.create({
model: "gpt-5-mini", // swap to claude-sonnet-4-6, gemini-3-flash, ...
input: "What is Neon?",
});
For the unified chat-completions dialect, point baseURL at /v1 instead:
const client = new OpenAI({
apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
baseURL: `${process.env.NEON_AI_GATEWAY_BASE_URL}/v1`,
});
const res = await client.chat.completions.create({
model: "claude-sonnet-4-6",
messages: [{ role: "user", content: "What is Neon?" }],
});
The Anthropic SDK and google-genai work the same way for native provider features — point the Anthropic SDK at ${NEON_AI_GATEWAY_BASE_URL}/anthropic (it appends /v1/messages itself) and google-genai at ${NEON_AI_GATEWAY_BASE_URL}/gemini (it appends /v1beta/models/...).
Use a model's catalog ID directly in the model field — e.g. claude-sonnet-4-6, gpt-5-mini, gemini-3-flash. No provider prefix is needed. To look up the exact identifiers the gateway serves, which underlying model each maps to, and their context windows, pricing, and capabilities, use any of:
neon key)./v1/models)The gateway also exposes the model catalog live from your own branch endpoint, so an app or agent can discover exactly which models this branch serves without hard-coding the list. It is an OpenAI-compatible list endpoint, served only on the unified dialect (/v1):
curl "$NEON_AI_GATEWAY_BASE_URL/v1/models" \
-H "Authorization: Bearer $NEON_AI_GATEWAY_TOKEN"
GET ${NEON_AI_GATEWAY_BASE_URL}/v1/models → 200GET ${NEON_AI_GATEWAY_BASE_URL}/openai/v1/models → 404 (not served on the Responses dialect — use /v1)Getting the credentials for the request. Both values come from the same branch-scoped Neon credential the gateway uses everywhere else — you never manage a provider key:
neon.ts (recommended). Enable aiGateway in neon.ts and run neon deploy (or neon config apply). Provisioning, neon link, and neon checkout pull NEON_AI_GATEWAY_TOKEN + NEON_AI_GATEWAY_BASE_URL into your local env file (.env if it exists, otherwise .env.local); inside a deployed Neon Function they're injected automatically. See Setup and Environment Variables above.neon env pull writes the two vars to .env/.env.local. With a neon.ts, a bare neon env pull includes them only when aiGateway is declared. Without a neon.ts, a bare neon env pull includes them, but the pulls bundled into init, link, and checkout leave them out and remove ones an earlier pull wrote, so run neon env pull again after those commands, or declare aiGateway in neon.ts so every pull keeps them. neon-env run -- <cmd> injects the vars at runtime without a file and needs a neon.ts that declares aiGateway.Any Neon credential (nt_live_...) valid for the branch works as the bearer token; NEON_AI_GATEWAY_BASE_URL is the bare branch host (no path).
Response shape — OpenAI/OpenRouter-compatible list:
{
"object": "list",
"data": [
{
"id": "claude-sonnet-4-6", // catalog model ID — use directly in the `model` field
"canonical_slug": "claude-sonnet-4-6",
"name": "Claude Sonnet 4.6", // human-readable display name
"object": "model",
"owned_by": "anthropic", // provider slug, e.g. anthropic | openai | google | meta | alibaba | databricks | ... (non-exhaustive; read live)
"created": 0,
"enabled": true,
"context_length": null,
"architecture": {
"modality": "text->text",
"input_modalities": ["text"],
"output_modalities": ["text"],
"tokenizer": "Claude", // Claude | Gemini | GPT | "" (empty for open-source)
"instruct_type": null
},
"top_provider": {
"is_moderated": false,
"context_length": null,
"max_completion_tokens": null
},
"pricing": null,
"per_request_limits": null
}
// ... one entry per model in the branch's catalog
]
}
Note:
context_length,pricing, andper_request_limitsare currentlynullandcreatedis0for every entry — for context windows, pricing, and capabilities use the models.dev catalog above. Use/v1/modelswhen you need the live, branch-scoped list of servable model IDs (e.g. to populate a model picker or validate amodelbefore a request), and keep only entries withenabled: true.
The Neon documentation is the source of truth and the AI Gateway is evolving rapidly, so always verify against the official docs. Any doc page can be fetched as markdown by appending .md to the URL or by requesting Accept: text/markdown. Find the right page from the docs index (https://neon.com/docs/llms.txt) and the changelog announcements.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/neon:neon-ai-gatewayfrom neon
neon@bokendell-skills is listed by aaronkendell/skills-marketplace — review the source before installing
npx claudepluginhub aaronkendell/skills-marketplace --plugin neon2 plugins in one repository ship this exact skill · first indexed Nov 19, 2026
7 skills in this plugin
/neonOverview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASE_URL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, a no-signup database, or pairing Neon with Upstash for cache, Redis, rate limiting, queues, or background jobs./neon-authAdd authentication to a new app. Use for "add auth", "add login", Neon Auth (Managed Better Auth), identity routing, sign-up, sign-in, password reset, email OTP, magic links, organizations, phone OTP, OAuth, OAuth server for MCP or third-party OAuth clients, passkeys, MFA, trusted domains, invalid domain, and @neon/auth. No existing identity: default to Managed Better Auth. Keep working Better Auth, Clerk, Supabase Auth, or another IdP. User asked to migrate from Supabase Auth: Managed Better Auth. A required plugin outside Managed support: self-managed Better Auth on a Neon Function or the existing app host. Also use for auth APIs in @neon/neon-js./neon-functionsLong-running, serverless Node.js HTTP functions deployed onto your Neon branch, with DATABASE_URL injected automatically and compute that runs next to your data. Use when a user wants to host an API, an AI agent with long streaming responses, a WebSocket or server-sent-events (SSE) server, a webhook handler, a Discord bot, an MCP server, or any request/response workload that risks timing out on short, lambda-style serverless functions — and wants it to branch with their database. Also use for Function Triggers: a cron or an object-storage event that POSTs to a function. Triggers include "serverless function", "deploy an API", "long-running function", "streaming agent", "SSE server", "WebSocket server", "webhook handler", "MCP server", "cron", "scheduled function", "object storage trigger", "on upload", "function that won't time out", "function logs", "Neon Functions", "Neon Compute", "DDoS protection", "rate limiting", and "production hardening". For live UIs over database rows, use neon-realtime./neon-object-storageS3-compatible object storage that branches with your database, so each branch gets its own copy of the files and the rows that point at them. Use when a user wants object storage, a bucket, blob/file storage, or somewhere to put uploads, images, documents, avatars, or user-generated files for their app or agent — especially when they already use (or are setting up) Lakebase Postgres and don't want to add a separate storage provider like AWS S3, Cloudflare R2, or Supabase Storage. Triggers include "object storage", "bucket", "blob storage", "file storage", "store uploads/images/files", "S3-compatible storage", "presigned URL", "where do I put files", "storage logs", "bucket logs", "CDN in front of object storage", "Neon Object Storage", "Neon Storage", and "storage that branches with my database"./neon-postgresGuides and best practices for working with Lakebase Postgres on Neon: connections, pooled vs direct, schema migrations, branching (including schema-only, reset-from-parent, and branch-per-PR workflows), autoscaling, scale-to-zero, instant restore, read replicas, IP allow lists, logical replication, egress optimization, and Lakebase Search. Use when the work is an existing DATABASE_URL, SQL, schema, inspect, or search. New backends, Auth, files, Functions, and LLM calls go to the parent `neon` skill. Live queries, reactive UIs, and realtime data go to `neon-realtime`. Also use for "@neondatabase/serverless", "@neon/neon-js", "neon inspect db", "neon postgres computes", "Neon branch", "schema-only branch", "reset branch", "branch per PR", high database bills, network transfer or egress, Free plan limits or a compute suspended over quota (SQLSTATE 53000, HTTP 402), SELECT * optimization, query overfetching, "semantic search", "vector search", "full-text search", "BM25", or "hybrid search"./neon-realtimeNeon Realtime makes any SQL query live. Build realtime, reactive apps and agents on Lakebase Postgres with live SQL queries and reactivity primitives. Use when app UI or agent state must update live from database rows (dashboards, feeds, collaboration, multi-user or multi-device sync), for optimistic mutations, or to replace polling or other realtime sync systems. Triggers include "live query", "subscribe", "sync engine", "useLiveQuery", "TanStack DB", "optimistic updates", "@neon/realtime". For push that doesn't come from database rows (presence, typing, LLM streams), use neon-functions.Other plugins' skills for the same job