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

# Create a chat completion



## OpenAPI

````yaml https://app.halesis.com/openapi.json post /v1/chat/completions
openapi: 3.0.0
info:
  title: Halesis API Documentation
  version: 1.0.0
  description: Spec for Halesis API.
servers:
  - url: https://api.halesis.com
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Chat
  - name: Models
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat
      summary: Create a chat completion
      operationId: post-external-api-v1-chat-completions
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequestSchema'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponseSchema'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatCompletionChunkSchema'
components:
  schemas:
    ChatCompletionRequestSchema:
      type: object
      properties:
        model:
          type: string
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessageSchema'
          minItems: 1
        temperature:
          type: number
          default: 0.7
        stream:
          type: boolean
          default: false
        max_tokens:
          type: integer
          exclusiveMinimum: true
          maximum: 4096
          minimum: 0
      required:
        - model
        - messages
    ChatCompletionResponseSchema:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - chat.completion
        created:
          type: number
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: number
              message:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                  content:
                    type: string
                required:
                  - role
                  - content
              finish_reason:
                type: string
            required:
              - index
              - message
              - finish_reason
        usage:
          type: object
          properties:
            prompt_tokens:
              type: number
            completion_tokens:
              type: number
            total_tokens:
              type: number
          required:
            - prompt_tokens
            - completion_tokens
            - total_tokens
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
    ChatCompletionChunkSchema:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - chat.completion.chunk
        created:
          type: number
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: number
              delta:
                type: object
                properties:
                  role:
                    type: string
                  content:
                    type: string
              finish_reason:
                type: string
                nullable: true
            required:
              - index
              - delta
              - finish_reason
      required:
        - id
        - object
        - created
        - model
        - choices
    ChatMessageSchema:
      type: object
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
        content:
          type: string
      required:
        - role
        - content
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.