Your first AI request with curl: the address, the key and the model

All in One AIUsing the AI API·· 1 view· 4 min read

In short: an AI request needs three things: the address https://api.mozout.com/v1/chat/completions, the key in the Authorization header and the id of a model. With curl, which already comes with Linux, macOS and Windows, you make your first request in a few minutes, without installing anything or writing a program.

Before you start

1 Create a key in the API Center with the ai:read and ai:write permissions. Start with a sandbox_ key: it answers in the same format and costs nothing. The fields are explained in creating an API key.
2 Keep the key in an environment variable, so you do not type it in the command. On Linux and macOS: export MOZOUT_API_KEY="sandbox_...". On Windows: setx MOZOUT_API_KEY "sandbox_...", then open a new terminal.
3 To use a prod_ key, have AI credits in All in One AI.

1. The three parts of the request

What Where it goes Example
The address After curl https://api.mozout.com/v1/chat/completions
The key In the Authorization header Authorization: Bearer $MOZOUT_API_KEY
The model In the model field of the body deepseek-ai/deepseek-v4-flash

The model id always has a slash. Copy it from the Models tab of All in One AI, with the «Copy the id» button, or from the GET /v1/models list. See how to list the models through the API.

2. The request on Linux and macOS

Paste this into the terminal as it is:

curl "https://api.mozout.com/v1/chat/completions" \
-H "Authorization: Bearer $MOZOUT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek-ai/deepseek-v4-flash", "messages": [{"role": "user", "content": "Write a two-sentence welcome message for our website."}], "max_tokens": 200}'

max_tokens limits the length of the answer and lowers the credit reservation. Without it, the reservation counts 4096 output tokens.

3. The request on Windows

In PowerShell, the quotes inside the JSON cause trouble. The simplest way is to put the body in a file. Type notepad request.json (if Notepad asks whether to create the file, answer yes), paste this and save:

{
"model": "deepseek-ai/deepseek-v4-flash",
"messages": [{"role": "user", "content": "Write a two-sentence welcome message for our website."}],
"max_tokens": 200
}

In the same folder, send the request with curl.exe. The @ before the name tells curl to read the body from that file:

curl.exe "https://api.mozout.com/v1/chat/completions" -H "Authorization: Bearer $env:MOZOUT_API_KEY" -H "Content-Type: application/json" -d "@request.json"

4. Reading the answer

The answer comes as JSON. The text is in choices[0].message.content and the tokens counted are in usage: that is what you pay for. If finish_reason is length, the answer stopped at max_tokens. Raise the value and try again.

With a sandbox_ key, the text is always "Resposta de teste (sandbox)." and usage is zero. It means the address, the key and the model are right. Change the variable to your prod_ key and repeat to see a real answer. Add -i to the command to see the headers too: X-API-Mode says sandbox or production.

If you get an error: 401 means the key is missing or wrong (on Windows, did you open a new terminal after setx?); 404 model_not_found means the model id is misspelt; 402 insufficient_credits means there are not enough credits for the reservation. See the AI API errors, one by one.
Once curl works, move to your program. With the OpenAI SDK only the address and the key change: see using the OpenAI SDK.

Did your first request work? See the models and their prices in All in One AI.

See All in One AI

SEE ALSO

Using the OpenAI SDK with All in One AI: only the address and the key change

Testing All in One AI in the Sandbox at no cost: what each answer looks like

Code examples in our API docs: curl, PHP, Python and JavaScript, ready to copy and adapt

Showing the AI reply as it is written in your website or app (streaming)

All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.