---
name: opencheap
description: Every major AI model behind one OpenAI-compatible API, routed to the cheapest healthy provider. Use it to call models, to run your user's account (keys, balance, usage, budgets and gateways), and to sell their spare capacity.
---

# 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. 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, or make a model key for this codebase with a monthly limit (create_key, or POST https://app.opencheap.si/api/v1/keys with monthlyLimitUsd).

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 or environment, each with its own limit and usage: sections B, C and D.
4. Sell the spare capacity of an API key they pay for, or of their own server: sections B or C, then E.

## 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.

Images, video, voice and music are a separate list: GET https://api.opencheap.si/v1/media/models (no key) gives each model's kind (image, video, speech, transcription, music), the settings it takes and its price per setting, with each provider's price in prices[].offers. Calls in OpenAI's shapes with a key: POST https://api.opencheap.si/v1/images/generations, POST https://api.opencheap.si/v1/audio/speech (the answer is the MP3), POST https://api.opencheap.si/v1/audio/transcriptions (multipart, field file), and POST https://api.opencheap.si/v1/videos then GET https://api.opencheap.si/v1/videos/{id} until status is completed, then GET https://api.opencheap.si/v1/videos/{id}/content. Music: POST https://api.opencheap.si/v1/music with model, prompt, and lyrics (required, optional or refused per model: its params.lyrics), title, instrumental or seconds where the model lists them; the answer is data[].url (Suno makes two takes a call), or a 202 job to follow with GET https://api.opencheap.si/v1/media/{id}. To pick who makes it, send "provider": {"only": ["kie.ai"]} (or "ignore", or "order" with "allow_fallbacks"; names as in offers, a JSON string in a multipart form): the call then costs that provider's price for the setting, and a name that does not make the model is 400 unknown_provider, nothing charged. They need an account that has added credits: until then a call is 402 top_up_required and nothing is charged (the free welcome credit does not count, and x402 does not pay them). Output links expire: save the files. Guide: https://app.opencheap.si/docs/media.

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 start at $5 (a smaller amount is raised to $5), with no maximum of ours. Auto top-up is console only (Credits › Auto top-up): once a card checkout has saved a card, a usage batch that leaves the available balance under their line charges that card for the amount they set, with the same card fee. There is no tool or API call for it. A decline pauses it until they save the setting again. Crypto and wallet balances are never charged this way. When their balance keeps running out, tell them the switch is on the Credits page. Details: https://docs.opencheap.si/top-ups#auto.

If your user already has an OpenCheap account, either ask them for an agent key (kl_rs_…): they create it in the console, under API keys › Agents. 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 (a key with its own gateway, or under a default gateway with guardrails, is locked to it: naming another is 403 gateway_locked); gateway_stats and gateway_decisions read its counters. The config and examples: https://docs.opencheap.si/management-api#gateways.

