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

# OpenAI Compatibility

> Point the official OpenAI SDK at deAPI — images, audio, embeddings and video with the request and response shapes you already know.

deAPI exposes an OpenAI-compatible `/v1/*` API. Point the official OpenAI SDK (Python, Node, or plain cURL) at our base URL, use your deAPI token as the API key, and call our models with the request and response shapes you already know.

This is a translation layer over the deAPI inference network — not a rebrand of OpenAI's models. Everything below documents exactly where the two contracts match and where they deliberately differ. It is the same approach used by Groq, Together AI, and Fireworks AI.

**Base URL:** `https://oai.deapi.ai/v1`

| Area | Where we stand |
| - | - |
| **Works today** | Models, embeddings, image generation, image editing, text-to-speech, transcription, video generation |
| **Not available** | `/v1/chat/completions`, `/v1/files`, voice cloning, moderation, translations |
| **Model IDs** | Native only — `Flux1schnell`, `Kokoro`, `WhisperLargeV3Ct2`, … There are no `dall-e-3` / `tts-1` / `whisper-1` aliases |
| **Streaming** | Not supported on any endpoint |

***

## Quick start

> [tab] Python
>
> ```bash theme={null}
> pip install openai
> export OPENAI_API_KEY="sk-dp-1234-AbCdEf..."
> export OPENAI_BASE_URL="https://oai.deapi.ai/v1"
> ```
>
> ```python theme={null}
> from openai import OpenAI
>
> client = OpenAI()   # reads OPENAI_API_KEY and OPENAI_BASE_URL from the env
>
> img = client.images.generate(
>     model="Flux1schnell",
>     prompt="a red fox in a snowy forest, cinematic lighting",
>     size="1024x1024",
> )
> print(img.data[0].url)
> ```

> [tab] Node.js / TypeScript
>
> ```bash theme={null}
> npm install openai
> export OPENAI_API_KEY="sk-dp-1234-AbCdEf..."
> export OPENAI_BASE_URL="https://oai.deapi.ai/v1"
> ```
>
> ```typescript theme={null}
> import OpenAI from "openai";
>
> const client = new OpenAI();
>
> const img = await client.images.generate({
>   model: "Flux1schnell",
>   prompt: "a red fox in a snowy forest, cinematic lighting",
>   size: "1024x1024",
> });
> console.log(img.data[0].url);
> ```

> [tab] cURL
>
> ```bash theme={null}
> curl -s https://oai.deapi.ai/v1/images/generations \
>   -H "Authorization: Bearer sk-dp-1234-AbCdEf..." \
>   -H "Content-Type: application/json" \
>   -d '{"model":"Flux1schnell","prompt":"a red fox in a snowy forest","size":"1024x1024"}'
> ```

