-
Step 1 of 6Request
A question reaches the backend
The user's question goes to the API, never straight to the model. The backend owns the conversation: it knows who the user is, what they may see and which tools they're allowed to use.
-
Step 2 of 6RAG
Retrieve before you generate
The API embeds the question and runs a vector search over the product's own content. The best-matching passages come back with their sources, so the model answers from real content instead of memory.
-
Step 3 of 6Prompt
Ask with context and a tool list
The request to the LLM carries the question, the retrieved passages and a short list of tools with JSON schemas. The instructions say to answer only from the passages, and to say so when they don't cover the question.
-
Step 4 of 6Edge case
The model asks, the backend runs it
When it needs live data, such as a price or an order status, the model replies with a tool call instead of text. The backend validates the arguments against the schema, checks permissions, runs the function and sends the result back.
-
Step 5 of 6Answer
A grounded answer, then logs
With the tool result in hand, the model writes the final answer and the API returns it with its sources. Prompts, tool calls and latency are logged, so answers can be checked and improved.
-
Step 6 of 6Recap
What I built at Cocoon
At Cocoon I integrated LLM APIs into client products, implementing tool calling and retrieval-augmented generation (RAG). This is how I'd build it again: retrieval for knowledge, tools for live data, the backend in control.
Tip: the ← and → keys work too.