@neon/skills 2.1.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ It all starts with the `SKILL.md` file in the skill's directory. It's the entry
20
20
 
21
21
  [![neon](https://shieldcn.dev/skills/installs/neondatabase/agent-skills/neon.svg?variant=branded&size=xs&label=neon)](https://skills.sh/neondatabase/agent-skills/neon)
22
22
 
23
- An overview of Neon for apps and agents — Lakebase Postgres, Auth, Data API, Object Storage, Compute Functions, and the AI Gateway — and how to get started. Includes Claimable Neon for use with no Neon account.
23
+ An overview of Neon for apps and agents — Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway — and how to get started. Includes Claimable Neon for use with no Neon account.
24
24
 
25
25
  ### Neon Postgres
26
26
 
@@ -70,6 +70,12 @@ One API and one Neon credential for frontier and open-source LLMs from multiple
70
70
 
71
71
  Long-running, serverless Node.js HTTP functions deployed onto your Neon branch, with `DATABASE_URL` injected automatically and compute that runs next to your data.
72
72
 
73
+ ### Neon Realtime
74
+
75
+ [![neon-realtime](https://shieldcn.dev/skills/installs/neondatabase/agent-skills/neon-realtime.svg?variant=branded&size=xs&label=neon-realtime)](https://skills.sh/neondatabase/agent-skills/neon-realtime)
76
+
77
+ Neon Realtime makes any SQL query live. Build realtime, reactive apps and agents on Lakebase Postgres, with type-safe live queries and optimistic mutations.
78
+
73
79
  ## Installation
74
80
 
75
81
  ```bash
@@ -82,6 +88,22 @@ The repository root is a portable [Agent Plugins v1](https://agent-plugins.org/s
82
88
 
83
89
  The Claude Code and Cursor packaging under `plugins/` remains available for clients that expect those formats.
84
90
 
91
+ ### Antigravity Plugin
92
+
93
+ Antigravity reads its Marketplace metadata from [`.antigravity-plugin/plugin.json`](.antigravity-plugin/plugin.json) and its native Neon MCP Server configuration from [`mcp_config.json`](mcp_config.json). Install the plugin from this repository:
94
+
95
+ ```bash
96
+ agy plugin install https://github.com/neondatabase/agent-skills
97
+ ```
98
+
99
+ Confirm that Antigravity discovered the plugin, its skills, and the MCP server:
100
+
101
+ ```bash
102
+ agy plugin list
103
+ ```
104
+
105
+ To authenticate, run `/mcp` in Antigravity, select the Neon MCP server, and complete the OAuth flow.
106
+
85
107
  ### Claude Code Plugin
86
108
 
87
109
  You can also install the skills as a Claude Code plugin, which bundles the Neon agent skills and the [Neon MCP Server](https://mcp.neon.tech) for natural language database management:
@@ -1,4 +1,4 @@
1
- <svg width="64" height="64" viewBox="-4 -4 72 72" fill="none" xmlns="http://www.w3.org/2000/svg">
1
+ <svg width="256" height="256" viewBox="-4 -4 72 72" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <g clip-path="url(#clip0_329_14442)">
3
3
  <path d="M57.113 7.01415V57.5526L37.5592 40.6076V57.5526H7V7L57.113 7.01415ZM13.1428 51.4168H31.4164V27.1437L50.9705 44.4238V13.1482L13.1428 13.1373V51.4168Z" fill="#37C38F"/>
4
4
  </g>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neon/skills",
3
- "version": "2.1.2",
4
- "description": "Agent Skills for Neon: Lakebase Postgres, branching, Object Storage, Functions, and the AI Gateway",
3
+ "version": "2.3.0",
4
+ "description": "Agent Skills for Neon: Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -37,9 +37,11 @@
37
37
  "scripts": {
38
38
  "prepare": "git config core.hooksPath .githooks || true",
39
39
  "fmt": "prettier --write .",
40
+ "sync:docs": "node scripts/sync-skill-docs.mjs",
40
41
  "sync:plugins": "node scripts/sync-plugin-skills.mjs",
41
42
  "sync:versions": "node scripts/sync-versions.mjs",
42
43
  "validate:agent-plugin": "node scripts/validate-agent-plugin.mjs",
44
+ "validate:antigravity-plugin": "node scripts/validate-antigravity-plugin.mjs",
43
45
  "validate:cursor-plugins": "node scripts/validate-cursor-plugins.mjs",
44
46
  "validate:claude-plugins": "node scripts/validate-claude-plugins.mjs",
45
47
  "validate:plugin-skills": "node scripts/sync-plugin-skills.mjs --check",
@@ -47,7 +49,8 @@
47
49
  "validate:versions": "node scripts/sync-versions.mjs --check",
48
50
  "validate:skills": "node scripts/validate-skills.mjs",
49
51
  "validate:references": "node scripts/check-skill-references.mjs",
50
- "validate:ci": "npm run validate:agent-plugin && npm run validate:plugins && npm run validate:versions && npm run validate:skills && npm run validate:references"
52
+ "validate:skill-docs": "node scripts/sync-skill-docs.mjs --check",
53
+ "validate:ci": "npm run validate:agent-plugin && npm run validate:antigravity-plugin && npm run validate:plugins && npm run validate:versions && npm run validate:skills && npm run validate:references && npm run validate:skill-docs"
51
54
  },
52
55
  "devDependencies": {
53
56
  "prettier": "3.9.6",
package/plugin.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "neon-postgres",
4
- "version": "2.1.2",
5
- "description": "Manage your Neon backend with the Neon agent skills and the Neon MCP Server: Lakebase Postgres, branching, Object Storage, Functions, and the AI Gateway",
4
+ "version": "2.3.0",
5
+ "description": "Manage your Neon backend with the Neon agent skills and the Neon MCP Server: Lakebase Postgres, Managed Better Auth, Realtime, Object Storage, Functions, the Data API, and AI Gateway",
6
6
  "author": {
7
7
  "name": "Neon",
8
8
  "url": "https://neon.com"
@@ -2,23 +2,24 @@
2
2
  name: neon
3
3
  description: >-
4
4
  Overview of Neon, a complete set of cloud backend primitives around Lakebase
5
- Postgres: Auth, Object Storage, Functions, and the AI Gateway. Start here to
5
+ Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to
6
6
  choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or
7
7
  MCP server, and follow the branch-first workflow. Use when building an app or
8
8
  backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child
9
9
  skill neon-postgres wins for an existing DATABASE_URL, SQL, schema, inspect,
10
10
  or search. Child skill neon-auth wins for login, users, sessions, identity
11
- routing, and Managed Better Auth setup. Also use for object storage, S3, buckets, serverless functions,
12
- function triggers, cron, AI gateway, LLM calls, logs, Loki, Grafana,
13
- observability, postgres, database, backend, Claimable Neon, neon.new, or a
14
- no-signup database.
11
+ routing, and Managed Better Auth setup. Child skill neon-realtime wins for
12
+ live queries in reactive apps and agents. Also use for object storage, S3,
13
+ buckets, serverless functions, function triggers, cron, AI gateway, LLM calls,
14
+ realtime, logs, Loki, Grafana, observability,
15
+ postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.
15
16
  metadata:
16
17
  source: https://github.com/neondatabase/agent-skills/tree/main/skills/neon
17
18
  ---
18
19
 
19
20
  # Neon
20
21
 
21
- Neon is a complete set of cloud backend primitives around Lakebase Postgres, from Databricks — Lakebase Postgres, Auth (managed Better Auth), long-running Functions, Object Storage, and an AI Gateway, all instant, branchable, and serverless.
22
+ Neon is a complete set of cloud backend primitives around Lakebase Postgres, from Databricks — Lakebase Postgres, Auth (managed Better Auth), long-running Functions, Object Storage, an AI Gateway, and Realtime live queries, all instant, branchable, and serverless.
22
23
 
23
24
  **Lakebase Postgres** is the database itself. It is one product, reached two ways: through Neon, with a free plan and the full set of backend primitives above, or through Databricks, alongside the rest of the Databricks suite. Same infrastructure, same features, same engineering team. Call the database Lakebase Postgres, and use "Neon" for the brand and for this access path — not as a name for the database.
24
25
 
@@ -35,11 +36,12 @@ Neon bundles several backend primitives for building apps and agents that all br
35
36
  - **Object Storage** — S3-compatible object storage that branches with your projects.
36
37
  - **Functions** — Neon's compute offering: long-running serverless functions that run close to your database, for WebSocket servers, long agent HTTP streams, APIs, and server-sent event servers. A Function Trigger POSTs to a function on a cron.
37
38
  - **AI Gateway** — One API for frontier and open-source models, supporting the chat completions API and the responses API, powered by Databricks Unity AI Gateway.
39
+ - **Realtime** (beta) — Makes any SQL query live. Subscribe in realtime to Lakebase Postgres and build reactive apps and agents with type-safe live queries and optimistic mutations.
38
40
  - **Data API** — Optional PostgREST-compatible HTTP interface. Use it only when the app already uses PostgREST or a Supabase database client, or is migrating that client. New apps query Postgres from Functions or existing handlers. There is no `neon-data-api` skill; configuration is `dataApi` in `neon.ts` (see [Type-safe config](#type-safe-config-invalid-setups-dont-compile) when you have chosen it).
39
41
 
40
42
  ### Region availability
41
43
 
42
- Object Storage, Functions, and AI Gateway are currently available on projects in `aws-us-east-2`, `aws-us-east-1`, `aws-eu-central-1`, and `aws-ap-southeast-1`. Before guiding a user through any of these services, confirm they are working in one of these regions. If not, they will need to create a new project in a supported region.
44
+ Object Storage, Functions, AI Gateway, and Realtime are currently available on projects in `aws-us-east-2`, `aws-us-east-1`, `aws-eu-central-1`, and `aws-ap-southeast-1`. Before guiding a user through any of these services, confirm they are working in one of these regions. If not, they will need to create a new project in a supported region.
43
45
 
44
46
  ## Architecture: How to Use Neon
45
47
 
@@ -63,7 +65,7 @@ Functions have public HTTPS URLs. Verify a JWT or API key at the top of the hand
63
65
 
64
66
  Inspect the repo before provisioning.
65
67
 
66
- 1. Map requested capabilities: login, files, HTTP APIs, LLM calls, SQL.
68
+ 1. Map requested capabilities: login, files, HTTP APIs, LLM calls, live data, SQL.
67
69
  2. Reuse what is already there: a supplied `DATABASE_URL`, an existing ORM or driver, Better Auth, Clerk or another auth provider, S3 or another object store, an existing `.neon` / `neon.ts`, an existing Data API or PostgREST client.
68
70
  3. Select Neon primitives for capabilities that are still undecided.
69
71
  4. Provision only when infrastructure is missing: `neon init` / `neon link` / Claimable, then `neon.ts`, then `neon deploy`.
@@ -81,7 +83,8 @@ New projects are created in AWS regions. Prefer pooled `DATABASE_URL` for applic
81
83
  | Existing Better Auth, Clerk, Supabase Auth, or another working IdP | Keep it. `neon-auth` only if they ask to migrate |
82
84
  | User asked to migrate from Supabase Auth | `neon-auth` (Managed Better Auth; keep `SupabaseAuthAdapter()` call shapes) |
83
85
  | Files, uploads, blobs (no existing object store) | Object Storage |
84
- | HTTP APIs, cron, WebSocket, SSE, long-running agents | Functions querying Postgres |
86
+ | HTTP APIs, cron, custom WebSocket or SSE push, long-running agents | Functions querying Postgres |
87
+ | Live queries for realtime, reactive apps and agents; optimistic mutations | `neon-realtime` (`preview.realtime` in `neon.ts`). Not available on Claimable projects until claimed |
85
88
  | LLM calls | AI Gateway |
86
89
  | SQL, schema, inspect, search | `neon-postgres` |
87
90
  | Existing PostgREST / Supabase database client | Data API (`dataApi` in `neon.ts`) |
@@ -124,6 +127,7 @@ The skills below live in the [`neondatabase/agent-skills`](https://github.com/ne
124
127
  | `neon-object-storage` | Storing and serving files (uploads, images, blobs), including branching them with the database. |
125
128
  | `neon-functions` | Deploying long-running or streaming serverless functions — APIs, agents, SSE/WebSocket servers, and Function Triggers (cron and object-storage). |
126
129
  | `neon-ai-gateway` | Calling an LLM or routing across model providers with one credential, including discovering the branch's servable models at runtime via the OpenAI-compatible `/v1/models` endpoint. |
130
+ | `neon-realtime` | Realtime makes any SQL query live, for realtime, reactive apps and agents: enabling Realtime, sealing queries, React and TanStack DB bindings, SSR, and optimistic mutations. |
127
131
  | `neon-postgres-egress-optimizer` | Diagnosing or fixing excessive Postgres egress (network data-transfer) costs in a codebase. |
128
132
 
129
133
  There is no `neon-data-api` skill. Configure `dataApi` in `neon.ts` only for PostgREST / Supabase database-client compatibility or a migration that already depends on it.
@@ -327,7 +331,7 @@ export default defineConfig({
327
331
 
328
332
  ### Provision services with neon config
329
333
 
330
- Every project ships with Lakebase Postgres; `neon.ts` also declares Auth, Functions, buckets, and the AI Gateway. Data API is a compatibility toggle, not part of a default backend:
334
+ Every project ships with Lakebase Postgres; `neon.ts` also declares Auth, Functions, buckets, and the AI Gateway. Realtime is declared under `preview`. Data API is a compatibility toggle, not part of a default backend:
331
335
 
332
336
  ```typescript
333
337
  // neon.ts
@@ -336,6 +340,7 @@ export default defineConfig({
336
340
  functions: {},
337
341
  buckets: {},
338
342
  aiGateway: true, // see the neon-ai-gateway skill
343
+ preview: { realtime: true }, // see the neon-realtime skill
339
344
  });
340
345
  ```
341
346
 
@@ -38,6 +38,8 @@ export default defineConfig({
38
38
  neon claim create --service auth --service data-api --env-pull
39
39
  ```
40
40
 
41
+ The project is created in `aws-us-east-2` unless you pass `--region-id` (for example `neon claim create --region-id aws-eu-central-1`). Pick the region closest to where the app runs. A project's region cannot change after create.
42
+
41
43
  `neon claim create` reads `neon.ts` when it is present. It writes provisioned vars to an existing `.env`, otherwise `.env.local`, and gitignores that file. If `.env` or `.env.local` already has a `DATABASE_URL` (or other Neon-managed keys), pass `--file <path>` or `--no-env-pull`. The identity assertion is the pre-claim credential.
42
44
 
43
45
  Before claim, Postgres is always granted; Auth and the Data API are granted when requested. Functions, Object Storage, and AI Gateway come back with `granted: false` and `reason: "requires_claim"`. The CLI prints those as `denied_capabilities`. Report what you were given. Do not retry or strip them.
@@ -1,17 +1,19 @@
1
1
  ---
2
2
  name: neon-ai-gateway
3
3
  description: >-
4
- One API and one credential for frontier and open-source LLMs, built into your
5
- Neon branch and powered by Databricks. Use when a user wants to call an LLM,
6
- add AI/chat/an agent to their app, route between model providers (OpenAI,
7
- Anthropic, Google/Gemini, Meta, Alibaba, and more), or avoid juggling
8
- separate provider API keys and accounts — especially when they already use
9
- Neon and want AI requests to branch with their project. Works with the OpenAI
10
- SDK, Anthropic SDK, google-genai, the Vercel AI SDK, and Mastra by changing
11
- only the base URL. Triggers include "call an LLM", "add AI to my app",
12
- "chat completion", "model routing", "LLM proxy/gateway", "one API for all
4
+ One API and one credential for frontier and open-source LLMs and
5
+ embedding models, built into your Neon branch and powered by Databricks.
6
+ Use when a user wants to call an LLM, generate embeddings, add AI/chat/an
7
+ agent to their app, route between model providers (OpenAI, Anthropic,
8
+ Google/Gemini, Meta, Alibaba, and more), or avoid juggling separate
9
+ provider API keys and accounts — especially when they already use Neon
10
+ and want AI requests to branch with their project. Works with the OpenAI
11
+ SDK, Anthropic SDK, google-genai, the Vercel AI SDK, and Mastra by
12
+ changing only the base URL. Triggers include "call an LLM",
13
+ "add AI to my app", "chat completion", "model routing", "LLM proxy/gateway",
14
+ "one API for all
13
15
  models", "use Claude/GPT/Gemini", "AI SDK", "Mastra agent", "Neon AI
14
- Gateway", and "log/rate-limit AI calls".
16
+ Gateway", "generate embeddings", and "log/rate-limit AI calls".
15
17
  metadata:
16
18
  parent: neon
17
19
  source: https://github.com/neondatabase/agent-skills/tree/main/skills/neon-ai-gateway
@@ -29,13 +31,13 @@ neon skills -s neon -y
29
31
 
30
32
  Currently available in `aws-us-east-2`, `aws-us-east-1`, `aws-eu-central-1`, and `aws-ap-southeast-1`.
31
33
 
32
- 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 many providers (Anthropic, OpenAI, Google, Meta, and more), all hosted and powered by Databricks. The catalog shifts over time, so treat `/v1/models` and the [models.dev Neon page](https://models.dev/providers/neon) as the source of truth rather than a fixed provider list. Your existing OpenAI/Anthropic/Gemini SDK works by changing only the base URL.
34
+ 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](https://models.dev/providers/neon) as the source of truth rather than a fixed provider list. For embedding model IDs and dimensions, see the [embeddings guide](https://neon.com/docs/ai-gateway/embeddings). Your existing OpenAI/Anthropic/Gemini SDK works by changing only the base URL.
33
35
 
34
36
  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.
35
37
 
36
38
  ## When to Use
37
39
 
38
- 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:
40
+ 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:
39
41
 
40
42
  - **One credential instead of many provider accounts.** A single Neon credential reaches the entire model catalog across every provider Databricks hosts. No separate OpenAI / Anthropic / Google billing, keys, or signups to provision and rotate.
41
43
  - **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.
@@ -49,7 +51,8 @@ If the user already has a deep, single-provider integration and no interest in N
49
51
  - **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-3-flash`).
50
52
  - **Standard SDKs, one URL change** — OpenAI SDK and AI SDK (OpenAI-compatible MLflow/Responses routes), Anthropic SDK (native Messages), google-genai (native Gemini).
51
53
  - **Branch-scoped** — Each branch gets its own gateway host; the Neon credential authorizes requests for that branch and its descendants.
52
- - **Streaming** — Server-sent events work on all endpoints with no extra configuration.
54
+ - **Streaming** — Chat generation supports server-sent events with no extra configuration.
55
+ - **Embeddings** — Generate vectors for semantic search.
53
56
 
54
57
  ## Availability
55
58
 
@@ -101,7 +104,7 @@ When `aiGateway` is enabled, Neon injects the gateway credentials as **Neon-bran
101
104
 
102
105
  | Variable | Meaning |
103
106
  | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
104
- | `NEON_AI_GATEWAY_TOKEN` | Gateway bearer token (a Neon credential, `nt_live_...`) |
107
+ | `NEON_AI_GATEWAY_TOKEN` | Gateway bearer token (a Neon credential, `nt_live_...`) |
105
108
  | `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` |
106
109
 
107
110
  > Neon injects **only** these two vars — it does **not** set `OPENAI_API_KEY` / `OPENAI_BASE_URL`. The `@neon/ai-sdk-provider` and Mastra's `neon/<model>` read `NEON_AI_GATEWAY_*` directly (zero config); for the plain OpenAI SDK / `@ai-sdk/openai`, build the client's `apiKey` + `baseURL` from them (shown below), or set your own `OPENAI_*` by hand (`env pull` leaves user-set vars untouched).
@@ -177,6 +180,31 @@ const { text } = await generateText({
177
180
 
178
181
  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](https://neon.com/docs/ai/skills/neon-functions/references/ai-sdk.md).
179
182
 
183
+ ## Generate Embeddings with the AI SDK
184
+
185
+ 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:
186
+
187
+ ```typescript
188
+ import { neon } from "@neon/ai-sdk-provider";
189
+ import { embed, embedMany } from "ai";
190
+
191
+ const model = neon.embeddingModel("qwen3-embedding-0-6b");
192
+ const providerOptions = { neon: { dimensions: 1024 } };
193
+ const { embeddings } = await embedMany({
194
+ model,
195
+ values: documentBodies, // unprefixed document text
196
+ providerOptions,
197
+ maxParallelCalls: 1,
198
+ });
199
+ const { embedding } = await embed({
200
+ model,
201
+ value: `Instruct: Given a question about Neon, retrieve documentation passages that answer the question\nQuery: ${queryText}`,
202
+ providerOptions,
203
+ });
204
+ ```
205
+
206
+ 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](https://neon.com/docs/ai/skills/neon-postgres/references/vector-search.md).
207
+
180
208
  ## Build Agents with Mastra (Recommended)
181
209
 
182
210
  [Mastra](https://mastra.ai) 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):
@@ -261,6 +289,7 @@ Any Neon credential (`nt_live_...`) valid for the branch works as the bearer tok
261
289
 
262
290
  **Response shape** — OpenAI/OpenRouter-compatible list:
263
291
 
292
+ <!-- prettier-ignore -->
264
293
  ```jsonc
265
294
  {
266
295
  "object": "list",
@@ -11,11 +11,10 @@ description: >-
11
11
  a cron or an object-storage event that POSTs to a function. Triggers include
12
12
  "serverless function", "deploy an API", "long-running function",
13
13
  "streaming agent", "SSE server", "WebSocket server", "webhook handler",
14
- "MCP server", "cron", "function trigger", "scheduled function", "cron job",
15
- "object storage trigger", "on upload", "run code next to my database",
16
- "function that won't time out", "function logs", "Neon Functions",
17
- "Neon Compute", "DDoS protection", "rate limiting", and
18
- "production hardening".
14
+ "MCP server", "cron", "scheduled function", "object storage trigger",
15
+ "on upload", "function that won't time out", "function logs",
16
+ "Neon Functions", "Neon Compute", "DDoS protection", "rate limiting", and
17
+ "production hardening". For live UIs over database rows, use neon-realtime.
19
18
  metadata:
20
19
  parent: neon
21
20
  source: https://github.com/neondatabase/agent-skills/tree/main/skills/neon-functions
@@ -452,13 +451,15 @@ beat.unref?.();
452
451
 
453
452
  The client skips these when handling messages. There is no protocol-level shortcut here: the standard `WebSocket` from `upgradeWebSocket` has no `ping()`, and a browser can't send ping frames from JavaScript, so an application-level message is the only keepalive a browser client can use. (A Node `ws` client can send ping frames, and the server auto-replies with a pong, but a browser can't.)
454
453
 
455
- ### Keeping clients in sync across isolates (do not skip this)
454
+ ### Fan-out across isolates (do not skip this)
456
455
 
457
456
  Under load the runtime runs **several isolates in parallel, each with its own copy of module state** — so each isolate has its own `clients` set. Broadcasting only to that local set means a client on isolate A never sees an event produced on isolate B, and the feed silently fractures. It's easy to miss: `neon dev` runs a single process (one isolate), so in-process broadcast always _looks_ fine locally but breaks in production, where concurrent connections spread across many isolates.
458
457
 
458
+ If the data is database rows (live dashboards, feeds, chat over stored messages), use Neon Realtime (the `neon-realtime` skill) instead of hand-rolling fan-out. Using Realtime does not prevent your database from scaling to zero. The strategies below are for push that doesn't come from database rows (presence, typing, LLM streams), and the fallback where Realtime isn't available, such as on Claimable projects until they're claimed.
459
+
459
460
  Module state doesn't survive eviction anyway, so **Postgres is the shared source of truth**. Pick a fan-out strategy. In every snippet below, `pool` is a pooled `pg` client and `clients` is this isolate's `Set` of live connections.
460
461
 
461
- **1. Poll Postgres — the default, and the only option that keeps Scale to Zero.** Each isolate re-reads the shared state (or rows past a cursor) on a short interval and pushes changes to its own clients. One query per isolate per tick (not per client), and none when the isolate has no clients — so an idle compute still suspends.
462
+ **1. Poll Postgres — the default, and it keeps Scale to Zero.** Each isolate re-reads the shared state (or rows past a cursor) on a short interval and pushes changes to its own clients. One query per isolate per tick (not per client), and none when the isolate has no clients — so an idle compute still suspends.
462
463
 
463
464
  ```typescript
464
465
  let lastId = "0"; // bigint id, so a string
@@ -495,7 +496,7 @@ pool
495
496
  .finally(() => setInterval(poll, 1000).unref?.());
496
497
  ```
497
498
 
498
- - **Latency:** up to the interval (~1s) — fine for counters, chat, and dashboards.
499
+ - **Latency:** up to the interval (~1s).
499
500
  - **Scaling:** database load grows with the number of live isolates, not clients. Keep the cursor on an indexed `serial`/`bigserial` PK and the interval sane.
500
501
  - **Scale to Zero:** ✅ preserved — polling stops when no clients are connected, so the compute suspends on its normal timer.
501
502
  - **Ordering:** `WHERE id > cursor` can skip a row that commits out of sequence: a transaction that took a lower id but commits after a higher one is already behind the cursor, so the poll never returns it. For a broadcast feed occasional loss is usually fine; when you need every row, use `LISTEN`/`NOTIFY` or poll by `created_at` with a small overlap window and dedupe by id.
@@ -539,7 +540,7 @@ function broadcast(event: unknown) {
539
540
 
540
541
  **3. External pub/sub (e.g. [Upstash](https://upstash.com) Redis) — best at scale.** For high fan-out, sub-second latency at large connection counts, or multi-region, publish/subscribe through a dedicated broker. Highest throughput, and it doesn't touch Postgres or block Scale to Zero — at the cost of another service to run.
541
542
 
542
- **Rule of thumb:** start with **polling** (works with Scale to Zero, no extra infra); switch to `LISTEN`/`NOTIFY` only on always-on compute that needs sub-second latency; move to Redis when fan-out outgrows Postgres.
543
+ **Rule of thumb:** for database rows, use **Neon Realtime**. Otherwise start with **polling** (works with Scale to Zero, no extra infra); switch to `LISTEN`/`NOTIFY` only on always-on compute that needs sub-second latency; move to Redis when fan-out outgrows Postgres.
543
544
 
544
545
  ### Client must reconnect
545
546
 
@@ -569,7 +570,7 @@ async function connect() {
569
570
  connect();
570
571
  ```
571
572
 
572
- Together — `upgradeWebSocket` inside `fetch`, JWT auth over `?token=`, cross-isolate fan-out, and client backoff — these compose into a complete realtime chat backend on a single function.
573
+ Together — `upgradeWebSocket` inside `fetch`, JWT auth over `?token=`, cross-isolate fan-out, and client backoff — these compose into a complete WebSocket backend on a single function, for push that doesn't come from database rows (presence, typing, LLM streams) or where Realtime isn't available. For persisted chat, feeds, and other live UIs over database rows, use Neon Realtime (the `neon-realtime` skill).
573
574
 
574
575
  ## Server-Sent Events (SSE)
575
576
 
@@ -605,7 +606,7 @@ export default {
605
606
  };
606
607
  ```
607
608
 
608
- The same rules as WebSockets apply. **Heartbeat:** a stream stays open only while bytes flow — Neon's window is 15 minutes ([Timeouts and Runtime Limits](#timeouts-and-runtime-limits)) but proxies are usually far stricter, so emit a `: ping\n\n` comment every ~25–30s (shown above) to keep idle streams from being dropped. Keep state in Postgres, and fan out across isolates using one of the [sync strategies](#keeping-clients-in-sync-across-isolates-do-not-skip-this) (hold a `Set` of stream controllers and `enqueue` to each). `EventSource` is GET-only and can't set headers, so authenticate with a `?token=` query param or cookie, exactly like the WebSocket case. [references/sse.md](https://neon.com/docs/ai/skills/neon-functions/references/sse.md) has the full pattern — Hono variant, cross-isolate fan-out, wire format, client, and caveats.
609
+ The same rules as WebSockets apply. **Heartbeat:** a stream stays open only while bytes flow — Neon's window is 15 minutes ([Timeouts and Runtime Limits](#timeouts-and-runtime-limits)) but proxies are usually far stricter, so emit a `: ping\n\n` comment every ~25–30s (shown above) to keep idle streams from being dropped. Keep state in Postgres, and fan out across isolates using one of the [fan-out strategies](#fan-out-across-isolates-do-not-skip-this) (hold a `Set` of stream controllers and `enqueue` to each). `EventSource` is GET-only and can't set headers, so authenticate with a `?token=` query param or cookie, exactly like the WebSocket case. [references/sse.md](https://neon.com/docs/ai/skills/neon-functions/references/sse.md) has the full pattern — Hono variant, cross-isolate fan-out, wire format, client, and caveats.
609
610
 
610
611
  ## Function Triggers
611
612
 
@@ -79,7 +79,7 @@ export default app;
79
79
 
80
80
  ## Push to every client, across isolates
81
81
 
82
- The fan-out rule is identical to WebSockets ([Keeping clients in sync across isolates](../SKILL.md#keeping-clients-in-sync-across-isolates-do-not-skip-this)): each isolate keeps its **own** set of open streams, so broadcasting in-process only reaches the clients on that isolate. Hold a `Set` of stream controllers and pick a strategy there — **poll Postgres** by default (keeps Scale to Zero), or `LISTEN`/`NOTIFY` (shown below) for lowest latency on always-on compute. Keep the source-of-truth state in Postgres — module state doesn't survive eviction.
82
+ If the data is database rows (live dashboards, feeds, chat over stored messages), use Neon Realtime (the `neon-realtime` skill) instead of hand-rolling fan-out. Otherwise, the fan-out rule is identical to WebSockets ([Fan-out across isolates](../SKILL.md#fan-out-across-isolates-do-not-skip-this)): each isolate keeps its **own** set of open streams, so broadcasting in-process only reaches the clients on that isolate. Hold a `Set` of stream controllers and pick a strategy there — **poll Postgres** by default (keeps Scale to Zero), or `LISTEN`/`NOTIFY` (shown below) for lowest latency on always-on compute. Keep the source-of-truth state in Postgres — module state doesn't survive eviction.
83
83
 
84
84
  ```typescript
85
85
  import { attachDatabasePool } from "@neon/functions";
@@ -160,4 +160,4 @@ source.onerror = () => {
160
160
  - **CORS.** A SPA hits the function cross-origin, so set `Access-Control-Allow-Origin`. `EventSource` sends no credentials by default, so `*` is fine for public streams.
161
161
  - **One-way only.** SSE is server → client. For client → server, the browser makes normal `fetch`/`POST` calls (often to the same function); reach for [WebSockets](../SKILL.md#websocket-servers) only when you need bidirectional, low-latency frames.
162
162
 
163
- Together — a Hono `fetch` SSE endpoint, cross-isolate fan-out, heartbeat, a counter persisted in Postgres, and a client-only TanStack Router SPA consuming it with `EventSource` — these compose into a complete realtime backend on a single function.
163
+ Together — a Hono `fetch` SSE endpoint, cross-isolate fan-out, heartbeat, a counter persisted in Postgres, and a client-only TanStack Router SPA consuming it with `EventSource` — these compose into a complete push backend on a single function, for push that doesn't come from database rows (presence, typing, LLM streams) or where Realtime isn't available. For persisted chat, feeds, and other live UIs over database rows, use Neon Realtime (the `neon-realtime` skill).
@@ -1,8 +1,9 @@
1
1
  ---
2
2
  name: neon-object-storage
3
3
  description: >-
4
- S3-compatible object storage that branches with your Neon project, so files
5
- and the database stay in sync across every branch. Use when a user wants
4
+ S3-compatible object storage that branches with your database, so each
5
+ branch gets its own copy of the files and the rows that point at them.
6
+ Use when a user wants
6
7
  object storage, a bucket, blob/file storage, or somewhere to put uploads,
7
8
  images, documents, avatars, or user-generated files for their app or agent —
8
9
  especially when they already use (or are setting up) Lakebase Postgres and don't
@@ -29,7 +30,7 @@ neon skills -s neon -y
29
30
 
30
31
  Currently available in `aws-us-east-2`, `aws-us-east-1`, `aws-eu-central-1`, and `aws-ap-southeast-1`.
31
32
 
32
- Neon Object Storage is S3-compatible object storage that branches with your projects: every branch gets its own isolated storage state, so files and database rows stay in sync across dev, preview, staging, and production.
33
+ Neon Object Storage is S3-compatible file storage built into your Neon project. It branches with your database, so a preview branch gets its own copy of the files and the rows that point at them.
33
34
 
34
35
  Use this skill to help the user store and serve files that branch alongside their database. Deliver a working bucket and upload/download flow, a branch-aware S3 client wired to the injected env vars, or a precise answer from the official Neon docs.
35
36
 
@@ -38,7 +39,7 @@ Use this skill to help the user store and serve files that branch alongside thei
38
39
  Reach for Neon Object Storage for the files an app and its users produce — uploads, attachments, avatars, images, documents, generated assets, backups. It is the default place to put them when the app is already on Neon:
39
40
 
40
41
  - **They already use Lakebase Postgres and don't want a second provider.** One backend, one bill, one CLI, one set of branches — instead of standing up and wiring a separate AWS S3 / R2 / Supabase Storage account. The same Neon credential that backs the database backs storage.
41
- - **Files must stay in sync with the database across environments.** Storage branches _together with_ your Postgres data. Fork a branch and the child instantly inherits the parent's buckets and objects at that point in time — copy-on-write, so no data is duplicated. This is what makes agent, dev, preview, and test environments seamless: a preview branch gets a consistent snapshot of _both_ the rows and the files they reference, and writes on the child never touch the parent.
42
+ - **Files must branch with the database across environments.** Storage branches _together with_ your Postgres data. Fork a branch and the child instantly inherits the parent's buckets and objects at that point in time — copy-on-write, so no data is duplicated. This is what makes agent, dev, preview, and test environments seamless: a preview branch gets a consistent snapshot of _both_ the rows and the files they reference, and writes on the child never touch the parent.
42
43
  - **They want safe, throwaway environments.** Upload, overwrite, and delete files in a preview/CI branch without any risk to production data, then drop the branch.
43
44
  - **They want standard S3 tooling.** It's built on S3 semantics and speaks the S3 API, so the AWS SDKs, `boto3`, the AWS CLI, and presigned URLs all work — reliable and familiar, with no proprietary client.
44
45
 
@@ -6,7 +6,8 @@ description: >-
6
6
  scale-to-zero, instant restore, read replicas, IP allow lists, logical
7
7
  replication, and Lakebase Search. Use when the work is an existing
8
8
  DATABASE_URL, SQL, schema, inspect, or search. New backends, Auth, files,
9
- Functions, and LLM calls go to the parent `neon` skill. Also use for
9
+ Functions, and LLM calls go to the parent `neon` skill. Live queries, reactive
10
+ UIs, and realtime data go to `neon-realtime`. Also use for
10
11
  "@neondatabase/serverless", "@neondatabase/neon-js", "neon inspect db",
11
12
  "semantic search", "vector search", "full-text search", "BM25", or
12
13
  "hybrid search".
@@ -31,6 +32,8 @@ It is the same database whether you reach it through Neon or through Databricks;
31
32
 
32
33
  Login, users, sessions, and `@neondatabase/auth` belong in `neon-auth`.
33
34
 
35
+ Live queries, reactive UIs, and realtime data belong in `neon-realtime`.
36
+
34
37
  ## Setup Flow
35
38
 
36
39
  ### 1. Select the organization and project
@@ -257,7 +260,7 @@ Link: https://neon.com/docs/guides/logical-replication-guide.md
257
260
 
258
261
  Use Lakebase Search for semantic, full-text, and hybrid search:
259
262
 
260
- - For semantic search, read [Vector search](references/vector-search.md).
263
+ - For semantic search, including generating embeddings with the Neon AI Gateway, read [Vector search](references/vector-search.md).
261
264
  - For full-text search with BM25 ranking, read [Full-text search](references/full-text-search.md).
262
265
  - For combining semantic and lexical results, read [Hybrid search](references/hybrid-search.md).
263
266
  - For managing any of the above through Drizzle ORM, read [Managing Lakebase Search with Drizzle](references/lakebase-search-drizzle.md).
@@ -45,18 +45,24 @@ After a large bulk load, run `VACUUM` to refresh the statistics used by BM25 sco
45
45
  `to_bm25query` binds the query `tsvector` to the BM25 index whose corpus statistics should be used. The `<@>` operator returns a negative BM25 score, so lower (more negative) values are more relevant and must sort ascending:
46
46
 
47
47
  ```sql
48
- SELECT
49
- id,
50
- title,
51
- body_tsv <@> to_bm25query(
52
- to_tsvector('english', $1),
53
- 'documents_body_bm25'::regclass
54
- ) AS score
55
- FROM documents
48
+ SELECT id, title, score
49
+ FROM (
50
+ SELECT
51
+ id,
52
+ title,
53
+ body_tsv <@> to_bm25query(
54
+ to_tsvector('english', $1),
55
+ 'documents_body_bm25'::regclass
56
+ ) AS score
57
+ FROM documents
58
+ ) AS keyword_scored
59
+ WHERE score < 0
56
60
  ORDER BY score
57
61
  LIMIT $2;
58
62
  ```
59
63
 
64
+ Scalar BM25 scoring returns zero for documents containing none of the query terms. Filter `score < 0` before `ORDER BY` and `LIMIT` so keyword results exclude non-matches under both sequential and index plans. Partial query-term matches remain eligible.
65
+
60
66
  Use the same text-search configuration for document and query vectors. Select a language-specific or custom configuration that matches the corpus.
61
67
 
62
68
  ## Set the Candidate Limit
@@ -72,15 +78,19 @@ BEGIN;
72
78
  SET LOCAL lakebase_bm25.default_limit = 20;
73
79
  SET LOCAL lakebase_bm25.prefilter = on;
74
80
 
75
- SELECT
76
- id,
77
- title,
78
- body_tsv <@> to_bm25query(
79
- to_tsvector('english', $1),
80
- 'documents_body_bm25'::regclass
81
- ) AS score
82
- FROM documents
83
- WHERE id % 1000 = 0
81
+ SELECT id, title, score
82
+ FROM (
83
+ SELECT
84
+ id,
85
+ title,
86
+ body_tsv <@> to_bm25query(
87
+ to_tsvector('english', $1),
88
+ 'documents_body_bm25'::regclass
89
+ ) AS score
90
+ FROM documents
91
+ WHERE id % 1000 = 0
92
+ ) AS keyword_scored
93
+ WHERE score < 0
84
94
  ORDER BY score
85
95
  LIMIT $2;
86
96
  COMMIT;
@@ -18,13 +18,13 @@ CREATE TABLE documents (
18
18
  id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
19
19
  title text NOT NULL,
20
20
  body text NOT NULL,
21
- embedding vector(1536),
21
+ embedding vector(1024),
22
22
  body_tsv tsvector GENERATED ALWAYS AS
23
23
  (to_tsvector('english', body)) STORED
24
24
  );
25
25
  ```
26
26
 
27
- Replace `1536` with the embedding model's dimension. Use the same model and preprocessing for stored-document and query embeddings, and choose a PostgreSQL text-search configuration appropriate for the corpus.
27
+ The 1024-dimensional column is an example. Set it to the output dimension of your selected embedding model. Generate document embeddings in batches and embed each query with the same model and dimensions; [Vector search](vector-search.md#prepare-embeddings) shows the AI Gateway calls. Follow any model-specific query instructions, while keeping the original query text for BM25. Choose a PostgreSQL text-search configuration appropriate for the corpus.
28
28
 
29
29
  Create and validate each retriever independently before combining them. Follow [Vector search](vector-search.md) and [Full-text search](full-text-search.md) for their indexes, query operators, and tuning.
30
30
 
@@ -34,7 +34,7 @@ Reciprocal Rank Fusion (RRF) is the approach in the Lakebase Search get-started
34
34
 
35
35
  For rank `r` and constant `k`, each retriever contributes `1 / (k + r)`. The documented starting point uses 40 candidates per retriever and `k = 60`; tune both for the corpus and workload.
36
36
 
37
- Bind the query embedding as `$1`, query text as `$2`, and final result count as `$3`:
37
+ Embed the query text through the same gateway model used for the stored documents, then bind that vector as `$1`, the original query text as `$2`, and the final result count as `$3`:
38
38
 
39
39
  ```sql
40
40
  WITH vector_ranked AS (
@@ -49,15 +49,19 @@ WITH vector_ranked AS (
49
49
  keyword_ranked AS (
50
50
  SELECT id, RANK() OVER (ORDER BY score) AS rank
51
51
  FROM (
52
- SELECT
53
- id,
54
- body_tsv <@> to_bm25query(
55
- to_tsvector('english', $2),
56
- 'documents_body_bm25'::regclass
57
- ) AS score
58
- FROM documents
59
- ORDER BY score
60
- FETCH FIRST 40 ROWS WITH TIES
52
+ SELECT id, score
53
+ FROM (
54
+ SELECT
55
+ id,
56
+ body_tsv <@> to_bm25query(
57
+ to_tsvector('english', $2),
58
+ 'documents_body_bm25'::regclass
59
+ ) AS score
60
+ FROM documents
61
+ ) AS keyword_scored
62
+ WHERE score < 0
63
+ ORDER BY score, id
64
+ LIMIT 40
61
65
  ) AS keyword_candidates
62
66
  )
63
67
  SELECT
@@ -73,13 +77,13 @@ ORDER BY rrf_score DESC, d.id
73
77
  LIMIT $3;
74
78
  ```
75
79
 
76
- `RANK()` gives tied retrieval scores the same rank. Sort by `rrf_score` descending and use the stable ID as a final tie-breaker.
80
+ `score < 0` excludes BM25 non-matches. Many matching documents can share a BM25 score, so `WITH TIES` could admit a large group at the cutoff. `ORDER BY score, id LIMIT 40` keeps keyword candidates bounded and breaks boundary ties by ID. `RANK()` uses score alone so retained ties receive equal ranks.
77
81
 
78
- `FETCH FIRST ... ROWS WITH TIES` keeps every candidate tied at the cutoff, so `RANK()` receives the complete boundary tie group. The candidate set can therefore exceed 40 rows. `lakebase_bm25.default_limit` defaults to `1000`; increase it only when the BM25 candidate set needs to exceed that value.
82
+ Vector retrieval preserves cutoff ties and can exceed 40 candidates. `lakebase_bm25.default_limit` defaults to `1000`; the SQL limit bounds keyword rows entering fusion, not total scoring work.
79
83
 
80
84
  ## Adapt the Hybrid Search
81
85
 
82
- - Retrieve more candidates from each source than the final result count; otherwise one retriever can dominate before fusion has enough overlap. Keep `lakebase_bm25.default_limit` above the BM25 candidate target and allow room for boundary ties.
86
+ - Retrieve more candidates from each source than the final result count; otherwise one retriever can dominate before fusion has enough overlap. Keep `lakebase_bm25.default_limit` at least as large as the BM25 candidate target.
83
87
  - Keep each retriever's operator and index configuration correct independently before tuning RRF.
84
88
  - Tune candidate counts and the RRF constant with judged or behavioral relevance data, plus latency measurements.
85
89
  - Add weights only when product evidence shows one retriever should contribute more. Weight the reciprocal-rank contributions, not the raw vector distance and negative BM25 score.