EN ▾

Curl Command for API: Text Generation Examples

Here is a working curl command for API testing against an OpenAI-compatible text endpoint, plus the variations you will need next. Every example uses the real base URL and the model ID uncensored.

Updated

Terminal panel sending a stream of glowing data cubes into response cards, illustrating a curl API request

No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).

Get API key

Key points

  • One POST to /v1/chat/completions with a Bearer key and a JSON body is the whole request.
  • Use -N for streaming, -i to see headers such as X-Balance-USD, and jq to pull out the reply text.
  • A 429 means a limit: rate_limited (per minute) or concurrency (too many at once).
  • The service is text only: no image, audio or video routes and no embeddings.

The first request

Export your key once so it never ends up pasted into a command history, then send a chat request. This is the minimal curl command for api use on this site:

export API_KEY="paste-your-key-here"

curl https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [
      {"role": "user", "content": "Write a one-line product description for a desk lamp."}
    ]
  }'

You get back a JSON object in the OpenAI chat completion format. The reply text is at choices[0].message.content, and a usage block reports prompt and completion tokens. If you do not have a key yet, the key page walks through sign-up, and new users can claim $0.50 of trial credit there with one click. It needs no card, lasts 7 days and is limited to one per person.

The backslashes at the end of lines tell the shell the command continues. The single quotes around the JSON body stop the shell from touching the double quotes inside. If you copy these examples into a script, keep that quoting.

Anatomy of the request

Each part of the command does one job, and knowing them makes errors easy to read.

PartWhat it does
POST (implied by -d)curl switches to POST when you send a body
/v1/chat/completionsThe chat route. The only generation route offered
Authorization: BearerYour key. Missing or wrong gives an auth error
Content-Type: application/jsonTells the server the body is JSON
"model": "uncensored"The single model ID on this endpoint
messagesList of objects with role (system, user, assistant, tool) and content

The other method you can call is a GET on the model list. It is the quickest check that your key and URL are right:

curl https://api.uncensoredimage.top/v1/models -H "Authorization: Bearer $API_KEY"

A response listing uncensored means the connection works. Anything else, check the host name, that /v1 is present, and that the key was copied whole.

Make the output readable with jq

Raw JSON on one line is hard to scan. Pipe the output into jq to print only the reply:

curl -s https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"Give me three names for a coffee shop."}]}' \
  | jq -r '.choices[0].message.content'

The -s flag hides curl's progress meter, and -r prints the string without JSON quoting. To see token usage as well, use jq '.usage' instead. If jq is not installed, python3 -m json.tool pretty-prints the response, though you will need to read the text out of it by eye.

You can also keep the body in a file, which is easier to edit than a long single line:

curl -s https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d @request.json

Here request.json holds the same JSON object. The maximum body is 8 MB, which is far more than a typical prompt, but a pasted-in document can grow quickly. Remember the 100,000 token context window covers prompt plus completion.

Tuning parameters and system prompts

Sampling settings go in the same JSON body. The API passes through temperature, top_p, stop, seed and the frequency and presence penalties. max_tokens is optional; leave it out and the completion can use the rest of the window.

curl -s https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "temperature": 0.3,
    "max_tokens": 120,
    "seed": 42,
    "messages": [
      {"role": "system", "content": "You answer in plain English, in two sentences."},
      {"role": "user", "content": "Why do people cache API responses?"}
    ]
  }' | jq -r '.choices[0].message.content'

A low temperature suits extraction and classification, while higher values suit brainstorming. Setting seed asks for repeatable sampling where the backend allows it, which helps when you compare two prompt wordings side by side. For a longer list of options, the docs page is the reference.

Streaming, JSON mode and tools

Streaming

Add "stream": true and the server sends server-sent events as the text is produced. Use -N so curl does not buffer the output.

curl -N https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","stream":true,"messages":[{"role":"user","content":"Count from one to ten in words."}]}'

Each line starts with data: and holds a JSON chunk. Usage figures arrive at the end of the stream. A streamed request holds one concurrency slot until it finishes, so a script that opens streams and never reads them to the end will block its own later calls.

JSON mode

curl -s https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "response_format": {"type": "json_object"},
    "messages": [
      {"role": "system", "content": "Reply with JSON only."},
      {"role": "user", "content": "List three HTTP status codes with a short meaning each, as {\"codes\": [...]}."}
    ]
  }' | jq -r '.choices[0].message.content'

