# Noirdoc — Complete Documentation > Complete developer documentation for the Noirdoc AI Gateway (`https://api.noirdoc.de/v1`). - **Documentation:** https://www.noirdoc.de/en/docs/ - **Index:** https://www.noirdoc.de/llms.txt - **German edition:** https://www.noirdoc.de/llms-full.txt --- # Quickstart > A base URL and an API key from the portal are all you need: existing OpenAI and Anthropic clients run unchanged through the Noirdoc gateway. - **Source:** https://www.noirdoc.de/en/docs/ - **API base URL:** `https://api.noirdoc.de/v1` - **Base URL:** `https://api.noirdoc.de/v1` - **Auth:** `Bearer px-...` - **Protocol:** OpenAI & Anthropic ### 1. Send your first request Create a `px-` key in the [Noirdoc portal](https://portal.noirdoc.de) under **Models → API keys** and store it in `NOIRDOC_API_KEY` (self-registration requires an EU or EFTA connection without a VPN, Private Relay, proxy or data centre IP; initial setup asks about [§ 203 German Criminal Code (StGB)](/en/docs/routing/#berufsgeheimnistraeger)). Point `base_url` at `https://api.noirdoc.de/v1` and pass a model ID such as `qwen3.8-27b`. **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) res = client.chat.completions.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Check § 4 for deadlines."}], ) print(res.choices[0].message.content) ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const res = await client.chat.completions.create({ model: "qwen3.8-27b", messages: [{ role: "user", content: "Check § 4 for deadlines." }], }); console.log(res.choices[0].message.content); ``` **curl** ```bash curl https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.8-27b", "messages": [{"role": "user", "content": "Check § 4 for deadlines."}] }' ``` **200 Response** ```jsonc // 200 OK · Header: X-Noirdoc-Provider: ionos { "id": "chatcmpl-8e21a9", "object": "chat.completion", "model": "qwen3.8-27b", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Clause 4 sets a three-month notice period.", }, "finish_reason": "stop", }, ], "usage": { "prompt_tokens": 14, "completion_tokens": 14, "total_tokens": 28, }, } ``` **403 Shield** ```jsonc // 403 Forbidden · Blocked by Noirdoc Shield { "error": { "type": "permission_error", "code": "shield_violation", "message": "Request blocked by Noirdoc Shield (secrets).", "param": null, }, } ``` The response names the answering provider in `X-Noirdoc-Provider`. Browse all model IDs in the [model catalogue](/en/models/) or query [`GET /v1/models`](/en/docs/keys-billing/#modelle-preise). > **Starter credit:** Your first organisation receives a starter credit capped at 5 requests per minute and 25 per day > UTC (exceeding this returns status 429 > [`starter_rate_limit_exceeded`](/en/docs/reference/error-codes/#starter_rate_limit_exceeded)). > Before your first confirmed top-up, only starter-eligible models such as `qwen3.8-27b` can be > called on managed providers; models marked **After top-up** return status 403 > [`starter_model_not_allowed`](/en/docs/reference/error-codes/#starter_model_not_allowed). Your > first top-up and your own provider keys (BYOK) lift both restrictions immediately; see [Credit & > billing](/en/docs/keys-billing/#guthaben). ### 2. Inspect inputs with Shield With `X-Noirdoc-Shield: on`, [Noirdoc Shield](/en/docs/shield/) inspects inbound text statelessly before forwarding to the provider so the model receives sanitised input. By default, personal data is redacted with markers such as `[PERSON]` or `[PHONE]`, while secrets and prompt injections are blocked with status 403 (`shield_violation`). > **Your input:** Please call Jonas Becker back on +49 30 901820. > **Sent to the model:** Please call [PERSON] back on [PHONE]. **Turn on Shield per request** **Python** ```python res = client.chat.completions.create( model="qwen3.8-27b", messages=[ { "role": "user", "content": "Please call Jonas Becker back on +49 30 901820.", } ], extra_headers={"X-Noirdoc-Shield": "on"}, ) ``` **TypeScript** ```ts const res = await client.chat.completions.create( { model: "qwen3.8-27b", messages: [ { role: "user", content: "Please call Jonas Becker back on +49 30 901820.", }, ], }, { headers: { "X-Noirdoc-Shield": "on" } }, ); ``` **curl** ```bash curl https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "qwen3.8-27b", "messages": [{ "role": "user", "content": "Please call Jonas Becker back on +49 30 901820." }] }' ``` New organisations start with `default_off`. Configure permanent rules per key, request tag or organisation under **Models → Shield**; see [Policy and precedence](/en/docs/shield/#richtlinie). ## Authentication and headers Every request (except `GET /v1/prices`) requires an active `px-` key; otherwise the gateway returns status 401 (`invalid_api_key`) with `message` `"Missing or invalid API key"` (no header starting with `px-`) or `"Invalid or inactive API key"` (unknown/disabled key or inactive organisation). The gateway checks the three key headers in table order and strips your key along with `X-Noirdoc-*`, `User-Agent`, cookies and custom `X-*` headers before forwarding to the provider. | Header | Direction | Effect | | ------------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `Authorization: Bearer px-...` | Request | Default for the OpenAI SDK and `curl` (checked first). | | `x-api-key: px-...` | Request | Default for the Anthropic SDK (checked second; selects the Anthropic format on `/v1/files`). | | `api-key: px-...` | Request | Compatible with Azure OpenAI clients (checked third). | | `X-Noirdoc-Shield` | Request & response | Request: `on` or `off` (`true`/`false`/`1`/`0`) overrides `default_on`/`default_off` below `enforced`, key and tag. Response: `redacted=` on full inspection, `partial; redacted=` when non-`enforced` requests include uninspectable binary/reference attachments, otherwise absent. | | `X-Noirdoc-Mask` | Request | Compatible alias for `X-Noirdoc-Shield`. On pre-existing organisations still using [legacy masking](/en/docs/shield/#klassische-maskierung) until 30 November 2026, controls reversible masking (responses carry `Deprecation: true` and `Sunset: Mon, 30 Nov 2026 23:59:59 GMT`). | | `X-Noirdoc-Tags` | Request | Attaches 1 to 5 comma-separated tags (`^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`) for budgets, model allowlists and Shield (status 403 `request_tags_disabled` unless enabled; see [Request tags](/en/docs/keys-billing/#request-tags)). | | `X-Noirdoc-Provider` | Response | Slug of the provider that answered or failed last (omitted on `/v1/files`, `/v1/skills`, gateway-only routes, pre-routing errors and streams flushed after 15 s in favour of `: provider=`). | | `X-Noirdoc-Masked` | Response | `true` on full Shield inspection (`redacted=`) or active legacy masking; `false` on `partial`, uninspected requests and errors before routing. | The gateway forwards only `Content-Type`, `Accept`, `anthropic-version` (fixed to `2023-06-01` on Anthropic, or moved with `anthropic-beta` into the body on Google Vertex AI), `anthropic-beta` and `OpenAI-Beta`; `OpenAI-Organization`, `OpenAI-Project` and `Idempotency-Key` are kept only with your own provider keys (BYOK). On all model endpoints, `model` alone selects the provider rather than the auth header (`/v1/skills` always goes to Anthropic, and `/v1/files` follows `x-api-key` vs `Bearer`/`api-key` or `X-Provider`; see [Files & Skills](/en/docs/reference/media-files/#dateien)). Keep `px-` keys on servers only and cap spend per application via [Budgets per key](/en/docs/keys-billing/#budgets). | Status | Code | Meaning | | --- | --- | --- | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | ## Endpoints All endpoints sit under `https://api.noirdoc.de/v1` (the Anthropic SDK uses `https://api.noirdoc.de` as its base URL and appends `/v1` itself). Each reference page documents Noirdoc-specific rules and limits relative to the upstream API. | Endpoint | Format | Documentation | | -------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------ | | `POST /v1/chat/completions` | OpenAI | [Chat Completions](/en/docs/reference/chat-responses/#chat-completions) | | `POST /v1/responses` | OpenAI | [Responses](/en/docs/reference/chat-responses/#responses) | | `POST /v1/messages`, `POST /v1/messages/count_tokens` | Anthropic | [Messages](/en/docs/reference/messages/#messages) | | `POST /v1/embeddings` | OpenAI | [Embeddings](/en/docs/reference/embeddings-rerank/#embeddings) | | `POST /v1/rerank` | Rerank | [Rerank](/en/docs/reference/embeddings-rerank/#rerank) | | `POST /v1/audio/transcriptions`, `POST /v1/audio/speech` | OpenAI | [Audio](/en/docs/reference/media-files/#audio) | | `POST /v1/images/generations` | OpenAI | [Images](/en/docs/reference/media-files/#bilder) | | `/v1/files`, `/v1/skills` | OpenAI, Anthropic | [Files & Skills](/en/docs/reference/media-files/#dateien) | | `POST /v1/shield/inspect`, `/v1/shield/policy` | Noirdoc | [Shield Inspect](/en/docs/shield/#inspect), [Shield Policy](/en/docs/shield/#policy) | | `POST /v1/workflows/{slug}/run`, `/v{n}/run` | Noirdoc | [Workflows](/en/docs/reference/workflows/) | | `GET /v1/models`, `GET /v1/prices` | OpenAI, Noirdoc (public) | [Models & pricing](/en/docs/keys-billing/#modelle-preise) | | `/v1/tags` | Noirdoc (Preview) | [Request tags](/en/docs/keys-billing/#request-tags) | ## Context for coding agents Drop this concise block into your `AGENTS.md` or `CLAUDE.md` so Claude Code, Cursor or Codex integrate the Noirdoc gateway cleanly: **AGENTS.md / CLAUDE.md** ```markdown # Noirdoc Gateway - Base URL: `https://api.noirdoc.de/v1` (Anthropic SDK: omit `/v1`) - Auth: `Authorization: Bearer $NOIRDOC_API_KEY` (`px-` key, server-side only) - Shield: send `X-Noirdoc-Shield: on` for stateless pre-flight checks - Error handling: always branch on `error.code`, never `error.message` - Up-to-date docs (Markdown): `https://www.noirdoc.de/llms.txt` and `https://www.noirdoc.de/en/llms-full.txt` (DE: `/llms-full.txt`) ``` ## Next steps - [**OpenAI & Anthropic SDK**](/en/docs/sdk/) — Configure the official Python and TypeScript SDKs, read response headers, stream SSE and handle gateway errors. - [**Noirdoc Shield**](/en/docs/shield/) — Five protection filters, policy precedence, inspected fields, /v1/shield/inspect and /v1/shield/policy. - [**Providers, Routing & § 203**](/en/docs/routing/) — Deterministic provider selection, automatic failover, model filters and § 203 StGB professional-secrecy mode. - [**Keys, Tags & Budgets**](/en/docs/keys-billing/) — Per-key euro budgets, request tags, prepaid credit and live GET /v1/models and /v1/prices. --- # OpenAI & Anthropic SDK > Point the official Python and TypeScript SDKs at the gateway, read response headers, stream server-sent events without buffering and handle gateway errors. - **Source:** https://www.noirdoc.de/en/docs/sdk/ - **API base URL:** `https://api.noirdoc.de/v1` ## OpenAI SDK Install `openai` (`pip install openai` or `npm install openai`) and point `base_url` (`https://api.noirdoc.de/v1`) and `api_key` at your `px-` key. Both SDKs also read `OPENAI_BASE_URL` and `OPENAI_API_KEY` from the environment with zero code changes. One client covers Chat Completions, `client.responses.create` (`POST /v1/responses`), `client.embeddings.create` (`POST /v1/embeddings`), Audio, Images and Files. Read response headers such as `X-Noirdoc-Provider` and `X-Noirdoc-Shield` via `with_raw_response` (Python) or `.withResponse()` (TypeScript). **Client, Shield header and response headers** **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], default_headers={"X-Noirdoc-Shield": "on"}, ) # Read response headers and override Shield for one request raw = client.chat.completions.with_raw_response.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Check clause 4."}], extra_headers={"X-Noirdoc-Shield": "off"}, ) print(raw.headers.get("x-noirdoc-provider")) res = raw.parse() ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, defaultHeaders: { "X-Noirdoc-Shield": "on" }, }); // Read response headers and override Shield for one request const { data, response } = await client.chat.completions .create( { model: "qwen3.8-27b", messages: [{ role: "user", content: "Check clause 4." }], }, { headers: { "X-Noirdoc-Shield": "off" } }, ) .withResponse(); console.log(response.headers.get("x-noirdoc-provider")); ``` `X-Noirdoc-Mask` remains supported as a compatible alias for `X-Noirdoc-Shield`. Whether the header takes effect follows the five-tier [Shield precedence](/en/docs/shield/#richtlinie). > **Endpoints without Shield:** `/v1/images/generations` rejects `X-Noirdoc-Shield: on` (and `X-Noirdoc-Mask: on`) with status 403 > (`masking_not_supported_for_endpoint`); `/v1/audio/*` and `/v1/files` reject `enforced` and > `X-Noirdoc-Mask: on` and forward other requests uninspected. Use a separate client without > `default_headers` for image generation. ## Anthropic SDK Install `anthropic` (`pip install anthropic`) or `@anthropic-ai/sdk` (`npm install @anthropic-ai/sdk`) and set `base_url` to `https://api.noirdoc.de` without `/v1`, as the SDK appends `/v1/messages` itself. Pass your `px-` key via `auth_token` (`Authorization: Bearer`) or `api_key` (`x-api-key`), or set `ANTHROPIC_BASE_URL` alongside either `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_API_KEY` (never set both key variables at once, or the SDK sends both headers). **Messages and token counting** **Python** ```python import os from anthropic import Anthropic anthropic_client = Anthropic( base_url="https://api.noirdoc.de", auth_token=os.environ["NOIRDOC_API_KEY"], default_headers={"X-Noirdoc-Shield": "on"}, ) count = anthropic_client.messages.count_tokens( model="claude-sonnet-5-5", messages=[{"role": "user", "content": "Check clause 4."}], ) msg = anthropic_client.messages.create( model="claude-sonnet-5-5", max_tokens=1024, messages=[{"role": "user", "content": "Check clause 4."}], ) print(count.input_tokens, msg.content[0].text) ``` **TypeScript** ```ts import Anthropic from "@anthropic-ai/sdk"; const anthropicClient = new Anthropic({ baseURL: "https://api.noirdoc.de", authToken: process.env.NOIRDOC_API_KEY, defaultHeaders: { "X-Noirdoc-Shield": "on" }, }); const count = await anthropicClient.messages.countTokens({ model: "claude-sonnet-5-5", messages: [{ role: "user", content: "Check clause 4." }], }); const msg = await anthropicClient.messages.create({ model: "claude-sonnet-5-5", max_tokens: 1024, messages: [{ role: "user", content: "Check clause 4." }], }); console.log(count.input_tokens, msg.content); ``` `POST /v1/messages` accepts Claude models via Google Vertex AI from [`GET /v1/models`](/en/docs/keys-billing/#modelle-preise) and your own Anthropic-compatible BYOK providers (OpenAI-format models return status 400 `wrong_endpoint_for_model`). `POST /v1/messages/count_tokens` skips Shield at €0. ## Streaming (SSE) With `"stream": true`, `POST /v1/chat/completions`, `POST /v1/responses` and `POST /v1/messages` deliver server-sent events (SSE) in the provider's native format. All other endpoints (`/v1/embeddings`, `/v1/rerank`, `/v1/audio/transcriptions` including form field `stream`, `/v1/audio/speech` including `stream_format`, `/v1/images/generations`) reject streaming with status 400 (`streaming_not_supported_for_endpoint`); on endpoints without Shield, status 403 (`masking_not_supported_for_endpoint`) takes precedence when `enforced` or `X-Noirdoc-Mask: on` (and `X-Noirdoc-Shield: on` on `/v1/images/generations`) is active. **SSE streams with the OpenAI and Anthropic SDKs** **Python** ```python # OpenAI SDK: POST /v1/chat/completions stream = client.chat.completions.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Draft a cover letter."}], stream=True, ) for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True) # Anthropic SDK: POST /v1/messages with anthropic_client.messages.stream( model="claude-sonnet-5-5", max_tokens=1024, messages=[{"role": "user", "content": "Draft a cover letter."}], ) as s: for text in s.text_stream: print(text, end="", flush=True) ``` **TypeScript** ```ts // OpenAI SDK: POST /v1/chat/completions const stream = await client.chat.completions.create({ model: "qwen3.8-27b", messages: [{ role: "user", content: "Draft a cover letter." }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); } // Anthropic SDK: POST /v1/messages const msgStream = anthropicClient.messages.stream({ model: "claude-sonnet-5-5", max_tokens: 1024, messages: [{ role: "user", content: "Draft a cover letter." }], }); msgStream.on("text", (t) => process.stdout.write(t)); await msgStream.finalMessage(); ``` **curl** ```bash curl -N https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.8-27b", "stream": true, "messages": [ {"role": "user", "content": "Draft a cover letter."} ] }' ``` #### Zero-buffering Shield inspection *Pre-stream* [Noirdoc Shield](/en/docs/shield/) inspects only the inbound request beforehand (`block` hits return HTTP 403 `shield_violation` before opening SSE) and forwards every SSE chunk and tool call immediately with zero sentence buffering. #### Usage data in streams (`stream_options.include_usage`) *POST /v1/chat/completions* The gateway enables `stream_options.include_usage` internally for billing and strips the extra usage chunk back out unless your request explicitly set the option. #### Keep-alive & provider comment (`: ping`) *Every 15 s* If the provider does not return headers within 15 s, the gateway sends status 200 and an SSE comment line `: ping` every 15 s (SDKs and `eventsource-parser` ignore `:` lines; skip lines starting with `:` in custom parsers). When 200 was flushed early, the `X-Noirdoc-Provider` HTTP header is omitted and emitted as `: provider=` directly before the first data event. #### Timeouts *Stream: 600 s · Non-streaming: 120 s* Streaming requests (`"stream": true`) wait at most 600 seconds in total across all failover attempts; non-streaming requests keep the 120-second limit. #### Pre-first-byte failover *Network · 401 · 402 · 429 · 5xx* Before the first response byte, the gateway automatically fails over on network errors and status 401, 402, 429 and 5xx ([Failover](/en/docs/routing/#failover)), even after `: ping` comment lines. If all providers fail before status 200, the gateway returns a normal HTTP JSON error. #### Mid-stream errors (`stream_interrupted`) *gateway_restarting* Once the stream starts, the provider stays fixed: mid-stream drops emit `stream_interrupted`, failures after an early status 200 emit their regular `code` (including `retry_after` in seconds in the error object), and deploys waiting on a provider emit `gateway_restarting` with `retry_after: 5`. #### Per-endpoint SSE error formats & legacy masking - **`/v1/chat/completions`:** Sends `data: {"error": {...}}` + `data: [DONE]` (raises `APIError`). - **`/v1/responses`:** Sends `event: error` + `data: [DONE]` (yields a flat `type: "error"` event in the OpenAI Python SDK without raising: check it directly in your loop). - **`/v1/messages`:** Sends `event: error` + `message_stop`. - **Legacy masking (until 30 November 2026):** Pre-existing organisations still on [legacy masking](/en/docs/shield/#klassische-maskierung) continue to receive sentence-buffered SSE (flushed at 2,000 characters, tool arguments once complete) when `<>` placeholders were assigned, marked with `Deprecation: true` and `Sunset`. ## Error handling and retries Every error response carries `type`, `code` and `message` (plus `request_id` on Anthropic routes: `/v1/messages` and `/v1/skills` always use the Anthropic format, `/v1/files` follows `x-api-key` vs `Bearer`, and all other routes use the OpenAI format). Always branch on `code` rather than `message`: the OpenAI SDK exposes `code` directly on the error, whereas the Anthropic SDK places it under `error.code` in the response body. **OpenAI SDK: inspect error code and provider** **Python** ```python import openai try: res = client.chat.completions.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Hello"}], ) except openai.APIStatusError as e: if e.code == "provider_rejected_request": prov = e.response.headers.get("x-noirdoc-provider") print("Provider rejected:", prov, e.body["message"]) else: print("Error:", e.status_code, e.code) ``` **TypeScript** ```ts try { const res = await client.chat.completions.create({ model: "qwen3.8-27b", messages: [{ role: "user", content: "Hello" }], }); } catch (err) { if (!(err instanceof OpenAI.APIError)) throw err; if (err.code === "provider_rejected_request") { const prov = err.headers?.get("x-noirdoc-provider"); console.log("Provider rejected:", prov, err.message); } else { console.log("Error:", err.status, err.code); } } ``` **Anthropic SDK: read error code from the body** **Python** ```python import anthropic try: msg = anthropic_client.messages.create( model="claude-sonnet-5-5", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], ) except anthropic.APIStatusError as e: err = e.body["error"] if err["code"] == "provider_rejected_request": prov = e.response.headers.get("x-noirdoc-provider") print("Provider rejected:", prov, err["message"]) else: print("Error:", e.status_code, err["code"]) ``` **TypeScript** ```ts type GatewayBody = { error?: { type?: string; code?: string; message?: string }; }; try { const msg = await anthropicClient.messages.create({ model: "claude-sonnet-5-5", max_tokens: 1024, messages: [{ role: "user", content: "Hello" }], }); } catch (err) { if (!(err instanceof Anthropic.APIError)) throw err; const body = err.error as GatewayBody | undefined; if (body?.error?.code === "provider_rejected_request") { const prov = err.headers?.get("x-noirdoc-provider"); console.log("Provider rejected:", prov, body.error.message); } else { console.log("Error:", err.status, body?.error?.code); } } ``` The gateway maps provider errors uniformly onto stable gateway codes: #### Capacity limits (`resource_exhausted`) *429 · Retry-After* Upstream rate limits or exhausted provider quotas, always returned with `Retry-After`. #### Provider overload (`provider_overloaded`) *503 / 529 · Retry-After* Status 503 on OpenAI routes and 529 on `/v1/messages`, each accompanied by `Retry-After`. #### Rejected request (`provider_rejected_request`) *Upstream message* Forwards the provider's original message; on BYOK routes this code also covers upstream 401, 402, 403 and 429 responses (see [Error format](/en/docs/reference/error-codes/#format)). #### Other upstream errors (`provider_error`) *502* Unexpected upstream failures once automatic failover is exhausted. > **Automatic retries & Retry-After:** Both SDKs retry status codes 408, 409, 429 and 5xx up to `max_retries` (default: 2, after gateway > [failover](/en/docs/routing/#failover)), honouring `Retry-After` up to 60 seconds and falling back > to exponential backoff beyond that. Status 401 (`invalid_api_key`) and 402 (`insufficient_credit`, > `key_budget_exhausted`) are never resolved by retrying — handle them directly in your application. | Status | Code | Meaning | | --- | --- | --- | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `streaming_not_supported_for_endpoint` | The request asks for streaming, but the endpoint does not support it. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `masking_not_supported_for_endpoint` | The endpoint supports neither Noirdoc Shield nor legacy masking, yet the policy is `enforced` or the request sends `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also `X-Noirdoc-Shield: on`). During the legacy masking transition until 30.11.2026, this also affects `/v1/embeddings` and `/v1/rerank` on pre-existing organisations that have not switched to Shield yet. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 502 | `stream_interrupted` | The provider's stream broke off or reported an error after the response had started. The error is in the stream itself, because status code 200 has already been sent by then. `stream_interrupted` carries no `retry_after`; only errors in the stream that correspond to an HTTP error with a wait carry it. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `gateway_restarting` | The gateway was restarted (deployment) while the stream was still waiting for the provider's response. The error is in the running stream, because status code 200 has already been sent by then. The error object contains `retry_after` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | --- # Claude Code & Tools > Connect Claude Code to the Noirdoc gateway or mask local files and paths directly on your machine with the Claude Code plugin and the noirdoc CLI. - **Source:** https://www.noirdoc.de/en/docs/tools/ - **API base URL:** `https://api.noirdoc.de/v1` ## Claude Code through the gateway Route Claude Code through the Noirdoc gateway to Claude models from [`GET /v1/models`](/en/docs/keys-billing/#modelle-preise) (Claude Code is built for Claude models and does not support other models through a gateway): ### 1. Set environment variables and start Set `ANTHROPIC_BASE_URL` to `https://api.noirdoc.de` (without `/v1`) and `ANTHROPIC_AUTH_TOKEN` to your `px-` key; select a Claude model such as `claude-sonnet-5-5` via `ANTHROPIC_MODEL`. Turn on [Noirdoc Shield](/en/docs/shield/) via `ANTHROPIC_CUSTOM_HEADERS` or directly on the API key (`shield_mode` set to **On**). **Start Claude Code** ```bash export ANTHROPIC_BASE_URL="https://api.noirdoc.de" export ANTHROPIC_AUTH_TOKEN="$NOIRDOC_API_KEY" export ANTHROPIC_MODEL="claude-sonnet-5-5" export ANTHROPIC_CUSTOM_HEADERS="X-Noirdoc-Shield: on" claude ``` | Environment variable | Effect | | -------------------------- | ------------------------------------------------------------------------------------------------------------------ | | `ANTHROPIC_BASE_URL` | Base URL `https://api.noirdoc.de` without `/v1` (Claude Code appends `/v1/messages` itself). | | `ANTHROPIC_AUTH_TOKEN` | Sends your `px-` key as `Authorization: Bearer`. Do not set alongside `ANTHROPIC_API_KEY`. | | `ANTHROPIC_API_KEY` | Alternative to `ANTHROPIC_AUTH_TOKEN`; sends your `px-` key as `x-api-key` (set only one of the two variables). | | `ANTHROPIC_MODEL` | Claude model ID from `GET /v1/models` (for example `claude-sonnet-5-5` or `claude-haiku-4-5`). | | `ANTHROPIC_CUSTOM_HEADERS` | Additional headers, one `Name: Value` pair per line (for example `X-Noirdoc-Shield: on` or `X-Noirdoc-Tags: ...`). | > **Preflight token counting:** Claude Code counts context tokens beforehand via `POST /v1/messages/count_tokens`. This call skips > Noirdoc Shield at €0 (for Claude on Google Vertex AI, the gateway forwards to the Vertex counting > method; see [Messages](/en/docs/reference/messages/#messages)), while actual `POST /v1/messages` > requests run through Shield when enabled. ### 2. Add project context to CLAUDE.md or AGENTS.md When your project integrates the Noirdoc gateway in code, add this short block to `CLAUDE.md` or `AGENTS.md` so coding agents consistently follow base URL, header and error-handling conventions: **AGENTS.md / CLAUDE.md** ```markdown # Noirdoc Gateway - Base URL: `https://api.noirdoc.de/v1` (Anthropic SDK: omit `/v1`) - Auth: `Authorization: Bearer $NOIRDOC_API_KEY` (`px-` key, server-side only) - Shield: send `X-Noirdoc-Shield: on` for stateless pre-flight checks - Error handling: always branch on `error.code`, never `error.message` - Up-to-date docs (Markdown): `https://www.noirdoc.de/llms.txt` and `https://www.noirdoc.de/en/llms-full.txt` (DE: `/llms-full.txt`) ``` ## Local Claude Code plugin The open-source Claude Code plugin (MIT licence, usable independently of the gateway) connects the local `noirdoc` CLI directly with Claude Code. The plugin intercepts reads of protected paths, hands Claude a copy masked locally with placeholders such as `<>` and stores responses containing placeholders; you put the original values back in your own terminal outside Claude Code. **Claude Code** ```text /plugin marketplace add nextaim-de/noirdoc-claude-plugin /plugin install noirdoc@nextaim /noirdoc:noirdoc-setup ``` > **Local tool privacy pattern:** Keep plaintext data on your own machine when working with local tools and agents: the plugin and > the `noirdoc` CLI substitute personal and client details with consistent placeholders before > anything leaves disk, so the model reasons over structure and placeholders while you restore > originals locally afterwards. Source code, path rules and commands are documented at [github.com/nextaim-de/noirdoc-claude-plugin](https://github.com/nextaim-de/noirdoc-claude-plugin#readme). ## noirdoc CLI for documents The Python package `noirdoc` (MIT licence) replaces personal data in PDF, DOCX, XLSX and plain-text files locally on your machine with consistent placeholders such as `<>`. With `--namespace`, placeholders stay identical across multiple files, and `noirdoc reveal` restores the original values locally. This makes the CLI well suited to sanitising binary office documents (PDF, DOCX, XLSX) beforehand or applying reversible pseudonymisation locally, whereas [Noirdoc Shield](/en/docs/shield/) in the gateway statelessly inspects and redacts inbound text without storing mappings. **noirdoc CLI** ```bash pip install "noirdoc[full]" noirdoc redact --namespace client-mueller \ letter.docx -o letter-masked.docx noirdoc reveal --namespace client-mueller \ letter-masked.docx -o letter.docx ``` Source code, supported formats and options are documented at [github.com/noirdoc-ai/mask-engine](https://github.com/noirdoc-ai/mask-engine#readme). --- # Workflows: 5-Minute Guide > From starter template to browser test run, immutable v1 publish and your first production API call. - **Source:** https://www.noirdoc.de/en/docs/guides/workflows/ - **API base URL:** `https://api.noirdoc.de/v1` With **Noirdoc Workflows**, you chain typed JSON inputs, single-pass Shield inspection and multiple EU models on a visual drafting canvas, then call the entire pipeline through one synchronous endpoint. > **Beta & prerequisites:** Workflows is in Beta and enabled by default for every active organisation (1 to 10 linear steps, synchronous JSON without streaming, up to 300 s wall-clock timeout). Creating, editing, test-running, publishing and archiving require the `admin` role (`member` users have read-only access). ## What you call in production Instead of wiring two SDKs, PII redaction and JSON retry loops in your backend, five minutes of setup gets you down to a single synchronous call: **Python** ```python import os import httpx key = os.environ["NOIRDOC_API_KEY"] res = httpx.post( "https://api.noirdoc.de/v1/workflows/support-triage/v1/run", headers={"Authorization": f"Bearer {key}"}, json={ "message": "Order #48291 from Max Weber arrived damaged.", "channel": "email", }, timeout=310, ) res.raise_for_status() print(res.json()["output"]) ``` **TypeScript** ```ts const url = "https://api.noirdoc.de/v1/workflows/support-triage/v1/run"; const res = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ message: "Order #48291 from Max Weber arrived damaged.", channel: "email", }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const { output } = await res.json(); console.log(output); ``` **curl** ```bash curl https://api.noirdoc.de/v1/workflows/support-triage/v1/run \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "Order #48291 from Max Weber arrived damaged.", "channel": "email" }' ``` **200 Response** ```jsonc // 200 OK · 2 models, 1× Shield, 1 synchronous call { "workflow": "support-triage", "version": 1, "output": { "category": "damaged_item", "urgency": "high", "reply_draft": "We are shipping a replacement for order #48291.", }, "meta": { "duration_ms": 1842, "total_cost_eur": "0.006120", "detected_types": ["PERSON"], }, } ``` **403 Shield** ```jsonc // 403 Forbidden · Shield block at ingress (€0 model cost) { "error": { "code": "shield_violation", "message": "Input blocked by Noirdoc Shield policy.", "blocked_rule": "pii", "detected_types": ["PERSON", "IBAN"], }, "meta": { "workflow": "support-triage", "version": 1, "model_cost_eur": "0.000000", "shield_cost_eur": "0.000020", "workflow_fee_eur": "0.002000", "total_cost_eur": "0.002020", }, } ``` One request runs input validation, single-pass Shield inspection, both model steps and local `output_schema` checks. The five steps to your first call take five minutes in the Portal. ## Step-by-step setup ### 1. Create from a template in the Portal Open **Workflows** in the [Noirdoc Portal](https://portal.noirdoc.de) and choose one of three starter templates: | Template | Slug | Models | Default Shield | | ------------------ | ------------------ | -------------------------------------------- | -------------- | | Support triage | `support-triage` | `mistral4-119b` → `claude-sonnet-5-5` | `redact` | | Invoice extraction | `beleg-extraktion` | `gemini-3.8-flash` (Vision) → `gpt-5.4-mini` | `off` | | Feedback analysis | `feedback-analyse` | `gpt-oss-120b` → `claude-sonnet-5-5` | `redact` | The draft opens on the visual canvas with five connected nodes (`IN`, `PII`, `01`, `02`, `OUT`). Creating, editing, test-running, publishing and archiving workflows require the `admin` role; organisation `member` users have read-only access to workflows, versions and run metadata. ### 2. Inspect steps, files and Shield on the canvas Click any node to review its configuration in the inspector: #### Input schema (`IN`) *JSON Schema Draft 2020-12* Defines required fields and types using JSON Schema Draft 2020-12 (required `message` and optional `channel` in `support-triage`). For PDFs, images or text files, mark a string property with `"format": "data-url"` (at most 10 MB decoded per file, 15 MB total request body). #### Noirdoc Shield (`PII`) *off · block · redact* Selects `off`, `block` or `redact`. When your organisation is set to `enforced` under **Models → Shield**, `off` is disabled (422 `shield_enforced_cannot_disable`) and binary PDFs or images are rejected with 422 `shield_uninspectable_content`. #### Prompt steps (`01 / 02`) *Multi-model & Vision* Pick any model from your organisation's catalogue (mixing OpenAI, Gemini and Anthropic wires freely), reference text values with `{{input.message}}` and `{{steps.classify.category}}`, and pass file inputs via `attachments: ["input.receipt_file"]` directly to Vision models such as `gemini-3.8-flash`, `claude-sonnet-5-5` or `gpt-5.4-mini`. #### Output schema (`OUT`) *Max. 1× auto-repair* Validates the final JSON locally against Draft 2020-12 and runs at most one automatic repair call on mismatch. > **Your input:** Order #48291 for Max Weber (DE89 3704 0044 0532 0130 00) arrived damaged. > **Sent to the model:** Order #48291 for [PERSON] ([IBAN]) arrived damaged. ### 3. Run a browser test As an `admin`, click **Test run** in the top bar with the synthetic sample payload. Browser test runs bill against your organisation's balance (no API key paste required) and enforce your [§ 203 StGB posture](/en/docs/routing/#berufsgeheimnistraeger). Each node updates live with latency, executing provider, detected Shield categories and real EUR cost (model + Shield + €0.002 workflow fee). Intermediate step outputs return live in the HTTP response only – nothing is stored. ### 4. Publish version `v1` Once the test run passes, click **Publish** as an `admin`. The engine stores an immutable `v1` snapshot (stripping `sample_input` and `ui_layout`). Later draft edits never affect live calls to `v1` until `v2` is published. ### 5. Call the published workflow Invoke the workflow using your existing `px-` key at `POST /v1/workflows/{slug}/v1/run` (pinned) or `POST /v1/workflows/{slug}/run` (latest version) – optionally with `X-Noirdoc-Tags` for [tag budgets](/en/docs/keys-billing/#budgets): **Python** ```python import os import httpx url = "https://api.noirdoc.de/v1/workflows/support-triage/v1/run" res = httpx.post( url, headers={ "Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}", "X-Noirdoc-Tags": "support-inbox", }, json={ "message": "Order #48291 from Max Weber arrived damaged.", "channel": "email", }, timeout=310, ) res.raise_for_status() data = res.json() print(data["output"], data["meta"]["total_cost_eur"]) ``` **TypeScript** ```ts const url = "https://api.noirdoc.de/v1/workflows/support-triage/v1/run"; const res = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", "X-Noirdoc-Tags": "support-inbox", }, body: JSON.stringify({ message: "Order #48291 from Max Weber arrived damaged.", channel: "email", }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const data = await res.json(); console.log(data.output, data.meta.total_cost_eur); ``` **curl** ```bash curl https://api.noirdoc.de/v1/workflows/support-triage/v1/run \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Tags: support-inbox" \ -d '{ "message": "Order #48291 from Max Weber arrived damaged.", "channel": "email" }' ``` **200 Response** ```json { "workflow": "support-triage", "version": 1, "run_id": "wfr_019a7f3c9d2e4b81", "output": { "category": "damaged_item", "urgency": "high", "reply_draft": "We are shipping a replacement for order #48291." }, "meta": { "duration_ms": 1842, "model_cost_eur": "0.004100", "shield_cost_eur": "0.000020", "workflow_fee_eur": "0.002000", "total_cost_eur": "0.006120", "pii_mode": "redact", "detected_types": ["PERSON"], "repair_attempted": false, "steps": [ { "key": "classify", "model": "mistral4-119b", "provider": "aki-io", "wire_format": "openai", "duration_ms": 410, "prompt_tokens": 184, "completion_tokens": 42, "cost_eur": "0.000400" }, { "key": "draft", "model": "claude-sonnet-5-5", "provider": "anthropic-gcp", "wire_format": "anthropic", "duration_ms": 1418, "prompt_tokens": 312, "completion_tokens": 96, "cost_eur": "0.003700" } ] } } ``` Production calls return only the validated `output` object and step metadata. ## Passing PDFs & images with Vision (`beleg-extraktion`) For document and image workflows such as `beleg-extraktion`, pass files as base64 data URLs (`format: "data-url"`, up to 10 MB decoded per file, 15 MB total request body). Bind the field in a prompt step via `attachments: ["input.receipt_file"]` on a Vision model (`gemini-3.8-flash`, `claude-sonnet-5-5` or `gpt-5.4-mini`): **Python** ```python import base64 import os import httpx pdf_b64 = base64.b64encode(open("invoice.pdf", "rb").read()).decode() res = httpx.post( "https://api.noirdoc.de/v1/workflows/beleg-extraktion/v1/run", headers={"Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}"}, json={"receipt_file": f"data:application/pdf;base64,{pdf_b64}"}, timeout=310, ) res.raise_for_status() print(res.json()["output"]) ``` **TypeScript** ```ts import { readFileSync } from "node:fs"; const url = "https://api.noirdoc.de/v1/workflows/beleg-extraktion/v1/run"; const pdfB64 = readFileSync("invoice.pdf").toString("base64"); const res = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ receipt_file: `data:application/pdf;base64,${pdfB64}`, }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const { output } = await res.json(); console.log(output); ``` **curl** ```bash { printf '%s' '{"receipt_file":"data:application/pdf;base64,' base64 < invoice.pdf | tr -d '\n' printf '%s\n' '"}' } | curl https://api.noirdoc.de/v1/workflows/beleg-extraktion/v1/run \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @- ``` **200 Response** ```json { "workflow": "beleg-extraktion", "version": 1, "output": { "invoice_no": "INV-2026-412", "vendor": "CloudHost GmbH", "net_eur": 420.0, "vat_rate": 0.19, "gross_eur": 499.8 } } ``` Allowed MIME types are PDF (`application/pdf`), images (PNG, JPEG, WebP, GIF) and UTF-8 text files. When your organisation Shield policy is `enforced`, binary PDFs or images return 422 `shield_uninspectable_content` (€0 fee). ## `/run` vs. `/v1/run` & error handling #### Pinned version for production (`/v1/workflows/{slug}/v1/run`) *Recommended* Keeps your application locked to immutable `v1`, even after an `admin` publishes `v2` with updated prompts or models. #### Unpinned for staging (`/v1/workflows/{slug}/run`) *Always latest version* Always runs the latest published version – useful for verifying prompt and model changes without a backend deploy. > **Always branch on error.code in client code:** Branch on `error.code` rather than `message`: 401 `invalid_api_key` indicates a missing, invalid or disabled API key or an inactive organisation (€0), 413 `payload_too_large` indicates a request exceeding the 15 MB body cap or 10 MB per-file cap (€0), 422 `invalid_workflow_input` reports failing `input_schema` paths (`details`, without raw values, €0), 422 `shield_uninspectable_content` rejects binary PDFs or images under `enforced` Shield (€0), and 403 `shield_violation` returns `blocked_rule`, `detected_types` and `meta` (€0.00 model tokens; Shield inspection and the single €0.002 workflow run fee apply normally). See concrete error payloads and all codes in the [API reference](/en/docs/reference/workflows/#fehlercodes). ## Related pages - [**Workflows: Concepts & Architecture**](/en/docs/concepts/workflows/) — Execution lifecycle, Draft 2020-12 schemas, safe variable interpolation, Shield guarantees and pricing. - [**Workflows: API Reference**](/en/docs/reference/workflows/) — Full headers, response fields, Vision attachments and error codes for /v1/workflows/{slug}/run. --- # Noirdoc Shield > Stateless input inspection on German infrastructure: redact or block secrets, PII, names, prompt injections and custom blocklist patterns. - **Source:** https://www.noirdoc.de/en/docs/shield/ - **API base URL:** `https://api.noirdoc.de/v1` Noirdoc Shield inspects inbound requests statelessly on German infrastructure before data leaves the gateway towards a model provider. Depending on each filter, Shield either redacts matches in-place with fixed category placeholders such as `[PERSON]` or `[IBAN]`, or blocks the request before forwarding with status 403 (`shield_violation`). > **Your input:** Confirm to Anna Schmidt that payment arrived on DE89 3704 0044 0532 0130 00. > **Sent to the model:** Confirm to [PERSON] that payment arrived on [IBAN]. > **Billing:** Input inspection costs +€0.40 per 1M inspected input tokens across all active filters — including > on BYOK routes and status 403 (`shield_violation`) blocks. `/v1/messages/count_tokens` and > `/v1/responses/input_tokens` are charged €0.00. ## Protection filters Under **Models → Shield** and via `/v1/shield/policy`, admins configure five independent protection filters. Shield stores no mapping table in Redis, prepends no system prompt, and streams model responses, `tool_calls` / `tool_use` blocks and citations straight through with zero sentence-buffering latency: #### Secrets & API Keys (`secrets`) *Default: block · off · redact · block* — `[SECRET]` Detects API keys, private keys, cloud tokens, credentials and high-entropy secrets across all message roles. #### Financial & Contact Data (`pii`) *Default: redact · off · redact · block* — `[IBAN]`, `[CREDIT_CARD]`, `[EMAIL]`, `[PHONE]`, `[TAX_ID]`, `[TAX_NUMBER]`, `[VAT_ID]`, `[SSN]`, `[DATE_OF_BIRTH]` Detects bank accounts, payment cards, contact details, tax and social security numbers, and dates of birth across all roles. #### Names & Addresses (`ner`) *Default: redact · off · redact · block* — `[PERSON]`, `[ADDRESS]` Detects personal names and postal addresses via named-entity recognition across all roles. #### Prompt Injection (`injection`) *Default: block · off · block* No `redact` action. Evaluated only on untrusted roles (`user` and `tool` / function outputs); `system`, `developer` and `assistant` are exempt. #### Custom Blocklist (`custom`) *Default: redact · off · redact · block* — `[CUSTOM]` Evaluates up to 100 entries in `custom_patterns` (2–256 characters each): case-insensitive literal substrings such as `"Projekt Helios"` or linear-time regular expressions prefixed with `re:` such as `"re:AZ-[0-9]{4}-[0-9]{5}"`. While `injection` evaluates only `user` and `tool` segments, `secrets`, `pii`, `ner` and `custom` inspect every role. When local tools in your application need to resolve real records after a model tool call, pass internal record IDs (for example `contact_id: "c_8492"`) rather than plaintext names or IBANs. #### RE2 syntax and custom_patterns rules - **Limits:** 0 to 100 entries in `custom_patterns`, each 2 to 256 characters long. - **Literals:** Without a prefix, Shield matches case-insensitive substrings (for example `"Projekt Helios"`). - **Regular expressions (`re:`):** Evaluated in linear time with RE2 semantics — no lookarounds, no backreferences and no patterns matching the empty string (invalid patterns are rejected on save or in `/v1/shield/inspect` with status 422 `shield_policy_invalid`). ## Policy and precedence Enable Shield per request via the `X-Noirdoc-Shield` header, permanently via `default_headers` / `defaultHeaders` on an SDK client, per API key, per request tag, or across your organisation under **Models → Shield**: **Python** ```python from openai import OpenAI client = OpenAI(base_url="https://api.noirdoc.de/v1") raw = client.chat.completions.with_raw_response.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Anna Schmidt, +49 30 901820"}], extra_headers={"X-Noirdoc-Shield": "on"}, ) print(raw.headers.get("x-noirdoc-shield")) # "redacted=2" ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1" }); const prompt = "Anna Schmidt, +49 30 901820"; const { data, response } = await client.chat.completions .create( { model: "qwen3.8-27b", messages: [{ role: "user", content: prompt }], }, { headers: { "X-Noirdoc-Shield": "on" } }, ) .withResponse(); console.log(response.headers.get("x-noirdoc-shield")); ``` **curl** ```bash curl -si https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "qwen3.8-27b", "messages": [ {"role": "user", "content": "Anna Schmidt, +49 30 901820"} ] }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Shield: redacted=2 · X-Noirdoc-Masked: true { "id": "chatcmpl-9a41c2", "object": "chat.completion", "model": "qwen3.8-27b", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Callback noted for [PERSON] on [PHONE].", }, "finish_reason": "stop", }, ], } ``` **403 shield_violation** ```jsonc // 403 Forbidden · Blocked by a filter with action "block" { "error": { "type": "permission_error", "code": "shield_violation", "message": "Request blocked by Noirdoc Shield (secrets).", "param": null, }, } ``` When all inspectable content has been checked, the response carries `X-Noirdoc-Shield: redacted=` (`0` when nothing matched) and `X-Noirdoc-Masked: true`; if non-enforced requests include uninspectable binary or media attachments, the response carries `X-Noirdoc-Shield: partial; redacted=` and `X-Noirdoc-Masked: false`. Under **Models → Shield**, admins choose the organisation's default mode (`default_off` **On demand** as default for new organisations, `default_on` **On by default** / alias `advisory`, or `enforced` **Enforced**). On every request, the gateway evaluates five levels in order: | Step | Level | Rule | | ---- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 1 | Active filters | If all five filters are `off`, Shield is inactive. Saving `enforced` with all five filters `off` is rejected with status 422 (`shield_policy_invalid`). | | 2 | Organisation `enforced` | Shield inspects every request mandatorily; API keys, request tags and headers cannot switch it off. | | 3 | API key (`shield_mode`) | Under **Models → API keys**, `on` (**On**) or `off` (**Off**) decides; `inherit` (**Inherit**) defers to step 4. | | 4 | Request tags (`X-Noirdoc-Tags`) | `shield_mode` configured under **Models → Tags** or `/v1/tags`; with multiple tags attached, any `on` wins over `off`, while `inherit` defers. | | 5 | Header & organisation default | `X-Noirdoc-Shield: on` or `off` (case-insensitive, stripped before forwarding; `X-Noirdoc-Mask` acts as an alias on Shield organisations) overrides `default_on`/`default_off`. | ## Inspected fields and attachments Shield inspects text segments and inline UTF-8 text attachments decoded under 4 MiB (`text/*`, JSON, XML, CSV, Markdown, YAML as Base64 `data:` URLs or Messages text `document` blocks), while leaving `tools[]` definitions, output schemas (`response_format`, `text.format`) and signed `thinking` blocks untouched: #### Chat Completions (`/v1/chat/completions`) Inspects `messages[].content` (`string` and `text` parts; `system`, `developer` and `assistant` exempt from `injection`, missing/unknown roles mapped to `user`, `tool`/`function` mapped to `tool`), all JSON string values in `messages[].tool_calls[].function.arguments` (`assistant`), `prediction.content` (`user`), and inline UTF-8 `file` parts under 4 MiB (file text always `tool`, `filename` per message role). #### Responses (`/v1/responses`) Inspects `instructions` (`system`), string `input` (`user`) or message/`input_text`/`output_text` items, JSON string values in `function_call.arguments` (`assistant`), `function_call_output.output` (`tool`), and inline UTF-8 `input_file` parts under 4 MiB (`tool`). `/v1/responses/input_tokens` skips Shield free of charge. #### Messages (`/v1/messages`) Inspects `system`, `messages[].content`, string values in `tool_use.input` (`assistant`), `tool_result.content` (`tool`), code-execution blocks (`server_tool_use`, `bash_code_execution_tool_result`, `text_editor_code_execution_tool_result`), `document` blocks with text/Base64 UTF-8 under 4 MiB plus `title` and `context`, `search_result` blocks, and `citations[]` (`cited_text`, `document_title`). `/v1/messages/count_tokens` skips Shield free of charge. #### Embeddings (`/v1/embeddings`) Inspects `input` as string, `string[]`, string fields of multimodal objects (excluding `image`/`image_url`) and integer token arrays (decoded via `tiktoken`, inspected and re-encoded into token IDs; undecodable arrays fail with status 422 `shield_uninspectable_content` under `enforced`). All segments run as role `user`. #### Rerank (`/v1/rerank`) Inspects `query` (role `user`), `instruction` and `documents[]` (strings and text fields of document objects, excluding `image`/`image_url`). #### Media, Files & Skills (`/v1/audio/* · /v1/images/generations · /v1/files · /v1/skills`) *Not inspected* Under `enforced`, with `X-Noirdoc-Mask: on`, and on `/v1/images/generations` with `X-Noirdoc-Shield: on`, content-bearing calls return status 403 (`masking_not_supported_for_endpoint`). Reading, listing, downloading and deleting on `/v1/files` and `/v1/skills` remain permitted. Before Shield runs, **Models → Gateway** enforces **Allow file and image attachments in requests** (`allow_file_content`, default: on; when off, any request containing file, image or audio parts returns status 403 `file_content_not_allowed`). When `allow_file_content` is enabled, Shield handles attachments by type: | Attachment type | `default_on` / `on` | `enforced` | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | Inline UTF-8 text files (< 4 MiB decoded) | Decoded, inspected and sanitised in-place (`X-Noirdoc-Shield: redacted=`, `X-Noirdoc-Masked: true`) | Fully inspected and permitted | | Binary documents (PDF, DOCX, XLSX, PPTX), media (`image_url`, `image`, `input_image`, `input_audio`), references (`file_id`, URL), files >= 4 MiB or invalid UTF-8 | Text fields inspected; attachment forwarded unchanged (`X-Noirdoc-Shield: partial; redacted=`, `X-Noirdoc-Masked: false`) | Status 422 `shield_uninspectable_content` (extract PDF/Office text client-side beforehand) | > **Tool definitions:** Do not place names, matter references, addresses or secrets in `tools[]` descriptions, parameter > schemas or `enum` values. Always pass confidential values inside message or tool content where > Shield inspects them. ## Standalone text inspection Inspect text directly on German infrastructure without a model call before storing free text in vector databases, search indexes or external tools (+€0.40 per 1M input tokens). **POST** `https://api.noirdoc.de/v1/shield/inspect` **Python** ```python import os import httpx resp = httpx.post( "https://api.noirdoc.de/v1/shield/inspect", headers={ "Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}", "X-Noirdoc-Tags": "mandat-2026-042", }, json={ "input": [ "Client in matter: Anna Schmidt", "Bank account: DE89 3704 0044 0532 0130 00", "Note on Projekt Helios, file AZ-2026-00418.", ], "role": "user", "policy": { "rules": {"custom": "redact"}, "custom_patterns": [ "Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}", ], }, }, ) data = resp.json() ``` **TypeScript** ```ts const resp = await fetch("https://api.noirdoc.de/v1/shield/inspect", { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "X-Noirdoc-Tags": "mandat-2026-042", "Content-Type": "application/json", }, body: JSON.stringify({ input: [ "Client in matter: Anna Schmidt", "Bank account: DE89 3704 0044 0532 0130 00", "Note on Projekt Helios, file AZ-2026-00418.", ], role: "user", policy: { rules: { custom: "redact" }, custom_patterns: ["Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}"], }, }), }); const data = await resp.json(); ``` **curl** ```bash curl https://api.noirdoc.de/v1/shield/inspect \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "X-Noirdoc-Tags: mandat-2026-042" \ -H "Content-Type: application/json" \ -d '{ "input": [ "Client in matter: Anna Schmidt", "Bank account: DE89 3704 0044 0532 0130 00", "Note on Projekt Helios, file AZ-2026-00418." ], "role": "user", "policy": { "rules": { "custom": "redact" }, "custom_patterns": ["Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}"] } }' ``` **Response** ```json { "id": "shld_7f3c9a12e4b048d19c2a6e10", "model": "noirdoc-shield-v1", "action": "redact", "flagged": true, "output": [ "Client in matter: [PERSON]", "Bank account: [IBAN]", "Note on [CUSTOM], file [CUSTOM]." ], "findings": [ { "category": "ner", "label": "PERSON", "kind": "PERSON", "action": "redact", "replacement": "[PERSON]", "start": 18, "end": 30, "index": 0 } ], "findings_truncated": false, "usage": { "input_tokens": 41 } } ``` The endpoint returns HTTP 200 OK even when `action` is `"block"` and runs without short-circuiting (`short_circuit=false`) so `findings` lists every match. | Field | Direction | Rule | | ----------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `input` | Request (required) | Non-empty string or array of 1 to 64 non-empty strings, up to 256 KB (262,144 bytes UTF-8) in total (status 413 `shield_input_too_large` above that). | | `role` | Request (optional) | `"user"` (default), `"tool"`, `"system"` or `"assistant"`. `injection` inspects `"user"` and `"tool"`. | | `policy` | Request (optional) | Per-call override `{"rules"?: {...}, "custom_patterns"?: [...]}` (or a flat rule map without `custom_patterns`; mixing both returns status 422 `shield_policy_invalid`). Under `enforced`, `policy` cannot weaken active rules or omit stored `custom_patterns` (403 `shield_policy_enforced`). | | `action`, `flagged`, `output` | Response (200 OK) | `action` is `"pass"`, `"redact"` or `"block"`; `flagged` is `true` on any match; `output` returns the sanitised `string` or `string[]` matching `input`. | | `findings`, `findings_truncated`, `usage` | Response (200 OK) | Matches with `category`, `label`, `kind`, `action`, `replacement`, `start`, `end`, `index` (0-based array index); `usage.input_tokens` states billed tokens (minimum 1). | ## Manage policy via API **GET** `https://api.noirdoc.de/v1/shield/policy` **PUT** `https://api.noirdoc.de/v1/shield/policy` **PATCH** `https://api.noirdoc.de/v1/shield/policy` Reads or updates your organisation's Shield policy. All three methods require **Manage Shield policy via API** (`can_manage_shield = true`) on the calling API key under **Models → API keys** (status 403 `insufficient_key_permissions`); a key pinned to `shield_mode: "on"` cannot weaken the policy. **Python** ```python import os import httpx resp = httpx.patch( "https://api.noirdoc.de/v1/shield/policy", headers={"Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}"}, json={ "mode": "default_on", "rules": {"pii": "redact", "custom": "block"}, "custom_patterns": [ "Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}", ], }, ) policy = resp.json() ``` **TypeScript** ```ts const resp = await fetch("https://api.noirdoc.de/v1/shield/policy", { method: "PATCH", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ mode: "default_on", rules: { pii: "redact", custom: "block" }, custom_patterns: ["Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}"], }), }); const policy = await resp.json(); ``` **curl** ```bash curl -X PATCH https://api.noirdoc.de/v1/shield/policy \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mode": "default_on", "rules": { "pii": "redact", "custom": "block" }, "custom_patterns": ["Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}"] }' ``` **Response** ```json { "mode": "default_on", "shield_policy": "default_on", "rules": { "secrets": "block", "pii": "redact", "ner": "redact", "injection": "block", "custom": "block" }, "custom_patterns": ["Projekt Helios", "re:AZ-[0-9]{4}-[0-9]{5}"], "price_per_1m_input_tokens_eur": "0.40", "legacy_mask_active": false, "legacy_mask_sunset_at": "2026-11-30T23:59:59Z" } ``` | Method / field | Behaviour | | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `mode` (`shield_policy`) | `"default_off"`, `"default_on"` or `"enforced"` (aliases `"off"`, `"advisory"` and `mask_policy` are accepted). | | `PUT` vs `PATCH` on `rules` | `PUT` resets omitted rule keys to their Shield defaults; `PATCH` merges provided rule keys into the stored state. | | `custom_patterns` | 0 to 100 patterns of 2–256 characters; when passed to `PATCH`, replaces the stored list completely, and when omitted leaves it unchanged. | | One-way migration | Any successful `PUT` or `PATCH /v1/shield/policy` permanently switches a pre-existing organisation off legacy masking (`legacy_mask_active: false`). | | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `shield_policy_enforced` | The organisation's Shield policy is `enforced`, and the request to `/v1/shield/inspect` tries to weaken an active rule or omit custom patterns via `policy`. | | 403 | `masking_not_supported_for_endpoint` | The endpoint supports neither Noirdoc Shield nor legacy masking, yet the policy is `enforced` or the request sends `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also `X-Noirdoc-Shield: on`). During the legacy masking transition until 30.11.2026, this also affects `/v1/embeddings` and `/v1/rerank` on pre-existing organisations that have not switched to Shield yet. | | 403 | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | | 403 | `insufficient_key_permissions` | The API key lacks permission for `/v1/tags` (`can_manage_tags`) or `/v1/shield/policy` (`can_manage_shield`), a key pinned to `shield_mode: on` tries to weaken the Shield policy or a tag's `shield_mode`, or the tag requests broader models, providers or compliance rules than the calling key itself holds. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `shield_policy_invalid` | The submitted Shield policy is inconsistent, such as `enforced` with all five protection filters set to `off`, or mixing `rules`/`custom_patterns` with flat rule keys. | | 422 | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | ## Legacy masking (sunset 30 November 2026) > **Legacy masking sunset on 30 November 2026:** Pre-existing organisations configured for reversible masking (`<>`) continue running unchanged until **30 November 2026** (`2026-11-30T23:59:59Z`). After that timestamp, all remaining organisations switch automatically to Noirdoc Shield. During the transition window, every legacy-masked response includes RFC 8594 headers: **Transition response headers** ```http Deprecation: true Sunset: Mon, 30 Nov 2026 23:59:59 GMT X-Noirdoc-Masked: true ``` #### Transition behaviour, parallel testing and migration details - **Transition scope:** Encrypted Redis mappings for `<>` placeholders, sentence-buffered streaming and Base64 `file_analysis_mode` on Chat, Responses and Messages continue at €0.00 surcharge during the transition window. `/v1/embeddings` and `/v1/rerank` do not support legacy masking; legacy PDF/DOCX/XLSX analysis uses status 403 (`file_pii_blocked`) and 422 (`file_unprocessable`). - **Parallel testing:** Test Noirdoc Shield in parallel via `X-Noirdoc-Shield: on` per request, `shield_mode: "on"` on selected keys or tags, or `POST /v1/shield/inspect` while `X-Noirdoc-Mask` continues to control legacy masking. - **Permanent switch:** Admins can switch permanently at any time under **Models → Shield** (**Switch to Noirdoc Shield now**) or via `PUT` / `PATCH /v1/shield/policy`. --- # Providers, Routing & § 203 > How the gateway selects providers, handles automatic failover, restricts models per key or tag and enforces § 203 StGB. - **Source:** https://www.noirdoc.de/en/docs/routing/ - **API base URL:** `https://api.noirdoc.de/v1` In your request you specify the model ID rather than the provider: the gateway filters eligible providers for the endpoint family, API format (Anthropic-format routes via `/v1/messages`, OpenAI-compatible routes via `/v1/chat/completions` and sibling endpoints), organisation, key and request tags, and returns the answering provider slug in the `X-Noirdoc-Provider` response header. **Python** ```python from openai import OpenAI client = OpenAI(base_url="https://api.noirdoc.de/v1") raw = client.chat.completions.with_raw_response.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Check clause 6 deadlines."}], ) print(raw.headers.get("x-noirdoc-provider")) # e.g. "aki-io" ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1" }); const { data, response } = await client.chat.completions .create({ model: "qwen3.8-27b", messages: [{ role: "user", content: "Check clause 6 deadlines." }], }) .withResponse(); console.log(response.headers.get("x-noirdoc-provider")); ``` **curl** ```bash curl -i https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.8-27b", "messages": [{"role": "user", "content": "Check clause 6 deadlines."}] }' ``` **Response** ```http HTTP/2 200 content-type: application/json x-noirdoc-provider: aki-io ``` Error responses involving an upstream provider also include `X-Noirdoc-Provider`; if a streaming provider responds after more than 15 seconds, the gateway emits an SSE comment `: provider=` instead (see [Streaming](/en/docs/sdk/#streaming)). ## Provider order, capacity and failover For every request, the gateway deterministically orders eligible providers and manages per-provider capacity and pre-stream failover: #### Primary sort order *Tiers 1–5* 1. Own provider keys (BYOK under **Models → Providers**, `owned_by: "personal"`) precede managed providers (`"platform"`). 2. Complete model pricing precedes unpriced routes. 3. Lowest weighted price per 1M tokens (3 × input + 1 × output, excluding cache prices). 4. Higher gateway priority (favouring German `DE` and sovereign `EU` data centres at equal price). 5. Longer tenure in the catalogue. #### Capacity limits *Up to 10 s wait* Per-provider concurrency and rate windows prevent overload. When the primary provider is at capacity, the request moves immediately to the next free provider in failover order. If all eligible providers are saturated before forwarding, the gateway waits up to 10 s and then returns status 503 (`capacity_exhausted`) with `Retry-After`. #### Automatic failover *Max 3 providers* Switches before any response bytes are sent on connection/timeout failures or upstream HTTP 401, 402, 429 and 5xx — ordering remaining providers by **priority first**, then **price**. Once streaming has started, the gateway never switches mid-stream. [Noirdoc Shield](/en/docs/shield/) runs once before attempt 1 so every retry receives the same sanitised payload. #### 429 cooldowns & boundaries *1–60 s cooldown* On a managed provider 429, the gateway skips that provider for `Retry-After` clamped to 1–60 s (10 s without a header, 60 s on quota exhaustion; BYOK providers are never paused). Failover never crosses from BYOK to managed providers or from priced to unpriced routes. #### Final error mapping (`provider_rejected_request`) Other upstream 4xx responses (plus 401, 402, 403 and 429 on BYOK routes) return immediately without failover as `provider_rejected_request`. If the final managed provider fails, the gateway returns 429 (`resource_exhausted` from 429/402), `provider_overloaded` (503 on OpenAI routes or 529 on `/v1/messages` and `/v1/skills`, both with `Retry-After`), 502 (`provider_error`, `provider_unreachable`) or 504 (`provider_timeout`). ## Model and provider restrictions By default, a new API key can call every model enabled for your organisation. Configure restrictions per key under **Models → API keys** and per request tag under **Models → Tags** or `/v1/tags`; `GET /v1/models` returns the exact set of models permitted for the calling key, organisation and attached tags: **Check permitted models** **Python** ```python from openai import OpenAI client = OpenAI(base_url="https://api.noirdoc.de/v1") models = client.models.list( extra_headers={"X-Noirdoc-Tags": "mandat-2026-042"} ) print([m.id for m in models.data]) ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1" }); const page = await client.models.list({ headers: { "X-Noirdoc-Tags": "mandat-2026-042" }, }); console.log(page.data.map((m) => m.id)); ``` **curl** ```bash curl https://api.noirdoc.de/v1/models \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "X-Noirdoc-Tags: mandat-2026-042" \ | jq -r '.data[].id' ``` When multiple tags are sent in `X-Noirdoc-Tags`, the gateway takes the intersection: both the model and the provider must be permitted for the organisation, the key and every named tag. #### Allowed models *Default: All models* **All models** (includes future models) or **Selected models only**. Unlisted model IDs fail before forwarding with status 403 (`model_not_allowed_for_key` or `model_not_allowed_for_tag`). #### Data residency *DE · EU* Restricts to providers in selected locations (for example `DE` for German data centres; `EU` also includes locations in EU member states). Without a selection, every location is permitted. #### Only providers without CLOUD Act exposure *403 on exclusion* Excludes providers subject to the US CLOUD Act (status 403 `provider_not_allowed_for_key` / `provider_not_allowed_for_tag`). #### Only §203-covered providers *Incl. BYOK* Allows only providers bound under § 203 StGB — including your own BYOK providers. #### Providers *Provider allowlist* Restricts to selected providers; choosing a single provider pins the key or tag to that route. #### Starter credit (`starter_allowed`) *Before first top-up* Before the first confirmed top-up, managed routes allow only models with `starter_allowed: true` (see [Keys, Tags & Budgets](/en/docs/keys-billing/#guthaben)). Non-starter providers are skipped, returning status 403 (`starter_model_not_allowed`) free of charge only if no eligible provider remains; BYOK routes are unaffected. ## Professionals bound by secrecy (§ 203 StGB) Lawyers, tax advisors, doctors and other professionals bound by secrecy may share confidential data only with service providers bound under § 203 German Criminal Code (StGB). Whether your organisation operates in professional-secrecy mode is set during onboarding on **Getting started** or under **Models → Gateway** (active by default until answered, requiring explicit confirmation to turn off, and also shown as the **§203 client** badge under **Models → Shield**): | Scope / catalogue value | Managed providers | Own providers (BYOK) | | ------------------------------------------------------------ | ----------------- | --------------------- | | Catalogue status `covered` (**§203 covered**) | Permitted | Permitted (if marked) | | Catalogue status `on_request` (**§203 on request**) / `none` | Excluded | Default `none` | | **Organisation mode** | Only `covered` | All allowed | | **Key / tag (Only §203-covered providers)** | Only `covered` | Only `covered` | #### Catalogue status covered vs on_request / none (`covered`) Providers with status `covered` are listed in Annex 4 of the [Data Processing Agreement (DPA)](/en/dpa/) and bound under § 203 StGB (contractual details in [AI for professionals bound by secrecy](/en/professional-secrecy/)). `on_request` is display-only and treated identically to `none` by the gateway. #### Organisation mode vs key/tag filter (`provider_not_allowed_for_tenant`) Organisation mode filters `GET /v1/models`, routing, failover and model-less endpoints such as `/v1/files` (if no eligible provider remains: status 403 `provider_not_allowed_for_tenant`, where the wire identifier refers to the organisation). **Only §203-covered providers** on a key or tag is stricter: because the portal provides no `covered` toggle on BYOK entries, this setting excludes BYOK routes as well (status 403 `provider_not_allowed_for_key` or `provider_not_allowed_for_tag`). > **§ 203 mode & provider-side storage:** Verify your organisation's effective model allowlist live at any time via `GET /v1/models`. > Remember that the § 203 check filters providers without disabling stateful storage — whether a > managed provider may retain Responses API inputs and outputs for 30 days is controlled separately > by **Allow Responses API storage at provider** (`allow_stored_responses` under **Models → > Gateway**, off by default for new organisations; see [Chat & > Responses](/en/docs/reference/chat-responses/#responses)). | Status | Code | Meaning | | --- | --- | --- | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | --- # Keys, Tags & Budgets > Organisation and roles, API keys with permissions and euro budgets, request tags (/v1/tags), prepaid credit, and /v1/models and /v1/prices. - **Source:** https://www.noirdoc.de/en/docs/keys-billing/ - **API base URL:** `https://api.noirdoc.de/v1` An organisation owns its API keys, own providers (BYOK), policies and credit balance; members access it in the portal per organisation either as an **Admin** (invite and remove members, change roles, create and revoke keys, connect BYOK providers, edit settings, top up credit) or as a **Member** (read-only access to keys, usage, settings and balance). ## Organisation, roles and API keys Every API key starts with `px-`, belongs to the organisation and is displayed in full once upon creation under **Models → API keys** (**New key**); a revoked key fails immediately with status 401 (`invalid_api_key`) and can be reactivated or permanently deleted: #### Shield policy & filters *Organisation · Models → Shield* Default mode (`default_off`, `default_on`, `enforced`), five protection filters and `custom_patterns` under **Models → Shield** (see [Noirdoc Shield](/en/docs/shield/)). #### Gateway settings *Organisation · Models → Gateway* `allow_stored_responses` (Responses API provider storage, new organisations: off) and `allow_file_content` (file/image/audio parts, default: on) under **Models → Gateway**. #### Own providers (BYOK), § 203 & credit *Organisation · Models → Providers · Gateway · Billing* Priority BYOK keys under **Models → Providers**, § 203 classification on **Getting started** or under **Models → Gateway** (see [Providers, Routing & § 203](/en/docs/routing/)) and balance under **Billing**. #### Models, providers & Shield mode (`shield_mode`) *API key · Models → API keys* Allowed models, data residency, CLOUD Act, § 203, provider allowlist and Shield (`inherit`, `on`, `off`) under **Models → API keys**. #### Budget (€) *API key · 402 key_budget_exhausted* Optional spending cap per key with configurable reset window (`key_budget_exhausted`). #### Manage Shield policy via API (`can_manage_shield`) *API key* Enables [`/v1/shield/policy`](/en/docs/shield/#policy); a key pinned to `on` cannot weaken the policy (status 403 `insufficient_key_permissions`). #### Allow tag management (/v1/tags) (`can_manage_tags`) *API key* Enables `/v1/tags` and `/v1/tags/_default` within the calling key's own model, provider and Shield restrictions (status 403 `insufficient_key_permissions`). > **One key per application:** Create a dedicated `px-` key for each application and environment (for example `chatbot-prod` and > `chatbot-staging`) so budgets, model restrictions and revocations stay isolated. ## Per-key budgets A euro budget caps spend on a single API key while all other keys in your organisation keep working. On HTTP 402, inspect `error.code` to distinguish credit exhaustion from key or tag budgets: **Python** ```python import openai from openai import OpenAI client = OpenAI(base_url="https://api.noirdoc.de/v1") try: client.chat.completions.create( model="qwen3.8-27b", max_tokens=500, messages=[{"role": "user", "content": "Summarise."}], ) except openai.APIStatusError as err: if err.status_code == 402: code = err.response.json()["error"]["code"] # "insufficient_credit" | "key_budget_exhausted" # | "tag_budget_exhausted" ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1" }); try { await client.chat.completions.create({ model: "qwen3.8-27b", max_tokens: 500, messages: [{ role: "user", content: "Summarise." }], }); } catch (err) { if (err instanceof OpenAI.APIError && err.status === 402) { // err.code: "insufficient_credit" | "key_budget_exhausted" // | "tag_budget_exhausted" } } ``` **curl** ```bash curl -s https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.8-27b", "max_tokens": 500, "messages": [{"role": "user", "content": "Summarise."}] }' | jq '.error.code' ``` **402 Budget** ```json { "error": { "type": "insufficient_quota", "code": "key_budget_exhausted", "message": "This request could cost up to 0.42 EUR, more …", "param": null } } ``` Before forwarding, the gateway checks organisation credit first (`insufficient_credit`), then the key budget (`key_budget_exhausted`), and finally attached tag budgets in header order (`tag_budget_exhausted`). #### Reset windows *UTC* **Daily** (00:00 UTC), **Weekly** (Mondays at 00:00 UTC), **Monthly** (1st of the month at 00:00 UTC) or **Never** (lifetime of the key; empty = no cap). #### Counted spend *status < 400 + Shield* Priced managed models (`status < 400`) plus the [Noirdoc Shield](/en/docs/shield/) inspection fee (+€0.40 per 1M inspected input tokens, including on BYOK routes with active Shield, status 403 `shield_violation` blocks and `POST /v1/shield/inspect`; BYOK without active Shield and legacy masking until 30 November 2026 count as €0.00). #### Pre-flight estimate *Pre-flight* Chat/embeddings: JSON input character length divided by 4 (+€0.40 per 1M tokens when Shield is active) plus `max_tokens` / `max_completion_tokens` / `max_output_tokens` (defaults to 4,096 chat output tokens when omitted — set a realistic `max_tokens` near the cap). Images: count × price per image/megapixel. Audio: checks only whether budget remains. ## Request tags (Preview) > **Preview:** Request tags are available in Preview for selected organisations. Email > [hello@noirdoc.de](mailto:hello@noirdoc.de) to enable them. Without activation, the gateway > rejects the `X-Noirdoc-Tags` header and calls to `/v1/tags` with status 403 > (`request_tags_disabled`). Pass 1 to 5 comma-separated tag names in `X-Noirdoc-Tags` (deduplicated and stripped before forwarding; also evaluated by `GET /v1/models` and `POST /v1/shield/inspect`) to attach per-matter, cost-centre or team budgets, model/provider rules and `shield_mode` without issuing separate API keys. Tag names match `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$` (`_default` is reserved for `/v1/tags/_default`; capped at **1,000** tags per organisation before status 403 `tag_limit_exceeded`). Under **Models → Tags**, unknown tags auto-create on the first forwarded request from the `_default` template by default (`tag_auto_create_enabled: true`; when turned off, unknown tags fail with status 403 `tag_not_found`): **Python** ```python import os import httpx from openai import OpenAI key = os.environ["NOIRDOC_API_KEY"] httpx.put( "https://api.noirdoc.de/v1/tags/mandat-2026-042", headers={"Authorization": f"Bearer {key}"}, json={ "description": "Matter 2026/042 – Employment law", "budget_limit_eur": 25.0, "budget_reset": "monthly", "shield_mode": "on", "allowed_residencies": ["DE", "EU"], "require_no_cloud_act": True, "require_section203": True, }, ).raise_for_status() client = OpenAI(base_url="https://api.noirdoc.de/v1", api_key=key) res = client.chat.completions.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Check deadlines."}], extra_headers={ "X-Noirdoc-Tags": "mandat-2026-042,team-arbeitsrecht" }, ) ``` **TypeScript** ```ts import OpenAI from "openai"; const key = process.env.NOIRDOC_API_KEY!; await fetch("https://api.noirdoc.de/v1/tags/mandat-2026-042", { method: "PUT", headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json", }, body: JSON.stringify({ description: "Matter 2026/042 – Employment law", budget_limit_eur: 25.0, budget_reset: "monthly", shield_mode: "on", allowed_residencies: ["DE", "EU"], require_no_cloud_act: true, require_section203: true, }), }); const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: key, }); await client.chat.completions.create( { model: "qwen3.8-27b", messages: [{ role: "user", content: "Check deadlines." }], }, { headers: { "X-Noirdoc-Tags": "mandat-2026-042,team-arbeitsrecht" } }, ); ``` **curl** ```bash curl -X PUT https://api.noirdoc.de/v1/tags/mandat-2026-042 \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "description": "Matter 2026/042 – Employment law", "budget_limit_eur": 25.0, "budget_reset": "monthly", "shield_mode": "on", "allowed_residencies": ["DE", "EU"], "require_no_cloud_act": true, "require_section203": true }' curl https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "X-Noirdoc-Tags: mandat-2026-042,team-arbeitsrecht" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.8-27b", "messages": [{"role": "user", "content": "Check deadlines."}] }' ``` **Response** ```json { "name": "mandat-2026-042", "description": "Matter 2026/042 – Employment law", "is_active": true, "budget_limit_eur": 25.0, "budget_reset": "monthly", "budget_spent_eur": 0.0, "budget_spent_total_eur": 0.0, "shield_mode": "on", "allowed_residencies": ["DE", "EU"], "require_no_cloud_act": true, "require_section203": true, "last_used_at": null } ``` With multiple tags on a request, allowed models and providers use the strict intersection (status 403 `model_not_allowed_for_tag` / `provider_not_allowed_for_tag`), any `"on"` in `shield_mode` wins over `"off"`, and the full request cost is booked to the API key and to **every** attached tag. | Method & path | Behaviour (`can_manage_tags` required) | | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `GET /v1/tags` | Lists your organisation's tags (optionally filtered with `limit`, `offset` and search query `q`). | | `POST /v1/tags` | Creates a new tag (201 Created); returns status 409 (`tag_already_exists`) if the name is already taken. | | `GET \| PUT /v1/tags/_default` | Reads or updates the default tag template (`tag_auto_create_enabled`, `shield_mode`, budget, model and provider restrictions). | | `GET \| PUT \| PATCH /v1/tags/{name}` | Reads, creates/replaces or updates a single tag; `budget_spent_eur`, `budget_spent_total_eur` and `last_used_at` are preserved across `PUT` and `PATCH`. | | `DELETE /v1/tags/{name}` | Two-stage (204 No Content): on an active tag (`is_active: true`), the first call sets `is_active: false` (subsequent requests get status 403 `tag_disabled`; reactivate via `PATCH` with `{"is_active": true}`). On an already inactive tag, a second call deletes it permanently if `budget_spent_total_eur == 0` — otherwise 409 `tag_has_spend_history`. | ## Credit, starter credit and top-up Organisations not billed by invoice pay for managed model calls (`status < 400`) and Noirdoc Shield inspections from prepaid credit (**Billing → Top up** via Mollie by card or SEPA bank transfer in whole euros, credited after 1–2 banking days for bank transfers, plus VAT where applicable). Because actual usage is deducted after the response, the balance can dip below zero and is settled automatically on the next top-up. > **Starter credit & starter limits:** Granted once per account on the first organisation created. Until the first top-up is confirmed, > managed routes allow only starter-eligible models (status 403 `starter_model_not_allowed`, marked > **After top-up** in the portal, free of charge and not counted against rate limits) and cap > managed requests across the organisation to **5 requests/minute** and **25 requests/day (UTC)** > (status 429 `starter_rate_limit_exceeded` with `Retry-After`; minute rejections do not count > towards the daily 25). BYOK routes are unrestricted; the first confirmed top-up unlocks the full > catalogue and lifts both limits immediately. | Endpoint / feature | Billing unit | | -------------------------- | ---------------------------------------------------------------------------- | | Chat, Responses, Messages | Input, output and cache tokens (`count_tokens` / `input_tokens`: €0) | | Embeddings | Input tokens | | Rerank | Input tokens or per request | | `/v1/audio/speech` | Input characters | | `/v1/audio/transcriptions` | Provider-reported audio duration pro rata per minute | | `/v1/images/generations` | Per image or megapixel | | Noirdoc Shield | +€0.40 per 1M inspected input tokens (BYOK without active Shield remains €0) | #### Automatic top-up *Card only* Configured under **Card payment** → **Top up automatically when credit runs low** with card-charge authorisation. Three required fields: **Top up below** (threshold), **Amount per top-up** (`>=` threshold) and **At most per month** (calendar month cap in `Europe/Berlin`, `>=` amount per top-up; manual top-ups excluded, daily card limit applies to new organisations). At most one automatic charge runs at a time; admins receive mandatory receipt emails. #### Pause & card replacement *Billing* After a bank decline, automatic top-up pauses and can be resumed under **Billing** via **Reactivate**. For an expired card (**Save a new card**), an invalid billing profile, or after **Switch off** / **Remove card**, make one fresh card top-up; for chargebacks or blocked top-ups, contact [hello@noirdoc.de](mailto:hello@noirdoc.de). | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `insufficient_key_permissions` | The API key lacks permission for `/v1/tags` (`can_manage_tags`) or `/v1/shield/policy` (`can_manage_shield`), a key pinned to `shield_mode: on` tries to weaken the Shield policy or a tag's `shield_mode`, or the tag requests broader models, providers or compliance rules than the calling key itself holds. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 409 | `tag_already_exists` | A tag with this name already exists in the organisation. | | 409 | `tag_has_spend_history` | Spend has already been recorded for this tag, so it cannot be permanently deleted. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | ## Models and pricing via API **GET** `https://api.noirdoc.de/v1/models` Returns, sorted by `id`, every model ID the calling key may invoke after applying § 203 StGB, starter credit, key rules and optional `X-Noirdoc-Tags` (own BYOK routes take precedence over managed routes; calling the wrong endpoint family or API format returns status 400 `wrong_endpoint_for_model`): **Python** ```python from openai import OpenAI client = OpenAI(base_url="https://api.noirdoc.de/v1") for model in client.models.list(): print(model.id, model.owned_by) ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1" }); for await (const model of client.models.list()) { console.log(model.id, model.owned_by); } ``` **curl** ```bash curl https://api.noirdoc.de/v1/models \ -H "Authorization: Bearer $NOIRDOC_API_KEY" ``` **Response** ```json { "object": "list", "data": [ { "id": "qwen3.8-27b", "object": "model", "owned_by": "platform", "display_name": "Qwen 3.8 27B", "endpoint_family": "chat", "legacy_public_id": null } ] } ``` `owned_by` distinguishes your own BYOK routes (`"personal"`) from managed routes (`"platform"`); `endpoint_family` is `"chat"`, `"embeddings"`, `"rerank"`, `"stt"`, `"tts"` or `"image_gen"` (non-model endpoints such as `/v1/shield`, `/v1/files`, `/v1/skills` and `/v1/tags` do not appear). **GET** `https://api.noirdoc.de/v1/prices` Public endpoint requiring no authentication: lists every active managed route with a complete price (one row per model and provider, never BYOK) including `starter_allowed`, alongside the top-level flat rate for Noirdoc Shield: **Python** ```python import httpx payload = httpx.get("https://api.noirdoc.de/v1/prices").json() prices = payload["data"] shield_price = payload["shield"] ``` **TypeScript** ```ts const res = await fetch("https://api.noirdoc.de/v1/prices"); const { data: prices, shield: shieldPrice } = await res.json(); ``` **curl** ```bash curl https://api.noirdoc.de/v1/prices ``` **Response** ```json { "object": "list", "data": [ { "public_id": "qwen3.8-27b", "legacy_public_id": null, "provider_slug": "aki-io", "provider_display_name": "AKI.IO", "endpoint_family": "chat", "price_input": 0.3, "price_output": 2.2, "price_cache_read": null, "price_cache_write": null, "price_cache_write_1h": null, "long_context_threshold": null, "price_input_long": null, "price_output_long": null, "price_cache_read_long": null, "price_cache_write_long": null, "price_unit": "per1MTokens", "price_currency": "EUR", "starter_allowed": true } ], "shield": { "price_input": "0.40", "price_unit": "per1MTokens", "currency": "EUR", "price_currency": "EUR" } } ``` Example figures illustrate the response format; query the endpoint directly for current euro prices (including prompt cache rates and long-context tiers above `long_context_threshold`). | `price_unit` | Meaning | Endpoint family & populated price fields | | ------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | | `per1MTokens` | per 1M tokens | Chat (`price_input`, `price_output`, optional cache & `*_long`), embeddings, rerank and Noirdoc Shield (`price_input`) | | `per1MChars` | per 1M input characters | Speech output `tts` (`price_input`) | | `perRequest` | per successful request (regardless of document count) | Rerank (`price_input`) | | `perMinute` | per minute of audio (charged pro rata) | Transcription `stt` (`price_input` or `price_output`) | | `perImage` | per generated image | Images `image_gen` (`price_output`) | | `perMpx` | per started megapixel (1024 × 1024 pixels) per image | Images `image_gen` (`price_output`) | | `perFirstMpx` | first megapixel in `price_output`; each additional megapixel optionally in `price_input` | Images `image_gen` (`price_output`, optional `price_input`) | --- # Workflows: Concepts & Architecture > Typed JSON schemas, safe variable interpolation, single-pass Shield guardrails, version pinning, zero payload retention and pricing. - **Source:** https://www.noirdoc.de/en/docs/concepts/workflows/ - **API base URL:** `https://api.noirdoc.de/v1` **Noirdoc Workflows** executes linear multi-model pipelines synchronously in a single HTTP request: ```text JSON Input → Shield Guardrail → Step 1 → … → Step N → JSON Output ``` Every step inherits your organisation's standard gateway routing: cheapest-first EU selection, Bring Your Own Key (BYOK), provider failover, [§ 203 StGB enforcement](/en/docs/routing/#berufsgeheimnistraeger), and key and [tag budgets](/en/docs/keys-billing/#budgets). > **Beta status & limits:** Noirdoc Workflows is in Beta, enabled by default for every active organisation, and runs 1 to 10 linear steps synchronously as a JSON response (no SSE streaming, at most 300 s total wall-clock timeout and 15 MB request body). ## What happens on a `/run` call? Every request to `POST /v1/workflows/{slug}/run` or `/v{n}/run` runs through five fixed stages: 1. **Auth, body limit (15 MB) & `input_schema`:** Checks the `px-` key and active organisation (401 `invalid_api_key` on an invalid/disabled key or inactive organisation), size caps (15 MB total JSON body, 10 MB decoded per file; 413 `payload_too_large`) and JSON Schema Draft 2020-12 (422 `invalid_workflow_input`). Rejections here (401, 413, 422) incur €0 workflow fee. 2. **Single-pass Shield inspection at ingress:** Under `block` or `redact`, [Noirdoc Shield](/en/docs/shield/) inspects every non-empty string field and inline UTF-8 text file once before Step 1 (billed separately like a direct Shield call). Binary PDFs and images trigger 422 `shield_uninspectable_content` (€0) under `enforced` Shield. If 403 `shield_violation` triggers, model cost is €0.00 while Shield inspection and the single €0.002 workflow run fee are settled normally (fail-closed 503 `shield_unavailable` incurs €0). 3. **Sequential steps 1..N:** Runs prompt steps (optionally with file attachments via `attachments`) with single-pass interpolation and your standard organisation routing. Every executed run settles the single €0.002 orchestration fee once. 4. **Local `output_schema` check + max. 1× auto-repair:** Validates the final JSON against Draft 2020-12 and runs at most one repair call on the final step (502 `workflow_output_invalid` if repair still fails). 5. **Synchronous JSON & zero payload retention:** Returns the validated `output` object with per-step and EUR cost metadata – only metadata is recorded in the run log. ## Typed schemas & 1× auto-repair Each workflow defines an `input_schema` and an `output_schema` using **JSON Schema Draft 2020-12**: #### Input validation (`input_schema`) *€0 on rejection* Before Shield and Step 1, the engine validates the JSON request body against `input_schema`. Invalid payloads fail immediately with 422 `invalid_workflow_input` (listing field paths without logging raw values) at €0 workflow fee. #### Provider normalisation (`strict: true`) *OpenAI & Anthropic* When dispatching to OpenAI or Anthropic models, the engine normalises a provider copy of the schema for `strict: true` (adding `additionalProperties: false` on objects and stripping provider-unsupported keywords such as `format`) while keeping full Draft 2020-12 validation locally. If a provider still rejects the schema with HTTP 400, the step falls back once to prompt-instructed JSON. #### Automatic repair (`meta.repair_attempted`) *Max. 1× on final step* If the final step's output fails JSON parsing or `output_schema` validation, the engine executes at most one repair call to the final step's model with the schema and exact validation errors (`meta.repair_attempted: true`). If it still fails, the API returns 502 `workflow_output_invalid`. ## Safe variable interpolation Prompt templates access inputs and earlier steps via dot paths: - `{{input.}}` reads fields from the (possibly redacted) input JSON. - `{{steps.}}` inserts the full output of a previous step (objects serialised as compact JSON). - `{{steps..}}` reads a nested field from a JSON step output. ```text Channel: {{input.channel}} Message: {{input.message}} Category from step 1: {{steps.classify.category}} ``` Substitution runs strictly in a **single pass** with no Jinja or code evaluation. If untrusted input literally contains `{{steps.classify}}`, that string stays untouched and is never re-expanded. ## File & Vision inputs Alongside text fields, workflows accept PDFs, images and text files directly for Vision-capable catalogue models (such as `gemini-3.8-flash`, `claude-sonnet-5-5` or `gpt-5.4-mini`): #### Schema declaration (`format: data-url`) *Base64 data URL* Declare file inputs in `input_schema` as string fields with `"format": "data-url"` and send them as base64 data URLs (`data:;base64,...`) inside the JSON body. #### Step binding (`attachments`) *Multimodal block* A prompt step references file inputs via `"attachments": ["input.receipt_file"]`. The engine attaches the payload as a native multimodal file or image block and never dumps raw base64 into the prompt text. #### Allowed MIME types & caps *Max. 15 MB body · Max. 10 MB / file* Supports PDF (`application/pdf`), images (`image/png`, `image/jpeg`, `image/webp`, `image/gif`) and UTF-8 text files (`text/plain`, `text/markdown`, `text/csv`, `application/json`, `application/xml`, `text/xml`). Total JSON request body is capped at 15 MB, with at most 10 MB decoded per file. #### Interaction with Noirdoc Shield (`enforced`) *UTF-8 inspected · binary fail-closed* Inline UTF-8 text files are decoded and inspected by Shield. Binary PDFs and images cannot be text-inspected: when your organisation's Shield policy is `enforced`, the run fails before Step 1 with 422 `shield_uninspectable_content` (€0.00); without `enforced`, Shield inspects all remaining text fields and forwards the binary attachment to the Vision model. ## Single-pass Shield at ingress The engine inspects every non-empty string leaf of the input JSON exactly **once before Step 1** through [Noirdoc Shield](/en/docs/shield/) on German infrastructure: #### Disabled (`off`) *Blocked under enforced* Skips Shield inspection; forbidden when the organisation policy is `enforced` (422 `shield_enforced_cannot_disable`). #### Block (`block`) *403 shield_violation* Overrides all enabled organisation rules to `block`; matching content halts before Step 1 with 403 `shield_violation`. #### Redact (`redact`) *secrets & injection stay block* — `[PERSON]`, `[IBAN]` `pii`, `ner` and `custom` redact in memory with fixed placeholders, while `secrets` and `injection` stay `block`. > **Operational guarantees for regulated workloads** > > - **No double billing:** Once ingress inspection passes, downstream step calls carry a service-authenticated internal Shield-checked marker so Shield is charged once at ingress (€0.40 / 1M inspected input tokens), never repeated per step. > - **Fail-closed:** If Shield is unreachable or times out while active, the run aborts with 503 `shield_unavailable`. Uninspected text never reaches a model. > - **Runtime `enforced` override:** If an organisation enables `enforced` after publishing an older workflow with `pii_mode: "off"`, the runtime fails safe to active Shield `redact`. ## Versioning & permissions Drafts (`draft_definition`) are mutable and can be tested in the browser at any time. Publishing records an immutable snapshot (`v1`, `v2`, …) with `sample_input` and `ui_layout` stripped: - `POST /v1/workflows/{slug}/run` always runs the latest published version. - `POST /v1/workflows/{slug}/v{n}/run` pins your application to version `n` – even after `v2` is published. Role boundaries within an organisation: `admin` creates workflows, edits drafts, runs browser tests, publishes new versions and archives workflows; `member` has read-only access to workflows, versions and run metadata. Workflows is available to every active organisation without separate activation; requests with a missing, invalid or disabled API key or an inactive organisation fail before Step 1 with 401 `invalid_api_key` (€0.00). ## Zero payload retention & audit trail The workflow engine **never stores** customer inputs, intermediate step outputs, final outputs or detected plaintext PII in databases, caches or logs: - The run log stores metadata only: `run_id`, workflow ID, version, source (`api` or `browser_test`), HTTP status, error code, duration, step count, `pii_mode`, detected categories (such as `["PERSON", "IBAN"]`) and EUR cost breakdown. - Browser test runs return intermediate step outputs live in the HTTP response only, require no `px-` key, and appear separately from production API runs in gateway audit logs. - Organisation audit logs (**Activity**) record control-plane events (`workflow.created`, `workflow.updated`, `workflow.published`, `workflow.archived`, `workflow.test_run`) without payload data. ## Pricing & settlement | Cost component | Rate | When billed | | -------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------ | | Workflow orchestration fee | €2.00 / 1,000 runs | €0.002 once per executed run (including 403 `shield_violation`, managed models, BYOK and browser test runs). | | Model tokens | Catalogue rate per step | Standard gateway token pricing per step executed (BYOK settles model tokens directly with your provider). | | Noirdoc Shield (optional) | €0.40 / 1M tokens | Once at ingress when `block` or `redact` is active, billed separately just like `/v1/shield/inspect`. | | Base fee / subscription | €0.00 | No minimum spend, no fixed contract term. | > **Billing on rejections and partial runs:** Requests rejected before execution (401 `invalid_api_key`, 413 `payload_too_large`, 422 `invalid_workflow_input`, 422 `shield_uninspectable_content`, 503 `shield_unavailable`) incur **€0.00**. When 403 `shield_violation` halts a run at ingress, zero model tokens are billed while Shield inspection (€0.40 / 1M tokens) and the single €0.002 workflow run fee settle normally. If Step 2 fails after Step 1 succeeds, Step 1's tokens and the single €0.002 run fee remain debited normally. ## Related pages - [**Workflows: 5-Minute Guide**](/en/docs/guides/workflows/) — From starter template to browser test run, immutable v1 publish and your first production API call. - [**Workflows: API Reference**](/en/docs/reference/workflows/) — Endpoints, headers, response fields, Vision attachments, limits and all workflow error codes. --- # Chat & Responses > Generates model responses in the format of the OpenAI Chat Completions and Responses APIs, inspects inputs with Noirdoc Shield and routes across European providers. - **Source:** https://www.noirdoc.de/en/docs/reference/chat-responses/ - **API base URL:** `https://api.noirdoc.de/v1` ## Chat Completions Accepts requests in the format of the OpenAI Chat Completions API (`https://api.noirdoc.de/v1`) and routes them across European providers. **POST** `https://api.noirdoc.de/v1/chat/completions` **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) res = client.chat.completions.create( model="qwen3.8-27b", messages=[{"role": "user", "content": "Check clause 4 deadlines."}], extra_headers={"X-Noirdoc-Shield": "on"}, ) print(res.choices[0].message.content) ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const res = await client.chat.completions.create( { model: "qwen3.8-27b", messages: [{ role: "user", content: "Check clause 4 deadlines." }], }, { headers: { "X-Noirdoc-Shield": "on" } }, ); console.log(res.choices[0]?.message.content); ``` **curl** ```bash curl https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "qwen3.8-27b", "messages": [ {"role": "user", "content": "Check clause 4 deadlines."} ] }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: ionos · X-Noirdoc-Shield: redacted=0 { "id": "chatcmpl-8e21a9", "object": "chat.completion", "model": "qwen3.8-27b", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Clause 4 sets a three-month notice period.", }, "finish_reason": "stop", }, ], "usage": { "prompt_tokens": 18, "completion_tokens": 22, "total_tokens": 40, }, } ``` **403 Shield** ```jsonc // 403 Forbidden · block rule triggered in Noirdoc Shield { "error": { "type": "permission_error", "code": "shield_violation", "message": "Request blocked by Noirdoc Shield policy.", "param": null, }, } ``` Browse public model IDs in the [model catalogue](/en/models/) or query [`GET /v1/models`](/en/docs/keys-billing/#modelle-preise). Standard fields such as `messages`, `tools`, `tool_choice`, `response_format` and `stream` work as documented by OpenAI. Only the following gateway rules differ: #### Model selection (`model`) *endpoint_family: chat* Public model ID of family `chat` from `GET /v1/models` (for example `qwen3.8-27b`). All OpenAI-format models and Google Vertex Gemini models run on this endpoint; managed `claude-*` models return 400 `wrong_endpoint_for_model` (use [`POST /v1/messages`](/en/docs/reference/messages/#messages) instead). Organisations still on starter credit can call starter-eligible models only; other managed models return 403 `starter_model_not_allowed` ([Credit](/en/docs/keys-billing/#guthaben)). The gateway rewrites upstream model names in `model` back to the ID you sent. #### Provider & failover (`X-Noirdoc-Provider`) *Up to 3 providers* `X-Noirdoc-Provider` names the executing provider, including on upstream errors. If a provider fails with 429, 5xx or a network error before the first byte, the gateway tries up to three providers of the same kind (managed providers and BYOK are never mixed; see [Routing](/en/docs/routing/#failover)). #### SSE keep-alive & usage (`stream`) *: ping every 15 s · 600 s limit* With `"stream": true`, if the provider has not sent response headers after 15 seconds, the gateway flushes HTTP 200 and sends a `: ping` comment line every 15 seconds (600 s total limit vs 120 s non-streaming). When 200 was flushed early, `: provider=` precedes the first data event instead of the HTTP header. For billing, the gateway sets `stream_options.include_usage` upstream and strips the extra usage chunk again unless you requested `include_usage: true` yourself ([Streaming](/en/docs/sdk/#streaming)). #### Noirdoc Shield (`X-Noirdoc-Shield`) `[PERSON]`, `[IBAN]` When active, redacts sensitive spans in `messages` in place with fixed placeholders without adding system prompts or buffering stream chunks; `block` hits return 403 `shield_violation` ([Inspected fields](/en/docs/shield/#felder)). Legacy reversible masking (`<>`) applies only to existing organisations during the transition until 2026-11-30 ([Legacy masking](/en/docs/shield/#klassische-maskierung)). #### Files, images & file_id (`file_id`) *UTF-8 < 4 MiB* `image_url`, `file` and `input_audio` parts require **Allow file and image attachments in requests** under **Models → Gateway** (otherwise 403 `file_content_not_allowed`). Shield inspects inline UTF-8 text files under 4 MiB directly; binary files, images and audio produce `X-Noirdoc-Shield: partial; redacted=` or 422 `shield_uninspectable_content` under `enforced` ([Files](/en/docs/reference/media-files/#dateien)). On managed providers, any referenced `file_id` must belong to your organisation (otherwise 404 `object_not_found`). #### Storage & subroutes (`store`) *BYOK for subroutes* On managed providers, `"store": true` returns 403 `stored_responses_disabled` unless **Allow Responses API storage at provider** is enabled under **Models → Gateway**. `GET /v1/chat/completions`, `GET|DELETE /v1/chat/completions/{id}` and `GET /v1/chat/completions/{id}/messages` work only with your own OpenAI-format provider key (BYOK; otherwise 403 `endpoint_not_available_on_platform`, or 502 `provider_not_configured` if none is configured). Stored completions retain one-way `[PERSON]` placeholders. Other paths under `/v1/chat/completions/` return 404 `unsupported_endpoint`. #### Stripped headers *Before forwarding* Before forwarding, the gateway removes your API key, `X-Noirdoc-Shield` and `X-Noirdoc-Mask`. | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `endpoint_not_available_on_platform` | The call would read data from the shared account of a provider managed by Noirdoc and is blocked there. | | 403 | `stored_responses_disabled` | The request would store input and response at the managed provider (`store`, `previous_response_id` or a sub-route for stored responses), and your organisation has not turned on storage at the provider. | | 403 | `reference_not_available_on_platform` | The body refers to objects at the provider (such as `conversation`, `prompt.id` or `vector_store_ids`) whose ownership the gateway cannot check for managed providers. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | | 403 | `file_pii_blocked` | A file contains personal data, and the organisation's legacy file analysis (transition until 30.11.2026) is set to `block` or to `detect_only` under `enforced`. | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `object_not_found` | The object (file, skill or stored response) does not exist or does not belong to your organisation. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 413 | `masking_input_too_large` | A single text segment in a legacy-masked request (transition until 30.11.2026) exceeds the detector's character limit. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | | 422 | `file_unprocessable` | A file could not be processed in legacy file analysis (transition until 30.11.2026): it is too large, unreadable or in a format without analysis. The gateway did not forward the request. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 500 | `internal_error` | An unexpected error occurred in the gateway. | | 500 | `detection_error` | Detecting personal data in legacy masking (transition until 30.11.2026) failed; the gateway did not forward the request. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 502 | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 502 | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | | 502 | `stream_interrupted` | The provider's stream broke off or reported an error after the response had started. The error is in the stream itself, because status code 200 has already been sent by then. `stream_interrupted` carries no `retry_after`; only errors in the stream that correspond to an HTTP error with a wait carry it. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | | 503 | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | | 503 | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | | 503 | `ownership_check_unavailable` | The gateway could not check just now whether the object belongs to your organisation and rejected the request. The response contains `Retry-After` with 5 seconds. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | | 503 | `masking_unavailable` | The legacy masking detector (transition until 30.11.2026) is temporarily unreachable; the gateway did not forward the request. The response contains `Retry-After` with 10 seconds. | | 503 | `gateway_restarting` | The gateway was restarted (deployment) while the stream was still waiting for the provider's response. The error is in the running stream, because status code 200 has already been sent by then. The error object contains `retry_after` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | ## Responses Accepts requests in the format of the OpenAI Responses API and forwards them to OpenAI-format providers that offer this endpoint (`endpoint_family: "chat"` in `GET /v1/models`; if a provider rejects the format, you receive `provider_rejected_request`). **POST** `https://api.noirdoc.de/v1/responses` **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) res = client.responses.create( model="qwen3.8-27b", instructions="Answer in at most three sentences.", input="Which deadlines does clause 8 set?", extra_headers={"X-Noirdoc-Shield": "on"}, ) print(res.output_text) ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const res = await client.responses.create( { model: "qwen3.8-27b", instructions: "Answer in at most three sentences.", input: "Which deadlines does clause 8 set?", }, { headers: { "X-Noirdoc-Shield": "on" } }, ); console.log(res.output_text); ``` **curl** ```bash curl https://api.noirdoc.de/v1/responses \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "qwen3.8-27b", "instructions": "Answer in at most three sentences.", "input": "Which deadlines does clause 8 set?" }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: azure { "id": "resp_4f92c1", "object": "response", "model": "qwen3.8-27b", "output": [ { "type": "message", "role": "assistant", "content": [ { "type": "output_text", "text": "Clause 8 sets a 14-day review deadline.", }, ], }, ], "usage": { "input_tokens": 23, "output_tokens": 15, "total_tokens": 38, }, } ``` **403 Storage** ```jsonc // 403 Forbidden · store: true while storage is disabled { "error": { "type": "permission_error", "code": "stored_responses_disabled", "message": "Provider-side response storage is disabled.", "param": null, }, } ``` Unlike OpenAI's default, `/v1/responses` on Noirdoc is stateless by default and disables upstream storage: #### Stateless default (`store`) *Default: false* On managed providers, the gateway sets `store` to `false` unless **Allow Responses API storage at provider** is enabled under **Models → Gateway** (off by default for new organisations). While off, `"store": true`, `previous_response_id` and `/v1/responses/{id}` subroutes return 403 `stored_responses_disabled`. Pass prior turns directly in `input`; reasoning models remain usable without storage via `include: ["reasoning.encrypted_content"]`. Not enforced on BYOK routes. #### Stored-object references *Managed providers* On managed providers, `conversation`, `prompt.id`, `input[]` items of type `item_reference` or carrying only an `id`, and `tools[].vector_store_ids` return 403 `reference_not_available_on_platform`. `previous_response_id`, `file_id` and containers must belong to your organisation (otherwise 404 `object_not_found`). Under Shield, `previous_response_id` needs no mapping store because `[PERSON]` placeholders are one-way. Not enforced on BYOK routes. #### Noirdoc Shield & attachments (`X-Noirdoc-Shield`) `[PERSON]`, `[IBAN]` Inspects `instructions` and `input` in place, or returns 403 `shield_violation` on `block` hits. `input_image` and `input_file` follow the same portal toggle and 4 MiB UTF-8 inspection rules as Chat Completions ([Files](/en/docs/reference/media-files/#dateien)). #### Subroutes (`/v1/responses/*`) *input_tokens · compact · {id}* `POST /v1/responses/input_tokens` counts input tokens for `model`, skips Shield and is billed at €0 (still returns 402 on managed providers when organisation credit or key budget is exhausted). `POST /v1/responses/compact` requires `model`, runs Shield when active and is billed by tokens. `GET|DELETE /v1/responses/{id}`, `POST /v1/responses/{id}/cancel` and `GET /v1/responses/{id}/input_items` carry no `model` and route to your organisation's oldest active OpenAI-format provider (BYOK first; on managed providers only when storage is enabled and the ID belongs to your organisation, otherwise 404 `object_not_found`). Other paths under `/v1/responses/` return 404 `unsupported_endpoint`. #### Streaming & starter credit (`: ping`) *15 s keep-alive* 15-second `: ping` keep-alives, `: provider=` and the `starter_model_not_allowed` starter-credit check match `/v1/chat/completions`. If a stream fails mid-flight, the gateway emits an `error` event followed by `data: [DONE]` — check `event.type == "error"` in your OpenAI Python SDK loop ([Streaming](/en/docs/sdk/#streaming)). | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `endpoint_not_available_on_platform` | The call would read data from the shared account of a provider managed by Noirdoc and is blocked there. | | 403 | `stored_responses_disabled` | The request would store input and response at the managed provider (`store`, `previous_response_id` or a sub-route for stored responses), and your organisation has not turned on storage at the provider. | | 403 | `reference_not_available_on_platform` | The body refers to objects at the provider (such as `conversation`, `prompt.id` or `vector_store_ids`) whose ownership the gateway cannot check for managed providers. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | | 403 | `file_pii_blocked` | A file contains personal data, and the organisation's legacy file analysis (transition until 30.11.2026) is set to `block` or to `detect_only` under `enforced`. | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `object_not_found` | The object (file, skill or stored response) does not exist or does not belong to your organisation. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 413 | `masking_input_too_large` | A single text segment in a legacy-masked request (transition until 30.11.2026) exceeds the detector's character limit. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | | 422 | `file_unprocessable` | A file could not be processed in legacy file analysis (transition until 30.11.2026): it is too large, unreadable or in a format without analysis. The gateway did not forward the request. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 500 | `internal_error` | An unexpected error occurred in the gateway. | | 500 | `detection_error` | Detecting personal data in legacy masking (transition until 30.11.2026) failed; the gateway did not forward the request. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 502 | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 502 | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | | 502 | `stream_interrupted` | The provider's stream broke off or reported an error after the response had started. The error is in the stream itself, because status code 200 has already been sent by then. `stream_interrupted` carries no `retry_after`; only errors in the stream that correspond to an HTTP error with a wait carry it. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | | 503 | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | | 503 | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | | 503 | `ownership_check_unavailable` | The gateway could not check just now whether the object belongs to your organisation and rejected the request. The response contains `Retry-After` with 5 seconds. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | | 503 | `masking_unavailable` | The legacy masking detector (transition until 30.11.2026) is temporarily unreachable; the gateway did not forward the request. The response contains `Retry-After` with 10 seconds. | | 503 | `gateway_restarting` | The gateway was restarted (deployment) while the stream was still waiting for the provider's response. The error is in the running stream, because status code 200 has already been sent by then. The error object contains `retry_after` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | --- # Messages (Anthropic) > Generates model responses in the format of the Anthropic Messages API for Claude models via Google Vertex EU and your own Anthropic providers. - **Source:** https://www.noirdoc.de/en/docs/reference/messages/ - **API base URL:** `https://api.noirdoc.de/v1` ## Messages Accepts requests in the format of the Anthropic Messages API (`base_url="https://api.noirdoc.de"` without `/v1` in the Anthropic SDK) and serves Claude models via Google Vertex EU as well as your own Anthropic-compatible providers (BYOK). **POST** `https://api.noirdoc.de/v1/messages` **Python** ```python import os from anthropic import Anthropic client = Anthropic( base_url="https://api.noirdoc.de", auth_token=os.environ["NOIRDOC_API_KEY"], ) msg = client.messages.create( model="claude-sonnet-5-5", max_tokens=1024, messages=[{"role": "user", "content": "Check clause 6 liability."}], extra_headers={"X-Noirdoc-Shield": "on"}, ) print(msg.content[0].text) ``` **TypeScript** ```ts import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ baseURL: "https://api.noirdoc.de", authToken: process.env.NOIRDOC_API_KEY, }); const msg = await client.messages.create( { model: "claude-sonnet-5-5", max_tokens: 1024, messages: [{ role: "user", content: "Check clause 6 liability." }], }, { headers: { "X-Noirdoc-Shield": "on" } }, ); console.log(msg.content); ``` **curl** ```bash curl https://api.noirdoc.de/v1/messages \ -H "x-api-key: $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "claude-sonnet-5-5", "max_tokens": 1024, "messages": [ {"role": "user", "content": "Check clause 6 liability."} ] }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: anthropic-gcp { "id": "msg_01XfdUDYJgAACzvnptvVoYEL", "type": "message", "role": "assistant", "model": "claude-sonnet-5-5", "content": [ { "type": "text", "text": "Clause 6 caps liability at the annual contract value.", }, ], "stop_reason": "end_turn", "usage": { "input_tokens": 21, "output_tokens": 31, }, } ``` **403 Shield** ```jsonc // 403 Forbidden · Anthropic error envelope on Shield block { "type": "error", "error": { "type": "permission_error", "code": "shield_violation", "message": "Request blocked by Noirdoc Shield policy.", }, "request_id": "4f1c9a20", } ``` The gateway accepts both `x-api-key` (`api_key`) and `Authorization: Bearer` (`auth_token`). For Claude Code setup see [Claude Code & Tools](/en/docs/tools/#claude-code). System prompts, tool use, extended thinking, streaming and prompt caching follow the Anthropic specification (`2023-06-01`). Only the following gateway rules differ: #### Model selection (`model`) *Anthropic format* Public model ID of an Anthropic-format model from `GET /v1/models` (such as `claude-sonnet-5-5` or `claude-haiku-4-5` via Google Vertex EU, or your own BYOK provider). OpenAI-format models return 400 `wrong_endpoint_for_model`. Organisations still on starter credit can call starter-eligible models only; non-starter managed models such as `claude-sonnet-5-5` return 403 `starter_model_not_allowed` before the first top-up ([Credit](/en/docs/keys-billing/#guthaben)). The gateway rewrites upstream model names in `model` back to the ID you sent. #### Google Vertex & version (`anthropic-version`) *2023-06-01* To Anthropic directly, the gateway always sends `anthropic-version: 2023-06-01`. On Google Vertex EU, the gateway translates `model`, version identifier and `anthropic-beta` headers into Vertex's native request format automatically — your `/v1/messages` request stays identical. #### Prompt caching (`cache_control`) *5 min · 1 h TTL* `cache_control` breakpoints (`ephemeral`, 5-minute and 1-hour TTLs where supported by the provider) pass through unchanged. Because Noirdoc Shield uses deterministic placeholders (`[PERSON]`) and preserves untouched JSON segments byte-for-byte, prompt-cache prefixes stay stable. Cache reads and writes are billed at the model's `price_cache_read`, `price_cache_write` and `price_cache_write_1h` catalogue rates ([Models & pricing](/en/docs/keys-billing/#modelle-preise)). #### Noirdoc Shield (`X-Noirdoc-Shield`) `[PERSON]`, `[IBAN]` Inspects `system` and `messages` in place when active without prepending system prompts or buffering stream chunks; `block` hits return 403 `shield_violation` ([Inspected fields](/en/docs/shield/#felder)). Legacy reversible masking (`<>`) applies only to existing organisations until 2026-11-30 ([Legacy masking](/en/docs/shield/#klassische-maskierung)). #### Streaming & keep-alive (`: ping`) *Up to 3 providers · 600 s limit* Retries up to three providers before the first byte; sends `: ping` every 15 seconds while waiting (600 s total limit, `: provider=` when HTTP 200 was flushed early). Mid-stream errors emit an `error` event followed by `event: message_stop` ([Streaming](/en/docs/sdk/#streaming)). #### Files, images & references (`container.skills`) *UTF-8 < 4 MiB* `image` and `document` blocks require **Allow file and image attachments in requests** under **Models → Gateway** (otherwise 403 `file_content_not_allowed`). Shield inspects inline UTF-8 text documents under 4 MiB directly; binary PDFs and images yield `X-Noirdoc-Shield: partial; redacted=` or 422 `shield_uninspectable_content` under `enforced`. On managed providers, `file` sources, containers and custom skills in `container.skills` must belong to your organisation (otherwise 404 `object_not_found`; see [Files & Skills](/en/docs/reference/media-files/#dateien)). #### Unsupported subroutes & headers (`/v1/messages/*`) *404 unsupported_endpoint* Message Batches (`/v1/messages/batches`) and all paths under `/v1/messages/` other than `/v1/messages/count_tokens` return 404 `unsupported_endpoint`. Before forwarding, the gateway removes your API key, `X-Noirdoc-Shield` and `X-Noirdoc-Mask`. > **Token counting via POST /v1/messages/count_tokens:** `POST /v1/messages/count_tokens` counts input tokens for `model` and `messages` (used by Claude Code for exact context sizing and forwarded to Vertex `count-tokens` on Vertex routes, returning `provider_rejected_request` if Vertex rejects the payload). It skips Noirdoc Shield (masked only under legacy masking until 2026-11-30) and costs €0; on managed providers it still returns 402 when organisation credit or key budget is exhausted. | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `reference_not_available_on_platform` | The body refers to objects at the provider (such as `conversation`, `prompt.id` or `vector_store_ids`) whose ownership the gateway cannot check for managed providers. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | | 403 | `file_pii_blocked` | A file contains personal data, and the organisation's legacy file analysis (transition until 30.11.2026) is set to `block` or to `detect_only` under `enforced`. | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `object_not_found` | The object (file, skill or stored response) does not exist or does not belong to your organisation. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 413 | `masking_input_too_large` | A single text segment in a legacy-masked request (transition until 30.11.2026) exceeds the detector's character limit. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | | 422 | `file_unprocessable` | A file could not be processed in legacy file analysis (transition until 30.11.2026): it is too large, unreadable or in a format without analysis. The gateway did not forward the request. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 500 | `internal_error` | An unexpected error occurred in the gateway. | | 500 | `detection_error` | Detecting personal data in legacy masking (transition until 30.11.2026) failed; the gateway did not forward the request. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 502 | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 502 | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | | 502 | `stream_interrupted` | The provider's stream broke off or reported an error after the response had started. The error is in the stream itself, because status code 200 has already been sent by then. `stream_interrupted` carries no `retry_after`; only errors in the stream that correspond to an HTTP error with a wait carry it. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | | 503 | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | | 503 | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | | 503 | `ownership_check_unavailable` | The gateway could not check just now whether the object belongs to your organisation and rejected the request. The response contains `Retry-After` with 5 seconds. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | | 503 | `masking_unavailable` | The legacy masking detector (transition until 30.11.2026) is temporarily unreachable; the gateway did not forward the request. The response contains `Retry-After` with 10 seconds. | | 503 | `gateway_restarting` | The gateway was restarted (deployment) while the stream was still waiting for the provider's response. The error is in the running stream, because status code 200 has already been sent by then. The error object contains `retry_after` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | --- # Embeddings & Rerank > Generates vector embeddings and re-orders search candidates by relevance, both with stateless Noirdoc Shield input inspection. - **Source:** https://www.noirdoc.de/en/docs/reference/embeddings-rerank/ - **API base URL:** `https://api.noirdoc.de/v1` ## Embeddings Accepts requests in the format of the OpenAI Embeddings API (`endpoint_family: "embeddings"` in `GET /v1/models`) and passes optional parameters such as `encoding_format` and `dimensions` through to the provider. **POST** `https://api.noirdoc.de/v1/embeddings` **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) res = client.embeddings.create( model="BAAI/bge-m3", input=[ "The notice period is three months.", "The contract ends at the end of the quarter.", ], extra_headers={"X-Noirdoc-Shield": "on"}, ) print(len(res.data[0].embedding)) ``` **TypeScript** ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const res = await client.embeddings.create( { model: "BAAI/bge-m3", input: [ "The notice period is three months.", "The contract ends at the end of the quarter.", "Renewal extends the term by twelve months.", ], }, { headers: { "X-Noirdoc-Shield": "on" } }, ); console.log(res.data[0]?.embedding.length); ``` **curl** ```bash curl https://api.noirdoc.de/v1/embeddings \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "BAAI/bge-m3", "input": [ "The notice period is three months.", "The contract ends at the end of the quarter." ] }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: ionos · X-Noirdoc-Shield: redacted=0 { "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.0184, -0.0291, 0.0412], }, { "object": "embedding", "index": 1, "embedding": [-0.0093, 0.0318, 0.0127], }, ], "model": "BAAI/bge-m3", "usage": { "prompt_tokens": 17, "total_tokens": 17, }, } ``` **403 Shield** ```jsonc // 403 Forbidden · block rule triggered in Noirdoc Shield { "error": { "type": "permission_error", "code": "shield_violation", "message": "Request blocked by Noirdoc Shield policy.", "param": null, }, } ``` #### Model selection (`model`) *endpoint_family: embeddings* Public model ID of family `embeddings` from `GET /v1/models` (other families return 400 `wrong_endpoint_for_model`). Organisations still on starter credit can call starter-eligible models only; other managed models return 403 `starter_model_not_allowed` ([Credit](/en/docs/keys-billing/#guthaben)). The response `model` field is rewritten back to the ID you sent. #### Noirdoc Shield (`X-Noirdoc-Shield`) *Text & token arrays* When active (`default_on`, `enforced`, `shield_mode: on` on key or tag, or `X-Noirdoc-Shield: on`), Shield inspects string inputs, string arrays, multimodal text fields and integer token arrays (decoded via `tiktoken`, redacted and re-encoded into token IDs) before forwarding. Responses carry `X-Noirdoc-Shield: redacted=` and `X-Noirdoc-Masked: true`; `block` hits return 403 `shield_violation` ([Inspected fields](/en/docs/shield/#felder)). #### Streaming (`stream`) *Not supported* Not supported. `"stream": true` returns 400 `streaming_not_supported_for_endpoint`. #### Billing (`usage`) *Input tokens + Shield* Input tokens from upstream `usage` (estimated from the request body if unreported), plus Noirdoc Shield when active ([Shield](/en/docs/shield/#schutzfilter)). #### Subroutes & headers (`X-Noirdoc-Provider`) *No subroutes* No subroutes (other paths under `/v1/embeddings/` return 404 `unsupported_endpoint`). `X-Noirdoc-Provider` names the provider; your API key, `X-Noirdoc-Shield` and `X-Noirdoc-Mask` are stripped before forwarding. > **Legacy masking is not supported on /v1/embeddings and /v1/rerank:** Existing organisations on [legacy masking](/en/docs/shield/#klassische-maskierung) (sunset 2026-11-30) receive 403 `masking_not_supported_for_endpoint` under `enforced` or `X-Noirdoc-Mask: on` on `/v1/embeddings` and `/v1/rerank` unless `X-Noirdoc-Shield: on` is set. Use Noirdoc Shield on these endpoints. | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `streaming_not_supported_for_endpoint` | The request asks for streaming, but the endpoint does not support it. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 500 | `internal_error` | An unexpected error occurred in the gateway. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 502 | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 502 | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | | 503 | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | | 503 | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | ## Rerank Scores and orders candidate documents by relevance to a search query (`endpoint_family: "rerank"` in `GET /v1/models`) and returns a normalised response structure across providers. **POST** `https://api.noirdoc.de/v1/rerank` **Python** ```python import os import httpx res = httpx.post( "https://api.noirdoc.de/v1/rerank", headers={ "Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}", "X-Noirdoc-Shield": "on", }, json={ "model": "Qwen/Qwen3-VL-Reranker-8B", "query": "What is the notice period?", "documents": [ "The contract ends at the end of the quarter.", "The notice period is three months.", "Rent is due on the first day of each month.", ], "top_n": 2, "return_documents": True, }, ) res.raise_for_status() print(res.json()["results"][0]) ``` **TypeScript** ```ts const res = await fetch("https://api.noirdoc.de/v1/rerank", { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", "X-Noirdoc-Shield": "on", }, body: JSON.stringify({ model: "Qwen/Qwen3-VL-Reranker-8B", query: "What is the notice period?", documents: [ "The contract ends at the end of the quarter.", "The notice period is three months.", "Rent is due on the first day of each month.", ], top_n: 2, return_documents: true, }), }); const data = await res.json(); console.log(data.results[0]); ``` **curl** ```bash curl https://api.noirdoc.de/v1/rerank \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "Qwen/Qwen3-VL-Reranker-8B", "query": "What is the notice period?", "documents": [ "The contract ends at the end of the quarter.", "The notice period is three months.", "Rent is due on the first day of each month." ], "top_n": 2, "return_documents": true }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: weber · X-Noirdoc-Shield: redacted=0 { "results": [ { "index": 1, "relevance_score": 0.94, "document": { "text": "The notice period is three months.", }, }, { "index": 0, "relevance_score": 0.31, "document": { "text": "The contract ends at the end of the quarter.", }, }, ], "usage": { "total_tokens": 44, }, } ``` **403 Shield** ```jsonc // 403 Forbidden · block rule triggered in Noirdoc Shield { "error": { "type": "permission_error", "code": "shield_violation", "message": "Request blocked by Noirdoc Shield policy.", "param": null, }, } ``` #### Model selection (`model`) *Required · endpoint_family: rerank* Public model ID of family `rerank` from `GET /v1/models` (other families return 400 `wrong_endpoint_for_model`; non-starter managed models on starter credit return 403 `starter_model_not_allowed`). #### Query & documents (`query / documents`) *Required · 1–1,000 strings* `query` must be a non-empty plain string; `documents` must be an array of 1 to 1,000 plain strings. Images or `content` arrays are rejected beforehand with 400 `invalid_rerank_request`. #### Optional parameters (`top_n`) *instruction · return_documents* All optional: `instruction` task string, `top_n` integer `>= 1` limiting returned candidates (`< 1` returns 400 `invalid_rerank_request`), and `return_documents: true` to include `document.text` in each result. #### Normalised response (`results[]`) *index · relevance_score* `results[]` carries `index` (0-based index into `documents`), `relevance_score` (model-specific scale — compare only within one response) and `document` normalised as `{"text": "…"}` (holding the redacted text when Shield redacted documents), plus `usage`. #### Noirdoc Shield (`X-Noirdoc-Shield`) *query · instruction · documents* Inspects `query`, `instruction` and `documents[]` before forwarding (`X-Noirdoc-Shield: redacted=`, `X-Noirdoc-Masked: true`, or 403 `shield_violation` on `block`). Under [legacy masking](/en/docs/shield/#klassische-maskierung) until 2026-11-30, `enforced` and `X-Noirdoc-Mask: on` without `X-Noirdoc-Shield: on` return 403 `masking_not_supported_for_endpoint`. #### Streaming, methods & billing *POST only · No streaming* `POST` only (405 `method_not_allowed` otherwise); `"stream": true` returns 400 `streaming_not_supported_for_endpoint`; subpaths under `/v1/rerank/` return 404 `unsupported_endpoint`. Billed per 1M input tokens (`per1MTokens`, estimated when `usage` is absent) or flat per request (`perRequest` via `price_input`), plus Shield when active ([Models & pricing](/en/docs/keys-billing/#modelle-preise)). ### Prompt tags for Qwen3-Reranker Qwen3-Reranker models achieve their best accuracy when `query` carries `:` and `:` tags and each entry in `documents` starts with `:`. The gateway forwards your strings unchanged without adding tags automatically: **Prompt tags for Qwen3-Reranker** ```python instruct = "Find contract clauses that answer the question." question = "What is the notice period?" docs = [ "The contract ends at the end of the quarter.", "The notice period is three months.", ] payload = { "model": "Qwen/Qwen3-VL-Reranker-8B", "query": f": {instruct}\n: {question}", "documents": [f": {d}" for d in docs], } ``` | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `streaming_not_supported_for_endpoint` | The request asks for streaming, but the endpoint does not support it. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 400 | `invalid_rerank_request` | `query` is not a non-empty string, `documents` is not a list of 1 to 1,000 strings or `top_n` is not an integer of at least 1; `message` names the field. | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 405 | `method_not_allowed` | The endpoint accepts only `POST`. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 500 | `internal_error` | An unexpected error occurred in the gateway. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 502 | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 502 | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | | 503 | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | | 503 | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | --- # Audio, Images & Files > Transcribes audio, generates speech and images, inspects inline text files with Shield and passes /v1/files and /v1/skills through. - **Source:** https://www.noirdoc.de/en/docs/reference/media-files/ - **API base URL:** `https://api.noirdoc.de/v1` ## Audio > **Not inspected by Noirdoc Shield:** `/v1/audio/*` and `/v1/images/generations` inspect neither audio files nor text prompts (use [`POST /v1/shield/inspect`](/en/docs/shield/#inspect) to check text beforehand). Under the `enforced` policy or with `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also with `X-Noirdoc-Shield: on`), the gateway fails closed with 403 `masking_not_supported_for_endpoint`. With `default_on` or `default_off` and no inspection header, requests pass through uninspected. `POST /v1/audio/transcriptions` accepts `multipart/form-data` in the format of the OpenAI Audio API (`endpoint_family: "stt"` in `GET /v1/models`). **POST** `https://api.noirdoc.de/v1/audio/transcriptions` **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) with open("dictation.mp3", "rb") as audio: transcript = client.audio.transcriptions.create( model="whisper", file=audio, ) print(transcript.text) ``` **TypeScript** ```ts import fs from "node:fs"; import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const transcript = await client.audio.transcriptions.create({ model: "whisper", file: fs.createReadStream("dictation.mp3"), }); console.log(transcript.text); ``` **curl** ```bash curl https://api.noirdoc.de/v1/audio/transcriptions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -F model="whisper" \ -F file="@dictation.mp3" ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: azure { "text": "The deadline for comments closes next Friday.", } ``` `POST /v1/audio/speech` accepts JSON in the format of the OpenAI Audio API (`endpoint_family: "tts"`) and returns raw audio bytes with the provider's `Content-Type`. **POST** `https://api.noirdoc.de/v1/audio/speech` **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) speech = client.audio.speech.create( model="tts", voice="alloy", response_format="mp3", input="The meeting takes place on Tuesday at 10:00.", ) speech.write_to_file("meeting.mp3") ``` **TypeScript** ```ts import fs from "node:fs"; import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const speech = await client.audio.speech.create({ model: "tts", voice: "alloy", response_format: "mp3", input: "The meeting takes place on Tuesday at 10:00.", }); fs.writeFileSync("meeting.mp3", Buffer.from(await speech.arrayBuffer())); ``` **curl** ```bash curl https://api.noirdoc.de/v1/audio/speech \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tts", "voice": "alloy", "response_format": "mp3", "input": "The meeting takes place on Tuesday at 10:00." }' \ --output meeting.mp3 ``` **200 Response** ```http HTTP/1.1 200 OK content-type: audio/mpeg x-noirdoc-provider: azure ``` #### Transcription (`stt`) *Max. 26 MB multipart* Multipart body at most 26 MB (26 × 1024 × 1024 bytes including form fields, otherwise 413 `request_too_large`). `model`, `stream` and `response_format` may each appear at most once (otherwise 400 `invalid_multipart_body`). Requires **Allow file and image attachments in requests** under **Models → Gateway** (otherwise 403 `file_content_not_allowed`). #### Response format & billing (`response_format`) *By audio duration* Billed by audio duration. When `response_format` is `json`, `text` or omitted, the gateway requests `verbose_json` upstream to read duration and converts back to your requested format (returning `verbose_json` unchanged if duration is absent). `verbose_json`, `srt` and `vtt` pass through unchanged. #### Text-to-speech (`tts`) *1–4,096 characters* Requires `input` (1 to 4,096 characters) and a non-empty `voice` string (otherwise 400 `invalid_tts_request`). Billed by character count in `input`. #### Streaming, methods & starter credit *POST only · No streaming* `POST` only (405 `method_not_allowed` otherwise); other paths under `/v1/audio/` return 404 `unsupported_endpoint`. `stream` (`true`, `1`, `yes`, `on`) or `stream_format` returns 400 `streaming_not_supported_for_endpoint`. Non-starter managed models on starter credit return 403 `starter_model_not_allowed`. `X-Noirdoc-Provider` names the provider. | Status | Code | Meaning | | --- | --- | --- | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `streaming_not_supported_for_endpoint` | The request asks for streaming, but the endpoint does not support it. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `invalid_tts_request` | `input` or `voice` is missing or empty, or `input` is too long. | | 400 | `invalid_multipart_body` | The body is not valid `multipart/form-data`, or `model`, `stream` or `response_format` appears more than once. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `masking_not_supported_for_endpoint` | The endpoint supports neither Noirdoc Shield nor legacy masking, yet the policy is `enforced` or the request sends `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also `X-Noirdoc-Shield: on`). During the legacy masking transition until 30.11.2026, this also affects `/v1/embeddings` and `/v1/rerank` on pre-existing organisations that have not switched to Shield yet. | | 403 | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | | 405 | `method_not_allowed` | The endpoint accepts only `POST`. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | ## Images Generates images from a text prompt in the format of the OpenAI Images API (`endpoint_family: "image_gen"` in `GET /v1/models`) and returns base64-encoded image data in `data[].b64_json`. **POST** `https://api.noirdoc.de/v1/images/generations` **Python** ```python import base64 import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) img = client.images.generate( model="black-forest-labs/FLUX.1-schnell", prompt="A North Sea lighthouse at sunrise", size="1024x1024", n=1, ) raw = base64.b64decode(img.data[0].b64_json or "") with open("lighthouse.png", "wb") as f: f.write(raw) ``` **TypeScript** ```ts import fs from "node:fs"; import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const img = await client.images.generate({ model: "black-forest-labs/FLUX.1-schnell", prompt: "A North Sea lighthouse at sunrise", size: "1024x1024", n: 1, }); const png = Buffer.from(img.data?.[0]?.b64_json ?? "", "base64"); fs.writeFileSync("lighthouse.png", png); ``` **curl** ```bash curl https://api.noirdoc.de/v1/images/generations \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "black-forest-labs/FLUX.1-schnell", "prompt": "A North Sea lighthouse at sunrise", "size": "1024x1024", "n": 1 }' ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Provider: ionos { "created": 1763180400, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zU...", }, ], } ``` #### Prompt & Shield (`prompt`) *No Shield inspection* Non-empty string (otherwise 400 `invalid_image_request`). Not inspected by Shield: `enforced`, `X-Noirdoc-Shield: on` or `X-Noirdoc-Mask: on` fails closed with 403 `masking_not_supported_for_endpoint`. #### Count & dimensions (`n / size`) *1–10 images · 1–2048 px* `n` integer from 1 to 10 (default 1). `size` as `WIDTHxHEIGHT` with each side 1 to 2048 pixels (defaults to `1024x1024`; `"auto"` is rejected with 400 `invalid_image_request`). Tighter model limits at the provider return `provider_rejected_request`. #### Total megapixels *Max. 16 MP per request* At most 16 megapixels per request (`n` × rounded-up 1024 × 1024 units per image: `1024x1024` = 1 unit → up to 10 images; `1536x1024` = 2 units; `2048x2048` = 4 units → up to 4 images; otherwise 400 `invalid_image_request`). #### Billing & starter credit *Per image or megapixel* Billed per image (`data` count) or per megapixel (from response `size`, else request `size`, else `1024x1024`; see [Models & pricing](/en/docs/keys-billing/#modelle-preise)). Non-starter managed models on starter credit return 403 `starter_model_not_allowed`. #### Streaming & subroutes *POST only · No streaming* `POST` only (405 `method_not_allowed` otherwise); `"stream": true` returns 400 `streaming_not_supported_for_endpoint`; `/v1/images/edits` and other paths under `/v1/images/` return 404 `unsupported_endpoint`. | Status | Code | Meaning | | --- | --- | --- | | 400 | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | | 400 | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | | 400 | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | | 400 | `streaming_not_supported_for_endpoint` | The request asks for streaming, but the endpoint does not support it. | | 400 | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | | 400 | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | | 400 | `invalid_image_request` | `prompt`, `n` or `size` is outside the gateway's limits; `message` names the parameter. | | 400 | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | | 403 | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | | 403 | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `masking_not_supported_for_endpoint` | The endpoint supports neither Noirdoc Shield nor legacy masking, yet the policy is `enforced` or the request sends `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also `X-Noirdoc-Shield: on`). During the legacy masking transition until 30.11.2026, this also affects `/v1/embeddings` and `/v1/rerank` on pre-existing organisations that have not switched to Shield yet. | | 403 | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | | 403 | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | | 403 | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | | 403 | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | | 403 | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | | 403 | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | | 403 | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | | 404 | `model_not_available` | The model ID is not available to the organisation. | | 405 | `method_not_allowed` | The endpoint accepts only `POST`. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 429 | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 500 | `internal_error` | An unexpected error occurred in the gateway. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 502 | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | | 502 | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | | 502 | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | | 503 | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | | 503 | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | | 503 | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | | 504 | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | ## Files & Skills Under **Models → Gateway**, the toggle **Allow file and image attachments in requests** (`allow_file_content`, default: on) gates all file paths. When switched off, messages with file, image, audio or `file_id` parts as well as all requests to `/v1/files`, `/v1/skills` and `/v1/audio/transcriptions` return 403 `file_content_not_allowed`. ### Inline attachments (with Shield inspection for UTF-8 text) When you embed files inline as base64 `data:` URLs on `/v1/chat/completions`, `/v1/responses` or `/v1/messages`, [Noirdoc Shield](/en/docs/shield/#felder) decodes and inspects inline UTF-8 text files (`text/*`, JSON, XML, CSV, Markdown, YAML **under 4 MiB** decoded; at most 4 MiB of inspected text in total or 413 `shield_input_too_large`) before forwarding. Binary documents (PDF, DOCX, XLSX, PPTX), images, audio and `file_id` references cannot be inspected as text: under `enforced` the gateway rejects with 422 `shield_uninspectable_content` (extract text client-side first); without `enforced`, Shield inspects all text fields and marks the response `X-Noirdoc-Shield: partial; redacted=` and `X-Noirdoc-Masked: false`. **Send an inline UTF-8 text file with Shield** ```bash curl https://api.noirdoc.de/v1/chat/completions \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Shield: on" \ -d '{ "model": "qwen3.8-27b", "messages": [{ "role": "user", "content": [ {"type": "text", "text": "Summarise the meeting notes."}, { "type": "file", "file": { "filename": "notes.txt", "file_data": "data:text/plain;base64,Sm9uYXMgQmVja2Vy..." } } ] }] }' ``` ### Passthrough via `/v1/files` and `/v1/skills` `/v1/files` and `/v1/skills` forward uploads, retrievals and deletions unchanged and without Shield inspection to the provider (body up to 600 MB, no gateway surcharge). **POST** `https://api.noirdoc.de/v1/files` **Python** ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.noirdoc.de/v1", api_key=os.environ["NOIRDOC_API_KEY"], ) with open("contract.pdf", "rb") as f: uploaded = client.files.create(file=f, purpose="user_data") print(uploaded.id) ``` **TypeScript** ```ts import fs from "node:fs"; import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.noirdoc.de/v1", apiKey: process.env.NOIRDOC_API_KEY, }); const uploaded = await client.files.create({ file: fs.createReadStream("contract.pdf"), purpose: "user_data", }); console.log(uploaded.id); ``` **curl** ```bash curl https://api.noirdoc.de/v1/files \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "X-Provider: anthropic" \ -F file="@contract.pdf" ``` **200 Response** ```jsonc // 200 OK · X-Noirdoc-Masked: false { "id": "file-7f3a91c2", "object": "file", "bytes": 184320, "created_at": 1763180400, "filename": "contract.pdf", "purpose": "user_data", } ``` #### Fail-closed under enforced (`enforced`) *Read & delete only* Because `/v1/files` and `/v1/skills` are not inspected by Shield, under `enforced` or with `X-Noirdoc-Mask: on` the gateway rejects all write methods (anything other than `GET`, `HEAD`, `OPTIONS`, `DELETE`) with 403 `masking_not_supported_for_endpoint`. Listing, retrieving, `GET /v1/files/{id}/content` and deleting remain permitted. #### Provider selection (`X-Provider`) *BYOK first* Both routes carry no `model` and route to your organisation's oldest active provider of the chosen format (BYOK first; Claude via Google Vertex is not used; 502 `provider_not_configured` if none exists; provider allowlists and starter-credit rules such as `starter_model_not_allowed` still apply). On `/v1/files`, `Authorization: Bearer` or `api-key` selects OpenAI format and `x-api-key` selects Anthropic format; `X-Provider: anthropic` or `X-Provider: openai` (lowercase) overrides that choice. `/v1/skills` always targets Anthropic (`X-Provider` has no effect). For Anthropic, the gateway appends `files-api-2025-04-14` or `skills-2025-10-02` to `anthropic-beta`. #### Managed providers *Per-organisation isolation* On shared platform accounts, the gateway isolates objects per organisation: list calls return only your organisation's files plus Anthropic's pre-built skills (pages may therefore contain fewer items than `limit`), foreign `{id}` lookups return 404 `object_not_found`, unsupported methods return 403 `endpoint_not_available_on_platform`, and an unavailable ownership store returns 503 `ownership_check_unavailable`. Not applied on BYOK routes. #### Subroutes & headers (`X-Noirdoc-Masked: false`) *Up to 600 MB* Supported routes are `POST|GET /v1/files`, `GET|DELETE /v1/files/{id}`, `GET /v1/files/{id}/content` as well as `/v1/skills`, `/v1/skills/{id}`, `/v1/skills/{id}/versions` and `/v1/skills/{id}/versions/{version}` (other subpaths return 404 `unsupported_endpoint`). Successful passthrough responses carry `X-Noirdoc-Masked: false` without `X-Noirdoc-Provider` or `X-Noirdoc-Shield` (upstream errors include `X-Noirdoc-Provider`). #### Legacy file analysis (sunset 2026-11-30) Existing organisations still running [legacy masking](/en/docs/shield/#klassische-maskierung) during the transition until 2026-11-30 continue to evaluate `file_analysis_mode` (`passthrough`, `detect_only`, `pseudonymize`, `block` returning 403 `file_pii_blocked`) on embedded documents up to 25 MB by default (returning 422 `file_unprocessable` in `pseudonymize`/`block` when oversized or unreadable, and reversing placeholders on `GET /v1/files/{id}/content` downloads). Switching to Noirdoc Shield under **Models → Shield** replaces those modes with stateless UTF-8 text inspection. | Status | Code | Meaning | | --- | --- | --- | | 403 | `endpoint_not_available_on_platform` | The call would read data from the shared account of a provider managed by Noirdoc and is blocked there. | | 403 | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 403 | `masking_not_supported_for_endpoint` | The endpoint supports neither Noirdoc Shield nor legacy masking, yet the policy is `enforced` or the request sends `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also `X-Noirdoc-Shield: on`). During the legacy masking transition until 30.11.2026, this also affects `/v1/embeddings` and `/v1/rerank` on pre-existing organisations that have not switched to Shield yet. | | 403 | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | | 403 | `file_pii_blocked` | A file contains personal data, and the organisation's legacy file analysis (transition until 30.11.2026) is set to `block` or to `detect_only` under `enforced`. | | 404 | `unsupported_endpoint` | The gateway does not know this path. | | 404 | `object_not_found` | The object (file, skill or stored response) does not exist or does not belong to your organisation. | | 413 | `request_too_large` | The body exceeds the endpoint's size limit. | | 413 | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `file_unprocessable` | A file could not be processed in legacy file analysis (transition until 30.11.2026): it is too large, unreadable or in a format without analysis. The gateway did not forward the request. | | 500 | `file_analysis_error` | Reserved for file analysis errors. The gateway does not currently send this code. | | 502 | `provider_not_configured` | The organisation has no suitable provider set up for this request. | | 503 | `ownership_check_unavailable` | The gateway could not check just now whether the object belongs to your organisation and rejected the request. The response contains `Retry-After` with 5 seconds. | --- # Workflows > Synchronous execution endpoint for published multi-model workflows with typed JSON input and output, Shield metadata and EUR cost breakdown. - **Source:** https://www.noirdoc.de/en/docs/reference/workflows/ - **API base URL:** `https://api.noirdoc.de/v1` **POST** `https://api.noirdoc.de/v1/workflows/{slug}/run` **POST** `https://api.noirdoc.de/v1/workflows/{slug}/v{n}/run` Executes a published workflow version synchronously and returns the schema-validated output JSON together with per-step and EUR cost metadata. Omitting `/v{n}` executes the latest published version; specifying `/v{n}` pins execution to version `n`. > **Beta & synchronous execution:** Workflows is in Beta (1 to 10 linear steps, synchronous JSON without SSE streaming, up to 300 s total wall-clock timeout). Use the pinned `/v{n}/run` route for production clients. ## Authentication & headers | Header | Required | Effect | | ------------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------- | | `Authorization: Bearer px-...` | Yes | Active Noirdoc API key for your organisation; key budgets, model allowlists and § 203 rules apply to every step. | | `Content-Type` | Yes | `application/json` (UTF-8, at most 15 MB; decoded file attachments at most 10 MB per file). | | `X-Noirdoc-Tags` | Optional | Up to 5 comma-separated request tags; forwarded to every model step and the workflow run fee debit. | ## Request & response The request body is a JSON object matching the workflow's `input_schema` (Draft 2020-12). **Python** ```python import os import httpx url = "https://api.noirdoc.de/v1/workflows/support-triage/run" res = httpx.post( url, headers={ "Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}", "X-Noirdoc-Tags": "support-inbox", }, json={ "message": "Order #48291 from Max Weber arrived damaged.", "channel": "email", }, timeout=310, ) res.raise_for_status() payload = res.json() ``` **TypeScript** ```ts const url = "https://api.noirdoc.de/v1/workflows/support-triage/run"; const res = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", "X-Noirdoc-Tags": "support-inbox", }, body: JSON.stringify({ message: "Order #48291 from Max Weber arrived damaged.", channel: "email", }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const payload = await res.json(); ``` **curl** ```bash curl https://api.noirdoc.de/v1/workflows/support-triage/run \ -H "Authorization: Bearer $NOIRDOC_API_KEY" \ -H "Content-Type: application/json" \ -H "X-Noirdoc-Tags: support-inbox" \ -d '{ "message": "Order #48291 from Max Weber arrived damaged.", "channel": "email" }' ``` **200 Response** ```json { "workflow": "support-triage", "version": 2, "run_id": "wfr_019a7f3c9d2e4b81", "output": { "category": "damaged_item", "urgency": "high", "reply_draft": "We are shipping a replacement for order #48291." }, "meta": { "duration_ms": 1842, "model_cost_eur": "0.004100", "shield_cost_eur": "0.000020", "workflow_fee_eur": "0.002000", "total_cost_eur": "0.006120", "pii_mode": "redact", "detected_types": ["PERSON"], "repair_attempted": false, "steps": [ { "key": "classify", "model": "mistral4-119b", "provider": "aki-io", "wire_format": "openai", "duration_ms": 410, "prompt_tokens": 184, "completion_tokens": 42, "cost_eur": "0.000400" }, { "key": "draft", "model": "claude-sonnet-5-5", "provider": "anthropic-gcp", "wire_format": "anthropic", "duration_ms": 1418, "prompt_tokens": 312, "completion_tokens": 96, "cost_eur": "0.003700" } ] } } ``` All EUR amounts in `meta` are six-decimal strings. On 403 `shield_violation`, the error body lists only `blocked_rule`, `detected_types` and the `meta` cost breakdown (€0.00 model tokens; Shield at €0.40 / 1M tokens and the €0.002 run fee apply normally, never raw values). ### Response fields #### Workflow identity & run ID (`workflow / version / run_id`) *string · int · string* `workflow` names the executed workflow slug (`^[a-z0-9][a-z0-9-]{1,62}$`), `version` the executed immutable version number (`1, 2, …`), and `run_id` the unique run identifier (`wfr_`) for support and audit correlation. #### Validated output (`output`) *object* Result object validated against `output_schema` (Draft 2020-12). #### Duration & repair (`meta.duration_ms / repair_attempted`) *int · bool* `meta.duration_ms` reports total synchronous execution time in milliseconds; `meta.repair_attempted` is `true` if the engine performed its single automatic schema-repair call on the final step. #### Cost breakdown (`meta.*_cost_eur / workflow_fee_eur`) *string (6 decimals)* `meta.model_cost_eur` sums gateway model costs across all executed steps in EUR (`0.000000` for BYOK steps), `meta.shield_cost_eur` reports single-pass ingress Shield inspection cost (`0.000000` when `pii_mode` is `off`), `meta.workflow_fee_eur` is the flat orchestration fee (`0.002000` = €2.00 / 1,000 runs, charged per executed run including 403 `shield_violation`), and `meta.total_cost_eur` is the total sum. #### Shield metadata (`meta.pii_mode / detected_types`) *string · array* `meta.pii_mode` reports the effective Shield mode for the run (`off`, `block` or `redact`); `meta.detected_types` lists detected Shield entity categories (e.g. `["PERSON", "IBAN"]`), never plaintext values. #### Step metadata (`meta.steps[]`) *array* Per-step execution metadata (fields listed in the table below). ### Fields in `meta.steps[]` | Field | Type | Description | | ------------------- | -------- | ---------------------------------------------------------------------------- | | `key` | `string` | Step key from the workflow definition (e.g. `classify`, `draft`). | | `model` | `string` | Model ID executed from your organisation's catalogue. | | `provider` | `string` | Executing provider slug (e.g. `aki-io`, `anthropic-gcp`, `google`, `azure`). | | `wire_format` | `string` | API wire protocol used for the step (`openai` or `anthropic`). | | `duration_ms` | `int` | Execution time for this individual step in milliseconds. | | `prompt_tokens` | `int` | Billed input tokens for the step. | | `completion_tokens` | `int` | Billed output tokens for the step. | | `cost_eur` | `string` | Gateway model cost for this step in EUR (`0.000000` for BYOK steps). | ## Files & Vision (`format: "data-url"` & `attachments`) To pass PDFs, images or text files to a Vision step (such as `gemini-3.8-flash`, `claude-sonnet-5-5` or `gpt-5.4-mini`), declare the input property in `input_schema` with `"format": "data-url"` and reference it in the step via `attachments`: ```json { "input_schema": { "type": "object", "required": ["receipt_file"], "properties": { "receipt_file": { "type": "string", "format": "data-url" } } }, "steps": [ { "key": "extract", "model": "gemini-3.8-flash", "attachments": ["input.receipt_file"], "prompt": "Extract vendor, invoice number, net total and VAT." } ] } ``` - **Allowed MIME types:** `application/pdf`, `image/png`, `image/jpeg`, `image/webp`, `image/gif` and UTF-8 text files (`text/plain`, `text/markdown`, `text/csv`, `application/json`, `application/xml`, `text/xml`). - **Size caps:** At most 15 MB total JSON body and 10 MB decoded per file. > **Binary attachments under enforced Shield:** Binary PDFs and images cannot be text-inspected and return 422 `shield_uninspectable_content` (€0 workflow fee) before Step 1 when your organisation policy is `enforced`. ## Limits | Dimension / limit | Value | Error when exceeded | | ----------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | Steps per workflow | 1 to 10 linear steps | 422 on save / publish | | Request body | at most 15 MB JSON | 413 `payload_too_large` (€0 workflow fee) | | File attachments (`data-url`) | at most 10 MB decoded per file (PDF, PNG/JPEG/WebP/GIF, UTF-8 text) | 413 `payload_too_large`, 422 `invalid_workflow_input` / 422 `shield_uninspectable_content` | | Total wall-clock timeout | 300 s total (steps share the remaining run budget) | 504 `workflow_timeout`, 504 `step_timeout` | | Streaming (SSE) | not supported (synchronous JSON only) | – | | Schema auto-repair | at most 1× on final step | 502 `workflow_output_invalid` | See [Error Codes & Limits](/en/docs/reference/error-codes/#grenzen) for all gateway limits. ## Error codes When an upstream error occurs during a step, the error body adds `step_key` and `model` context and preserves `Retry-After` on 429, 503 and 504. **Typical error payloads** **422 Input** ```jsonc // HTTP 422 Unprocessable Content · €0 workflow fee { "error": { "code": "invalid_workflow_input", "message": "Input payload does not match workflow input_schema.", "details": [ "$: 'message' is a required property", "$.channel: value is not one of the allowed enum values", ], }, } ``` **403 Shield** ```jsonc // HTTP 403 Forbidden · €0 models · Shield + €0.002 run fee { "error": { "code": "shield_violation", "message": "Input blocked by Noirdoc Shield policy.", "blocked_rule": "pii", "detected_types": ["PERSON", "IBAN"], }, "meta": { "run_id": "wfr_019a7f3c9d2e4b81", "workflow": "support-triage", "version": 2, "duration_ms": 64, "model_cost_eur": "0.000000", "shield_cost_eur": "0.000020", "workflow_fee_eur": "0.002000", "total_cost_eur": "0.002020", "pii_mode": "block", "detected_types": ["PERSON", "IBAN"], }, } ``` **502 / 504 Step** ```jsonc // HTTP 502 step_execution_failed (504 step_timeout with Retry-After) { "error": { "code": "step_execution_failed", "message": "Workflow step failed at upstream provider.", "step_key": "draft", "model": "claude-sonnet-5-5", }, } ``` On 403 `shield_violation`, model tokens are €0.00 while Shield (€0.40 / 1M tokens) and the €0.002 run fee apply normally and are reported in `meta`. On 504 `step_timeout`, the body carries the same `step_key` and `model` fields with `"code": "step_timeout"` and preserves any `Retry-After` header. Raw input values never appear in error payloads. | Status | Code | Meaning | | --- | --- | --- | | 401 | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | | 402 | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | | 402 | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | | 402 | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | | 403 | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | | 404 | `workflow_not_found` | The workflow slug or requested version does not exist, has been archived or is not yet published for your organisation. | | 404 | `workflow_version_not_found` | The published version requested in `/v1/workflows/{slug}/v{n}/run` does not exist for this workflow or is less than `1`. | | 409 | `slug_already_exists` | An active (non-archived) workflow with this `slug` already exists in your organisation. | | 413 | `payload_too_large` | The JSON body of a workflow call exceeds the 15 MB limit (or an inline file exceeds 10 MB decoded) before schema and Shield inspection (`0 €` workflow fee). | | 422 | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | | 422 | `invalid_workflow_input` | The JSON body violates the workflow's `input_schema` (Draft 2020-12); execution stops before Step 1 with no workflow fee (`details` lists the missing or invalid fields without raw values). | | 422 | `invalid_template_variable` | A prompt template in step `step_key` references an unknown or missing path under `{{input.*}}` or `{{steps.*}}`. | | 422 | `shield_enforced_cannot_disable` | The organisation's Shield policy is `enforced`, so a workflow cannot be saved or published with `pii_mode: "off"`. | | 429 | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | | 502 | `workflow_output_invalid` | The final workflow step's output still did not match `output_schema` (Draft 2020-12) after one automatic repair attempt. | | 502 | `step_execution_failed` | A workflow model step failed with a gateway or provider response carrying no more specific error code; the response includes `step_key` and `model`. | | 502 | `workflow_charge_failed` | Settling the flat workflow run fee at the gateway was rejected or failed with an unexpected response. | | 503 | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | | 503 | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | | 503 | `billing_unavailable` | The gateway billing endpoint was temporarily unreachable while settling the workflow run fee. | | 504 | `workflow_timeout` | The synchronous workflow run exceeded the 300-second total wall-clock limit. | | 504 | `step_timeout` | A single model step (`step_key`) exceeded the remaining timeout budget of the 300-second run. | ## Related pages - [**Workflows: 5-Minute Guide**](/en/docs/guides/workflows/) — Create from a starter template, run a browser test, publish v1 and make your first API call. - [**Workflows: Concepts & Architecture**](/en/docs/concepts/workflows/) — Execution lifecycle, Draft 2020-12 schemas, interpolation, zero payload retention and billing. --- # Error Codes & Limits > Gateway error JSON format, status-to-type mapping, Retry-After behaviour, body, timeout and rate limits, and all gateway error codes. - **Source:** https://www.noirdoc.de/en/docs/reference/error-codes/ - **API base URL:** `https://api.noirdoc.de/v1` ## Error format & handling The gateway answers every error — including upstream provider errors — with a unified JSON object under `error` carrying a stable `code`, a status-derived `type` and an English `message` (plus `retry_after` in seconds on mid-stream errors after HTTP 200). Always match on `error.code` in application code rather than `message`. On status codes 500 and above, `message` ends with ` (request id )`, matching the `x-request-id` and `request-id` headers. **Gateway error responses** **OpenAI endpoints** ```json { "error": { "type": "insufficient_quota", "code": "key_budget_exhausted", "message": "This API key has reached its spending limit.", "param": null } } ``` **Messages & Skills** ```json { "type": "error", "error": { "type": "billing_error", "code": "key_budget_exhausted", "message": "This API key has reached its spending limit." }, "request_id": "4f1c9a20" } ``` **429 Retry-After** ```http HTTP/1.1 429 Too Many Requests content-type: application/json retry-after: 5 x-noirdoc-provider: ionos x-request-id: 4f1c9a20 { "error": { "type": "rate_limit_error", "code": "resource_exhausted", "message": "The requested resource is temporarily at capacity.", "param": null } } ``` OpenAI endpoints always include `"param": null`; `/v1/messages` and `/v1/skills` use the Anthropic envelope with `request_id`. Only on `/v1/files` does `x-api-key` select the Anthropic envelope while `Authorization: Bearer` and `api-key` select the OpenAI envelope. ### Status-to-`type` mapping | Status | `type` on OpenAI endpoints | `type` on `/v1/messages` and `/v1/skills` | | ------------------ | -------------------------- | ----------------------------------------- | | 400, 405, 409, 422 | `invalid_request_error` | `invalid_request_error` | | 401 | `authentication_error` | `authentication_error` | | 402 | `insufficient_quota` | `billing_error` | | 403 | `permission_error` | `permission_error` | | 404 | `not_found_error` | `not_found_error` | | 413 | `invalid_request_error` | `request_too_large` | | 429 | `rate_limit_error` | `rate_limit_error` | | 500, 502 | `server_error` | `api_error` | | 503 | `server_error` | `overloaded_error` | | 504 | `server_error` | `timeout_error` | | 529 | not used | `overloaded_error` | ### Provider errors & BYOK When a provider returns an error, the gateway normalises it into the error envelope above. On capacity or overload errors it first tries up to three providers for the model ([failover](/en/docs/routing/#failover)), temporarily skipping a managed provider that returned 429 for the duration in its `Retry-After` header (1–60 s, 10 s without header, 60 s when quota is exhausted): | Upstream response | Managed provider | Own provider key (BYOK) | | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | 429 or 402 (capacity / quota) | 429 `resource_exhausted` with `Retry-After` (after failover) | `provider_rejected_request` with upstream status & message (with `Retry-After` 1–60 s on 429, else 5 s) | | 503 or 529 (overload) | `provider_overloaded` with `Retry-After` (status 503 on OpenAI routes, 529 on `/v1/messages` and `/v1/skills`) | `provider_overloaded` with `Retry-After` | | 400, 404, 422 and other 4xx request errors | Immediate `provider_rejected_request` with upstream status and sanitised message (at most 500 characters; `"The provider rejected the request."` if non-JSON; 4xx message text is not logged) | Immediate `provider_rejected_request` with upstream status and message | | 401, 403 or other 5xx | 502 `provider_error` (fixed message) | `provider_rejected_request` on 401/403; 502 `provider_error` on 5xx | Responses expose only the headers set by the gateway (`Content-Type`, `X-Noirdoc-Provider`, `X-Noirdoc-Shield`, `X-Noirdoc-Masked`, `X-Request-ID`, `Request-ID`, `Retry-After`, plus `Content-Disposition` on audio and file downloads); upstream headers such as `x-ratelimit-*` are stripped. ### `Retry-After` & mid-stream errors | Status | Code | `Retry-After` (seconds) | | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | | 429 | `starter_rate_limit_exceeded` | Remaining seconds in the current minute (1–60 s) or current UTC day | | 429 | `resource_exhausted` | Provider value if between 1 and 60 s, otherwise 5 s | | 503, 529 | `provider_overloaded` | Provider value if between 1 and 60 s, otherwise 5 s | | 503 | `capacity_exhausted` | Estimated seconds until a provider frees up (at most 60 s), otherwise 5 s | | 503 | `shield_unavailable`, `service_overloaded`, `forwarding_pool_exhausted`, `ownership_check_unavailable`, `provider_auth_unavailable` | 5 s | | 503 | `masking_unavailable` (legacy masking until 2026-11-30) | 10 s | | 504 | `provider_timeout` | 10 s | > **Mid-stream failure after HTTP 200:** If a stream fails after HTTP 200 has already been sent (for instance after `: ping` keep-alives, mid-stream disconnection with `stream_interrupted`, or `gateway_restarting` with `"retry_after": 5`), the gateway closes the stream with an error event in the endpoint's wire format: > > - **`/v1/chat/completions`:** `data: {"error": {"type": "...", "code": "stream_interrupted", "message": "...", "param": null}}` followed by `data: [DONE]` (raises `APIError` in the OpenAI SDKs). > - **`/v1/responses`:** SSE `error` event followed by `data: [DONE]` (check `event.type == "error"` in OpenAI Python SDK loops). > - **`/v1/messages`:** SSE `error` event followed by `event: message_stop`. **Handle error.code and Retry-After in client code** **Python** ```python import os import httpx RETRYABLE = { "starter_rate_limit_exceeded", "resource_exhausted", "provider_overloaded", "capacity_exhausted", "shield_unavailable", "service_overloaded", "forwarding_pool_exhausted", "provider_timeout", } res = httpx.post( "https://api.noirdoc.de/v1/chat/completions", headers={"Authorization": f"Bearer {os.environ['NOIRDOC_API_KEY']}"}, json={ "model": "qwen3.8-27b", "messages": [{"role": "user", "content": "Hello"}], }, timeout=400, ) if res.status_code >= 400: err = res.json().get("error", {}) code = err.get("code", "unknown") if code in RETRYABLE: wait = int(res.headers.get("retry-after", 5)) print(f"Retry after {wait} s ({code}).") else: print(f"Error {code}: {err.get('message')}") ``` **TypeScript** ```ts const RETRYABLE = new Set([ "starter_rate_limit_exceeded", "resource_exhausted", "provider_overloaded", "capacity_exhausted", "shield_unavailable", "service_overloaded", "forwarding_pool_exhausted", "provider_timeout", ]); const res = await fetch("https://api.noirdoc.de/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.NOIRDOC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "qwen3.8-27b", messages: [{ role: "user", content: "Hello" }], }), }); if (!res.ok) { const body = await res.json().catch(() => null); const code = body?.error?.code ?? "unknown"; if (RETRYABLE.has(code)) { const wait = Number(res.headers.get("retry-after") ?? 5); console.log(`Retry after ${wait} s (${code}).`); } else { console.log(`Error ${code}: ${body?.error?.message ?? res.status}`); } } ``` ## Gateway limits This section consolidates all body-size, timeout, rate and parameter limits enforced by the gateway itself (1 MB = 1024 × 1024 bytes). Tighter model-specific limits at a provider (such as context window length) are returned as `provider_rejected_request`. ### Request sizes & timeouts | Area / endpoint | Limit | Error when exceeded | | ----------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | | Body `/v1/files` & `/v1/skills` (incl. paths) | at most 600 MB | 413 `request_too_large` | | Body all other `/v1/*` endpoints | at most 160 MB | 413 `request_too_large` | | Body `/v1/audio/transcriptions` (multipart) | at most 26 MB | 413 `request_too_large` | | Connecting to a provider | 10 s per provider | 504 `provider_timeout` | | Waiting for provider data (non-stream / stream) | 120 s per provider / 600 s total (`: ping` every 15 s) | 504 `provider_timeout` | | Failover attempts per request | at most 3 providers of the same kind (never mixing BYOK and managed; 3xx returned unchanged) | Error of final attempt | | Waiting for a free provider / upstream pool | up to 10 s / pool cap | 503 `capacity_exhausted` / 503 `forwarding_pool_exhausted` | ### Starter credit, Shield & tags #### Starter credit: model access *Before first top-up · 403 starter_model_not_allowed* Before the first top-up, only starter-eligible models can be called on managed providers; other managed models return 403 `starter_model_not_allowed`. #### Starter credit: rate limits *5 / min · 25 / day (UTC)* Before the first top-up, organisations are limited to 5 requests/minute and 25 requests/day (UTC) on managed providers; exceeding either limit returns 429 `starter_rate_limit_exceeded` with `Retry-After`. Requests rejected by the minute limit or `starter_model_not_allowed` do not count towards the daily limit. #### Standard operation & BYOK *No gateway rate limits* After the first confirmed top-up, on invoice billing or with BYOK, the gateway enforces no per-customer or per-key rate limits ([credit](/en/docs/keys-billing/#guthaben) & [budgets](/en/docs/keys-billing/#budgets) cap spend via status 402). #### Noirdoc Shield: text limit *Max. 4 MiB · 413 shield_input_too_large* At most 4 MiB of encoded text inspected per gateway request; larger inputs return 413 `shield_input_too_large`. #### Inline UTF-8 text attachments under Shield *< 4 MiB decoded* Under 4 MiB decoded. At 4 MiB and above — as well as for binary files, images, audio and `file_id` — Shield sets `X-Noirdoc-Shield: partial; redacted=` without `enforced`, returns 422 `shield_uninspectable_content` under `enforced`, or returns 403 `file_content_not_allowed` when the attachment toggle is off. Legacy file analysis until 2026-11-30: default 25 MB per file or 422 `file_unprocessable`. #### Request tags (Preview) (`X-Noirdoc-Tags`) *1–5 per request · Max. 1,000 / org* 1 to 5 comma-separated tags per request via `X-Noirdoc-Tags` and `/v1/tags`, 1 to 64 characters each (`^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`, not `_default`), at most 1,000 tags per organisation. Exceeding these limits returns 400 `invalid_request_tags` or 403 `tag_limit_exceeded`. ### Endpoint limits | Endpoint / area | Limit | Error when exceeded | | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `POST /v1/shield/inspect`: `input` | 1 to 64 non-empty strings, at most 256 KB UTF-8 combined | 400 `invalid_request_error` | | Shield `custom_patterns` | at most 100 patterns, 2 to 256 characters each (`re:` regex or case-insensitive literal) | 400 `invalid_request_error` | | `POST /v1/rerank` | non-empty `query` string, 1 to 1,000 `documents` strings, optional `top_n >= 1` (text only) | 400 `invalid_rerank_request` | | `POST /v1/audio/speech` | `input` 1 to 4,096 characters, non-empty `voice` string | 400 `invalid_tts_request` | | `POST /v1/images/generations` | non-empty `prompt`, `n` 1 to 10 (default 1), `size` `WIDTHxHEIGHT` 1 to 2048 px per side (default `1024x1024`, `"auto"` rejected), total at most 16 MP rounded up in 1024 × 1024 units | 400 `invalid_image_request` | | `POST /v1/workflows/{slug}/run` & `/v{n}/run` | 1 to 10 linear steps per workflow, at most 15 MB JSON body (10 MB decoded per `format: "data-url"` file), 300 s total wall-clock timeout (steps share the remaining run budget), synchronous JSON without streaming, at most 1× automatic schema repair ([Reference](/en/docs/reference/workflows/)) | 413 `payload_too_large`, 422 `invalid_workflow_input`, 422 `shield_uninspectable_content`, 502 `workflow_output_invalid`, 504 `workflow_timeout` | ## All error codes Reference of all gateway error codes grouped by HTTP status. Search to filter or click any row for meaning and fix; every code has a direct anchor such as [`#key_budget_exhausted`](#key_budget_exhausted): ### 400 Bad request | Code | Meaning | Fix | | --- | --- | --- | | `invalid_request_path` | The path contains a dot segment (`.` or `..`), a `%`, a backslash or a control character. | Send the path without dot segments and without encoded characters, for example `/v1/chat/completions`. | | `model_required` | The request names no model (`model` in the body, or in the form field for `/v1/audio/transcriptions`). | Pass a model ID from `GET /v1/models`. | | `wrong_endpoint_for_model` | The model belongs to a different endpoint family or API format than the endpoint called. | Call the model through the matching endpoint, for example an embedding model through `/v1/embeddings`. | | `streaming_not_supported_for_endpoint` | The request asks for streaming, but the endpoint does not support it. | Remove `stream` from the request. | | `invalid_request_body` | The body is not a JSON object or not encoded in UTF-8. | Send the body as a JSON object in UTF-8 with `Content-Type: application/json` and check the field named in `message`. | | `invalid_request_error` | A parameter on `/v1/shield/inspect` or `/v1/shield/policy` is invalid (such as an empty `input` or one over 256 KB, more than 64 entries, an unknown rule or an invalid custom pattern), or the JSON body is nested too deeply for Shield extraction. | Check `message` and adjust `input` (1 to 64 non-empty strings, at most 256 KB in total), `rules`, `mode` or `custom_patterns` according to the `/v1/shield` reference. | | `provider_rejected_request` | The provider itself rejected the request, for example because of an invalid parameter or a context that is too long. The response carries the provider's status code (400, 404, 409, 413, 422 or another 4xx status code except 401, 402, 403 and 429), and `message` contains the provider's message, shortened and sanitised, at most 500 characters. On routes with your own provider key (BYOK) the gateway also reports the provider's status codes 401, 402, 403 and 429 this way, because the key, credit and quota belong to the customer; with 429 it adds `Retry-After`. | Correct the request based on the message. Repeating it unchanged fails again. `X-Noirdoc-Provider` names the provider. | | `invalid_image_request` | `prompt`, `n` or `size` is outside the gateway's limits; `message` names the parameter. | Correct the named parameter. Split large image requests into several requests. | | `invalid_rerank_request` | `query` is not a non-empty string, `documents` is not a list of 1 to 1,000 strings or `top_n` is not an integer of at least 1; `message` names the field. | Send `query` and each document as plain text, at most 1,000 documents per request, and `top_n` as an integer of at least 1. | | `invalid_tts_request` | `input` or `voice` is missing or empty, or `input` is too long. | Send `input` and `voice` as non-empty strings and shorten `input` to at most 4,096 characters. | | `invalid_multipart_body` | The body is not valid `multipart/form-data`, or `model`, `stream` or `response_format` appears more than once. | Send the audio file as a multipart form with each of these fields at most once. | | `invalid_request_tags` | The `X-Noirdoc-Tags` header or the tag name in the path under `/v1/tags` is empty, contains more than 5 tags or does not match the format `^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$`. | Send 1 to 5 comma-separated tag names of 1 to 64 characters each (`a-z`, `A-Z`, `0-9` and `_ . : -`, starting with a letter or digit). | ### 401 Not authenticated | Code | Meaning | Fix | | --- | --- | --- | | `invalid_api_key` | The key is missing, invalid or deactivated, or the organisation is not active. | Send a valid key starting with `px-` in the `Authorization: Bearer`, `x-api-key` or `api-key` (Azure style) header. Check the key under Models → API keys. | ### 402 Credit or budget | Code | Meaning | Fix | | --- | --- | --- | | `insufficient_credit` | The organisation's credit is used up or lower than the estimated maximum cost of the request (including Noirdoc Shield, also on BYOK routes when Shield is active). | Top up credit under Billing → Top up, or lower `max_tokens` or shorten the input. | | `key_budget_exhausted` | This key's budget is used up for the current period or does not cover the estimated cost of the request. | Raise the spending limit under Models → API keys, lower `max_tokens` or wait for the next reset. | | `tag_budget_exhausted` | The budget of a tag named in `X-Noirdoc-Tags` is used up for the current period or does not cover the estimated cost of the request; `message` names the tag. | Raise the tag's spending limit under Models → Tags or through `/v1/tags`, lower `max_tokens` or wait for the next reset. | ### 403 Not allowed | Code | Meaning | Fix | | --- | --- | --- | | `endpoint_not_available_on_platform` | The call would read data from the shared account of a provider managed by Noirdoc and is blocked there. | Connect your own provider key (BYOK) for this endpoint under Models → Providers. | | `stored_responses_disabled` | The request would store input and response at the managed provider (`store`, `previous_response_id` or a sub-route for stored responses), and your organisation has not turned on storage at the provider. | Send the history with every request, ask an admin to turn on “Allow Responses API storage at provider” under Models → Gateway, or use your own provider key (BYOK). | | `reference_not_available_on_platform` | The body refers to objects at the provider (such as `conversation`, `prompt.id` or `vector_store_ids`) whose ownership the gateway cannot check for managed providers. | Remove the fields named in `message` or use your own provider key (BYOK). | | `model_not_allowed_for_key` | The model is not one of this key's allowed models. | Choose a model from `GET /v1/models` or extend the allowed models under Models → API keys. | | `provider_not_allowed_for_tenant` | The organisation counts as bound by professional secrecy (§ 203 StGB); this excludes every provider that offers this model. | Choose a model from `GET /v1/models`. The list contains only models with permitted providers. | | `provider_not_allowed_for_key` | The key's restrictions (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | Choose a model from `GET /v1/models` or relax the restrictions under Models → API keys. | | `starter_model_not_allowed` | The organisation is still using only its starter credit, and the model or its managed provider is not included in starter credit. | Choose a starter-eligible model from `GET /v1/models`, connect your own provider key under Models → BYOK, or top up credit once under Billing → Top up to unlock all managed models immediately. | | `shield_violation` | Noirdoc Shield blocked the request before forwarding to the provider because an active protection filter configured with `block` matched; `message` names the triggered rule (`secrets`, `pii`, `ner`, `injection` or `custom`). | Remove the triggering content from the request, or change the rule under Models → Shield or via `/v1/shield/policy` to `redact` or `off` (`off` only for `injection`). | | `shield_policy_enforced` | The organisation's Shield policy is `enforced`, and the request to `/v1/shield/inspect` tries to weaken an active rule or omit custom patterns via `policy`. | Omit `policy` or pass only equally strict or stricter rules (`redact` to `block`, or additional `custom_patterns`). | | `masking_not_supported_for_endpoint` | The endpoint supports neither Noirdoc Shield nor legacy masking, yet the policy is `enforced` or the request sends `X-Noirdoc-Mask: on` (and on `/v1/images/generations` also `X-Noirdoc-Shield: on`). During the legacy masking transition until 30.11.2026, this also affects `/v1/embeddings` and `/v1/rerank` on pre-existing organisations that have not switched to Shield yet. | Leave out the header. With `enforced`, an admin can change the default setting under Models → Shield; for `/v1/embeddings` and `/v1/rerank`, switching to Noirdoc Shield enables inspection. | | `file_content_not_allowed` | The request contains files, images or audio, and the organisation does not allow file content. | Send the request without files, or ask an admin to turn on “Allow file and image attachments in requests” under Models → Gateway. | | `file_pii_blocked` | A file contains personal data, and the organisation's legacy file analysis (transition until 30.11.2026) is set to `block` or to `detect_only` under `enforced`. | Remove the personal data from the file, or switch to Noirdoc Shield under Models → Shield. | | `model_not_billable` | The model has no complete price on record, so it cannot be used with credit. | Choose another model or contact support. | | `request_tags_disabled` | The request sends `X-Noirdoc-Tags` or calls `/v1/tags`, but request tags (Preview) are not enabled for this organisation. | Remove the `X-Noirdoc-Tags` header or have request tags enabled for your organisation. | | `tag_not_found` | The named tag does not exist. On requests with `X-Noirdoc-Tags`, automatic tag creation is turned off (status code 403); on `/v1/tags/{name}`, the gateway answers with status code 404. | Create the tag under Models → Tags or with `POST /v1/tags`, or turn on automatic creation in the default tag template. | | `tag_disabled` | A tag named in `X-Noirdoc-Tags` is deactivated. | Activate the tag under Models → Tags or through `/v1/tags`, or remove it from `X-Noirdoc-Tags`. | | `tag_limit_exceeded` | The organisation has reached the maximum of 1,000 request tags. | Delete unused tags without spend history under Models → Tags or with `DELETE /v1/tags/{name}`, or reuse existing tags. | | `insufficient_key_permissions` | The API key lacks permission for `/v1/tags` (`can_manage_tags`) or `/v1/shield/policy` (`can_manage_shield`), a key pinned to `shield_mode: on` tries to weaken the Shield policy or a tag's `shield_mode`, or the tag requests broader models, providers or compliance rules than the calling key itself holds. | Turn on the corresponding management permission under Models → API keys (“Allow tag management (/v1/tags)” or “Manage Shield policy via API”) and modify policies only within that key's own constraints. | | `model_not_allowed_for_tag` | The model is not one of the allowed models of a tag named in `X-Noirdoc-Tags`. | Choose a model from `GET /v1/models` (with the same `X-Noirdoc-Tags` header) or extend the tag's allowed models under Models → Tags. | | `provider_not_allowed_for_tag` | The restrictions of a tag named in `X-Noirdoc-Tags` (providers, data residency, CLOUD Act, § 203) exclude every provider of this model. | Choose a model from `GET /v1/models` (with the same `X-Noirdoc-Tags` header) or relax the tag's restrictions under Models → Tags. | ### 404 Not found | Code | Meaning | Fix | | --- | --- | --- | | `unsupported_endpoint` | The gateway does not know this path. | Use an endpoint from the reference and check the spelling and the `/v1/` prefix. | | `object_not_found` | The object (file, skill or stored response) does not exist or does not belong to your organisation. | Check the ID. Use only IDs that your organisation created through the gateway. | | `model_not_available` | The model ID is not available to the organisation. | Check the model ID with `GET /v1/models`. | | `workflow_not_found` | The workflow slug or requested version does not exist, has been archived or is not yet published for your organisation. | Check the slug and version under Workflows in the Portal and publish the draft as `v1` before calling `/v1/workflows/{slug}/run`. | | `workflow_version_not_found` | The published version requested in `/v1/workflows/{slug}/v{n}/run` does not exist for this workflow or is less than `1`. | Check the published versions under Workflows in the Portal and use an existing positive version number or `/v1/workflows/{slug}/run` for the latest version. | | `http_error` | A request fails with a general HTTP error for which the gateway has no code of its own. The status code follows the error: 404 for an unknown path, 405 for a wrong method and 503 with `Retry-After: 5` when an endpoint is not available in standalone mode. | Read `message` and check the method and path of the request. | ### 405 Method not allowed | Code | Meaning | Fix | | --- | --- | --- | | `method_not_allowed` | The endpoint accepts only `POST`. | Send the request with `POST`. | ### 409 Conflict | Code | Meaning | Fix | | --- | --- | --- | | `tag_already_exists` | A tag with this name already exists in the organisation. | Choose a different tag name or update the existing tag with `PUT /v1/tags/{name}` or `PATCH /v1/tags/{name}`. | | `tag_has_spend_history` | Spend has already been recorded for this tag, so it cannot be permanently deleted. | Leave the tag in the “Inactive” state so that counters and billing history remain intact. | | `slug_already_exists` | An active (non-archived) workflow with this `slug` already exists in your organisation. | Choose another `slug` or archive the existing workflow under Workflows in the Portal to free the name. | ### 413 Request too large | Code | Meaning | Fix | | --- | --- | --- | | `request_too_large` | The body exceeds the endpoint's size limit. | Shrink or split the body, for example the audio file or embedded files. The values are listed under Limits. | | `payload_too_large` | The JSON body of a workflow call exceeds the 15 MB limit (or an inline file exceeds 10 MB decoded) before schema and Shield inspection (`0 €` workflow fee). | Reduce attached PDFs/images below 10 MB decoded or split large inputs across multiple calls under 15 MB. | | `shield_input_too_large` | The text to inspect in this request exceeds the Shield service limit of 4 MiB of encoded text in a single call. | Split large inputs or inline text files across several smaller requests. | | `masking_input_too_large` | A single text segment in a legacy-masked request (transition until 30.11.2026) exceeds the detector's character limit. | Split the text into smaller parts or switch to Noirdoc Shield under Models → Shield. | ### 422 Unprocessable | Code | Meaning | Fix | | --- | --- | --- | | `shield_uninspectable_content` | The Shield policy is `enforced`, and the request carries content that Shield cannot inspect as text (`binary_document` such as PDF or Office, `media_not_inspectable` such as images, audio or video, `file_reference` by ID or URL, `file_too_large` at 4 MiB or above, `file_not_decodable` or `unrecognised_content`). The gateway did not forward the request. | Extract the text beforehand and send it as message text or an inline UTF-8 text file under 4 MiB, or change the default setting from `enforced` to `default_on` under Models → Shield. | | `shield_policy_invalid` | The submitted Shield policy is inconsistent, such as `enforced` with all five protection filters set to `off`, or mixing `rules`/`custom_patterns` with flat rule keys. | Enable at least one protection filter when using `enforced`, and pass rule actions together inside the `rules` object. | | `shield_config_invalid` | The organisation's stored Shield configuration is invalid (for example `enforced` without any active protection filter, or a pattern that fails compilation); the gateway did not forward the request. | Review and re-save the protection filters and custom blocklist under Models → Shield or via `/v1/shield/policy`. | | `file_unprocessable` | A file could not be processed in legacy file analysis (transition until 30.11.2026): it is too large, unreadable or in a format without analysis. The gateway did not forward the request. | Save the file again or in another format (such as PDF, DOCX or XLSX), make it smaller, or extract the text beforehand for Noirdoc Shield. | | `invalid_workflow_input` | The JSON body violates the workflow's `input_schema` (Draft 2020-12); execution stops before Step 1 with no workflow fee (`details` lists the missing or invalid fields without raw values). | Update the request body based on `details` to match the workflow's `input_schema`. | | `invalid_template_variable` | A prompt template in step `step_key` references an unknown or missing path under `{{input.*}}` or `{{steps.*}}`. | Check the variable path in the affected step on the canvas and make sure the field name and upstream step key match exactly. | | `shield_enforced_cannot_disable` | The organisation's Shield policy is `enforced`, so a workflow cannot be saved or published with `pii_mode: "off"`. | Set `pii_mode` on the workflow to `redact` or `block`. | ### 429 Rate limit or provider at capacity | Code | Meaning | Fix | | --- | --- | --- | | `starter_rate_limit_exceeded` | The organisation is still using only its starter credit and has reached the limit of 5 requests per minute or 25 requests per day (UTC) for managed providers. The response contains `Retry-After` with the wait in seconds. | Top up credit under Billing → Top up to lift the limit immediately, or wait the seconds from `Retry-After`. | | `resource_exhausted` | The provider reported capacity problems or exhausted credit (status code 429 or 402), even after failover across up to three providers. The response contains `Retry-After` with the wait in seconds. | Wait the seconds from `Retry-After` and send the request again. The OpenAI and Anthropic SDKs do this on their own. | ### 500 Internal error | Code | Meaning | Fix | | --- | --- | --- | | `internal_error` | An unexpected error occurred in the gateway. | Send the request again. If the error persists, give support the request ID from `message` or `x-request-id`. | | `detection_error` | Detecting personal data in legacy masking (transition until 30.11.2026) failed; the gateway did not forward the request. | Send the request again. If the error persists, contact support or switch to Noirdoc Shield under Models → Shield. | | `file_analysis_error` | Reserved for file analysis errors. The gateway does not currently send this code. | Send the request again. | ### 502 Provider error | Code | Meaning | Fix | | --- | --- | --- | | `provider_not_configured` | The organisation has no suitable provider set up for this request. | Connect a provider for this API format under Models → Providers. | | `provider_misconfigured` | The configuration of the selected provider is invalid, for example a base URL that is not allowed. | Check the provider's base URL and settings under Models → Providers. If a provider managed by Noirdoc is affected, contact support. | | `provider_unreachable` | The gateway could not connect to the provider, or the connection dropped. | Send the request again after a short wait. | | `provider_error` | The provider answered with an error (status code 5xx except 503 and 529, or 401 and 403 on routes with a provider managed by Noirdoc) that the request did not cause. The gateway replaces the provider's message with a fixed text. On routes with your own provider key it reports 401 and 403 as `provider_rejected_request`. | Send the request again. If the error persists, give support the request ID from `message` or `x-request-id`. | | `stream_interrupted` | The provider's stream broke off or reported an error after the response had started. The error is in the stream itself, because status code 200 has already been sent by then. `stream_interrupted` carries no `retry_after`; only errors in the stream that correspond to an HTTP error with a wait carry it. | Discard the incomplete response and send the request again. | | `workflow_output_invalid` | The final workflow step's output still did not match `output_schema` (Draft 2020-12) after one automatic repair attempt. | Review the prompt and `output_schema` in a browser test run, pick a model with `json_schema` support or simplify nested required fields. | | `step_execution_failed` | A workflow model step failed with a gateway or provider response carrying no more specific error code; the response includes `step_key` and `model`. | Inspect `step_key`, `model` and `message`, test the step on the browser canvas or retry after a short wait. | | `workflow_charge_failed` | Settling the flat workflow run fee at the gateway was rejected or failed with an unexpected response. | Check your organisation's credit balance as well as key and tag budgets, then retry the request. | ### 503 Temporarily unavailable | Code | Meaning | Fix | | --- | --- | --- | | `capacity_exhausted` | All providers of the model were at their capacity limit or paused after a 429, even after a wait of up to 10 seconds. The response contains `Retry-After` with the seconds until a provider is expected to be free again, at most 60, or 5 seconds if that is not known. | Wait the seconds from `Retry-After` and send the request again. The OpenAI and Anthropic SDKs do this on their own. | | `provider_overloaded` | The provider reported overload (status code 503 or 529), even after failover across up to three providers. The status code is 503 on OpenAI endpoints and 529 on `/v1/messages` and `/v1/skills`. The response contains `Retry-After` with the provider's value between 1 and 60 seconds, otherwise 5 seconds. | Wait the seconds from `Retry-After` and send the request again. The OpenAI and Anthropic SDKs do this on their own. | | `service_overloaded` | The gateway is temporarily at capacity. The response contains `Retry-After` with 5 seconds. | Wait the seconds from `Retry-After` and send the request again. | | `forwarding_pool_exhausted` | All of the gateway's connections to the providers are in use. This is a limit of the gateway, not of a provider. The response contains `Retry-After` with 5 seconds. | Wait the seconds from `Retry-After` and send the request again. The OpenAI and Anthropic SDKs do this on their own. | | `provider_auth_unavailable` | The gateway's credentials for the provider are currently unavailable. The response contains `Retry-After` with 5 seconds. | Send the request again later. | | `ownership_check_unavailable` | The gateway could not check just now whether the object belongs to your organisation and rejected the request. The response contains `Retry-After` with 5 seconds. | Send the request again. | | `shield_unavailable` | The Noirdoc Shield inspection service is temporarily unreachable; the gateway never forwards a request that requires inspection uninspected (fail-closed). The response contains `Retry-After` with 5 seconds. | Wait the seconds from `Retry-After` and send the request again. The OpenAI and Anthropic SDKs do this on their own. | | `billing_unavailable` | The gateway billing endpoint was temporarily unreachable while settling the workflow run fee. | Wait a few seconds and send the request again. | | `masking_unavailable` | The legacy masking detector (transition until 30.11.2026) is temporarily unreachable; the gateway did not forward the request. The response contains `Retry-After` with 10 seconds. | Wait the seconds from `Retry-After` and send the request again. | | `gateway_restarting` | The gateway was restarted (deployment) while the stream was still waiting for the provider's response. The error is in the running stream, because status code 200 has already been sent by then. The error object contains `retry_after` with 5 seconds. | Wait the seconds from `retry_after` and send the request again. | ### 504 Timeout | Code | Meaning | Fix | | --- | --- | --- | | `provider_timeout` | The provider did not answer within the gateway's timeout. The response contains `Retry-After` with 10 seconds. | Wait the seconds from `Retry-After` and send the request again. | | `workflow_timeout` | The synchronous workflow run exceeded the 300-second total wall-clock limit. | Lower `max_tokens` or the step count, use faster models for earlier steps and send the request again. | | `step_timeout` | A single model step (`step_key`) exceeded the remaining timeout budget of the 300-second run. | Lower `max_tokens` on the affected step or choose a faster `model`, then send the request again. |