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.

post/ai/chat

Request body

streamboolean

Enable server streaming of the AI response

Example request

{
  "messages": [
    {
      "role": "user",
      "content": "What is the USDC balance of vitalik.eth on Base?"
    }
  ],
  "context": {
    "chain_ids": [
      8453
    ],
    "from": "0x1234567890123456789012345678901234567890"
  },
  "stream": false
}

Response

AI assistant response or SSE stream when stream=true

messagestring required

The AI assistant's response

session_idstring required
request_idstring required

Example response

{
  "message": "I've prepared a native ETH transfer as requested. Would you like to proceed with executing this transfer?",
  "session_id": "123",
  "request_id": "456",
  "actions": [
    {
      "type": "sign_transaction",
      "data": {
        "chain_id": 8453,
        "to": "0x1234567890123456789012345678901234567890",
        "value": "10000000000000000",
        "data": "0x"
      },
      "session_id": "123",
      "request_id": "456",
      "source": "model"
    }
  ]
}

Changes