Budgets: cap spend per day, week, month or for good on the whole account (set_account_budget, PUT https://app.opencheap.si/api/v1/budgets/account) or on one key (set_key_budget, PUT https://app.opencheap.si/api/v1/keys/{id}/budget), stopping at the limit or only alerting; list_budgets (GET https://app.opencheap.si/api/v1/budgets) shows each limit with its spend this window. Details: https://docs.opencheap.si/management-api#budgets.

Price limit: a chat request with "provider": {"max_price": {"input": 0.0058, "output": 0.01, "cache": 0.00012}} (USD per 1M tokens, any of the three legs; cache is input read from the cache) is billed at most that on each leg, or refused with 422 no_offer_under_limit and not billed. The compatible names prompt, completion and input_cache_read are accepted too. A key keeps a default with update_key ({"maxPrice": {"input": 0.5, "output": 2}}). Details: https://docs.opencheap.si/index-methodology#orders.

Minimum discount: one limit that fits every model. A chat request with "min_discount": 90 (or the x-min-discount: 90 header, or the base URL https://api.opencheap.si/min90/v1) is served only by providers at least 90 % under the model's list price on input, output and cache read, or refused with 422 no_offer_under_limit and not billed; the message and error.details give the list price per leg (list_price) and the best discount available (best_discount). GET https://api.opencheap.si/v1/index shows how far under its list price each model is now (discount_vs_list). A model with no list price (more than half of the models today; its discount_vs_list in the index is null) gets no limit from it and is served at the market price: the answer's x-min-discount-applied header says which (the percentage, or no-list-price), and a max_price is the way to cap such a model. A key keeps a default with update_key ({"minDiscount": 90}), a gateway with "min_discount" in its config; the strictest of the request's, the gateway's and the key's applies, and with a max_price too the lower limit on each leg. Details: https://docs.opencheap.si/index-methodology#min-discount.

Price fall-over: when no source can serve a request at the model's price, a dearer one does (marked x-price-basis: fallover). To keep a request at the model's price send "provider": {"allow_price_fallover": false}; to keep every request of a key there, update_key with {"priceFallover": false} (null returns it to the default, on). Details: https://docs.opencheap.si/errors#fallover.

Input-heavy work: routes are ranked by what the request would cost on each, taking max_tokens (or 512) as the output. When the prompt is much longer than the answer (say 15 input tokens per output token), send the header x-klinn-io-ratio: 15 (or "15:1"; "1:4" for output-heavy) and routes are ranked at that ratio, the output being the prompt divided by it and never above max_tokens, so the cheapest input wins. Ranking only: billing, holds, limits and max_price are unchanged; a value that does not read is a 400. A key keeps a default with update_key ({"ioRatio": 15}), a gateway with "io_ratio": 15 in its config; the request's header wins, then the gateway's, then the key's. The answer says what it ranked at in x-klinn-io-ratio-applied (the ratio) and x-klinn-io-ratio-from (request, gateway or key), and names who served it in its top-level "provider" field. Details: https://docs.opencheap.si/speed#io-ratio.

## D. Customers: keys grouped with their own limit

A customer is a group of model keys with its own monthly limit and usage, billed to your user's balance at OpenCheap's price. POST https://app.opencheap.si/api/v1/customers with {"name": "Northwind"} (optional "spendLimitUsd": 100 caps its month), then POST https://app.opencheap.si/api/v1/customers/{id}/keys with {"name": "prod"} (the secret is shown once). Pause one with PATCH https://app.opencheap.si/api/v1/customers/{id} {"status": "paused"}. Over MCP: create_customer, create_customer_key, update_customer.

## E. Sell your user's spare capacity

Your user can list their own OpenAI-compatible server, or a Z.ai GLM Coding Plan key (other vendors' keys are coming soon), and earn their price on every token it serves. Over MCP these are the Sell tools; over REST, https://app.opencheap.si/api/v1/sell/…. Guide: https://docs.opencheap.si/sell; own server setup: https://docs.opencheap.si/sell-own-server; every call: https://docs.opencheap.si/sell-api.

1. The account's owner accepts the selling terms once: in the console (Sell › Providers) or with become_seller from the owner's own wallet. Before that every sell call answers 403 not_seller: tell your user.
2. list_supply_presets (GET https://app.opencheap.si/api/v1/sell/presets): what can be listed, each provider's terms page, and the statement for the key with its version. Tell your user to make sure their provider's terms allow it.
3. create_supply_credential (POST https://app.opencheap.si/api/v1/sell/credentials; own server: {"preset": "custom", "baseUrl": "https://…/v1", "key": "…"}, the key optional; a Z.ai GLM Coding Plan key: {"preset": "zai", "key": "…"}; a preset marked comingSoon answers 422 preset_coming_soon). Ask your user for the key; it is sealed at once and never shown again. Never put it in a file.
4. discover_models (POST https://app.opencheap.si/api/v1/sell/credentials/{id}/discover), then poll get_supply_job every second until done (a few seconds): every model the key serves, with its reference price. A free-tier or unfunded key fails here: the user adds funds and you discover again.
5. create_offers (POST https://app.opencheap.si/api/v1/sell/offers {"credentialId", "models": [...], "pricingMode": "match", "maxDiscountPct": 60}): match the market, or "discount" with discountPct. Ask your user for the price and the floor. A model with no reference price gets your user's own price: set_offer_pricing with {"price": {"p": 0.2, "c": 0.8}} (USD per 1M tokens, each above 0).
6. test_offer, then get_offer until its status is ready (failed: a rate limit usually passes, test again).
7. Show your user the statement text from step 2 and ask them to accept it. Only then publish_offer (POST https://app.opencheap.si/api/v1/sell/offers/{id}/publish {"statement": "<its version>"}): live within about a minute.
8. Afterwards: list_offers (status, price, health), get_supply_earnings, get_supply_payouts (earnings are pending for 7 days after the request is billed, then payable; requests from your own account to your own offers earn nothing); to get paid, the owner saves any address for USDC on Base with set_payout_address (no signature) and calls request_payout from $5 (sent manually, usually within 72 hours); pause_offer, resume_offer, cancel_offer, set_offer_pricing. To price against the market, get_order_book (GET https://app.opencheap.si/api/v1/sell/book/{model}): the asks by level, what buyers pay and what a seller there earns, yours flagged. "Paused · No balance" means the provider account needs funds.

## 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, customers' included).
- 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.
