---
title: "Quickstart"
description: "Get started with P-API in minutes. Learn how to generate and edit images using our AI models."
url: "https://docs.api.pruna.ai/guides/quickstart"
image: "https://docs.api.pruna.ai/_og/d/c_Ocean.takumi,title_Quickstart,description_Get+started+with+P-API+in+minutes.+Learn+how+to+generate+and+edit+images+using+our+AI+models.,props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiM3YzNhZWQifX19,p_Ii9ndWlkZXMvcXVpY2tzdGFydCI,s_zdaUOFcWN6RRi26X.png"
---

# Quickstart

Get up and running with P-API in just a few minutes. This guide covers authentication, file uploads, and making your first image generation requests.

## [Getting Your API Key](#getting-your-api-key)

To use P-API, you'll need an API key. Contact [us](https://pruna.ai/contact) to get started.

Once you have your API key, include it in the `apikey` header for all requests:

```bash
curl -H "apikey: YOUR_API_KEY" https://api.pruna.ai/v1/<endpoint> <body>
```

## [Your First Request: Generate an Image](#your-first-request-generate-an-image)

Let's generate an image using the P-Image model. We'll use synchronous mode (Try-Sync: true) to get results immediately:

```bash
curl -X POST https://api.pruna.ai/v1/predictions \
-H "apikey: YOUR_API_KEY" \
-H "Model: p-image" \
-H "Try-Sync: true" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A majestic lion standing on a rocky cliff at sunset, photorealistic, 4k",
"aspect_ratio": "16:9"
}
}'
```

Response (if completed within 60 seconds):

```text
{
"status": "succeeded",
"generation_url": "https://api.pruna.ai/v1/predictions/delivery/xezq/abc123.../output.jpg"
}
```

Download your image: `curl -H "apikey: YOUR_API_KEY" \ https://api.pruna.ai/v1/predictions/delivery/xezq/abc123.../output.jpg \ -o my-image.jpg`

## [File Upload & Image Editing](#file-upload-image-editing)

To edit images with P-Image-Edit, you'll first need to upload your reference images:

### [Step 1: Upload Your Images](#step-1-upload-your-images)

#### [Upload first image](#upload-first-image)

```bash
curl -X POST https://api.pruna.ai/v1/files \
-H "apikey: YOUR_API_KEY" \
-F "content=@my-photo.jpg" \
> upload1.json
```

Response:

```text
{
"id": "file-abc123",
"urls": {
"get": "https://api.pruna.ai/v1/files/file-abc123"
}
}
```

#### [Upload second image (optional, p-image-edit supports 1-5 images)](#upload-second-image-optional-p-image-edit-supports-1-5-images)

```bash
curl -X POST https://api.pruna.ai/v1/files \
-H "apikey: YOUR_API_KEY" \
-F "content=@another-photo.jpg" \
> upload2.json
```

Response:

```text
{
"id": "file-abc123",
"urls": {
"get": "https://api.pruna.ai/v1/files/file-def456"
}
}
```

### [Step 2: Edit Your Images](#step-2-edit-your-images)

Use the uploaded file URLs in your editing request:

```bash
curl -X POST https://api.pruna.ai/v1/predictions \
-H "apikey: YOUR_API_KEY" \
-H "Model: p-image-edit" \
-H "Try-Sync: true" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Transform into a watercolor painting style with vibrant colors",
"images": [
"https://api.pruna.ai/v1/files/file-abc123",
"https://api.pruna.ai/v1/files/file-xyz789"
],
"reference_image": "1",
"aspect_ratio": "16:9"
}
}'
```

Response:

```text
{
"status": "succeeded",
"generation_url": "https://api.pruna.ai/v1/predictions/delivery/xezq/def456.../output.jpg"
}
```

#### [Asynchronous Workflow (For Longer Requests)](#asynchronous-workflow-for-longer-requests)

Some models or complex requests may take longer than 60 seconds. For these, use the asynchronous workflow to avoid timeouts:

##### Step 1: Submit Request (Without Try-Sync)

```bash
curl -X POST https://api.pruna.ai/v1/predictions \
-H "apikey: YOUR_API_KEY" \
-H "Model: p-image-edit" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Complex artistic transformation with multiple effects",
"images": ["https://api.pruna.ai/v1/files/file-abc123"]
}
}'
```

Response:

```text
{
"id": "1zww7deyssrme0csqwr90phzzr",
"model": "p-image-edit",
"input": { ... },
"get_url": "https://api.pruna.ai/v1/predictions/status/1zww7deyssrme0csqwr90phzzr"
}
```

##### Step 2: Check Status

Poll the status endpoint to check progress:

```bash
curl -H "apikey: YOUR_API_KEY" \
https://api.pruna.ai/v1/predictions/status/1zww7deyssrme0csqwr90phzzr
```

Response (Starting):

```text
{
"status": "starting",
"message": "Generation in progress"
}
```

Response (Processing):

```text
{
"status": "processing",
"message": "Generation in progress"
}
```

Response (Completed):

```text
"status": "succeeded",
"generation_url": "https://api.pruna.ai/v1/predictions/delivery/xezq/52UGYRrRfqViaKmvYsEnENTh0qLDAWHptQ8jOnEHu7XC6AtKA/output.mp4"
}
```

Response (Failed):

```text
{
"status": "failed",
"message": "Prediction failed",
"error": "Number of samples, -5, must be non-negative."
}
```

##### Step 3: Download Result

```text
curl -H "apikey: YOUR_API_KEY" \
https://api.pruna.ai/v1/predictions/delivery/xezq/abc123.../output.jpg \
-o result.jpg
```

### [When to Use Each Workflow](#when-to-use-each-workflow)

**Asynchronous Mode (recommended)**

-   ✅ Video generation models (wan-i2v, wan-t2v, vace)
-   ✅ Complex image processing that may take longer
-   ✅ When you want to avoid timeout issues
-   ✅ When processing multiple requests in parallel (causing a spike in usage will trigger infrastructure scaling and queuing of your requests)

**Synchronous Mode (Try-Sync: true)**

-   ✅ Fast models like p-image, p-image-edit, wan-image-small
-   ✅ Simple requests with quick processing times
-   ✅ When you need immediate results in a single request
-   ❌ Not recommended for video models or complex edits that may take ~10 seconds or more

Note: use the synchronous mode at your own risk, you may encounter timeouts / 504 errors. Async mode is safer, but the sync mode gets you the results faster and with less code.

### [Rate Limits](#rate-limits)

Different models have different rate limits:

-   P-Models (p-image, p-image-edit): 250 requests/minute
-   Other Image Models (flux-dev, qwen-image, etc.): 150 requests/minute
-   Video Models (wan-i2v, wan-t2v, vace): 30 requests/minute
-   Status Endpoint: 30,000 requests/minute
-   Delivery Endpoint: 10,000 requests/minute

Next Steps

-   Explore all /models and their capabilities
-   Learn about /api-reference for fine-tuning results
-   Check out /examples for inspiration

Need help? [Contact us](https://pruna.ai/contact).