OpenAI-Style API with cURL and a Bearer Token
To call an OpenAI-style API from the command line you send an HTTP POST with an Authorization header that carries your token. This page gives working cURL commands for every feature of this API, and the checks to run when one fails.
Updated

Key points
- The token goes in the header Authorization: Bearer YOUR_KEY, and the model ID is uncensored.
- Two endpoints exist: GET /v1/models and POST /v1/chat/completions.
- Add -N and stream true to see tokens arrive over server-sent events.
- Read X-Balance-USD and the rate limit headers with curl -i; a 429 means wait and retry.
The minimal request
Here is the shortest way to do open ai api curl with token against this service. Put the key in an environment variable so it does not end up in your shell history, then post a chat message:
export UF_KEY="paste-your-key-here"
curl https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "user", "content": "Explain what a bearer token is in two sentences."}
]
}'
The response is JSON in the OpenAI chat completion shape. The answer sits at choices[0].message.content, and a usage object reports prompt and completion tokens. Each part of the command has a job:
Authorization: Bearer ...carries the token. "Bearer" is the scheme name; whoever holds the token is treated as its owner, which is why you keep it out of public repositories.Content-Type: application/jsontells the server how to read the body. Without it, the request often fails with a body parsing error.modelmust beuncensored, the one model this API serves.messagesis a list of objects with arole(system, user, assistant or tool) andcontent.
To get a key, sign up with Google or email and password, then use the API key page. New users can claim $0.50 of trial credit with one click there: no card, valid for 7 days, one per person.
Check the key with GET /v1/models
Before debugging a long request, confirm the token works with the cheapest call available. Listing models costs nothing and shows whether the URL, the header and the key are all correct.
curl -s https://api.unfilteredaimodels.com/v1/models \
-H "Authorization: Bearer $UF_KEY"
A good answer is a JSON list that includes uncensored. If you have jq installed, pipe the output to extract only the IDs:
curl -s https://api.unfilteredaimodels.com/v1/models \
-H "Authorization: Bearer $UF_KEY" | jq -r '.data[].id'
If nothing useful comes back, work through the list below in order, because the causes are listed by how often they happen:
- The variable is empty. Run
echo "${UF_KEY:0:6}"to see the first characters without printing the whole key. - The header is misspelled, or "Bearer" is missing before the key.
- Curly quotes from a document or chat client replaced straight quotes in the command.
- The base URL is wrong. It is
https://api.unfilteredaimodels.com/v1, withapi.in front and/v1at the end. - The key was copied with a trailing space or newline.
Read the response headers
Add -i to include headers in the output, or -D - to print them while keeping the body clean:
curl -s -D - -o /dev/null \
https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","max_tokens":5,"messages":[{"role":"user","content":"ping"}]}'
Four response headers are worth knowing:
| Header | Meaning |
|---|---|
X-Request-Id | Identifier for this request. Quote it if you contact support. |
X-Balance-USD | Your remaining prepaid credit. |
X-RateLimit-Limit-Requests | Requests per minute allowed for your key. |
X-RateLimit-Limit-Concurrency | Simultaneous requests allowed for your key. |
The limits are 300 requests per minute and 8 concurrent requests for a full key, and 60 per minute and 2 concurrent for a trial key. The request above sets max_tokens to 5 just to keep the test small. In normal use max_tokens is optional, and the completion can use whatever remains of the 100,000-token window after your prompt.
Streaming from the command line
Set "stream": true and add -N so curl does not buffer the output. You will see lines that start with data:, each carrying a small JSON delta, and a final data: [DONE]. The chunk before it includes token usage.
curl -N https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"stream": true,
"messages": [{"role": "user", "content": "Write a four-line poem about a cron job."}]
}'
To print only the text, filter the stream with a short pipeline:
curl -sN https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","stream":true,"messages":[{"role":"user","content":"Count to five."}]}' \
| sed -u 's/^data: //' | grep -v '^\[DONE\]' | grep -v '^$' \
| jq -rj '.choices[0].delta.content // empty'
echo
A streamed request holds its concurrency slot until the stream ends. If you start many streams in parallel from a script and forget to let them finish, you will hit the concurrency limit even though the request rate is low.
JSON mode and tool calls
JSON mode makes the model return a single valid JSON object. State the shape you want in the prompt as well, or the keys will be whatever the model picks.
curl -s https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_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 Portugal."}
]
}' | jq -r '.choices[0].message.content'
Tool calling uses the standard tools and tool_choice fields. The model answers with a tool_calls array instead of text; you run the function yourself and send the result back as a message with role: "tool" and the matching tool_call_id.
curl -s https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"tool_choice": "auto",
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"messages": [{"role": "user", "content": "What is the weather in Lisbon?"}]
}'
In the reply, look for choices[0].message.tool_calls[0].function.arguments. It is a JSON string you parse, call your own weather function with, and return in the next request. Parameters such as temperature, top_p, stop, seed and the penalties are passed through. The documentation lists all supported fields.
Keep the token safe and the commands tidy
A bearer token is a password with a different name. Anyone who has it can spend your credit, so treat it with the same care. Never paste a real key into a public issue, a screenshot or a shared terminal log. If you suspect a key leaked, replace it from the key page and update your scripts.
Shell history is the most common leak on a personal machine. Typing the key directly into a command stores it in the history file. Setting it once with export still stores that line. Two cleaner habits help. Read the key from a file that only you can open, or prefix the command with a space if your shell is set to ignore space-led lines. A small file works well:
mkdir -p ~/.config/uf
printf '%s' 'paste-your-key-here' > ~/.config/uf/key
chmod 600 ~/.config/uf/key
export UF_KEY="$(cat ~/.config/uf/key)"
Long JSON bodies are hard to read inside single quotes, and quoting breaks as soon as the prompt itself contains an apostrophe. Put the body in a file and let curl read it with -d @file:
cat > request.json <<'JSON'
{
"model": "uncensored",
"temperature": 0.3,
"messages": [
{"role": "system", "content": "You answer in plain language."},
{"role": "user", "content": "What's the difference between a 401 and a 403 status code?"}
]
}
JSON
curl -s https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d @request.json | jq -r '.choices[0].message.content'
The same approach keeps large prompts under the 8 MB body limit manageable, and a file can be versioned in git while the key stays outside the repository. On Windows PowerShell, single quotes around JSON behave differently and the backslash line continuation does not exist; the -d @request.json form avoids both problems, and you can use a backtick at the end of a line to continue a command.
When you are done testing, move to an SDK. The OpenAI Python and Node libraries accept the same base URL and key, handle retries and streaming for you, and read the same response format you have been parsing by hand here. The cURL commands remain the fastest way to check whether a failure comes from your code or from the request itself, so keep a known-good one in your notes. When you report a problem to support, include the X-Request-Id of the failing call and the exact status code; that pair lets someone find the request without asking you to repeat the test, and it saves a round of back and forth.
Errors, retries and cost per call
When you exceed a limit, the API answers HTTP 429. The error code tells you which limit: rate_limited means too many requests per minute, concurrency means too many at once. A temporary overload also returns 429 and adds Retry-After: 5. Curl can retry on its own for transient errors:
curl --retry 3 --retry-delay 5 --retry-all-errors \
https://api.unfilteredaimodels.com/v1/chat/completions \
-H "Authorization: Bearer $UF_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"Hello"}]}'
Also keep the body under 8 MB, which matters if you post files encoded into the prompt.
Failed or refused requests are not charged. Successful ones follow a simple formula: $0.15 per 1M input tokens and $0.50 per 1M output tokens. A test call with 40 input tokens and 120 output tokens costs 40 / 1,000,000 x $0.15 = $0.000006 plus 120 / 1,000,000 x $0.50 = $0.00006, so $0.000066 in total. A thousand of them come to $0.066.
Credit is prepaid and never expires. Top-ups run from $20 to $500 in whole amounts, with a bonus of 5% from $50, 10% from $100 and 15% from $200, by crypto (USDT on TRC20, USDC on Base). The pricing page shows the details. If a response looks wrong, the myths and facts page explains what the model does and does not do.
More guides
Questions and answers
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.
Where does the token go in a cURL command?
- In a header: -H "Authorization: Bearer YOUR_KEY". The request body also needs the Content-Type: application/json header.
What model name do I use?
- Use uncensored. You can confirm it with GET /v1/models.
Why do I get 429?
- You passed a limit. The code rate_limited means too many requests per minute, concurrency means too many at once. Wait a few seconds, or lower the number of parallel calls.
How do I see my remaining credit?
- Every response includes an X-Balance-USD header. Print headers with curl -i or curl -D -.
Is this the official OpenAI API?
- No. It is an independent OpenAI-compatible service running one open-weight model, so SDKs and cURL commands built for the OpenAI format work after changing the base URL and key.