Getting started

Learn how to quickly set up and start using Prisma Optimize

Prerequisites

Before you begin with Prisma Optimize, ensure you have:

Prisma Optimize is intended for use in local development environments. Learn more in the FAQ.

1. Launch Optimize

  1. Log in to your Prisma Data Platform account
  2. Click the Optimize tab in the left navigation
  3. Click Generate API key
  4. Copy the API key and save it securely
  5. Click through the setup screens until you see Finish & optimize

2. Add Optimize to your application

Install the extension

npm install @prisma/extension-optimize

Add API key to .env

OPTIMIZE_API_KEY="YOUR_OPTIMIZE_API_KEY"

Extend Prisma Client

import { PrismaClient } from "@prisma/client";
import { withOptimize } from "@prisma/extension-optimize";

const prisma = new PrismaClient().$extends(
  withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY })
);

Using with other extensions:

Extensions are applied sequentially. If using Prisma Accelerate, apply it after Optimize:

const prisma = new PrismaClient()
  .$extends(withOptimize())
  .$extends(withAccelerate());

3. Generate insights

  1. In the Optimize dashboard, click Start recording
  2. Run your app and execute Prisma queries
  3. Click Stop recording when done
  4. Explore query details and check the Recommendations tab

Use Prisma AI to understand recommendations and apply them within your Prisma model context.

Next steps

Need help?

Reach out in the #help-and-questions channel on Discord, or connect with our community.

On this page