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

# OpenClaw Chat Completion

> Send a chat completion request to an OpenClaw instance via the OpenAI-compatible API. Returns the assistant's response text.



## OpenAPI

````yaml /api-reference/v1/v1.1.0_openapi.json post /action/openclaw_chat_completion
openapi: 3.0.0
info:
  version: 1.1.0
  title: AI Actions - Get Data
  description: API specifications for 'Get Data' category AI actions.
  license:
    name: MIT
servers:
  - url: https://api-lr.agent.ai/v1
security:
  - bearerAuth: []
paths:
  /action/openclaw_chat_completion:
    post:
      tags:
        - OpenClaw
      summary: OpenClaw Chat Completion
      description: >-
        Send a chat completion request to an OpenClaw instance via the
        OpenAI-compatible API. Returns the assistant's response text.
      operationId: openclawChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                instance_ip:
                  type: string
                  description: >-
                    IP address or hostname of the OpenClaw instance (e.g.,
                    167.71.242.214). Do not include https:// prefix.
                auth_token:
                  type: string
                  description: Bearer token for authenticating with the OpenClaw Gateway.
                message:
                  type: string
                  x-ui: textarea
                  description: >-
                    The user message to send. For multi-turn conversations, use
                    'Messages JSON' instead or in addition.
                messages_json:
                  type: string
                  x-ui: textarea
                  description: >-
                    Optional JSON array of prior messages for multi-turn
                    conversations. Format:
                    [{"role":"user","content":"hi"},{"role":"assistant","content":"hello"}].
                    If 'Message' is also provided, it is appended as the latest
                    user turn.
                model:
                  type: string
                  description: >-
                    Model identifier. Format: 'openclaw:<agentId>' or
                    'agent:<agentId>'. Default: openclaw:main.
                  default: openclaw:main
                agent_id:
                  type: string
                  description: >-
                    OpenClaw agent ID sent via x-openclaw-agent-id header.
                    Default: main.
                  default: main
                session_key:
                  type: string
                  description: >-
                    Optional session key for conversation continuity. Requests
                    with the same session key share the same agent session on
                    the OpenClaw instance.
                stream:
                  type: boolean
                  description: Use Server-Sent Events (SSE) streaming for the response.
                  default: false
                timeout:
                  type: string
                  description: 'Request timeout in seconds. Default: 120.'
                  default: '120'
                output_variable_name:
                  type: string
                  description: >-
                    Variable name for the result. Access response with
                    {{openclaw_result.response_text}}.
                  default: openclaw_result
                  pattern: ^[a-zA-Z][a-zA-Z0-9_]*$
              required:
                - instance_ip
                - auth_token
                - output_variable_name
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
        '401':
          description: Unauthorized - invalid or missing bearer token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionResponse'
components:
  schemas:
    ActionResponse:
      type: object
      properties:
        status:
          type: integer
          format: int32
          description: HTTP status code of the action response
        response:
          type: object
          description: Response data from the action
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token from your account
        ([https://agent.ai/user/integrations#api](https://agent.ai/user/integrations#api))

````