Say the word JSON in the prompt as well as setting the format; it makes the shape you want far more likely. Always parse and validate the result in your own code.

Tool calling

Tools use the standard OpenAI shape: a tools array of function definitions, optional tool_choice, and results sent back as messages with role set to tool. With curl you will usually do this by hand only for a single test; for loops, a script in Python or Node is easier to maintain.

Multi-turn chats and common mistakes

The API is stateless. It does not remember your last call, so a conversation is just a longer messages list that you send each time, with the earlier assistant replies included. A two-turn test looks like this:

curl -s https://api.uncensoredimage.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [
      {"role": "user", "content": "Pick a random animal."},
      {"role": "assistant", "content": "A heron."},
      {"role": "user", "content": "Write a haiku about it."}
    ]
  }' | jq -r '.choices[0].message.content'

Because every call carries the whole history, input tokens grow with each turn. That is where most of your bill comes from in long chats, so trim old turns when they stop mattering.

Mistakes that look like API problems

  • Smart quotes. Copying a command from a web page or chat app can replace straight quotes with curly ones. The shell then passes broken JSON. Retype the quotes if you get a parse error.
  • Trailing comma in the JSON. JSON does not allow it. Validate the body with jq . before sending.
  • Extra space after the backslash. A space after the line-continuation backslash ends the command early, and the next line runs as its own command.
  • Key with a newline. If you saved the key from a file, strip the line break with tr -d '\n'.
  • Single quotes inside the body. An apostrophe in the prompt closes the shell string. Put long prompts in a file and use -d @request.json.

Read the response headers

Add -i to print the headers along with the body. These ones are worth knowing:

  • X-Request-Id: quote this when you contact support about a particular call.
  • X-Balance-USD: your remaining credit after the call.
  • X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency: the limits that apply to your key.
curl -i -s https://api.uncensoredimage.top/v1/models -H "Authorization: Bearer $API_KEY" | head -n 15

A full key allows 300 requests per minute and 8 concurrent requests; a trial key allows 60 and 2. When you pass a limit, the API returns HTTP 429. The body's error code is rate_limited for too many per minute, or concurrency for too many at once. A temporary overload also returns 429, with a Retry-After: 5 header. Wait that long and send again.

# retry up to 3 times on 429, waiting 5 seconds each time
for i in 1 2 3; do
  code=$(curl -s -o out.json -w "%{http_code}" https://api.uncensoredimage.top/v1/chat/completions \
    -H "Authorization: Bearer $API_KEY" \
    -H "Content-Type: application/json" \
    -d @request.json)
  [ "$code" != "429" ] && break
  sleep 5
done
cat out.json

Cost of testing, and Windows quoting

Testing with curl is close to free. A call with 1,000 input tokens and 500 output tokens costs 1,000 / 1,000,000 x $0.15 = $0.00015 for input plus 500 / 1,000,000 x $0.50 = $0.00025 for output, so $0.0004 in total. A hundred such calls cost $0.04. Failed or refused requests are not charged, and prompts are not used for training. Credit is prepaid, never expires, and tops up from $20 to $500 in crypto on this site (USDT on TRC20 or USDC on Base); see the pricing page for the bonus tiers.

On Windows, the quoting rules differ. In PowerShell, the safest route is the file method: write request.json and use curl.exe with -d @request.json, since plain curl in older PowerShell is an alias for another command. In cmd.exe, wrap the body in double quotes and escape the inner ones as \", or again use a file. Use ^ instead of \ for line continuation in cmd.exe.

One last point on scope: this endpoint returns text. If you are looking for prompts to feed an image tool, the page on the text engine for image prompts covers that angle. This API itself does not return pictures.

Questions and answers

What is the simplest curl command for the API?

A POST to /v1/chat/completions with the Authorization Bearer header, a JSON content type, and a body holding model uncensored and a messages array.

How do I stream the reply in curl?

Set stream to true in the body and add the -N flag so curl prints chunks as they arrive. Usage is sent at the end of the stream.

Why does curl return 429?

You passed a limit. rate_limited means too many requests per minute, concurrency means too many at once, and an overload response carries Retry-After: 5.

Can I call an image generation route with curl?

No. Only POST /v1/chat/completions and GET /v1/models are offered, and the service is text only.