Skip to content

Create chat completion

OpenAI

OpenAI

Create chat completion

Create a chat completion using OpenAI's /v1/chat/completions API.

Action

Inputs

Name Type Required Description
modeltextRequiredThe model to use (e.g. gpt-4.1-mini, gpt-4o, gpt-4.1). Defaults to gpt-4o-mini.
messagesarray of objectRequiredList of messages that make up the conversation.
roleselectRequiredThe role of the message. (options: system, user, assistant, tool)
contenttextRequiredThe content of the message.
temperaturenumberOptionalSampling temperature between 0 and 2. Higher values make output more random. Defaults to 0.7.
max_tokensnumberOptionalMaximum length of the model reply (in tokens). Approximate guide: 100 tokens ≈ 75 English words or ~400 characters. Defaults to 1024.
top_pnumberOptionalNucleus sampling: consider tokens up to top_p probability mass. Defaults to 1.

Outputs

Name Type Description
statusCodenumberHTTP status code from OpenAI API response.
bodyobjectOpenAI chat completion response: id, choices (message content), usage.
idtextUnique completion ID.
objecttextObject type (e.g. chat.completion).
creatednumberUnix timestamp of creation.
modeltextModel used for the completion.
choicesarray of objectArray of completion choices.
indexnumberChoice index.
messageobjectAssistant message.
roletextMessage role (e.g. assistant).
contenttextMessage content (assistant reply).
refusaltextRefusal reason if applicable.
annotationsarray of objectAnnotations.
finish_reasontextWhy the model stopped (e.g. stop, length).
usageobjectToken usage. Includes prompt_tokens, completion_tokens, total_tokens, plus prompt_tokens_details and completion_tokens_details breakdowns (cached, audio, reasoning, accepted/rejected prediction tokens).
prompt_tokensnumberInput tokens used.
completion_tokensnumberOutput tokens generated.
total_tokensnumberTotal tokens used.
service_tiertextService tier used.
system_fingerprinttextSystem fingerprint.