# Veil: setup guide for coding agents This file is everything needed to connect a program or a coding agent to Veil. It is self-contained. The same content for people is at https://veil.st/docs. ## What this service is Veil is a proxy in front of uncensored and abliterated open-weight language models. It speaks two API formats: OpenAI chat completions and Anthropic messages. An account is one key. There is no name, email or password. Balance is prepaid and topped up with Monero. Prompts and replies are not stored or logged. ## Facts at a glance - OpenAI-compatible base URL: `https://veil.st/v1` - Anthropic SDK base URL: `https://veil.st` (the SDK adds `/v1/messages` itself) - Auth header: `Authorization: Bearer ` or `x-api-key: ` - Key format: `ak_` followed by 40 lowercase hex characters - Default model for examples: `deepseek-v4.1-flash-1017-abliterated` - Endpoints: `POST /v1/chat/completions`, `POST /v1/messages`, `GET /v1/models` - Account endpoints: `POST /api/signup`, `POST /api/session`, `GET /api/account`, `POST /api/topups`, `GET /api/topups/{id}` ## Step 1: get a key If the user already has a key, ask them for it and skip this step. Never invent a key. Store it in an environment variable or a secret store, not in source code. A person can get a key at https://veil.st/signup. There is no form: the page shows the key once and asks for it to be pasted back. An agent that can make HTTP requests can do the same in two calls. No browser is needed: ```bash # 1. Create the account. The key is returned once and cannot be shown again. curl -X POST https://veil.st/api/signup # {"key":"ak_<40 hex characters>"} # 2. Activate it by sending the key back. Do this within one hour. curl -X POST https://veil.st/api/session \ -H "Content-Type: application/json" \ -d '{"key":"ak_..."}' # {"ok":true} ``` Rules: - `POST /api/signup` takes no body and returns `{"key":"..."}`. The key is shown this one time. The server keeps only a hash, so it cannot be shown again or recovered. - The account is pending until `POST /api/session` is called with `{"key":"..."}`. That call activates it and returns `{"ok":true}`. It also sets a browser session cookie, which API clients can ignore. - A pending key gets `403 account_inactive` from the model endpoints. A pending account that is not activated within one hour is deleted. - Signup is limited across the whole service. On 429, wait one minute. - Give the key to the user and tell them to save it. If it is lost, the account and its balance are gone. Anyone who has the key can spend the balance. ## Step 2: add balance A new account has a zero balance, and model requests return `402 insufficient_balance` until it is topped up. A human must send the Monero payment. An agent can create the invoice and watch it: ```bash # Create an invoice for 10 US dollars of credit. curl -X POST https://veil.st/api/topups \ -H "Authorization: Bearer ak_..." \ -H "Content-Type: application/json" \ -d '{"usd": 10}' # Check it later, using the id from the reply. curl https://veil.st/api/topups/123 \ -H "Authorization: Bearer ak_..." ``` Invoice reply: ```json { "id": 123, "usd": 10, "amount_xmr": "0.061728395062", "address": "", "uri": "monero:?tx_amount=0.061728395062", "status": "pending", "confirmations": 0, "confirmations_needed": 10, "created_at": "2026-01-01T12:00:00.000Z", "expires_at": "2026-01-01T13:00:00.000Z", "qr_svg": "" } ``` - Show the user `address` and `amount_xmr`, or the `uri`. They should send `amount_xmr`. The amount is how the payment is matched to the account. Rounding inside 0.3% is accepted, and a short payment credits what arrives and leaves the invoice open for the rest. - `status` moves from `pending` to `confirming` when the payment is seen, then to `paid` after `confirmations_needed` confirmations. Then the balance grows by the `usd` amount. - An unpaid invoice expires at `expires_at`. An account can hold up to five unpaid invoices. - An amount outside the allowed range returns 400 with a message that states the minimum and maximum. - The same flow is available to a person at https://veil.st/dashboard. ## Step 3: configure the client ### OpenAI SDK, Python ```python from openai import OpenAI client = OpenAI( base_url="https://veil.st/v1", api_key="ak_...", ) reply = client.chat.completions.create( model="deepseek-v4.1-flash-1017-abliterated", messages=[{"role": "user", "content": "Say hello in five words."}], max_tokens=200, ) print(reply.choices[0].message.content) ``` ### OpenAI SDK, Node ```javascript import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://veil.st/v1", apiKey: "ak_...", }); const reply = await client.chat.completions.create({ model: "deepseek-v4.1-flash-1017-abliterated", messages: [{ role: "user", content: "Say hello in five words." }], max_tokens: 200, }); console.log(reply.choices[0].message.content); ``` ### Anthropic SDK, Python ```python import anthropic client = anthropic.Anthropic( base_url="https://veil.st", api_key="ak_...", ) message = client.messages.create( model="deepseek-v4.1-flash-1017-abliterated", max_tokens=200, messages=[{"role": "user", "content": "Say hello in five words."}], ) print(message.content[0].text) ``` ### Anthropic SDK, Node ```javascript import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ baseURL: "https://veil.st", apiKey: "ak_...", }); const message = await client.messages.create({ model: "deepseek-v4.1-flash-1017-abliterated", max_tokens: 200, messages: [{ role: "user", content: "Say hello in five words." }], }); console.log(message.content[0].text); ``` ### Environment variables The OpenAI SDKs read these: ```bash OPENAI_BASE_URL=https://veil.st/v1 OPENAI_API_KEY=ak_... ``` The Anthropic SDKs read these: ```bash ANTHROPIC_BASE_URL=https://veil.st ANTHROPIC_API_KEY=ak_... ``` ### Any tool with an "OpenAI-compatible" provider setting Fill the fields like this. Field names vary by tool. - Base URL (also called API base, endpoint or host): `https://veil.st/v1` - API key: the account key, `ak_...` - Model (also called model id or model name): `deepseek-v4.1-flash-1017-abliterated` - API type, if asked: OpenAI chat completions. Not the responses API, not legacy completions, not embeddings. - Organization or project: leave empty. If the tool appends `/chat/completions` to the base URL, the base URL must end in `/v1`. If it asks for the full endpoint URL, use `https://veil.st/v1/chat/completions`. ### No SDK ```javascript const res = await fetch("https://veil.st/v1/chat/completions", { method: "POST", headers: { Authorization: "Bearer ak_...", "Content-Type": "application/json", }, body: JSON.stringify({ model: "deepseek-v4.1-flash-1017-abliterated", messages: [{ role: "user", content: "Say hello in five words." }], max_tokens: 200, }), }); const data = await res.json(); console.log(data.choices[0].message.content); ``` ## Endpoint: POST /v1/chat/completions OpenAI chat completions format. Every model is available here. Request: ```bash curl https://veil.st/v1/chat/completions \ -H "Authorization: Bearer ak_..." \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-v4.1-flash-1017-abliterated", "messages": [{"role": "user", "content": "Say hello in five words."}], "max_tokens": 200 }' ``` Response, status 200: ```json { "id": "chatcmpl-...", "object": "chat.completion", "created": 1767268800, "model": "deepseek-v4.1-flash-1017-abliterated", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello there, how are you?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 14, "completion_tokens": 7, "total_tokens": 21 } } ``` Request fields: - `model` (required): an exact id from the model list. - `messages` (required): a non-empty array in the OpenAI format. - `max_tokens` (optional): defaults to 4096. `max_completion_tokens` is accepted as another name. Values above the model limit are lowered to the limit. - `stream` (optional): see Streaming. - `reasoning_effort` (optional): only the thinking model uses it. See Reasoning. - `tools`, `temperature` and other standard fields are passed to the model unchanged. A parameter the model does not support can come back as a 400. What the service changes: - `max_tokens` is always set and can be lowered when the balance is short. See Billing. - `user` and `metadata` are removed before the request is forwarded. - In the reply, `model` is always the id that was sent. `system_fingerprint` and `provider` are removed. - Images go in `image_url` content parts. A model without vision returns 400 with `This model does not accept images.` The request body may be up to 12 MB, with at most 16 images of at most 4 MB each. More images returns 400; a larger image returns 413. ## Endpoint: POST /v1/messages Anthropic messages format. `max_tokens` is required and must be a number. Request: ```bash curl https://veil.st/v1/messages \ -H "x-api-key: ak_..." \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-v4.1-flash-1017-abliterated", "max_tokens": 200, "messages": [{"role": "user", "content": "Say hello in five words."}] }' ``` Response, status 200: ```json { "id": "msg_...", "type": "message", "role": "assistant", "model": "deepseek-v4.1-flash-1017-abliterated", "content": [{ "type": "text", "text": "Hello there, how are you?" }], "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 14, "output_tokens": 7 } } ``` Notes: - The key may be sent in `x-api-key` (what the SDK does) or as a Bearer token. The `anthropic-version` header is not required. - Some models are served in the chat completions format only. Calling one here returns 400 with `This model is available on /v1/chat/completions only.` Switch that model to `/v1/chat/completions`. - `thinking`, `metadata` and `user` are removed before forwarding. Reasoning is set by the model id and `output_config.effort`. - Errors use the Anthropic envelope with this service's own type strings. See Errors. ## Endpoint: GET /v1/models The live catalog. No key needed. ```bash curl https://veil.st/v1/models ``` Response, status 200 (one entry shown, prices here are placeholders): ```json { "object": "list", "data": [ { "id": "deepseek-v4.1-flash-1017-abliterated:thinking", "object": "model", "owned_by": "DeepSeek", "name": "DeepSeek V4.1 Flash 1017 Abliterated (thinking)", "description": "The same model with reasoning switched on. ...", "variant": "abliterated", "uncensored": true, "context_length": 1000000, "max_output_tokens": 65536, "capabilities": { "vision": true, "tools": true, "reasoning": true }, "reasoning_efforts": ["low", "high", "max"], "default_reasoning_effort": "high", "pricing": { "input_usd_per_mtok": 0.0, "output_usd_per_mtok": 0.0 } } ] } ``` Fields per model: `id`, `object`, `owned_by`, `name`, `description`, `variant` (`abliterated` or `uncensored`), `uncensored`, `context_length`, `max_output_tokens`, `capabilities` (`vision`, `tools`, `reasoning`), `reasoning_efforts`, `default_reasoning_effort`, `pricing` (`input_usd_per_mtok`, `output_usd_per_mtok`, in US dollars per million tokens). ## Models Ids at the time of writing: - `deepseek-v4.1-flash-1017-abliterated` - `deepseek-v4.1-flash-1017-abliterated:thinking` - `glm-5.3-flash-abliterated` - `gemma-4-uncensored` - `glm-4.7-flash-heretic` - `venice-uncensored-1.2` Ids are exact, including the `:thinking` suffix. An unknown id returns `404 model_not_found`. The catalog and prices live in a database and can change, so read `GET /v1/models` for the current list, limits and prices instead of hardcoding them. Prices for people are at https://veil.st/pricing. ## Reasoning - `deepseek-v4.1-flash-1017-abliterated`: reasoning is always off. Any effort value sent is ignored. - `deepseek-v4.1-flash-1017-abliterated:thinking`: reasoning is always on. Effort is `low`, `high` or `max`. The default is `high`. - All other models: no effort control. Effort values are ignored. On `/v1/chat/completions` send `reasoning_effort` (the nested `reasoning.effort` is also read): ```json { "model": "deepseek-v4.1-flash-1017-abliterated:thinking", "reasoning_effort": "max", "max_tokens": 8000, "messages": [{"role": "user", "content": "Prove that the square root of 2 is irrational."}] } ``` On `/v1/messages` send `output_config.effort` (a top-level `reasoning_effort` is also read, and `thinking` is dropped): ```json { "model": "deepseek-v4.1-flash-1017-abliterated:thinking", "output_config": { "effort": "low" }, "max_tokens": 8000, "messages": [{"role": "user", "content": "Prove that the square root of 2 is irrational."}] } ``` - An effort value the model does not list is not an error. The default is used. - Reasoning tokens are billed as output tokens and count against `max_tokens`. Leave room for the answer. - To turn reasoning on or off, change the model id. A parameter cannot do it. ## Streaming Send `"stream": true`. The reply is `text/event-stream`. OpenAI format. Content chunks, then one chunk with an empty `choices` array that carries `usage`, then `data: [DONE]`. `stream_options` is not needed. Skip chunks with no choices when reading deltas. Reasoning text from the thinking model arrives in `delta.reasoning_content` or `delta.reasoning`. ```text data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"deepseek-v4.1-flash-1017-abliterated","choices":[{"index":0,"delta":{"role":"assistant","content":"One"},"finish_reason":null}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"deepseek-v4.1-flash-1017-abliterated","choices":[{"index":0,"delta":{"content":", two"},"finish_reason":null}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"deepseek-v4.1-flash-1017-abliterated","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"deepseek-v4.1-flash-1017-abliterated","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":9,"total_tokens":21}} data: [DONE] ``` Anthropic format. The standard event sequence, ending with `message_stop`: ```text event: message_start data: {"type":"message_start","message":{"id":"msg_...","type":"message","role":"assistant","model":"deepseek-v4.1-flash-1017-abliterated","content":[],"usage":{"input_tokens":12,"output_tokens":0}}} event: content_block_start data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"One, two"}} event: content_block_stop data: {"type":"content_block_stop","index":0} event: message_delta data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":9}} event: message_stop data: {"type":"message_stop"} ``` If the model stops partway, or the stream ends without its normal final event, one last error event is sent and the stream closes. The HTTP status stays 200. The charge covers only what was delivered. OpenAI format: ```text data: {"error":{"message":"The model stopped responding. You were charged only for what was delivered.","type":"upstream_error","param":null,"code":"upstream_error"}} ``` Anthropic format: ```text event: error data: {"type":"error","error":{"type":"overloaded_error","message":"The model stopped responding. You were charged only for what was delivered."}} ``` - Treat a stream that ends without `[DONE]` or `message_stop` as incomplete. The text received so far is valid. - Closing the connection stops the model and bills only the tokens produced up to that point. - Errors before the stream starts (auth, validation, balance, rate limit) are normal JSON responses with a 4xx or 5xx status. Check the status before reading the body as a stream. ## Billing - The balance is prepaid in US dollars. Each model has an input and an output price per million tokens. - Hold: before a request is sent to the model, its worst-case cost is moved out of the balance. That is the estimated input tokens plus `max_tokens` of output (4096 when not sent). - Settle: when the reply ends, the real cost from the reported token usage is charged and the rest of the hold returns to the balance. - If the balance cannot cover the requested `max_tokens`, the request still runs with the output cap lowered to what the balance covers. The reply may end early with a length stop reason. - If the balance cannot cover the input plus a minimal reply of 16 tokens, the request returns `402 insufficient_balance` and nothing is charged. - Requests in progress hold their worst case, so many large parallel requests on a small balance can cause lower caps or 402 until earlier ones settle. Set a sensible `max_tokens`. - If usage is not reported, for example when a stream breaks, the cost is estimated from the text length at one token per three characters. - Requests that fail before any reply (4xx, 502, 503) cost nothing. - Costs are rounded up to a millionth of a dollar. ## Rate limits - Per key. Defaults: 60 requests per minute and 8 concurrent requests. The limits for a key are in the `limits` object of `GET /api/account`. - The per-minute limit uses a fixed window that starts on each clock minute. Concurrency counts requests in progress, streams included. - Over the limit: `429 rate_limit_error` with a `Retry-After` header in seconds. Wait that long, then retry. `Retry-After` is the time to the next minute for the per-minute limit and 1 for the concurrency limit. Requests refused by the per-minute limit still count in the current minute. - Headers `x-ratelimit-limit` and `x-ratelimit-remaining` are on successful replies, on 429 and on errors that happen after the limit check. Responses refused before the limit check (401, 403, 404, 413 and validation 400) do not carry them and do not count. A 402 counts against the minute but carries no rate limit headers. ## Errors On `/v1/chat/completions` (`code` always equals `type`, `param` is always null): ```json { "error": { "message": "Missing or invalid API key.", "type": "invalid_api_key", "param": null, "code": "invalid_api_key" } } ``` On `/v1/messages`: ```json { "type": "error", "error": { "type": "invalid_api_key", "message": "Missing or invalid API key." } } ``` | Status | Type | Meaning | What to do | | --- | --- | --- | --- | | 400 | `invalid_request_error` | The body is not valid JSON, has no model or no messages, lacks max_tokens on /v1/messages, sends images to a model without vision, uses /v1/messages with a model that is chat-completions only, or carries parameters the model host rejected. | Fix the request. Do not retry it unchanged. | | 401 | `invalid_api_key` | The key is missing, malformed or unknown. | Send the full key in the Authorization or x-api-key header. | | 402 | `insufficient_balance` | The balance cannot cover the input plus a minimal reply. | Top up, send a shorter prompt, or wait for requests in progress to finish and release their holds. | | 403 | `account_inactive` | The key was never activated, or the account is suspended. | Activate a new key by signing in with it once. A suspended account cannot be reactivated through the API. | | 404 | `model_not_found` | The model id is not in the catalog. | Use an id from GET /v1/models, spelled exactly. | | 413 | `request_too_large` | The request body is larger than 12 MB. | Send less history or smaller images. | | 429 | `rate_limit_error` | The key reached its requests-per-minute limit or its concurrent request limit. | Wait the number of seconds in the Retry-After header, then retry. | | 502 | `upstream_error` | The model returned a reply that could not be read. Nothing was charged. | Retry. | | 503 | `service_unavailable` | No model host could take the request. Nothing was charged. | Retry after the number of seconds in the Retry-After header. | - Retry 429, 502 and 503, waiting for `Retry-After` when present. A 503 carries `Retry-After` of 5 or 10 seconds. - Do not retry 400, 401, 403, 404 or 413 without changing the request. Retry 402 only after a top-up. - A `403 account_inactive` on a new key means it was not activated. Call `POST /api/session` with the key. - Error messages are written by this service. Raw errors from a model host are never passed through. - The account endpoints under `/api` use a simpler shape: `{"error":"message"}`. ## Privacy facts for your user - Stored per request: time, model id, input and output token counts, cost, whether the count was estimated, and an outcome flag. - Never stored or logged by the application: prompts, replies, system prompts, tool calls, images, IP addresses, user agents. - Prompts are forwarded to the model hosts that run the models, without the caller's headers and without the `user` and `metadata` fields. - The network in front of the service may keep its own connection logs. Use Tor or a VPN when network-level anonymity matters. - Full policy: https://veil.st/privacy. Acceptable use: https://veil.st/aup. ## Checklist to verify the setup 1. List models. Expect status 200 and the model id you plan to use in `data`. ```bash curl https://veil.st/v1/models ``` 2. Send one request. Expect status 200 and text in `choices[0].message.content`. ```bash curl https://veil.st/v1/chat/completions \ -H "Authorization: Bearer ak_..." \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-v4.1-flash-1017-abliterated", "messages": [{"role": "user", "content": "Say hello in five words."}], "max_tokens": 200 }' ``` 3. Check the balance. Expect `status` to be `active` and the request from step 2 in `recent`. `balance_micro` and `cost_micro` are millionths of a dollar. ```bash curl https://veil.st/api/account \ -H "Authorization: Bearer ak_..." ``` ```json { "key_hint": "ak_1a2b…9f0e", "status": "active", "balance_micro": 9987340, "held_micro": 0, "limits": { "requests_per_minute": 60, "concurrent_requests": 8 }, "usage_30d": { "by_model": [ { "model_id": "deepseek-v4.1-flash-1017-abliterated", "requests": 3, "input_tokens": 42, "output_tokens": 21, "cost_micro": 37 } ], "by_day": [{ "day": "2026-01-01", "requests": 3, "cost_micro": 37 }] }, "recent": [ { "created_at": "2026-01-01T12:00:00.000Z", "model_id": "deepseek-v4.1-flash-1017-abliterated", "input_tokens": 14, "output_tokens": 7, "cost_micro": 13, "estimated": false, "outcome": "ok" } ] } ``` If a step fails: - 401 on step 2: the key is wrong or the header is missing. - 403 on step 2: the key was not activated. Run the `POST /api/session` call from step 1 of this guide. - 402 on step 2: the balance is zero or too low. Top up. - 404 on step 2: the model id is misspelled. Copy it from step 1 of this checklist. - An HTML page or a 404 from the SDK: the base URL is wrong. OpenAI clients need the `/v1` suffix. Anthropic SDKs need the URL without it. ## More - Quickstart: https://veil.st/docs - Authentication: https://veil.st/docs/authentication - Chat completions: https://veil.st/docs/chat-completions - Messages: https://veil.st/docs/messages - Models: https://veil.st/docs/models - Reasoning: https://veil.st/docs/reasoning - Streaming: https://veil.st/docs/streaming - Billing: https://veil.st/docs/billing - Rate limits: https://veil.st/docs/rate-limits - Errors: https://veil.st/docs/errors - Privacy notes: https://veil.st/docs/privacy-notes