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 |
|---|---|---|---|
model | text | Required | The model to use (e.g. gpt-4.1-mini, gpt-4o, gpt-4.1). Defaults to gpt-4o-mini. |
messages | array of object | Required | List of messages that make up the conversation. |
role | select | Required | The role of the message. (options: system, user, assistant, tool) |
content | text | Required | The content of the message. |
temperature | number | Optional | Sampling temperature between 0 and 2. Higher values make output more random. Defaults to 0.7. |
max_tokens | number | Optional | Maximum length of the model reply (in tokens). Approximate guide: 100 tokens ≈ 75 English words or ~400 characters. Defaults to 1024. |
top_p | number | Optional | Nucleus sampling: consider tokens up to top_p probability mass. Defaults to 1. |
Outputs
| Name | Type | Description |
|---|---|---|
statusCode | number | HTTP status code from OpenAI API response. |
body | object | OpenAI chat completion response: id, choices (message content), usage. |
id | text | Unique completion ID. |
object | text | Object type (e.g. chat.completion). |
created | number | Unix timestamp of creation. |
model | text | Model used for the completion. |
choices | array of object | Array of completion choices. |
index | number | Choice index. |
message | object | Assistant message. |
role | text | Message role (e.g. assistant). |
content | text | Message content (assistant reply). |
refusal | text | Refusal reason if applicable. |
annotations | array of object | Annotations. |
finish_reason | text | Why the model stopped (e.g. stop, length). |
usage | object | Token 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_tokens | number | Input tokens used. |
completion_tokens | number | Output tokens generated. |
total_tokens | number | Total tokens used. |
service_tier | text | Service tier used. |
system_fingerprint | text | System fingerprint. |