Build
Request parameters
Set output limits, sampling controls and tool calls for your API requests.
Find what you need
- Tools and plugins — use built-in tools, call your own functions, or adjust prompts and JSON responses.
- Common fields — choose a model, set answer length and adjust sampling.
- Thinking and reasoning, structured output, and streaming — follow a focused guide.
- Field names by endpoint — compare Chat Completions, Responses and Messages.
Set your key
Create an API key, save its recovery link, and add credits. Replace the placeholder below and run it in your terminal before running the examples on this page.
export MINIROUTER_KEY='paste-your-api-key-here'Examples use paid models. For free requests, follow the Auto Free guide.
Send a request with parameters
Run this in the same terminal. Change the prompt, temperature or output limit to suit your request.
curl https://api.minirouter.sh/v1/chat/completions \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "alibaba/qwen3.5-flash",
"reasoning": {
"effort": "none"
},
"messages": [
{
"role": "system",
"content": "Give short, practical answers."
},
{
"role": "user",
"content": "Give three names for a gardening app."
}
],
"max_tokens": 256,
"temperature": 0.7
}'Read the answer in choices[0].message.content. A finish_reason of
length means the output limit was reached; increase it for a longer answer.
Common Chat Completions fields
| Field | How to use it |
|---|---|
model | Required. Copy an exact model ID or listed alias from the catalog. |
messages | Required, non-empty conversation array. Use system for instructions, user for prompts and assistant for earlier answers. Send the history needed for each request. |
max_tokens | Positive integer limiting generated output. Keep it within the model limit. |
max_completion_tokens | Alternative output-limit field used by some models. Send this or max_tokens, never both. |
temperature | Controls sampling randomness. Lower values generally make answers more focused. Accepted ranges depend on the model. |
top_p | Nucleus sampling. Tune this or temperature first, rather than changing both together. |
stop | A string or list of stop sequences. Output ends when a supported model reaches one. |
frequency_penalty, presence_penalty | Adjust repetition on models that support these controls. |
stream | Set to true for server-sent events. See streaming. |
stream_options | Chat Completions accepts {"include_usage":true} for streaming usage. |
usage | {"include":true} is accepted as an alias for stream_options.include_usage. Non-streaming responses always include usage. |
reasoning, reasoning_effort | Thinking controls. Choose one form; see reasoning. |
tools, tool_choice | Add built-in server tools or your own functions. See tools and plugins. |
parallel_tool_calls | Boolean controlling parallel calls on models that support them. |
max_tool_calls | Caps built-in server tool executions, from 1 to 30 (default 5). Requires a server tool. See limits and cost. |
plugins | context-compression fits an over-long prompt to the model; response-healing repairs malformed JSON output. See plugins. |
seed | Integer sampling seed where supported. It does not guarantee identical answers. |
n | Only 1 is supported. |
logprobs, top_logprobs | Request token probabilities where supported. top_logprobs accepts an integer from 0 to 20. |
models | Ordered text-model fallback list. See fallback models. |
Optional parameters vary by model and provider. Check supported_parameters
on the public catalog, plus
reasoning_options for thinking controls. If a field is rejected, read the
field path in the error and remove or adjust it. For schema-constrained JSON,
use the structured-output guide.
Field names by endpoint
| Setting | Chat Completions | Responses | Messages |
|---|---|---|---|
| Endpoint | /v1/chat/completions | /v1/responses | /v1/messages |
| Input | messages | input | messages |
| System instructions | A system message | instructions | system |
| Output limit | max_tokens or max_completion_tokens | max_output_tokens | max_tokens (required) |
| Thinking | reasoning or reasoning_effort | reasoning | thinking and output_config.effort |
| Schema output | response_format on models listing structured_outputs | Ignored | output_config.format on the models listed in the structured-output guide |
Where schema output is not enforced it is dropped and the response carries
x-minirouter-structured-output: ignored; provider.require_parameters: true
returns 400 instead.
Use the request shape for your endpoint. Moving the same JSON body between endpoints without changing its fields will return an error.
Call a tool
Your app runs the function. Send a function definition in tools, read
choices[0].message.tool_calls, run the function, and return its result to the model.
Follow the function-calling example.
Let MiniRouter run a tool
MiniRouter runs the built-in tool. Add minirouter:datetime,
minirouter:web_search or minirouter:web_fetch to tools. MiniRouter calls the tool, sends the result
back to the model, and returns the answer in the same request.
Start with the datetime example.
Server tools use Chat Completions and a model that supports tool calling.
Fit a long prompt
The context-compression plugin removes older content when a prompt is too
long for a named model. Read how compression works
before using it with conversation history you need to preserve.
Repair JSON output
The response-healing plugin can repair malformed JSON in non-streaming
responses. See JSON repair and its limits.
Handle an error
A 400 invalid_request names the field to change. Reduce oversized schemas,
remove unsupported controls, and check that you used the right endpoint.
A 402 insufficient_credits means the available balance cannot cover the request;
reduce the output limit or add credits. See the error reference.