Skip to content

Commit 633f0ca

Browse files
committed
[Portal] Nebula documentation update (#6201)
CORE-0000 <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the documentation for `thirdweb Nebula`, adding detailed metadata, explanations of new features, and clarifying existing concepts. It includes updates to various pages, improving user understanding of plugins, sessions, context filters, and response handling. ### Detailed summary - Added `metadata` exports to multiple `.mdx` files. - Enhanced FAQ entries with links and additional context. - Updated `sidebar` to include new key concepts. - Added sections on `Chat & Execute endpoints`, `Execute Configuration`, and `Context Filters`. - Introduced new content on `Response Handling` and streaming vs non-streaming responses. - Clarified `Sessions` management and benefits. - Replaced `Stack` with `Grid` in the `page.mdx` and updated links. - Improved descriptions and examples for API usage and configurations. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 91b0367 commit 633f0ca

File tree

16 files changed

+320
-175
lines changed

16 files changed

+320
-175
lines changed

apps/portal/src/app/nebula/api-reference/chat/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EndpointMetadata } from './EndpointMetadata';
22

33
<EndpointMetadata />
44

5-
#### Chat Actions
5+
# Chat Actions
66

77
Chat actions represent blockchain transactions or operations that Nebula has prepared in response to your request. The response includes both a detailed explanation in the `message` field and the actual transaction data in the `actions` array.
88

apps/portal/src/app/nebula/api-reference/page.mdx

Lines changed: 15 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
import { createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
image: {
5+
title: "API Reference",
6+
icon: "nebula",
7+
},
8+
title: "thirdweb Nebula API Reference",
9+
description:
10+
"Explore the thirdweb Nebula API reference to unlock the most powerful AI to interact with the blockchain and start building AI powered web3 apps.",
11+
});
12+
113
# Nebula API Reference
214

315
Nebula provides a conversational interface to interact with blockchain data and services, and access to thirdweb tools.
@@ -13,7 +25,9 @@ https://nebula-api.thirdweb.com
1325

1426
## Authentication
1527

16-
All API endpoints require authentication using the thirdweb secret key. Include this key in your request headers:
28+
All API endpoints require authentication using the thirdweb secret key. [Learn how to obtain a secret key.](/nebula/get-started).
29+
30+
Include this key in your request headers:
1731

1832
```bash
1933
x-secret-key: YOUR_THIRDWEB_SECRET_KEY
@@ -31,161 +45,7 @@ curl -X POST https://nebula-api.thirdweb.com/chat \
3145
}'
3246
```
3347

34-
## Sessions
35-
36-
Sessions maintain conversation threads with the AI and can be:
37-
38-
- Created explicitly via the `/session` endpoint
39-
- Created automatically when sending a message without a session_id
40-
- Reused to maintain context across multiple messages
41-
- Configured with specific execution parameters
42-
43-
Sessions persist your conversation history and custom configurations for blockchain data and thirdweb tools interactions.
44-
45-
## Context Filters
46-
47-
Control what blockchain data informs AI responses through context filtering:
48-
49-
```json
50-
{
51-
"context": {
52-
"chain_ids": ["1"], // comma delimited list of chain ID's
53-
"wallet_address": "0x..." // wallet address
54-
}
55-
}
56-
```
57-
58-
Benefits:
59-
- Filter by blockchain networks using chain IDs
60-
- Target specific contract addresses
61-
- Target specific wallet addresses
62-
- Control context scope for relevant responses
63-
- Optimize token usage and response relevance
64-
65-
## Execute Configuration
66-
67-
Configure transaction execution behavior using the execute config:
68-
69-
```json
70-
{
71-
"execute_config": {
72-
"mode": "client",
73-
"signer_wallet_address": "0x..."
74-
}
75-
}
76-
```
77-
78-
Parameters:
79-
- `mode`: Execution mode (currently supports "client")
80-
- `signer_wallet_address`: Wallet address for transaction signing
81-
82-
When mode is "client", Nebula returns an unsigned transaction for local wallet signing.
83-
84-
## Response Handling
85-
86-
Nebula API supports two types of response modes: streaming and non-streaming. The mode is controlled by the `stream` parameter in your request.
87-
88-
### Non-Streaming Responses
89-
90-
When `stream: false`, the API returns a single JSON response:
91-
92-
```json
93-
{
94-
"result": {
95-
"message": "The last 5 blocks on polygon are...",
96-
"session_id": "abc",
97-
"message_id": "1234"
98-
}
99-
}
100-
```
101-
102-
### Streaming Responses
103-
104-
When `stream: true`, the API uses Server-Sent Events (SSE) to stream the response. You'll need to handle the following event types:
105-
106-
1. `init`: Initializes the stream and provides session information
107-
2. `presence`: Provides backend status updates about worker processing
108-
3. `action`: Contains blockchain transaction or action data
109-
4. `delta`: Contains chunks of the response message text
110-
5. `error`: Contains error information if something goes wrong
111-
112-
**Example SSE Stream:**
113-
```tsx
114-
event: init
115-
data: {
116-
"session_id": "f4b45429-9570-4ee8-8c8f-8b267429915a",
117-
"request_id": "9efc7f6a-8576-4d9c-8603-f6c72aa72164",
118-
"type": "init",
119-
"source": "user",
120-
"data": ""
121-
}
122-
123-
event: presence
124-
data: {
125-
"session_id": "f4b45429-9570-4ee8-8c8f-8b267429915a",
126-
"request_id": "9efc7f6a-8576-4d9c-8603-f6c72aa72164",
127-
"type": "presence",
128-
"source": "executor",
129-
"data": "Performing function execution: ExecuteNativeTransferClientSigning"
130-
}
131-
132-
event: action
133-
data: {
134-
"session_id": "f4b45429-9570-4ee8-8c8f-8b267429915a",
135-
"request_id": "9efc7f6a-8576-4d9c-8603-f6c72aa72164",
136-
"type": "sign_transaction",
137-
"source": "executor",
138-
"data": "{\"chainId\": 11155111, \"to\": \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\", \"data\": \"0x\", \"value\": \"0x5af3107a4000\"}"
139-
}
140-
141-
event: delta
142-
data: {"v": "To send 0.0001 ETH on the Sepolia network"}
143-
144-
event: delta
145-
data: {"v": " to the address associated with"}
146-
```
147-
148-
**JavaScript Example for Handling Streams:**
149-
```javascript
150-
const eventSource = new EventSource('/chat', {
151-
headers: {
152-
'x-secret-key': 'YOUR_THIRDWEB_SECRET_KEY'
153-
}
154-
});
15548

156-
let messageText = '';
157-
158-
eventSource.addEventListener('init', (event) => {
159-
const data = JSON.parse(event.data);
160-
console.log('Stream initialized:', data);
161-
});
162-
163-
eventSource.addEventListener('presence', (event) => {
164-
const data = JSON.parse(event.data);
165-
console.log('Backend status:', data.data);
166-
});
167-
168-
eventSource.addEventListener('action', (event) => {
169-
const data = JSON.parse(event.data);
170-
console.log('Received action:', data);
171-
if (data.type === 'sign_transaction') {
172-
// Handle transaction signing
173-
handleTransaction(data);
174-
}
175-
});
176-
177-
eventSource.addEventListener('delta', (event) => {
178-
const data = JSON.parse(event.data);
179-
messageText += data.v;
180-
console.log('Current message:', messageText);
181-
});
182-
183-
eventSource.addEventListener('error', (event) => {
184-
const error = JSON.parse(event.data);
185-
console.error('Error:', error);
186-
eventSource.close();
187-
});
188-
```
18949

