NE

neon-ai-gateway

A unified inference endpoint providing access to multiple LLM providers through a single Neon credential.

Install

mkdir -p .claude/skills/neon-ai-gateway && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16884" && unzip -o skill.zip -d .claude/skills/neon-ai-gateway && rm skill.zip

Installs to .claude/skills/neon-ai-gateway

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

One 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), or...
286 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Route LLM requests to various model providers
  • Manage a single credential for multiple LLM providers
  • Switch between LLM models by changing a model field
  • Isolate AI requests to specific development branches
  • Access frontier and open-source models through one API

How it works

The Neon AI Gateway acts as an LLM inference layer built into a Neon branch, providing a unified API and credential for accessing multiple frontier and open-source models. It allows standard SDKs to work by changing only the base URL and model field.

Inputs & outputs

You give it
LLM inference request
You get back
LLM response from a selected model

When to use neon-ai-gateway

  • Integrate AI chat into an application
  • Route calls between different model providers
  • Simplify model provider credential management

About this skill

Neon AI Gateway

This is a preview 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.

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.

When to Use

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:

  • 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.
  • 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.
  • 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.
  • 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.

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.

What It Does

  • 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).
  • Standard SDKs, one URL change — OpenAI SDK and AI SDK (OpenAI-compatible MLflow/Responses routes), Anthropic SDK (native Messages), google-genai (native Gemini).
  • Branch-scoped — Each branch gets its own gateway host; the Neon credential authorizes requests for that branch and its descendants.
  • Streaming — Server-sent events work on all endpoints with no extra configuration.

Setup

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:

// neon.ts
import { defineConfig } from "@neon/config/v1";

export default defineConfig({
  preview: {
    aiGateway: true,
  },
});
neon deploy   # provisions the gateway on the linked branch

Neon Infrastructure as Code (neon.ts)

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:

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. Provisioning (config apply / deploy), link, and checkout also pull the branch's gateway credentials into your local .env.local, so local runs hit the same branch gateway as the deployed function (no manual env pull needed).

For typed, validated access to the injected credentials, pass the same config object to parseEnv from @neon/env — it returns an env.aiGateway namespace (apiKey, baseUrl) derived from your neon.ts.

Environment variables

When preview.aiGateway is enabled, Neon injects the gateway credentials as OpenAI-standard env vars (so the OpenAI SDK and AI SDK work from the environment with no config), plus NEON_-branded aliases. 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):

VariableMeaning
OPENAI_API_KEYGateway bearer token (a Neon credential, nt_live_...)
OPENAI_BASE_URLFull OpenAI-dialect route, including /ai-gateway/openai/v1: https://<branch-id>-api.ai.<region>.aws.neon.tech/ai-gateway/openai/v1
NEON_AI_GATEWAY_TOKENSame bearer as OPENAI_API_KEY (survives a user overriding OPENAI_* with their own keys)
NEON_AI_GATEWAY_BASE_URLBare branch gateway host (scheme://host, no path — no /ai-gateway): https://<branch-id>-api.ai.<region>.aws.neon.tech

The two base URLs are different: OPENAI_BASE_URL already includes the full /ai-gateway/openai/v1 (Responses) route, while NEON_AI_GATEWAY_BASE_URL is just the bare host, so you append /ai-gateway/<dialect> yourself (this is also what the @neon/ai-sdk-provider does for you). The routes under the host are:

  • /ai-gateway/mlflow/v1 — unified, OpenAI Chat Completions-compatible; recommended default, works with every provider.
  • /ai-gateway/openai/v1 — OpenAI Responses API (required for gpt-5-…-codex variants and gpt-5-5-pro). This is the route OPENAI_BASE_URL already points at, because the @ai-sdk/openai provider uses the Responses API by default.
  • /ai-gateway/anthropic/v1 — native Anthropic Messages (extended thinking, prompt caching).
  • /ai-gateway/gemini/v1beta/... — native Gemini generateContent.

So ${NEON_AI_GATEWAY_BASE_URL}/ai-gateway/mlflow/v1 is the chat-completions endpoint, ${NEON_AI_GATEWAY_BASE_URL}/ai-gateway/openai/v1 equals OPENAI_BASE_URL, and so on. If you only have OPENAI_BASE_URL and need chat completions, swap the dialect: baseUrl.replace("/openai/v1", "/mlflow/v1") (this is what the Mastra example does).

For typed access, parseEnv (from @neon/env) returns env.aiGateway (apiKey, baseUrl) derived from your neon.ts.

Build agents with the Vercel AI SDK (recommended)

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.

On a Neon Function that streams text and generates images, the @ai-sdk/openai provider reads OPENAI_API_KEY and OPENAI_BASE_URL from the injected env automatically — no client config needed; just pick a catalog model:

import { openai } from "@ai-sdk/openai";
import { streamText } from "ai";

const result = streamText({
  model: openai("gpt-5-mini"),
  messages,
  tools: {
    image_generation: openai.tools.imageGeneration({
      outputFormat: "jpeg",
      size: "1024x1024",
    }),
  },
});
return result.toUIMessageStreamResponse();

For multi-provider routing from a single call, the dedicated @neon/ai-sdk-provider reads NEON_AI_GATEWAY_BASE_URL + NEON_AI_GATEWAY_TOKEN and routes each model to the best endpoint (Anthropic → Messages, OpenAI/Codex → Responses, everything else → MLflow):

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-2-5-flash, ...
  prompt: "Summarize Postgres for me.",
});

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.

Build agents with Mastra (recommended)

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. A memory-backed agent (threads/messages in Post


Content truncated.

When not to use it

  • When a user has a deep, single-provider integration and no interest in Neon branching
  • When a user has a deep, single-provider integration and no interest in multi-model routing

Limitations

  • The AI Gateway is a preview feature available only on new projects in the us-east-2 region.
  • It cannot be enabled on existing projects.
  • Foundation model access requires a paid Neon plan.

How it compares

This gateway simplifies LLM integration by offering a single API and credential for multiple providers, unlike managing individual accounts and SDKs for each model.

Compared to similar skills

neon-ai-gateway side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
neon-ai-gateway (this skill)01moReviewIntermediate
mcp-builder1364moReviewAdvanced
langchain269moReviewIntermediate
mcp-integration219moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

langchain

zechenzhangAGI

Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.

26138

mcp-integration

anthropics

This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.

21123

opencode-orchestrator-creator

IgorWarzocha

Creates universal OpenCode orchestrator folder structure with specialized agent that can manage swarm servers via curl commands

8104

claude-opus-4-5-migration

anthropics

Migrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5. Use when the user wants to update their codebase, prompts, or API calls to use Opus 4.5. Handles model string updates and prompt adjustments for known Opus 4.5 behavioral differences. Does NOT migrate Haiku 4.5.

9101

mcp-management

mrgoonie

Manage Model Context Protocol (MCP) servers - discover, analyze, and execute tools/prompts/resources from configured MCP servers. Use when working with MCP integrations, need to discover available MCP capabilities, filter MCP tools for specific tasks, execute MCP tools programmatically, access MCP prompts/resources, or implement MCP client functionality. Supports intelligent tool selection, multi-server management, and context-efficient capability discovery.

6100

Search skills

Search the agent skills registry