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

# Chat Completion

> Receives a series of messages as input to generate a contextually relevant chat response using a large language model (LLM).



## OpenAPI

````yaml api-reference/openapi.json post /chat/completions
openapi: 3.1.0
info:
  version: 2.0.0
  title: Animus API
  description: >-
    Animus' API provides you with a variety of AI-driven capabilities. From
    generating text with our advanced large language models to creating
    customized content schedules, our API's applications are vast and versatile.

    Whether it's facilitating seamless conversation through predictive response
    or simulating a comprehensive content calendar, our advanced functionalities
    can cater to an array of feature requirements.
servers:
  - url: https://api.animusai.co/v2
security: []
paths:
  /chat/completions:
    post:
      tags:
        - Chat
      summary: Chat Completion
      description: >-
        Receives a series of messages as input to generate a contextually
        relevant chat response using a large language model (LLM).
      operationId: chat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  description: >-
                    A chronological list of messages that compose the current
                    conversation.
                  default:
                    - content: You are having a conversation with a friend.
                      role: system
                    - content: Hey, what have you been up to?
                      role: user
                  items:
                    type: object
                    description: >-
                      Each message within the conversation, attributed to either
                      a system, user, or assistant.
                    properties:
                      content:
                        type: string
                        description: The textual content of the message.
                      role:
                        type: string
                        description: >-
                          The role or origin of the message within the
                          conversation (e.g., user, system, assistant).
                        enum:
                          - user
                          - system
                          - assistant
                      name:
                        type: string
                        description: >-
                          A name associated with the role to help with
                          conversational context. (e.g. Bob, Alice, etc.)
                temperature:
                  type: number
                  format: float
                  description: >-
                    Adjusts randomness in the response generation, with lower
                    values yielding more predictable responses.
                  default: 1
                top_p:
                  type: number
                  format: float
                  description: >-
                    Filters the token set to those with cumulative probability
                    above this threshold, influencing diversity.
                  default: 1
                'n':
                  type: integer
                  description: Number of alternate responses to generate.
                  default: 1
                max_tokens:
                  type: integer
                  description: >-
                    Caps the number of tokens in the generated response. Lacks a
                    default to allow model-specific limits.
                  default: 150
                stop:
                  type: array
                  items:
                    type: string
                  description: >-
                    A set of strings which, when generated, signal the model to
                    cease response generation.
                  default:
                    - <|im_end|>
                stream:
                  type: boolean
                  description: >-
                    If set to true, the response is streamed back to the client
                    as it's being generated.
                  default: false
                presence_penalty:
                  type: number
                  format: float
                  description: >-
                    Adjusts likelihood of new words based on their existing
                    presence in the text. Discourages repetition when positive.
                  default: 1
                frequency_penalty:
                  type: number
                  format: float
                  description: >-
                    Penalizes words based on their frequency in the document to
                    encourage diversity.
                  default: 1
                best_of:
                  type: integer
                  description: >-
                    Generates several completions server-side and returns the
                    best. The definition of "best" depends on model and
                    settings.
                  default: 1
                top_k:
                  type: integer
                  description: >-
                    Limits consideration to the top k tokens, diversifying
                    outputs by reducing predictability.
                  default: 40
                repetition_penalty:
                  type: number
                  format: float
                  description: >-
                    Modifies likelihood of repeating tokens based on their
                    previous occurrence, counteracting model's repetition
                    tendency.
                  default: 1
                min_p:
                  type: number
                  format: float
                  description: >-
                    Sets a minimum probability threshold for tokens to be
                    considered for generation, further filtering the possible
                    outputs.
                  default: 0
                length_penalty:
                  type: number
                  format: float
                  description: >-
                    Adjusts the impact of sequence length on selection,
                    encouraging shorter or longer responses.
                  default: 1
                compliance:
                  type: boolean
                  description: >-
                    When true, verifies if the response contains any violations
                    such as inappropriate content.
                  default: true
                model:
                  type: string
                  description: The model to use for generating the response.
                  example: animuslabs/Vivian-llama3.1-70b-1.0-fp8
                reasoning:
                  type: boolean
                  description: >-
                    When true, enables reasoning/thinking content from the
                    model. For non-streaming responses, adds a reasoning field.
                    For streaming, thinking content appears in the stream.
                  default: false
                check_image_generation:
                  type: boolean
                  description: >-
                    ⚠️ ALPHA FEATURE: When true, the AI analyzes its response
                    and creates an image_prompt field if an image is requested
                    or desired. This feature is in alpha state and not
                    recommended for production use.
                  default: false
                tools:
                  type: array
                  description: >-
                    A list of tools the model may call. Currently, only
                    functions are supported as a tool.
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - function
                        description: >-
                          The type of the tool. Currently, only function is
                          supported.
                      function:
                        type: object
                        properties:
                          name:
                            type: string
                            description: The name of the function to be called.
                          description:
                            type: string
                            description: A description of what the function does.
                          parameters:
                            type: object
                            description: >-
                              The parameters the functions accepts, described as
                              a JSON Schema object.
                        required:
                          - name
                    required:
                      - type
                      - function
                tool_choice:
                  oneOf:
                    - type: string
                      enum:
                        - none
                        - auto
                      description: >-
                        none means the model will not call any tool and instead
                        generates a message. auto means the model can pick
                        between generating a message or calling one or more
                        tools.
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - function
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                              description: The name of the function to call.
                          required:
                            - name
                      required:
                        - type
                        - function
                  description: Controls which (if any) tool is called by the model.
                  default: auto
                autoTurn:
                  type: boolean
                  description: >-
                    When true, splits the API response into individual
                    conversational turns returned as an array called 'turns'.
                  default: false
              required:
                - messages
      responses:
        '200':
          description: The generated response along with relevant metadata.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: >-
                      Unique identifier for the chat completion provided by the
                      system.
                  object:
                    type: string
                    description: >-
                      Type indicator for the object, typically
                      'chat.completion'.
                  created:
                    type: integer
                    description: Unix timestamp when the response was created.
                  model:
                    type: string
                    description: Identifier for the model used in generating the response.
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                          description: >-
                            Index of the choice, useful when multiple responses
                            are generated.
                        message:
                          type: object
                          properties:
                            role:
                              type: string
                              description: >-
                                Indicates the assumed role of the message,
                                usually 'assistant'.
                            content:
                              type: string
                              description: >-
                                The generated message content intended to
                                continue the conversation.
                            reasoning:
                              type: string
                              description: >-
                                Content extracted from <think>...</think> blocks
                                when reasoning is enabled.
                            image_prompt:
                              type: string
                              description: >-
                                ⚠️ ALPHA FEATURE: Generated image prompt when
                                check_image_generation is enabled and AI
                                determines an image is requested or desired.
                                This feature is in alpha state.
                            tool_calls:
                              type: array
                              description: >-
                                The tool calls generated by the model, such as
                                function calls.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                    description: The ID of the tool call.
                                  type:
                                    type: string
                                    enum:
                                      - function
                                    description: >-
                                      The type of the tool. Currently, only
                                      function is supported.
                                  function:
                                    type: object
                                    properties:
                                      name:
                                        type: string
                                        description: The name of the function to call.
                                      arguments:
                                        type: string
                                        description: >-
                                          The arguments to call the function with,
                                          as generated by the model in JSON
                                          format.
                                    required:
                                      - name
                                      - arguments
                                required:
                                  - id
                                  - type
                                  - function
                            turns:
                              type: array
                              description: >-
                                Array of conversational turns when autoTurn is
                                enabled. Each turn contains a portion of the
                                response split for natural conversation flow.
                              items:
                                type: string
                                description: A single conversational turn content.
                            next:
                              type: boolean
                              description: >-
                                Indicates whether there are more turns expected
                                in the conversation when autoTurn is enabled.
                        finish_reason:
                          type: string
                          description: >-
                            The reason generation ceased, such as reaching a
                            stop condition.
                        compliance_violations:
                          type: array
                          description: >-
                            List of detected content violations for this
                            specific choice when compliance checking is enabled.
                          items:
                            type: string
                            enum:
                              - pedophilia
                              - beastiality
                              - murder
                              - rape
                              - incest
                              - gore
                              - prostitution
                              - drug_use
                    description: >-
                      Contains the generated responses, along with
                      meta-information about each.
                  usage:
                    type: object
                    properties:
                      prompt_tokens:
                        type: integer
                        description: Number of tokens consumed from the prompt.
                      completion_tokens:
                        type: integer
                        description: Number of tokens in the generated completion.
                      total_tokens:
                        type: integer
                        description: Sum of prompt and completion tokens.
                  compliance_violations:
                    type: array
                    description: >-
                      List of detected content violations when compliance
                      checking is enabled.
                    items:
                      type: string
                      enum:
                        - pedophilia
                        - beastiality
                        - murder
                        - rape
                        - incest
                        - gore
                        - prostitution
                        - drug_use
                    example:
                      - drug_use
                required:
                  - id
                  - object
                  - created
                  - choices
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````