Chat completions
POST /v1/chat/completions creates a model response for a conversation.
| Parameter | Type | Description |
|---|---|---|
model | string | Model ID from List models |
messages | array | Conversation so far, as role and content pairs |
stream | boolean | Return server-sent events as tokens are produced |
temperature | number | Sampling temperature, 0 to 2 |
max_tokens | integer | Upper bound on generated tokens |
tools | array | Function definitions the model may call |
Example
curl http://kpnmail.net/v1/chat/completions \
-H "Authorization: Bearer $NORTHWIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Summarize our refund policy"}]}'
Response
{"id":"chatcmpl-8f2c","object":"chat.completion","model":"gpt-4o",
"choices":[{"index":0,"message":{"role":"assistant","content":"..."},"finish_reason":"stop"}],
"usage":{"prompt_tokens":14,"completion_tokens":96,"total_tokens":110}}