Chat Completions
Chat Completions — самый распространенный диалоговый API. Он подходит для чата, помощников по коду, резюме, классификации, инструментов и многоходовых диалогов.
Endpoint
Section titled “Endpoint”POST /v1/chat/completionshttps://www.routeapi.ai/v1/chat/completionsПример
Section titled “Пример”curl https://www.routeapi.ai/v1/chat/completions \ -H "Authorization: Bearer $ROUTEAPI_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello RouteAPI"}]}'Request parameters
Section titled “Request parameters”| Field | Type | Обяз. | Описание |
|---|---|---|---|
model | string | Да | Model ID |
messages | array | Да | Conversation messages |
stream | boolean | Нет | SSE streaming |
top_p | number | Нет | nucleus sampling |
max_tokens | number | Нет | Maximum output tokens |
temperature | number | Нет | Sampling temperature |
tools | array | Нет | Tool definitions |
tool_choice | string/object | Нет | Tool selection policy |
response_format | object | Нет | JSON mode or JSON Schema |
stream_options | object | Нет | Extra streaming options |
messages format
Section titled “messages format”[{"role":"system","content":"You are a careful technical assistant."},{"role":"user","content":"Explain API gateway."}]| Role | Описание |
|---|---|
system | System prompt |
user | User input |
assistant | Model reply |
tool | Tool result |
Response example
Section titled “Response example”{"id":"chatcmpl_xxx","object":"chat.completion","model":"gpt-4o","choices":[{"message":{"role":"assistant","content":"RouteAPI provides one AI API entry."}}],"usage":{"total_tokens":42}}Примечания
Section titled “Примечания”- Support may vary by model service.
- Confirm optional capabilities before production.
- Explicit
0andfalsevalues are preserved.