thirdweb AI - Chat API

We’ve added an OpenAI-compatible AI Chat endpoint specialized for blockchain interactions, powered by thirdweb’s 't0' model. It can query live on-chain data, analyze transactions, prepare contract calls, swaps, and more via a single /ai/chat
call.
Docs: https://portal.thirdweb.com/ai/chat
Playground: https://playground.thirdweb.com/ai/chat
API reference: https://api.thirdweb.com/reference#tag/ai/post/ai/chat
Capabilities
- Realtime chain data: balances, prices, metadata, transaction & contract insights.
- Prepare on-chain operations: contract writes, native/token transfers, swaps, and deployments. Generates call data & parameters.
- Actionable outputs: returns structured
actions
(e.g.,sign_transaction
) you can pass to your signing/execution flow. - Context-aware: include wallet + chain context for targeted answers.
- OpenAI-compatible: works with standard Chat Completions clients using
model: "t0"
.
Common use cases
- Explore blockchain data — find interesting contract and tokens, analyze transactions, follow transfers, etc
- Wallet assistant — “Send 10 USDC on Base to vitalik.eth”, "Swap 0.1 ETH to USDT on Arbitrum", etc
- Token launcher — Create tradeable tokens with natural language, generate images for the metadata.
Get started
1) HTTP example
const res = await fetch("https://api.thirdweb.com/ai/chat", {
method: "POST",
headers: {
"content-type": "application/json",
"x-secret-key": process.env.THIRDWEB_SECRET_KEY!, // project secret
},
body: JSON.stringify({
messages: [{ role: "user", content: "Transfer 0.01 ETH to vitalik.eth on Base" }],
stream: false,
context: {
from: "0xYourWallet",
chain_ids: [8453], // Base
},
}),
});
const json = await res.json();
// json.actions[0] may be { type: "sign_transaction", data: { to, value, data, chainId } }
2) OpenAI-compatible client (Python)
from openai import OpenAI
client = OpenAI(
base_url="https://api.thirdweb.com/ai", # uses OpenAI-compatible interface
api_key="YOUR_TW_SECRET_KEY", # maps to x-secret-key
)
resp = client.chat.completions.create(
model="t0",
messages=[{"role": "user", "content": "What's my USDC balance?"}],
stream=False,
extra_body={ "context": { "from": "0xYourWallet", "chain_ids": [8453] } },
)
print(resp)
Response shape
{
"message": "I've prepared a native transfer. Do you want to execute it?",
"session_id": "123",
"request_id": "456",
"actions": [
{
"type": "sign_transaction",
"data": { "chainId": 8453, "to": "0x...", "value": "10000000000000000", "data": "0x" },
"source": "model"
}
]
}
Links
Docs: https://portal.thirdweb.com/ai/chat
Playground: https://playground.thirdweb.com/ai/chat
API reference: https://api.thirdweb.com/reference#tag/ai/post/ai/chat