19050

19151

173 KB
Loading

apps/portal/src/app/nebula/faqs/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Nebula supports the read and write context of any verified contract or any contr
1010
If you have a published contract you would like to enable for deployment through Nebula, please [contact us](https://thirdweb.com/contact-us).
1111

1212
### Does Nebula have memory from past conversations?
13-
Nebula retains memory within the confines of a session.
13+
Nebula retains memory within the confines of a session. [Learn more about sessions](/nebula/key-concepts/sessions).
1414

1515
### What is the context size of Nebula?
1616
The context size or window is 128k tokens.

apps/portal/src/app/nebula/get-started/page.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { Step, Steps, DocImage, Callout } from "@doc";
1+
import { Step, Steps, DocImage, Callout, createMetadata } from "@doc";
22
import NewProject from "../assets/new-project.png";
33
import KeysSetup from "../assets/keys.png";
44

5+
export const metadata = createMetadata({
6+
image: {
7+
title: "Get Started",
8+
icon: "nebula",
9+
},
10+
title: "Get started with thirdweb Nebula: Set up Guide",
11+
description:
12+
"How to start building web3 capable apps with thirdweb Nebula, the most powerful AI to interact with the blockchain.",
13+
});
14+
15+
516
# Get Started
617

718
Learn how to get set up and started with the Nebula API to successfully prepare and enable a connected user to sign a transfer .
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Chat & Execute endpoints
2+
3+
The `/chat` endpoint is used for **natural language interactions** with the AI. It allows users to ask questions, get explanations, or retrieve blockchain-related insights, and execute transactions.
4+
5+
The `/execute` endpoint is used for **triggering actual blockchain transactions** through AI-generated execution logic. This endpoint **performs actions** on-chain and is designed to be used without historical context.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Context Filters
2+
3+
Context filters help control what blockchain data the AI uses to generate responses.
4+
5+
You can specify:
6+
7+
- Chain IDs – Choose which blockchain networks to pull data from.
8+
- Wallet Address – Focus on a specific wallet’s transactions, balances, and interactions.
9+
10+
Benefits:
11+
12+
- **More relevant answers:** AI focuses only on the data you care about.
13+
- **Enable Scope**: Keep results relevant to networks and wallets specified.
14+
15+
Example,
16+
17+
```jsx
18+
{
19+
"context": {
20+
"chain_ids": ["1"], // Ethereum network
21+
"wallet_address": "0x123...abc" // Specific wallet to analyze
22+
}
23+
}
24+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Execute Configuration
2+
3+
Configure transaction execution behavior using the execute config:
4+
5+
```json
6+
{
7+
"execute_config": {
8+
"mode": "client",
9+
"signer_wallet_address": "0x..."
10+
}
11+
}
12+
```
13+
14+
Parameters:
15+
16+
- `mode`: Execution mode (currently supports "client")
17+
- `signer_wallet_address`: Wallet address for transaction signing
18+
19+
When mode is "client", Nebula returns an unsigned transaction for local wallet signing.

0 commit comments

Comments
 (0)