v1

latestOpenAPI 3.1.02026-07-13570316.1 KB
AI

Chat

Thirdweb AI chat completion API (BETA).

Send natural language queries to interact with any EVM chain, read data, prepare transactions, swap tokens, deploy contracts, payments and more.

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": "Send 0.01 ETH to vitalik.eth"
    }
  ],
  "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"
    }
  ]
}