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

# LLM Chat Completion



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/runtime/v1/chat
openapi: 3.0.0
info:
  title: Runflow Runtime API
  description: >-
    Programmatic surface for the Runflow platform — used by the SDK, the CLI,
    the execution engine, and any server-to-server caller. Authenticate with an
    `x-api-key` header (or `Authorization: Bearer ...`).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.runflow.ai
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
tags: []
paths:
  /api/v1/runtime/v1/chat:
    post:
      tags:
        - Runtime API - Core
      summary: LLM Chat Completion
      operationId: RuntimeController_chatCompletion
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionDto'
      responses:
        '201':
          description: >-
            ChatResponse: { text, finishReason, usage: { promptTokens,
            completionTokens, totalTokens }, model, toolCalls? }.
        '400':
          description: Invalid chat payload.
        '401':
          description: Missing or invalid API key.
      security:
        - bearer: []
components:
  schemas:
    ChatCompletionDto:
      type: object
      properties:
        projectId:
          type: string
          description: Project ID
        provider:
          type: string
          description: LLM provider
          enum:
            - openai
            - anthropic
            - bedrock
            - groq
            - gemini
            - xai
            - custom
        model:
          type: string
          description: Model name
          example: gpt-4
        providerName:
          type: string
          description: Provider name (configured in LLM Providers)
          example: OpenAI Production
        legacy:
          type: boolean
          description: Use legacy Chat Completions API when true
          example: true
        messages:
          description: Messages
          type: array
          items:
            $ref: '#/components/schemas/ChatMessageDto'
        instructions:
          type: string
          description: System instructions
        temperature:
          type: number
          description: Temperature
          minimum: 0
          maximum: 2
          example: 0.7
        maxTokens:
          type: number
          description: Max tokens
          example: 1000
        topP:
          type: number
          description: Top P (nucleus sampling)
          minimum: 0
          maximum: 1
          example: 0.9
        frequencyPenalty:
          type: number
          description: Frequency penalty
          minimum: -2
          maximum: 2
          example: 0.3
        presencePenalty:
          type: number
          description: Presence penalty
          minimum: -2
          maximum: 2
          example: 0.2
        stop:
          description: Stop sequences
          example:
            - END
            - STOP
          type: array
          items:
            type: string
        seed:
          type: number
          description: Seed for reproducible outputs
          example: 12345
        tools:
          description: Tools available for the model to call
          type: array
          items:
            type: object
        responseFormat:
          type: object
          description: Response format for structured output
          example:
            type: json_object
        thinking:
          type: object
          description: Enable extended thinking/reasoning for supported models
          example:
            type: enabled
            budgetTokens: 5000
        serverTools:
          description: >-
            Server-side tools (provider-specific). Anthropic: web_search,
            code_execution
          example:
            - type: web_search_20250305
          type: array
          items:
            type: string
      required:
        - projectId
        - provider
        - model
        - messages
    ChatMessageDto:
      type: object
      properties:
        role:
          type: string
          description: Message role
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          description: Message content (string for text-only, array for multimodal)
          oneOf:
            - type: string
            - type: array
              items:
                oneOf:
                  - 6026e782-f00e-4160-91f9-6273d09a082f
                  - 0a3d1e2c-b187-47c0-93cf-752459492c26
                  - 746517e5-9fc3-489d-abcc-8b05b16969cc
        tool_calls:
          description: Tool calls (for assistant messages)
          type: array
          items:
            type: object
        tool_call_id:
          type: string
          description: Tool call ID (for tool response messages)
        name:
          type: string
          description: Tool name (for tool response messages)
      required:
        - role
        - content

````