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-TierPrivacyMode headerWhich 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 MellowsbecomesHenry 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 Mellowsbecomes<<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_moderather than reinterpreted — a header is code you just wrote, and silently resolving a typo is how an integration ships believing a privacy setting works.offandcontinuitywere retired on 2026-07-28: there is no unprotected posture, and cross-turn stability is now unconditional.X-Cloak-Engine-Versionstring headerClient-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 (seeX-CloakAPI-Tokenized); any other request without it is answered 428engine_identity_required.Example:"1.6.0"X-Cloak-Engine-Hashstring headerClient-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_untrustedwhen missing or unknown; this does not prove that binary ran. Leave it out, together withX-Cloak-Engine-Version, only on a declared rules-only send.X-CloakAPI-Tokenizedstring headerClient-declared detection coverage, written
true;coverage=full,true;coverage=rules_and_namesortrue;coverage=rules_only. A client that ran rule-based detection without an engine sends exactlytrue;coverage=rules_only, sends neitherX-Cloak-Engine-VersionnorX-Cloak-Engine-Hash, and still sendsX-Cloak-PretokenisedandX-Cloak-Client-MAC. The gateway then relays the request without an engine identity, answers with the response headerX-Cloak-Coverageset torules_only, and signs a receipt that recordsx-cloakapi-detectionwithengine_identityset tonot_declaredandgenuine_engineset 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-Pretokenisedstring header requiredClient 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-MACstring header requiredMAC over the exact request body, obtained from
POST /api/v1/pretokenised/mac. Missing or wrong answers 403pretokenised_mac_invalid.
Request body
application/json EmbeddingsRequest
attachmentsarray of objectClient-reviewed attachment text entries.
Each item:
textstring
clipboardstringOptional client-reviewed clipboard text.
dimensionsintegerRange: at least 1encoding_formatstringOne of:"float","base64". Default:"float"frequency_penaltynumberRange: -2 to 2inputany requiredInteger 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_tokensintegerRange: 1 to 200000max_tokensintegermessagesarray of objectOnly 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_controlobjectttlstringOne of:"5m","1h"typestring requiredOne of:"ephemeral"
contentany requiredOne of
- string
- array of any
Each item:
One of
- object
- object
- object
- object
metadataobjectmessages[*].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.
rolestring requiredOne of:"system","developer","user","assistant"tool_call_idanytool_callsarray of objectEach item:
functionobject requiredargumentsstring requirednamestring
idstringtypestringOne of:"function"
metadataobjectmessages[*].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.
modelstring requiredLength: at most 64 characters. Pattern:^(?!.*//)(?!.*(?:^|/)\.{1,2}(?:/|$))(?!.*\/$)[A-Za-z0-9][A-Za-z0-9._:/@~+-]{0,63}(?![\s\S])nintegerRange: 1 to 128prepromptstringOptional client-reviewed prompt prefix.
presence_penaltynumberRange: -2 to 2providerstringProvider 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_effortstringReasoning effort hint.
One of:"none","minimal","low","medium","high","xhigh","max"seedintegerRange: 0 to 2147483647stopanyOperator configuration, not user text. One string or up to four strings, each at most 32 characters.
One of
- string
- array of string
streambooleansystemanyOne of
- string
- array of object
Each item:
cache_controlobjectttlstringOne of:"5m","1h"typestring requiredOne of:"ephemeral"
textstring requiredtypestring requiredOne of:"text"
temperaturenumbertool_choiceanyOne of
- string
- object
functionobject requirednamestring required
typestring requiredOne of:"function"
toolsarray of objectEach item:
functionobjectdescriptionstring requirednamestringparametersReviewedToolJsonSchema
typestringOne of:"function"
top_pnumberRange: 0 to 1userstringOptional 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
dataarray of objectEach item:
embeddingarray of numberindexintegerobjectstring
modelstringobjectstringExample:"list"usageobjectprompt_tokensintegertotal_tokensinteger
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
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
401 Missing or invalid CloakAPI API key.
application/json object
Any keys are accepted.
402 Insufficient balance
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
403 Engine not recognized (engine_untrusted) or client MAC missing/invalid (pretokenised_mac_invalid).
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny 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
errorobject requiredcodestring requiredOne of:"idempotency_key_conflict","idempotency_request_in_progress","idempotency_response_not_retained"messagestring requiredtypestring requiredValue:"idempotency_error"
410 The requested model is no longer available or is not a valid model ID for the selected provider.
application/json object
errorobject requiredcodestring requiredOne of:"model_retired","model_unavailable"messagestring requiredparamstring requiredValue:"model"typestring requiredValue:"invalid_request_error"suggested_modelSuggestedModelId
413 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
415 Request body must use Content-Type: application/json (unsupported_media_type).
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
422 An unrecognized message key can result in HTTP 422 with error.code=untokenisable_content_part.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
426 Engine version below the minimum (min_engine_version in the body).
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny 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
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
429 Rate limit exceeded
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
text/html string
500 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
502 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
503 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.