Skip to content
Main Site News Console

Chat Completions

Chat completions is the most commonly used interface and is fully compatible with the OpenAI protocol.

POST https://api.4allapi.com/v1/chat/completions

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel name, see Model Overview
messagesarrayYesArray of conversation messages; each item includes role and content
streambooleanNoWhether to return streamed output, see Streaming Output
temperaturenumberNoSampling temperature 0–2; higher values produce more diverse output
top_pnumberNoNucleus sampling threshold; adjust it as an alternative to temperature
max_tokensnumberNoMaximum number of tokens in the reply
stopstring/arrayNoStop words
presence_penaltynumberNoTopic novelty penalty -2–2
frequency_penaltynumberNoRepetition penalty -2–2
toolsarrayNoTool/function call definitions (supported models)
response_formatobjectNoFor example {"type":"json_object"} forces JSON output

The role in messages supports system / user / assistant / tool. content can be a string, or a multimodal array (text + image, see Vision Understanding).

Request Example

Terminal window
curl https://api.4allapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AIPROXY_KEY" \
-d '{
"model": "fable-5",
"messages": [
{"role": "system", "content": "You are a rigorous technical assistant"},
{"role": "user", "content": "Explain what an API gateway is in one sentence"}
],
"temperature": 0.7,
"max_tokens": 512
}'

Response Structure

{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1750000000,
"model": "fable-5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "The API gateway is..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 32,
"completion_tokens": 41,
"total_tokens": 73
}
}

The usage field is the basis for billing; see Billing and Credits.