Methods to understand
Keep API keys on the server and define the model, input, timeout, and output limits. The client sends only task-relevant material. Implement a minimal request first, then add error handling.
Apply the method to a scenario
Goal: complete a clearly scoped work task using AI. Input: public, task-relevant material. Acceptance: verifiable results and explicitly marked unknowns.
Hands-on workshop
Make a real server-side model request.
- Bind AI in your own Worker configuration.
- Call the model through server-side env.AI; keep keys out of the browser.
- Check success, invalid input, and service failure and record actual responses.
const result = await env.AI.run(
"@cf/meta/llama-3.3-70b-instruct-fp8-fast",
{ messages: [
{ role: "system", content: "Answer only from supplied material; state uncertainty when evidence is missing." },
{ role: "user", content: "Material: the course contains one retrieval evaluation task. Question: what task does it contain?" }
], max_tokens: 300 }
);
if (!result.response) throw new Error("Empty model result");
return Response.json({ answer: result.response });How to verify
The output must answer the question from the supplied material. Also test material without an answer and check whether the model admits uncertainty.
Practice task
Choose a case related to your work and practice "Model APIs and requests". Submit inputs, steps, results, and verification records.
- Explain the task goal and inputs
- Provide actual results or runnable deliverables
- Identify errors, limits, and verification evidence
Saving a record documents your practice. It does not automatically grant certification.