> ## Documentation Index
> Fetch the complete documentation index at: https://docs.px0.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Run px0 Locally

> Set up and run the px0 prompt infrastructure on your local machine using Docker Compose.

Running px0 locally allows you to test, develop, and integrate prompt management into your application before deploying to production. This guide walks you through setting up px0 with Docker Compose.

## Prerequisites

Before starting, ensure that Docker and Docker Compose are installed on your machine.

## Initial Setup

1. Clone the [px0 repository](https://github.com/px0-ai/px0) and navigate to the project root directory:

```bash theme={null}
git clone https://github.com/px0-ai/px0.git
cd px0
```

2. Copy the example environment file to create your local environment file:

```bash theme={null}
cp .env.example .env
```

3. Open the `.env` file and set the `RESEND_API_KEY` variable:

```env theme={null}
RESEND_API_KEY=mock
```

Setting `RESEND_API_KEY` to `mock` bypasses email verification during user registration, automatically marking newly registered users as verified immediately. If you leave `RESEND_API_KEY` empty or omit it during registration, the Go API server generates a six-digit verification code and prints it to standard output. You will then need to retrieve it from the container logs and verify manually.

## Orchestration Services

To build the Go application image, run migrations, and start all dependency containers, run the following command in detached mode from the project root:

```bash theme={null}
docker compose up -d
```

<Note>
  After starting the services, you can open the px0 Web Console at [http://localhost:8000](http://localhost:8000) to navigate and manage your prompt infrastructure, or you can continue directly from your terminal using CLI tools like `curl`.
</Note>

## Port Mapping and Web UIs

When you boot the stack, the following services and endpoints are exposed locally:

| Service                  | Port            | Endpoint URL                                   | Description                                                      |
| :----------------------- | :-------------- | :--------------------------------------------- | :--------------------------------------------------------------- |
| Go API Server            | `8000`          | [http://localhost:8000](http://localhost:8000) | The primary Go backend application built with Fiber              |
| Prometheus               | `9090`          | [http://localhost:9090](http://localhost:9090) | The metrics database scraping all collector endpoints            |
| Grafana                  | `3000`          | [http://localhost:3000](http://localhost:3000) | The visualization platform preloaded with provisioned dashboards |
| OpenTelemetry Collector  | `4317` / `4318` | localhost:4317                                 | The OTLP gRPC and HTTP receiver pipelines                        |
| OTEL Prometheus Exporter | `8889`          | [http://localhost:8889](http://localhost:8889) | Scraper endpoint for Go API server metrics                       |
| PostgreSQL Exporter      | `9187`          | [http://localhost:9187](http://localhost:9187) | Scraper endpoint for PostgreSQL database metrics                 |
| Redis Exporter           | `9121`          | [http://localhost:9121](http://localhost:9121) | Scraper endpoint for Redis cache metrics                         |

## Verification and Traffic Generation

Once the containers are running, you can verify the setup by running health checks and registering a user.

### 1. Health Check Request

Send a request to the health endpoint to confirm the API server is healthy:

```bash theme={null}
curl -i http://localhost:8000/v1/health
```

### 2. Register a User

Register a new user using a JSON payload. Ensure your password is secure: at least 8 characters, one uppercase letter, one lowercase letter, one digit, and one special character.

```bash theme={null}
curl -i -X POST http://localhost:8000/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "hello@example.com", "password": "SecurePassword123!"}'
```

If you configured `RESEND_API_KEY=mock` in your environment file, the user is verified immediately.

If you left `RESEND_API_KEY` empty, retrieve the six-digit code from the container logs:

```bash theme={null}
docker compose logs app | grep EMAIL
```

Then, submit the code to verify your account:

```bash theme={null}
curl -i -X POST http://localhost:8000/v1/auth/verify-email \
  -H "Content-Type: application/json" \
  -d '{"email": "hello@example.com", "code": "<retrieved_code>"}'
```

### 3. Login to Obtain a Token

Log in to establish a session and obtain your bearer token:

```bash theme={null}
curl -i -X POST http://localhost:8000/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "hello@example.com", "password": "SecurePassword123!"}'
```

Copy the token value from the JSON response to use in authenticated requests. This session token starts with `sess_`.

## Next Steps

Now that you have running services and a verified account, you can proceed to obtain an API key for programmatic integration, or create and render your first prompt.

* [Get an Access Key](/get-started/get-access-key)
* [Create Your First Prompt](/get-started/create-prompt)
* [Setup Telemetry](/get-started/setup-telemetry)
