-
Notifications
You must be signed in to change notification settings - Fork 588
added AI migration guide #7961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added AI migration guide #7961
Changes from 1 commit
76be3f8
03ca9bc
2f6bf29
126a333
38f50d0
f8e468d
c42db48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,185 @@ | ||||||||||||||
import {Callout, Step, Steps} from "@doc"; | ||||||||||||||
|
||||||||||||||
# Migrate to thirdweb AI | ||||||||||||||
|
||||||||||||||
If you previously used the Nebula endpoints (nebula-api.thirdweb.com/chat) for thirdweb AI features, this guide that will teach you how | ||||||||||||||
to migrate to the thirdweb API. | ||||||||||||||
|
||||||||||||||
<Callout variant="info" title="Nebula Deprecation"> As of August 14, 2025 Nebula (blockchain LLM) has officially been deprecated and re-branded to thirdweb AI </Callout> | ||||||||||||||
|
||||||||||||||
**Endpoint Changes:** | ||||||||||||||
- Old URL: `https://nebula-api.thirdweb.com/chat` | ||||||||||||||
- New URL: `https://api.thirdweb.com/ai/chat` | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
## Benefits of thirdweb API | ||||||||||||||
|
||||||||||||||
- Standard Chat Format: Follows industry-standard conversational AI patterns | ||||||||||||||
- Better Message History: Support for multi-turn conversations with role-based messages | ||||||||||||||
- Structured Context: Type-safe object format instead of string parsing | ||||||||||||||
- Enhanced Session Management: More flexible session handling | ||||||||||||||
- Future-Proof: Aligned with modern chat API standards | ||||||||||||||
|
||||||||||||||
## Quick Reference | ||||||||||||||
|
||||||||||||||
| First API Field | Second API Field | Notes | | ||||||||||||||
|-----------------|-------------------------|---------------------------------------------| | ||||||||||||||
| message | messages[].content | Single string → Array of message objects | | ||||||||||||||
| session_id | context.session_id | Moved inside context object (optional) | | ||||||||||||||
| context (string)| context (object) | String format → Structured object | | ||||||||||||||
| walletAddress | context.from | Renamed field | | ||||||||||||||
| chainIds | context.chain_ids | Renamed field | | ||||||||||||||
|
||||||||||||||
## Request Structure Comparison | ||||||||||||||
|
||||||||||||||
Before (Nebula API) | ||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
fetch("<https://nebula-api.thirdweb.com/chat>", { | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
method: "POST", | ||||||||||||||
headers: { | ||||||||||||||
"Content-Type": "application/json", | ||||||||||||||
"x-secret-key": "your-secret-key", | ||||||||||||||
}, | ||||||||||||||
body: JSON.stringify({ | ||||||||||||||
message: "Send 0.01 ETH to vitalik.eth", | ||||||||||||||
stream: false, | ||||||||||||||
session_id: "your-session-id", | ||||||||||||||
context: "{ chainIds: [1]; walletAddress: '0x123...'; }", | ||||||||||||||
}), | ||||||||||||||
}); | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## After (thirdweb AI Chat API) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The heading format is inconsistent between the "Before" and "After" sections. For document structure consistency, consider changing this heading to use the same heading level as the "Before" section: ### After (thirdweb AI Chat API) This maintains proper document hierarchy and improves readability of the migration guide.
Suggested change
Spotted by Diamond |
||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
fetch("<https://api.thirdweb.com/ai/chat>", { | ||||||||||||||
saminacodes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
method: "POST", | ||||||||||||||
headers: { | ||||||||||||||
"Content-Type": "application/json", | ||||||||||||||
"x-secret-key": "your-secret-key", | ||||||||||||||
}, | ||||||||||||||
body: JSON.stringify({ | ||||||||||||||
context: { | ||||||||||||||
chain_ids: [1], | ||||||||||||||
from: "0x123...", | ||||||||||||||
session_id: "your-session-id", // Optional | ||||||||||||||
}, | ||||||||||||||
messages: [ | ||||||||||||||
{ | ||||||||||||||
role: "user", | ||||||||||||||
content: "Send 0.01 ETH to vitalik.eth", | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
stream: false, | ||||||||||||||
}), | ||||||||||||||
}); | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## Migration Steps | ||||||||||||||
|
||||||||||||||
<Steps> | ||||||||||||||
|
||||||||||||||
<Step title="Update Endpoint URL"> | ||||||||||||||
|
||||||||||||||
Change your base URL from: | ||||||||||||||
|
||||||||||||||
`<https://nebula-api.thirdweb.com/chat>` | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The URL formatting contains a mix of backticks and angle brackets which creates inconsistent markdown. Please use either backticks alone:
Or angle brackets alone:
This will ensure proper rendering in the documentation.
Suggested change
Spotted by Diamond |
||||||||||||||
|
||||||||||||||
to | ||||||||||||||
|
||||||||||||||
`<https://api.thirdweb.com/ai/chat>` | ||||||||||||||
|
||||||||||||||
</Step> | ||||||||||||||
|
||||||||||||||
<Step title="Restructure Message Format"> | ||||||||||||||
Convert the single message field to a messages array: | ||||||||||||||
|
||||||||||||||
Before: | ||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
message: "Your message here" | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
After: | ||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
messages: [ | ||||||||||||||
{ | ||||||||||||||
role: "user", content: "Your message here" } | ||||||||||||||
] | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing closing quotes here, which breaks the component |
||||||||||||||
``` | ||||||||||||||
saminacodes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
||||||||||||||
Supported roles: | ||||||||||||||
- **user** - Messages from the user | ||||||||||||||
- **assistant** - Messages from the AI | ||||||||||||||
- **system** - System messages for context | ||||||||||||||
Comment on lines
+114
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code block formatting has an issue where the "Supported roles" section is incorrectly placed inside the code block. This creates a formatting problem in the rendered documentation. The code block should be closed before the roles list begins, like this: messages: [
{
role: "user",
content: "Your message here",
}
] Then the supported roles should be listed as regular markdown text: Supported roles:
- **user** - Messages from the user
- **assistant** - Messages from the AI
- **system** - System messages for context This will ensure proper rendering of both the code example and the roles explanation. Spotted by Diamond |
||||||||||||||
|
||||||||||||||
|
||||||||||||||
</Step> | ||||||||||||||
|
||||||||||||||
<Step title="Update Context Structure"> | ||||||||||||||
Old format (string): | ||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
context: "{ chainIds: [1, 137]; walletAddress: '0x123...'; }" | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
New format (object): | ||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
context: { | ||||||||||||||
chain_ids: [1, 137], | ||||||||||||||
from: "0x123...", | ||||||||||||||
session_id: "optional-session-id" | ||||||||||||||
} | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
</Step> | ||||||||||||||
|
||||||||||||||
<Step title="Map Fields"> | ||||||||||||||
|
||||||||||||||
| Old Field | New Field | Required | Notes | | ||||||||||||||
|---------------|--------------------|----------|--------------------------------| | ||||||||||||||
| walletAddress | context.from | Optional | Wallet that executes transactions | | ||||||||||||||
| chainIds | context.chain_ids | Optional | Array of chain IDs | | ||||||||||||||
| session_id | context.session_id | Optional | Now nested in context | | ||||||||||||||
|
||||||||||||||
</Step> | ||||||||||||||
|
||||||||||||||
<Step title="Session Manangement"> | ||||||||||||||
saminacodes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
- Session ID is now optional and nested within the context object | ||||||||||||||
- If not provided, a new session will be created automatically | ||||||||||||||
- Sssions enable conversation continuity | ||||||||||||||
saminacodes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
</Step> | ||||||||||||||
</Steps> | ||||||||||||||
|
||||||||||||||
### Example Migration Function | ||||||||||||||
|
||||||||||||||
```typescript | ||||||||||||||
function migrateToNewAPI(oldRequest) { | ||||||||||||||
// Parse old context string const contextString = oldRequest.context; const contextData = parseContextString(contextString); // Implement this helper | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code formatting in this line appears to have lost its line breaks, resulting in multiple statements running together. This will cause a JavaScript syntax error when executed. The code should be properly formatted with each statement on its own line: // Parse old context string
const contextString = oldRequest.context;
const contextData = parseContextString(contextString); // Implement this helper This maintains the intended functionality while ensuring the code will parse correctly.
Suggested change
Spotted by Diamond |
||||||||||||||
return { | ||||||||||||||
context: { | ||||||||||||||
chain_ids: contextData.chainIds, | ||||||||||||||
from: contextData.walletAddress, | ||||||||||||||
session_id: oldRequest.session_id, | ||||||||||||||
}, | ||||||||||||||
messages: [ | ||||||||||||||
{ | ||||||||||||||
role: "user", | ||||||||||||||
content: oldRequest.message, | ||||||||||||||
}, | ||||||||||||||
], | ||||||||||||||
stream: oldRequest.stream || false, | ||||||||||||||
}; | ||||||||||||||
} | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
### Test Migration | ||||||||||||||
|
||||||||||||||
1. Update your endpoint URL | ||||||||||||||
2. Transform your request payload structure | ||||||||||||||
3. Test with a simple message first | ||||||||||||||
4. Verify session continuity works as expected | ||||||||||||||
5. Test complex scenarios with multiple messages |
Uh oh!
There was an error while loading. Please reload this page.