Create chat completion
/v1/chat/completionsCreate a chat completion response for the given conversation.
Authentication
Authorization Bearer
API key as bearer token in Authorization header.
Request Body
messagesarrayrequiredConversation messages.
messages.rolestringrequiredMessage role, such as system, user, assistant, or tool.
messages.contentstring | object[]requiredMessage content. Multimodal models may accept structured content parts.
messages.namestringOptional participant name.
messages.tool_call_idstringTool call ID for tool messages.
modelstringrequiredModel ID.
temperaturenumberControls randomness in generated output. Higher values make responses more varied; lower values make responses more deterministic.
top_pnumberControls nucleus sampling by limiting token choices to a cumulative probability mass. Lower values make output more focused; higher values allow more variety.
max_completion_tokensintegerMaximum number of tokens the model may generate in the response.
top_kintegerTop-k sampling cutoff.
frequency_penaltynumberFrequency-based repetition penalty.
presence_penaltynumberPresence-based novelty penalty.
context_lengthintegerContext window length.
streambooleanStreaming response flag.
stream_optionsobjectStreaming response configuration.
stream_options.include_usagebooleanInclude usage information in the streaming response.
toolsarrayTool definitions.
tools.typestringTool type, usually function.
tools.functionobjectFunction definition.
tool_choiceobjectTool selection policy.
tool_choice.typestringTool choice type, such as function.
tool_choice.functionobjectFunction selection payload.
parallel_tool_callsbooleanParallel tool-call flag.
previous_response_idstringPrevious response ID.
conversationobjectConversation state object or ID.
prompt_cache_keystringPrompt cache key.
storebooleanResponse storage flag.
truncationstringInput truncation strategy.
includearrayAdditional response fields to include.
metadataobjectApplication metadata.
extra_bodyobjectAdditional request body fields.
provider_optionsobjectUpstream configuration.
schema_paramsobjectStructured output schema parameters.
network_searchbooleanNetwork search flag.
reasoningobjectReasoning control configuration.
reasoning.enabledbooleanEnable reasoning when the selected model supports it.
reasoning.effortstringReasoning effort. Supports xhigh, high, medium, low, minimal, and none.
reasoning.max_tokensintegerMaximum reasoning tokens. Used for execution when supplied with effort.
reasoning.excludebooleanReason internally without returning reasoning text.
response_formatstringResponse
idstringUnique completion ID.
objectstringAlways chat.completion for non-streaming responses.
createdintegerUnix timestamp.
modelstringModel used for the request.
choicesobject[]Generated choices.
choices.indexintegerChoice index.
choices.messageobjectAssistant message.
choices.finish_reasonstringstop, length, or tool_calls.
usageobjectToken usage and cost details.
usage.prompt_tokensintegerInput token count when returned.
usage.completion_tokensintegerOutput token count when returned.
usage.total_tokensintegerTotal token count when returned.
usage.input_tokensintegerInput token count for providers that use input/output names.
usage.output_tokensintegerOutput token count for providers that use input/output names.
usage.generated_imagesintegerGenerated image count when returned.
usage.audio_duration_secondsnumberAudio duration used for billing when returned.
usage.video_duration_secondsnumberVideo duration used for billing when returned.
usage.provider_request_idstringProvider request ID used for upstream correlation.