Skip to main content
POST
/
messages
Python
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.infercom.ai",
    api_key="your-infercom-api-key",
)

message = client.messages.create(
    model="MiniMax-M2.7",
    max_tokens=1024,
curl --request POST \
  --url https://api.infercom.ai/v1/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "MiniMax-M2.7",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ]
}
'
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    model: 'MiniMax-M2.7',
    max_tokens: 1024,
    messages: [{role: 'user', content: 'Hello, how are you?'}]
  })
};

fetch('https://api.infercom.ai/v1/messages', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.infercom.ai/v1/messages",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'model' => 'MiniMax-M2.7',
    'max_tokens' => 1024,
    'messages' => [
        [
                'role' => 'user',
                'content' => 'Hello, how are you?'
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.infercom.ai/v1/messages"

	payload := strings.NewReader("{\n  \"model\": \"MiniMax-M2.7\",\n  \"max_tokens\": 1024,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Hello, how are you?\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.infercom.ai/v1/messages")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"MiniMax-M2.7\",\n  \"max_tokens\": 1024,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Hello, how are you?\"\n    }\n  ]\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.infercom.ai/v1/messages")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"MiniMax-M2.7\",\n  \"max_tokens\": 1024,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Hello, how are you?\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello! I'm doing well, thank you for asking. How can I help you today?"
    }
  ],
  "model": "MiniMax-M2.7",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 12,
    "output_tokens": 18
  }
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "messages: field required"
  },
  "request_id": "abc123"
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "The model `nonexistent-model` does not exist or you do not have access to it.",
    "param": "model"
  },
  "request_id": "2f8274e5"
}
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "The model `nonexistent-model` does not exist or you do not have access to it.",
    "param": "model",
    "code": "model_not_found"
  },
  "request_id": "def456"
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "The model `nonexistent-model` does not exist or you do not have access to it.",
    "param": "model"
  },
  "request_id": "2f8274e5"
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "The model `nonexistent-model` does not exist or you do not have access to it.",
    "param": "model"
  },
  "request_id": "2f8274e5"
}

Authorizations

Authorization
string
header
required

Infercom API Key

Headers

anthropic-version
string

The API version to use. Supported but optional.

Example:

"2023-06-01"

Body

application/json

Message creation parameters

Request body for creating a message.

model
string
required

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.7"

messages
Input Message · object[]
required

The conversation messages.

Minimum array length: 1
max_tokens
integer
required

The maximum number of tokens to generate.

Required range: x >= 1
Example:

1024

system

System prompt providing context and instructions.

temperature
number

Sampling temperature between 0 and 1.

Required range: 0 <= x <= 1
Example:

1

top_p
number

Nucleus sampling parameter.

Required range: 0 <= x <= 1
top_k
integer

Top-k sampling parameter.

Required range: x >= 0
stop_sequences
string[]

Custom stop sequences.

stream
boolean
default:false

Whether to stream the response.

tools
Tool · object[]

Tools the model may use.

tool_choice
Tool Choice Auto · object

How the model should use the provided tools.

Response

Successful response. Returns a Message object (non-streaming), or a stream of Server-Sent Events (when stream: true).

A message response from the API.

id
string
required

Unique message identifier.

Example:

"msg_013Zva2CMHLNnXjNJJKqJ2EF"

type
string
required

Object type, always "message".

Allowed value: "message"
role
string
required

The role of the message author, always "assistant".

Allowed value: "assistant"
content
(Text Block · object | Tool Use Block · object)[]
required

The generated content blocks.

A text content block in an Anthropic message.

model
string
required

The model used to generate the response.

Example:

"MiniMax-M2.7"

stop_reason
enum<string> | null
required

The reason generation stopped.

Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use
usage
Usage · object
required

Token usage information.

stop_sequence
string | null

The stop sequence that triggered stopping, if any.