chat

Chat with Nebula.

Example

import { Nebula } from "thirdweb/ai";
const response = await Nebula.chat({
client: TEST_CLIENT,
message:
"What's the symbol of this contract: 0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8",
contextFilter: {
chains: [sepolia],
},
});

Multi message prompt:

const response = await Nebula.chat({
client,
messages: [
{ role: "user", content: "What's my balance?" },
{ role: "assistant", content: "Your balance is 0.023 ETH" },
{ role: "user", content: "What about my NFTs?" },
],
contextFilter: {
chains: [sepolia],
},
});

Extracting and sending transactions from a chat response:

const response = await Nebula.chat({ ... });
const transactions = response.transactions;
for (const transaction of transactions) {
await sendTransaction({ transaction, account });
}
function chat(input: Input): Promise<Output>;

Parameters

The input for the chat.

Type

let input: {
account?: Account;
client: ThirdwebClient;
contextFilter?: {
chains?: Array<Chain>;
contractAddresses?: Array<string>;
walletAddresses?: Array<string>;
};
sessionId?: string;
} & (
| {
messages: Array<{
content: string;
role: "user" | "assistant";
}>;
}
| { message: string }
);

Returns

let returnType: {
message: string;
sessionId: string;
transactions: Array<PreparedTransaction>;
};

The chat response. This API is in early access and might change in the future.