No KYC — no ID, no selfie, no documents. Pay in crypto: BTC, USDT, USDC, ETH, SOL, LTC
Language: English
Get an API key

Docs · curl

curl: the LLM API from a terminal

Every call is plain HTTPS with a JSON body, so curl is enough to test a key, compare two models or script a quick job. jq makes the JSON readable; both ship with most systems or install in one command.

Last updated: · 4 min read

Quick answer

How do I call LLMwithCrypto with curl?

Send a POST to https://llmwithcrypto.com/api/v1/chat/completions with -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY", a JSON content type and a body holding model and messages. LLMwithCrypto returns the OpenAI response object; pipe it to jq to print the answer and the token counts. Add -N and "stream": true to see the text arrive live, as documented on 23 October 2026.

How do I set the key once?

Export it in your shell session so that every command can use it, and keep it out of your shell history and of shared scripts:

  • Linux and macOS: export LLMWITHCRYPTO_API_KEY=… in the terminal, or in a .env file that your scripts load and that is never committed.
  • Windows PowerShell: $env:LLMWITHCRYPTO_API_KEY = "…", then run the commands in Git Bash or WSL, or adapt the quoting.

Make one API key per app, agent or teammate and revoke any of them from the dashboard without touching the others.

A short answer and its token counts
curl -s "https://llmwithcrypto.com/api/v1/chat/completions" \
  -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-oss-20b", "messages": [{"role": "user", "content": "One word for fast?"}], "max_tokens": 20}' \
  | jq -r '.choices[0].message.content, "\(.usage.prompt_tokens) in, \(.usage.completion_tokens) out"'

How do I avoid quoting problems?

Put the body in a file. Shell quotes and JSON quotes fight each other as soon as a prompt contains an apostrophe or a dollar sign; a file avoids both. --data @request.json sends the file as it is.

A request read from a file
cat > request.json <<'EOF'
{
  "model": "deepseek-v4-pro",
  "messages": [
    {"role": "system", "content": "You review shell scripts."},
    {"role": "user", "content": "Is it safe to run rm -rf \"$DIR\"/ when DIR may be empty?"}
  ],
  "max_tokens": 300
}
EOF
curl -s "https://llmwithcrypto.com/api/v1/chat/completions" \
  -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY" \
  -H "Content-Type: application/json" \
  --data @request.json | jq -r '.choices[0].message.content'

How do I watch a streamed answer?

-N turns off curl’s output buffer, so each server-sent event prints as soon as it arrives. You will see raw data: lines; the streaming page explains them.

Streamed answer, raw events
curl -sN "https://llmwithcrypto.com/api/v1/chat/completions" \
  -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "messages": [{"role": "user", "content": "Write a haiku about latency."}],
    "stream": true,
    "stream_options": {"include_usage": true},
    "max_tokens": 120
  }'

How do I list the models and check the credit?

Both calls are free. The first prints one model id per line, ready for the model field; the second prints the credit left in US dollars.

Model ids
curl -s "https://llmwithcrypto.com/api/v1/models" \
  -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY" | jq -r '.data[].id'
Credit left
curl -s "https://llmwithcrypto.com/api/v1/credits" \
  -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY" | jq -r '.balance_usd'

How do I see an error in the terminal?

Add -w "\nHTTP %{http_code}\n" to print the status after the body. An error body is a small JSON object with a code field, such as invalid_api_key, insufficient_balance or model_not_found; the errors page explains each one. With jq, .error.code // empty prints the code when there is one and nothing otherwise, which makes scripts easy to branch on.

Errors cost nothing. You pay per token from your balance: input and output tokens are counted by the model’s own tokenizer and charged at that model’s price per 1M tokens. A call that ends in an error costs nothing.

Can I script a batch with curl?

For a handful of requests, a shell loop over files is fine: one JSON body per file, one curl per file, results written next to them. Keep it sequential, or run a few at a time with xargs -P 4, so that you stay under your rate limit. Every account has a per-minute request and token limit, shown in the dashboard; ask support and it can be raised.

For anything larger, retries and concurrency are easier in code: the Python and Node.js pages have ready-made batch examples with a concurrency cap.

curl: common questions

Why do I get a 401 error?

The key is missing, mistyped or revoked, or the variable is not set in this shell. Run echo ${#LLMWITHCRYPTO_API_KEY} to check that it is not empty.

How do I compare two models quickly?

Run the same file twice and change only model, for example deepseek-v4-pro and gpt-oss-120b; the usage lines show what each answer cost in tokens.

Is my prompt stored?

No. We do not store your prompts or the model’s answers: once a response is sent, its text is gone. Each call leaves one log line with the time, the account, the model and the token counts, deleted after 30 days.

DeepSeek V4 Pro from $1.254 per 1M input tokens · no KYC

Get an API key