Skip to content

Integrate with Claude Code and Codex

The goal is to use a coding agent like Claude Code or Codex normally while sensitive values never reach the model provider. This page shows the paths that work today and the transparent gateway that is on the roadmap.

Create a key in the TokenVeil UI, under Preferences > “API key” tab > Generate an API key. You use it in the X-TV-API-Key header. See the API reference for the full contract.

The direct, shipped way is to wrap your agent call with two API calls: anonymize the content before it leaves, restore the reply afterwards.

Fenêtre de terminal
# anonymize a log or a file's content
curl -s -X POST https://<host>/api/v1/anonymize \
-H "X-TV-API-Key: $TV_KEY" -H "Content-Type: application/json" \
-d '{"text": "..."}'
# -> { "session_id": "TV-...", "anonymized_text": "...", "detected": {...} }
# ... send anonymized_text to Claude Code or Codex, get a reply that still carries the tokens ...
# restore the real values locally
curl -s -X POST https://<host>/api/v1/deanonymize \
-H "X-TV-API-Key: $TV_KEY" -H "Content-Type: application/json" \
-d '{"session_id": "TV-...", "text": "<the agent reply>"}'

The mapping stays encrypted on your instance. The provider only ever sees the tokenized text.

For a scripted local flow, a thin wrapper around the two calls lets a developer run the agent on tokenized content without touching the UI. It reads a log or file, anonymizes it, runs the agent on the tokens, and restores the reply. Configuration is two environment variables:

Fenêtre de terminal
export TOKENVEIL_URL="https://<host>"
export TOKENVEIL_API_KEY="tkv_..."

The one discipline to keep: let the script anonymize the file before the agent reads it, and keep raw content out of the chat, so the agent only ever sees tokens. This is the manual bridge until the transparent gateway below.

The same pattern applies to OpenAI Codex and any OpenAI-compatible client: anonymize the context, run the agent on tokens, restore the reply. Codex reaches the model through a configurable base URL, which is the mechanism the transparent gateway uses.

The fully transparent form, where you point the agent at TokenVeil as its model endpoint (ANTHROPIC_BASE_URL for Claude Code, the OpenAI base URL for Codex) and the entire model-bound context is anonymized on the wire with no wrapper and no manual step, is in development. It is the fail-closed drop-in version of the flows above. See the roadmap and deployment security.