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

# Chat Completions Endpoint

> OpenAI chat completions endpoint with intelligent context injection.

This endpoint provides:
- Unlimited context through intelligent memory management
- Automatic retrieval of relevant memories and knowledge
- Streaming support for real-time responses
- Tool calling and function execution
- Cost optimization through context optimization
- Diagnostic headers for monitoring and debugging

Headers:
- x-user-id: Unique user identifier for memory retrieval
- x-conversation-id: Conversation identifier for context continuity
- x-session-id: Session identifier for session-based context
- x-workspace-id: Workspace identifier for multi-tenant support
- x-collection-ids: JSON array of collection IDs for knowledge retrieval



## OpenAPI

````yaml api-reference/openapi.json post /api/v1/chat/completions
openapi: 3.1.0
info:
  title: FastAPI app
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/chat/completions:
    post:
      tags:
        - OpenAI Compatible Endpoint
      summary: Chat Completions Endpoint
      description: |-
        OpenAI chat completions endpoint with intelligent context injection.

        This endpoint provides:
        - Unlimited context through intelligent memory management
        - Automatic retrieval of relevant memories and knowledge
        - Streaming support for real-time responses
        - Tool calling and function execution
        - Cost optimization through context optimization
        - Diagnostic headers for monitoring and debugging

        Headers:
        - x-user-id: Unique user identifier for memory retrieval
        - x-conversation-id: Conversation identifier for context continuity
        - x-session-id: Session identifier for session-based context
        - x-workspace-id: Workspace identifier for multi-tenant support
        - x-collection-ids: JSON array of collection IDs for knowledge retrieval
      operationId: chat_completions_endpoint_api_v1_chat_completions_post
      parameters:
        - name: X-Workspace-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The workspace ID
            title: X-Workspace-Id
          description: The workspace ID
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - DualAuthScheme: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    DualAuthScheme:
      type: http
      scheme: bearer

````