Command Palette

Search for a command to run...

Hectal
Phase 1: Calling a Model over HTTP
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

  1. Before the click, #answer, #finish and #usage are empty
  2. After clicking #ask, #answer shows the reply text
  3. #finish says Finish: stop
  4. #usage says Used <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.