> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infercom.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a message

> Send a structured list of input messages and the model will generate the next message in the conversation. This endpoint is compatible with Anthropic's Messages API format, allowing you to use the Anthropic SDK with Infercom models.



## OpenAPI

````yaml /en/api-reference/openapi_infercom.yml post /messages
openapi: 3.1.1
info:
  title: Infercom Inference Service API
  description: Infercom Inference Service API Specification
  version: 1.0.0
  termsOfService: https://infercom.ai/terms-of-service
  contact:
    email: support@infercom.ai
    name: Infercom Support
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.infercom.ai/v1
security:
  - api_key: []
externalDocs:
  description: Find out more in the official Infercom docs
  url: /en/api-reference/overview
paths:
  /messages:
    post:
      tags:
        - Messages
      summary: Create a message
      description: >-
        Send a structured list of input messages and the model will generate the
        next message in the conversation. This endpoint is compatible with
        Anthropic's Messages API format, allowing you to use the Anthropic SDK
        with Infercom models.
      operationId: createMessage
      parameters:
        - name: anthropic-version
          in: header
          required: false
          schema:
            type: string
            example: '2023-06-01'
          description: The API version to use. Supported but optional.
      requestBody:
        required: true
        description: Message creation parameters
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicMessageRequest'
      responses:
        '200':
          description: >-
            Successful response. Returns a Message object (non-streaming), or a
            stream of Server-Sent Events (when stream: true).
          headers:
            inference-id:
              $ref: '#/components/headers/InferenceId'
            x-ratelimit-limit-requests:
              $ref: '#/components/headers/RateLimitRequests'
            x-ratelimit-limit-requests-day:
              $ref: '#/components/headers/RateLimitRequestsDay'
            x-ratelimit-remaining-requests:
              $ref: '#/components/headers/RateLimitRemainingRequests'
            x-ratelimit-remaining-requests-day:
              $ref: '#/components/headers/RateLimitRemainingRequestsDay'
            x-ratelimit-reset-requests:
              $ref: '#/components/headers/RateLimitResetRequests'
            x-ratelimit-reset-requests-day:
              $ref: '#/components/headers/RateLimitResetRequestsDay'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicMessage'
        '400':
          description: Bad Request - Missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
              examples:
                missing_field:
                  summary: Required field missing
                  value:
                    type: error
                    error:
                      type: invalid_request_error
                      message: 'messages: field required'
                    request_id: abc123
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        '404':
          description: Not found - Model does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
              examples:
                model_not_found:
                  summary: Model not found
                  value:
                    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
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
      security:
        - api_key: []
      x-codeSamples:
        - lang: Python
          source: |-
            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,
