Skip to content

Chat Completions

Chat Completions — самый распространенный диалоговый API. Он подходит для чата, помощников по коду, резюме, классификации, инструментов и многоходовых диалогов.

POST /v1/chat/completions
https://www.routeapi.ai/v1/chat/completions
Terminal window
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"}]}'
FieldTypeОбяз.Описание
modelstringДаModel ID
messagesarrayДаConversation messages
streambooleanНетSSE streaming
top_pnumberНетnucleus sampling
max_tokensnumberНетMaximum output tokens
temperaturenumberНетSampling temperature
toolsarrayНетTool definitions
tool_choicestring/objectНетTool selection policy
response_formatobjectНетJSON mode or JSON Schema
stream_optionsobjectНетExtra streaming options
[{"role":"system","content":"You are a careful technical assistant."},{"role":"user","content":"Explain API gateway."}]
RoleОписание
systemSystem prompt
userUser input
assistantModel reply
toolTool result
{"id":"chatcmpl_xxx","object":"chat.completion","model":"gpt-4o","choices":[{"message":{"role":"assistant","content":"RouteAPI provides one AI API entry."}}],"usage":{"total_tokens":42}}
  • Support may vary by model service.
  • Confirm optional capabilities before production.
  • Explicit 0 and false values are preserved.