AI Frontend · Exercise 1 of 6Next
Beginner
Read the Reply
The route /api/chat answers with the usual chat JSON. When #ask is clicked, send the request and show three things: the reply text in #answer, the finish reason as Finish: stop in #finish, and the token total as Used 50 tokens in #usage (use the real number from the response).
The request body is already written. Everything you need is in the JSON the route returns.
What Check tests
- Before the click,
#answer,#finishand#usageare empty - After clicking
#ask,#answershows the reply text #finishsaysFinish: stop#usagesaysUsed <number> tokens
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.