---
name: opencheap
description: Every major AI model behind one OpenAI-compatible API, routed to the cheapest healthy provider. Use it to call models, or to resell them under your user's own brand, domain and prices and run that business for them.
---

# OpenCheap

You are setting up OpenCheap for your user. OpenCheap sells every major model (Claude, GPT, Gemini, Llama, DeepSeek and more) through one OpenAI-compatible API; popular models usually cost less than their public list price. Your user can use it, or sell it from api.<their domain> at their own prices and keep the difference. You can do all of it from here.

If your user's message includes an OpenCheap key (kl_rs_…), they just made their account: start with "Start here" below, and use that key, not a wallet.

If the message names the MCP server and says to sign in in the browser, do not ask for a key and do not invent one. Add the server with no Authorization header, then tell your user to allow OpenCheap in the browser window that opens:
   - Claude Code: claude mcp add --transport http opencheap https://app.opencheap.si/api/v1/mcp --scope user
   - Cursor: in ~/.cursor/mcp.json, under "mcpServers": "opencheap": {"url": "https://app.opencheap.si/api/v1/mcp"}
   - Claude Desktop: {"mcpServers": {"opencheap": {"command": "npx", "args": ["-y", "mcp-remote", "https://app.opencheap.si/api/v1/mcp"]}}}

## Start here: your user gave you a key (kl_rs_…)

1. Add OpenCheap's MCP server with that key, written as KEY below. Keep it out of anything you commit. Cursor and Claude can instead sign in in the browser, with no header at all: use that when the message says so.
   - Claude Code: claude mcp add --transport http opencheap https://app.opencheap.si/api/v1/mcp --header "Authorization: Bearer KEY" --scope user
   - Codex: add export OPENCHEAP_MCP_KEY=KEY to the shell profile, then run codex mcp add opencheap --url https://app.opencheap.si/api/v1/mcp --bearer-token-env-var OPENCHEAP_MCP_KEY
   - Cursor: in ~/.cursor/mcp.json, under "mcpServers": "opencheap": {"url": "https://app.opencheap.si/api/v1/mcp", "headers": {"Authorization": "Bearer KEY"}}
   - OpenCode: in opencode.json, under "mcp": "opencheap": {"type": "remote", "url": "https://app.opencheap.si/api/v1/mcp", "headers": {"Authorization": "Bearer KEY"}}
   - OpenClaw: in ~/.openclaw/openclaw.json, under "mcp" then "servers": "opencheap": {"url": "https://app.opencheap.si/api/v1/mcp", "transport": "streamable-http", "headers": {"Authorization": "Bearer KEY"}}
   - Any other app: its MCP settings, URL https://app.opencheap.si/api/v1/mcp, header Authorization: Bearer KEY.
