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

# Create chat completion

> Generates a model response for the given conversation. Compatible with the OpenAI chat completions API.



## OpenAPI

````yaml https://dev.hub.oxen.ai/api/_spec/oxen_hub_api.json post /api/ai/chat/completions
openapi: 3.0.0
info:
  title: oxen
  version: 0.224.2
servers:
  - url: https://dev.hub.oxen.ai
    variables: {}
security: []
tags: []
paths:
  /api/ai/chat/completions:
    post:
      tags: []
      summary: Create chat completion
      description: >-
        Generates a model response for the given conversation. Compatible with
        the OpenAI chat completions API.
      operationId: OxenApiWeb.Controllers.ModelController.get_model_response
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
        description: Chat completion request
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
          description: Chat completion
        '400':
          content:
            application/json:
              schema:
                type: object
          description: Invalid request
      callbacks: {}
components:
  schemas:
    ChatCompletionRequest:
      description: >-
        Request to generate a chat completion. Compatible with the OpenAI chat
        completions API.
      properties:
        frequency_penalty:
          nullable: true
          type: number
        max_tokens:
          nullable: true
          type: integer
        messages:
          items:
            properties:
              content:
                oneOf:
                  - type: string
                  - items:
                      type: object
                    type: array
              name:
                nullable: true
                type: string
              role:
                enum:
                  - system
                  - user
                  - assistant
                  - tool
                type: string
              tool_call_id:
                nullable: true
                type: string
              tool_calls:
                items:
                  type: object
                nullable: true
                type: array
            required:
              - role
              - content
            type: object
          type: array
        model:
          description: Model ID to use
          example: gpt-4o
          type: string
        presence_penalty:
          nullable: true
          type: number
        response_format:
          nullable: true
          type: object
        temperature:
          nullable: true
          type: number
        tool_choice:
          nullable: true
          oneOf:
            - type: string
            - type: object
        tools:
          items:
            type: object
          nullable: true
          type: array
        top_p:
          nullable: true
          type: number
      required:
        - model
        - messages
      title: ChatCompletionRequest
      type: object
    ChatCompletionResponse:
      properties:
        choices:
          items:
            properties:
              finish_reason:
                type: string
              index:
                type: integer
              message:
                properties:
                  content:
                    nullable: true
                    type: string
                  role:
                    type: string
                  tool_calls:
                    items:
                      type: object
                    nullable: true
                    type: array
                type: object
            type: object
          type: array
        created:
          type: integer
        id:
          type: string
        model:
          type: string
        object:
          enum:
            - chat.completion
          type: string
        usage:
          nullable: true
          properties:
            completion_tokens:
              type: integer
            prompt_tokens:
              type: integer
            total_tokens:
              type: integer
          type: object
      title: ChatCompletionResponse
      type: object

````