How to Test an API Using curl: LLM Chat Walkthrough
curl is the fastest way to find out whether an API key, a URL and a request body are correct. This walkthrough tests a chat completions endpoint step by step, from the first call to streaming and error handling.

Key points
- Start with GET /v1/models, then send one small POST /v1/chat/completions request.
- Use -i to see response headers such as X-Balance-USD and the rate limit headers.
- Add -N with stream: true to watch tokens arrive over SSE.
- A 429 carries the error code rate_limited or concurrency; a temporary overload adds Retry-After: 5.
The short version
If you want to know how to test api using curl, the pattern is always the same: set the URL and key as shell variables, send the smallest valid request, and read both the body and the headers. The rest of this article applies that pattern to a chat completions API that follows the OpenAI format. We will use the endpoint at https://api.unfilteredsearch.top/v1 and the model uncensored, but the habits carry over to any HTTP API.
You need three things: a key, a terminal with curl, and optionally jq for reading JSON. New users can claim $0.50 of trial credit with one click on the key page, which is more than enough for a long afternoon of curl experiments. Each test below costs a fraction of a cent. The key page has the sign-up and the trial button.
Put the two values you will reuse into variables so that you never paste a key into a command by hand:
export API="https://api.unfilteredsearch.top/v1"
export KEY="paste-your-key-here"
Everything below uses $API and $KEY. If a command fails, the first thing to check is that both variables are set in the current shell: echo "$API" should print the URL.
Step 1: check the key with GET /v1/models
The cheapest request you can make reads the model list. It sends no prompt, so it costs nothing, and it tells you three things at once: the URL is reachable, the key is accepted, and the model ID you plan to use exists.
curl -sS "$API/models" -H "Authorization: Bearer $KEY"
The flags matter. -s hides the progress meter, and -S brings error messages back when something fails, so you get quiet output on success and a clear message on a network problem. The response should list uncensored. If you installed jq, pipe the output through it to pretty-print:
curl -sS "$API/models" -H "Authorization: Bearer $KEY" | jq .
Typical failures at this step are easy to read. A 401 means the key is wrong, often because of a trailing newline copied with it. A connection error or DNS failure means a typo in the host. A 404 usually means the path is wrong, for example a missing /v1 or a doubled one.
Step 2: send a first chat request
Now send a real prompt to POST /v1/chat/completions. The body is JSON with a model name and a list of messages:
curl -sS "$API/chat/completions" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "Answer in one short sentence."},
{"role": "user", "content": "What does HTTP status 429 mean?"}
],
"max_tokens": 60
}' | jq -r '.choices[0].message.content'
The jq -r filter prints only the reply text. Remove it and look at the whole response once, because it also holds the usage block with prompt and completion token counts. Those numbers are how you check cost. At $0.15 per 1M input tokens and $0.50 per 1M output tokens, a call with 30 input tokens and 25 output tokens costs 30 x $0.15 / 1,000,000 = $0.0000045 plus 25 x $0.50 / 1,000,000 = $0.0000125, so $0.000017 in total.
max_tokens is optional. The completion can use whatever remains of the 100,000-token window, so set a limit when you are testing and do not want a long answer. Quote handling is the usual stumbling block here: the body is wrapped in single quotes so the shell leaves the double quotes alone. If your prompt itself contains a single quote, either escape it or put the body in a file and use -d @body.json.
Step 3: read the response headers
A body tells you what the model said. Headers tell you what the service thinks of your request. Add -i to print them above the body, or -D - to dump them separately:
curl -sS -i "$API/chat/completions" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"Say ok."}],"max_tokens":5}'
Four headers are worth knowing. X-Request-Id identifies the request; quote it if you ever contact support. X-Balance-USD shows how much credit remains, which turns a curl loop into a cheap balance monitor. X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency show the limits that apply to the key: a full key gets 300 requests per minute and 8 concurrent requests, a trial key gets 60 and 2.
When you only care about the status code, switch to -w:
curl -sS -o /dev/null -w "%{http_code} in %{time_total}s\n" "$API/models" \
-H "Authorization: Bearer $KEY"
This prints the HTTP code and total time. Treat the time as a rough local observation, not a benchmark: it includes your network and varies from run to run.
Step 4: stream the answer
Streaming is where curl earns its place, because you can watch the server-sent events arrive. Set stream to true and disable curl's output buffering with -N:
curl -sS -N "$API/chat/completions" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"stream": true,
"messages": [{"role": "user", "content": "Count from one to five in words."}]
}'
You will see lines that start with data: , each followed by a JSON chunk with a small delta of text. The stream ends with a line reading data: [DONE], and usage arrives at the end of the stream. Without -N curl may hold the output back and print everything at once, which makes streaming look broken when it is not.
To print just the text as it arrives, filter the lines:
curl -sS -N "$API/chat/completions" \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"model":"uncensored","stream":true,"messages":[{"role":"user","content":"Name three rivers."}]}' \
| grep --line-buffered '^data: {' | sed -u 's/^data: //' \
| jq --unbuffered -rj '.choices[0].delta.content // empty'
echo
One thing to remember when you script this: a streamed request occupies a concurrency slot until the stream ends. If you background several curl streams on a trial key, the third will be rejected.
Step 5: test JSON mode and tool calls
JSON mode is switched on with response_format. Mention JSON in the prompt as well, so the model knows which keys you want:
curl -sS "$API/chat/completions" \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"response_format": {"type": "json_object"},
"messages": [{"role": "user", "content": "Return JSON with keys city and country for the capital of Peru."}]
}' | jq -r '.choices[0].message.content' | jq .
The second jq is a validity test: if the content is not parseable JSON, it complains. That makes a handy check in a shell script.
Tool calling takes a tools array. The model replies with a tool_calls entry instead of text when it decides a tool is needed:
curl -sS "$API/chat/completions" \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "What is the weather in Lima?"}],
"tools": [{"type": "function", "function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
}}],
"tool_choice": "auto"
}' | jq '.choices[0].message'
To complete the round trip, send a second request that repeats the conversation, adds the assistant message with its tool_calls, and then a message with role set to tool holding your function's result. The documentation lists every parameter that is passed through, including temperature, top_p, stop, seed and the penalties.
Reading errors and 429s
Errors are the second half of testing. Provoke them on purpose so you recognise them later. A wrong key gives 401. A malformed JSON body gives an error with a message; jq on your own body file is the quickest way to find the typo. A body larger than 8 MB is rejected.
The 429 status deserves a closer look because it has three causes. If the error code is rate_limited, you exceeded requests per minute. If it is concurrency, you had too many requests in flight at once. If the service is temporarily overloaded, it also returns 429, with a Retry-After: 5 header telling you to wait five seconds. Failed or refused requests are not charged, so probing limits does not drain your balance.
Here is a small loop that retries politely:
for i in 1 2 3 4; do
code=$(curl -sS -o out.json -w "%{http_code}" "$API/chat/completions" \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"ping"}],"max_tokens":5}')
[ "$code" = "429" ] || break
sleep 5
done
cat out.json
In your own client code, read the error code from the response body and treat the two limit types differently: wait for rate_limited, but lower your parallelism for concurrency.
Turning a curl test into a repeatable check
Once the individual calls work, save them. A file called smoke.sh that runs the models call, one short chat request and one JSON-mode request makes a good health check for a deploy. It exits non-zero on a bad status code, and you can run it from CI or cron. Keep the key in an environment variable or a secrets manager, never in the script.
When a test passes in curl but fails in your application, the difference is nearly always the request your library actually sends. Run the app through a proxy or enable the HTTP client's debug logging, then compare the URL, headers and body with your working curl command. The usual culprits are a missing /v1, a wrong model name, and an Authorization header that lacks the word Bearer.
If you want a fuller picture of how the endpoint fits into a project, the page on the uncensored LLM API covers pricing and integration, and the pricing page shows the top-up options: any whole amount from $20 to $500, paid by crypto (USDT on TRC20 or USDC on Base), with bonuses of +5% from $50, +10% from $100 and +15% from $200.
More guides
Questions and answers
Do I need a paid account to test with curl?
No. A new user can claim $0.50 of trial credit with one click on the key page. It lasts 7 days and covers thousands of small test calls.
Why does my streamed curl output arrive all at once?
Add the -N flag so curl does not buffer. Also check that the body contains stream: true.
What does HTTP 429 mean on this API?
You hit a limit. The error code rate_limited means too many requests per minute, concurrency means too many at once. A temporary overload also returns 429 with Retry-After: 5.
How do I see my remaining balance from curl?
Run a request with -i and read the X-Balance-USD response header.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.