Getting startedGuide
First request to CheapTokens with HTTPie: key in env, = and :=
One readable http command that sends a chat completion with the key in an environment variable, then shows where the answer and token usage are.

On this page
You want to know that the key works and the model id is right, and you want to know it in one line. HTTPie's http command does that with far less quoting than curl: you type the fields, it builds the JSON. Here is the whole request, and the rest of the article explains each piece.
export CHEAPTOKENS_API_KEY="paste-your-key-here"
http --body -A bearer -a "$CHEAPTOKENS_API_KEY" \
POST https://api.cheaptokens.dev/v1/chat/completions \
model=deepseek-ai/DeepSeek-V4-Flash-0731 \
max_tokens:=200 \
'messages:=[{"role":"user","content":"In one sentence, what is a token?"}]'The API is OpenAI-compatible, so the base URL is https:/ and chat requests go to / under it. The model id is the full one, deepseek- (the short name from price tables is not accepted). If you have not stored a key before, store an API key safely first: typing the export line puts the key in your shell history, so a profile file or a secrets manager is the better home for it.

What = and := actually do#
This is the only part of HTTPie you have to learn. HTTPie's JSON documentation (version 3.2.4, dated 1 November 2024, read on 9 November 2026) says = sets a string field and := sets a raw JSON value: a number, a boolean, an array or an object. Fields given this way are sent as a JSON body by default, so you don't add a Content-Type header yourself.
In our request that gives three different shapes:
model=deepseek-is a string, soai/ DeepSeek- V4- Flash- 0731 =.max_tokens:=200is a number, so:=. With=you would send the string"200".messages:=[…]is an array of objects, so:=again, and the value goes in single quotes so the shell leaves the inner double quotes alone.
The docs also say a body from stdin cannot be combined with command-line fields, so pick one style. For a first test the fields are shorter and easier to edit.
Quick check
What does max_tokens=200 (with a plain =) send?
Show answer
Answer: The string "200"
= always makes a string. For a number you need :=, so write max_tokens:=200.
Where the answer is#
The reply follows the OpenAI chat-completions format. You are looking for three things, and they sit in different places:
{
"choices": [
{
"message": { "role": "assistant", "content": "…the answer text…" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": …, "completion_tokens": …, "total_tokens": … }
}The answer text is choices[0].. finish_reason is next to it in the same choice, and usage is at the top level. usage shows how many tokens you sent (prompt_tokens) and how many the model wrote (completion_), which is handy for estimating the cost of a request.

If you only want the text, pipe the body to jq:
http --body -A bearer -a "$CHEAPTOKENS_API_KEY" \
POST https://api.cheaptokens.dev/v1/chat/completions \
model=deepseek-ai/DeepSeek-V4-Flash-0731 \
max_tokens:=200 \
'messages:=[{"role":"user","content":"In one sentence, what is a token?"}]' \
| jq -r '.choices[0].message.content'Try it yourselfTry it: make the limit too small and read finish_reasonShow answer
Change max_tokens:=200 to max_tokens:=5 and run it again. The answer is cut off, and finish_reason reads length instead of stop: the limit stopped the model, not the end of the thought. Why an answer cuts off covers the fix.
Swap the model: change one field#
The model is one string, so trying another is a one-word edit. Both ids below are available on CheapTokens with one balance; DeepSeek-V4-Flash gives you a 380K context and up to 32,768 output tokens per answer, GLM-5.3-Flash a 390K context and up to 8,192.
One request, two models
DeepSeek-V4-Flash
http --body -A bearer -a "$CHEAPTOKENS_API_KEY" \
POST https://api.cheaptokens.dev/v1/chat/completions \
model=deepseek-ai/DeepSeek-V4-Flash-0731 \
max_tokens:=200 \
'messages:=[{"role":"user","content":"Name three uses of a token limit."}]'GLM-5.3-Flash
http --body -A bearer -a "$CHEAPTOKENS_API_KEY" \
POST https://api.cheaptokens.dev/v1/chat/completions \
model=zai-org/GLM-5.3-Flash \
max_tokens:=200 \
'messages:=[{"role":"user","content":"Name three uses of a token limit."}]'Not sure which id to use? List the models with GET /v1/models and copy the exact string.
What one test request costs#
A short question like this one is cheap. Say the question is about 100 tokens and the answer about 150: that request costs $0.000017. A thousand of them look like this, with input and output counted together:
| Model | Input $/1M | Output $/1M | Per request | 1,000 requests | OpenRouter, 1,000 requests |
|---|---|---|---|---|---|
| GLM-5.3-Flash | $0.02 | $0.04 | $0.000008 | $0.008 | $0.0158 |
| DeepSeek-V4-Flash | $0.015 | $0.10 | $0.000017 | $0.0165 | $0.028 |
| MiniMax-M2.7 | $0.05 | $0.15 | $0.000028 | $0.0275 | $0.33 |
100 input and 150 output tokens per request. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.
In total, with input and output counted together, DeepSeek-V4-Flash comes out cheaper than OpenRouter, and the price is one fixed rate with no peak hours. Current rates for every model are on the pricing page.
If it doesn't work#
- You typed
messages=[…]with a plain=. The array goes out as a string, not a list of messages. Use:=and single quotes around the whole value. - The JSON inside
:=is invalid. Every key and string needs double quotes, and the outer quotes must be single. If you edit the message text, keep the quotes balanced. - The key is empty.
echo ${#CHEAPTOKENS_prints the length without showing the key;API_ KEY} 0means the variable isn't set in this terminal. - The model id is the short name. Use the full
deepseek-. For 401 and 404 answers, see wrong key, base URL or model id.ai/ DeepSeek- V4- Flash- 0731 - You reached for
--session. HTTPie's authentication docs say session files store credentials in plain text, so keep the key in the environment and leave--sessionout of this command.
Check your version with http --version if a flag behaves differently from what's above. Prefer Python? The same request without an SDK is in first request in Python with requests. For the full API reference, see the CheapTokens docs.



