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

# AI chat completion

> Internal endpoint on `agent-worker`. Sends a chat-style prompt
to the configured multi-provider AI manager and returns the
completion. Supports custom system prompts, temperature, and
max tokens.




## OpenAPI

````yaml /docs/openapi-minimal.yaml post /agent/chat
openapi: 3.0.3
info:
  title: Hoox API
  description: |
    REST API for the Hoox algorithmic trading platform.

    Ingest trade signals, check system health, and manage DeFi wallet
    operations on the Cloudflare edge. All requests are handled by the
    Hoox gateway worker (`workers/hoox`) running at the network edge.
  version: 1.0.0
  contact:
    name: Hoox Support
    email: support@hoox.sh
servers:
  - url: https://api.hoox.sh
    description: Production API
  - url: https://staging.hoox.sh
    description: Staging environment
security: []
paths:
  /agent/chat:
    post:
      tags:
        - AI Agent
      summary: AI chat completion
      description: |
        Internal endpoint on `agent-worker`. Sends a chat-style prompt
        to the configured multi-provider AI manager and returns the
        completion. Supports custom system prompts, temperature, and
        max tokens.
      operationId: agentChat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  description: Pre-built chat messages
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                      content:
                        type: string
                systemPrompt:
                  type: string
                  description: System prompt (used if `messages` is omitted)
                  example: You are a helpful trading assistant.
                prompt:
                  type: string
                  description: User prompt (used if `messages` is omitted)
                  example: Summarize my trade history and win rate today.
                temperature:
                  type: number
                  minimum: 0
                  maximum: 2
                maxTokens:
                  type: integer
                  minimum: 1
      responses:
        '200':
          description: Chat completion returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  response:
                    type: string
                  model:
                    type: string
                  provider:
                    type: string
                  error:
                    type: string
                    nullable: true
        '400':
          description: Invalid payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Internal authentication missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Upstream provider failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        requestId:
          type: string
          format: uuid
          description: Request trace identifier
          example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
        error:
          type: string
          description: Human-readable error description
          example: Invalid JSON payload structure.

````