Skip to content
InfercomInfercomInfercom Documentation

Chat completions

Create chat-based completion

POST
/chat/completions
from openai import OpenAI
client = OpenAI(
base_url="https://api.infercom.ai/v1",
api_key="your-infercom-api-key",
)
completion = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[
{"role": "user", "content": "Write a haiku about AI."}
]
)
print(completion.choices[0].message.content)

Create a chat completion from a list of messages using Infercom’s OpenAI-compatible API. Supports streaming, function calling, vision, and JSON output.

Chat prompt and parameters

Media typeapplication/json
Chat Completion Request

Chat completions request object

object
model
required
Model

The model ID to use. Call GET /v1/models to retrieve the current list of available models. See available models for details.

string
Example
MiniMax-M2.7
messages
required
Messages

A list of messages comprising the conversation so far.

Array
>= 1 items
Any of:
System Message
object
role
required
Role

The role of the messages author, in this case system.

string
Allowed value: system
Allowed values: system
content
required
Any of:
string
key
additional properties
any
max_tokens
Max Tokens

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length.

integer
nullable
Example
2048
max_completion_tokens
Max Completion Tokens

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length.

integer
nullable
Example
2048
temperature
Temperature

What sampling temperature to use, determines the degree of randomness in the response. Accepted range is 0 to 2. Higher values like 1.5 make the output more random, while lower values like 0.2 make it more focused and deterministic. A value of 1.0 uses the model’s distribution exactly as trained. There is no service-wide default. If you omit temperature, most models decode greedily, which behaves like temperature 0 and can send a reasoning model into a non-terminating repetition loop. It also forces top_k to 1, so any top_k you send is silently ignored. Always set temperature explicitly, using the value the model publisher recommends; see Recommended sampling parameters. Alter this, top_p or top_k, but not more than one of these.

number
nullable <= 2
Example
1
top_p
Top P

Cumulative probability for token choices. An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. Is recommended altering this, top_k or temperature but not more than one of these.

number
nullable <= 1
Example
1
top_k
Top K

Amount limit of token choices. The model considers only the K tokens with the highest probability, so 10 means only the first 10 are considered. Alter this, top_p or temperature, but not more than one of these. top_k has no effect unless temperature is 0.001 or above. Below that threshold, including when temperature is omitted entirely, top_k is forced to 1 and decoding is greedy - nothing in the response signals that your value was ignored. When omitted, top_k is 1048576, which is effectively unrestricted. The minimum accepted value is 1; -1 and 0 are rejected with a 400 and are not a way to disable it. No upper bound is enforced. See How top_k interacts with temperature.

integer
nullable >= 1
Example
40
repetition_penalty
Repetition Penalty

Penalises tokens that have already appeared, to break repetition loops. Tokens in your prompt count too, so a long system prompt can suppress words the prompt itself relies on. This makes it a different tool from frequency_penalty, which penalises generated tokens only. Accepted range is 1 to 2; values outside it return a 400. 1.0 applies no penalty and is the value used when you omit the parameter. Raise it only if repetition survives a correct temperature, and keep it at or below 1.2. Higher values lengthen reasoning: on gpt-oss-120b a one-sentence answer used 104 completion tokens at 1.0 and 244 at 1.3, so a tight max_tokens can truncate the answer. At 1.8 the model returns no content at all. Honoured on gpt-oss-120b, MiniMax-M2.7 and gemma-4-31B-it. Accepted and ignored on DeepSeek-V3.1, DeepSeek-V3.2 and Meta-Llama-3.3-70B-Instruct. Applied on /v1/chat/completions only: /v1/responses and /v1/messages accept it and ignore it. This parameter is not part of the OpenAI dialect, so send it through extra_body with the OpenAI SDKs.

number
default: 1 nullable >= 1 <= 2
Example
1.05
presence_penalty
Presence Penalty

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics. Not currently implemented on the Infercom API; accepted for compatibility and ignored. To control repetition, use repetition_penalty.

number
0 nullable >= -2 <= 2
frequency_penalty
Frequency Penalty

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim. Not currently implemented on the Infercom API; accepted for compatibility and ignored. Unlike presence_penalty, values outside the stated range are accepted without an error and are also ignored. To control repetition, use repetition_penalty.

number
0 >= -2 <= 2
do_sample
do_sample

If true, sampling is enabled during output generation. If false, deterministic decoding is used.

boolean
nullable
stop
One of:
string
nullable
Example
stream
Stream

