# Enhance

> AI image enhancement with upscale and face enhancement.

## Overview

- **Model ID**: `picsart-enhance`
- **Workflow**: `pcp/v1/enhancement`
- **Provider**: Picsart
- **Category**: Image → Image (image)
- **Output**: One or more image URLs.
- **Tags**: enhancement, image required
- **Unified endpoint**: `POST https://api.picsart.com/workflows/v1/models/execute` (model id in the body)
- **Compatibility endpoint**: `POST https://api.picsart.com/workflows/pcp/v1/enhancement/execute` (vendor's own parameters)
- **Execution**: sync (`/execute`) returns the result in one call; async is also available
- **Model page**: https://picsart.com/api-platform/models/picsart-enhance

## Pricing

Rates are in USD. Every row below is an exact rate for the settings it names — the columns are the settings that change the price for this model. Every response reports what was actually charged in `response.usage.credits`.

| Rate |
| --- |
| $0.044 / generation |

Published rates. Volume pricing, invoicing and annual agreements: https://picsart.com/api-platform/contact-sales

## Authentication

The SDK and the REST API authenticate with a Picsart API key sent as a bearer token. Create a key in the console at https://picsart.com/api-platform/dashboard/api-keys, keep it in a server-side environment variable, and never ship it in browser code or commit it.

```bash
export PICSART_API_KEY="YOUR_KEY"
```

```http
Authorization: Bearer $PICSART_API_KEY
```

The CLI and the MCP server do not use an API key: `gen-ai login` signs in through the browser once per machine and stores a token locally.

## Interfaces

- **SDK** — `@picsart/ai-sdk` (TypeScript, Node 20+, ESM). Type-safe `ai.generate()` / `ai.generateText()` with per-model parameter types; polls long jobs for you.
- **REST** — the API gateway at `https://api.picsart.com`. Sync `/execute`, or async `/submit` + `/{taskId}/result`.
- **CLI** — `@picsart/gen-ai` (`gen-ai`). Generate from a terminal, quote cost before spending, emit JSON for pipelines.
- **MCP** — the same models inside Claude Code, Cursor, Windsurf and other MCP hosts. Setup: https://picsart.com/gen-ai-mcp/

```bash
npm install @picsart/ai-sdk      # SDK
npm install -g @picsart/gen-ai   # CLI (also drives the MCP server)
```

## Unified API (recommended)

One parameter set, used by the SDK and by REST alike: the names below are what `ai.generate('picsart-enhance', …)` takes, and what goes inside the inner `params` of a REST call. Over REST the model id travels in the body, not the path — one workflow, `v1/models`, fronts the whole catalogue.

### Execution modes

- **Sync** — `POST /workflows/v1/models/execute` returns the result in one call. Only for jobs that finish within ~20 seconds; otherwise it times out.
- **Async** — `POST /workflows/v1/models/submit` returns a task id; poll `GET /workflows/v1/models/{taskId}/result` until `response.status` is `COMPLETED` or `FAILED`. Task statuses: `ACCEPTED` · `IN_PROGRESS` · `COMPLETED` · `FAILED`.
- **SDK** — `ai.generate()` always awaits the finished result; polling is hidden.

### Input parameters

- **`imageUrls`** (`list<string>`, _required_): Source Image
  - Accepts: image URLs (max 1)

### Input JSON Schema

The inner `params` object. Over REST it is wrapped as `{ "params": { "model": "<id>", "params": <this> } }`; the SDK takes it directly.

```json
{
  "type": "object",
  "required": [
    "imageUrls"
  ],
  "properties": {
    "imageUrls": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri",
        "description": "image URL"
      },
      "maxItems": 1,
      "description": "Source Image"
    }
  },
  "additionalProperties": false
}
```

### Required parameters example

The required parameters plus the defaults that shape the output, as a REST body:

```json
{
  "params": {
    "model": "picsart-enhance",
    "params": {
      "imageUrls": [
        "https://cdn.example.com/input.jpg"
      ]
    }
  }
}
```

### Response

The body is the gateway's status envelope: the output is at `response.result`, next to the task id, its status and the credits charged. Asset models return `url` plus an `items` array of results.

```json
{
  "status": "success",
  "response": {
    "id": "task_abc123",
    "status": "COMPLETED",
    "result": {
      "url": "https://cdn.picsart.com/…/result",
      "items": [
        {
          "url": "https://cdn.picsart.com/…/result"
        }
      ],
      "model": "picsart-enhance"
    }
  }
}
```

What `ai.generate()` / `ai.generateText()` resolve to (the envelope already unwrapped):

```json
{
  "items": [
    {
      "url": "https://cdn.picsart.com/…/result"
    }
  ],
  "model": "picsart-enhance"
}
```

### Usage examples

#### TypeScript (SDK)

```typescript
import { createClient } from '@picsart/ai-sdk';

const ai = createClient({
  apiKey: process.env.PICSART_API_KEY,
  apiUrl: 'https://api.picsart.com',
});

const result = await ai.generate('picsart-enhance', {
  imageUrls: [
    "https://cdn.example.com/input.jpg"
  ]
});

console.log(result.url); // image URL
```

#### cURL (sync)

```bash
curl -X POST 'https://api.picsart.com/workflows/v1/models/execute' \
  -H 'Authorization: Bearer $PICSART_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "params": {
    "model": "picsart-enhance",
    "params": {
      "imageUrls": [
        "https://cdn.example.com/input.jpg"
      ]
    }
  }
}'
```

#### CLI

```bash
gen-ai login  # once per machine
gen-ai models info picsart-enhance  # this model's parameters
gen-ai pricing picsart-enhance  # quote before spending credits
gen-ai generate -m picsart-enhance \
  -i ./input.jpg
```

## Compatibility API (vendor parameters)

Alongside the unified API, the `pcp/v1/enhancement` workflow takes Picsart's own parameters exactly as the vendor defines them — nothing renamed or reshaped. It is the shortest path onto Picsart for request bodies already written against the vendor; the trade is that a request is written for one vendor, and the result comes back in the vendor's own shape. Same authentication.

- **Endpoint**: `POST https://api.picsart.com/workflows/pcp/v1/enhancement/execute` (sync) · `POST …/submit` + `GET …/{taskId}/result` (async)
- **SDK**: `ai.apis.run('pcp/v1/enhancement', params, { mode })` — params forwarded verbatim

### Vendor parameters

| Parameter | Type | Required | Default | Details |
| --- | --- | --- | --- | --- |
| `image` | `string` | yes | — | Full URL of the input image. |
| `upscale` | `object` | no | — | Upscaling configuration. Runs with default settings when omitted. Pass { enabled: false } to skip. |
| └ `enabled` | `boolean` | no | — | Enable the upscaling stage. |
| └ `node` | `string` | no | — | Algorithm variant / processing node to use for upscaling. |
| └ `target_scale` | `number` | no | — | Output scale multiplier relative to the input (e.g. 2 doubles resolution). Mutually exclusive with target_size, target_height, and target_width. |
| └ `target_size` | `number` | no | — | Target size in pixels for the longer edge. Mutually exclusive with target_scale. |
| └ `target_height` | `number` | no | — | Target output height in pixels. |
| └ `target_width` | `number` | no | — | Target output width in pixels. |
| └ `units` | `string` | no | — | Unit system for target dimensions (e.g. "px", "in"). |
| └ `output_dpi` | `number` | no | — | DPI of the output image; relevant when units is "in". |
| └ `resize_before_processing` | `boolean` | no | — | Downscale the image before running the upscaler to reduce GPU memory usage. |
| └ `smooth_patch_average` | `boolean` | no | — | Average overlapping tile patches to reduce boundary artifacts. |
| └ `creative_num_steps` | `number` | no | — | Diffusion steps for the generative (creative) upscaling pass (1–32). Higher values improve quality at the cost of speed. |
| └ `strength` | `number` | no | — | Denoising strength controlling how much the upscaler alters fine detail (0–1). |
| └ `guidance_scale` | `number` | no | — | Classifier-free guidance scale for the diffusion upscaler (0–8). |
| └ `masked_latents_scale` | `number` | no | — | Scale applied to masked latent regions during inpainting (0–2). |
| └ `creative_strength` | `number` | no | — | Intensity of the generative enhancement pass (0–1). |
| └ `creative_use_gan` | `boolean` | no | — | Use a GAN-based upscaler instead of the diffusion model for the creative pass. |
| └ `srtv_fidelity` | `number` | no | — | Fidelity weight balancing output realism against faithfulness to the input image (0–1). |
| `face_enhancement` | `object` | no | — | Face-enhancement configuration. Runs with default settings when omitted. Pass { enabled: false } to skip. |
| └ `enabled` | `boolean` | no | — | Enable the face-enhancement stage. |
| └ `face_blending_cbcr` | `number` | no | — | Chroma-channel blending weight between the enhanced and original face (0–1). Higher values apply more colour correction from the restored face. |
| └ `antialias` | `boolean` | no | — | Apply antialiasing when warping the enhanced face back onto the original. |
| └ `face_size_upper_threshold` | `number` | no | — | Maximum face size relative to the image above which face enhancement is skipped. |
| └ `num_inference_steps` | `number` | no | — | Number of diffusion inference steps for face restoration (0–1000). Higher values produce finer detail at the cost of speed. |
| └ `prompt` | `string` | no | — | Text prompt guiding the face-restoration diffusion model. |
| └ `negative_prompt` | `string` | no | — | Negative prompt for the face-restoration diffusion model; describes features to suppress. |
| └ `guidance_scale` | `number` | no | — | Classifier-free guidance scale for the face-restoration diffusion model (≥1). |
| └ `gfpgan_threshold` | `number` | no | — | GFPGAN detection confidence threshold; faces with a score below this value are skipped. |
| └ `diffbir_thresholds` | `object` | no | — | Per-stage detection thresholds. Keys are stage names; values are numeric thresholds or "auto". · e.g. `{"source":20,"target":"auto"}` |
| `colour_correction` | `object` | no | — | Colour-correction configuration. Runs with default settings when omitted. Pass { enabled: false } to skip. |
| └ `enabled` | `boolean` | no | — | Enable the colour-correction stage. |
| └ `blending` | `number` | no | — | Blending weight between the colour-corrected and original image (0–1). 1 applies the full correction; 0 leaves the original colours unchanged. |
| `seed` | `number` | no | — | Random seed for reproducible results. Omit to use a random seed. |
| `output_format` | `string` | no | — | Output image format. Defaults to the input image format when omitted. |
| `max_output_area_mp` | `number` | no | — | Maximum output area in megapixels. The image is downscaled before processing if it exceeds this limit. |
| `options` | `object` | no | — | Options controlling safety checks and drive integration. |
| └ `safety_checks` | `object` | no | — | Safety check settings |
| └   `enabled` | `boolean` | no | — | Whether to run content moderation. Defaults to true. |
| └ `drive` | `object` | no | — | Save result to Picsart Drive |
| └   `name` | `string` | yes | — | File name in Picsart Drive |
| └   `attributes` | `object` | no | — | Custom attributes to attach to the file |
| └   `folder` | `object` | no | — | Target folder in Picsart Drive |
| └ `inputs_transformation` | `object` | no | — | Input transformation settings |
| └   `downscale_oversized_images` | `boolean` | no | — | Whether to downscale oversized input images. Defaults to false. |
| `model_execution_mode` | `string` | no | — | Execution mode of the underlying diffbir model service. Optional, defaults to sync. Use async for batch executions. |

### Example request body

```json
{
  "params": {
    "image": "your value here"
  }
}
```

### Usage examples

#### TypeScript (`ai.apis.run`)

```typescript
import { createClient, ApiRunMode } from '@picsart/ai-sdk';

const ai = createClient({
  apiKey: process.env.PICSART_API_KEY,
  apiUrl: 'https://api.picsart.com',
});

// Calls the 'pcp/v1/enhancement' workflow directly — params are sent as-is.
const { result, usage } = await ai.apis.run('pcp/v1/enhancement', {
  image: "your value here"
}, {
  mode: ApiRunMode.SYNC,
});

console.log(result); // workflow-specific output
console.log(usage?.credits); // amount charged, in $
```

#### cURL (sync)

```bash
curl -X POST 'https://api.picsart.com/workflows/pcp/v1/enhancement/execute' \
  -H 'Authorization: Bearer $PICSART_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "params": {
    "image": "your value here"
  }
}'
```

### Response

Over HTTP the vendor-shaped result arrives inside the gateway envelope at `response.result`:

```json
{
  "status": "success",
  "response": {
    "id": "wf_abc123",
    "status": "COMPLETED",
    "result": {
      "url": "https://cdn.picsart.com/…/result.jpg",
      "mimeType": "image/jpeg",
      "driveFile": {}
    }
  }
}
```

`ai.apis.run()` unwraps that envelope and resolves to `{ result, usage }`:

```json
{
  "result": {
    "url": "https://cdn.picsart.com/…/result.jpg",
    "mimeType": "image/jpeg",
    "driveFile": {}
  }
}
```

## Additional resources

- Model page: https://picsart.com/api-platform/models/picsart-enhance
- Try it: https://picsart.com/api-platform/models/picsart-enhance/playground
- SDK: https://picsart.com/api-platform/models/picsart-enhance/sdk
- REST API (unified): https://picsart.com/api-platform/models/picsart-enhance/api
- Compatibility API (vendor parameters): https://picsart.com/api-platform/models/picsart-enhance/advanced
- Pricing: https://picsart.com/api-platform/models/picsart-enhance/pricing
- This document: https://picsart.com/api-platform/models/picsart-enhance/llms.txt
- All models: https://picsart.com/api-platform/models
- Docs — quickstart https://picsart.com/api-platform/docs/quickstart, authentication https://picsart.com/api-platform/docs/authentication, SDK https://picsart.com/api-platform/docs/sdk, REST https://picsart.com/api-platform/docs/api-reference, CLI https://picsart.com/api-platform/docs/cli, MCP https://picsart.com/api-platform/docs/mcp
- CLI reference: https://picsart.github.io/picsart-mcp-cli-docs/guide/introduction
