Chat Completions
The Chat Completions endpoint is the core of text interaction with platform models. By providing a series of messages, you can have the model return a completed, contextually relevant response. This is the primary endpoint for building chatbots, content generation, text analysis, and other applications.
With an OriginRouter One subscription, choose the corresponding Coding API endpoint and make sure the model ID comes from the Supported Models list; with the pay-as-you-go API plan, choose the corresponding Beta API endpoint and make sure the model ID comes from the Model List; a plan and endpoint mismatch may make models unavailable or result in unexpected billing.
Create Chat Completion
This endpoint creates a model response based on the series of messages you provide.
Headers
- Name
Content-Type- Type
- string
- Required
- Required
- Description
- Value must be
application/json.
- Name
Authorization- Type
- string
- Optional
- Optional
- Description
- Optional authentication method. Credentials for API authentication. For details, see Authentication.
- Name
x-api-key- Type
- string
- Optional
- Optional
- Description
- Optional authentication method. Pass your API key directly. Note: Do not use both
Authorizationandx-api-keysimultaneously.
Request Body
- Name
model- Type
- string
- Required
- Required
- Description
- The model ID to use. Available values include gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.1, o3, o1, gpt-4o, gpt-4o-mini, claude-4.0-sonnet, gemini-2.5-pro, etc.
- Name
messages- Type
- array
- Required
- Required
- Description
- The list of conversation content up to now. Depending on the model you use, it supports different types of messages (modalities), such as text, image, and audio.
- Name
temperature- Type
- number
- Optional
- Optional
- Description
- Temperature parameter controlling randomness, with a range of 0-2. Lower values (such as 0.2) make output more focused and deterministic, while higher values (such as 0.8) make output more diverse and creative. Default value is 1.
- Name
max_tokens- Type
- integer
- Optional
- Optional
- Description
- Deprecated. The maximum number of tokens to generate. Please use
max_completion_tokensinstead. Tokens roughly correspond to word fragments, with about 75 tokens equaling approximately 50 English words. Default value depends on the model.
- Name
max_completion_tokens- Type
- integer
- Optional
- Optional
- Description
- An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
- Name
top_p- Type
- number
- Optional
- Optional
- Description
- Nucleus sampling parameter controlling diversity. The model only considers tokens whose probabilities accumulate to top_p (e.g., 0.9 means only considering tokens that make up the top 90% probability mass). Recommended values are between 0.3-0.9, default value is 1.
- Name
tools- Type
- array
- Optional
- Optional
- Description
- A list of tools the model may call. You can provide custom tools or function tools.
- Name
tool_choice- Type
- string | object
- Optional
- Optional
- Description
- Controls which tool (if any) the model calls.
nonemeans the model will not call any tool and will instead generate a message.automeans the model can choose between generating a message or calling one or more tools.requiredmeans the model must call one or more tools. Specifying a specific tool via{"type": "function", "function": {"name": "my_function"}}will force the model to call that tool.
- Name
n- Type
- integer
- Optional
- Optional
- Description
- The number of chat completion options to generate for each input message. Default value is 1.
- Name
stream- Type
- boolean
- Optional
- Optional
- Description
- If set to true, response data will be returned incrementally in chunks in the form of Server-Sent Events (SSE). Default value is false.
- Name
stop- Type
- string | array
- Optional
- Optional
- Description
- Up to 4 sequences at which the model will stop generating more tokens.
- Name
presence_penalty- Type
- number
- Optional
- Optional
- Description
- A number between -2.0 and 2.0. Positive values increase the likelihood of the model talking about new topics. Default is 0.
- Name
frequency_penalty- Type
- number
- Optional
- Optional
- Description
- A number between -2.0 and 2.0. Positive values reduce the likelihood of repeating the same words based on their existing frequency in the text. Default is 0.
- Name
user- Type
- string
- Optional
- Optional
- Description
- Deprecated. This field is being replaced by
safety_identifierandprompt_cache_key. A unique identifier representing the end user, can be used for monitoring and detecting abuse.
- Name
verbosity- Type
- string
- Optional
- Optional
- Description
- Constrains the verbosity of the model's response. Supports
low,medium,high. Lower values will result in more concise responses, while higher values will result in more verbose responses.
- Name
reasoning_effort- Type
- string | null
- Optional
- Optional
- Description
- Limits the computational overhead during reasoning for reasoning models. Currently supported values include
none,minimal,low,medium(default),high,xhigh. Lowering reasoning overhead can result in faster response times and reduce the number of tokens used for reasoning in the response.
- Name
response_format- Type
- object
- Optional
- Optional
- Description
- Specifies the format that the model must output.
- Name
audio- Type
- object
- Optional
- Optional
- Description
- Parameters for audio output. Required when audio output is requested with
modalities: ["audio"].
- Name
modalities- Type
- array
- Optional
- Optional
- Description
- Output types that you would like the model to generate. Default is
["text"]. Some models also support["audio"]or["text", "audio"].
- Name
logprobs- Type
- boolean
- Optional
- Optional
- Description
- Whether to return log probabilities of the output tokens or not. Default is
false.
- Name
top_logprobs- Type
- integer
- Optional
- Optional
- Description
- An integer between 0 and 20 specifying the number of most likely tokens to return at each token position.
logprobsmust be set totrueif this parameter is used.
- Name
logit_bias- Type
- object
- Optional
- Optional
- Description
- Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID) to an associated bias value from -100 to 100.
- Name
prediction- Type
- object
- Optional
- Optional
- Description
- Static predicted output content, such as the content of a text file that is being regenerated.
- Name
parallel_tool_calls- Type
- boolean
- Optional
- Optional
- Description
- Whether to enable parallel function calling during tool use.
- Name
store- Type
- boolean
- Optional
- Optional
- Description
- Whether or not to store the output of this chat completion request for use in model distillation or evals products.
- Name
metadata- Type
- object
- Optional
- Optional
- Description
- Set of 16 key-value pairs that can be attached to an object.
- Name
seed- Type
- integer
- Optional
- Optional
- Description
- Beta feature. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same
seedand parameters should return the same result.
- Name
prompt_cache_key- Type
- string
- Optional
- Optional
- Description
- Used by OpenAI to cache responses for similar requests. Replaces the
userfield.
- Name
prompt_cache_retention- Type
- string
- Optional
- Optional
- Description
- The retention policy for the prompt cache. Set to
24hto enable extended prompt caching, which keeps cached prefixes active for longer, up to a maximum of 24 hours.
- Name
safety_identifier- Type
- string
- Optional
- Optional
- Description
- A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.
- Name
service_tier- Type
- string
- Optional
- Optional
- Description
- Specifies the processing type used for serving the request. Supported values:
auto,default,flex,scale,priority.
- Name
stream_options- Type
- object
- Optional
- Optional
- Description
- Options for streaming response. Only set this when you set
stream: true.
- Name
web_search_options- Type
- object
- Optional
- Optional
- Description
- Options for web search tool.
- Name
function_call- Type
- string | object
- Optional
- Optional
- Description
- Deprecated. Replaced by
tool_choice. Controls which (if any) function is called by the model.
- Name
functions- Type
- array
- Optional
- Optional
- Description
- Deprecated. Replaced by
tools. A list of functions the model may generate JSON inputs for.
- Name
multimodal- Type
- object
- Optional
- Optional
- Description
- Multimodal adaptation configuration. Used to enable and control automatic conversion of non-text content (such as images, PDFs, videos, audio, etc.). For details, see Multimodal Support.
- Name
fallback- Type
- string
- Optional
- Optional
- Description
- Defines the fallback strategy when a request fails. This parameter only applies to the
/beta/v1/chat/completionsendpoint. For details, see Model Fallback.
- Name
fallback_config- Type
- object
- Optional
- Optional
- Description
- Detailed configuration for custom fallback behavior. This parameter only applies to the
/beta/v1/chat/completionsendpoint. For details, see Model Fallback.
Response Body
- Name
id- Type
- string
- Optional
- Optional
- Description
- Unique identifier for this chat completion, for example
chatcmpl-9UgP85B0gYBjEAiYMcF3Ryt9Y3fdZ.
- Name
object- Type
- string
- Optional
- Optional
- Description
- Object type, for this endpoint the value is always
chat.completion.
- Name
created- Type
- integer
- Optional
- Optional
- Description
- Unix timestamp when the chat completion was created.
- Name
model- Type
- string
- Optional
- Optional
- Description
- The model ID used for this request, for example
gpt-4o, etc.
- Name
choices- Type
- array
- Optional
- Optional
- Description
- A list containing chat completion results. Even if only one result is generated in most cases, the response is always in array form.
- Name
usage- Type
- object
- Optional
- Optional
- Description
- Token usage statistics for this completion request, crucial for cost control and usage analysis.
- Name
service_tier- Type
- string
- Optional
- Optional
- Description
- The processing type used for serving the request.
Request
curl https://api.easytransnote.com/beta/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "developer",
"content": "You are a helpful AI assistant."
},
{
"role": "user",
"content": "Who won the 2020 World Cup?"
}
],
"temperature": 0.7,
"max_completion_tokens": 150
}'
Response
{
"id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxx",
"object": "chat.completion",
"created": 1715990400,
"model": "gemini-2.5-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Once upon a time, in an era where digital signals and analog dreams intertwined, there was an AI called 'ZhHe'. It wasn't born in cold server rooms, but awakened from a child's curious doodle..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 80,
"total_tokens": 105,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default"
}