Lab 1 · LLM API fundamentals

Messages, parameters, latency, cost

The chat box hides the protocol. This lab makes the request and response shape visible: roles, parameters, token usage, simulated latency, and cost. The provider is a deterministic simulator so the lesson focuses on the wire-level contract.

Simulated provider. The model output is generated by a small deterministic function so the lab works without API keys. Token counts use the ~4-chars-per-token heuristic; cost uses mock per-million rates. Real-provider wiring would slot in behind the same interface — see /api/agent-lab/decide.ts for the existing extension point.

Two prompt configurations

Configuration A

A

Wire payload preview

{
  "messages": [
    {
      "role": "system",
      "content": "You are a careful credit-risk analyst. Respond with concrete next actions."
    },
    {
      "role": "user",
      "content": "Summarise how blocked accounts and overdue invoices interact for order eligibility."
    }
  ],
  "temperature": 0,
  "maxTokens": 256
}

Configuration B

B

Wire payload preview

{
  "messages": [
    {
      "role": "system",
      "content": "You are a terse credit-risk analyst. One short paragraph."
    },
    {
      "role": "user",
      "content": "Summarise how blocked accounts and overdue invoices interact for order eligibility."
    }
  ],
  "temperature": 1.2,
  "maxTokens": 256
}
What this lab teaches: messages are the real interface (the chat box hides this); the system message changes the response without changing the user's intent; temperature and max-tokens are part of the contract, not afterthoughts; latency, cost, and output variance are visible from day one, not surfaced only when something breaks in production.