What an SDK does: bodies, retries and one reply shape
A hand-built mini SDK over two fake providers. Real SDKs do the same jobs with more care.
An SDK is a library that wraps the HTTP request for you: it builds the body, retries safe failures, parses the reply into typed objects and adds streaming helpers. Most providers copy the OpenAI shape, Anthropic uses its own, and frameworks add a common layer on top.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write to_anthropic_body(openai_body) that converts an OpenAI-style body (with a system message first) into an Anthropic-style body: top-level system, the remaining messages, and max_tokens defaulting to 256.
Write normalise_stop(stop_reason) that maps end_turn to stop, max_tokens to length, tool_use to tool_calls, and returns anything else unchanged.
Explain it without notes
What does an SDK add over a plain HTTP call?
Name three differences between the OpenAI chat-completions shape and Anthropic's Messages shape.
When would you choose plain HTTP over an SDK or framework?
Expected output
openai request: {"model":"some-model","messages":[{"role":"system","content":"Be brief."},{"role":"user","content":"Hi"}],"max_tokens":20}
openai reply: text=Hello! stop=stop in=12 out=3 retries=1
anthropic request: {"model":"some-model","max_tokens":20,"system":"Be brief.","messages":[{"role":"user","content":"Hi"}]}
anthropic reply: text=Hello! stop=stop in=11 out=3 retries=0