> [!TIP]
>
> **Get your API key** at [app.deapi.ai/dashboard](https://app.deapi.ai/dashboard). New accounts receive a **\$5 bonus** — no credit card required.

***

## Authentication

Create an API key in the deAPI panel. It looks like `sk-dp-<id>-<secret>` and goes, unchanged, into the standard OpenAI `Authorization` header:

```http theme={null}
Authorization: Bearer sk-dp-<id>-<secret>
```

It is the same key you use with the native API at `https://api.deapi.ai` — paste it as is, with no prefix to add or remove.

Keys created before the `sk-dp-` format keep working here: the raw `<id>|<secret>` form, and the same key with a `dpn-sk-` prefix added. A raw key contains a literal `|`, so quote it in a shell.

Every request validates the key against your deAPI account, so a revoked key stops working immediately.

> [!WARNING]
>
> Keys with an [IP allowlist](https://docs.deapi.ai/api-keys.md#key-restrictions) do not work through this endpoint. Use a key without an IP allowlist here, or call the native API at `https://api.deapi.ai` instead.

| Response | Meaning |
| - | - |
| `401` `missing_api_key` | No `Authorization` header, an empty one, or a scheme other than `Bearer` |
| `401` `invalid_api_key` | The key was rejected by deAPI: unknown, malformed, expired or deactivated |

The `Bearer` scheme is matched case-insensitively, so `authorization: bearer …` works too.

### Calling from a browser

`/v1/*` sends CORS headers, so `openai-node` works in the browser with `dangerouslyAllowBrowser: true`, as does a plain `fetch` from any origin. Preflight is answered without authentication (`204`, `Access-Control-Max-Age: 86400`), every header the SDK sends is accepted, and these are exposed to scripts:

```http theme={null}
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS
Access-Control-Allow-Headers: authorization,content-type,idempotency-key
Access-Control-Expose-Headers: X-Request-Id, X-DeAPI-Request-Id, Retry-After,
  X-Should-Retry, X-RateLimit-Type, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
```

So a failure in the browser still gives you the id to quote in a support ticket.

> [!WARNING]
>
> **Read the flag name before you use it.** Anything you put in browser JavaScript is readable by everyone who loads the page, and that includes your deAPI token — which is a billing credential, not a session cookie. This is a viable path for a demo, an internal tool behind your own auth, or a prototype. It is not one for a public site. For anything user-facing, keep the token on your server and proxy the calls.

***

## Timeouts

Image, audio and edit jobs run on a distributed GPU network and the gateway holds the HTTP connection until the job finishes. A request may legitimately take up to 10 minutes, which is exactly where the OpenAI SDK's own 600 s default sits. For heavy work (image edits, long transcriptions, `n > 1`) raise it:

> [tab] Python
>
> ```python theme={null}
> client = OpenAI(timeout=900.0)   # seconds
> ```

> [tab] Node.js / TypeScript
>
> ```typescript theme={null}
> const client = new OpenAI({ timeout: 900_000 });  // milliseconds
> ```

Video generation is the exception — it is asynchronous by design and returns immediately. See [Video](#video).

***

## Supported endpoints

| Endpoint | Method | Mode |
| - | - | - |
| `/v1/models` | `GET` | Synchronous |
| `/v1/models/{model}` | `GET` | Synchronous |
| `/v1/embeddings` | `POST` | Synchronous |
| `/v1/images/generations` | `POST` | Job — the connection is held until it completes |
| `/v1/images/edits` | `POST` | Job — the connection is held until it completes |
| `/v1/audio/speech` | `POST` | Job — the connection is held until it completes |
| `/v1/audio/transcriptions` | `POST` | Job — the connection is held until it completes |
| `/v1/videos`, `/v1/videos/{id}`, `/v1/videos/{id}/content` | `POST`, `GET` | Natively asynchronous |

> [!NOTE]
>
> **Paths that are recognised but not implemented.** `POST /v1/videos/edits`, `POST /v1/videos/extensions`, `POST /v1/videos/characters`, `GET /v1/videos/characters/{id}`, `GET /v1/videos` (list), `DELETE /v1/videos/{id}`, `POST /v1/videos/{id}/remix`.
>
> These exist in the OpenAI spec but have no counterpart in our backend. They answer `404` with `code: "endpoint_not_implemented"` — the code, not the status, is what tells you the path was understood and there is no typo on your side. Branch on `code`; a plain `404` from a real endpoint carries a different one (`model_not_found`, `video_not_found`).
>
> **They used to answer `501`, and the reason we changed it is worth knowing.** Both official SDKs retry every response with status `>= 500`. A mistyped URL therefore cost you four requests with backoff and surfaced as `InternalServerError` — your monitoring reported an outage that was not happening. `404` maps to `NotFoundError` and is not retried, so a typo now fails once, immediately, with a message that names the path.
>
> Two codes share the `404`, and the difference is only diagnostic: an unrecognised path answers `endpoint_not_implemented`, while extra segments below a route we do own (`/v1/videos/foo/bar`) answer `endpoint_not_found`. Treat them the same way — you have the wrong URL.
>
> Calling a real endpoint with the wrong verb is different again: `405 method_not_allowed`, and the message names the verb to use.

***

## Models

`GET /v1/models` returns the models available to your account. The catalog is plan-dependent, so two accounts can legitimately see different lists.

```python theme={null}
for m in client.models.list().data:
    print(m.id)
```

`GET /v1/models/{model}` (`client.models.retrieve(...)`) returns a single entry in the same shape. Unknown, hidden, or out-of-plan models answer `404 model_not_found`.

The response shape is standard: `{id, object, created, owned_by}`, where `owned_by` is always `deapi` (it read `depin` until November 2026). **`created` is the date the model first became available on this gateway**, not the date the model itself was built — the inference backend publishes no such date, and this is the only one we can state truthfully. Cohorts that arrived together share a timestamp, so it does not order models within a release.

Entries used to report `0` unless the model was also listed on OpenRouter. Every model now carries a real timestamp.

Catalog reads are cached for 5 minutes, so a model added or removed on the deAPI side appears (or disappears) within that window.

```json GET /v1/models → 200 theme={null}
{
  "object": "list",
  "data": [
    {"id": "Flux1schnell", "object": "model", "created": 1776902400, "owned_by": "deapi"},
    {"id": "Kokoro", "object": "model", "created": 1776902400, "owned_by": "deapi"},
    {"id": "Bge_M3_FP16", "object": "model", "created": 1776902400, "owned_by": "deapi"},
    {"id": "QwenImageEdit_Plus_NF4", "object": "model", "created": 1776902400, "owned_by": "deapi"},
    {"id": "Ltx2_3_22B_Dist_INT8", "object": "model", "created": 1777334400, "owned_by": "deapi"},
    {"id": "WhisperLargeV3Ct2", "object": "model", "created": 1787011200, "owned_by": "deapi"}
  ]
}
```

```json GET /v1/models/Flux1schnell → 200 theme={null}
{"id": "Flux1schnell", "object": "model", "created": 1776902400, "owned_by": "deapi"}
```

```json GET /v1/models/dall-e-3 → 404 theme={null}
{
  "error": {
    "message": "Model \"dall-e-3\" is not available on this gateway.",
    "type": "not_found_error",
    "code": "model_not_found"
  }
}
```

For the full native catalog with capabilities, limits, defaults and LoRAs, use the [Model Selection endpoint](https://docs.deapi.ai/api/v2/utilities/models.md) or the [Models guide](https://docs.deapi.ai/models.md).

> [!WARNING]
>
> **Partner models are native-only.** deAPI's catalog includes hosted partner models whose IDs look like the ones you already type — `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2.5`, `nano-banana-2`, `nano-banana-2.1`, and the video model `seedance-2.5`. **None of them is routable through this gateway.** They are absent from `GET /v1/models` and every call naming one answers `404 model_not_found`, on `/v1/models/{model}` and on POST alike.
>
> This trips people up in exactly one way: `gpt-image-2` is a real deAPI model *and* the natural thing to send to an OpenAI-shaped endpoint, so the `404` reads like an outage rather than a routing rule. Reach partner models through the [native API](https://docs.deapi.ai/api/v2/overview.md); they are billed differently from the network models, which is the reason they are not folded in here.

### When a model name is refused

A name your account cannot use fails in one of three ways, and the code says which:

| Outcome | Answer | What it means |
| - | - | - |
| The gateway does not know the name at all | `404 model_not_found` | A typo, an OpenAI alias, or a native-only model such as a partner model |
| It knows the name, but not on this endpoint | `400 model_wrong_endpoint` | The message names the endpoint type it does serve, e.g. `endpoint_type=video_generation` |
| It knows the name and the endpoint, but does not run it for your account | `400 invalid_value` | `message` carries the reason |

Build your integration against `GET /v1/models`. It is already filtered to your account, so every name in it resolves on the endpoint it belongs to — which makes it the list to check first when a model name is refused.

### Why there are no OpenAI model aliases

We publish native model IDs only. Aliasing `dall-e-3` onto `Flux1schnell` would promise an OpenAI parameter contract — its sizes, qualities and defaults — that our models do not implement. A wrong picture is worse than an explicit model name, so `model="dall-e-3"` returns `404 model_not_found` — on POST endpoints as well as on `GET /v1/models/{model}`.

### Migrating from OpenAI

Three parameters change. Everything else — request format, response schema, error envelope — follows the OpenAI specification.

| Parameter | OpenAI | deAPI |
| - | - | - |
| `base_url` / `baseURL` | `https://api.openai.com/v1` | `https://oai.deapi.ai/v1` |
| `api_key` / `apiKey` | `sk-...` | `sk-dp-<id>-<secret>` — your deAPI key as is |
| `model` | `dall-e-3`, `tts-1`, … | Native model ID (see below) |

| If you were calling | Use instead |
| - | - |
| `dall-e-3`, `gpt-image-1` (generations) | `Flux1schnell`, `Flux_2_Klein_4B_BF16`, `ZImageTurbo_INT8`, `ZAnimeDistill_8Step_INT8` |
| `gpt-image-1` (edits) | `QwenImageEdit_Plus_NF4`, `Flux_2_Klein_4B_BF16` |
| `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts` | `Kokoro`, `Chatterbox`, `Qwen3_TTS_12Hz_1_7B_CustomVoice` |
| `whisper-1`, `gpt-4o-transcribe` | `WhisperLargeV3`, `WhisperLargeV3Ct2` |
| `text-embedding-3-small` | `Bge_M3_FP16` |
| `sora-2` | `Ltx2_5_22B_Dist_INT8`, `Ltx2_3_22B_Dist_INT8`, `MiniMaxH3_33B_Turbo_INT8`, `Ltxv_13B_0_9_8_Distilled_FP8` |

***

## Embeddings

```python theme={null}
r = client.embeddings.create(model="Bge_M3_FP16", input=["first", "second"])
print(len(r.data), len(r.data[0].embedding))
```

| Model | Dimensions |
| - | - |
| `Bge_M3_FP16` | 1024 |

| Field | Behaviour |
| - | - |
| `input` | String or array of strings |
| `encoding_format` | `float` (default) or `base64` |
| `dimensions` | Accepted, ignored — you always get the model's native width |
| `user` | Accepted, not forwarded |

> [!WARNING]
>
> `dimensions` does not resize the vector. `Bge_M3_FP16` always returns 1024 floats, whatever you pass. Size your index from the response, not from the request.

```json encoding_format: "float" (default) → 200 theme={null}
{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [-0.0234, 0.1187, -0.0051, "… 1024 floats total"]},
    {"object": "embedding", "index": 1, "embedding": [0.0412, -0.0776, 0.0093, "… 1024 floats total"]}
  ],
  "model": "Bge_M3_FP16",
  "usage": {"prompt_tokens": 0, "total_tokens": 0}
}
```

```json encoding_format: "base64" → 200 theme={null}
{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": "2S6XvPmRND2Ln6a8…"}
  ],
  "model": "Bge_M3_FP16",
  "usage": {"prompt_tokens": 0, "total_tokens": 0}
}
```

Array inputs are capped at **100 items** per request; above that you get `400 input_too_large`. The batch is all-or-nothing: the first failure cancels the rest, so you receive either every vector or a single error — never a partially filled `data[]`.

> [!WARNING]
>
> **The cap is not your rate limit, and batching does not shelter you from it.** The backend embeds one string per call, so an array of N strings is N jobs and counts as **N requests** against your account's allowance. On a plan with a small per-minute bucket a large array can exhaust it, return `429` for the whole request, and still have spent the allowance on the items already dispatched. Size your arrays against your plan's rate limit, not against the 100-item cap.

`usage.prompt_tokens` is always `0`. The backend does not report token counts and inventing one would be worse than reporting zero. `total_tokens` mirrors it.

***

## Image generation

```python theme={null}
img = client.images.generate(
    model="Flux1schnell",
    prompt="an isometric city block at golden hour",
    size="1024x1024",
    quality="high",
    n=2,
    response_format="b64_json",
)
```

| Model | Sizes | `n` max | Notes |
| - | - | - | - |
| `Flux1schnell` | `512x512`, `768x768`, `1024x1024`, `1024x1536`, `1536x1024` | 4 | Distilled: quality maps to 2 / 4 / 8 steps — not 50 |
| `ZImageTurbo_INT8` | `512x512`, `768x768`, `1024x1024` | 4 | 6 / 8 / 16 steps |
| `ZAnimeDistill_8Step_INT8` | `512x512`, `768x768`, `1024x1024` | 4 | Anime-oriented variant, 6 / 8 / 16 steps |
| `Flux_2_Klein_4B_BF16` | Any `WxH` from 256 to 1536 px per side, in steps of 16 (e.g. `1024x1024`, `1536x1024`, `1024x1536`) | 2 | Distilled model with a fixed 4 steps. The same model also does [image editing](#image-editing) |

| Field | Behaviour |
| - | - |
| `model`, `prompt` | Required |
| `n` | Fans out into `n` parallel jobs, capped per model |
| `size` | Validated against the model's list |
| `quality` | `low`, `medium`, `high`, `standard`, `hd`, `auto` → a per-model step preset |
| `response_format` | `url` (default) or `b64_json` |
| `user` | Accepted, not forwarded |

```json response_format: "url" (default) → 200 theme={null}
{
  "created": 1755691200,
  "data": [
    {"url": "https://results.deapi.ai/20297698/kxEJhkVUciFCT9fah9YT4h….png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=18000&X-Amz-Signature=…"},
    {"url": "https://results.deapi.ai/20297699/Nz8c3sQ6CokrLyD7habNz8c…png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=18000&X-Amz-Signature=…"}
  ]
}
```

```json response_format: "b64_json" → 200 theme={null}
{
  "created": 1755691200,
  "data": [
    {"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAAB…"},
    {"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAAB…"}
  ]
}
```

`revised_prompt` is part of the OpenAI shape but is never populated here, so the key is absent — none of our models rewrites your prompt.

`quality="auto"` is the SDK default and means "pick the best setting for this model" — identical to omitting the field. Quality presets are defined per model because distilled models (Flux Schnell: 2–8 steps) and full models operate in disjoint ranges. A generic "high = 50 steps" rule would silently produce garbage on distilled models.

### Rejected fields

| Field | Error | Why |
| - | - | - |
| `stream=true`, `partial_images > 0` | `stream_not_supported` | The response is a single body, not a stream |
| `background="transparent"` | `param_not_supported` | Output is PNG without an alpha channel — measured, not assumed |
| `output_format="jpeg"` \| `"webp"` | `param_not_supported` | Output is always PNG; we do not transcode in the proxy |
| `output_compression` | `param_not_supported` | Applies to JPEG/WebP, which we do not produce (including value `0`) |

Accepted with no change in behaviour: `stream=false`, `partial_images=0`, `background="opaque"` | `"auto"`, `output_format="png"` — these describe what we already do. `moderation` and `style` are accepted and explicitly declared as not affecting the image.

> [!NOTE]
>
> Output is PNG, RGB, no alpha — measured on the bytes, not assumed. With `response_format="url"` you get a pre-signed `results.deapi.ai` link valid for **5 hours** (`X-Amz-Expires` ≈ `18000`, counted from the `X-Amz-Date` in the same query string). There is no expiry field in the JSON body, and unlike a video there is no route that re-signs the link — once it lapses the image is gone from your side. Download promptly, or request `b64_json` and skip the question.

***

## Image editing

Both content types from the spec are supported.

| Model | Input images | Max file | `n` max |
| - | - | - | - |
| `QwenImageEdit_Plus_NF4` | 1 | 10 MB | 2 |
| `Flux_2_Klein_4B_BF16` | Up to 3 (combine) | 10 MB | 2 |

Both are instruction-following editors, not inpainting models. The gateway itself accepts a multipart body up to 50 MiB, but the platform caps a single image at **10 MB** — see [Limits & Quotas → File Uploads](https://docs.deapi.ai/limits-and-quotas.md#file-uploads).

### multipart/form-data

```bash theme={null}
curl -s https://oai.deapi.ai/v1/images/edits \
  -H "Authorization: Bearer sk-dp-1234-AbCdEf..." \
  -F model=QwenImageEdit_Plus_NF4 \
  -F image=@source.png \
  -F prompt="make the sky stormy"
```

Fields: `image` (one or more files), `prompt`, `model`, `n`, `size`, `quality`, `response_format`, `user`. File type is detected from the bytes, not from the declared part header.

### application/json

```json theme={null}
{
  "model": "Flux_2_Klein_4B_BF16",
  "prompt": "combine these into one poster",
  "images": [
    {"image_url": "https://example.com/a.png"},
    {"image_url": "data:image/png;base64,iVBORw0KGgo..."}
  ]
}
```

* `data:` URLs are decoded locally, with no outbound traffic.
* Plain URLs are fetched by the gateway: 10 MB limit, publicly reachable addresses only.
* `file_id` → `400 file_id_not_supported` (there is no Files API here).
* A bare string instead of an object → `400`. We do not reinterpret it.

Ordering, if you care what the gateway touches before it gives up: the model, the required fields and every unsupported-parameter check (`stream`, `output_format`, `mask`, `input_fidelity`, …) are settled **before** any address is fetched. The two per-model limits — `size` and `n` — are checked **after**, so an oversized `n` on an otherwise valid request will still have cost you one outbound fetch of the URL you supplied. A `data:` URL is decoded locally and never leaves the gateway either way.

### Response

Identical envelope to `/v1/images/generations` — the two endpoints share a shape on the wire.

```json theme={null}
{
  "created": 1755691200,
  "data": [
    {"url": "https://results.deapi.ai/20297704/4b81ZKcq5fhd1wclfGAi…png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=18000&X-Amz-Signature=…"}
  ]
}
```

With `response_format="b64_json"` each element carries `b64_json` instead of `url`. With `n=2` you get two elements, one per job.

### Rejected fields on edits

Everything from [image generation](#rejected-fields), plus:

| Field | Error | Why |
| - | - | - |
| `mask` | `mask_not_supported` | No inpainting model on the backend — a deliberate gap, not an oversight |
| `input_fidelity` | `param_not_supported` | Our edit models have no fidelity control |

One deviation in your favour: we accept `quality="hd"` here, even though the spec restricts `hd` to `/images/generations`. The alias is defined per model and produces a sensible preset, so rejecting it would break working integrations.

***

## Text-to-speech

Returns raw audio bytes, not JSON.

```python theme={null}
speech = client.audio.speech.create(
    model="Kokoro",
    voice="af_nova",
    input="Hello from the deAPI network.",
    response_format="mp3",
)
speech.write_to_file("out.mp3")
```

| Model | Voices | Speed | Max input | Languages |
| - | - | - | - | - |
| `Kokoro` | 41 named voices across 7 languages | 0.5 – 2.0 | 10 000 chars | Language comes from the voice prefix |
| `Chatterbox` | Default only | Pinned at 1.0 | 2 000 chars | 23 |
| `Qwen3_TTS_12Hz_1_7B_CustomVoice` | `Vivian`, `Serena`, `Uncle_Fu`, `Dylan`, `Eric`, `Ryan`, `Aiden`, `Ono_Anna`, `Sohee` | Pinned at 1.0 | 5 000 chars | 10 |
| `Qwen3_TTS_12Hz_1_7B_VoiceDesign` | None — the voice is described in `instructions` | Pinned at 1.0 | 5 000 chars | 10 |

| Field | Behaviour |
| - | - |
| `model`, `input` | Required; `input` capped per model |
| `voice` | Validated against the model's voice list |
| `response_format` | `mp3` only |
| `speed` | Validated against the model's range |
| `instructions` | Only on the voice-design model — see below |
| `language` | Our extension, not in the OpenAI spec |

The body is the audio file itself, not JSON:

```http theme={null}
HTTP/1.1 200 OK
Content-Type: audio/mpeg
Content-Length: 41328
X-Request-Id: 08100094961504aa5352ce5f8a9367cb
X-DeAPI-Request-Id: 9cef6c98-5a55-48c5-854d-420fd5bb7993

<mp3 bytes>
```

> [!WARNING]
>
> Errors on this endpoint still come back as the usual JSON envelope with `Content-Type: application/json`, so branch on the status code before reading the body as audio.

Speed is pinned at `1.0` on `Chatterbox` and the whole Qwen3 family — any other value returns `400 speed_out_of_range`. Those models have no tempo control, and pretending otherwise would bill you for a request executed against your instructions.

OpenAI voice names work on `Kokoro` through aliases: `alloy` → `af_alloy`, `echo` → `am_echo`, `fable` → `bm_fable`, `onyx` → `am_onyx`, `nova` → `af_nova`, `shimmer` → `af_sky`. On `Chatterbox` and Qwen3 they map to that model's own voices.

### Describing a voice instead of picking one

`Qwen3_TTS_12Hz_1_7B_VoiceDesign` takes a natural-language voice description:

```python theme={null}
client.audio.speech.create(
    model="Qwen3_TTS_12Hz_1_7B_VoiceDesign",
    input="Chapter one.",
    voice="alloy",                       # accepted and ignored on this model
    instructions="a low-pitched, calm male narrator",
)
```

* `instructions` on a model with a voice list → `400 instructions_not_supported`, and the message names the model that does support it. We refuse instead of ignoring, because a silently dropped field means paying for half of what you asked for.
* The voice-design model without `instructions` → `400 instructions_required`.
* `voice` is accepted and ignored on that model — OpenAI types the field as required, but this model has no voice list.

### How the language is chosen

The OpenAI spec has no `language` field for speech, and our backend needs one. The first rule that yields a value wins:

1. An explicit `language` in the request (our extension).

2. The voice slug prefix, where the model publishes a mapping. `Kokoro`:

   | Prefix | Language | Voices |
   | - | - | - |
   | `af_`, `am_` | `en-us` | 20 |
   | `bf_`, `bm_` | `en-gb` | 8 |
   | `ef_`, `em_` | `es` | 3 |
   | `ff_` | `fr-fr` | 1 |
   | `hf_`, `hm_` | `hi` | 4 |
   | `if_`, `im_` | `it` | 2 |
   | `pf_`, `pm_` | `pt-br` | 3 |

3. The model's default language.

4. `en-us`.

> [!WARNING]
>
> **No language auto-detection.** `Kokoro` voices are hard-wired to a language and the model does not detect language from the text. All six OpenAI voice aliases map to English voices, so non-English text needs an explicit `voice` from the right family — or an explicit `language`. Drop-in compatibility is incomplete here.

### Rejected fields on speech

| Field | Error |
| - | - |
| `stream_format="sse"` | `stream_not_supported` — audio arrives as one body when synthesis completes |
| `response_format` ≠ `mp3` | `format_not_supported` |
| Unknown `stream_format` value | `param_not_supported` |

`stream_format="audio"` is accepted — it describes the current behaviour.

***

## Transcription

```python theme={null}
with open("meeting.mp3", "rb") as f:
    r = client.audio.transcriptions.create(
        model="WhisperLargeV3Ct2",
        file=f,
        response_format="verbose_json",
        timestamp_granularities=["word"],
        language="en",
    )
```

| Model | Formats | Timestamps | Diarization |
| - | - | - | - |
| `WhisperLargeV3` | `json`, `text`, `verbose_json` | Segment | No |
| `WhisperLargeV3Ct2` | `json`, `text`, `verbose_json`, `diarized_json` | Segment + native word-level | Yes |

| Field | Behaviour |
| - | - |
| `file`, `model` | Required |
| `language` | Forwarded to the backend and affects the result; region subtags are trimmed (`en-US` → `en`) |
| `response_format` | `json` (default), `text`, `verbose_json`, `diarized_json` |
| `timestamp_granularities[]` | `word` requires a model that publishes word-level support; on `WhisperLargeV3` it is `400 timestamp_level_not_supported` rather than a silent fallback to segment timings |

The gateway accepts a multipart body up to 50 MiB, but the platform caps a single audio file at **20 MB** and a single video file at **50 MB**, within a global 75 MB request body cap. See [Limits & Quotas → File Uploads](https://docs.deapi.ai/limits-and-quotas.md#file-uploads).

### Response formats

```json response_format: "json" (default) → 200 theme={null}
{"text": "Good morning. Let's start with the quarterly numbers."}
```

```text response_format: "text" → 200 (Content-Type: text/plain) theme={null}
Good morning. Let's start with the quarterly numbers.
```

```json verbose_json + timestamp_granularities: ["word"] → 200 theme={null}
{
  "task": "transcribe",
  "language": "english",
  "duration": 5.24,
  "text": "Good morning. Let's start with the quarterly numbers.",
  "words": [
    {"word": "Good", "start": 0.12, "end": 0.38},
    {"word": "morning", "start": 0.38, "end": 0.91}
  ],
  "segments": [
    {
      "id": 0,
      "seek": 0,
      "start": 0.0,
      "end": 5.24,
      "text": "Good morning. Let's start with the quarterly numbers.",
      "tokens": [],
      "temperature": 0.0,
      "avg_logprob": -0.2431,
      "compression_ratio": 1.372,
      "no_speech_prob": 0.0
    }
  ]
}
```

```json diarized_json → 200 (WhisperLargeV3Ct2 only) theme={null}
{
  "task": "transcribe",
  "duration": 9.87,
  "text": "Good morning. Morning — shall we start?",
  "segments": [
    {
      "type": "transcript.text.segment",
      "id": "0",
      "start": 0.0,
      "end": 4.12,
      "text": "Good morning.",
      "speaker": "A"
    },
    {
      "type": "transcript.text.segment",
      "id": "1",
      "start": 4.12,
      "end": 9.87,
      "text": "Morning — shall we start?",
      "speaker": "B"
    }
  ],
  "usage": {"type": "duration", "seconds": 9.87}
}
```

`srt` and `vtt` return `400 format_not_supported` — the backend returns text and we do not synthesise subtitle files.

Speakers in `diarized_json` are numbered by first appearance (`A`, `B`, …) and are stable within one response, **not** across calls — the same person may be `A` in one recording and `B` in the next. This matches OpenAI's behaviour without speaker references.

Diarization is available on exactly one model (`WhisperLargeV3Ct2`). Requesting it elsewhere returns `400` before a billable job is created, and the message names the model that can do it.

### Word timings come from the model, never from us

`timestamp_granularities=["word"]` is served only by models that publish word-level support — today `WhisperLargeV3Ct2`. On `WhisperLargeV3` it is a `400`:

```json theme={null}
{
  "error": {
    "message": "Model WhisperLargeV3 does not produce word-level timestamps — it reports [segment] granularity. Models with word timestamps: WhisperLargeV3Ct2.",
    "type": "invalid_request_error",
    "param": "timestamp_granularities[]",
    "code": "timestamp_level_not_supported"
  }
}
```

We used to answer `200` here and build `words[]` by splitting each segment's duration evenly across its words. In a 3-second, 9-word clip every single word came back as exactly 0.333 s — numbers you had no way of telling apart from a measurement. Since a model that does the job properly sits in the same catalog, refusing and naming it is the honest answer.

### Fields in `verbose_json` that carry no real measurement

The shape is always complete so drop-in clients see a stable set of keys, but some values are placeholders rather than measurements:

| Field | Value |
| - | - |
| `start`, `end`, `text` | Real |
| `compression_ratio` | Computed locally |
| `avg_logprob` | Real on `WhisperLargeV3Ct2`, `0` otherwise |
| `seek`, `temperature`, `no_speech_prob` | Always `0` |
| `tokens` | Always an empty array |

The `language` field in the response is a real detection on `WhisperLargeV3Ct2` (the model's own detection wins over your hint, returned as a Whisper-style name such as `english`). On `WhisperLargeV3` it echoes your request instead.

### Rejected fields on transcription

| Field | Error | Why |
| - | - | - |
| `stream=true` | `stream_not_supported` | The response is a single body |
| `include[]` | `param_not_supported` | Asks for logprobs the backend does not return |
| `languages[]` | `param_not_supported` | Use the single `language` field |
| `chunking_strategy` | `param_not_supported` | The backend decides how long audio is split |
| `known_speaker_names[]`, `known_speaker_references[]` | `param_not_supported` | No reference-sample support; returning A/B anyway would be answering a different question |

> [!WARNING]
>
> **Accepted, but with no effect on the transcript:** `prompt`, `temperature`, `keywords[]`. These are best-effort hints at OpenAI too, and we accept them so that existing code keeps working — but they do not change the transcript. If you are counting on `prompt` to force terminology or `temperature=0` to give determinism, it will not happen here.

`stream=false` is accepted; it describes what we already do.

***

## Video

The only family that is asynchronous for the client as well: `POST` returns immediately and you poll for the result.

| Model | Durations (s) | Sizes | fps | Image-to-video |
| - | - | - | - | - |
| `Ltxv_13B_0_9_8_Distilled_FP8` | 1, 2, 3, 4 | `512x512`, `512x768`, `768x512`, `768x768` | 30 | Yes |
| `Ltx2_3_22B_Dist_INT8` | 3, 4, 5, 6, 8, 10 | `768x768`, `768x1024`, `1024x768`, `1024x1024` | 24 | Yes |
| `Ltx2_5_22B_Dist_INT8` | 3, 4, 5, 6, 8, 10 | `768x768`, `1344x768`, `768x1344`, `1024x768`, `768x1024` | 24 | Yes |
| `MiniMaxH3_33B_Turbo_INT8` | 8 | `1344x768`, `768x1344`, `1024x768`, `768x1024`, `768x768` | 24 | Yes |

Each model validates `seconds` and `size` against its own list — the table is a union, not a menu that applies everywhere.

```python theme={null}
import time

job = client.videos.create(
    model="Ltx2_3_22B_Dist_INT8",
    prompt="a paper boat drifting down a rain-soaked street",
    seconds="5",
    size="768x768",
)

while True:
    job = client.videos.retrieve(job.id)
    if job.status in ("completed", "failed"):
        break
    time.sleep(5)

content = client.videos.download_content(job.id)
content.write_to_file("clip.mp4")
```

| Route | Purpose |
| - | - |
| `POST /v1/videos` | Creates the job, returns `{id, status: "queued", …}` |
| `GET /v1/videos/{id}` | `status`: `queued` → `in_progress` → `completed` / `failed` |
| `GET /v1/videos/{id}/content` | Downloads the finished file |

```json POST /v1/videos → 200 theme={null}
{
  "id": "c08a339c-73e5-4d67-a4d5-231302fbff9a",
  "object": "video",
  "status": "queued",
  "created_at": 1755691200,
  "expires_at": 1755777600,
  "model": "Ltx2_3_22B_Dist_INT8",
  "prompt": "a paper boat drifting down a rain-soaked street",
  "seconds": "5",
  "size": "768x768",
  "progress": 0
}
```

```json GET — running → 200 theme={null}
{
  "id": "c08a339c-73e5-4d67-a4d5-231302fbff9a",
  "object": "video",
  "status": "in_progress",
  "created_at": 1755691200,
  "expires_at": 1755777600,
  "model": "Ltx2_3_22B_Dist_INT8",
  "prompt": "a paper boat drifting down a rain-soaked street",
  "seconds": "5",
  "size": "768x768",
  "progress": 50
}
```

```json GET — finished → 200 theme={null}
{
  "id": "c08a339c-73e5-4d67-a4d5-231302fbff9a",
  "object": "video",
  "status": "completed",
  "created_at": 1755691200,
  "completed_at": 1755691436,
  "expires_at": 1755777600,
  "model": "Ltx2_3_22B_Dist_INT8",
  "prompt": "a paper boat drifting down a rain-soaked street",
  "seconds": "5",
  "size": "768x768",
  "progress": 100
}
```

```json GET — failed → 200 theme={null}
{
  "id": "c08a339c-73e5-4d67-a4d5-231302fbff9a",
  "object": "video",
  "status": "failed",
  "created_at": 1755691200,
  "expires_at": 1755777600,
  "model": "Ltx2_3_22B_Dist_INT8",
  "seconds": "5",
  "size": "768x768",
  "progress": 0,
  "error": {
    "code": "job_failed",
    "message": "Job failed during rendering."
  }
}
```

> [!NOTE]
>
> A failed job carries an `error` object inside the video object and the `GET` itself still returns **200** — the request succeeded, the job did not. Branch on `status`, not on the status code.

`GET /v1/videos/{id}/content` returns the file:

```http theme={null}
HTTP/1.1 200 OK
Content-Type: video/mp4
X-Request-Id: fe5c29e21216dae7f60a9733b4d7faf3

<mp4 bytes>
```

Before the job completes the same route answers `409 video_not_ready`, and `502 video_failed` if it failed:

```json theme={null}
{
  "error": {
    "message": "Video c08a339c-73e5-4d67-a4d5-231302fbff9a is not ready (status=in_progress). Poll /v1/videos/c08a339c-73e5-4d67-a4d5-231302fbff9a until status=completed.",
    "type": "invalid_request_error",
    "code": "video_not_ready"
  }
}
```

`?variant=` accepts `video` only; anything else (`thumbnail`, `spritesheet`, …) returns `501 variant_not_supported` rather than quietly handing you the main file.

### Image-to-video

```json theme={null}
{
  "model": "Ltx2_3_22B_Dist_INT8",
  "prompt": "the camera pushes in slowly",
  "input_reference": {"image_url": "https://example.com/first-frame.png"}
}
```

`input_reference` is an object, exactly as in the spec — `image_url` accepts a public URL or a base64 `data:` URL (10 MB limit; `data:` URLs are decoded locally). `file_id` returns `400`, since there is no Files API here. A bare string returns `400` rather than being reinterpreted.

All three video models accept `input_reference` — there is currently no video model on this gateway that takes a prompt but refuses a first frame.

**`Ltxv_13B_0_9_8_Distilled_FP8` is by far the cheapest of them** and used to reject `input_reference` even though it supports the mode natively. If you built around `Ltx2_3_22B_Dist_INT8` or `MiniMaxH3_33B_Turbo_INT8` only because of that rejection, it is worth re-measuring.

The reference is fetched while the request is being validated, so an unreachable or oversized address fails the call with `400 input_reference_unreadable` and the message carries the status we got. A `data:` URL is decoded locally and never leaves the gateway.

### Fields not to take literally

* `progress` is mostly synthetic: `0` when queued, `100` when completed, `50` in between. It is not a render progress meter.
* `expires_at` is `created_at` + 24 h computed on our side. `/content` re-resolves a fresh download link on every call, so the window is real — but it is our promise, not a backend guarantee.
* `model`, `prompt`, `size`, `seconds`, `created_at` in the `GET` response come from in-memory state recorded when the job was created. After a gateway restart they come back empty; `/content` keeps working.
* An unrecognised backend status is reported as `in_progress`, so your polling loop keeps going instead of failing on a transient mismatch.

> [!WARNING]
>
> **Enum mismatch — read before integrating.** The OpenAI spec allows `seconds` ∈ `{4, 8, 12}` and four fixed resolutions. Our models publish `1 | 2 | 3 | 4 | 5 | 6 | 8 | 10` seconds and eight sizes (`512x512`, `512x768`, `768x512`, `768x768`, `768x1024`, `1024x768`, `1024x1024`, `1344x768`).
>
> A strictly typed TypeScript client will not compile `"512x512"`, and Python type checkers will warn. This is the direct consequence of exposing our own models with their own parameters; it cannot be "fixed" without pretending to be OpenAI models. Cast or bypass the enum on the client side.

***

## Errors

Every error under `/v1/*` uses the OpenAI envelope:

```json theme={null}
{
  "error": {
    "message": "Size \"2048x2048\" is not supported by Flux1schnell. Supported: [512x512 768x768 1024x1024 1024x1536 1536x1024].",
    "type": "invalid_request_error",
    "param": "size",
    "code": "size_not_supported"
  }
}
```

Build your handling on `code`, not on `message`. `param` and `code` are omitted entirely when they do not apply, so treat them as optional keys rather than expecting empty strings. Some responses carry no `code` at all; for those, `type` plus the HTTP status is the stable signal.

| HTTP | `type` |
| - | - |
| `400` | `invalid_request_error` |
| `401` | `authentication_error` |
| `404` | `not_found_error` |
| `405`, `409` | `invalid_request_error` |
| `422` | `idempotency_error` |
| `429` | `rate_limit_exceeded` or `insufficient_quota` |
| `501` | `not_implemented` — only `variant_not_supported` on `/v1/videos/{id}/content` |
| `503` | `overloaded_error` |
| `504` | `timeout_error` |
| `500`, `502`, other | `api_error` |

`not_implemented` and `timeout_error` are our extensions to OpenAI's vocabulary: the first means "this surface will not work this way", the second "retry with a longer deadline". Unimplemented *paths* are `404 endpoint_not_implemented`, not `501` — `501` is reserved for a recognised route asked for something it cannot produce, which today is only `variant_not_supported`.

**`429` carries two different meanings and `type` tells them apart:** `rate_limit_exceeded` means *too fast*, `insufficient_quota` means *out of credit*. The second is not solved by waiting.

### Common codes

| Code | HTTP | Meaning |
| - | - | - |
| `missing_required_parameter` | 400 | A field the spec requires is missing |
| `model_not_found` | 404 | Model outside your account's catalog, on every endpoint including POST |
| `model_wrong_endpoint` | 400 | The model exists but does not serve this endpoint |
| `param_not_supported` | 400 | Legal in the spec, no counterpart on our backend |
| `method_not_allowed` | 405 | Right path, wrong verb; the message names the verb to use |
| `endpoint_not_implemented` | 404 | The path is understood but this gateway does not serve it |
| `endpoint_not_found` | 404 | Extra segments below a route we do own, e.g. `/v1/videos/foo/bar` |
| `insufficient_quota` | 429 | The account is out of credit — not a rate limit, and waiting will not help. Used to be reported as `400`, which wrongly blamed your payload |
| `timestamp_level_not_supported` | 400 | Word-level timestamps asked of a segment-only model; the message names one that can |
| `stream_not_supported` | 400 | Streaming was requested; we do not open streams |
| `idempotency_key_reuse` | 422 | Same `Idempotency-Key`, different request body |
| `invalid_value` | 400 / 401 / 403 / 404 / 409 | The backend rejected the request; `message` explains. `param` names the field **as you sent it** — the backend's internal field names are translated back into the OpenAI ones. Was `upstream_validation_error` |
| `upstream_unavailable` | 503 | A retryable failure — capacity, not your request |
| `upstream_job_failed` | 502 | The job failed permanently; `message` carries the reason |
| `upstream_timeout` | 504 | The job did not finish within the wait window |
| `internal_error` | 500 | Unexpected failure on our side |

Endpoint-specific codes are listed in the sections above.

### Retry guidance

* `503 upstream_unavailable` — retry with backoff; this is our capacity, not your payload.
* `504 upstream_timeout` — the job exceeded the wait window; retry, ideally with an [`Idempotency-Key`](#idempotency) so you are not billed twice.
* `502 upstream_job_failed` — do not blindly retry; read `message` first.
* `429 rate_limit_exceeded` — retry after the delay we give you; see [Rate limits](#rate-limits).
* `429 insufficient_quota` — **do not retry**; top up the account first. You do not have to code around this: the response carries `X-Should-Retry: false`, which both official SDKs honour ahead of the status, so it fails once instead of three times.
* `404` — never retried by the SDKs, which is the point: a wrong path or an unknown model fails immediately instead of costing you four round-trips.

```json 503 — retryable capacity failure theme={null}
{
  "error": {
    "message": "Upstream job failed: no worker available for this model.",
    "type": "overloaded_error",
    "code": "upstream_unavailable"
  }
}
```

```json 504 — the job outlived the wait window theme={null}
{
  "error": {
    "message": "Job did not complete within the wait window.",
    "type": "timeout_error",
    "code": "upstream_timeout"
  }
}
```

### Request IDs

Every response, including errors, carries an `X-Request-Id` header. Quote it in support tickets — it is how we find your request in the logs. Request bodies are never logged.

Endpoints that enqueue work also return `X-DeAPI-Request-Id` with the backend job identifier — one value for single-job endpoints (`audio/speech`, `audio/transcriptions`, `videos`), or a comma-separated list where the request fans out (`embeddings`, `images/generations`, `images/edits`). It is set before the status code, so it is present on error responses too.

***

## Rate limits

Rate limiting is enforced by your deAPI plan and passed through unmodified. On `429` you get the OpenAI envelope:

```json theme={null}
{"error": {"message": "Rate limit exceeded (per-minute). Retry after 60 seconds.", "type": "rate_limit_exceeded"}}
```

Note there is no `code` field on this one — `type` is the stable signal.

**Not every `429` is a rate limit.** Running out of credit also returns `429`, with `"type": "insufficient_quota"` and a matching `code`. Waiting does not clear that one — only a top-up does — so it is sent with `X-Should-Retry: false` and your SDK stops after the first attempt:

```json theme={null}
{"error": {"message": "Insufficient balance.", "type": "insufficient_quota", "code": "insufficient_quota"}}
```

A `429` carries the accounting headers:

```http theme={null}
X-RateLimit-Type: minute
X-RateLimit-Limit: 3
X-RateLimit-Remaining: 0
X-RateLimit-Daily-Limit: 1000
X-RateLimit-Daily-Remaining: 947
Retry-After: 60
```

The SDKs read `Retry-After` and `x-should-retry` only — the `X-RateLimit-*` values are there for your dashboards, not for the SDK. For the per-plan numbers, see [Limits & Quotas](https://docs.deapi.ai/limits-and-quotas.md).

A **per-minute** limit is deliberately left retryable: waiting is the right response and `Retry-After` says how long. `X-Should-Retry: false` is sent on the two `429`s where retrying cannot work:

* `insufficient_quota` — no amount of waiting changes that answer.
* A rate limit whose `Retry-After` exceeds **120 seconds**, i.e. the daily window. Neither SDK waits that long unaided: `openai-python` declines to retry above 120 s, and `openai-node` honours `Retry-After` only below 60 s and otherwise falls back to a 0.5 s backoff — three requests into a window that reopens hours later, each one another hit on the same counter.

The header is withheld when the delay is something your client can sensibly wait out, including a daily limit hit just before the window rolls over. The real `Retry-After` is always sent, so you can schedule your own retry either way.

> [!WARNING]
>
> **You cannot track headroom from a successful response here.** The native API returns `X-RateLimit-Limit` and `X-RateLimit-Remaining` on `200`s, so you can throttle before you are throttled. This gateway does not: a successful `/v1/*` response carries `X-Request-Id` and nothing else about limits (measured over 351 consecutive calls — no `X-RateLimit-*` header on any of them). If you need to watch the counter, read it from the [native API](https://docs.deapi.ai/api/v2/overview.md); here, handle the `429` when it arrives.

***

## Idempotency

Send `Idempotency-Key: <uuid>` on a `POST` and a repeated request with the same key and the same body returns the stored response plus `Idempotent-Replayed: true` — no second job, no second charge.

```python theme={null}
import uuid

key = str(uuid.uuid4())
r1 = client.embeddings.create(
    model="Bge_M3_FP16", input="hello",
    extra_headers={"Idempotency-Key": key},
)
r2 = client.embeddings.create(          # same key, same body → replayed
    model="Bge_M3_FP16", input="hello",
    extra_headers={"Idempotency-Key": key},
)
```

What you should know about the mechanics:

* **`POST` only.** `GET`/`HEAD` and requests without the header pass through untouched.
* **Scoped per caller and per endpoint.** The same key on `/v1/embeddings` and `/v1/images/generations` are two independent entries, and two accounts never share one.
* **Rotating your token invalidates in-flight keys.**
* **Only `2xx` responses are stored.** After a `4xx` you are free to fix the request and retry with the same key instead of being served a stale error.
* **Same key, different body → `422 idempotency_key_reuse`.** We never quietly serve the previous response.
* **Bodies over 1 MiB bypass the mechanism entirely** — in practice, multipart uploads (`images/edits`, `audio/transcriptions`). Responses over 1 MiB are not stored either: the request runs normally, it simply cannot be replayed.
* **Two concurrent requests with the same key both execute.** There is no in-flight lock; the last one to finish wins. Sequential SDK retries — the common case — are protected.
* **A replayed response carries a fresh `X-Request-Id`**, not the original one.
* **`POST /v1/videos` is covered too.** A retried create would otherwise produce a second job whose `id` you never learn, orphaned and billed. With a key, the same `id` comes back.

Entries live for one hour.

***

## Framework integrations

Because deAPI uses the OpenAI API format, it works with any framework that accepts a `base_url` / `api_base` parameter.

> [tab] LangChain
>
> ```python theme={null}
> from langchain_openai import OpenAIEmbeddings
>
> embeddings = OpenAIEmbeddings(
>     openai_api_key="sk-dp-1234-AbCdEf...",
>     openai_api_base="https://oai.deapi.ai/v1",
>     model="Bge_M3_FP16",
> )
> ```

> [tab] LlamaIndex
>
> ```python theme={null}
> from llama_index.embeddings.openai import OpenAIEmbedding
>
> embed_model = OpenAIEmbedding(
>     api_key="sk-dp-1234-AbCdEf...",
>     api_base="https://oai.deapi.ai/v1",
>     model="Bge_M3_FP16",
> )
> ```

> [tab] Vercel AI SDK
>
> ```typescript theme={null}
> import { createOpenAI } from "@ai-sdk/openai";
>
> const deapi = createOpenAI({
>   apiKey: "sk-dp-1234-AbCdEf...",
>   baseURL: "https://oai.deapi.ai/v1",
> });
> ```

If your codebase already uses the standard OpenAI environment variables, override them at the process level — zero code changes required:

```bash theme={null}
export OPENAI_API_KEY="sk-dp-1234-AbCdEf..."
export OPENAI_BASE_URL="https://oai.deapi.ai/v1"
```

For multi-provider setups (e.g. OpenAI for chat, deAPI for images and audio), instantiate separate clients:

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

openai_client = OpenAI(api_key=os.environ["OPENAI_KEY"])

deapi_client = OpenAI(
    api_key=os.environ["DEAPI_KEY"],
    base_url="https://oai.deapi.ai/v1",
)

# openai_client → GPT models
# deapi_client  → images, audio, video, embeddings
```

***

## Deliberate differences from OpenAI

A single list of everything that will not behave the way the OpenAI docs describe.

| Area | Difference |
| - | - |
| Model IDs | Native only. No `dall-e-3`, `tts-1`, `whisper-1` aliases |
| Model catalog | Plan-dependent — two accounts can see different lists |
| Streaming | Not supported anywhere: `stream=true`, `partial_images`, `stream_format=sse` are rejected |
| Image output | Always PNG without alpha; `output_format`, `output_compression`, `background=transparent` rejected |
| Image edits | `mask` rejected — no inpainting model. `quality=hd` accepted although the spec restricts it to generations |
| `n` (images) | 4 on generations, 2 on edits — OpenAI allows 10 |
| TTS formats | `mp3` only; `opus`, `aac`, `flac`, `wav`, `pcm` rejected |
| TTS language | No auto-detection — non-English text needs an explicit `voice` or `language` |
| Transcription | `srt`/`vtt` rejected; `prompt`, `temperature`, `keywords[]` accepted but inert; `include[]`, `languages[]`, `chunking_strategy` rejected |
| Speaker labels | Sequential letters only; speaker references not supported |
| Transcription detail | `segments[].tokens` is always `[]` and `avg_logprob` `0` outside `WhisperLargeV3Ct2` — the backend returns plain text, so these are not recoverable. We report empty rather than estimate |
| Embeddings | `dimensions` ignored; `usage.prompt_tokens` always `0`; array cap 100, and each array item counts as one request against your rate limit |
| Video enums | Our `seconds` and `size` values differ from the spec enums — typed clients will complain |
| Video history | `GET /v1/videos` and `DELETE /v1/videos/{id}` answer `404 endpoint_not_implemented` — we keep no per-user history |
| Files | No `/v1/files`; `file_id` is rejected wherever the spec allows it |

> [!NOTE]
>
> A field we cannot honour gets an answer, not silence. Where dropping a field would change the response shape or the product you pay for, we return `400` instead of accepting the request. Where a field is a best-effort hint (and is one at OpenAI too), we accept it and say plainly that it does not change the result. That rule is why several fields that used to pass silently now return `400` — you were paying for requests that did something other than what you asked.

***

## Not available yet

| Surface | Status |
| - | - |
| `POST /v1/chat/completions`, `/v1/responses` | Planned. Not an LLM endpoint here — it will dispatch to image / TTS / STT / vision models |
| `/v1/files`, `/v1/uploads` | Planned. Until then, `file_id` is rejected and you send bytes or URLs |
| `POST /v1/audio/voices`, `/v1/audio/voice_consents` | Voice cloning — planned |
| `POST /v1/audio/translations` | No translate mode on the backend |
| `POST /v1/images/variations` | No variations model |
| `POST /v1/moderations` | No moderation model |
| `/v1/videos/edits`, `/extensions`, `/{id}/remix`, `/characters` | No backend equivalent |
| Assistants, threads, vector stores, fine-tuning, batches, realtime | Out of scope — this is an inference proxy, not a platform clone |

deAPI also runs models with no OpenAI counterpart at all — image and video upscaling, background removal, music generation, OCR. Those stay on the [native deAPI API](https://docs.deapi.ai/api/v2/overview.md) rather than being forced into a foreign contract.

***

## Recent changes

### Added — November 2026

* **`Flux_2_Klein_4B_BF16` on `/v1/images/generations`.** It was documented for edits only. On generations it accepts any `size` from 256 to 1536 px per side in steps of 16, with `n` up to 2.
* **`Ltx2_5_22B_Dist_INT8` on `/v1/videos`**, for text-to-video and image-to-video: 3–10 s at 24 fps, landscape and portrait up to `1344x768`.
* **More sizes on `MiniMaxH3_33B_Turbo_INT8`:** `768x1344`, `1024x768`, `768x1024` and `768x768` in addition to `1344x768`.

### Changed — `owned_by` is `deapi`

`GET /v1/models` now reports `"owned_by": "deapi"` for every model. It used to be `"depin"`. If you filter the list on this value, update the filter.

### Changed — one key format for both APIs

* **Keys look like `sk-dp-<id>-<secret>` and work here unchanged.** The gateway used to need a `dpn-sk-` prefix in front of the native key, which tools set up for OpenAI often left out. Older keys still work in their raw `<id>|<secret>` form and with the `dpn-sk-` prefix.
* **A missing key now has a `code`.** No `Authorization` header, an empty one, or a scheme other than `Bearer` returns `401 missing_api_key` instead of a `401` with no `code`.
* **`bearer` in lowercase is accepted.** `authorization: bearer <key>` used to return `401` although the header was sent.

### Changed — unimplemented paths answer `404`, not `501`

Every path this gateway does not serve — `GET /v1/videos`, `DELETE /v1/videos/{id}`, `/v1/videos/edits`, `/extensions`, `/{id}/remix`, `/characters`, `/v1/responses`, `/v1/files`, `/v1/moderations`, `/v1/audio/translations`, `/v1/images/variations`, and anything unrecognised under `/v1/*` — now answers **`404`** with `code: "endpoint_not_implemented"`. It used to answer `501`.

If you branched on the status code, that branch is now dead. Branch on `code` instead: it is the part that distinguishes "this gateway does not serve this path" from an ordinary `404` such as `model_not_found` or `video_not_found`. `501` survives in one place only — `variant_not_supported` on `/v1/videos/{id}/content`.

`model_not_found` moved the same way: **`404` on POST endpoints too**, where it used to be `400`. One code on two statuses forced every client to handle both.

The reason for the whole move is in [Supported endpoints](#supported-endpoints): both SDKs retry any status `>= 500`, so the old `501` turned a typo into four requests and an `InternalServerError`.

### Added

* **`GET /v1/models/{model}`** — `client.models.retrieve(...)` now works instead of refusing the path.
* **Speaker diarization** — `response_format="diarized_json"` on `WhisperLargeV3Ct2`, with sequential speaker labels.
* **Native word-level timestamps** — `timestamp_granularities=["word"]` returns the model's own word timings on `WhisperLargeV3Ct2`, instead of interpolating them across the segment. Models that publish no word-level support reject the field outright rather than handing back invented offsets.
* **`instructions` for text-to-speech** — describe a voice in words on `Qwen3_TTS_12Hz_1_7B_VoiceDesign`.
* **`application/json` on `/v1/images/edits`** — the second content type the spec defines; images are passed as `images: [{"image_url": …}]`.
* **New models:** `ZAnimeDistill_8Step_INT8`, `WhisperLargeV3Ct2`, `MiniMaxH3_33B_Turbo_INT8`, `Qwen3_TTS_12Hz_1_7B_VoiceDesign`.
* **Browser support** — `/v1/*` now sends CORS headers, so the official Node SDK runs in the browser with `dangerouslyAllowBrowser: true`. Preflight no longer fails on authentication, which previously made every browser-side call impossible. Read the [warning](#calling-from-a-browser) before you ship it.
* **`created` is populated for every model** in `GET /v1/models`. It reports when the model became available here; entries used to be `0` unless the model was also listed on OpenRouter.
* **Image-to-video on `Ltxv_13B_0_9_8_Distilled_FP8`** — the model supports it natively and we were rejecting it. It is the cheapest image-to-video model in the catalog by a wide margin.

### Fixed

* **Image-to-video now works.** `input_reference` used to be silently dropped: the job succeeded, you were billed, and the clip was generated from the prompt alone. It is now an object, routed to the correct backend endpoint.
* **Models no longer disappear from `/v1/models`.** The catalog is paginated and only the first page was read, so correctly configured models were missing from the list with no error.
* `response_format="text"` on CTranslate2 models returned a raw JSON document, and `verbose_json` returned an empty `segments` array.
* `POST /v1/videos/edits`, `/extensions` and `/characters` answered `405`, telling you the path existed and the method was wrong — both untrue. They now answer `404 endpoint_not_implemented`.
* `language` in transcription is no longer an echo — it reaches the model and affects the transcript.
* **Running out of credit reported `400`** — "your request is malformed", when the request was fine. It is now `429 insufficient_quota`, sent with `X-Should-Retry: false` so your SDK does not retry an answer only a top-up can change: one failed call instead of three.
* **`param` named the backend's field, not yours.** A validation error on `input`, `file`, `input_reference` or `response_format` came back pointing at an internal field name that appears nowhere in your request. The names are now translated back to the ones you sent.
* **Unrecognised paths under `/v1/videos/` answered `405`.** The earlier fix covered only the three collection names spelled out in the spec (`/edits`, `/extensions`, `/characters`); every other word still leaked a `405`. The whole class now answers `404`.

### Changed — may affect existing integrations

* **`Ltxv_13B_0_9_8_Distilled_FP8` accepts `input_reference`.** Image-to-video is not limited to the `Ltx2_*` and `MiniMaxH3_*` families; all three video models take a first frame.
* **Partner models (`gpt-image-1.5`, `gpt-image-2`, `nano-banana-2`) are not routable here.** They are in the native catalog and answer `404 model_not_found` on this gateway.
* **`upstream_validation_error` was renamed to `invalid_value`** — a code from OpenAI's own vocabulary rather than one of ours.
* **`timestamp_granularities=["word"]` on a segment-only model now returns `400`.** It used to return `200` with word timings interpolated evenly across each segment; those numbers looked like measurements and were not.
* **`Ltx2_3_22B_Dist_INT8` no longer advertises `2` seconds.** The backend requires at least 49 frames and 2 s is 48, so that value always failed; `3` and `5` stand in its place.

> [!WARNING]
>
> **Fields that used to be accepted and silently dropped now return `400`:** `stream=true`, `partial_images`, `background=transparent`, `output_format=jpeg|webp`, `output_compression` (both image endpoints); `input_fidelity` (edits — on `/v1/images/generations` the spec does not define it and it is accepted and ignored); `stream_format=sse` (speech); `stream=true`, `include[]`, `languages[]`, `chunking_strategy` (transcription).

* `quality="auto"` no longer returns `400`. It is the SDK's default value and now maps to the model's default quality.
* **Job failures return a real reason.** Retryable failures come back as `503`, permanent ones as `502` with a message — previously every failure was an empty `502`.
* **TTS is `mp3`-only.** `wav` and `flac` were withdrawn from the TTS family on the backend and are now rejected locally with `400 format_not_supported`.

***

## Support

Include the `X-Request-Id` from the failing response (and `X-DeAPI-Request-Id` if present) in any report — with those we can trace the request end to end.

## Next steps

> [card] [Models](https://docs.deapi.ai/models.md)
>
> Discover all available models and their capabilities

> [card] [Quickstart](https://docs.deapi.ai/quickstart.md)
>
> Get your API key and make your first request

> [card] [API v2 Reference](https://docs.deapi.ai/api/v2/overview.md)
>
> Full native API reference with all endpoints

> [card] [Pricing](https://docs.deapi.ai/pricing.md)
>
> Pay-as-you-go rates per task and model


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