If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

boolean
nullable
stream_options
StreamOptions

Options for streaming response. Only set this when setting stream as true

object
include_usage
Any of:
boolean
key
additional properties
any
response_format
One of: discriminator: type
ResponseFormatText

Specifies that the model should produce output as plain text.

object
type
required
Type
string
Allowed value: text
Allowed values: text
key
additional properties
any
reasoning_effort
Reasoning Effort

Value specifying the amount of reasoning the model is allowed to do. Increasing it increases the number of output reasoning tokens and latency, but improves quality of the responses. Allowed values are ‘low’, ‘medium’, ‘high’. On Infercom this parameter is implemented by gpt-oss-120b, where the default is medium. Reasoning cannot be switched off - low is the minimum, and ‘none’ or ‘off’ are rejected with a 400. Other models accept the parameter for OpenAI compatibility and ignore it. See the Reasoning guide for per-model behavior.

string
nullable
Allowed values: low medium high
tool_choice
Any of:
string
Allowed values: none auto required
parallel_tool_calls
Parallel Tool Calls

Whether to enable parallel function calling during tool use.

boolean
nullable
tools

A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.

Array<object>
nullable <= 128 items
Tool
object
function
required
Function Object
object
name
required
Name

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes.

string
description
Description

A description of what the function does, used by the model to choose when and how to call the function.

string
nullable
parameters
Function Parameters

The parameters the functions accepts, described as a JSON Schema object. see the JSON Schema reference for documentation about the format. Omitting parameters defines a function with an empty parameter list.

object
key
additional properties
any
key
additional properties
any
type
required
Type

The type of the tool. Currently, only function is supported.

string
key
additional properties
any
chat_template_kwargs
Chat Template Kwargs

A dictionary of additional keyword arguments to pass into the chat template. Use this to provide extra context or parameters that the model’s chat template can process. Keys must be strings; values may be any valid JSON type.

object
enable_thinking
Enable Thinking

Enables the model’s internal reasoning or “thinking” mode, if supported by the chat template. On Infercom this applies to gemma-4-31B-it, where thinking is off by default - set this to true to turn it on, or false for a direct answer. Models that reason by default, such as MiniMax-M2.7 and the DeepSeek models, do not need this flag.

boolean
Example
true
key
additional properties
any
Example
{
"enable_thinking": true
}
logprobs
Logprobs

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message. Supported on every model.

boolean
nullable
top_logprobs
Top Logprobs

An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used. Supported on every model.

integer
nullable <= 20
n
N

How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens.

integer
default: 1 nullable >= 1 <= 8
Example
1
logit_bias
Logit Bias

Modify the likelihood of specified tokens appearing in the completion. Maps token IDs from the model’s tokenizer to a bias from -100 to 100. Supported on gpt-oss-120b only. On gemma-4-31B-it it is accepted and ignored. On MiniMax-M2.7, DeepSeek-V3.1, DeepSeek-V3.2 and Meta-Llama-3.3-70B-Instruct, do not send it: some or all requests fail with HTTP 500.

object
key
additional properties
integer
seed
Seed

If specified, the system makes a best effort to sample deterministically, so repeated requests with the same seed and parameters return the same result. Pins the output on gpt-oss-120b, DeepSeek-V3.1, DeepSeek-V3.2 and Meta-Llama-3.3-70B-Instruct. On MiniMax-M2.7 the same seed returns one of two texts, because the model is served by two deployments. No effect on gemma-4-31B-it. Determinism is not guaranteed across platform releases.

integer
nullable
key
additional properties
any

Successful Response, or model output error (when unsuccessful tool calling or structured response generation)

Media typeapplication/json
One of:
Chat Completion Response

Chat completion response returned by the model

object
choices
required
Choices
Array<object>
>= 1 items
Chat Completion Choice
object
message
required
Completion Response Message
object
role
required
Role

The role of the messages author

string
Allowed values: assistant user system tool
content
required
Content

The contents of the assistant message.

string
nullable
tool_calls
Tool Calls

The tool calls generated by the model.

Array<object>
nullable
AssistantToolCall
object
function
required
AssistantToolCallFunction

The tool that the model called.

object
name
required
Name

The name of the function to call.

string
arguments
required
Arguments

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.

string
key
additional properties
any
id
required
Id

ID of the tool call.

string
type
required
Type

Type of the tool cal. only function is supported.

string
Allowed value: function
Allowed values: function
index
index

Index of tool call chunk only used when using streaming

