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.
Get an API key
Section titled “Get an API key”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.
Path 1: the API in your own flow
Section titled “Path 1: the API in your own flow”The direct, shipped way is to wrap your agent call with two API calls: anonymize the content before it leaves, restore the reply afterwards.
# anonymize a log or a file's contentcurl -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 locallycurl -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.
Path 2: the wrapper script
Section titled “Path 2: the wrapper script”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:
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.
Transparent gateway (roadmap)
Section titled “Transparent gateway (roadmap)”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.