# Generating Prisma Client (/docs/orm/prisma-client/setup-and-configuration/generating-prisma-client)

Location: ORM > Prisma Client > Setup and Configuration > Generating Prisma Client

`prisma generate` creates Prisma Client from the models and generator configuration in your `schema.prisma` file.

Define a generator [#define-a-generator]

In Prisma ORM v7, the `output` field is required:

```prisma title="schema.prisma"
generator client {
  provider = "prisma-client"
  output   = "./generated"
}
```

Generate the client [#generate-the-client]

Run the following command whenever you add models, change fields, or update generator settings:

  

#### npm

```bash
npx prisma generate
```

#### pnpm

```bash
pnpm dlx prisma generate
```

#### yarn

```bash
yarn dlx prisma generate
```

#### bun

```bash
bunx --bun prisma generate
```

If you want the CLI-specific options such as `--watch` or `--generator`, see the [`prisma generate` command reference](/cli/generate).

Import the generated client [#import-the-generated-client]

Import Prisma Client from the output path you configured:

```ts
import { PrismaClient } from "./generated/client";

const prisma = new PrismaClient();
```

When to run generate [#when-to-run-generate]

You should run `prisma generate` after:

* changing your Prisma schema
* updating generator configuration
* enabling features that affect the client API
* pulling schema changes from another branch or teammate

In many projects it also makes sense to run `prisma generate` in `postinstall` or before your production build so deployments always use a current client.

Related pages [#related-pages]

* [Introduction to Prisma Client](/orm/prisma-client/setup-and-configuration/introduction)
* [Generators in the Prisma schema](/orm/prisma-schema/overview/generators)
* [Prisma CLI reference for generate](/cli/generate)

## Related pages

- [`Configuring error formatting`](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/error-formatting): This page explains how to configure the formatting of errors when using Prisma Client
- [`Custom model and field names`](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/custom-model-and-field-names): Learn how you can decouple the naming of Prisma models from database tables to improve the ergonomics of the generated Prisma Client API
- [`Database connections`](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections): Learn how to manage database connections and configure connection pools
- [`Database polyfills`](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/database-polyfills): Prisma Client provides features that are not achievable with relational databases. These features are referred to as "polyfills" and explained on this page.
- [`Introduction to Prisma Client`](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/introduction): Learn how to set up and configure Prisma Client in your project