integer
nullable
key
additional properties
any
key
additional properties
any
finish_reason
required
Finish Reason

The reason the model stopped generating tokens. Will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, tool_calls if the model called a tool.

string
Allowed values: stop length tool_calls
index
required
Index

The index of the choice in the list of choices

integer
logprobs
Any of:
Completion Log Probs

Completion Log Probs object

object
content
required
Log Probs Content
object
bytes
Any of:
Array<integer>
logprob
required
Logprob
number
token
required
Token
string
top_logprobs
required
TopLogProbs
object
bytes
Any of:
Array<integer>
logprob
required
Logprob
number
token
required
Token
string
key
additional properties
any
key
additional properties
any
key
additional properties
any
key
additional properties
any
created
required
Created

The Unix timestamp (in seconds) of when the chat completion was created.

number
id
required
Id

A unique identifier for the chat completion.

string
model
required
Model

The model used for the chat completion.

string
object
required
Object

The object type, always chat.completion.

string
Allowed value: chat.completion
Allowed values: chat.completion
system_fingerprint
required
System fingerprint

Backend configuration that the model runs with.

string
usage
required
Usage

Usage metrics for the completion, embeddings,transcription or translation request

object
acceptance_rate
Acceptance Rate

Acceptance rate

number
completion_tokens
Completion Tokens

Number of tokens generated in completion

integer
completion_tokens_after_first_per_sec
Completion Tokens After First Per Sec

Completion tokens per second after first token generation

number
completion_tokens_after_first_per_sec_first_ten
Completion Tokens After First Per Sec First Ten

Completion tokens per second after first token generation first ten

number
completion_tokens_after_first_per_sec_graph
Completion Tokens After First Per Sec Graph

Completion tokens per second after first token generation

number
completion_tokens_per_sec
Completion Tokens Per Sec

Completion tokens per second

number
completion_tokens_details
Completion tokens details

Breakdown of the generated tokens. Returned by every model. Use it to budget and bill reasoning separately from the visible answer.

object
reasoning_tokens
Reasoning tokens

Number of tokens spent on the chain of thought. Counts towards completion_tokens and therefore towards max_tokens. Returns 0 when the model did not reason, for example gemma-4-31B-it without chat_template_kwargs: {"enable_thinking": true}.

integer
key
additional properties
any
end_time
End Time

The Unix timestamp (in seconds) of when the generation finished.

number
is_last_response
Is Last Response

Whether or not is last response, always true for non streaming response

boolean
prompt_tokens_details
Prompt tokens details

Extra prompt token details. Not returned by /chat/completions. Prompt caching is reported on /responses as usage.input_tokens_details.cached_tokens instead.

object
cached_tokens
Cached tokens

Amount of cached tokens

integer
key
additional properties
any
prompt_tokens
Prompt Tokens

Number of tokens used in the prompt sent

integer
start_time
Start Time

The Unix timestamp (in seconds) of when the generation started.

number
time_to_first_token
Time To First Token

Also TTF, time (in seconds) taken to generate the first token

number
time_to_first_token_graph
Time To First Token Graph

Time to first token measurement for graphing/monitoring purposes

number
stop_reason
Stop Reason

The reason generation stopped. Values include stop (natural end or stop sequence), length (max_tokens reached), tool_calls (model invoked a tool).

string
nullable
total_latency
Total Latency

Total time (in seconds) taken to generate the full generation

number
total_tokens
Total Tokens

Prompt tokens + completion tokens

integer
total_tokens_per_sec
Total Tokens Per Sec

Tokens per second including prompt and completion

