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

# OpenAI API

> OpenAI-compatible image and video APIs, SGLang action generation APIs, and LoRA adapter management.

The SGLang Diffusion server supports image, video, audio, and action generation. It provides OpenAI-compatible image and video APIs, plus SGLang extensions for [action generation](#action-generation-sglang-extension), mesh generation, and LoRA adapter management. Audio output depends on the selected model's audio/video pipeline; action endpoints are not part of the OpenAI API standard.

## Prerequisites

* Python 3.11+ if you plan to use the OpenAI Python SDK.

## Serve

Launch the server using the `sglang serve` command.

### Start the server

```bash theme={null}
SERVER_ARGS=(
  --model-path Wan-AI/Wan2.1-T2V-1.3B-Diffusers
  --served-model-name wan-t2v
  --text-encoder-cpu-offload
  --pin-cpu-memory
  --num-gpus 4
  --ulysses-degree=2
  --ring-degree=2
  --port 30010
)

sglang serve "${SERVER_ARGS[@]}"
```

* **--model-path**: Path to the model or model ID.
* **--served-model-name**: Stable model name exposed by the serving APIs. It defaults to `--model-id` when set, otherwise `--model-path`.
* **--port**: HTTP port to listen on (default: `30000`).

### Served model name

`--served-model-name` separates the public API identity from the checkpoint location. This is useful when replicas use different local mount paths or when a gateway needs one stable model name:

```bash theme={null}
sglang serve \
  --model-path /models/Wan2.1-T2V-1.3B-Diffusers \
  --served-model-name wan-t2v \
  --port 30010
```

`--model-id` is not a free-form deployment alias: it selects the registered model configuration for checkpoints whose local path cannot be identified. `--served-model-name` only controls the name exposed by serving APIs. When both are set, the served name takes precedence for API responses.

### Discover the served model

**Endpoint:** `GET /v1/models`

Returns the public model name together with diffusion-specific runtime information.

**Curl Example:**

```bash curl theme={null}
curl -sS "http://localhost:30010/v1/models"
```

**Response Example:**

```json theme={null}
{
  "object": "list",
  "data": [
    {
      "id": "wan-t2v",
      "object": "model",
      "created": 1786348800,
      "owned_by": "sglang",
      "root": "wan-t2v",
      "parent": null,
      "max_model_len": null,
      "num_gpus": 4,
      "task_type": "T2V",
      "supported_task_types": ["T2V"],
      "dit_precision": "bf16",
      "vae_precision": "fp16",
      "pipeline_name": "WanPipeline",
      "pipeline_class": "WanPipeline"
    }
  ]
}
```

Retrieve the same model by its served name:

```bash curl theme={null}
curl -sS "http://localhost:30010/v1/models/wan-t2v"
```

`GET /server_info` also reports `served_model_name` for gateway discovery. Video and action responses use this name when the request does not provide a model explicitly.

***

## Endpoints

### Select a request task

`GET /v1/models` reports `task_type` (the configured default) and
`supported_task_types` (the tasks implemented by that configured pipeline).
`GET /model_info` also reports the supported `output_types`. A pipeline may
support image and video output on one server when its implementation and
loaded components provide both paths.

Send the optional SGLang extension `task_type` as a case-insensitive enum name:

| Interface | Task field | Output constraint |
| - | - | - |
| `POST /v1/images/generations` JSON | `"task_type": "t2i"` | Image |
| `POST /v1/images/edits` multipart | `-F task_type=i2i` | Image |
| `POST /v1/videos` JSON or multipart | `"task_type": "i2v"` or `-F task_type=i2v` | Video |
| OpenAI Python client | `extra_body={"task_type": "t2i"}` | Selected endpoint |
| Native Python `generate` sampling parameters | `"task_type": "t2i"` | Selected task |
| `sglang generate` | `--task-type t2i` | Selected task |

Choose only a task in the server's advertised set. An unsupported task, a task
with the wrong output type for the endpoint, or missing required conditioning
returns HTTP 400. For example, `i2v` needs image input, while `v2v` and `f2v`
need video input. Model-specific size, frame count, and reference constraints
still apply.

If you omit `task_type`, the server uses the endpoint and supplied inputs to
choose a compatible task, preferring its default when compatible. It asks for
an explicit task if several alternatives remain (for example `v2v` versus
`f2v`). Pipelines with one task keep that task as their default. Sending a
request never changes the server default or subsequent requests.

### Prompt enhancement

Image generation, image edits and video creation accept `enhance_prompt=true`
when the server is configured with `--prompt-enhancer-config`. An independent
SRT service rewrites the prompt before diffusion runs. The default is `false`;
image responses return `data[].revised_prompt`, and video responses return
`revised_prompt`. See [deployment and model compatibility](https://docs.sglang.io/docs/sglang-diffusion/models_with_pe.md).

### Model-specific request fields

The image and video request schemas contain only OpenAI fields and stable
SGLang extensions shared across model families. Put model-specific controls in
`extra_body` when using the OpenAI Python client:

```python Python theme={null}
from openai import OpenAI

client = OpenAI(api_key="EMPTY", base_url="http://localhost:30010/v1")
response = client.images.generate(
    model="ideogram-ai/ideogram-4-nf4",
    prompt="A typeset poster",
    extra_body={"preset": "V4_QUALITY_48"},
)
```

Raw JSON requests may send these fields at the top level. Multipart video
requests may send individual declared form fields or one JSON object in
`extra_params`. SGLang forwards model-specific extensions only when the active
model declares them, so a field for one model family does not silently change
another model.

### Image Generation

The server implements an OpenAI-compatible Images API under the `/v1/images` namespace.

**Create an image**

**Endpoint:** `POST /v1/images/generations`

#### Request quality

`quality` selects a cumulative request-level optimization tier: `exact` keeps the selected deployment's reference path and all unconditional bit-exact replacements, so output is bit-identical to it in the same environment; `lossless` additionally enables the request-gated DiT/VAE fusions that keep the reference math and every operand's precision and only move the rounding; `high` includes the full `lossless` set and may also enable model-owned sparse, caching, lower-precision, or other approximate paths. `extra-high` is accepted as the former name of `lossless`. The tier does not override separately configured quantization, attention, or caching options. Omit it (or send OpenAI's default `auto`) to keep the `lossless` runtime default. It is distinct from `output_quality`, which controls only output-file compression. The same extension is accepted by image edits and video requests.

**Python Example (b64\_json response):**

```python Python theme={null}
import base64
from openai import OpenAI

client = OpenAI(api_key="sk-proj-1234567890", base_url="http://localhost:30010/v1")

img = client.images.generate(
    prompt="A calico cat playing a piano on stage",
    size="1024x1024",
    n=1,
    response_format="b64_json",
)

image_bytes = base64.b64decode(img.data[0].b64_json)
with open("output.png", "wb") as f:
    f.write(image_bytes)
```

**Curl Example:**

```bash curl theme={null}
curl -sS -X POST "http://localhost:30010/v1/images/generations" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -d '{
        "prompt": "A calico cat playing a piano on stage",
        "size": "1024x1024",
        "n": 1,
        "response_format": "b64_json"
      }'
```

> **Note**
> If `response_format=url` is used and cloud storage is not configured, the API returns
> a relative URL like `/v1/images/<IMAGE_ID>/content`.

**Edit an image**

**Endpoint:** `POST /v1/images/edits`

This endpoint accepts a multipart form upload with input images and a text prompt. The server can return either a base64-encoded image or a URL to download the image.

Uploaded filenames are sanitized, and saved uploads are constrained to the
server's upload directory. This also applies to image uploads for video and mesh
generation.

**Curl Example (b64\_json response):**

```bash Command theme={null}
curl -sS -X POST "http://localhost:30010/v1/images/edits" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -F "image=@local_input_image.png" \
  -F "url=image_url.jpg" \
  -F "prompt=A calico cat playing a piano on stage" \
  -F "size=1024x1024" \
  -F "response_format=b64_json"
```

**Curl Example (URL response):**

```bash Command theme={null}
curl -sS -X POST "http://localhost:30010/v1/images/edits" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -F "image=@local_input_image.png" \
  -F "url=image_url.jpg" \
  -F "prompt=A calico cat playing a piano on stage" \
  -F "size=1024x1024" \
  -F "response_format=url"
```

**Download image content**

When `response_format=url` is used with `POST /v1/images/generations` or `POST /v1/images/edits`,
the API returns a relative URL like `/v1/images/<IMAGE_ID>/content`.

**Endpoint:** `GET /v1/images/&#123;image_id&#125;/content`

**Curl Example:**

```bash theme={null}
curl -sS -L "http://localhost:30010/v1/images/<IMAGE_ID>/content" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -o output.png
```

### Mesh generation (SGLang extension)

For a mesh-generation model, `POST /v1/meshes` accepts an input image and returns
an asynchronous job. This endpoint is a SGLang extension, not an OpenAI API.

```bash theme={null}
curl -sS http://localhost:30010/v1/meshes \
  -F 'image=@input.png' \
  -F 'output_format=glb'
```

Poll `GET /v1/meshes/{id}` until `status` is `completed` or `failed`. The content
endpoint, `GET /v1/meshes/{id}/content`, returns 404 until the job completes
successfully; an unfinished or failed export is not downloadable even if a
partial file exists. When cloud storage is enabled, use the completed job's
`url` instead.

Job metadata is process-local and does not survive server restart.
`DELETE /v1/meshes/{id}` removes the record, not the running generation or its
output files. Manage output retention separately.

### Video Generation

The server implements a subset of the OpenAI Videos API under the `/v1/videos` namespace.

With `--input-save-path ""`, uploads use request-owned temporary directories,
removed on rejection or after the background job exits. Configured input and
output directories remain persistent. Cancelling preparation waits for active
CPU preprocessing to finish before cleanup; it does not abort queued GPU work.
With `--output-path ""`, cloud upload must succeed before a job reports completion.

**Create a video (text-to-video)**

**Endpoint:** `POST /v1/videos`

**Python Example:**

```python Python theme={null}
from openai import OpenAI

client = OpenAI(api_key="sk-proj-1234567890", base_url="http://localhost:30010/v1")

video = client.videos.create(
    prompt="A calico cat playing a piano on stage",
    size="1280x720"
)
print(f"Video ID: {video.id}, Status: {video.status}")
```

**Curl Example:**

```bash curl theme={null}
curl -sS -X POST "http://localhost:30010/v1/videos" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -d '{
        "prompt": "A calico cat playing a piano on stage",
        "size": "1280x720"
      }'
```

**Create a video (image-to-video)**

For I2V or TI2V models (e.g., Wan2.1 I2V, LTX-2.3 two-stage), pass an input image via multipart form upload or a reference URL.

**Curl Example (multipart form upload):**

```bash Command theme={null}
curl -sS -X POST "http://localhost:30010/v1/videos" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -F "prompt=A cat playing a piano" \
  -F "input_reference=@input_image.png" \
  -F "size=1280x720"
```

**Curl Example (reference URL):**

```bash Command theme={null}
curl -sS -X POST "http://localhost:30010/v1/videos" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -d '{
        "prompt": "A cat playing a piano",
        "reference_url": "https://example.com/input_image.png",
        "size": "1280x720"
      }'
```

> [!NOTE]
>
> `size` is the literal output resolution for most pipelines. Wan-Animate-2
> treats it as a pixel-area budget instead: the output keeps the reference image's
> aspect ratio and uses the largest frame with at most `width × height` pixels whose
> sides are multiples of 16, so `size=640x800` with a 9:16 reference image yields a
> 528×944 video. Request a budget with the reference image's aspect ratio to get a
> specific size. Wan-Animate-2 also ignores `seconds` and `num_frames`: the output
> has as many frames as the (resampled) reference video, generated in chunks of
> `clip_len` frames; see the
> [Wan-Animate-2 cookbook](https://docs.sglang.io/cookbook/diffusion/Wan/Wan-Animate-2.md#1-2-defaults).
> Wan-Animate-2 keeps the reference video's audio track on the output; the
> model-specific `enable_audio` field (form field or `extra_body`, default `true`)
> set to `false` gives a silent output.

#### MP4 encoding

`x264_preset` picks the libx264 preset for the returned MP4: `ultrafast`,
`superfast`, `veryfast`, `faster`, `fast` (the default), `medium`, `slow`,
`slower`, `veryslow` or `placebo`. Faster presets finish encoding sooner and
trade file size and fidelity at the same `output_compression`/`output_quality`.
Send it at the top level of a JSON body or as a multipart form field;
`sglang generate` takes `--x264-preset`.

**List videos**

**Endpoint:** `GET /v1/videos`

Returns up to 20 jobs by default. Set `limit` from 1 to 100 and `order` to
`asc` or `desc` (default). Responses include `first_id`, `last_id`, and
`has_more`; pass `after=last_id` to fetch the next page. The same pagination
contract applies to `GET /v1/meshes`. Pagination bounds each response, not
the number of stored jobs or queued generation requests.

**Python Example:**

```python Python theme={null}
for item in client.videos.list(limit=20):
    print(item.id, item.status)
```

**Curl Example:**

```bash curl theme={null}
curl -sS -X GET "http://localhost:30010/v1/videos" \
  -H "Authorization: Bearer sk-proj-1234567890"
```

**Retrieve a video**

**Endpoint:** `GET /v1/videos/&#123;video_id&#125;`

A job is `queued` until the scheduler starts it, then `in_progress`, then
`completed` or `failed`. `progress` estimates denoising progress and stays below
100 until the output is ready. Multiple denoising stages, including refinement,
share the progress range equally. This is not an elapsed-time estimate or a
measurement of GPU completion.

Progress updates are best effort and never block generation. They currently
support single-node, monolithic serving; other deployments may remain `queued`
at 0 until completion. Job metadata is process-local and does not survive an
HTTP server restart.

When load balancing independent HTTP servers, route polling and content requests
to the server that accepted the job. Scheduler DP replicas behind one HTTP server
share its job store; independent HTTP servers do not. Restart recovery, durable
job ownership, and queue admission limits require an external serving layer.

An accepted job continues after the submitting client disconnects. For a bounded
scheduler wait, set `--scheduler-rpc-timeout` in seconds; it includes queue time
and generation. A timeout marks the job failed but does not cancel GPU work.
On supported deployments, delete the job to request cancellation. Retrying
generation creates another job, so retain and poll the returned ID.

`DELETE /v1/videos/&#123;video_id&#125;` removes the API record and requests
cancellation: a cancelled queued job does not start. Running jobs check at stage
boundaries and between sampling steps, independently of progress reporting.
All ranks of a replica stop together. If cancellation arrives during encoding or
decoding, that stage may finish, but subsequent stages are skipped once the
request is observed. Rank-only stages check at executor boundaries, not inside
their sampling loops. There is also a check before output finalization is started
or handed to a background thread. Already submitted GPU kernels and ongoing
saves or uploads are not interrupted; the API does not return deleted jobs.
Cancelled jobs are excluded before dynamic batching. Once a batch starts,
it runs to the end unless every member is cancelled.

If a replica's cancellation channel is not connected or its queue is full,
DELETE returns `503` with `Retry-After: 1`. The job record remains available;
retry DELETE with the same video ID. A successful DELETE enqueues the command,
not an acknowledgement that GPU work has already stopped. Cancellation is best
effort: process failures or eviction from the driver's bounded history (the
latest 4096 cancelled job IDs) can still prevent it. Cancellation supports single-node,
monolithic serving only; in other deployments DELETE removes the API record
without stopping GPU work. Completed jobs can be deleted without a cancellation
channel.
Deleting a job does not remove files that were already generated. Manage output
retention separately.

**Python Example:**

```python Python theme={null}
video = client.videos.retrieve(video_id)
print(video.status, video.progress)
```

**Curl Example:**

```bash curl theme={null}
curl -sS -X GET "http://localhost:30010/v1/videos/<VIDEO_ID>" \
  -H "Authorization: Bearer sk-proj-1234567890"
```

**Download video content**

**Endpoint:** `GET /v1/videos/&#123;video_id&#125;/content`

**Python Example:**

```python Python theme={null}
import time

# Poll for completion
while True:
    item = client.videos.retrieve(video_id)
    if item.status == "completed":
        break
    if item.status == "failed":
        raise RuntimeError(item.error)
    time.sleep(5)

# Download content
resp = client.videos.download_content(video_id=video_id)
with open("output.mp4", "wb") as f:
    f.write(resp.read())
```

**Curl Example:**

```bash curl theme={null}
curl -sS -L "http://localhost:30010/v1/videos/<VIDEO_ID>/content" \
  -H "Authorization: Bearer sk-proj-1234567890" \
  -o output.mp4
```

***

### Action generation (SGLang extension)

Action policies use `/v1/actions` rather than the image or video endpoints.
Launch a supported policy with `sglang serve` and use its cookbook recipe for
the observation schema, action layout, and sampling defaults.

| Endpoint | Purpose |
| - | - |
| `POST /v1/actions/generations` | Generate an action chunk synchronously using JSON or msgpack. |
| `GET /v1/actions/metadata` | Discover the served policy's observation schema, action shape, defaults, and capabilities. |
| `WS /v1/actions/realtime` | Send successive action requests using the msgpack WebSocket protocol. |

See the [VLA cookbook](https://docs.sglang.io/cookbook/vla/intro.md) for Pi0.5, FLUX 3 Action, and
Praxis-1 recipes, or [Cosmos3 policy and inverse dynamics](https://docs.sglang.io/cookbook/diffusion/Cosmos/Cosmos3.md#action-generation)
for world-model action generation. Supported inputs, session behavior, and
transports depend on the policy; consult its metadata and recipe before use.

### LoRA Management

The server supports dynamic loading, merging, and unmerging of LoRA adapters.

**Important Notes:**

* Mutual Exclusion: Only one LoRA configuration can be active per target at a time; that configuration can contain multiple adapters
* Switching: To switch LoRAs, deactivate the current LoRA with `unmerge_lora_weights`, then `set` the new one
* Caching: The server caches loaded LoRA weights in memory. Switching back to a previously loaded LoRA (same path) has little cost

**Set LoRA Adapter**

Loads one or more LoRA adapters and applies them to the model. Both static merge and dynamic execution support multiple adapters on the same target, with a separate strength for each adapter.

When `merge_mode` is omitted, the request inherits the server's `--lora-merge-mode`. The default policy, `auto`, merges regular weights but uses dynamic LoRA for FSDP-sharded weights, supported quantized or AMX-packed weights that cannot merge in place, and updates estimated to lose more than 50% of their norm to merge rounding. These rules also apply to multiple adapters. Forcing `merge` fails for weights that cannot merge in place; `dynamic` leaves the base weights unchanged and adds the adapters' updates during each forward pass.

**Endpoint:** `POST /v1/set_lora`

**Parameters:**

* `lora_nickname` (string or list of strings, required): A unique identifier for the LoRA adapter(s). Can be a single string or a list of strings for multiple LoRAs
* `lora_path` (string or list of strings/None, optional): Path to the `.safetensors` file(s) or Hugging Face repo ID(s). Required for the first load; optional if re-activating a cached nickname. If a list, must match the length of `lora_nickname`
* `target` (string or list of strings, optional): Which transformer(s) to apply the LoRA to. If a list, must match the length of `lora_nickname`. Valid values:
  * `"all"` (default): Apply to all transformers
  * `"transformer"`: Apply only to the primary transformer (high noise for Wan2.2)
  * `"transformer_2"`: Apply only to transformer\_2 (low noise for Wan2.2)
  * `"critic"`: Apply only to the critic model
* `strength` (float or list of floats, optional): LoRA strength for static merge or dynamic execution, default 1.0. If a list, must match the length of `lora_nickname`. Values \< 1.0 reduce the effect, values > 1.0 amplify the effect
* `merge_mode` (string, optional): `"auto"`, `"merge"` (force static merge), or `"dynamic"` (apply LoRA at forward time). If omitted, inherits `--lora-merge-mode`

**Single LoRA Example:**

```bash Command theme={null}
curl -X POST http://localhost:30010/v1/set_lora \
  -H "Content-Type: application/json" \
  -d '{
        "lora_nickname": "lora_name",
        "lora_path": "/path/to/lora.safetensors",
        "target": "all",
        "strength": 0.8
      }'
```

**Multiple LoRA Example:**

```bash Command theme={null}
curl -X POST http://localhost:30010/v1/set_lora \
  -H "Content-Type: application/json" \
  -d '{
        "lora_nickname": ["lora_1", "lora_2"],
        "lora_path": ["/path/to/lora1.safetensors", "/path/to/lora2.safetensors"],
        "target": ["transformer", "transformer_2"],
        "strength": [0.8, 1.0]
      }'
```

**Multiple Dynamic LoRAs with the Same Target:**

```bash Command theme={null}
curl -X POST http://localhost:30010/v1/set_lora \
  -H "Content-Type: application/json" \
  -d '{
        "lora_nickname": ["style_lora", "character_lora"],
        "lora_path": ["/path/to/style.safetensors", "/path/to/character.safetensors"],
        "target": "all",
        "strength": [0.7, 0.9],
        "merge_mode": "dynamic"
      }'
```

> [!NOTE]
>
> When using multiple LoRAs:
>
> * All list parameters (`lora_nickname`, `lora_path`, `target`, `strength`) must have the same length
> * If `target` or `strength` is a single value, it will be applied to all LoRAs
> * Multiple LoRAs applied to the same target are applied in order

**Merge LoRA Weights**

Manually merges the currently set LoRA weights into the base model.

> [!NOTE]
>
> With FSDP-sharded weights, manual merge may require a full-gather and can OOM. Use `set_lora` with `merge_mode="auto"` or `"dynamic"` for the lower-peak path.

**Endpoint:** `POST /v1/merge_lora_weights`

**Parameters:**

* `target` (string, optional): Which transformer(s) to merge. One of "all" (default), "transformer", "transformer\_2", "critic"
* `strength` (float, optional): LoRA strength for merge, default 1.0. Values \< 1.0 reduce the effect, values > 1.0 amplify the effect

**Curl Example:**

```bash theme={null}
curl -X POST http://localhost:30010/v1/merge_lora_weights \
  -H "Content-Type: application/json" \
  -d '{"strength": 0.8}'
```

**Unmerge LoRA Weights**

Unmerges the currently active LoRA weights from the base model, restoring it to its original state. This **must** be called before setting a different LoRA.

**Endpoint:** `POST /v1/unmerge_lora_weights`

**Curl Example:**

```bash theme={null}
curl -X POST http://localhost:30010/v1/unmerge_lora_weights \
  -H "Content-Type: application/json"
```

**List LoRA Adapters**

Returns loaded LoRA adapters and current application status per module.

**Endpoint:** `GET /v1/list_loras`

**Curl Example:**

```bash theme={null}
curl -sS -X GET "http://localhost:30010/v1/list_loras"
```

**Response Example:**

```json theme={null}
{
  "loaded_adapters": [
    { "nickname": "lora_a", "path": "/weights/lora_a.safetensors" },
    { "nickname": "lora_b", "path": "/weights/lora_b.safetensors" }
  ],
  "active": {
    "transformer": [
      {
        "nickname": "lora2",
        "path": "tarn59/pixel_art_style_lora_z_image_turbo",
        "merged": true,
        "mode": "merged",
        "strength": 1.0
      }
    ]
  }
}
```

Notes:

* If LoRA is not enabled for the current pipeline, the server will return an error.
* `num_lora_layers_with_weights` counts only layers that have LoRA weights applied for the active adapter.

### Example: Switching LoRAs

1. Set LoRA A:
   ```bash Command theme={null}
   curl -X POST http://localhost:30010/v1/set_lora -d '{"lora_nickname": "lora_a", "lora_path": "path/to/A"}'
   ```
2. Generate with LoRA A...
3. Unmerge LoRA A:
   ```bash Command theme={null}
   curl -X POST http://localhost:30010/v1/unmerge_lora_weights
   ```
4. Set LoRA B:
   ```bash Command theme={null}
   curl -X POST http://localhost:30010/v1/set_lora -d '{"lora_nickname": "lora_b", "lora_path": "path/to/B"}'
   ```
5. Generate with LoRA B...

### Adjust Output Quality

The server supports adjusting output quality and compression levels for both image and video generation through the `output-quality` and `output-compression` parameters.

#### Parameters

* **`output-quality`** (string, optional): Preset quality level that automatically sets compression. **Default is `"default"`**. Valid values:
  * `"maximum"`: Highest quality (100)
  * `"high"`: High quality (90)
  * `"medium"`: Medium quality (55)
  * `"low"`: Lower quality (35)
  * `"default"`: Auto-adjust based on media type (50 for video, 75 for image)

* **`output-compression`** (integer, optional): Direct compression level override (0-100). **Default is `None`**. When provided (not `None`), takes precedence over `output-quality`.
  * `0`: Lowest quality, smallest file size
  * `100`: Highest quality, largest file size

#### Notes

* **Precedence**: When both `output-quality` and `output-compression` are provided, `output-compression` takes precedence
* **Format Support**: Quality settings apply to JPEG, and video formats. PNG is lossless: by default it is stored without zlib compression, which encodes fastest but keeps files close to the raw pixel size; an `output-compression` other than 75 selects zlib level `round(output-compression / 100 * 9)` instead
* **File Size vs Quality**: Lower compression values (or "low" quality preset) produce smaller files but may show visible artifacts


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.