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

# Create chat completion

> Generates a response based on a list of messages sent by the user to the model. The list of messages may include system messages, user messages, and assistant messages.<br/><br/>This endpoint allows other tools in the developer ecosystem to leverage poolside as a drop-in replacement for other models.



## OpenAPI

````yaml https://api.poolsi.de/openai/openapi.json post /openai/v1/chat/completions
openapi: 3.1.0
info:
  title: OpenAI Compatible API
  version: 1.0.0
servers: []
security: []
paths:
  /openai/v1/chat/completions:
    post:
      tags:
        - chat
      summary: Create chat completion
      description: >-
        Generates a response based on a list of messages sent by the user to the
        model. The list of messages may include system messages, user messages,
        and assistant messages.<br/><br/>This endpoint allows other tools in the
        developer ecosystem to leverage poolside as a drop-in replacement for
        other models.
      operationId: create-chat-completion
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatCompletionBody'
          application/octet-stream:
            schema:
              contentMediaType: application/octet-stream
              format: binary
              type: string
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
            text/event-stream:
              schema:
                description: Server-Sent Events stream.
                items:
                  properties:
                    data:
                      $ref: '#/components/schemas/ChatCompletion'
                  required:
                    - data
                  type: object
                title: Server Sent Events
                type: array
          description: Successful response - JSON when stream=false, SSE when stream=true
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1PromptModelError'
          description: Bad Request
      security:
        - bearerAuth: []
components:
  schemas:
    CreateChatCompletionBody:
      additionalProperties: true
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
            - https://example.com/openai/schemas/CreateChatCompletionBody.json
          format: uri
          readOnly: true
          type: string
        model:
          description: The model to use for the completion.
          type: string
        stream:
          description: >-
            If true, the response will be streamed as a series of events instead
            of a single JSON object.
          type: boolean
        stream_options:
          $ref: '#/components/schemas/StreamOptions'
          description: >-
            Options for streaming response. Only set this when you set stream:
            true.
      required:
        - model
      type: object
    ChatCompletion:
      additionalProperties: true
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
            - https://example.com/openai/schemas/ChatCompletion.json
          format: uri
          readOnly: true
          type: string
        choices:
          description: A list of chat completions from the model.
          items:
            $ref: '#/components/schemas/ChatCompletionChoice'
          minItems: 1
          type: array
        created:
          description: The Unix timestamp (in seconds) when the completion was created.
          format: int64
          type: integer
        model:
          description: The model used for the chat completion.
          type: string
        object:
          description: The object type 'chat.completion' or ''chat.completion.chunk'
          type: string
        usage:
          $ref: '#/components/schemas/CompletionUsage'
          description: Usage statistics for the chat completion.
      required:
        - model
        - created
        - object
        - choices
      type: object
    V1PromptModelError:
      additionalProperties: true
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
            - https://example.com/openai/schemas/V1PromptModelError.json
          format: uri
          readOnly: true
          type: string
        code:
          enum:
            - max-tokens-exceeded
            - model-not-found
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
      type: object
    StreamOptions:
      additionalProperties: true
      properties:
        include_usage:
          description: Whether to include usage statistics in the stream response.
          type: boolean
      type: object
    ChatCompletionChoice:
      additionalProperties: true
      properties:
        delta:
          $ref: '#/components/schemas/ChatCompletionMessage'
          description: The chat completion message when streaming.
        finish_reason:
          description: >-
            The reason the model stopped generating tokens. 'stop' the model hit
            a stop point, 'length' the maximum number of tokens was reached,
            'content_filter' content was avoided due to filtering.
          type: string
        index:
          description: The index of the choice in the list of choices.
          format: int64
          type: integer
        message:
          $ref: '#/components/schemas/ChatCompletionMessage'
          description: The chat completion message when not streaming.
      required:
        - index
        - finish_reason
      type: object
    CompletionUsage:
      additionalProperties: true
      properties:
        completion_tokens:
          description: Number of tokens in the completion.
          format: int64
          type: integer
        prompt_tokens:
          description: Number of tokens in the prompt.
          format: int64
          type: integer
        total_tokens:
          description: Total number of tokens used in the request 'prompt + completion'.
          format: int64
          type: integer
      required:
        - completion_tokens
        - prompt_tokens
        - total_tokens
      type: object
    ErrorDetail:
      additionalProperties: true
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    ChatCompletionMessage:
      additionalProperties: true
      properties:
        content:
          description: >-
            The text content of the message. Can be either a string or an array
            of content parts.
        role:
          description: The role of the author of this message.
          enum:
            - user
            - assistant
            - system
            - tool
          type: string
        tool_call_id:
          description: >-
            Identifies the tool call this message relates to, used for 'tool'
            role messages
          type: string
        tool_calls:
          items:
            $ref: '#/components/schemas/ToolCall'
          type: array
      type: object
    ToolCall:
      additionalProperties: true
      properties:
        function:
          $ref: '#/components/schemas/FunctionCall'
        id:
          description: The ID of the tool call.
          type: string
        type:
          enum:
            - function
          type: string
      required:
        - type
        - function
      type: object
    FunctionCall:
      additionalProperties: true
      properties:
        arguments:
          type: string
        name:
          type: string
      required:
        - name
        - arguments
      type: object
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````