API Reference

NoPII exposes drop-in proxy endpoints for OpenAI and Anthropic. The request and response formats are identical to the upstream providers - NoPII only modifies message content to tokenize and detokenize PII.

Base URL: https://api.nopii.co

Providers: OpenAI, Anthropic, xAI, DeepSeek, Mistral, Gemini, Groq, Together, Fireworks. All OpenAI-compatible providers use /chat/completions. See Supported Providers for details.

Authentication

NoPII uses drop-in authentication - it identifies your account by the LLM API key already present in the request. No NoPII-specific API keys or headers are needed.

ProviderHeaderFormat
OpenAIAuthorizationBearer sk-...
Anthropicx-api-key or Authorizationsk-ant-... or Bearer sk-ant-...

Your API key must be registered in the admin console before use. The key is passed through to the LLM provider - NoPII never stores it.

OpenAI Chat Completions

POST /chat/completions

Proxies to the OpenAI Chat Completions API with automatic PII tokenization.

Also served at /v1/chat/completions and under the prefixes OpenAI-compatible providers use, /openai/v1 (Groq), /inference/v1 (Fireworks) and /v1beta/openai (Gemini), so swapping only the host of a provider URL lands on this endpoint. The same applies to /responses. The provider the request goes to is chosen from your API key, never from the path.

Headers

HeaderRequiredDescription
AuthorizationYesBearer token - your OpenAI API key
Content-TypeYesapplication/json
X-NoPII-Session-IdNoSession ID for token cache continuity
traceparentNoW3C Trace Context header for distributed tracing

Request body

Standard OpenAI Chat Completions request. The messages[].content field is sanitized before forwarding. Supports "stream": true.

Example

bash
curl -X POST https://api.nopii.co/chat/completions \
  -H "Authorization: Bearer sk-your-openai-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Summarize the case for John Smith, SSN 123-45-6789"}
    ]
  }'

Response

Standard OpenAI response format. Assistant message content is detokenized (tokens replaced with original PII). Includes X-NoPII-Session-Id response header.

OpenAI Embeddings

POST /embeddings

Proxies to the OpenAI Embeddings API. Every text in input (a string or a list of strings) is tokenized before it reaches the provider, so indexing pipelines embed tokens in place of PII. The vectors come back exactly as the provider returned them: there is nothing in them to detokenize, and no reference-code preamble is added, so the provider's prompt_tokens are all your own.

Also served at /v1/embeddings and under the same provider prefixes as /chat/completions. The same headers apply, and X-NoPII-Mode: tokens-only works as it does there. Because tokens are deterministic, the same name or email becomes the same token in every document and every query, so similarity search still finds documents that mention the same person.

Matching names by similarity. A token carries nothing of the value it replaces, so vectors of tokenized text say nothing about how alike two names are. Two different people score high (every token has the same shape) and "Jane Doe" and "Jane A. Doe" score low (different tokens). Equal tokens mean an identical value; that is the only comparison they support. Do not auto-merge records on a similarity score between tokenized names. For deduplication, match names on your side before they reach the proxy, with a string matcher and an alias table. Keep embeddings through NoPII for search over documents that mention people, where a name works as a consistent keyword.

Example

bash
curl -X POST https://api.nopii.co/embeddings \
-H "Authorization: Bearer sk-your-openai-key" \
-H "Content-Type: application/json" \
-d '{
  "model": "text-embedding-3-small",
  "input": ["Case notes for John Smith, john@example.com", "Follow-up scheduled"]
}'

Response

Standard OpenAI embeddings response, unchanged. Includes the X-NoPII-Session-Id and X-NoPII-Entity-Count response headers.

Limits

  • input must be text. A token-id array cannot be checked for PII and is refused with a 400 and X-NoPII-Error-Code: embeddings_input_unsupported.
  • Available for keys registered with OpenAI, Mistral, Together, Fireworks and Gemini, whose APIs serve an embeddings endpoint. A key for another provider gets a 404 with X-NoPII-Error-Code: embeddings_unsupported.

Anthropic Messages

POST /v1/messages

Proxies to the Anthropic Messages API with automatic PII tokenization.

Headers

HeaderRequiredDescription
x-api-key or AuthorizationYesYour Anthropic API key, as x-api-key: sk-ant-... or Authorization: Bearer sk-ant-... (Anthropic's Python SDK 2.x sends the Bearer form). If both are sent, x-api-key is used.
anthropic-versionNoDefaults to 2023-06-01 - passed through
Content-TypeYesapplication/json
X-NoPII-Session-IdNoSession ID for token cache continuity
traceparentNoW3C Trace Context header for distributed tracing

Request body

Standard Anthropic Messages request. Both the system field (string or content block array) and messages[].content are sanitized. Supports "stream": true.

Example

bash
curl -X POST https://api.nopii.co/v1/messages \
  -H "x-api-key: sk-ant-your-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Draft a letter for Jane Doe at 123 Main St"}
    ]
  }'

Response

Standard Anthropic response format. Text content blocks are detokenized. Includes X-NoPII-Session-Id response header.

Health checks

GET /healthz

Liveness probe. Returns {"status": "ok"}

GET /readyz

Readiness probe. Returns {"status": "ready"}

Debug mode

Debug mode can be enabled per tenant in the admin console. When enabled, NoPII logs the full sanitized request body and raw LLM response body for each proxy call. These are visible in the request log detail view.

Debug mode is intended for troubleshooting only. Disable it in production to avoid logging overhead.

Related