# API Reference Source: https://docs.corvex.cloud/api-reference/openapi Public OpenAI- and Anthropic-compatible endpoints for Corvex Token Factory. Corvex Token Factory exposes OpenAI-compatible inference endpoints, Anthropic-compatible Messages endpoints, a public model catalog, and account-scoped usage reporting. The endpoint schemas below are generated from the public OpenAPI 3.1 specification in this repository. ## Base URL ```text theme={null} https://api.tokenfactory.corvex.cloud ``` OpenAI SDKs normally append `/v1` in their configured base URL. Anthropic SDKs use the host-level URL shown above. ## Authentication Inference and usage requests require a Token Factory API key. Send `Authorization: Bearer sk-corvex-...` to OpenAI-compatible and usage endpoints. Send `x-api-key: sk-corvex-...` to Anthropic-compatible endpoints. `GET /v1/models` and its `/openai/v1/models` alias are public. A valid key is optional on these two list operations. Create and revoke keys in the [Token Factory dashboard](https://tokenfactory.corvex.cloud/app/settings/keys). See [Authentication](/getting-started/authentication) for storage and rotation guidance. ## Endpoint groups > **Chat Completions** > > `POST /v1/chat/completions` supports OpenAI-compatible streaming and > non-streaming chat requests. > **Responses** > > `POST /v1/responses` supports the documented stateless subset of the OpenAI > Responses API. > **Messages** > > `POST /v1/messages` and `POST /v1/messages/count_tokens` provide the > Anthropic-compatible surface used by the Anthropic SDK and Claude Code. > **Models** > > `GET /v1/models` returns the public live catalog, capabilities, limits, and > published rates. > **Legacy text completions** > > `POST /v1/completions` accepts models that advertise text-completion > support. Use Chat Completions for the current catalog. > **Embeddings** > > `POST /v1/embeddings` is defined, but no embedding model is currently > deployed. > **Usage** > > `GET /api/v1/usage` returns usage scoped to the authenticated account. ## Current models Call `GET /v1/models` for the live catalog. Currently available: * `zai-org/GLM-5.3` * `deepseek-ai/DeepSeek-V4-Flash-0731` Use the model ID exactly as returned. The [model catalog](/models/overview) compares context windows, image input, capabilities, and pricing. # Authentication Source: https://docs.corvex.cloud/getting-started/authentication Create, send, and protect a Corvex Token Factory API key. Corvex Token Factory uses virtual API keys with the `sk-corvex-` prefix. A key identifies your account and controls which models and usage limits apply to a request. ## Create an API key Open **Settings → API Keys** in the [Token Factory dashboard](https://tokenfactory.corvex.cloud/app/settings/keys), select **Create API key**, and copy the value immediately. The dashboard shows the key only once. Keys are created and revoked in the dashboard. Token Factory does not provide a public API for key management. > [!WARNING] > > Keep API keys server-side and out of source control, browser code, logs, and > screenshots. If a key is exposed, revoke it in the dashboard and create a new > one. ## Send the key Use the header required by the endpoint family: | Endpoint family | Header | | - | - | | OpenAI-compatible endpoints | `Authorization: Bearer sk-corvex-...` | | Anthropic-compatible `/v1/messages` endpoints | `x-api-key: sk-corvex-...` | | Usage endpoint `/api/v1/usage` | `Authorization: Bearer sk-corvex-...` | The Anthropic-compatible endpoints also accept a Bearer token, but `x-api-key` matches the default behavior of the Anthropic SDK and Claude Code. `GET /v1/models` is public and does not require a key. When a valid key is included, the response can include account-specific availability and limit information. > [!NOTE] > > Existing `sk-bf-` keys remain accepted. Create new integrations with an > `sk-corvex-` key. ## Rate limits and usage When a request or token-rate limit is exceeded, the API returns HTTP `429`. If the response includes `Retry-After`, wait for that interval before retrying; otherwise use exponential backoff. Review usage in the [dashboard](https://tokenfactory.corvex.cloud/app/usage) or query `GET /api/v1/usage` with the same API key. The [error reference](/reference/errors) documents the stable error codes for request, token, authentication, and billing failures. ## Related documentation > **[Quickstart](/getting-started/quickstart)** > > Send a chat-completions request with `curl`. > **[API reference](/api-reference/openapi)** > > Review endpoint authentication and schemas. # Quickstart Source: https://docs.corvex.cloud/getting-started/quickstart Create a Token Factory API key and send your first chat-completions request. This quickstart calls the Corvex Token Factory OpenAI-compatible Chat Completions API with `curl`. The same API key works with the SDK and developer-tool integrations documented on this site. **1. Create an API key** Sign in to the [Token Factory dashboard](https://tokenfactory.corvex.cloud/app/settings/keys), select **Create API key**, and copy the value when it appears. New keys start with `sk-corvex-` and are shown only once. **2. Store the key in your shell** ```bash theme={null} export CORVEX_API_KEY="sk-corvex-YOUR_VIRTUAL_KEY" ``` Keep the key server-side. Do not commit it, paste it into a screenshot, or include it in browser code. **3. Send a chat completion** ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/chat/completions \ -H "Authorization: Bearer ${CORVEX_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "model": "zai-org/GLM-5.3", "messages": [ {"role": "user", "content": "Explain token-based inference pricing in one sentence."} ] }' ``` **4. Check the response** A successful request returns HTTP `200` and an OpenAI-compatible response: ```json theme={null} { "id": "chatcmpl-...", "object": "chat.completion", "model": "zai-org/GLM-5.3", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Token-based pricing charges separately for the tokens sent to and generated by a model." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` ## Choose a model Model IDs use the model publisher's repository ID in `namespace/model` format. List the live public catalog before hard-coding an ID: ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/models ``` Legacy IDs with a `corvex/` prefix are not supported. See [Models and pricing](/models/overview) for context windows, input types, and rates. ## Use an SDK or developer tool > **[OpenAI SDK](/integrations/openai-drop-in)** > > Configure the official OpenAI Python or TypeScript client. > **[Claude Code](/integrations/claude-code)** > > Connect through the Anthropic-compatible Messages API. > **[OpenCode](/integrations/opencode)** > > Add Token Factory as an OpenAI-compatible provider. > **[API reference](/api-reference/openapi)** > > Review request fields, response schemas, and supported endpoints. ## Troubleshoot the first request An invalid or missing key returns HTTP `401`: ```json theme={null} { "error": { "code": "invalid_api_key", "message": "Invalid API key", "type": "authentication_error" } } ``` Check that `CORVEX_API_KEY` is set in the shell running `curl` and does not contain spaces or a trailing newline. For other status codes, see the [error reference](/reference/errors). # Connect Aider to Token Factory Source: https://docs.corvex.cloud/integrations/aider Run the Aider CLI against a Corvex Token Factory model through the OpenAI-compatible Chat Completions API. Corvex Token Factory connects to Aider as an OpenAI-compatible endpoint. Set two environment variables, register the model's limits in a metadata file, and pass the model ID with the `openai/` prefix. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * [Aider](https://aider.chat/docs/install.html) installed (this guide was verified with Aider 0.86). * A model ID from the [Token Factory catalog](/models/overview). **1. Store the key and endpoint in your shell** Aider reads the OpenAI-compatible endpoint and key from the environment. ```bash theme={null} export OPENAI_API_BASE="https://api.tokenfactory.corvex.cloud/v1" export OPENAI_API_KEY="sk-corvex-YOUR_VIRTUAL_KEY" ``` Add both lines to your shell profile to make them permanent. **2. Register the model limits** Aider does not read context limits from the endpoint. Without this step it starts with `Warning for openai/zai-org/GLM-5.3: Unknown context window size and costs, using sane defaults.` Create `.aider.model.metadata.json` in your home directory or the repository root with the Token Factory models. Use the fully qualified `openai/` name. ```json theme={null} { "openai/zai-org/GLM-5.3": { "max_input_tokens": 393216, "max_output_tokens": 32000, "input_cost_per_token": 0, "output_cost_per_token": 0, "litellm_provider": "openai", "mode": "chat" }, "openai/deepseek-ai/DeepSeek-V4-Flash-0731": { "max_input_tokens": 1048576, "max_output_tokens": 32000, "input_cost_per_token": 0, "output_cost_per_token": 0, "litellm_provider": "openai", "mode": "chat" } } ``` The cost fields only affect Aider's local cost display; the published rates are on the [Pricing](/pricing) page. `max_output_tokens` is a per-response budget; keep it well below the context window so there is room for input. **3. Run Aider** Pass the Token Factory model ID with the `openai/` prefix. ```bash theme={null} cd /path/to/your/repo aider --model openai/zai-org/GLM-5.3 ``` Aider uses its `whole` edit format for models it does not know, which resends entire files on every edit. Both Token Factory models handle the more economical `diff` format; pass `--edit-format diff` or set it in the config file. To make the model and edit format the default, add them to `.aider.conf.yml` in your home directory or the repository root: ```yaml theme={null} model: openai/zai-org/GLM-5.3 edit-format: diff ``` To run a single change non-interactively: ```bash theme={null} aider --model openai/zai-org/GLM-5.3 --yes-always \ --message "Fix the bug in add() so it returns a + b." calc.py ``` **4. Verify the connection** Aider prints the model name on startup. Ask for a small edit to a file you added to the chat. Aider shows the model's reasoning under **THINKING**, the diff under **ANSWER**, applies the edit, and commits it. A completed edit confirms the endpoint, key, and model ID. ## Compatibility notes * **Model IDs.** Use `openai/` followed by the exact `id` from `GET /v1/models`, for example `openai/zai-org/GLM-5.3`. IDs are case-sensitive. Do not add a `corvex/` prefix. * **Reasoning.** Both models reason before answering. Aider displays the reasoning separately from the answer. Reasoning tokens count toward `max_output_tokens`. * **Context length.** If a session exceeds the model's window, the gateway returns `context_length_exceeded`. Drop files from the chat with `/drop` or start a new session. See [Errors](/reference/errors#context_length_exceeded-400). * **Input types.** Neither model accepts image input. Do not add images with `/paste` or `--image`; the request returns a structured error. ## Related documentation * [Use the OpenAI SDK](/integrations/openai-drop-in) — the same endpoint from Python or TypeScript. * [Connect OpenCode](/integrations/opencode) and [Connect Codex](/integrations/codex) — other terminal coding agents. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Use the Anthropic SDK Source: https://docs.corvex.cloud/integrations/anthropic-drop-in Configure the official Anthropic Python or TypeScript SDK to call Corvex Token Factory through the Messages API. Keep the official Anthropic client and Messages API request format. Change the client's base URL and API key, then choose a model from the Corvex Token Factory catalog. Model IDs and feature support differ from Anthropic's hosted models. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * Python with the `anthropic` package, or Node.js with the `@anthropic-ai/sdk` package. * A model ID from the [live catalog](/models/overview). Set the key in your shell: ```bash theme={null} export CORVEX_API_KEY="sk-corvex-YOUR_VIRTUAL_KEY" ``` ## Configure the client ```python python {6-7} theme={null} import os from anthropic import Anthropic client = Anthropic( api_key=os.environ["CORVEX_API_KEY"], base_url="https://api.tokenfactory.corvex.cloud", ) message = client.messages.create( model="zai-org/GLM-5.3", max_tokens=1024, messages=[{"role": "user", "content": "Explain this function."}], ) print(next(block.text for block in message.content if block.type == "text")) ``` ```typescript TypeScript {4-5} theme={null} import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ apiKey: process.env.CORVEX_API_KEY, baseURL: "https://api.tokenfactory.corvex.cloud", }); const message = await client.messages.create({ model: "zai-org/GLM-5.3", max_tokens: 1024, messages: [{ role: "user", content: "Explain this function." }], }); console.log(message.content.find((block) => block.type === "text")?.text); ``` The highlighted constructor fields route the client to Token Factory. The base URL has no `/v1` suffix; the SDK appends `/v1/messages` itself and sends the key in the `x-api-key` header. `max_tokens` is required by the Messages API. Both Token Factory models reason before answering, so `content` starts with a `thinking` block followed by the `text` block. Select the block by `type` rather than by position, as the examples do. Reasoning tokens count toward `max_tokens`. ## Run the repository examples ```bash theme={null} # Python python -m pip install anthropic python integrations/anthropic-drop-in/python.py # Node.js npm install @anthropic-ai/sdk node integrations/anthropic-drop-in/node.mjs ``` A non-`2xx` response raises the SDK's API error type with the Anthropic-shaped Token Factory error body. See [Errors: Anthropic endpoints](/reference/errors#anthropic-endpoints-v1messages). ## Streaming and tool use The endpoint accepts `stream: true` and returns the Anthropic Server-Sent Events sequence (`message_start`, `content_block_delta`, ..., `message_stop`), so the SDK's streaming helpers work as they do against Anthropic. Tool definitions and `tool_use` / `tool_result` content blocks are accepted for both Token Factory models. ## Count tokens `POST /v1/messages/count_tokens` validates the key and request shape without running inference: ```python theme={null} count = client.messages.count_tokens( model="deepseek-ai/DeepSeek-V4-Flash-0731", messages=[{"role": "user", "content": "Hello"}], ) print(count.input_tokens) ``` ## Compatibility notes * **Model IDs.** Use the Token Factory `namespace/model` ID exactly as `GET /v1/models` returns it. Anthropic model names are not served. * **Prompt caching.** The endpoint accepts `cache_control` but Token Factory does not treat it as a request to cache content. Cached input tokens that the engine reports are billed at the cached input rate. See [Errors: Prompt caching](/reference/errors#prompt-caching-cache_control). * **Input types.** Neither model accepts image input. Unsupported inputs return a structured error. ## Related documentation * [Connect Claude Code](/integrations/claude-code) — the same Messages API from the Claude Code CLI. * [Use the OpenAI SDK](/integrations/openai-drop-in) — the Chat Completions surface for OpenAI clients. * [API reference](/api-reference/openapi) — supported Messages API request and response fields. # Connect Claude Code to Token Factory Source: https://docs.corvex.cloud/integrations/claude-code Point Claude Code at Corvex Token Factory through its Anthropic-compatible Messages API and size the context window to the model you serve. Corvex Token Factory exposes an Anthropic-compatible Messages API, so Claude Code connects to it as an [LLM gateway](https://code.claude.com/docs/en/llm-gateway). You set the endpoint, key, and model as environment variables, either in your shell or in the `env` block of a Claude Code settings file, and tell Claude Code the model's real context window. Verified with Claude Code 2.1.299, October 2026. ## Prerequisites * A Token Factory API key (`sk-corvex-...`). See [Authentication](/getting-started/authentication). * A model ID from the [Models](/models/overview) catalog. * [Claude Code](https://code.claude.com/docs/en/setup) 2.1.296 or later. ## Context window and compaction Claude Code does not read the context window of a model it doesn't recognize from the endpoint. Unless you tell it otherwise, it assumes 200,000 tokens and compacts the conversation well before a Token Factory model's real limit. Two variables fix that: * `CLAUDE_CODE_MAX_CONTEXT_TOKENS` sets the window Claude Code assumes for the model. Set it to the model's `context_window`. * `CLAUDE_CODE_AUTO_COMPACT_WINDOW` sets the window Claude Code compacts against. `/context` reports usage out of this value. Claude Code compacts before usage reaches it, keeping a buffer of `min(max_tokens, 20,000) + 13,000` tokens (33,000 by default), shown in `/context` as the autocompact buffer. Every request reserves room for the reply: the engine enforces `input + max_tokens ≤ context_window`, and Claude Code sends `max_tokens` = 32,000 by default (`CLAUDE_CODE_MAX_OUTPUT_TOKENS`). A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: size the compaction window as `(context_window − max_tokens) / 1.15`, rounded down: | Model | Context window | Output cap | `max_tokens` sent | Compaction window | | - | - | - | - | - | | `zai-org/GLM-5.3` | 393,216 | 393,216 | 32,000 | 314,100 | | `deepseek-ai/DeepSeek-V4-Flash-0731` | 1,048,576 | 1,048,576 | 32,000 | 883,979 | `CLAUDE_CODE_AUTO_COMPACT_WINDOW` accepts plain integers from `100000` to `1000000`. If you change `CLAUDE_CODE_MAX_OUTPUT_TOKENS`, recompute the compaction window with the formula. `GET /v1/models` reports each model's current `context_window` and `max_output_tokens`. **1. Verify the key** Export the key and send a token-counting request. It checks the key and request shape without running inference. ```bash theme={null} export ANTHROPIC_BASE_URL="https://api.tokenfactory.corvex.cloud" export ANTHROPIC_AUTH_TOKEN="sk-corvex-..." curl -sS "${ANTHROPIC_BASE_URL}/v1/messages/count_tokens" \ -H "Authorization: Bearer ${ANTHROPIC_AUTH_TOKEN}" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "zai-org/GLM-5.3", "messages": [{"role": "user", "content": "Hello"}] }' ``` **2. Add the settings** Add an `env` block to your user settings file. This example selects `zai-org/GLM-5.3`; for another model, change every model ID and take both numbers from the table above. ```json settings.json theme={null} { "env": { "ANTHROPIC_BASE_URL": "https://api.tokenfactory.corvex.cloud", "ANTHROPIC_AUTH_TOKEN": "sk-corvex-...", "ANTHROPIC_MODEL": "zai-org/GLM-5.3", "ANTHROPIC_DEFAULT_OPUS_MODEL": "zai-org/GLM-5.3", "ANTHROPIC_DEFAULT_SONNET_MODEL": "zai-org/GLM-5.3", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "zai-org/GLM-5.3", "CLAUDE_CODE_SUBAGENT_MODEL": "zai-org/GLM-5.3", "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "393216", "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "314100", "CLAUDE_CODE_AUTO_MODE_SERVER": "0" } } ``` The user settings file is `~/.claude/settings.json`. Keep the key out of a project's `.claude/settings.json`, which is usually committed. The same variables also work as shell exports. To keep your default Claude Code setup and use Token Factory only on demand, put the block in a separate file and start Claude Code with `claude --settings `. The `ANTHROPIC_DEFAULT_*_MODEL` and `CLAUDE_CODE_SUBAGENT_MODEL` variables route Claude Code's background and subagent requests to the same model, so no request asks for a model Token Factory doesn't serve. **3. Run Claude Code and check the window** ```bash theme={null} cd /path/to/your/repo claude ``` Run `/status` to confirm the base URL and model, and `/context` to confirm the window. For `zai-org/GLM-5.3`, `/context` reports usage out of `314.1k` tokens. ## Compatibility notes * **Prompt caching.** The Messages API accepts `cache_control`, but Token Factory does not treat it as a request to cache content. Engine-reported cache usage is passed through; missing cache-usage fields are reported as zero. Cached input tokens are billed at the cached input rate. See [Errors: Prompt caching](/reference/errors#prompt-caching-cache_control) for details. * **Auto mode classifier.** In auto mode, Claude Code asks the Anthropic API to run its safety classifier server-side and shows a notice saying the session "isn't eligible" when the results don't come back. Token Factory serves non-Anthropic models and does not provide those server-side checks. `CLAUDE_CODE_AUTO_MODE_SERVER=0` is the opt-out Anthropic documents for this case: auto mode keeps working with the local classifier, its requests count toward token usage at the applicable model rates, and the notice does not appear. See [Auto mode classifier request charges](https://code.claude.com/docs/en/auto-mode-classifier-billing). * **Context length.** If a session still reaches the model's limit, the gateway returns `context_length_exceeded`. Run `/compact` and retry. See [Errors](/reference/errors#context_length_exceeded-400). * **Model capabilities.** Choose a model whose input types and features match the task. Unsupported inputs return a structured error; compare the available models on the [Models](/models/overview) page. ## Related documentation * [Use the Anthropic SDK](/integrations/anthropic-drop-in) — the same Messages API from Python or TypeScript. * [Connect Codex](/integrations/codex) and [Connect OpenCode](/integrations/opencode) — other terminal coding agents. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Connect Cline to Token Factory Source: https://docs.corvex.cloud/integrations/cline Configure Corvex Token Factory as an OpenAI Compatible provider in the Cline extension. Corvex Token Factory connects to Cline through its **OpenAI Compatible** API provider. Point the provider at the Token Factory Chat Completions endpoint, paste your API key, and enter a model ID from the catalog. Cline sends OpenAI-shaped requests with tool definitions, which both Token Factory models accept. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * [Cline](https://docs.cline.bot/) installed in VS Code, Cursor, JetBrains, or another supported IDE. * A model ID from the [Token Factory catalog](/models/overview). **1. Choose your own API key** On first launch, Cline shows an onboarding screen titled **How will you use Cline?**. Select **Bring my own API key** and then **Continue**. The settings (gear) icon is inactive until onboarding is complete. If Cline is already configured, open the Cline panel, select the settings (gear) icon, and go to **API Configuration**. **2. Enter the Token Factory endpoint, key, and model** | Field | Value | | - | - | | Base URL | `https://api.tokenfactory.corvex.cloud/v1` | | API Key | your `sk-corvex-...` key | | Model ID | `zai-org/GLM-5.3` or `deepseek-ai/DeepSeek-V4-Flash-0731` | Enter the model ID exactly as the catalog lists it, including the `namespace/` prefix. Do not add a `corvex/` prefix. **3. Set the model limits** Cline does not read context limits from the endpoint and defaults to a 128,000-token window. Expand **Model Configuration** and set the values for the model you selected. | Model | Context Window Size | Max Output Tokens | | - | - | - | | `zai-org/GLM-5.3` | `393216` | `32000` | | `deepseek-ai/DeepSeek-V4-Flash-0731` | `1048576` | `32000` | **Supports Images** is checked by default; clear it, because neither model accepts image input. Leave **Enable R1 messages format** off. The Max Output Tokens value is a per-response budget; keep it well below the context window so there is room for input and tool results. The price fields only affect Cline's local cost display; the published rates are on the [Pricing](/pricing) page. **4. Verify the connection** Return to the chat, confirm the context bar shows the configured window (for example `393.2k`), and start a task in **Act** mode that reads a file in your repository. A completed tool call confirms the endpoint, key, and model ID. ## Compatibility notes * **Model IDs.** Use the exact `id` from `GET /v1/models`. IDs are case-sensitive. See [Models](/models/overview). * **Context length.** If a long task exceeds the model's window, the gateway returns `context_length_exceeded`. Start a new task or shorten the context. See [Errors](/reference/errors#context_length_exceeded-400). * **Reasoning.** Both models reason before answering; Cline shows the reasoning under **Thinking**. Reasoning tokens count toward the Max Output Tokens value you configured. The **Reasoning Effort** setting is sent with the request; Token Factory applies the model's default reasoning behavior. ## Related documentation * [Use the OpenAI SDK](/integrations/openai-drop-in) — the same endpoint from Python or TypeScript. * [Connect Kilo Code](/integrations/kilo-code) — the same provider settings in a related extension. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Connect Codex to Token Factory Source: https://docs.corvex.cloud/integrations/codex Configure OpenAI Codex CLI and the Codex IDE extension to use a Corvex Token Factory model through the Responses API. Corvex Token Factory exposes an OpenAI Responses API endpoint, which is the protocol Codex requires from a custom model provider. Add Token Factory as a provider in `~/.codex/config.toml`, describe its models in a model catalog file so Codex knows their real context windows, and select a model. The Codex CLI and the Codex IDE extension read the same configuration. Verified with Codex 0.162.1, October 2026. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * [Codex CLI](https://developers.openai.com/codex/cli) 0.162.1 or later (`npm install -g @openai/codex`) and `jq`. * A model ID from the [Token Factory catalog](/models/overview). ## Context window and compaction Codex treats a model ID it doesn't know as a 272,000-token model, and `model_context_window` cannot raise that ceiling. A model catalog file (`model_catalog_json`) gives Codex each model's real window. Codex does not send `max_output_tokens`, so it reserves no output room of its own (`max_tokens` = 0 in the formula below). Its default compaction point is 90% of the window. A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: set `model_auto_compact_token_limit` to `(context_window − max_tokens) / 1.15`, rounded down: | Model | Context window | Output cap | `max_tokens` sent | Compaction window | | - | - | - | - | - | | `zai-org/GLM-5.3` | 393,216 | 393,216 | 0 | 341,926 | | `deepseek-ai/DeepSeek-V4-Flash-0731` | 1,048,576 | 1,048,576 | 0 | 911,805 | Codex counts 95% of the window as usable (373,555 tokens for a 393,216-token window); after the first turn, `/status` shows that usable window. `GET /v1/models` reports each model's current `context_window` and `max_output_tokens`. **1. Store the key in your shell** Codex reads the API key from the environment variable named by `env_key`. Export it in your shell profile so both the CLI and the IDE extension can read it. ```bash theme={null} export CORVEX_API_KEY="sk-corvex-..." ``` **2. Create the model catalog** Build the catalog from Codex's bundled one, so the Token Factory models keep Codex's standard instructions. The command writes `~/.codex/token-factory-models.json`: ```bash create-catalog.sh theme={null} codex debug models --bundled | jq ' (.models | min_by(.priority) | .model_messages) as $messages | {models: [ {slug: "zai-org/GLM-5.3", context_window: 393216}, {slug: "deepseek-ai/DeepSeek-V4-Flash-0731", context_window: 1048576} ] | map(. + { display_name: .slug, description: null, max_context_window: .context_window, effective_context_window_percent: 95, model_messages: $messages, supported_reasoning_levels: [], shell_type: "unified_exec", visibility: "list", supported_in_api: true, priority: 99, availability_nux: null, upgrade: null, support_verbosity: false, default_verbosity: null, apply_patch_tool_type: null, web_search_tool_type: "text", truncation_policy: {mode: "bytes", limit: 10000}, experimental_supported_tools: [] })}' > ~/.codex/token-factory-models.json ``` The catalog replaces Codex's built-in model list, so it lists only Token Factory models. **3. Add the provider to config.toml** Create or edit `~/.codex/config.toml`: ```toml config.toml theme={null} model = "zai-org/GLM-5.3" model_provider = "corvex" model_catalog_json = "~/.codex/token-factory-models.json" model_auto_compact_token_limit = 341926 [model_providers.corvex] name = "Corvex Token Factory" base_url = "https://api.tokenfactory.corvex.cloud/v1" env_key = "CORVEX_API_KEY" wire_api = "responses" ``` Enter the model ID exactly as the catalog lists it, including the `namespace/` prefix. Do not add a `corvex/` prefix. **4. Add a profile for each other model** The compaction limit is per model, so keep one profile file per model next to `config.toml`. Codex layers `~/.codex/.config.toml` on top of `config.toml` when you pass `--profile `: ```toml deepseek.config.toml theme={null} model = "deepseek-ai/DeepSeek-V4-Flash-0731" model_auto_compact_token_limit = 911805 ``` **5. Run Codex** ```bash theme={null} cd /path/to/your/repo codex # zai-org/GLM-5.3 codex --profile deepseek # deepseek-ai/DeepSeek-V4-Flash-0731 ``` To run a single task non-interactively: ```bash theme={null} codex exec "Summarize what this repository does." ``` **6. Verify the connection** Ask Codex to read a file in the repository, then run `/status`. It shows **Corvex Token Factory**, the model ID, and a usable window of 95% of the model's context window. A window of 258,400 means Codex did not load the catalog; check the `model_catalog_json` path. ## How Token Factory serves the Responses API `POST /v1/responses` accepts the Codex request shape, including `instructions`, `input` items, `tools`, `tool_choice`, `max_output_tokens`, `temperature`, and `stream`. The gateway translates each request to the model's Chat Completions interface and returns Responses-shaped output, with streaming events in the Responses event order. The model's reasoning is returned as a `reasoning` output item ahead of the message item. Conversation persistence is not exposed: `store` and `previous_response_id` have no effect, and there is no `/v1/conversations` endpoint. Codex resends the full conversation on each turn, so this does not affect normal use. Request fields that control OpenAI-hosted reasoning (`reasoning`, `include`) are accepted and ignored; the model reasons with its default settings. See the [API reference](/api-reference/openapi) for the documented request and response fields. ## Compatibility notes * **Context length.** If a session exceeds the model's window, the gateway returns `context_length_exceeded`. Run `/compact` in Codex, or start a new session. See [Errors](/reference/errors#context_length_exceeded-400). * **Output budget.** Reasoning tokens count toward the output budget. If a response is truncated, shorten the prompt or split the task. * **Input types.** Neither model accepts image input. Do not attach images with `-i`; the request returns a structured error. ## Related documentation * [Use the OpenAI SDK](/integrations/openai-drop-in) — Chat Completions from Python or TypeScript. * [Connect OpenCode](/integrations/opencode) — another terminal coding agent on the OpenAI-compatible surface. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Connect DeepSeek Harness to Token Factory Source: https://docs.corvex.cloud/integrations/deepseek-harness Configure Corvex Token Factory as an OpenAI-compatible provider in DeepSeek Harness. Corvex Token Factory connects to DeepSeek Harness (`dsh`) through an OpenAI-compatible provider. Add your API key and provider configuration, then start the Web UI with a Token Factory model. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness#run) installed following its official instructions. * A model from the [Token Factory catalog](/models/overview). This guide uses `zai-org/GLM-5.3`. **1. Set your API key** Run these commands in your terminal, replacing `sk-corvex-...` with your API key. `DSH_HOME` gives Token Factory its own DSH settings folder. ```bash theme={null} export CORVEX_API_KEY="sk-corvex-..." export DSH_HOME="$HOME/.dsh-corvex" mkdir -p "$DSH_HOME" chmod 700 "$DSH_HOME" ``` **2. Add the provider configuration** Create `$DSH_HOME/corvex.patch.yml` with the following contents. `apiKeyEnv` tells DSH to read the key you set above. ```yaml theme={null} - id: llm-pi-ai config: providers: corvex: apiKeyEnv: CORVEX_API_KEY api: openai-completions baseURL: https://api.tokenfactory.corvex.cloud/v1 compat: supportsDeveloperRole: false maxTokensField: max_tokens models: - id: zai-org/GLM-5.3 contextWindow: 393216 maxTokens: 393216 input: [text] - id: agent-default-model config: provider: corvex model: zai-org/GLM-5.3 ``` If you already configured other providers, keep them in the `providers` section when adding this one. **3. Start the Web UI** Open your project directory and start DSH: ```bash theme={null} cd /path/to/your/project dsh --profile web --patch "$DSH_HOME/corvex.patch.yml" ``` DSH opens the Web UI at `http://127.0.0.1:3080`. Start a new session with **zai-org/GLM-5.3** selected. Use **Add workspace** to choose another project. If you normally start DSH with a different command, use it in place of `dsh`. In a new terminal, repeat the commands in step 1 before starting DSH. To run a single task from the command line instead: ```bash theme={null} dsh --profile headless --patch "$DSH_HOME/corvex.patch.yml" \ "Explain the structure of this project." ``` ## Token limits The conversation, reasoning and answer share the model's token limit. The configuration sets `contextWindow` and `maxTokens` to `393216`; DSH leaves room for the conversation when deciding how many tokens the model can generate. A smaller `maxTokens` value can stop the model before it finishes reasoning. ## If a request fails DSH automatically summarizes older messages to make room and retries when a request exceeds the context limit. You do not need to edit the conversation. A `429` error means requests are temporarily limited. This can follow heavy usage or repeated failures. If the response includes `Retry-After`, wait that long before trying again. Waiting alone will not fix a request that keeps failing. If DSH cannot continue, contact [Token Factory support](/reference/faq#how-do-i-contact-support) with the error message and request ID, if available. See [Errors](/reference/errors) for details. # Connect Kilo Code to Token Factory Source: https://docs.corvex.cloud/integrations/kilo-code Add Corvex Token Factory as a custom OpenAI Compatible provider in Kilo Code and size each model's limits. Corvex Token Factory connects to Kilo Code as a **custom provider** that uses the OpenAI Compatible API. The Kilo Code CLI and the VS Code and JetBrains extensions read the same global configuration file, so one provider entry serves all of them. Verified with Kilo Code 7.8.8, October 2026, using the Kilo Code CLI. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * [Kilo Code](https://kilo.ai/docs/) 7.8.8 or later: the CLI (`npm install -g @kilocode/cli`) or the VS Code or JetBrains extension. * A model from the [Token Factory catalog](/models/overview). ## Context window and compaction Kilo Code does not read limits from the endpoint, so each model declares them under `limit`: * `limit.context` is the model's `context_window`. * `limit.output` is the model's `max_output_tokens`. Kilo Code sends `max_tokens` = the smaller of this and its built-in 32,000-token cap, reduced only when the context is nearly full. * `limit.input` sets where Kilo Code compacts: it summarizes the conversation once a request reaches `limit.input` minus 20,000 tokens (its default `compaction.reserved` while the output cap is at least 20,000). Without `limit.input`, Kilo Code compacts only at `limit.context − max_tokens`, with no headroom. A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: the compaction window is `(context_window − max_tokens) / 1.15`, rounded down, and `limit.input` is that value plus 20,000: | Model | Context window | Output cap | `max_tokens` sent | Compaction window | `limit.input` | | - | - | - | - | - | - | | `zai-org/GLM-5.3` | 393,216 | 393,216 | 32,000 | 314,100 | 334,100 | | `deepseek-ai/DeepSeek-V4-Flash-0731` | 1,048,576 | 1,048,576 | 32,000 | 883,979 | 903,979 | `GET /v1/models` reports each model's current `context_window` and `max_output_tokens`. **1. Store the API key** Export the key in your shell profile. The configuration below reads it with `{env:CORVEX_API_KEY}`, which Kilo Code resolves only in the global configuration file. ```bash theme={null} export CORVEX_API_KEY="sk-corvex-..." ``` **2. Add the provider configuration** Add the provider to the global configuration file, `~/.config/kilo/kilo.jsonc`: ```jsonc kilo.jsonc theme={null} { "provider": { "corvex": { "npm": "@ai-sdk/openai-compatible", "name": "Corvex Token Factory", "options": { "baseURL": "https://api.tokenfactory.corvex.cloud/v1", "apiKey": "{env:CORVEX_API_KEY}" }, "models": { "zai-org/GLM-5.3": { "name": "GLM 5.3", "reasoning": true, "tool_call": true, "limit": { "context": 393216, "input": 334100, "output": 393216 } }, "deepseek-ai/DeepSeek-V4-Flash-0731": { "name": "DeepSeek V4 Flash 0731", "reasoning": true, "tool_call": true, "limit": { "context": 1048576, "input": 903979, "output": 1048576 } } } } }, "model": "corvex/zai-org/GLM-5.3" } ``` In the extensions you can also add the provider from the settings (gear icon) under **Providers → Custom provider**, with the Base URL `https://api.tokenfactory.corvex.cloud/v1` and **OpenAI Compatible** as the API. Then add the `limit` entries above to the same file and reload the window (**Developer: Reload Window** in VS Code). **3. Select the model and verify the connection** New sessions in the extension can start on Kilo Code's own model router, which does not use Token Factory. Select the model button under the chat box and choose a model in the **Corvex Token Factory** group. The context bar shows the configured window (`393.2K` for `zai-org/GLM-5.3`). From the CLI, run one prompt non-interactively: ```bash theme={null} kilo run -m corvex/deepseek-ai/DeepSeek-V4-Flash-0731 "Summarize this repository." ``` `kilo models corvex --verbose` prints the limits Kilo Code loaded for each model. ## Compatibility notes * **Model IDs.** Use the exact `id` from `GET /v1/models`. IDs are case-sensitive and use `namespace/model` format; add the `corvex/` provider prefix only when you select a model on the command line. * **Output budget.** Reasoning tokens count toward the 32,000-token budget. The `KILO_EXPERIMENTAL_OUTPUT_TOKEN_MAX` environment variable changes the cap; recompute the compaction window if you change it. * **Context length.** If a long task still exceeds the model's window, the gateway returns `context_length_exceeded`. Start a new task or shorten the context. See [Errors](/reference/errors#context_length_exceeded-400). * **Debug output.** `kilo debug config` prints the resolved API key in plain text. Do not paste its output into issues or logs. ## Related documentation * [Connect OpenCode](/integrations/opencode) — the same configuration format in OpenCode. * [Use the OpenAI SDK](/integrations/openai-drop-in) — the same endpoint from Python or TypeScript. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Use the OpenAI SDK Source: https://docs.corvex.cloud/integrations/openai-drop-in Configure the official OpenAI Python or TypeScript SDK to call Corvex Token Factory. Keep the official OpenAI client and Chat Completions request format. Change the client's base URL and API key, then choose a model from the Token Factory catalog. Model IDs and feature support differ from OpenAI's hosted models. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * Python with the `openai` package, or Node.js with the `openai` package. * A model ID from the [live catalog](/models/overview). Set the key in your shell: ```bash theme={null} export CORVEX_API_KEY="sk-corvex-YOUR_VIRTUAL_KEY" ``` ## Configure the client ```python python {6-7} theme={null} import os from openai import OpenAI client = OpenAI( api_key=os.environ["CORVEX_API_KEY"], base_url="https://api.tokenfactory.corvex.cloud/v1", ) response = client.chat.completions.create( model="zai-org/GLM-5.3", messages=[{"role": "user", "content": "Explain this function."}], ) print(response.choices[0].message.content) ``` ```typescript TypeScript {4-5} theme={null} import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.CORVEX_API_KEY, baseURL: "https://api.tokenfactory.corvex.cloud/v1", }); const response = await client.chat.completions.create({ model: "zai-org/GLM-5.3", messages: [{ role: "user", content: "Explain this function." }], }); console.log(response.choices[0].message.content); ``` The highlighted constructor fields route the client to Token Factory. Requests use the standard Bearer header generated by the OpenAI SDK. ## Run the repository examples ```bash theme={null} # Python python -m pip install openai python integrations/openai-drop-in/python.py # Node.js npm install openai node integrations/openai-drop-in/node.mjs ``` A non-`2xx` response raises the SDK's API error type with the structured Token Factory error body. Configure timeouts and retries through the SDK as you would for any remote inference service. ## Model IDs Token Factory model IDs use `namespace/model` format. List the public catalog before hard-coding an ID: ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/models ``` Do not add a `corvex/` prefix. The [model catalog](/models/overview) documents input types, context windows, capabilities, and rates. ## Related documentation * [Quickstart](/getting-started/quickstart) — test the endpoint with `curl`. * [Errors](/reference/errors) — handle authentication, validation, rate-limit, and server failures. * [API reference](/api-reference/openapi) — review the supported OpenAI-compatible request and response fields. # Connect OpenCode to Token Factory Source: https://docs.corvex.cloud/integrations/opencode Configure Corvex Token Factory as an OpenAI-compatible provider in OpenCode and size each model's limits. Corvex Token Factory connects to OpenCode through a custom OpenAI-compatible provider. Add the provider and its models to your OpenCode configuration, then select a Token Factory model from `/models`. Verified with OpenCode 1.19.0, October 2026. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * [OpenCode](https://opencode.ai/docs/) 1.19.0 or later. * A model from the [Token Factory catalog](/models/overview). ## Context window and compaction OpenCode does not read limits from the endpoint, so each model declares them under `limit`: * `limit.context` is the model's `context_window`. * `limit.output` is the model's `max_output_tokens`. OpenCode sends `max_tokens` = the smaller of this and its built-in 32,000-token cap. * `limit.input` sets where OpenCode compacts: it summarizes the conversation once a request reaches `limit.input` minus 20,000 tokens (its default `compaction.reserved` while the output cap is at least 20,000). Without `limit.input`, OpenCode compacts only at `limit.context − max_tokens`, with no headroom. A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: the compaction window is `(context_window − max_tokens) / 1.15`, rounded down, and `limit.input` is that value plus 20,000: | Model | Context window | Output cap | `max_tokens` sent | Compaction window | `limit.input` | | - | - | - | - | - | - | | `zai-org/GLM-5.3` | 393,216 | 393,216 | 32,000 | 314,100 | 334,100 | | `deepseek-ai/DeepSeek-V4-Flash-0731` | 1,048,576 | 1,048,576 | 32,000 | 883,979 | 903,979 | `GET /v1/models` reports each model's current `context_window` and `max_output_tokens`. **1. Store the API key** Export the key in your shell profile. The configuration below reads it with `{env:CORVEX_API_KEY}`. ```bash theme={null} export CORVEX_API_KEY="sk-corvex-..." ``` You can instead run `/connect` in OpenCode, select **Other**, enter `corvex` as the provider ID, and paste the key; then omit `apiKey` below. **2. Add the provider configuration** Add the provider to `~/.config/opencode/opencode.json` for global use, or to `opencode.json` in the project root: ```json opencode.json theme={null} { "$schema": "https://opencode.ai/config.json", "provider": { "corvex": { "npm": "@ai-sdk/openai-compatible", "name": "Corvex Token Factory", "options": { "baseURL": "https://api.tokenfactory.corvex.cloud/v1", "apiKey": "{env:CORVEX_API_KEY}" }, "models": { "zai-org/GLM-5.3": { "name": "GLM 5.3", "reasoning": true, "tool_call": true, "cost": { "input": 1.4, "output": 4.4 }, "limit": { "context": 393216, "input": 334100, "output": 393216 } }, "deepseek-ai/DeepSeek-V4-Flash-0731": { "name": "DeepSeek V4 Flash 0731", "reasoning": true, "tool_call": true, "cost": { "input": 0.14, "output": 0.28 }, "limit": { "context": 1048576, "input": 903979, "output": 1048576 } } } } }, "model": "corvex/zai-org/GLM-5.3" } ``` `cost` is in US dollars per million tokens and only affects OpenCode's cost display; see [Pricing](/pricing) for current rates. **3. Select and test a model** Start OpenCode in your repository and run `/models`. Select a model under **Corvex Token Factory**, then run a short task that exercises a tool call. To run one prompt non-interactively: ```bash theme={null} opencode run -m corvex/deepseek-ai/DeepSeek-V4-Flash-0731 "Summarize this repository." ``` `opencode models corvex --verbose` prints the limits OpenCode loaded for each model. ## Compatibility notes * **Output budget.** Reasoning tokens count toward the 32,000-token step budget. If a response or tool call is truncated, retry with a shorter prompt or split the task. The `OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX` environment variable changes the cap; recompute the compaction window if you change it. * **Context length.** If a session still exceeds the model's window, the gateway returns `context_length_exceeded`. Run `/compact` or start a new session. See [Errors](/reference/errors#context_length_exceeded-400). * **Model IDs.** Use the exact `id` from `GET /v1/models`, prefixed with the provider ID (`corvex/`) when you select it on the command line. ## Related documentation * [Connect Kilo Code](/integrations/kilo-code) — the same configuration format in Kilo Code. * [Connect pi](/integrations/pi) and [Connect Codex](/integrations/codex) — other terminal coding agents. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Integrations Source: https://docs.corvex.cloud/integrations/overview Connect SDKs, coding agents, and developer tools to Corvex Token Factory. Corvex Token Factory supports the documented OpenAI- and Anthropic-compatible API surfaces. Reuse a compatible client by configuring the appropriate base URL, authentication header, and Token Factory model ID. | Protocol | Base URL | Authentication | Used by | | - | - | - | - | | OpenAI Chat Completions | `https://api.tokenfactory.corvex.cloud/v1` | `Authorization: Bearer sk-corvex-...` | OpenAI SDK, OpenCode, Kilo Code, pi, Cline, Aider, DeepSeek Harness | | OpenAI Responses API | `https://api.tokenfactory.corvex.cloud/v1` | `Authorization: Bearer sk-corvex-...` | Codex | | Anthropic Messages API | `https://api.tokenfactory.corvex.cloud` | `x-api-key: sk-corvex-...` or `Authorization: Bearer sk-corvex-...` | Anthropic SDK, Claude Code | ## SDKs > **[OpenAI SDK](/integrations/openai-drop-in)** > > Configure the official OpenAI Python or TypeScript client for Chat > Completions. > **[Anthropic SDK](/integrations/anthropic-drop-in)** > > Configure the official Anthropic Python or TypeScript client for the > Messages API. ## Coding agents > **[Claude Code](/integrations/claude-code)** > > Connect Claude Code through the Anthropic-compatible Messages API. > **[Codex](/integrations/codex)** > > Add Token Factory as a Responses API provider for the Codex CLI and IDE > extension. > **[OpenCode](/integrations/opencode)** > > Add Token Factory as an OpenAI-compatible provider. > **[Kilo Code](/integrations/kilo-code)** > > Add Token Factory as a custom OpenAI Compatible provider in the Kilo Code > CLI and extensions. > **[pi](/integrations/pi)** > > Add Token Factory as a custom provider in the pi coding agent. > **[Cline](/integrations/cline)** > > Configure the OpenAI Compatible provider in the Cline extension. > **[Aider](/integrations/aider)** > > Point the Aider CLI at Token Factory with two environment variables and a > model metadata file. > **[DeepSeek Harness](/integrations/deepseek-harness)** > > Connect DeepSeek Harness to Token Factory. ## JetBrains IDEs > **[PyCharm AI Assistant](/integrations/pycharm)** > > Configure the native provider, enable tool calling, and troubleshoot request > errors. ACP setup is covered separately. ## Other OpenAI-compatible tools Tools that let you set a custom OpenAI-compatible base URL, API key, and model ID can usually be configured the same way as the guides above: 1. Base URL: `https://api.tokenfactory.corvex.cloud/v1` 2. API key: your `sk-corvex-...` key, sent as a Bearer token 3. Model ID: the exact `id` from `GET /v1/models`, for example `zai-org/GLM-5.3` 4. Context window: the model's `context_window` from the catalog, if the tool asks for it Before configuring a tool, test your key and endpoint with the [API quickstart](/getting-started/quickstart). Compatibility is limited to the endpoints, fields, and model features listed in the [API reference](/api-reference/openapi) and [model catalog](/models/overview). A tool that requires an undocumented API or model feature may need additional configuration or may not be supported. # Connect pi to Token Factory Source: https://docs.corvex.cloud/integrations/pi Add Corvex Token Factory as a custom OpenAI-compatible provider in the pi coding agent and size each model's limits. Corvex Token Factory connects to the [pi coding agent](https://github.com/earendil-works/pi) as a custom provider on the OpenAI-compatible Chat Completions API. You declare the provider and its models in pi's `models.json`, and set per-model compaction in its `settings.json`. Verified with pi 1.2.0, October 2026. ## Prerequisites * A Token Factory API key. See [Authentication](/getting-started/authentication). * pi 1.2.0 or later (`npm install -g @earendil-works/pi-coding-agent`; requires Node.js 22.19 or later). * A model from the [Token Factory catalog](/models/overview). ## Context window and compaction pi does not read limits from the endpoint, so each model declares them: * `contextWindow` is the model's `context_window`. * `maxTokens` is the output reservation pi sends with every request (as `max_completion_tokens`), reduced only when the context is nearly full. The example keeps pi's default of 16,384. Setting it to the model's full output cap would make every request reserve almost the entire window. * pi compacts the conversation once it exceeds `contextWindow − reserveTokens`, where `reserveTokens` is a compaction setting. A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: the compaction window is `(context_window − max_tokens) / 1.15`, rounded down, and `reserveTokens` is the context window minus that value: | Model | Context window | Output cap | `max_tokens` sent | Compaction window | `reserveTokens` | | - | - | - | - | - | - | | `zai-org/GLM-5.3` | 393,216 | 393,216 | 16,384 | 327,680 | 65,536 | | `deepseek-ai/DeepSeek-V4-Flash-0731` | 1,048,576 | 1,048,576 | 16,384 | 897,558 | 151,018 | `GET /v1/models` reports each model's current `context_window` and `max_output_tokens`. **1. Store the API key** Export the key in your shell profile. `models.json` reads it with `$CORVEX_API_KEY`; a bare variable name without `$` is sent as the key itself. ```bash theme={null} export CORVEX_API_KEY="sk-corvex-..." ``` **2. Add the provider and models** Add the provider to `~/.pi/agent/models.json`: ```json models.json theme={null} { "providers": { "corvex": { "name": "Corvex Token Factory", "baseUrl": "https://api.tokenfactory.corvex.cloud/v1", "api": "openai-completions", "apiKey": "$CORVEX_API_KEY", "models": [ { "id": "zai-org/GLM-5.3", "name": "GLM 5.3", "reasoning": true, "input": ["text"], "contextWindow": 393216, "maxTokens": 16384, "cost": { "input": 1.4, "output": 4.4, "cacheRead": 0.26, "cacheWrite": 0 } }, { "id": "deepseek-ai/DeepSeek-V4-Flash-0731", "name": "DeepSeek V4 Flash 0731", "reasoning": true, "input": ["text"], "contextWindow": 1048576, "maxTokens": 16384, "cost": { "input": 0.14, "output": 0.28, "cacheRead": 0.07, "cacheWrite": 0 } } ] } } } ``` `cost` is in US dollars per million tokens and only affects pi's cost display; see [Pricing](/pricing) for current rates. **3. Set the default model and compaction** Add these keys to `~/.pi/agent/settings.json`: ```json settings.json theme={null} { "defaultProvider": "corvex", "defaultModel": "zai-org/GLM-5.3", "compaction": { "modelOverrides": { "corvex/zai-org/GLM-5.3": { "reserveTokens": 65536 }, "corvex/deepseek-ai/DeepSeek-V4-Flash-0731": { "reserveTokens": 151018 } } } } ``` `defaultModel` takes the bare model ID; the provider goes in `defaultProvider`. **4. Run pi and verify the connection** ```bash theme={null} cd /path/to/your/repo pi # zai-org/GLM-5.3 pi --model corvex/deepseek-ai/DeepSeek-V4-Flash-0731 # another model ``` `pi --list-models corvex` prints the context window and output reservation pi loaded for each model. To run one prompt non-interactively: ```bash theme={null} pi -p "Summarize this repository." ``` ## Compatibility notes * **Reasoning.** Both models reason before answering. Reasoning tokens count toward `maxTokens`; raise it if responses are cut off, and recompute `reserveTokens` with the formula. * **Context length.** If a session still exceeds the model's window, the gateway returns `context_length_exceeded`, and pi compacts and retries. See [Errors](/reference/errors#context_length_exceeded-400). * **Input types.** Neither model accepts image input; keep `input` set to `["text"]`. ## Related documentation * [Connect OpenCode](/integrations/opencode) — another terminal coding agent on the OpenAI-compatible surface. * [Use the OpenAI SDK](/integrations/openai-drop-in) — the same endpoint from Python or TypeScript. * [Errors](/reference/errors) — authentication, rate-limit, and validation responses. # Connect PyCharm AI Assistant to Token Factory Source: https://docs.corvex.cloud/integrations/pycharm Configure PyCharm AI Assistant with Token Factory and troubleshoot tool-calling and concurrency errors. Connect PyCharm AI Assistant to Token Factory through its native OpenAI-compatible provider. You can use it to read project files, suggest edits, and continue working in the same conversation. PyCharm 2026.2.2 with AI Assistant 262.10315.187 passed five read/edit turns with `zai-org/GLM-5.3` and the gateway tool-argument compatibility fix. This validation used a local patched gateway connected to our development endpoint; it does not establish availability of the fix on every endpoint. For a separate agent route, see [Claude Code and ACP](#claude-code-and-acp). ## Configure the native provider You need PyCharm with the JetBrains AI Assistant plugin, a Token Factory [API key](/getting-started/authentication), and a model ID from the [model catalog](/models/overview). The settings below follow the reported PyCharm 2026.2.2 configuration; labels can differ between IDE versions. 1. Open **Settings → Tools → AI Assistant → Third-party AI providers**. 2. Add an **OpenAI-compatible** provider. 3. Set the URL to `https://api.tokenfactory.corvex.cloud/v1` and enter your Token Factory API key. 4. Select `zai-org/GLM-5.3` for **Core features**. When checking tool calling, use the same model for **Instant helpers** so both request types use the intended provider. 5. Enable **Tool calling** when evaluating file reads or edits. Start with a disposable project. Ask AI Assistant to read a file and make a small edit, then continue the same conversation with another read and edit. In native Chat, use **Apply**, **Accept**, or **Create File** when offered, then save and inspect the files. A suggested snippet is not a saved file change. ## Follow-up tool calls return 400 The affected client can encode `function.arguments` twice when it replays an assistant tool call. The next request may fail with: ```text theme={null} Assistant tool call function.arguments must be a JSON object. ``` This issue is tracked by JetBrains as [LLM-30278](https://youtrack.jetbrains.com/issue/LLM-30278). An upstream code fix alone does not confirm that a particular installed plugin contains it. The gateway compatibility fix removes one redundant encoding layer when the result is a valid JSON object. If your endpoint still returns this error, contact support with your PyCharm build, AI Assistant plugin version, model ID, error text and request ID if available so we can check your endpoint's status. Do not include your API key or private project contents. ## Concurrent requests return 429 AI Assistant can send several helper requests alongside the main chat request. A `429 Concurrent request limit exceeded` error is separate from the tool argument failure above. Respect `Retry-After`, avoid immediately repeating the whole request burst. This message can come from your key's concurrency limit or a model capacity guard; it does not by itself mean your key needs a higher limit. Ask support to review the error text, timing and request ID so we can identify the guard involved. Other 429 errors can have different quota causes. ## Claude Code and ACP The [Claude Code guide](/integrations/claude-code) configures Claude Code for Token Factory. Verify that configuration in a terminal first. PyCharm can also run external agents through the Agent Client Protocol (ACP). Connecting Claude Code this way requires an ACP-compatible adapter and its configuration; Claude Code alone is not an ACP server. Follow [JetBrains' custom-agent setup](https://www.jetbrains.com/help/ai-assistant/activate-agents.html) and the adapter's instructions, and confirm it uses your Token Factory endpoint and model. Contact support for the Token Factory configuration appropriate to your IDE and adapter versions. This is a separate path from AI Assistant's native OpenAI-compatible provider. # Corvex Token Factory Source: https://docs.corvex.cloud/introduction Open-weight model APIs for production inference, with usage-based pricing and no GPU infrastructure to manage. Corvex Token Factory is a managed inference service for open-weight models. Use OpenAI- or Anthropic-compatible clients, choose a model from the live catalog, and send requests without deploying or operating GPU infrastructure. Token Factory publishes separate input and output rates for each model. The dashboard provides API-key management, a playground, and usage reporting. > [!NOTE] > > Inference usage is deducted from your available credits. New accounts receive > a one-time \$6 welcome credit, valid for one calendar year from issuance. > See [Pricing](/pricing) for rates and how to add credits. ## Data security Read about [zero data retention for inference](/security/data-security). Token Factory retains operational metadata; the Data Security page explains what is retained and how volatile prompt caching works. ## API compatibility > **[OpenAI-compatible API](/integrations/overview)** > > Use Chat Completions, the Responses API, model listing, and supported > OpenAI SDK features. > **[Anthropic-compatible API](/integrations/overview)** > > Use the Messages API, token counting, the Anthropic SDK, and Claude Code. > **[Models and pricing](/models/overview)** > > Compare the models currently served by Token Factory, including context > windows, capabilities, and per-token rates. > **[Usage API](/api-reference/openapi)** > > Query account-scoped usage from `GET /api/v1/usage` with your API key. Compatibility applies to the documented endpoints and fields. Model features such as image input, tool use, context length, and structured output vary by model; check the [model catalog](/models/overview) before relying on them. ## Start here > **[Send your first request](/getting-started/quickstart)** > > Create an API key and call `POST /v1/chat/completions`. > **[Protect your API key](/getting-started/authentication)** > > Choose the correct authentication header and store keys safely. > **[Connect a client or tool](/integrations/overview)** > > Configure an SDK or coding agent. > **[Read the API reference](/api-reference/openapi)** > > Review endpoint schemas generated from the public OpenAPI 3.1 specification. ## Community and support > **[Join the Discord](https://discord.gg/BUJVNYWQbB)** > > Ask questions in #get-help and share feedback in #feedback. No invitation > required. > **[Contact support](/reference/faq#how-do-i-contact-support)** > > Use the dashboard support form or email for account and billing questions. # DeepSeek V4 Flash 0731 Source: https://docs.corvex.cloud/models/deepseek-ai/DeepSeek-V4-Flash-0731 Text, code, reasoning, and tool use with a 1,048,576-token context window on Corvex Token Factory. DeepSeek V4 Flash 0731 is DeepSeek's open-weight model for text, code, reasoning, and tool use. Token Factory serves this version with a 1,048,576-token context window. Model ID: `deepseek-ai/DeepSeek-V4-Flash-0731` ## Specifications * **Context window:** 1,048,576 tokens (1M) * **Maximum output:** 1,048,576 tokens, subject to the remaining context space * **Input:** text * **Output:** text * **Capabilities:** chat, reasoning, coding, tool use, JSON mode, structured output * **Sampling parameters:** `temperature`, `top_p`, `stop`, `max_tokens` * **License:** MIT * **Model repository:** [deepseek-ai/DeepSeek-V4-Flash-0731](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-0731) Input and reserved output share the context window: `input_tokens + max_tokens` must fit within 1,048,576 tokens. Image input is not supported. Include the `-0731` suffix when selecting this version. ## Pricing | Direction | Rate (USD) | | - | - | | Input | \$0.14 / 1M tokens | | Cached input | \$0.07 / 1M tokens | | Output | \$0.28 / 1M tokens | Inference usage is deducted from your available credits at these rates. See [Pricing](/pricing). ## Send a request ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/chat/completions \ -H "Authorization: Bearer ${CORVEX_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-ai/DeepSeek-V4-Flash-0731", "messages": [ {"role": "user", "content": "Plan a zero-downtime database migration."} ] }' ``` Set `stream: true` for streamed responses. See the [API reference](/api-reference/openapi) for request fields and the [integration guides](/integrations/overview) for SDKs and developer tools. [Open DeepSeek V4 Flash 0731 in the Token Factory playground](https://tokenfactory.corvex.cloud/app/playground/deepseek-ai/DeepSeek-V4-Flash-0731). # Models Source: https://docs.corvex.cloud/models/overview Open-weight models currently served by Corvex Token Factory. Corvex Token Factory currently serves the models below. Both support the OpenAI-compatible Chat Completions API and the Anthropic-compatible Messages API. | Model | Context | Image input | Input rate | Output rate | Capabilities | | - | - | - | - | - | - | | [GLM 5.3](/models/zai-org/GLM-5.3) | 393,216 tokens (384K) | No | \$1.40 / 1M | \$4.40 / 1M | chat, reasoning, coding, tool use, structured output | | [DeepSeek V4 Flash 0731](/models/deepseek-ai/DeepSeek-V4-Flash-0731) | 1,048,576 tokens (1M) | No | \$0.14 / 1M | \$0.28 / 1M | chat, reasoning, coding, tool use, structured output | Both models accept text and support tool calls, JSON mode, and structured output. DeepSeek V4 Flash 0731 has the larger context window and lower published token rates. Each model page lists its limits and sample request. Neither model accepts image input. ## Query the live catalog `GET /v1/models` is public and returns the models currently available, their capabilities, context limits, and published rates: ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/models ``` Use the returned `id` exactly as shown in inference requests. Model IDs are case-sensitive and use `namespace/model` format. > [!NOTE] > > Inference usage is deducted from your available credits at the rates above. > See [Pricing](/pricing) for welcome credits and how to add more credits. # GLM 5.3 Source: https://docs.corvex.cloud/models/zai-org/GLM-5.3 Text, code, reasoning, and tool use with a 393,216-token context window on Corvex Token Factory. GLM 5.3 is Z.AI's open-weight model for text, code, reasoning, and tool use. Token Factory serves it with a 393,216-token context window. Model ID: `zai-org/GLM-5.3` ## Specifications * **Context window:** 393,216 tokens (384K) * **Maximum output:** 393,216 tokens, subject to the remaining context space * **Input:** text * **Output:** text * **Capabilities:** chat, reasoning, coding, tool use, JSON mode, structured output * **Sampling parameters:** `temperature`, `top_p`, `stop`, `max_tokens` * **License identifier:** `glm-5.3` * **Model repository:** [zai-org/GLM-5.3](https://huggingface.co/zai-org/GLM-5.3) Input and reserved output share the context window: `input_tokens + max_tokens` must fit within 393,216 tokens. Image input is not supported. ## Pricing | Direction | Rate (USD) | | - | - | | Input | \$1.40 / 1M tokens | | Cached input | \$0.26 / 1M tokens | | Output | \$4.40 / 1M tokens | Inference usage is deducted from your available credits at these rates. See [Pricing](/pricing). ## Send a request ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/chat/completions \ -H "Authorization: Bearer ${CORVEX_API_KEY}" \ -H "Content-Type: application/json" \ -d '{ "model": "zai-org/GLM-5.3", "messages": [ {"role": "user", "content": "Refactor this Go function and explain each change."} ] }' ``` Set `stream: true` for streamed responses. See the [API reference](/api-reference/openapi) for request fields and the [integration guides](/integrations/overview) for SDKs and developer tools. [Open GLM 5.3 in the Token Factory playground](https://tokenfactory.corvex.cloud/app/playground/zai-org/GLM-5.3). # Pricing Source: https://docs.corvex.cloud/pricing Per-token rates, prepaid billing, and account credits for Corvex Token Factory. Corvex Token Factory publishes separate rates for input tokens, cached input tokens, and output tokens. Rates are in US dollars per million tokens. > [!NOTE] > > Inference usage is deducted from your available credits at the published rates > below. Check your balance and add credits with a card in the > [Token Factory dashboard](https://tokenfactory.corvex.cloud/app/billing). ## Per-million-token rates | Model | Input | Cached input | Output | Model details | | - | - | - | - | - | | GLM 5.3 | \$1.40 / 1M | \$0.26 / 1M | \$4.40 / 1M | [View model](/models/zai-org/GLM-5.3) | | DeepSeek V4 Flash 0731 | \$0.14 / 1M | \$0.07 / 1M | \$0.28 / 1M | [View model](/models/deepseek-ai/DeepSeek-V4-Flash-0731) | The public model catalog is the programmatic source for current rates. Each model lists `input_rate_cents_per_mtok`, `cached_input_rate_cents_per_mtok`, and `output_rate_cents_per_mtok`, and the same prices per token in `pricing`: ```bash theme={null} curl https://api.tokenfactory.corvex.cloud/v1/models ``` The documentation CI compares the rates on this site with the live catalog when the catalog is reachable. ## Cached input tokens When a request starts with a prompt prefix that the model recently processed, the serving engine reuses that work instead of computing it again. Those input tokens are cached input tokens, billed at the cached input rate. Caching is automatic: there is no request parameter, and you do not need `cache_control`. Requests that share a long, unchanged prefix, such as a system prompt or earlier conversation turns, get the most cached input tokens. Cached input pricing applies to requests that start at or after 2026-10-27 12:00 UTC. Earlier requests were billed at the input rate for all input tokens. Every response reports the cached share of its input tokens: | API | Input tokens | Cached input tokens | | - | - | - | | Chat Completions, Completions | `usage.prompt_tokens` | `usage.prompt_tokens_details.cached_tokens` | | Responses | `usage.input_tokens` | `usage.input_tokens_details.cached_tokens` | | Messages | `usage.input_tokens` + `usage.cache_read_input_tokens` | `usage.cache_read_input_tokens` | In the Messages API, `input_tokens` does not include the cached input tokens, as in Anthropic's API. ## Estimate usage cost Calculate the usage cost of a request as: ```text theme={null} (uncached input tokens / 1,000,000 × input rate) + (cached input tokens / 1,000,000 × cached input rate) + (output tokens / 1,000,000 × output rate) ``` Uncached input tokens are the input tokens minus the cached input tokens. For example, a request on GLM 5.3 with 1,000 input tokens, 600 of them cached, and 500 output tokens costs `$0.002916`: ```text theme={null} (400 / 1,000,000 × $1.40) + (600 / 1,000,000 × $0.26) + (500 / 1,000,000 × $4.40) = $0.000560 + $0.000156 + $0.002200 = $0.002916 ``` The same request with no cached input tokens costs `$0.00360`. The response `usage` object reports the token counts needed for this calculation. Account-level totals are available in the [Token Factory dashboard](https://tokenfactory.corvex.cloud/app/usage) and from `GET /api/v1/usage`. ## Credits and billing New accounts receive a **one-time \$6 welcome credit**, valid for one calendar year from issuance. It does not renew when used up. Accounts created before September 15, 2026 received a **\$2,500 Alpha transition credit** on September 28, 2026. It expires on March 28, 2027. Check your dashboard for your current balance and credit activity. Inference requires an available credit balance. If your credits run out, add more through the dashboard to resume requests. See [insufficient credits](/reference/errors#insufficient-credits-402) for the API error and retry guidance. For dedicated single-tenant GPU capacity, contact Corvex about [Reserved Endpoints](/reference/faq#how-do-i-contact-support). [Open Corvex Token Factory](https://tokenfactory.corvex.cloud/app) # Error Reference Source: https://docs.corvex.cloud/reference/errors Stable Corvex Token Factory error codes, causes, remediation, and retry guidance. The error envelope and `code` values below are stable for the Token Factory API. New codes may be added without changing existing code meanings. ## Quick reference | HTTP | Code | Category | Retryable? | | - | - | - | - | | 400 | `bad_request` | Request | No | | 400 | `context_length_exceeded` | Request | No; compact or shrink the input, then retry | | 401 | `invalid_api_key` | Authentication | No | | 402 | `insufficient_credits` | Billing | No; resolve the billing or quota condition first | | 403 | `virtual_key_blocked` | Authentication | No | | 403 | `model_blocked` | Authentication | No | | 404 | `model_unavailable` | Catalog | No | | 404 | `not_found` | Request | No | | 429 | `rate_limited` | Throttling | Yes; honor `Retry-After` | | 429 | `token_limited` | Throttling | Yes; honor `Retry-After` | | 500 | `server_error` | Server | Yes; use exponential backoff | | 502 | `service_unavailable` | Capacity | Yes; use exponential backoff | | 502 | `server_error` | Server | Yes; use exponential backoff | | 503 | `model_unavailable` | Catalog | Yes; the model is temporarily not serving | | 503 | `service_unavailable` | Capacity | Yes; use exponential backoff | An HTTP `502` uses `service_unavailable` when the gateway cannot reach the model backend and `server_error` when the backend returns `502`. Both are retryable. ## Categories | Category | Meaning | | - | - | | **Authentication** | The key is missing, invalid, disabled, or not allowed for the requested scope. | | **Billing** | A paid balance, quota, or configured spend cap is exhausted. | | **Capacity** | The requested service or model is temporarily unavailable. | | **Catalog** | The requested model is unknown or not currently serving. | | **Request** | The request path or body is invalid. | | **Server** | An unexpected platform or model-backend failure occurred. | | **Throttling** | A request or token-rate limit was exceeded. | ## Error envelopes The endpoint family decides the envelope shape (no content negotiation): the OpenAI-compatible endpoints return the OpenAI-style envelope below, and the Anthropic-compatible endpoints return the [Anthropic-style envelope](#anthropic-endpoints-/v1/messages). The stable `code` catalog is shared by both. ### OpenAI endpoints All Token Factory OpenAI-family inference endpoints (`/v1/chat/completions`, `/v1/completions`, `/v1/embeddings`, `/v1/models`, `/v1/responses`) return errors as `Content-Type: application/json` with this shape: ```json theme={null} { "error": { "code": "invalid_api_key", "message": "Invalid API key", "type": "authentication_error" } } ``` For `invalid_request_error`s where the failing field is identifiable, the gateway additionally emits an optional `param`: ```json theme={null} { "error": { "code": "bad_request", "message": "model field is required", "type": "invalid_request_error", "param": "model" } } ``` * **`code`** — stable, snake\_case, machine-readable slug. **Match on this** in your client code. Codes do not change once published. * **`message`** — human-readable string safe to surface in UIs or logs. The wording may change between releases — do not parse it. * **`type`** — OpenAI-style category enum: `invalid_request_error`, `authentication_error`, `permission_error`, `not_found_error`, `rate_limit_error`, `server_error`, `service_unavailable`. Used by the OpenAI Python and TypeScript SDKs to pick the exception class (`AuthenticationError`, `RateLimitError`, etc.). Safe to ignore if you match on `code` directly. * **`param`** *(optional)* — for `invalid_request_error`s, the request field at fault (`"model"`, `"input"`, `"messages"`, etc.). Omitted when no specific field is identifiable, and omitted on non-validation errors. Mirrors OpenAI's error-object shape so the OpenAI Python and TypeScript SDKs surface it on `BadRequestError.param`. * **HTTP status** — conveys the broad category (auth, throttling, server, etc.). The `code` is the precise identity within that category. * **`x-request-id`** *(response header)* — present on **every** response, including all errors (401/403/404 and every 4xx/5xx). Log it and quote it in support requests so a failure can be correlated end-to-end. > [!NOTE] > > These endpoints return an OpenAI-compatible JSON envelope under > `application/json`, not an RFC 7807 `application/problem+json` document. ### Anthropic endpoints (/v1/messages) The Anthropic-compatible endpoints (`POST /v1/messages`, `POST /v1/messages/count_tokens`) return every 4xx/5xx as `Content-Type: application/json` with the Anthropic-style envelope, extended with the same stable `code` catalog: ```json theme={null} { "type": "error", "error": { "type": "authentication_error", "message": "Invalid API key", "code": "invalid_api_key" }, "request_id": "req_abc123" } ``` * **`error.type`** — Anthropic's published category enum: `invalid_request_error`, `authentication_error`, `permission_error`, `not_found_error`, `request_too_large`, `rate_limit_error`, `api_error`, `overloaded_error`. The Anthropic Python and TypeScript SDKs use it (with the HTTP status) to pick the exception class (`AuthenticationError`, `RateLimitError`, etc.). Relative to the OpenAI-style `type`, two values map: `server_error` → `api_error` and `service_unavailable` → `overloaded_error`; the rest are identical. * **`error.code`** — the same stable, snake\_case catalog documented on this page. **Match on this** for precise handling — e.g. `rate_limited` vs `token_limited` both surface as `rate_limit_error`, and only `code` distinguishes them. * **`error.message`** — human-readable; wording may change between releases. There is no `param` field on this surface — the failing request field is named in the message text instead. * **`request_id`** — echoes your `X-Request-Id` request header (also returned as a response header) so you can correlate to gateway logs. Omitted when the request carried no `X-Request-Id`. * **HTTP status** — unchanged from the table below; Token Factory does not adopt Anthropic's 529 (`overloaded_error` ships on 503) or 413 (oversized requests surface as 400 `bad_request`). Errors raised by an upstream engine on these endpoints are normalized into this same envelope before reaching you — clients never see a raw engine error body (on either endpoint family). For example, an upstream `502`/`504` surfaces as `api_error` and a `503` as `overloaded_error`: ```json theme={null} { "type": "error", "error": { "type": "api_error", "message": "upstream service error", "code": "server_error" }, "request_id": "req_abc123" } ``` For `stream: true` requests, failures that occur before the stream starts return this JSON envelope with the error status (not an SSE body). ## Codes Each entry below documents: * **Cause** — what triggered this error. * **Remediation** — what the API consumer should do. * **Retry** — whether the SDK retries this automatically, and how. * **Where to look** — dashboards, settings, or support flow to investigate. *** ### invalid\_api\_key (401) **Cause.** No `Authorization: Bearer ` header, malformed header, or the key value is unknown to the gateway. **Remediation.** Create or rotate an API key (`sk-corvex-*`) in the dashboard and send it as `Authorization: Bearer sk-corvex-...` (or as an `x-api-key` header on the Anthropic `/v1/messages` surface). See [Authentication](/getting-started/authentication) for the key types. **Retry.** No. This is a non-retryable client error. **Where to look.** Dashboard → API Keys. Revoked keys appear with status `disabled`; expired keys must be replaced. ```json theme={null} { "error": { "code": "invalid_api_key", "message": "Invalid API key", "type": "authentication_error" } } ``` *** ### virtual\_key\_blocked (403) **Cause.** The API key has been deactivated. **Remediation.** Create a new API key in the dashboard. If access remains blocked, contact [Token Factory support](/reference/faq#how-do-i-contact-support). **Retry.** No. **Where to look.** Dashboard → API Keys → key status. Audit log will show the deactivation event. ```json theme={null} { "error": { "code": "virtual_key_blocked", "message": "Virtual key is deactivated", "type": "permission_error" } } ``` *** ### model\_blocked (403) **Cause.** The key is active, but the requested model is not among the models allowed for your account or key. **Remediation.** Use a model your account is allowed to call (list them with `GET /v1/models`), or contact [Token Factory support](/reference/faq#how-do-i-contact-support) about model access. **Retry.** No. **Where to look.** Dashboard → API Keys → key detail → Allowed models. ```json theme={null} { "error": { "code": "model_blocked", "message": "Model not allowed for this virtual key", "type": "permission_error" } } ``` *** ### model\_unavailable (404) > [!NOTE] > > The HTTP status determines how to handle this code. A 404 means the model is > not in the public catalog and is not retryable. A 503 means the model is in the > catalog but temporarily not serving; retry that response with bounded > exponential backoff. **Cause.** The requested model identifier (e.g. `some-org/Nonexistent-Model`) is not in the public catalog. **Remediation.** List available models via `GET /v1/models` and pick a model returned by the gateway. **Retry.** No for this 404 response. **Where to look.** The models list endpoint: `GET /v1/models`. ```json theme={null} { "error": { "code": "model_unavailable", "message": "Model not available", "type": "not_found_error" } } ``` *** ### not\_found (404) **Cause.** The request reached a valid inference surface prefix (`/v1/…` or `/openai/v1/…`) but no endpoint matched — e.g. `GET /v1/models/{id}` or a typo like `GET /v1/bogus`. Distinct from `model_unavailable`, which means the endpoint matched but the model is not serveable. **Remediation.** Check the path against the [API reference](/api-reference/openapi). Unknown `/v1/*` paths return this structured envelope rather than a bare string, so SDK error parsing stays intact. **Retry.** No. This is a non-retryable client error. **Where to look.** Your request URL. The `x-request-id` response header correlates the 404 in the gateway logs. ```json theme={null} { "error": { "code": "not_found", "message": "unknown endpoint: /v1/bogus", "type": "not_found_error" } } ``` *** ### rate\_limited (429) **Cause.** Your account's request-rate limit or an API key's concurrent-request limit was reached, or the requested model is temporarily at capacity. **Remediation.** Slow down. If the response includes a `Retry-After` header (in seconds), wait that long before retrying. Otherwise back off exponentially. **Retry.** **Yes.** Honor `Retry-After` when present and otherwise use exponential backoff. SDK defaults vary by package and version; configure the attempt count explicitly for production clients. **Where to look.** Check your [account limits](https://tokenfactory.corvex.cloud/app/settings/limits) in the dashboard. To request higher limits, contact [Token Factory support](/reference/faq#how-do-i-contact-support). ```json theme={null} { "error": { "code": "rate_limited", "message": "Request rate limit exceeded", "type": "rate_limit_error" } } ``` *** ### token\_limited (429) **Cause.** A configured token-usage limit for your account was exceeded. This limit is separate from the request-rate limit. **Remediation.** Same as `rate_limited`. The response `code` is `token_limited` (not `rate_limited`), so you can branch on which limit was hit; the SDKs surface both as a `RateLimitError`. **Retry.** **Yes**, same retry policy as `rate_limited`. Honor `Retry-After`. **Where to look.** Review token usage in the dashboard. For questions about a configured token limit, contact [Token Factory support](/reference/faq#how-do-i-contact-support). ```json theme={null} { "error": { "code": "token_limited", "message": "Token rate limit exceeded", "type": "rate_limit_error" } } ``` *** ### insufficient\_credits (402) **Cause.** Your account's available credit balance has reached zero, a hard quota has been exhausted, or a configured monthly spend cap has been reached. **Remediation.** For an exhausted credit balance, add credits through the [dashboard](https://tokenfactory.corvex.cloud/app/billing). For quota or spend-cap exhaustion, contact [Token Factory support](/reference/faq#how-do-i-contact-support) or wait for the configured reset window. **Retry.** No. Retrying before the billing or quota condition is resolved will return the same error. Match on `code` (`insufficient_credits`), not `type`: on the OpenAI surface this carries `type: permission_error` (there is no billing-specific type). **Where to look.** Check the dashboard's billing and usage sections, or contact [Token Factory support](/reference/faq#how-do-i-contact-support). ```json theme={null} { "error": { "code": "insufficient_credits", "message": "Workspace has insufficient credits", "type": "permission_error" } } ``` *** ### bad\_request (400) **Cause.** The request body is malformed, missing required fields, or fails server-side validation. Examples: missing `model`, missing `messages` for chat completions, or invalid JSON. Common validation cases: | Condition | Endpoint | `param` | Corrective action | | - | - | - | - | | A chat or embedding model is sent to the legacy text-completions API | `POST /v1/completions` | `model` | Use `/v1/chat/completions` or a model with text-completion support. | | A model without embedding support is used | `POST /v1/embeddings` | `model` | Choose an embedding-capable model. No embedding model is currently deployed. | | Image content is sent to a text-only model | Chat or Messages API | `messages` | Use a vision-capable model or remove the image block. | | `max_tokens` is negative or not an integer | Chat Completions, legacy Completions, or Messages API | `max_tokens` | Send a non-negative integer or omit the optional field. | | `max_output_tokens` is negative or not an integer | Responses API | `max_output_tokens` | Send a non-negative integer or omit the optional field. | Integer-valued numbers such as `5.0` and `1e3`, and the value `0`, are accepted. **Remediation.** Read the `message` for the specific field at fault and correct the request. For the legacy-completions case, call `/v1/chat/completions` (recommended), or switch the `model` to a text-completion model. The [API reference](/api-reference/openapi) documents the public request schemas. **Retry.** No. Retrying the same payload will return the same error. **Where to look.** Validate the request against the public OpenAPI schema and call `GET /v1/models` to check model capabilities. ```json theme={null} { "error": { "code": "bad_request", "message": "Model is required", "type": "invalid_request_error" } } ``` ```json theme={null} { "error": { "code": "bad_request", "message": "model 'zai-org/GLM-5.3' does not support /v1/completions; use /v1/chat/completions instead", "type": "invalid_request_error", "param": "model" } } ``` ```json theme={null} { "error": { "code": "bad_request", "message": "model 'zai-org/GLM-5.3' does not support the /v1/embeddings endpoint", "type": "invalid_request_error", "param": "model" } } ``` ```json theme={null} { "error": { "code": "bad_request", "message": "messages: required", "type": "invalid_request_error", "param": "messages" } } ``` ```json theme={null} { "error": { "code": "bad_request", "message": "model 'zai-org/GLM-5.3' does not support image input", "type": "invalid_request_error", "param": "messages" } } ``` ```json theme={null} { "error": { "code": "bad_request", "message": "max_tokens must be a non-negative integer", "type": "invalid_request_error", "param": "max_tokens" } } ``` ```json theme={null} { "error": { "code": "bad_request", "message": "max_output_tokens must be a non-negative integer", "type": "invalid_request_error", "param": "max_output_tokens" } } ``` *** ### context\_length\_exceeded (400) **Cause.** The request's input (or input + `max_tokens`) exceeds the model's context window. The gateway surfaces this as a stable code whenever the upstream engine reports a context-length rejection — on both endpoint families, and including engine failures initially reported as a 5xx that the gateway downgrades to the spec-correct 400. The `message` carries the engine's own token accounting (e.g. the model's maximum context length and your requested totals) where the engine reports it. **Remediation.** Reduce the input: compact the conversation, drop or truncate older turns or tool outputs, or lower `max_tokens`. For agentic clients (Claude Code and similar harnesses), treat this code as the compact-and-retry signal. To size a session up front, read the model's limits from `GET /v1/models`: `context_window` (total), `max_output_tokens` (the model's completion cap), and — only for a model whose output cap sits below its window — `max_input_tokens` (`context_window − max_output_tokens`). That last value is the input ceiling for a request that reserves the full output cap; a request with a smaller `max_tokens` has correspondingly more input room, since the engine enforces `input + max_tokens ≤ context_window`. **Retry.** No. Retrying the same payload returns the same error. Retry only after compacting or otherwise shrinking the input. **Where to look.** The model's limits on `GET /v1/models` (`context_window`, `max_output_tokens`, `max_input_tokens`), and the `message` field for the engine's token accounting. OpenAI envelope: ```json theme={null} { "error": { "code": "context_length_exceeded", "message": "prompt tokens + max_tokens exceeds the model's maximum context length of 262144", "type": "invalid_request_error" } } ``` Anthropic envelope: ```json theme={null} { "type": "error", "error": { "type": "invalid_request_error", "message": "prompt tokens + max_tokens exceeds the model's maximum context length of 262144", "code": "context_length_exceeded" }, "request_id": "req_abc123" } ``` *** ### server\_error (500, 502) **Cause.** An unexpected server-side failure: a downstream component crashed, a database call failed, or the gateway hit an internal panic. On HTTP 502, this code means the upstream engine itself answered 502 and the gateway normalized its error body into the standard envelope. **Remediation.** Retry with exponential backoff. If the error persists after the configured retries, capture a sample response and its `x-request-id` header before contacting support. **Retry.** **Yes.** Use exponential backoff and a bounded retry count. SDK defaults vary by package and version. **Where to look.** Quote the `x-request-id` response header in a support request so the failure can be correlated. ```json theme={null} { "error": { "code": "server_error", "message": "Internal server error", "type": "server_error" } } ``` *** ### service\_unavailable (502, 503) **Cause.** The platform is temporarily over capacity, or the requested model is still starting up and not yet ready to serve. On HTTP 502, the gateway could not reach the model backend at all. **Remediation.** Retry with exponential backoff. Honor `Retry-After` when present. **Retry.** **Yes**, same policy as `server_error`. **Where to look.** Confirm that `GET /v1/models` lists the model. If it does not, choose an available model; if it does, retry after the temporary failure. ```json theme={null} { "error": { "code": "service_unavailable", "message": "Service temporarily unavailable", "type": "service_unavailable" } } ``` *** ## Retry semantics The official OpenAI and Anthropic SDKs include automatic retry behavior, but the exact statuses, delays, and attempt counts depend on the SDK and version. For Token Factory responses: * **Retry:** HTTP `429` (`rate_limited`, `token_limited`) and `5xx` responses, including a temporary `503 model_unavailable`. * **Do not retry:** Other `4xx` responses, including `bad_request`, `context_length_exceeded`, `invalid_api_key`, `virtual_key_blocked`, `model_blocked`, the `404` form of `model_unavailable`, and `insufficient_credits`. * **Backoff.** Use exponential backoff with a bounded maximum delay and attempt count. Configure these values for the latency and reliability needs of your application. * **`Retry-After` header.** When the server returns `Retry-After`, the SDK waits at least that long before retrying. The header takes precedence over the default exponential backoff. Both `rate_limited` and `token_limited` are surfaced by the SDKs as a `RateLimitError` (a subclass of `APIError`). To tell which limit was hit, match on the wire `error.code` (`rate_limited` vs `token_limited`) — the OpenAI `error.type` is `rate_limit_error` for both. Use the `Retry-After` response header to decide how long to wait. ## Prompt caching (`cache_control`) The Anthropic Messages surface (`POST /v1/messages`, `POST /v1/messages/count_tokens`) accepts `cache_control` annotations on system and message content blocks. Token Factory does not interpret the annotation as a request to cache content. When the model backend reports cache usage, Token Factory passes those values through. When the backend omits them, the response includes explicit zero values in the non-streaming `usage` object or streaming `message_start` event: ```json theme={null} "usage": { "input_tokens": 32, "output_tokens": 10, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0 } ``` A zero value preserves the Anthropic-compatible usage shape and does not indicate an error. `cache_read_input_tokens` counts the input tokens that the engine served from its prefix cache; `input_tokens` does not include them. Cached input tokens are billed at the model's cached input rate, and no cache write is charged. See [Pricing: Cached input tokens](/pricing#cached-input-tokens). ## Related documentation * [DeepSeek Harness](/integrations/deepseek-harness) — setup and troubleshooting. * [API Reference](/api-reference/openapi) — endpoint-by-endpoint request/response schemas, including error responses per endpoint. * [Authentication](/getting-started/authentication) — virtual keys (`sk-corvex-*`) for inference. * [Quickstart](/getting-started/quickstart) — first inference call end-to-end. # Token Factory FAQ — Inference, Data Retention, and Support Source: https://docs.corvex.cloud/reference/faq Answers about Token Factory models, open-weight model API data retention, contractual terms, rate limits, and support. Find answers to common questions about Corvex Token Factory. For data handling, read the [Data Security page](/security/data-security), including retained operational metadata and volatile prompt caching. ## How do I get an API key and make my first call? > **Create a key and send a request** > > Sign in to the [Token Factory dashboard](https://tokenfactory.corvex.cloud/app), > create an API key, and follow the [Quickstart](/getting-started/quickstart). > New accounts receive a one-time \$6 welcome credit, valid for one calendar year > from issuance. Usage is deducted from your available credits; add more in the > dashboard when needed. See [Pricing](/pricing) for details. ## Can I switch without rewriting my code? > **Configure an existing client** > > For supported OpenAI SDK calls, set the base URL to > `https://api.tokenfactory.corvex.cloud/v1` and use your Token Factory API key. > Compatibility depends on the endpoint, fields, and model features your > application uses. The [OpenAI SDK guide](/integrations/openai-drop-in) includes > Python and TypeScript examples and compatibility boundaries. ## What happens to my prompts? > **Prompt handling and retained metadata** > > Token Factory processes prompts and generations in volatile memory; prompt > caching can keep prompt data and KV caches in memory for several minutes. > Prompt and generation data are not logged or stored persistently by default. > Operational metadata, such as token counts, is retained. Read the > [Data Security page](/security/data-security) for the full retention policy. ## Does ZDR apply per model? > **Retention policy across models** > > Token Factory's default zero data retention policy applies to its served > open-weight models without a separate per-model opt-in. Operational metadata is > retained. Review the [Data Security page](/security/data-security) before relying > on ZDR for a workload. ## What models do you support, and can I request one? > **Current models and model requests** > > Token Factory currently serves `zai-org/GLM-5.3` and > `deepseek-ai/DeepSeek-V4-Flash-0731`. Check the [model catalog](/models/overview) > or `GET https://api.tokenfactory.corvex.cloud/v1/models` for current availability > and capabilities. Send requests for other models through > [Token Factory support](#how-do-i-contact-support). ## What are the rate limits? > **Request limits and retries** > > Token Factory allows **60 requests per minute per account**, shared across > all your API keys. > > If you reach a limit, the API returns HTTP 429. Honor `Retry-After` when present; > otherwise, retry with exponential backoff. Requests may also be temporarily limited when > model capacity is busy. > > View your limits in the [dashboard](https://tokenfactory.corvex.cloud/app/settings/limits). > For higher limits, contact [Token Factory support](#how-do-i-contact-support). ## Do you offer embeddings? > **Embedding model availability** > > Token Factory does not currently serve an embedding model. The presence of an > embeddings endpoint does not mean a suitable model is available. Check the > [model catalog](/models/overview) before choosing an endpoint and model. ## How do I contact support? > **Open the Token Factory support form** > > Sign in to the [Token Factory dashboard](https://tokenfactory.corvex.cloud/app) > and select **Support** in the sidebar to open the **Contact us** form. The form > uses your signed-in account to identify your request. > > If you cannot sign in or have a pre-sales question, email > [tokenfactory-support@corvex.ai](mailto:tokenfactory-support@corvex.ai). > For API errors, include the request ID, model, and error code. Do not send API > keys or sensitive prompt content. > **Ask the community on Discord** > > Join the Token Factory Discord at > [discord.gg/BUJVNYWQbB](https://discord.gg/BUJVNYWQbB). No invitation is > required. Post questions in **#get-help** and feature requests or bug reports > in **#feedback**, one thread per topic. The team reads both channels every > business day. > > Discord channels are public. Do not post API keys, billing details, or account > identifiers there; use the support form or email for those. # Data Security and Zero Data Retention for Inference Source: https://docs.corvex.cloud/security/data-security Learn how Corvex Token Factory handles inference data, retains operational metadata, and protects its systems through technical and operational controls. Corvex Token Factory processes open-weight model inference requests. This page explains how request content and operational metadata are handled and how Corvex protects the systems that process them. For security documentation and audit reports, visit the [Corvex Trust Center](https://trust.corvex.ai/). ## Zero Data Retention Token Factory's zero data retention (ZDR) policy means prompt and generation data are not logged or stored persistently by default, without explicit user opt-in. Corvex retains operational metadata, such as token counts, to deliver the service. Prompt and generation data exist in volatile memory for the duration of a request. If prompt caching is active, some prompt data and associated key-value (KV) caches can remain in volatile memory for several minutes. ## Technical Safeguards * **Device security:** Access to sensitive Corvex systems requires approved, secured devices and strong authentication. * **Network protection:** Firewalls and security groups restrict inbound and outbound traffic. DDoS protections help maintain availability across core services. * **Monitoring and detection:** Real-time monitoring and anomaly detection alert our team to suspicious activity. * **Vulnerability management:** Ongoing vulnerability scanning and patching help identify and address known security risks. ## Operational Security * **Security testing:** Regular penetration testing evaluates security controls and identifies areas for remediation. * **Incident response:** A documented response plan guides investigation, containment, remediation, and customer notification when required. * **Employee access:** Production access is limited to authorized personnel who need it for their work. Access permissions are reviewed periodically. * **Vendor review:** Vendors and subprocessors undergo security due diligence and are subject to contractual security obligations. ## Compliance and Security Review Corvex provides security documentation and audit reports to support customer security and compliance assessments. Visit the [Corvex Trust Center](https://trust.corvex.ai/) for current reports and details of their scope. For requirements specific to your use of Token Factory, contact [Token Factory support](/reference/faq#how-do-i-contact-support).