Teams switch from Aurora Serverless to Neon for better performance and 80% less costs. Read more
AI

Why we built @neondatabase/toolkit

Because AI Agents need especially terse APIs.

We recently published a package on NPM called @neondatabase/toolkit (@neon/toolkit on JSR). The idea behind it was to merge the already existing @neondatabase/api-client and @neondatabase/serverless packages into a single SDK that is easier for AI agents to consume.

AI agents do better when their search space is less wide.

For example:

If these agents had to support a bunch of different frontend frameworks, or various storage providers, they wouldn’t work as well. This might become less relevant in the future as the models get better, but just like specialized software engineers can generally outperform generic engineers when operating with their comfort stack, the same might be true for all AI agents going forward.

Neon already has unique features perfect for AI agents, but we realized that a simple JavaScript script to launch and connect to a Postgres instance required two dependencies:

import { createApiClient } from "@neondatabase/api-client"; 
import { neon } from "@neondatabase/serverless"; 

const apiClient = createApiClient({
  apiKey: process.env.NEON_API_KEY!,
});

const {
  data: { connection_uris },
} = await apiClient.createProject({
  project: {},
});

await neon(
  connection_uris[0].connection_uri
)`CREATE TABLE users (id uuid, name text)`;

So, with @neondatabase/toolkit, we’ve narrowed down the API to make it easier for AI agents to consume it:

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);

Since you can access the underlying toolkit.apiClient, you can already perform any action from the Neon API. However, we’ll be streamlining more features through the higher-level API such as branching and autoscaling configuration. Furthermore, we’ll soon expose an easier way for consumers to dictate whether they wish to connect via HTTP, WebSockets or good old TCP. (The default will continue to be HTTP.)

Building Agents? Try it. Join us.

Call for Design Partners

We are iterating quickly on Neon for Agents and we need feedback. If you're building an Agent that interacts with DB's, let us know here.

Please file an issue in the repository, or reach out to us via Discord to give us any feedback. We’re especially interested in enabling AI agents with this package, but we know that other use cases will emerge as well, and that’s fine!