New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
I'm passing the whole conversation back as one giant string and it feels wrong, but I don't know the right way.
What you'll have at the end
A chat loop with a proper message list that correctly answers a follow-up depending on an earlier turn.
You need
A script that already sends one prompt to a live LLM API and prints back a single reply.
Not covered
Trimming or summarizing history once it grows past the model's context window, remembering a user once the process restarts or the browser tab closes, and passing a tool call's result back through the same list are separate problems this recipe leaves alone.
Leans on
Send your first prompt to a live LLM API
This recipe's starting point: one script that already sends a single prompt and gets back a single reply.
Log the token count and dollar cost behind every API call you make
Every earlier turn you keep resending adds to the bill, and this is where you start measuring what it actually costs.
Compact old turns before your context window overflows
Once the growing list gets long enough to bump into the model's context limit, this is how you trim it without losing what matters.
Checked 15 Aug 2026
Part of the LLM APIs and Integration cookbook