components:
  schemas:
    AnthropicMessageRequest:
      title: Create Message Request
      type: object
      description: Request body for creating a message.
      properties:
        model:
          type: string
          description: >-
            The model ID to use. Call `GET /v1/models` to retrieve the current
            list of available models. See [available
            models](/en/models/infercomcloud-models) for details.
          example: MiniMax-M2.7
        messages:
          type: array
          items:
            $ref: '#/components/schemas/AnthropicInputMessage'
          description: The conversation messages.
          minItems: 1
        max_tokens:
          type: integer
          description: The maximum number of tokens to generate.
          minimum: 1
          example: 1024
        system:
          anyOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/AnthropicTextBlock'
          description: System prompt providing context and instructions.
        temperature:
          type: number
          description: Sampling temperature between 0 and 1.
          minimum: 0
          maximum: 1
          example: 1
        top_p:
          type: number
          description: Nucleus sampling parameter.
          minimum: 0
          maximum: 1
        top_k:
          type: integer
          description: Top-k sampling parameter.
          minimum: 0
        stop_sequences:
          type: array
          items:
            type: string
          description: Custom stop sequences.
        stream:
          type: boolean
          description: Whether to stream the response.
          default: false
        tools:
          type: array
          items:
            $ref: '#/components/schemas/AnthropicTool'
          description: Tools the model may use.
        tool_choice:
          $ref: '#/components/schemas/AnthropicToolChoice'
      required:
        - model
        - messages
        - max_tokens
      example:
        model: MiniMax-M2.7
        max_tokens: 1024
        messages:
          - role: user
            content: Hello, how are you?
    AnthropicMessage:
      title: Message Response
      type: object
      description: A message response from the API.
      properties:
        id:
          type: string
          description: Unique message identifier.
          example: msg_013Zva2CMHLNnXjNJJKqJ2EF
        type:
          type: string
          const: message
          description: Object type, always "message".
        role:
          type: string
          const: assistant
          description: The role of the message author, always "assistant".
        content:
          type: array
          items:
            $ref: '#/components/schemas/AnthropicOutputContentBlock'
          description: The generated content blocks.
        model:
          type: string
          description: The model used to generate the response.
          example: MiniMax-M2.7
        stop_reason:
          type: string
          enum:
            - end_turn
            - max_tokens
            - stop_sequence
            - tool_use
          description: The reason generation stopped.
          nullable: true
        stop_sequence:
          type: string
          description: The stop sequence that triggered stopping, if any.
          nullable: true
        usage:
          $ref: '#/components/schemas/AnthropicUsage'
      required:
        - id
        - type
        - role
        - content
        - model
        - stop_reason
        - usage
      example:
        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
    AnthropicError:
      title: Anthropic Error
      type: object
      description: Error response in Anthropic format.
      properties:
        type:
          type: string
          const: error
        error:
          type: object
          properties:
            type:
              type: string
              description: The error type.
              enum:
                - invalid_request_error
                - authentication_error
                - permission_error
                - not_found_error
                - rate_limit_error
                - api_error
            message:
              type: string
              description: A human-readable error message.
            param:
              type: string
              description: The parameter that caused the error.
              nullable: true
            code:
              type: string
              description: An error code.
              nullable: true
          required:
            - type
            - message
        request_id:
          type: string
          description: Unique request identifier for debugging.
      required:
        - type
        - error
      example:
        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
    AnthropicInputMessage:
      title: Input Message
      type: object
      description: A message in the conversation.
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          description: The role of the message author.
        content:
          anyOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/AnthropicInputContentBlock'
          description: The content of the message.
      required:
        - role
        - content
    AnthropicTextBlock:
      title: Text Block
      type: object
      description: A text content block in an Anthropic message.
      properties:
        type:
          type: string
          const: text
          description: The type of content block.
        text:
          type: string
          description: The text content.
      required:
        - type
        - text
    AnthropicTool:
      title: Tool
      type: object
      description: Definition of a tool the model may use.
      properties:
        name:
          type: string
          description: The name of the tool.
          pattern: ^[a-zA-Z0-9_-]{1,128}$
        description:
          type: string
          description: Description of what the tool does.
        input_schema:
          type: object
          additionalProperties: true
          description: JSON Schema for the tool's input parameters.
      required:
        - name
        - input_schema
    AnthropicToolChoice:
      title: Tool Choice
      description: How the model should use the provided tools.
      oneOf:
        - $ref: '#/components/schemas/AnthropicToolChoiceAuto'
        - $ref: '#/components/schemas/AnthropicToolChoiceAny'
        - $ref: '#/components/schemas/AnthropicToolChoiceTool'
      discriminator:
        propertyName: type
        mapping:
          auto:
            $ref: '#/components/schemas/AnthropicToolChoiceAuto'
          any:
            $ref: '#/components/schemas/AnthropicToolChoiceAny'
          tool:
            $ref: '#/components/schemas/AnthropicToolChoiceTool'
    AnthropicOutputContentBlock:
      title: Output Content Block
      description: A content block in an output message.
      oneOf:
        - $ref: '#/components/schemas/AnthropicTextBlock'
        - $ref: '#/components/schemas/AnthropicToolUseBlock'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/AnthropicTextBlock'
          tool_use:
            $ref: '#/components/schemas/AnthropicToolUseBlock'
    AnthropicUsage:
      title: Usage
      type: object
      description: Token usage information.
      properties:
        input_tokens:
          type: integer
          description: The number of input tokens used.
        output_tokens:
          type: integer
          description: The number of output tokens generated.
      required:
        - input_tokens
        - output_tokens
    AnthropicInputContentBlock:
      title: Input Content Block
      description: A content block in an input message.
      oneOf:
        - $ref: '#/components/schemas/AnthropicTextBlock'
        - $ref: '#/components/schemas/AnthropicToolUseBlock'
        - $ref: '#/components/schemas/AnthropicToolResultBlock'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/AnthropicTextBlock'
          tool_use:
            $ref: '#/components/schemas/AnthropicToolUseBlock'
          tool_result:
            $ref: '#/components/schemas/AnthropicToolResultBlock'
    AnthropicToolChoiceAuto:
      title: Tool Choice Auto
      type: object
      properties:
        type:
          type: string
          const: auto
      required:
        - type
    AnthropicToolChoiceAny:
      title: Tool Choice Any
      type: object
      properties:
        type:
          type: string
          const: any
      required:
        - type
    AnthropicToolChoiceTool:
      title: Tool Choice Tool
      type: object
      properties:
        type:
          type: string
          const: tool
        name:
          type: string
          description: The name of the specific tool to use.
      required:
        - type
        - name
    AnthropicToolUseBlock:
      title: Tool Use Block
      type: object
      description: A tool use content block, indicating the model wants to call a tool.
      properties:
        type:
          type: string
          const: tool_use
          description: The type of content block.
        id:
          type: string
          description: Unique identifier for this tool use.
        name:
          type: string
          description: The name of the tool to call.
        input:
          type: object
          additionalProperties: true
          description: The input parameters for the tool call.
      required:
        - type
        - id
        - name
        - input
    AnthropicToolResultBlock:
      title: Tool Result Block
      type: object
      description: A tool result content block, providing the output of a tool call.
      properties:
        type:
          type: string
          const: tool_result
          description: The type of content block.
        tool_use_id:
          type: string
          description: The ID of the tool use this result is for.
        content:
          anyOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/AnthropicTextBlock'
          description: The result content.
        is_error:
          type: boolean
          description: Whether this result represents an error.
      required:
        - type
        - tool_use_id
  headers:
    InferenceId:
      description: >-
        Unique identifier for this inference request, useful for debugging and
        support.
      schema:
        type: string
        example: a0b08d8a-1893-45d6-a0f4-7ad6fdeb5443
    RateLimitRequests:
      description: Maximum requests allowed per minute.
      schema:
        type: integer
        example: 250
    RateLimitRequestsDay:
      description: Maximum requests allowed per day.
      schema:
        type: integer
        example: 50000
    RateLimitRemainingRequests:
      description: Remaining requests in the current minute window.
      schema:
        type: integer
        example: 247
    RateLimitRemainingRequestsDay:
      description: Remaining requests in the current day.
      schema:
        type: integer
        example: 49988
    RateLimitResetRequests:
      description: Unix timestamp when the per-minute limit resets.
      schema:
        type: integer
        example: 1776937132
    RateLimitResetRequestsDay:
      description: Unix timestamp when the daily limit resets.
      schema:
        type: integer
        example: 1777023472
  securitySchemes:
    api_key:
      type: http
      description: Infercom API Key
      scheme: bearer
      bearerFormat: apiKey

````