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

# Create Generation

> Send a chat completion request to a selected model



## OpenAPI

````yaml POST /v1/chat/completions
openapi: 3.0.1
info:
  title: OpenTools API
  description: API for OpenTools chat completions
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.opentools.com
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      description: Send a chat completion request to a selected model
      operationId: chatCompletion
      requestBody:
        description: Chat completion request parameters
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
        required: true
      responses:
        '200':
          description: Successful completion
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: The model ID to use
        messages:
          type: array
          description: A list of messages comprising the conversation so far
          items:
            $ref: '#/components/schemas/Message'
        stream:
          type: boolean
          description: Whether to stream the response
          default: false
        tools:
          type: array
          description: A list of tools the model may use
          items:
            $ref: '#/components/schemas/Tool'
        tool_choice:
          type: object
          description: Controls which tool is used by the model
        temperature:
          type: number
          format: float
          description: What sampling temperature to use
          minimum: 0
          maximum: 2
        max_tokens:
          type: integer
          description: The maximum number of tokens to generate
          minimum: 1
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: A unique identifier for the completion
        choices:
          type: array
          description: A list of completion choices
          items:
            type: object
            properties:
              message:
                $ref: '#/components/schemas/Message'
              finish_reason:
                type: string
                description: The reason the model stopped generating tokens
              index:
                type: integer
                description: The index of the choice in the list
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
              description: Number of tokens in the prompt
            completion_tokens:
              type: integer
              description: Number of tokens in the completion
            total_tokens:
              type: integer
              description: Total number of tokens used
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Error code
        message:
          type: string
          description: Error message
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: The role of the message sender
          enum:
            - system
            - user
            - assistant
            - function
            - tool
        content:
          type: string
          description: The content of the message
        tool_calls:
          type: array
          description: Tool calls made by the assistant
          items:
            type: object
            properties:
              id:
                type: string
                description: The ID of the tool call
              function:
                type: object
                properties:
                  name:
                    type: string
                    description: The name of the function
                  arguments:
                    type: string
                    description: The arguments for the function as a JSON string
              type:
                type: string
                description: The type of tool call
                enum:
                  - function
        name:
          type: string
          description: The name of the function or tool
    Tool:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          description: The type of the tool
          enum:
            - function
        function:
          type: object
          required:
            - name
            - description
          properties:
            name:
              type: string
              description: The name of the function
            description:
              type: string
              description: A description of what the function does
            parameters:
              type: object
              description: >-
                The parameters the function accepts, described as a JSON Schema
                object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Authentication using a bearer token

````