Skip to content
Sign in Create account

Embedding generation (relayed to the upstream provider)

POST /api/v1/embeddings

The request is relayed to the upstream provider you select; the gateway runs no local embedding model. Supported clients should attempt best-effort detection and tokenization on-device before sending. The gateway receives and relays request bytes but does not inspect body content for personal data or verify that detection ran.

Authenticate with an API key.

Parameters

  • X-CloakAPI-Privacy-Tier PrivacyMode header

    Which substitution style your client applies to sensitive values before the request leaves your user's device. Per-call; never persisted.

    Both modes protect the same data — a mode selects style only and can never switch protection off. Both cost something, so choose knowing which:

    • balanced (default) — Realistic stand-ins: John Mellows becomes Henry Caulinger. Cost: the model cannot tell the stand-ins are fake, so it may reason about them as if they were real — drawing conclusions from a substituted name, or treating a substituted address as a genuine place.
    • max — Opaque placeholders: John Mellows becomes <<CLOAK:PERSON:5e4120>>. Cost: the model can see the value is hidden, so it may write awkwardly around the placeholder, ask you for the real value, or decline to continue.

    Either way, the same detail always maps to the same replacement for the whole conversation, and the real values are restored in the reply on your device. You do not need to ask for that and cannot turn it off.

    An unrecognized value is rejected with 400 invalid_privacy_mode rather than reinterpreted — a header is code you just wrote, and silently resolving a typo is how an integration ships believing a privacy setting works. off and continuity were retired on 2026-07-28: there is no unprotected posture, and cross-turn stability is now unconditional.

  • X-Cloak-Engine-Version string header

    Client-declared version of the on-device CloakAPI tokenizer associated with this request. The gateway checks it against the minimum (currently 1.6.0) and answers 426 when lower; this does not prove that version ran. Leave it out, together with X-Cloak-Engine-Hash, only on a declared rules-only send (see X-CloakAPI-Tokenized); any other request without it is answered 428 engine_identity_required.

    Example: "1.6.0"
  • X-Cloak-Engine-Hash string header

    Client-declared SHA-256 of the engine binary claimed for this request. The gateway checks whether the hash is on its published allowlist and answers 403 engine_untrusted when missing or unknown; this does not prove that binary ran. Leave it out, together with X-Cloak-Engine-Version, only on a declared rules-only send.

  • X-CloakAPI-Tokenized string header

    Client-declared detection coverage, written true;coverage=full, true;coverage=rules_and_names or true;coverage=rules_only. A client that ran rule-based detection without an engine sends exactly true;coverage=rules_only, sends neither X-Cloak-Engine-Version nor X-Cloak-Engine-Hash, and still sends X-Cloak-Pretokenised and X-Cloak-Client-MAC. The gateway then relays the request without an engine identity, answers with the response header X-Cloak-Coverage set to rules_only, and signs a receipt that records x-cloakapi-detection with engine_identity set to not_declared and genuine_engine set to false. If an engine version or hash is sent, the engine checks apply whatever coverage is declared. The gateway does not read the body and does not verify the declared coverage.

    Example: "true;coverage=rules_only"
  • X-Cloak-Pretokenised string header required

    Client assertion that the request body was tokenized on-device. The gateway requires this header and verifies the tenant-bound MAC, but cannot verify that detection ran. Missing header answers 428 pretokenised_required.

    One of: "1"
  • X-Cloak-Client-MAC string header required

    MAC over the exact request body, obtained from POST /api/v1/pretokenised/mac. Missing or wrong answers 403 pretokenised_mac_invalid.

Request body

