Lesson 00.05 · Phase 00 · Setup & Tooling

Calling an LLM over raw HTTP

Every SDK is a thin wrapper around one HTTP POST. Write that POST yourself once, in both formats that matter, and no SDK error will ever be a mystery again.

Learning objectives

  • Send a chat request with tools to an LLM using only urllib, in the OpenAI-compatible and the Anthropic Messages formats.
  • Convert a conversation, including tool calls and tool results, between the two formats.
  • Normalize both responses into one Reply: text, tool calls, stop reason, and token usage.
  • Map HTTP failures (401, 429, connection refused) into one error type that carries Retry-After.

You've used client.chat.completions.create(...). Then something breaks:

Loading the full lesson…