Chat Completions

Send messages to any supported chat model and receive AI-generated responses. Every chat model in the catalogue is available.

Endpoint

POST/v1/chat/completions

Request body

modelstringrequired
ID of the model. Examples: gpt-4o, claude-sonnet-4-6, gemini-2.5-pro
messagesarrayrequired
Array of message objects with role (system, user, assistant) and content.
temperaturenumber
Sampling temperature between 0 and 2. Higher = more random. Default: 1
max_tokensinteger
Maximum number of tokens to generate.
top_pnumber
Nucleus sampling. Alternative to temperature. Default: 1
streamboolean
If true, partial message deltas are sent as SSE. Default: false
presence_penaltynumber
Penalty for new tokens based on presence. Range: -2 to 2.
frequency_penaltynumber
Penalty for new tokens based on frequency. Range: -2 to 2.
toolsarray
Array of tool definitions for function calling.
tool_choicestring | object
Controls which tool is called. Options: auto, none, or a specific tool.

Example request

curl https://api.aetherapi.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-aetherapi-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"}
    ],
    "temperature": 0.7,
    "max_tokens": 256
  }'

Example response

{
  "id": "aetherapi-p60RW7nRFPlyLf5nkRlofVzPDnPpT",
  "object": "chat.completion",
  "created": 1777906388,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello!",
        "tool_calls": null
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 3,
    "total_tokens": 15,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  }
}

Streaming responses

When stream: true is set, the API returns Server-Sent Events (SSE) with partial message deltas:

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: [DONE]

Tip

Use streaming for real-time UIs. Each chunk contains a partial message delta. The stream ends with a data: [DONE] event.