application/json EmbeddingsRequest

  • attachments array of object

    Client-reviewed attachment text entries.

    Each item:

    • text string
  • clipboard string

    Optional client-reviewed clipboard text.

  • dimensions integer
    Range: at least 1
  • encoding_format string
    One of: "float", "base64". Default: "float"
  • frequency_penalty number
    Range: -2 to 2
  • input any required

    Integer token IDs only. The TypeScript request-body slot list has no reviewed text channel for raw embeddings input.

    One of

    • array of integer
    • array of array of integer
  • max_completion_tokens integer
    Range: 1 to 200000
  • max_tokens integer
  • messages array of object

    Only allowlisted message keys are accepted. annotations, audio metadata, url_citation, and other unknown message keys are rejected with 422 because they may contain text the client has not reviewed. Content parts also reject unknown keys and unsupported types. This gateway input subset is not measured against the upstream provider.

    Each item:

    • cache_control object
      • ttl string
        One of: "5m", "1h"
      • type string required
        One of: "ephemeral"
    • content any required

      One of

      • string
      • array of any

        Each item:

        One of

        • object
        • object
        • object
        • object
    • metadata object

      messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.

    • role string required
      One of: "system", "developer", "user", "assistant"
    • tool_call_id any
    • tool_calls array of object

      Each item:

      • function object required
        • arguments string required
        • name string
      • id string
      • type string
        One of: "function"
  • metadata object

    messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.

  • model string required
    Length: at most 64 characters. Pattern: ^(?!.*//)(?!.*(?:^|/)\.{1,2}(?:/|$))(?!.*\/$)[A-Za-z0-9][A-Za-z0-9._:/@~+-]{0,63}(?![\s\S])
  • n integer
    Range: 1 to 128
  • preprompt string

    Optional client-reviewed prompt prefix.

  • presence_penalty number
    Range: -2 to 2
  • provider string

    Provider identifier used for routing. Other values receive 422; inactive or unavailable providers receive 403.

    One of: "openai", "anthropic", "google", "azure", "grok", "openrouter", "gemini", "deepseek", "perplexity", "mistral", "cohere", "groq", "together", "fireworks"
  • reasoning_effort string

    Reasoning effort hint.

    One of: "none", "minimal", "low", "medium", "high", "xhigh", "max"
  • seed integer
    Range: 0 to 2147483647
  • stop any

    Operator configuration, not user text. One string or up to four strings, each at most 32 characters.

    One of

    • string
    • array of string
  • stream boolean
  • system any

    One of

    • string
    • array of object

      Each item:

      • cache_control object
        • ttl string
          One of: "5m", "1h"
        • type string required
          One of: "ephemeral"
      • text string required
      • type string required
        One of: "text"
  • temperature number
  • tool_choice any

    One of

    • string
    • object
      • function object required
        • name string required
      • type string required
        One of: "function"
  • tools array of object

    Each item:

    • function object
    • type string
      One of: "function"
  • top_p number
    Range: 0 to 1
  • user string

    Optional short identifier only. Arbitrary user strings are not supported yet and receive 422.

    Pattern: ^[A-Za-z0-9_.:-]{1,64}$

Generated sample

{
  "attachments": [
    {
      "text": "string"
    }
  ],
  "clipboard": "string",
  "dimensions": 1,
  "encoding_format": "float",
  "frequency_penalty": -2,
  "input": [
    0
  ],
  "max_completion_tokens": 1,
  "max_tokens": 0,
  "messages": [
    {
      "cache_control": {
        "ttl": "5m",
        "type": "ephemeral"
      },
      "content": "string",
      "metadata": {},
      "role": "system",
      "tool_call_id": null,
      "tool_calls": [
        {
          "function": {
            "arguments": "string",
            "name": "string"
          },
          "id": "string",
          "type": "function"
        }
      ]
    }
  ],
  "metadata": {},
  "model": "string",
  "n": 1,
  "preprompt": "string",
  "presence_penalty": -2,
  "provider": "openai",
  "reasoning_effort": "none",
  "seed": 0,
  "stop": "string",
  "stream": true,
  "system": "string",
  "temperature": 0,
  "tool_choice": "auto",
  "tools": [
    {
      "function": {
        "description": "string",
        "name": "string",
        "parameters": {
          "$defs": {},
          "$ref": "string",
          "additionalProperties": {},
          "allOf": [
            {}
          ],
          "anyOf": [
            {}
          ],
          "definitions": {},
          "description": "string",
          "examples": [
            "string"
          ],
          "exclusiveMaximum": 0,
          "exclusiveMinimum": 0,
          "format": "date-time",
          "items": {},
          "maxItems": 0,
          "maxLength": 0,
          "maxProperties": 0,
          "maximum": 0,
          "minItems": 0,
          "minLength": 0,
          "minProperties": 0,
          "minimum": 0,
          "multipleOf": 0,
          "not": {},
          "nullable": true,
          "oneOf": [
            {}
          ],
          "properties": {},
          "required": [
            "string"
          ],
          "title": "string",
          "type": "object",
          "uniqueItems": true
        }
      },
      "type": "function"
    }
  ],
  "top_p": 0,
  "user": "string"
}

Responses

200 Embeddings

application/json EmbeddingsResponse

  • data array of object

    Each item:

    • embedding array of number
    • index integer
    • object string
  • model string
  • object string
    Example: "list"
  • usage object
    • prompt_tokens integer
    • total_tokens integer

Generated sample

{
  "data": [
    {
      "embedding": [
        0
      ],
      "index": 0,
      "object": "string"
    }
  ],
  "model": "string",
  "object": "list",
  "usage": {
    "prompt_tokens": 0,
    "total_tokens": 0
  }
}
400 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

401 Missing or invalid CloakAPI API key.

application/json object

Any keys are accepted.

402 Insufficient balance

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

403 Engine not recognized (engine_untrusted) or client MAC missing/invalid (pretokenised_mac_invalid).

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

409 The Idempotency-Key cannot be used for this request because it conflicts with another request (idempotency_key_conflict), is still in progress (idempotency_request_in_progress), or its response was not retained (idempotency_response_not_retained).

application/json IdempotencyError

  • error object required
    • code string required
      One of: "idempotency_key_conflict", "idempotency_request_in_progress", "idempotency_response_not_retained"
    • message string required
    • type string required
      Value: "idempotency_error"
410 The requested model is no longer available or is not a valid model ID for the selected provider.

application/json object

  • error object required
    • code string required
      One of: "model_retired", "model_unavailable"
    • message string required
    • param string required
      Value: "model"
    • type string required
      Value: "invalid_request_error"
    • suggested_model SuggestedModelId
413 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

415 Request body must use Content-Type: application/json (unsupported_media_type).

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

422 An unrecognized message key can result in HTTP 422 with error.code=untokenisable_content_part.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

426 Engine version below the minimum (min_engine_version in the body).

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

428 Either no engine identity was declared: X-Cloak-Engine-Version is missing and the request is not a declared rules-only send (engine_identity_required; the body carries min_engine_version and upgrade_url). Or the required client pre-tokenization assertion was missing (pretokenised_required). Response header X-Cloak-Pretokenised-Required: 1.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

429 Rate limit exceeded

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

text/html string

500 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

502 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

503 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.