number
key
additional properties
any
Example
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "In madam moon's silver glow, Aha, a palindrome to know, Radar spins, a circular tale, Level heads prevail, without fail. A man, a plan, a canal, Panama! Able was I ere I saw Elba, A Santa at NASA, a curious sight, Do geese see God, in the pale moonlight? Mr. Owl ate my metal worm, Do nine men interpret? Nine men, I nod, Never odd or even, a palindrome's might, Madam, in Eden, I'm Adam. Aibohphobia, a fear to confess, A palindrome's symmetry, I must address, Refer, a word that reads the same, A palindrome's beauty, in its circular game. In the stillness of the night, Ava, a palindrome, shining bright, Hannah, a name that reads the same, A palindrome's magic, in its circular flame. Note: Please keep in mind that creating a poem using palindromes can be a challenging task, and the resulting poem may not be as cohesive or flowing as one that doesn't rely on palindromes. However, I hope you enjoy the attempt!",
"role": "assistant"
}
}
],
"created": 1737583288.6076705,
"id": "83a7809d-e18f-44f9-9ab7-2bc494c6c661",
"model": "MiniMax-M2.7",
"object": "chat.completion",
"system_fingerprint": "fastcoe",
"usage": {
"acceptance_rate": 4.058139324188232,
"completion_tokens": 350,
"completion_tokens_after_first_per_sec": 248.09314856382406,
"completion_tokens_after_first_per_sec_first_ten": 249.67922929952655,
"completion_tokens_per_sec": 238.91966176995348,
"end_time": 1737583289.7345645,
"is_last_response": true,
"prompt_tokens": 43,
"start_time": 1737583288.264706,
"time_to_first_token": 0.06312894821166992,
"total_latency": 1.4649275719174653,
"total_tokens": 393,
"total_tokens_per_sec": 268.27264878740493
}
}
inference-id
string
Example
a0b08d8a-1893-45d6-a0f4-7ad6fdeb5443

Unique identifier for this inference request, useful for debugging and support.

x-ratelimit-limit-requests
integer
Example
250

Maximum requests allowed per minute.

x-ratelimit-limit-requests-day
integer
Example
50000

Maximum requests allowed per day.

x-ratelimit-remaining-requests
integer
Example
247

Remaining requests in the current minute window.

x-ratelimit-remaining-requests-day
integer
Example
49988

Remaining requests in the current day.

x-ratelimit-reset-requests
integer
Example
1776937132

Unix timestamp when the per-minute limit resets.

x-ratelimit-reset-requests-day
integer
Example
1777023472

Unix timestamp when the daily limit resets.

Bad Request - missing or invalid parameters. Most responses use the standard error envelope. Two paths do not: a malformed image, and a forced tool_choice the model does not satisfy.

Media typeapplication/json
One of:
GeneralError

Other kind of errors

object
error
required
object
code
code

Error code

string
nullable
message
message

Error message

string
param
param

Error params

string
nullable
type
type

Error type

string
request_id
request_id

Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.

string
Example
{
"error": "Unable to decode image: cannot identify image file <_io.BytesIO object at 0x...>",
"error_code": null,
"error_param": null,
"error_type": "invalid_request_error"
}

Unauthorized - the API key is missing, incorrect or revoked.

Media typeapplication/json
GeneralError

Other kind of errors

object
error
required
object
code
code

Error code

string
nullable
message
message

Error message

string
param
param

Error params

string
nullable
type
type

Error type

string
request_id
request_id

Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}

Not found - the model ID does not exist.

Media typeapplication/json
GeneralError

Other kind of errors

object
error
required
object
code
code

Error code

string
nullable
message
message

Error message

string
param
param

Error params

string
nullable
type
type

Error type

string
request_id
request_id

Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}

Request timeout

Media typeapplication/json
GeneralError

Other kind of errors

object
error
required
object
code
code

Error code

string
nullable
message
message

Error message

string
param
param

Error params

string
nullable
type
type

Error type

string
request_id
request_id

Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}

Gone - the model has been deprecated and removed. This response is not JSON. It is served as content-type: text/plain; charset=utf-8 with a plain sentence as the whole body, and carries no error object and no request_id. Parsing it as JSON raises a decode error. The condition is permanent - change the model ID rather than retrying.

Media typetext/plain
string
Example
The requested model (MiniMax-M2.5) is not available on SambaNova Cloud. For more information, please visit https://docs.sambanova.ai/cloud/docs/resources/deprecations. For further inquiries, please contact our support team at help@sambanova.ai.

Unprocessable Entity - the model exists but is not enabled on your plan. Error code model_not_in_plan.

Media typeapplication/json
GeneralError

Other kind of errors

object
error
required
object
code
code

Error code

string
nullable
message
message

Error message

string
param
param

Error params

string
nullable
type
type

Error type

string
request_id
request_id

Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}

Too Many Requests

Media typeapplication/json
GeneralError

Other kind of errors

object
error
required
object
code
code

Error code

string
nullable
message
message

Error message

string
param
param

Error params

string
nullable
type
type

Error type

string
request_id
request_id

Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"param": "example",
"type": "example"
},
"request_id": "example"
}

Internal Server Error. Unexpected issue on server side.

Media typetext/plain
string

Service Temporarily Unavailable

Media typetext/plain
string
Example
Service Temporarily Unavailable