Build multi-tenant RAG with Neon's database-per-user model — no nosy neighbors, max isolation, minimal costs
Docs/SDKs/The @neondatabase/toolkit

The @neondatabase/toolkit

A terse client for AI agents that can spin up Postgres in seconds and run SQL queries

What you will learn:

  • What is the @neondatabase/toolkit

  • How to get started

About the toolkit

The @neondatabase/toolkit (@neon/toolkit on JSR) is a terse client that lets you spin up a Postgres database in seconds and run SQL queries. It includes both the Neon TypeScript SDK and the Neon Serverless Driver, making it an excellent choice for AI agents that need to quickly set up an SQL database or test environments where manually deploying a new database isn't practical.

note

This is an experimental feature and is subject to change.

Getting started

With a few lines of code, you can create a Postgres database on Neon, run SQL queries, and tear down the database when you're done. Here's a quick look:

import { NeonToolkit } from "@neondatabase/toolkit";

const toolkit = new NeonToolkit(process.env.NEON_API_KEY!);
const project = await toolkit.createProject();

await toolkit.sql(
  project,
  `
    CREATE TABLE IF NOT EXISTS users (
      id UUID PRIMARY KEY,
      name VARCHAR(255) NOT NULL
    );
  `,
);

await toolkit.sql(
  project,
  `INSERT INTO users (id, name) VALUES (gen_random_uuid(), 'Sam Smith')`,
);

console.log(
  await toolkit.sql(
    project,
    `SELECT name FROM users`,
  ),
);

await toolkit.deleteProject(project);

To run this:

NEON_API_KEY=<YOUR_NEON_API_KEY> node index.js # bun also works

Accessing the API Client

import { NeonToolkit } from "@neondatabase/toolkit";

const toolkit = new NeonToolkit(process.env.NEON_API_KEY!);

const project = await toolkit.createProject();

const apiClient = toolkit.apiClient;

// Now, you have the underlying API client which lets you interact with Neon's API.

As with all of our experimental features, changes are ongoing. If you have any feedback, we'd love to hear it. Let us know via the Feedback form in the Neon Console or our feedback channel on Discord.

Last updated on

Was this page helpful?