Skip to main content
Base URL: https://api.freemodel.app/v1
Create a model response from a list of chat messages.

Create a completion

POST /chat/completions
curl https://api.freemodel.app/v1/chat/completions \
  -H "Authorization: Bearer sk-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {
        "role": "system",
        "content": "You answer in one concise sentence."
      },
      {
        "role": "user",
        "content": "What is an API gateway?"
      }
    ],
    "temperature": 0.2,
    "max_tokens": 100
  }'
Response
{
  "id": "chatcmpl_01HXYZ",
  "object": "chat.completion",
  "created": 1730000000,
  "model": "gpt-5.4-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "An API gateway is a service that provides one interface for routing requests to one or more APIs."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 19,
    "total_tokens": 44
  }
}

Request body

FieldTypeRequiredDescription
modelstringYesA model ID available to your API key. Use GET /v1/models to discover IDs.
messagesarrayYesOrdered chat messages. Each message includes a role and content.
streambooleanNoSet to true to receive server-sent events. Defaults to false.
temperaturenumberNoControls sampling variation. Lower values are more deterministic.
max_tokensintegerNoCaps generated tokens when supported by the selected model.

Stream a response

Set stream to true. The response uses server-sent events (SSE).
curl -N https://api.freemodel.app/v1/chat/completions \
  -H "Authorization: Bearer sk-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {"role": "user", "content": "Say hello in three words."}
    ],
    "stream": true
  }'
Each event begins with data:. Read events until the data: [DONE] marker.
data: {"id":"chatcmpl_01HXYZ","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl_01HXYZ","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" from FreeModel"},"finish_reason":null}]}

data: [DONE]
Concatenate choices[0].delta.content values as they arrive. A delta can omit content, especially in the first or final event.