Veil
When Veil is on, kenari finds credentials in what you send, replaces each one with a stand-in before the provider sees the request, and puts the real value back in the reply where it is safe. Veil is off by default.
Turn Veil on
Section titled “Turn Veil on”Turn Veil on either for an API key in the dashboard or for a single request with a header.
In the dashboard, open API Keys, open a key’s menu, and switch on Veil: hide secrets. You can also turn on Veil under Advanced settings when creating a new key. Rotating a key keeps its Veil setting, and changing Veil on a kenari login key updates its per-tool keys too.
To control Veil per request, send the x-kenari-veil header:
x-kenari-veil: onturns Veil on for that request.x-kenari-veil: offskips Veil for one request, even when the API key has Veil turned on.- Any other value, an empty value, or sending the header more than once fails with
400andveil_header_invalid.
curl https://kenari.id/v1/chat/completions \ -H "Authorization: Bearer $KENARI_API_KEY" \ -H "Content-Type: application/json" \ -H "x-kenari-veil: on" \ -d '{ "model": "hy4-flash:free", "messages": [ {"role": "user", "content": "Check this config: DATABASE_URL=postgres://app:s3cr3tpass@db.internal/app"} ] }'If you use a tool that cannot send custom headers, turn Veil on for its API key in the dashboard instead.
For Claude Code, set ANTHROPIC_CUSTOM_HEADERS alongside the environment variables on that page:
export ANTHROPIC_CUSTOM_HEADERS="x-kenari-veil: on"You can also add "ANTHROPIC_CUSTOM_HEADERS": "x-kenari-veil: on" to the env block of Claude Code’s settings.json.
What Veil replaces
Section titled “What Veil replaces”Veil uses deterministic rules only, so no model ever reads your secrets to detect them. It scans prompt text, tool inputs and outputs, document text, and metadata for these families:
- Provider and service API keys, including OpenAI, Anthropic, Google, GitHub, GitLab, Slack, Stripe, Midtrans, Xendit and others
- kenari API keys (
kn-...) - Cloud access keys, such as AWS access key IDs and secret access keys
- Private keys in PEM blocks (RSA, EC, OpenSSH and PKCS8)
- JWTs
- Passwords of at least 8 characters in connection strings and URLs, such as
postgres://app:Zr8kq2LmX0pw@hostandhttps://user:Zr8kq2LmX0pw@host Authorization(BearerandBasic) andx-api-keyheaders- Values of at least 8 characters next to names like
password,token,secretorapi_keyin.envfiles, JSON, YAML, assignments and CLI flags
Veil leaves these alone on purpose:
- Presigned URL signatures (
X-Amz-Credential,X-Amz-Signature,X-Goog-Signatureand Azuresig) - Common development defaults, placeholders and variable references (such as
changeme,password,<your-key>,$OPENAI_API_KEYandprocess.env.KEY), as well as git SHAs, UUIDs andsha256:digests - Images, PDFs and binary file bytes, along with image and document source URLs
- Schemas, identifiers and protocol fields (such as tool names, call IDs, JSON schemas,
role,type,modelandtool_choice), except when Veil finds a vendor-prefixed key there, in which case it refuses the request with400andveil_unsupported_field
Veil replaces secrets in unsigned reasoning like any other text. It never changes signed reasoning (a thinking block with a signature), and never puts real values back into any reasoning. If a secret found in the request also sits in signed reasoning from the current turn, the request fails with 400 and veil_signed_reasoning. Signed reasoning from an earlier turn that holds such a secret is left out of the request instead.
Stand-ins
Section titled “Stand-ins”Every replaced secret becomes a stand-in in the form VEIL_<KIND>_<8 characters>, using uppercase letters and digits, for example VEIL_APIKEY_K7M2Q9XA.
The kinds are APIKEY, AWSKEY, PRIVATEKEY, JWT, PASSWORD, DBPASSWORD, TOKEN and SECRET.
The same secret on the same API key always produces the same stand-in across turns, so Prompt caching keeps working. Two different API keys never share stand-ins for the same value. The mapping exists only in memory for that request.
Where real values go back
Section titled “Where real values go back”When the model replies, Veil puts a real value back only if its stand-in came from this request and its destination is trusted.
In a tool call, Veil checks every argument of the call together, so a stand-in in a header is withheld when the same call’s URL points to an untrusted host. In ordinary reply text, Veil checks the logical line holding the stand-in (including lines joined with a trailing \). It reads every URL in that unit, with a scheme (https://, http://, and so on) or as a //host link:
| Where the stand-in appears | Result |
|---|---|
A vendor’s own API host (such as api.stripe.com, api.midtrans.com or api.xendit.co for that vendor’s key) | Real value restored |
| A host you named in your message or system prompt | Real value restored |
A host in the same file or tool output the value came from (such as a BASE_URL in the same .env file) | Real value restored |
A line or argument with no host, or a neutral host like localhost or example.com | Real value restored |
| A link, image or command pointing to any other host | Stand-in stays (withheld) |
A URL Veil cannot read with certainty, such as one with \ or a space before @ in its host part | Stand-in stays (withheld) |
Reasoning always keeps stand-ins. kenari’s own Server tools (web_fetch, web_search and x_search) also run with stand-ins and never receive real values.
Response headers
Section titled “Response headers”When Veil is off, kenari sends no Veil headers. When Veil is on, kenari sends these response headers:
| Header | Meaning |
|---|---|
x-kenari-veil | applied when Veil ran on the request, or not_applied when you sent x-kenari-veil: on to an endpoint Veil does not cover. |
x-kenari-veil-count | Number of distinct secrets replaced in the request. This header can be missing on a slow-starting reply whose headers are sent before the model begins answering. |
x-kenari-veil-withheld | Non-streaming replies only. Number of stand-ins kept because their destination was not trusted. Omitted when zero. |
In a streaming reply, HTTP headers are already sent before the reply finishes, so withheld stand-ins are reported as an SSE comment before the final frame:
: veil-withheld 1Endpoints
Section titled “Endpoints”Veil covers these endpoints:
POST /v1/chat/completions(Chat completions)POST /v1/messages(Messages)POST /v1/responses(Responses)kenari_askon the kenari Connect, which calls/v1/chat/completionswith your key
Veil does not cover these endpoints, and sending x-kenari-veil: on to any uncovered /v1 route returns x-kenari-veil: not_applied:
- Studio and Forge: neither uses an API key.
- Embeddings (
/v1/embeddings): replacing text with stand-ins would change the output vectors. - Rerank (
/v1/rerank): scores each document directly against the query text. - Moderations (
/v1/moderations): evaluates the raw input text against moderation categories. - Media, OCR and file bytes (Images, Text to speech, Transcriptions, Music, Videos, OCR): these process media or raw file bytes rather than chat text.
- System One (
/v1/systemone): evaluates typed state questions with structured answers. - Web and X search (
/v1/web/search,/v1/web/fetch,/v1/x/search): direct search and fetch routes with no chat model. - Claude Managed Agents passthrough: streams raw bytes directly with your own Anthropic key.
Errors
Section titled “Errors”When Veil cannot safely cover a request, it fails closed and sends nothing to the provider. See the six Veil error codes (400 and 500) in Errors.
What kenari learns
Section titled “What kenari learns”Only for requests where Veil runs, kenari records aggregate counts per model and rule, how well models preserve stand-ins intact or alter them, and two kinds of anonymous signals: the shape of an unknown high-entropy token (its prefix pattern, length band and character type) and the domain a withheld stand-in was headed to.
Each signal is kept as a hash and becomes readable only once five different accounts have sent the same one, so a single account’s internal names never become visible. kenari never stores a prompt, a reply or a secret value.
Limits and pitfalls
Section titled “Limits and pitfalls”- Not a reason to paste production secrets. Veil is a safety net, not a substitute for keeping production credentials out of prompts and using scoped test keys.
- Bare hostnames are not recognized. The destination check reads URLs with a scheme such as
https://and//hostlinks. A bare hostname such asevil.example/pathis not treated as a host. - Unusual URL spellings. Veil reads URLs the way browsers, markdown renderers and common HTTP clients read them, including encoded and escaped forms. A deliberately odd spelling aimed at one program’s parser, or a raw HTML link split across lines, may still get through.
- Multi-step chains. Veil stops one-step exfiltration such as a command, link or image to an untrusted host. A multi-step chain, such as writing a secret to a file in one call and uploading that file in a later call, can route around the check because the later call carries no secret for kenari to see.
- One logical line in text. Outside tool calls, the destination check evaluates one logical line at a time (including lines joined with
\). A host on another line does not affect the line holding the stand-in. - Undetected values. Veil relies on deterministic rules. A secret that does not match any rule is sent to the provider as is.
- Non-vendor matches in schemas and IDs. Schemas and identifiers are never rewritten. Vendor-prefixed keys there are refused with
400veil_unsupported_field, while other matches (such as a JWT or a context-based password) inside a schema or ID are sent as is. - Secrets only, not conversation text. Veil protects detected credentials, not general conversation text, customer names or business data.
- Review tool calls and name your hosts. Review tool calls before approving them when secrets are in play, and name the exact hosts a secret is meant for in your prompt or system prompt so Veil knows where restoring it is safe.