---
title: "Chat"
method: POST
path: "/ai/chat"
tags: ["AI"]
---

# Chat

`POST /ai/chat`

Thirdweb AI chat completion API (BETA).

Send natural language queries to read on-chain data across any EVM chain - contracts, tokens, NFTs, balances, transactions, events and blocks - and to search the thirdweb documentation.

Read-only: the API answers questions and does not build, sign or send transactions.

Compatible with standard OpenAI API chat completion format, can be used raw or with any popular AI library.

**Authentication**: Pass `x-client-id` header for frontend usage from allowlisted origins or `x-secret-key` for backend usage.

## Request body

- object — Chat request
  - `messages` object[], required — Natural language query for the AI assistant
    - `role` 'user' | 'assistant' | 'system' | 'tool', required
    - `content` union, required
      - string
      - union[]
        - union
          - object — Image content
            - `type` 'image', required
            - `image_url` string, nullable
            - `b64` string, nullable
          - object — Text content
            - `type` 'text', required
            - `text` string, required
          - object — Transaction content
            - `type` 'transaction', required
            - `chain_id` number, required
            - `transaction_hash` string, required
  - `context` object — Context for the AI assistant
    - `from` string, nullable — Optional wallet address to answer questions about
    - `chain_ids` number[], nullable — Optional chain IDs for context
    - `networks` 'all' | 'mainnet' | 'testnet', nullable — Optional network filter for context
    - `session_id` string, nullable — Optional session ID for conversation continuity. If not provided, a new session will be created
  - `stream` boolean — Enable server streaming of the AI response

## Response `200`

AI assistant response or SSE stream when stream=true

- object — Chat response
  - `message` string, required — The AI assistant's response
  - `actions` union[], required
    - union
      - object — Sign a transaction
        - `session_id` string, required
        - `request_id` string, required
        - `source` string
        - `type` 'sign_transaction', required
        - `data` object, required
          - `chain_id` number, required
          - `function` string, nullable
          - `to` string, required
          - `value` string, required
          - `data` string, required
      - object — Sign a swap
        - `session_id` string, required
        - `request_id` string, required
        - `source` string
        - `type` 'sign_swap', required
        - `data` object, required
          - `transaction` object, required
            - `chain_id` number, required
            - `function` string, nullable
            - `to` string, required
            - `value` string, required
            - `data` string, required
          - `action` string, nullable, required
          - `intent` object, required
            - `origin_chain_id` number, required
            - `origin_token_address` string, required
            - `destination_chain_id` number, required
            - `destination_token_address` string, required
            - `amount` string, required
            - `sender` string, required
            - `receiver` string, required
            - `maxSteps` number, required
          - `from_token` object, required
            - `address` string, required
            - `chain_id` number, required
            - `amount` string, required
            - `symbol` string, required
            - `decimals` number, required
            - `price` number, nullable, required
          - `to_token` object, required
            - `address` string, required
            - `chain_id` number, required
            - `amount` string, required
            - `symbol` string, required
            - `decimals` number, required
            - `price` number, nullable, required
      - object — Monitor a transaction
        - `session_id` string, required
        - `request_id` string, required
        - `source` string
        - `type` 'monitor_transaction', required
        - `data` object, required
          - `transaction_id` string, required
  - `session_id` string, required
  - `request_id` string, required

---

[API](https://skmtc.dev/thirdweb/apis/thirdweb-api.md) · [All operations](https://skmtc.dev/thirdweb/apis/thirdweb-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/thirdweb/thirdweb-api/revisions/67ab6773fb59/schema)
