Chat completions
Create chat-based completion
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)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.infercom.ai/v1', apiKey: process.env['INFERCOM_API_KEY'],});
const completion = await client.chat.completions.create({ model: 'MiniMax-M2.7', messages: [{ role: 'user', content: 'Write a haiku about AI.' }],});
console.log(completion.choices[0].message.content);curl -X POST https://api.infercom.ai/v1/chat/completions \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "messages": [ {"role": "user", "content": "Write a haiku about AI."} ] }'Create a chat completion from a list of messages using Infercom’s OpenAI-compatible API. Supports streaming, function calling, vision, and JSON output.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Chat prompt and parameters
Chat completions request object
object
The model ID to use. Call GET /v1/models to retrieve the current list of available models. See available models for details.
Example
MiniMax-M2.7A list of messages comprising the conversation so far.
object
The role of the messages author, in this case system.
object
Type of content to send. in this case text.
String content of the message
object
The role of the messages author, in this case user.
object
Type of content to send. in this case text.
String content of the message
object
Type of content to send. in this case image_url.
object
Either a URL of the image or the base64 encoded image data. currently only base64 encoded image supported
object
Type of content to send. in this case audio_content.
object
The base64 encoded audio data.
object
The role of the messages author, in this case assistant.
object
Type of content to send. in this case text.
String content of the message
Chain-of-thought reasoning output from reasoning-capable models (e.g., gpt-oss-120b, MiniMax-M2.7). gemma-4-31B-it returns this field only when the request sets chat_template_kwargs: {"enable_thinking": true}. The token count is reported in usage.completion_tokens_details.reasoning_tokens. Note: The reasoning_details array from the OpenAI Harmony format is not returned.
Internal channel identifier emitted by gpt-oss-120b during streaming, and only on streams that carry no tools array. Holds analysis while the model reasons. No other model returns this field. Clients must ignore delta fields they do not recognise rather than validate the key set strictly.
The tool calls generated by the model.
object
The tool that the model called.
object
The name of the function to call.
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.
ID of the tool call.
Type of the tool cal. only function is supported.
Index of tool call chunk only used when using streaming
object
The role of the messages author, in this case tool.
object
Type of content to send. in this case text.
String content of the message
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.
Example
2048The 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.
Example
2048What 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.
Example
1Cumulative 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.
Example
1Amount 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.
Example
40Penalises 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.
Example
1.05Number 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 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.
If true, sampling is enabled during output generation. If false, deterministic decoding is used.
Example
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.
Options for streaming response. Only set this when setting stream as true
object
Specifies that the model should produce output as plain text.
object
Specifies that the model should produce output as a raw JSON object.
object
Example
{ "type": "json_object"}Specifies that the model should produce output conforming to a given JSON schema.
object
A JSON Schema definition the model’s structured output. Follows standard JSON Schema syntax.
object
Description the json schema
Name of the object schema
Actual json schema object
object
Whether or not to do an strict validation of the schema
Example
{ "type": "json_schema", "json_schema": { "name": "User", "description": "JSON schema for a simple user object", "strict": false, "schema": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique identifier for the user" }, "name": { "type": "string", "description": "Full name of the user" } }, "required": [ "id", "name" ] } }}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.
object
Specifies a tool the model should use. Use it to force the model to call that specific tool.
object
The name of the tool expected to be used by the model
The type of the tool. only function is supported.
Whether to enable parallel function calling during tool use.
A list of tools the model may call. Use this to provide a list of functions the model may generate JSON inputs for.
object
object
The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes.
A description of what the function does, used by the model to choose when and how to call the function.
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
The type of the tool. Currently, only function is supported.
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
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.
Example
trueExample
{ "enable_thinking": true}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.
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.
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.
Example
1Modify 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
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.
Responses
Section titled “Responses”Successful Response, or model output error (when unsuccessful tool calling or structured response generation)
Chat completion response returned by the model
object
object
object
The role of the messages author
The contents of the assistant message.
The tool calls generated by the model.
object
The tool that the model called.
object
The name of the function to call.
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.
ID of the tool call.
Type of the tool cal. only function is supported.
Index of tool call chunk only used when using streaming
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.
The index of the choice in the list of choices
Completion Log Probs object
object
object
object
The Unix timestamp (in seconds) of when the chat completion was created.
A unique identifier for the chat completion.
The model used for the chat completion.
The object type, always chat.completion.
Backend configuration that the model runs with.
Usage metrics for the completion, embeddings,transcription or translation request
object
Acceptance rate
Number of tokens generated in completion
Completion tokens per second after first token generation
Completion tokens per second after first token generation first ten
Completion tokens per second after first token generation
Completion tokens per second
Breakdown of the generated tokens. Returned by every model. Use it to budget and bill reasoning separately from the visible answer.
object
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}.
The Unix timestamp (in seconds) of when the generation finished.
Whether or not is last response, always true for non streaming response
Extra prompt token details. Not returned by /chat/completions. Prompt caching is reported on /responses as usage.input_tokens_details.cached_tokens instead.
object
Amount of cached tokens
Number of tokens used in the prompt sent
The Unix timestamp (in seconds) of when the generation started.
Also TTF, time (in seconds) taken to generate the first token
Time to first token measurement for graphing/monitoring purposes
The reason generation stopped. Values include stop (natural end or stop sequence), length (max_tokens reached), tool_calls (model invoked a tool).
Total time (in seconds) taken to generate the full generation
Prompt tokens + completion tokens
Tokens per second including prompt and completion
Streamed chunk of a chat completion response returned by the model
object
A list of chat completion choices.
object
Completion response delta chunk generated by streamed model responses.
object
The role of the messages author
The contents of the assistant message.
Chain-of-thought reasoning output from reasoning-capable models (e.g., gpt-oss-120b, MiniMax-M2.7). gemma-4-31B-it returns this field only when the request sets chat_template_kwargs: {"enable_thinking": true}. The token count is reported in usage.completion_tokens_details.reasoning_tokens. Note: The reasoning_details array from the OpenAI Harmony format is not returned.
Internal channel identifier emitted by gpt-oss-120b during streaming, and only on streams that carry no tools array. Holds analysis while the model reasons. No other model returns this field. Clients must ignore delta fields they do not recognise rather than validate the key set strictly.
The tool calls generated by the model.
object
The tool that the model called.
object
The name of the function to call.
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.
ID of the tool call.
Type of the tool cal. only function is supported.
Index of tool call chunk only used when using streaming
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.
The index of the choice in the list of choices
Completion Log Probs object
object
object
object
The Unix timestamp (in seconds) of when the chat completion was created.
A unique identifier for the chat completion.
The model used for the chat completion.
The object type, always chat.completion.chunk.
Backend configuration that the model runs with.
Usage metrics for the completion, embeddings,transcription or translation request
object
Acceptance rate
Number of tokens generated in completion
Completion tokens per second after first token generation
Completion tokens per second after first token generation first ten
Completion tokens per second after first token generation
Completion tokens per second
Breakdown of the generated tokens. Returned by every model. Use it to budget and bill reasoning separately from the visible answer.
object
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}.
The Unix timestamp (in seconds) of when the generation finished.
Whether or not is last response, always true for non streaming response
Extra prompt token details. Not returned by /chat/completions. Prompt caching is reported on /responses as usage.input_tokens_details.cached_tokens instead.
object
Amount of cached tokens
Number of tokens used in the prompt sent
The Unix timestamp (in seconds) of when the generation started.
Also TTF, time (in seconds) taken to generate the first token
Time to first token measurement for graphing/monitoring purposes
The reason generation stopped. Values include stop (natural end or stop sequence), length (max_tokens reached), tool_calls (model invoked a tool).
Total time (in seconds) taken to generate the full generation
Prompt tokens + completion tokens
Tokens per second including prompt and completion
Returned with HTTP 400 when a forced tool_choice names a function and the model produces no valid function call. This response does not use the standard error envelope. error is a string, not an object, and there is no request_id. A client that reads error.message gets undefined here.
object
The error message, as a plain string.
Always null on this path.
The text the model produced instead of the tool call. Read it if you need to recover the answer.
Always null on this path.
A sentence describing the failure, for example Invalid function calling output.. Note that this holds prose, not a code such as invalid_request_error.
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
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 }}Headers
Section titled “Headers”Example
a0b08d8a-1893-45d6-a0f4-7ad6fdeb5443Unique identifier for this inference request, useful for debugging and support.
Example
250Maximum requests allowed per minute.
Example
50000Maximum requests allowed per day.
Example
247Remaining requests in the current minute window.
Example
49988Remaining requests in the current day.
Example
1776937132Unix timestamp when the per-minute limit resets.
Example
1777023472Unix 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.
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
Returned with HTTP 400 when the API cannot decode an image supplied in a vision request. This is a permanent error - do not retry it. This response does not use the standard error envelope. error is a string, not an object, and there is no request_id.
object
The error message, as a plain string.
Always null on this path.
Always null on this path.
The error class, for example invalid_request_error.
Returned with HTTP 400 when a forced tool_choice names a function and the model produces no valid function call. This response does not use the standard error envelope. error is a string, not an object, and there is no request_id. A client that reads error.message gets undefined here.
object
The error message, as a plain string.
Always null on this path.
The text the model produced instead of the tool call. Read it if you need to recover the answer.
Always null on this path.
A sentence describing the failure, for example Invalid function calling output.. Note that this holds prose, not a code such as invalid_request_error.
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.
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
Examplegenerated
{ "error": { "code": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Not found - the model ID does not exist.
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
Examplegenerated
{ "error": { "code": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Request timeout
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
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.
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.
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
Examplegenerated
{ "error": { "code": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Too Many Requests
Other kind of errors
object
object
Error code
Error message
Error params
Error type
Unique identifier for the request. Quote it in any support report. Absent on the two responses that use the flat error shape.
Examplegenerated
{ "error": { "code": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Internal Server Error. Unexpected issue on server side.
Service Temporarily Unavailable
Example
Service Temporarily Unavailable