AI

Blockchain LLM

The thirdweb API provides an OpenAI-compatible chat completion interface optimized for blockchain interactions.

You can use it to:

  • Query on-chain data
  • Analyze transactions
  • Fetch token info and prices
  • Execute or prepare contract calls and swaps
  • Deploy contracts
  • Generate images and search the web

and more.

QuickStart

You can use thirdweb AI with the HTTP API directly, the AI SDK, or with any OpenAI-compatible client library.

Request

fetch("https://api.thirdweb.com/ai/chat", {
method: "POST",
headers: {
"x-secret-key": "<your-project-secret-key>",
},
body: {
messages: [
{
role: "user",
content: "Send 0.01 ETH to vitalik.eth",
},
],
context: {
chain_ids: [8453],
from: "0x1234567890123456789012345678901234567890",
},
stream: false,
},
});

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"
}
]
}

Going further