Skip to content

Commit 512f9dd

Browse files
[Docs] Fix AI model response handling in server example (#8459)
1 parent 919230f commit 512f9dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/portal/src/app/x402/server/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if (verifyResult.status !== 200) {
110110
}
111111

112112
// Do the expensive work that requires payment
113-
const { tokensUsed } = await callExpensiveAIModel();
113+
const { answer, tokensUsed } = await callExpensiveAIModel();
114114

115115
// Now settle the payment based on actual usage
116116
const pricePerTokenUsed = 0.00001; // ex: $0.00001 per AI model token used
@@ -119,7 +119,7 @@ const settleResult = await settlePayment({
119119
price: tokensUsed * pricePerTokenUsed, // adjust final price based on usage
120120
});
121121

122-
return Response.json(result);
122+
return Response.json(answer);
123123
```
124124

125125
## Price and Token Configuration

0 commit comments

Comments
 (0)