# Zapros > Zapros is a metered AI API aggregator at https://zapros.ai. It provides OpenAI-compatible chat, Responses and embeddings, OpenRouter-compatible rerank, Anthropic Messages compatibility, asynchronous image, audio and video generation, scoped management automation, and a stateless MCP server. Prices and balances are in RUB. ## Machine-readable references - OpenAPI 3.1: https://zapros.ai/openapi.json - MCP endpoint: https://zapros.ai/mcp - MCP OAuth protected-resource metadata (RFC 9728): https://zapros.ai/.well-known/oauth-protected-resource/mcp - Management OAuth protected-resource metadata (RFC 9728): https://zapros.ai/.well-known/oauth-protected-resource/api/v1/management - OAuth authorization-server metadata (RFC 8414): https://zapros.ai/.well-known/oauth-authorization-server - OAuth token revocation (RFC 7009): POST https://zapros.ai/oauth/revoke - Human Agent Connect onboarding: https://zapros.ai/connect - Human documentation: https://zapros.ai/docs - Current inference-key policy and usage: https://zapros.ai/api/v1/key - Chat, Responses, and Messages model catalog: https://zapros.ai/api/v1/models - Current text-model count: https://zapros.ai/api/v1/models/count - One current model by canonical author/slug: https://zapros.ai/api/v1/model/{author}/{slug} - Current text models allowed by one inference key: https://zapros.ai/api/v1/models/user - Embedding model catalog: https://zapros.ai/api/v1/embeddings/models - BYOK rerank endpoint: https://zapros.ai/api/v1/rerank - Image model catalog and asynchronous job creation: https://zapros.ai/api/v1/images - Audio model catalog and asynchronous job creation: https://zapros.ai/api/v1/audio - Video model catalog: https://zapros.ai/api/v1/videos ## Authentication and secret separation - Inference keys start with `zpr_`. Use them only for inference endpoints with `Authorization: Bearer zpr_...`. The Anthropic Messages endpoint also accepts the same key in `x-api-key` for official Anthropic SDK compatibility. If both headers are present they must contain the same key. - Manually provisioned management tokens start with `zpm_`. Use them for the management REST API or MCP with `Authorization: Bearer zpm_...`. - Agent Connect OAuth access tokens start with `zpo_` and normally expire after 15 minutes. Each grant and token has exactly one audience: `https://zapros.ai/mcp` or `https://zapros.ai/api/v1/management`. These are separate grants and token families: an MCP token must fail at Management REST and a Management token must fail at MCP. - Management and OAuth scopes are `account:read`, `models:read`, `usage:read`, `compute:read`, `keys:read`, `keys:create`, `keys:update`, and `keys:revoke`. Legacy manual tokens with `keys:write` remain compatible, but new grants use the three narrow mutation scopes. - A management token cannot create another management token, access payments, or top up a balance. Never expose a `zpm_` token to an untrusted model, browser, log, or prompt. - OAuth key creation never returns a raw newly created `zpr_` to an OAuth client, whether it uses MCP or Management REST. It returns a 15-minute, session-authenticated dashboard claim: the owner may safely retry Reveal until explicitly acknowledging that the key was saved. ACK erases encrypted replay copies; expiry before ACK disables the key. Manual `zpm_` calls through MCP use the same claim because output can enter model context. A trusted direct Management REST creation with `zpm_` returns the secret once; if the same idempotent operation was also completed through MCP, a later terminal replay returns claim metadata and never restores an acknowledged or expired secret. - Each account may retain at most 20 active and 100 total management tokens. - Agent Connect public clients revoke a grant with `POST /oauth/revoke`, an exact `zpo_` or `zprf_` token, and their public `client_id`. Revocation invalidates the entire grant, both OAuth token families, and active inference keys created by that grant. Unknown, wrong-client, and already-revoked tokens receive the same empty HTTP 200 response. ## Inference The OpenAI-compatible base URL is `https://zapros.ai/api/v1`. The official Anthropic SDK uses `https://zapros.ai` as its base URL and calls `POST /v1/messages`; the OpenRouter-shaped alias is `POST /api/v1/messages`. - GET `/key`: inspect the authenticated `zpr_` key's policy, current UTC-month budget spend, daily and rolling-seven-UTC-day usage, active reservations, BYOK service fees, and inference rate limit. This read has its own per-key quota. - GET `/models`: public no-charge discovery of the current RUB-priced Chat, Responses, and Messages catalog. Without `offset` and `limit`, it returns the complete filtered catalog; supplying either opts into offset pagination with `offset >= 0`, `1 <= limit <= 1000`, and defaults of 0 and 500 for the omitted member. Supported filters are case-insensitive `q` over model ID/name, comma-separated `model_authors`, comma-separated `input_modalities` (every requested value must be supported; values are `text`, `image`, `audio`, or `file`), minimum `context`, `sort=context-high-to-low`, and optional `output_modalities=text`. Filtering and sorting precede pagination. The response contains `data`, pre-pagination `total_count`, and `links.next`, plus Zapros `object` and `feature_pricing` extensions; it is `no-store` and monetary responses carry `X-Zapros-Currency: RUB`. - GET `/models/count`: return `{ "data": { "count": ... } }` for the current public text catalog; `output_modalities` may be omitted or exactly `text`. - GET `/model/{author}/{slug}`: return `{ "data": ... }` for one exact current public model, or a generic 404 when it is not advertised. This and `/models` expose Zapros's safe RUB catalog projection, not OpenRouter's complete USD-denominated `Model` object. The list/count/get paths use OpenRouter-style HTTP paths and envelopes, but the official OpenRouter SDK's strict `models.list()` and `models.get()` response validators are not a supported contract; use raw HTTP and the published Zapros schema. - GET `/models/user`: with `Authorization: Bearer zpr_...`, list the current RUB chat catalog intersected with this key's `allowed_models`; an empty allowlist means all current chat models. Optional `offset` is 0 or greater, `limit` is 1-1000, and `output_modalities` may be omitted or exactly `text`. Filtering happens before pagination. The private, no-store response uses `data`, `total_count`, and `links.next` while retaining optional Zapros `object` and `feature_pricing` extensions. It is an advisory snapshot, not a dispatch guarantee, balance or remaining-budget check, statement about stored BYOK credentials, or claim about provider preferences, privacy settings, or guardrails. The read performs no inference, provider call, reservation, or charge. - POST `/chat/completions`: chat completions, including streaming. Non-streaming requests may use the optional text-idempotency contract below; OpenRouter BYOK streaming requires its dispatch-only keyed variant. - POST `/responses`: Responses API with managed JSON/SSE and explicit OpenRouter BYOK JSON/one-shot SSE. Every BYOK request requires a first-attempt `Idempotency-Key`. - POST `/messages` (and `https://zapros.ai/v1/messages`): native Anthropic Messages with managed JSON/SSE by default and explicit OpenRouter BYOK JSON/one-shot SSE. Use `x-api-key: zpr_...` with the Anthropic SDK, or the normal Bearer header. Both aliases share one billing and idempotency scope; every BYOK request requires a first-attempt `Idempotency-Key`. - POST `/embeddings`: bounded non-streaming text embeddings with managed credit by default or an exact OpenRouter BYOK selector. It accepts string or string-array input, optional integer `dimensions` from 1 through 32768, and an optional model-specific `input_type` string of 1-64 characters. BYOK requires a first-attempt `Idempotency-Key`. - POST `/rerank`: bounded non-streaming OpenRouter BYOK text reranking for one to 100 documents. It always requires a directly created inference key, exactly one stored OpenRouter workspace credential, and a first-attempt `Idempotency-Key`. - GET `/images`: public no-charge catalog for the single bounded asynchronous image model and its RUB price. - POST `/images`: start one asynchronous `black-forest-labs/flux-1-schnell` image job. It requires a unique 8-128 character visible-ASCII `Idempotency-Key`, a non-empty prompt of at most 10,000 characters, and only `n: 1`, `size: "1024x1024"`, `quality: "standard"`, and `response_format: "url"`. Omitted optional fields use those values. Unknown fields, streaming, and SSE are rejected. HTTP 202 includes `Location`, `Retry-After`, `X-Request-ID`, and `Idempotency-Replayed`. - GET `/images/{id}`: poll the no-store image job using the exact same inference API key that created it. Another key from the same project receives HTTP 404. A known failed job is an HTTP 200 state, not a transport error. - GET `/audio`: public no-charge catalog for the single bounded asynchronous speech model, supported settings, and authoritative `price_per_1000_characters_rub` tariff. - POST `/audio`: start one asynchronous `minimax/speech-02-hd` text-to-speech job. It requires a unique 8-128 character visible-ASCII `Idempotency-Key` and an `input` of 1-5,000 JavaScript UTF-16 code units containing at least one non-whitespace character. Original whitespace is preserved and billed. The only optional settings are `voice: "wise-woman"`, `response_format: "mp3"`, and `speed: 1`; omitted values use those defaults. Unknown fields, streaming, SSE, voice cloning, reference audio, uploads, and arbitrary settings are rejected. HTTP 202 includes `Location`, `Retry-After`, `X-Request-ID`, and `Idempotency-Replayed`. - GET `/audio/{id}`: poll the no-store audio job using the exact same inference API key, organization, workspace, and project that created it. An absent or foreign job returns HTTP 404. A known failed job is an HTTP 200 state, not a transport error. A completed job's `audio_url` is a provider-hosted HTTPS URL that may expire; download and persist the MP3 promptly because Zapros neither proxies nor stores generated audio bytes. - POST `/videos`: start an asynchronous video job. It requires a unique 8-128 character visible-ASCII `Idempotency-Key`. To retry the same intended job within 24 hours of the first request, reuse that key with the identical JSON body; changing the body returns HTTP 409. Do not retry an old key after the 24-hour replay window. Responses include `X-Request-ID` and `Idempotency-Replayed`. - GET `/videos/{id}`: poll a video job with an active inference key from the same owning project. - GET `/models/{author}/{slug}/endpoints`: no-charge discovery of current OpenRouter base provider slugs for one catalog chat model. Send a normal `Authorization: Bearer zpr_...` inference key; the endpoint has a separate per-key rate limit. Eligible `GET /models` entries expose the exact path in `provider_endpoints_url`. The OpenRouter-shaped monetary names returned by `GET /key` are explicitly RUB credits: `data.currency` and `X-Zapros-Currency` are both `RUB`, and one credit equals one ruble, never one USD. `usage` and `usage_monthly` are the authoritative key-budget spend for the current UTC calendar month; a dispatched BYOK request may consume conservative budget authorization, while `byok_usage*` reports only Zapros service fees and excludes the external provider's bill. `usage_daily` starts at 00:00 on the current UTC day, `usage_weekly` covers that day plus the previous six UTC days, and `limit_remaining` already subtracts active reservations. The response excludes account balance, is `private, no-store`, and does not call a provider, run inference, initialize budget state, reserve, or charge funds. Its `X-RateLimit-*` headers describe the separate introspection quota; `data.rate_limit` describes inference. Use `GET /api/v1/management/account` with `account:read` for the wallet balance. Zapros deliberately does not expose `/api/v1/credits`, whose purchased-USD-credit semantics would misrepresent the RUB wallet ledger. ### Chat Project preset references Chat Completions accepts one bounded Zapros alias as the entire primary `model`: `@preset/`. Obtain the private UUID from the Project preset's **Copy API reference** action in Chat Playground. Zapros resolves it only under the exact organization, workspace, and project stored on the authenticated `zpr_` key; creator identity and a browser session do not widen that scope. Foreign, deleted, malformed, or nested saved references return the same opaque HTTP 404 `project_request_preset_not_found`. A preset lookup failure returns HTTP 503 `project_request_preset_unavailable`. Presets saved only in `This browser` are never callable through the API. The saved model is a default. When and only when the raw request has no own `messages` property, a non-empty saved prompt becomes exactly one `{ "role": "user", "content": ... }` message. An explicit `messages` value always wins, including `null`, an empty array, or malformed content that normal Chat validation then rejects. The alias keeps every existing bounded request surface: managed or BYOK dispatch, direct providers, provider preferences, tools, media, structured output, and allowed JSON or SSE behavior are still validated after expansion against the resolved model and route. Only the primary `model` accepts the alias. Fallback `models` entries cannot contain it. A separate top-level `preset` field returns HTTP 400 `unsupported_preset`; combined `model-id@preset/...` syntax returns HTTP 400 `unsupported_combined_preset`. This endpoint does not expose generic OpenRouter presets REST, parameter profiles, stored tools, a system prompt, preset history, or version pins. Zapros's saved prompt is a user message, unlike OpenRouter's system-prompt preset behavior. New calls resolve the latest saved snapshot. Zapros expands the alias locally before catalog freshness, model allowlist, budget, reservation, provider routing, and billing checks; only the resolved model can reach an upstream provider. The raw request-body hash and early idempotency replay happen before preset lookup. Therefore an exact retry with the same `zpr_`, `Idempotency-Key`, and raw parsed JSON body replays the original stored JSON response even if the preset is later updated or deleted; a new idempotency key creates a new call against the latest snapshot. ```bash # Set the zpr_ secret safely in the environment before the first attempt. PRESET_MODEL="@preset/00000000-0000-4000-8000-000000000000" # paste the entire Copy API reference # Generate once for this request and retain it for an exact retry. IDEMPOTENCY_KEY="$(uuidgen)" curl https://zapros.ai/api/v1/chat/completions \ -H "Authorization: Bearer ${ZAPROS_API_KEY:?set ZAPROS_API_KEY}" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $IDEMPOTENCY_KEY" \ -d "{\"model\":\"$PRESET_MODEL\",\"stream\":false,\"max_tokens\":256}" ``` Chat Completions, Responses, and both Messages aliases accept the same strict `provider` object for OpenRouter-backed models. Supported fields are `sort` (`price`, `throughput`, or `latency`), `allow_fallbacks`, `only`, `ignore`, and `order` (each one to eight unique lowercase OpenRouter base-provider slugs without endpoint or paid-tier suffixes), `quantizations` (one to twelve unique values from `int4`, `int8`, `fp4`, `mxfp4`, `nvfp4`, `fp6`, `fp8`, `mxfp8`, `fp16`, `bf16`, `fp32`, or `unknown`), the privacy-tightening values `data_collection: "deny"` and `zdr: true`, and the optional compatibility assertion `require_parameters: true`. `only` is an allowlist and `ignore` is a denylist; their array order has no priority meaning. `order` prioritizes its listed providers. With `allow_fallbacks: true`, `order` is not an allowlist and OpenRouter may use another eligible provider after its ordered candidates are unavailable; combine it with `allow_fallbacks: false` to restrict fallback outside that list. When `order` is present, OpenRouter does not apply `sort`. Zapros always enforces `require_parameters: true` and a server-computed `max_price`; client price caps and provider-specific `options` remain rejected. These routing fields are forwarded only when Zapros dispatches through OpenRouter, whether with managed credit or an OpenRouter BYOK key; direct providers reject them. Preferences may reduce availability and can change the final RUB charge within the reserved ceiling. Privacy preferences constrain inference endpoints, not third-party tool backends. The model catalog advertises `supported_provider_preferences` per model. Chat Completions additionally accepts the Zapros extension `provider.credential_mode` with `managed` (default) or `byok`. BYOK requires the scalar local selector `provider.credential_provider` (`openrouter`, `openai`, `anthropic`, `google`, `deepseek`, or `mistral`) and exactly one active credential for that provider in the inference key's workspace. Every BYOK request requires a directly created (not OAuth-delegated) `zpr_` key and a first-attempt `Idempotency-Key`; `credential_mode` and `credential_provider` are consumed locally and never forwarded. With `credential_provider: "openrouter"`, both `stream: false` and `stream: true` retain the full bounded Chat surface: requested fallback models, client tools and legacy functions, structured output, image/PDF input, capped web-search/plugins, and all bounded OpenRouter preferences (`only`, `ignore`, `order`, `quantizations`, `sort`, `allow_fallbacks`, `data_collection`, `zdr`, and `require_parameters`). OpenRouter model or endpoint fallback remains inside the same selected stored OpenRouter credential; Zapros does not retry the upstream call or fall back to managed credit. OpenRouter BYOK Chat, Responses, and native Messages support one-shot streaming. Their first SSE response is delivered once with `Idempotency-Replayed: false`, and its durable record becomes terminal `idempotency_replay_unavailable` before the stream is returned. Zapros stores no SSE transcript and supports neither replay, resume, nor `Last-Event-ID`. An exact same-key/body retry after stream start, client cancellation, disconnect, stream error, or completion returns HTTP 409 with the stable `X-Request-ID` and never redispatches to the provider; a pre-stream JSON response is instead snapshotted and replayed exactly with `Idempotency-Replayed: true`. A concurrent retry before the SSE is established may return `idempotency_in_progress` with `Retry-After: 2`. Managed streaming plus `Idempotency-Key` remains unsupported, and direct-provider BYOK remains `stream: false`. OpenRouter BYOK Responses is a separate JSON/one-shot-SSE slice of `POST /responses`. Select it with `provider.credential_mode: "byok"` and `provider.credential_provider: "openrouter"`; `managed` remains the default. The local selector can be combined with the existing bounded Responses provider preferences, which are forwarded field by field while both credential fields are consumed locally. The request may use `stream: false` or `stream: true` and requires a directly created `zpr_` key, exactly one active OpenRouter credential in its workspace, and a fresh first-attempt `Idempotency-Key`. Zapros makes one upstream call with no retry, managed-credit fallback, or credential switch. Each committed dispatch charges an immutable 0.01 RUB Zapros endpoint-fee snapshot while the external OpenRouter account pays model cost; a spend-limited key separately authorizes and consumes a conservative catalog amount after dispatch. Responses with a durable fee reservation expose `X-Zapros-Credential-Mode: byok` and `X-Zapros-Service-Fee-Rub`. For an OpenRouter BYOK Responses retry within 24 hours, keep the same `zpr_` credential, `Idempotency-Key`, and identical parsed JSON body. A stored JSON response up to 256 KiB replays exactly with `Idempotency-Replayed: true` and no provider redispatch. A successful SSE is delivered once: before return, Zapros durably commits the 0.01 RUB fee obligation and marks the key terminally `idempotency_replay_unavailable`; cancellation, disconnect, or a mid-stream failure does not release the fee, and reconciliation may finish the ledger settlement. A same-key retry returns HTTP 409 without redispatch. A non-JSON or larger response uses the same terminal retry result; an ambiguous committed dispatch becomes stable HTTP 502 `provider_response_unavailable`. Never switch keys for the same intent in either case. A stored HTTP 409 `idempotency_abandoned` proves no provider call occurred and is the only safe reason to retry that intent under a new key. OpenRouter BYOK Messages is a native JSON/one-shot-SSE slice of both Messages aliases. Select it with `provider.credential_mode: "byok"` and `provider.credential_provider: "openrouter"`; `managed` remains the default. Both local fields are consumed by Zapros and never forwarded. Existing bounded native system/messages, tools, requested model fallbacks, and OpenRouter provider preferences remain available through exactly one stored workspace OpenRouter credential. A stored direct Anthropic credential is not selected by the native Messages endpoints. The request requires a directly created `zpr_` key and a fresh first-attempt `Idempotency-Key`. Zapros makes one upstream call with no retry, managed-credit fallback, or credential switch. Each committed dispatch charges an immutable 0.01 RUB Zapros Messages endpoint-fee snapshot while the external OpenRouter account pays model cost; a spend-limited key separately authorizes and consumes a conservative catalog amount. Durable fee responses expose `X-Zapros-Credential-Mode: byok` and `X-Zapros-Service-Fee-Rub`. For an OpenRouter BYOK Messages retry within 24 hours, keep the same `zpr_` credential, `Idempotency-Key`, and identical parsed JSON body; the two aliases remain one logical endpoint. A stored native JSON response up to 256 KiB replays exactly with `Idempotency-Replayed: true`. A successful native Anthropic SSE is delivered once: before return, Zapros durably commits the 0.01 RUB fee obligation and marks the key terminally `idempotency_replay_unavailable`. Cancellation, disconnect, or a mid-stream failure does not release the fee, and reconciliation may finish the ledger settlement. A same-key retry returns HTTP 409 without redispatch; no transcript, replay, resume, or `Last-Event-ID` is available. Pre-stream JSON remains exactly replayable. An ambiguous committed dispatch becomes stable HTTP 502 `provider_response_unavailable`; never switch keys for the same intent. Embeddings accept one non-empty string or an array of up to 256 non-empty strings; token-ID and media inputs remain disabled. Optional `dimensions` is a safe integer from 1 through 32768. Optional `input_type` is a non-empty string of at most 64 characters; it is intentionally not a closed enum because OpenRouter defines it as a model-specific pass-through string, with values such as `search_query` and `search_document`. Both options are forwarded unchanged and may still be rejected by the selected model or provider. A conservative dimensions-by-batch estimate is checked against the configured maximum response size before dispatch. OpenRouter BYOK embeddings are a separate non-streaming slice of `POST /embeddings`. Select it with exactly `provider: { "credential_mode": "byok", "credential_provider": "openrouter" }`; no other provider fields, routing preferences, or direct-provider embedding credentials are supported. Both selector fields are consumed locally and never forwarded. The request requires a directly created `zpr_` key, exactly one active OpenRouter credential in its workspace, and a fresh first-attempt `Idempotency-Key`. Zapros makes one upstream call with no retry, managed-credit fallback, or credential switch. Each committed dispatch charges an immutable 0.01 RUB Zapros endpoint-fee snapshot while the external OpenRouter account pays model cost; a spend-limited key separately authorizes and consumes a conservative catalog amount after dispatch. Responses with a durable fee reservation expose `X-Zapros-Credential-Mode: byok` and `X-Zapros-Service-Fee-Rub`. For an OpenRouter BYOK embedding retry within 24 hours, keep the same `zpr_` credential, `Idempotency-Key`, and identical parsed JSON body. A stored JSON response up to 256 KiB replays exactly with `Idempotency-Replayed: true` and no provider redispatch. A non-JSON or larger response becomes terminal HTTP 409 `idempotency_replay_unavailable` on retry; an ambiguous committed dispatch becomes stable HTTP 502 `provider_response_unavailable`. Never switch keys for the same intent in either case. A stored HTTP 409 `idempotency_abandoned` proves no provider call occurred and is the only safe reason to retry that intent under a new key. Managed embeddings do not expose this replay contract. OpenRouter BYOK rerank is a separate non-streaming slice of `POST /rerank`. Its exact JSON body contains `model`, `query`, one to 100 non-empty string `documents`, and optional `top_n`, `user`, and `session_id`; `top_n` cannot exceed the document count. The body is capped at 128 KiB. Structured or image documents, `provider`, `trace`, streaming, and unknown fields are rejected. The endpoint is inherently BYOK, so no local provider selector is present in the body. It requires a directly created `zpr_` key, exactly one active OpenRouter credential in its workspace, and a fresh first-attempt `Idempotency-Key`; a non-empty key model allowlist must include the exact rerank model ID. Zapros makes one upstream dispatch with no retry, managed-credit fallback, or credential switch. Each committed rerank dispatch charges an immutable 0.0100 RUB Zapros service-fee snapshot; both the wallet and Zapros key budget account only for that fee, while the external OpenRouter account pays the model cost. Managed rerank is unavailable because OpenRouter's public machine-readable model catalog does not publish authoritative pre-request rerank SKU prices. Private upstream cost fields are removed, while bounded `search_units` and `total_tokens` may remain. A proven pre-dispatch failure releases the fee; a committed provider error or ambiguous post-dispatch result keeps it. For 24 hours, retry rerank with the same inference key, `Idempotency-Key`, and identical parsed JSON body. A JSON response up to 256 KiB replays exactly without another provider call. Because the response echoes selected document text, that text is stored in plaintext for the replay window and then scheduled for deletion. A caught in-process response failure after dispatch becomes a sanitized JSON HTTP 502 that can replay when its snapshot is durable. If the process stops or that snapshot cannot be persisted after dispatch, reconciliation instead makes the retry terminal HTTP 409 `idempotency_replay_unavailable`. Neither outcome redispatches; do not switch keys for the same intent. The image API is a bounded Zapros asynchronous extension, not a wire-compatible implementation of OpenRouter's synchronous `POST /images` JSON/SSE contract and not OpenAI's `/images/generations` path. Use raw HTTP against `GET/POST /api/v1/images` and `GET /api/v1/images/{id}`. The first slice supports only `black-forest-labs/flux-1-schnell`, one 1024x1024 standard-quality URL result, and no input image, multiple outputs, provider preferences, streaming, SSE, resume, or `Last-Event-ID`. POST returns `{ id, status: "processing", model, cost_rub }` with HTTP 202, `Location`, and `Retry-After`. Polling returns `{ id, status, model, image_url, cost_rub, error }`; status is `pending`, `processing`, `completed`, or `failed`, and a known failed job still uses HTTP 200. `image_url` is a provider-hosted HTTPS URL that may expire; download and persist the result promptly. Zapros neither proxies nor stores generated image bytes and does not promise a durable URL. Every image job requires a first-attempt `Idempotency-Key`. For 24 hours, retry the same intent with the same `zpr_` credential, key, and effective image request after defaults. Omitting `n`, `size`, `quality`, or `response_format` is equivalent to sending its documented default explicitly. Zapros replays the small original HTTP 202 envelope and never stores image bytes in the idempotency snapshot. A changed effective value or unfinished matching operation returns HTTP 409, with `Retry-After: 2` on `idempotency_in_progress`. Never reuse the old key after the replay window. Image catalog and job responses are `no-store`. Every audio job requires a first-attempt `Idempotency-Key`. For 24 hours, retry the same intent with the exact same `zpr_` credential, key, and effective audio request after defaults. Omitting `voice`, `response_format`, or `speed` is equivalent to sending `wise-woman`, `mp3`, and `1` explicitly. Zapros replays only the small original HTTP 202 envelope and never stores input text or generated audio bytes in the idempotency snapshot; it retains canonical request hashes and job/billing metadata. A changed effective request or unfinished matching operation returns HTTP 409, with `Retry-After: 2` on `idempotency_in_progress`. Never reuse the old key after the replay window. The immutable request quote counts the original decoded input with JavaScript `string.length`, including leading and trailing whitespace, applies the current public tariff, rounds up to a whole kopek, and has a 0.01 RUB minimum. Audio catalog and job responses are `no-store`. The asynchronous `GET/POST /audio` job API is a Zapros extension, not a wire-compatible implementation of OpenAI or OpenRouter synchronous `POST /audio/speech`. It returns a JSON job envelope rather than raw audio and provides no streaming, SSE, resume, or `Last-Event-ID` contract. Direct OpenAI, Anthropic, Google, DeepSeek, and Mistral BYOK keep a narrower contract: one exact non-streaming scalar-text model without fallbacks, current or legacy tools/functions, media, web search/plugins, or structured output. They reject `only`, `ignore`, `order`, `quantizations`, `sort`, `data_collection`, `zdr`, and `require_parameters`; `allow_fallbacks` may only be false. Direct OpenAI supports only `openai/gpt-5-mini`; direct Anthropic maps only stable `anthropic/claude-sonnet-5.5` to native `claude-sonnet-5-5` at Anthropic's fixed `/v1/messages` endpoint; direct Google supports only `google/gemini-3.8-flash`; direct DeepSeek supports only the non-thinking `deepseek/deepseek-v4.1-flash` slice; direct Mistral supports only the Public Preview `mistralai/mistral-large-4-0` model with reasoning disabled. A direct-provider body may contain only `model`, `messages`, `stream`, `provider`, and at most one of `max_tokens` or `max_completion_tokens`; each message must contain exactly a `system`, `user`, or `assistant` role and string `content`. For Anthropic, one or more leading system messages are combined in the native system field; the conversation must then start and end with a user message, so later system messages and assistant prefills are rejected. Zapros fixes Anthropic upstream reasoning to adaptive thinking with high effort: caller reasoning or thinking controls are rejected, and thinking blocks are omitted from returned assistant content while remaining included in billed `completion_tokens`. Direct Anthropic is selected only through Chat Completions; native Messages BYOK selects only a stored OpenRouter credential, never a stored direct Anthropic key. Sampling, reasoning or thinking controls, and `store` fields are rejected. Direct dispatch is one-shot with no internal retry. No BYOK route switches credential providers or falls back to Zapros' managed credential. Zapros charges a fixed 0.01 RUB service fee for each committed upstream dispatch attempt; for OpenRouter BYOK SSE the fee obligation is durably committed before the stream is returned and remains due after client cancellation, disconnect, a mid-stream failure, or an ambiguous post-dispatch failure. Reconciliation may finish the ledger settlement. A proven pre-dispatch failure releases the reservation without a fee. Cancellation propagates upstream on a best-effort basis, but OpenRouter may continue processing or billing. The selected external provider account pays model costs separately. A spend-limited inference key authorizes a conservative OpenRouter-catalog hold and consumes that full authorization after dispatch, separately from the 0.01 RUB wallet charge. Responses that have a durable fee reservation include `X-Zapros-Credential-Mode: byok` and the immutable fee snapshot in `X-Zapros-Service-Fee-Rub`. The live OpenRouter stream may carry a final usage chunk; this initial slice does not promise terminal token or status analytics from Zapros. Private upstream fields such as `cost`, `cost_details`, `is_byok`, and provider-cost details are not forwarded. For paid Anthropic SDK calls, construct the client with `max_retries=0` and send a fresh `Idempotency-Key` on the first non-streaming attempt. Automatic SDK retry after a lost connection can otherwise create a second provider call. A charge-possible HTTP error includes `X-Should-Retry: false`; any explicit retry of the same intent must reuse the original key and body. For non-streaming `POST /chat/completions`, `POST /responses`, and either Messages alias, an `Idempotency-Key` is optional for managed requests and mandatory for BYOK. Generate 8-128 visible-ASCII characters for each intended request and send it on the first attempt. Adding the key only after an unkeyed timeout cannot associate with or deduplicate the original request and may cause a second paid provider call. A retry must use the same `zpr_` credential and the same logical endpoint; rotating credentials or switching among Chat Completions, Responses, and Messages creates a distinct scope and may issue another paid provider call. The two Messages aliases are the same logical endpoint, so an exact retry may switch between them. Within 24 hours, retry with the same key and an identical parsed JSON body. A stored JSON response up to 256 KiB is replayed without another provider call. If the original response is non-JSON or too large, retrying returns HTTP 409 `idempotency_replay_unavailable` without another provider call. A changed body or an operation still in progress also returns HTTP 409. OpenRouter BYOK Chat, Responses, and Messages are the streaming exceptions above; other `stream: true` requests with the header return HTTP 400. Every attempt, including a replay, passes authentication and rate limiting before idempotency lookup. A pre-lookup HTTP 401, 429, or 503 may omit `Idempotency-Replayed` and use an attempt-local `X-Request-ID`. When an attempt successfully matches or creates the durable idempotency record, `X-Request-ID` stays stable. `Idempotency-Replayed: true` means if and only if the exact stored response body was returned; `false` means no body was replayed and is used for the owning response plus in-progress or replay-unavailable HTTP 409. An `idempotency_in_progress` response includes `Retry-After: 2`; retry the same key after two seconds. A changed-body conflict, invalid input, or other error before a successful record match or claim may likewise omit the idempotency headers or use an attempt-local request ID. Snapshots preserve the HTTP status, JSON body, and Content-Type for terminal responses, including 402 and 5xx errors. Other original provider headers such as Retry-After are not replayed; current CORS and rate-limit headers are recomputed. For `idempotency_replay_unavailable` or stable HTTP 502 `provider_response_unavailable`, never switch keys for the same intent; contact support with `X-Request-ID`. A stored HTTP 409 `idempotency_abandoned` proves the provider was not called, so the same intent may safely retry under a new key. JSON response snapshots are stored in plaintext in the database for 24 hours for supported idempotent JSON responses, including optional managed non-streaming text, required OpenRouter BYOK Responses, Messages, embeddings and rerank, OpenRouter BYOK pre-stream responses, required image, audio, and video submission. Image and audio replay snapshots contain only their small POST job envelopes, never generated media bytes; the audio snapshot also excludes the input text. Rerank snapshots can contain echoed document text. An OpenRouter BYOK SSE record stores no chunks or transcript. The replay record stores neither the raw idempotency key nor the raw request body; only SHA-256 hashes are retained, including a canonical request-body hash for conflict detection. Never retry or reuse an `Idempotency-Key` after the 24-hour replay window: after record cleanup it can be accepted as a new paid provider call. Otherwise, generate a fresh key only for a genuinely new intended request; the narrow exception is an explicit `idempotency_abandoned` result as described above. Always select a current model from a catalog endpoint. The catalogs fail closed when price data is stale. Respect HTTP 402 budget/balance errors, HTTP 429 with Retry-After, and the request ID returned in response headers. After an unsuccessful image or video submission, reserved funds are returned only when Zapros confirms that the provider did not charge for it. ## Management API Use a scoped manual `zpm_` bearer token, or complete OAuth authorization with the exact resource `https://zapros.ai/api/v1/management` and use the resulting `zpo_` token. Management OAuth is a separate grant from MCP OAuth, even for the same client: - GET `/api/v1/management/account` - GET `/api/v1/management/models?kind=all&limit=50` - GET `/api/v1/management/models/endpoints?model={model}&limit=50` - POST `/api/v1/management/cost-estimates` - GET `/api/v1/management/projects?limit=50` - POST `/api/v1/management/projects/default` - GET/POST `/api/v1/management/keys` - PATCH/DELETE `/api/v1/management/keys/{id}` - GET `/api/v1/management/usage?days=30` - GET `/api/v1/management/usage?days=30&project_id={project_id}` (optional narrowing filter) - GET `/api/v1/management/compute/offers` - GET `/api/v1/management/compute/instances` The management `GET /models/endpoints` operation requires `models:read` and returns the same bounded discovery projection as the inference-key per-model URL advertised by `provider_endpoints_url`. Discovery performs a cached metadata lookup for one active OpenRouter chat model but no inference, reservation, or charge. It exposes only fresh bounded capabilities, never raw upstream prices, retention guarantees, internal credentials/routing state, or an SLA. A returned base `provider_slug` may be used in `provider.only`, `provider.ignore`, or `provider.order`, and its `quantization` value may be used in `provider.quantizations`; these preferences affect a later OpenRouter request but do not guarantee that the endpoint will still be available. Endpoint and paid-tier suffixes remain disabled. `GET /models` and `POST /cost-estimates` require `models:read`; an estimate reads current catalog pricing and never calls a provider, reserves balance, or charges the account. Before key management or project-filtered usage, call `GET /projects` with any key-management scope or `usage:read`. If it returns an empty page, only `POST /projects/default` under `keys:create` may idempotently create or repair the personal organization, workspace, wallet, and default project; `usage:read` alone is read-only. Every key list/create/update/revoke operation requires an explicit `project_id` (query for list/revoke, body for create/update). On `GET /usage`, `project_id` is optional and only narrows the caller's existing boundary: a manual `zpm_` token remains limited to usage owned by its authenticated account, and a Management OAuth token remains limited to keys created by that exact grant. The filter never adds usage from other project members, accounts, or grants. `POST /api/v1/management/keys` also requires a stable 8–128 character `Idempotency-Key`, an explicit monthly budget, a per-request limit, and a non-empty allowed-model list. A direct `zpm_` REST creation receives the new `zpr_` secret once while it remains available; the 24-hour idempotency record prevents duplicate creation but cannot recover a secret erased by claim acknowledgement or expiry. A Management OAuth caller receives only an owner-authenticated dashboard claim and can list, update, revoke, and read usage only for keys created by that exact grant. Mutations use the separate `keys:create`, `keys:update`, and `keys:revoke` scopes and are audited. Compute endpoints are discovery-only until hosting is enabled; do not infer that an empty offer list is an error. ## MCP Zapros MCP is a stateless JSON-RPC 2.0 endpoint. It supports MCP `2026-07-28` and compatibility with `2025-11-25` and `2025-06-18`. It uses POST only; it does not expose an SSE GET stream or protocol sessions. Preferred onboarding is Agent Connect OAuth. Client-specific instructions are at `https://zapros.ai/connect`. Point the MCP client at `https://zapros.ai/mcp`; the unauthenticated challenge identifies RFC 9728 protected-resource metadata, which links to RFC 8414 authorization-server metadata. Public clients use authorization code with S256 PKCE, an exact registered redirect URI, and `resource=https://zapros.ai/mcp`. Client secrets are not accepted. Client ID Metadata Documents and bounded dynamic public-client registration are supported for client compatibility. The returned `zpo_` access token is short-lived; refresh tokens rotate on every exchange, and reuse revokes the whole grant. The consent screen binds the grant to aggregate limits: total monthly budget across all active keys created by the connection, per-request maximum, model allowlist, maximum active-key count, and grant expiry. An OAuth connection may list, update, or revoke only keys created by that same connection. Users can inspect and revoke connected applications under Dashboard → Agents & MCP; revocation invalidates tokens and disables the connection's active keys. Manual MCP access remains supported. For that mode create a scoped `zpm_` token in the dashboard and configure `Authorization: Bearer zpm_...` explicitly. A manual token remains account-scoped and is a different trust model from a consent-bounded OAuth connection. For MCP 2026-07-28 every request must include: - `Content-Type: application/json` - `Accept: application/json, text/event-stream` - `Authorization: Bearer zpo_...` for OAuth, or `Bearer zpm_...` for manual setup - `MCP-Protocol-Version: 2026-07-28` - `Mcp-Method` exactly matching the JSON-RPC body method - `Mcp-Name` exactly matching `params.name` for `tools/call` - `params._meta["io.modelcontextprotocol/protocolVersion"]` equal to `2026-07-28` Encode an unsafe or non-ASCII `Mcp-Name` as `=?base64?{canonical-base64-utf8}?=`. Browser requests are accepted only from `https://zapros.ai`, `https://www.zapros.ai`, or an explicitly configured origin; native MCP clients normally omit `Origin`. Begin modern discovery with `server/discover`. Available methods are `ping`, `tools/list`, and `tools/call`. Available tools are `get_account`, `list_projects`, `ensure_default_project`, `list_models`, `list_model_endpoints`, `estimate_cost`, `list_api_keys`, `create_api_key`, `update_api_key`, `revoke_api_key`, `get_usage`, `list_compute_offers`, and `list_compute_instances`. `list_model_endpoints` is an open-world metadata lookup under `models:read`; it does not run or authorize inference, while each returned base `provider_slug` is valid input for `provider.only`, `provider.ignore`, or `provider.order`, and its `quantization` is valid input for `provider.quantizations` on a separately authenticated OpenRouter-backed request. `list_projects` is available with any key-management scope or `usage:read`; `ensure_default_project` requires `keys:create` and is idempotent. Read the returned project object's `id` field and pass that value as `project_id` to every key tool or optionally to `get_usage`. The usage filter only narrows the same account or exact OAuth-grant boundary described above. Tool availability is filtered by token scope. The modern params._meta object must also include io.modelcontextprotocol/clientCapabilities as an object (it may be empty). JSON-RPC request IDs must be strings or safe integers; omit the ID for notifications and never send explicit null. A successful create_api_key result contains only `secret_delivery.method=dashboard_claim`, a claim URL, and its expiry—never the raw `zpr_` secret. Grant only the narrow key mutation scopes the client needs. Example discovery body: ```json { "jsonrpc": "2.0", "id": 1, "method": "server/discover", "params": { "_meta": { "io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientInfo": { "name": "my-agent", "version": "1.0.0" }, "io.modelcontextprotocol/clientCapabilities": {} } } } ``` MCP tool results include both `structuredContent` and a text JSON fallback. The MCP server deliberately excludes payments, balance top-ups, management-token creation, and compute mutations.