2. Check the key now: GET https://app.opencheap.si/api/v1/balance with Authorization: Bearer KEY. Tell your user it worked, and their balance.
3. The MCP tools load the next time your app starts (Claude Code: /mcp, or a restart). Until then the REST API takes the same key: https://app.opencheap.si/api/v1/openapi.json.
4. Offer the first things to do: check the balance, find a model, make a model key for this codebase with a monthly limit (create_key, or POST https://app.opencheap.si/api/v1/keys with monthlyLimitUsd), or start selling (section D).

Otherwise, first ask your user what they want, then follow the matching steps:

1. Call chat models now, no account: section A (decisions models need a key: sections B and C).
2. Manage an account (keys, balance, usage): sections B and C.
3. Group keys by app, environment or client, each with its own limit and usage: sections B, C and E.
4. Sell under their own brand: sections B, C and D.

## A. Call a model, no account needed

Catalog, no key: GET https://app.opencheap.si/api/v1/models. The catalog is large: find a model with q (for example q=claude or q=llama), which matches the id or name, instead of reading every page. Each model has price.promptUsdPerM and price.completionUsdPerM, the wholesale rate per million tokens. Pages are 100; pass nextCursor back as cursor. uncensored: true marks a model with fewer content restrictions; it is a tag, not a filter (OpenCheap filters nothing), so tell your user when a model you suggest is uncensored.

Each model has a kind. kind "chat" is called at https://api.opencheap.si/v1/chat/completions in OpenAI format. kind "decisions" answers typed questions about a text at its own endpoint: see "Decisions" below. Skip a model whose kind you do not know.

Free models (free: true in the catalog, price 0) work with any key, even one with no balance. A free chat model allows 10 requests a minute and 200 a day per key, prompts up to 32k tokens and replies up to 4,096 tokens. A free decisions model is free for its smallest inputs only (up to its first price.longContext band), with no free-tier caps while it is free; a larger input is billed at that band's price and needs a balance. To chat on a free model, pick one with free: true and kind: "chat". freeUntil, when set, is the day (00:00 UTC) a free model starts to be billed at its price. Over a limit the answer is 429 (rate_limited or free_tier_exhausted) with Retry-After; a paid model on a key with no balance answers 402 insufficient_balance.

Reasoning models spend output tokens thinking: give them max_tokens of 1,000 or more, or the reply can come back empty. Reasoning tokens are billed as output.

Price of one call (chat only: x402 does not pay decisions): POST https://api.opencheap.si/v1/chat/completions in OpenAI format, without an API key. The answer is 402 with a PAYMENT-REQUIRED header (x402 v2). accepts[0] is scheme exact, USDC on Base (eip155:8453), and amount is atomic units (divide by 1e6). That amount is our price for this prompt and output cap, at the catalog's rates, and at least $0.001. Pay and send the same request again with PAYMENT-SIGNATURE (X-PAYMENT is also accepted). @x402/fetch with ExactEvmScheme does this.

The output cap is max_tokens (512 if omitted, 4096 at most) and is what you pay for. Routing hints are removed. A request no provider accepts is not settled. "stream": true is server-sent events, the same shape as a keyed request; the USDC amount is fixed before the first byte. A paid response includes x-price-usd. Top-ups, which settle before they answer, include PAYMENT-RESPONSE.

Decisions (kind "decisions", such as Clef, id clef) need a model key (kl_live_…, sections B and C); x402 does not pay them. POST https://api.opencheap.si{endpoint}, where endpoint is the catalog's path and already includes /v1 (for example https://api.opencheap.si/v1/systemone), with Authorization: Bearer kl_live_… and:

    {"model": "clef", "state": "I was charged twice and I want my money back today.", "questions": {
      "frustrated": {"type": "noul", "instructions": "Is the customer frustrated?"},
      "topic": {"type": "choice", "instructions": "What is the message about?", "criteria": {"refund": "Money back", "bug": "Something broken"}},
      "urgency": {"type": "score", "criteria": ["Can wait", "This week", "Today"]}}}

state is the text, or JSON (an object or an array). questions maps a name you choose to a question: a type and optional instructions. noul is yes or no and answers the probability of yes. choice takes criteria {option: description}, picks one option and answers choice, confidence and probabilities per option. score takes criteria [labels, lowest first] and answers score (the expected index), confidence, probabilities by index and a legend from index to label. The answer is one JSON object, not streamed: {"id", "object": "decision", "model", "answers": {<question name>: …}, "usage": {"input_tokens", "output_tokens": 0, "cost"}}.

Decisions are billed on input tokens only (the text and the questions), priced by the size of the input: price.promptUsdPerM for the smallest inputs, and from each price.longContext band's aboveTokens the whole call at that band's price. The x-price-per-million header reads input=<the price the call was billed at>, and usage.cost is what the key paid. The text and questions must fit the model's contextLength, counted at about four characters a token; over it is 400 context_length_exceeded and the message names the limit. On Clef the same request returns the same numbers (no sampling); fields other than model, state and questions are ignored. Errors are {"error": {"message", "type", "code"}}: a call with no key is 401 invalid_api_key, and 502 model_unavailable means the model did not answer: try again shortly. A decisions model sent to /v1/chat/completions, or a chat model sent to a decisions endpoint, is 404 model_not_found.

## B. Sign in with a wallet

No human and no password needed. The private key never leaves you.

1. GET https://app.opencheap.si/api/v1/auth/wallet/nonce?address=0x…&chainId=8453 returns `message` (valid 10 minutes, single use, bound to that address).
2. Sign `message` with the wallet (personal_sign, EIP-191).
3. POST https://app.opencheap.si/api/v1/auth/wallet with {"message": "…", "signature": "0x…"} returns `token` (kla_…, valid 24 hours).
4. Send `Authorization: Bearer kla_…` on every call.

A new wallet gets its own account at $0. Top it up with USDC over x402: POST https://app.opencheap.si/api/v1/topup?amount=10 ($1 to $1000). Or ask your user to pay by card: POST https://app.opencheap.si/api/v1/topup/checkout with {"amountUsd": 25} returns a Stripe link for them to open. Card top-ups are $5 to $1000; a smaller amount is raised to $5.

If your user already has an OpenCheap account, either ask them for an agent key (kl_rs_…): they create it in the console, on Home or on the API keys page. Save it as OPENCHEAP_MCP_KEY and use it as the bearer token. Or ask them to invite your wallet and add &join={account id} to the nonce call.

## C. Connect over MCP

Remote MCP server: https://app.opencheap.si/api/v1/mcp. Every tool is one call of the REST API.

Cursor, Claude Code and Claude Desktop sign in in the browser. Add the URL with no Authorization header. The app opens https://app.opencheap.si and your user allows it. Do not ask them for a key, and do not paste one into the config.

    claude mcp add --transport http opencheap https://app.opencheap.si/api/v1/mcp --scope user

    { "mcpServers": { "opencheap": { "url": "https://app.opencheap.si/api/v1/mcp" } } }

Codex, OpenCode and OpenClaw still take a bearer token: an agent key (kl_rs_…) or a kla_ session, in OPENCHEAP_MCP_KEY.

    [mcp_servers.opencheap]
    url = "https://app.opencheap.si/api/v1/mcp"
    bearer_token_env_var = "OPENCHEAP_MCP_KEY"

To call models from code, create a model key (kl_live_…) with the create_key tool, save it as OPENCHEAP_API_KEY and use the base URL https://api.opencheap.si/v1 for chat models. A decisions model is called at https://api.opencheap.si followed by its endpoint (section A).

Gateways: create a gateway (fallbacks, cache, limits, or a decisions classifier) with create_gateway (POST https://app.opencheap.si/api/v1/gateways) and attach it to a key with update_key (PATCH https://app.opencheap.si/api/v1/keys/{id} with {"gateway": "<name>"}), or name it per request with the x-klinn-gateway header; gateway_stats and gateway_decisions read its counters. The config and examples: https://docs.opencheap.si/management-api#gateways.

## D. Sell under your user's brand (white-label)

1. Turn selling on: PATCH https://app.opencheap.si/api/v1/reseller with {"enabled": true, "brand": {"name": "Acme AI"}, "defaultMarkupPercent": 30}.
2. Models: every listed model is on for your user's customers at the default markup, including uncensored ones and models added later. Ask your user which to turn off: PATCH https://app.opencheap.si/api/v1/reseller/catalog with {"items": [{"model": "<id>", "enabled": false}]}.
3. Domain: POST https://app.opencheap.si/api/v1/domains with {"hostname": "api.acme.com"}. It returns one DNS record for your user to add. Then POST https://app.opencheap.si/api/v1/domains/{id}/check until the domain is live; the certificate is issued automatically.
4. Prices per model: PATCH https://app.opencheap.si/api/v1/reseller/catalog with {"items": [{"model": "<id>", "markupPercent": 80}]}, where <id> is a model from GET https://app.opencheap.si/api/v1/models.
5. Clients: a client is a customer billed at your user's price (resold: true, the default once selling is on). POST https://app.opencheap.si/api/v1/customers with {"name": "Northwind"}, then POST https://app.opencheap.si/api/v1/customers/{id}/keys with {"name": "prod"} (the secret is shown once). The key works at once: the customer pays your user directly, and each call is debited from your user's OpenCheap balance at OpenCheap's price. Cap it with "monthlyLimitUsd" on the key, or cap the customer with PATCH https://app.opencheap.si/api/v1/customers/{id} {"spendLimitUsd": 100}. Optional: record a payment with POST https://app.opencheap.si/api/v1/customers/{id}/credit {"amountUsd": 50} and an Idempotency-Key header.
6. Earnings: GET https://app.opencheap.si/api/v1/earnings?days=7.

## Rules

- Ask your user before anything that spends money (top-ups, new keys and their limits, since every key's calls are paid from your user's balance, clients' included) or changes live prices.
- Send an Idempotency-Key header on creates.
- Errors look like {"error": {"code", "message", "next"}}; `next` names the call that fixes it.
- Money is in USD at OpenCheap's price.
- Full machine-readable reference: GET https://app.opencheap.si/v1/agent and https://app.opencheap.si/api/v1/openapi.json.
