Working with LLM APIs · TRACK 01/05
API Basics
Keys, messages, roles, and errors: everything before your first production call.
// THE TRACK
01 · START HERELLM APIsUnderstand what actually travels over the wire when your code talks to an AI model, and what happens between request and reply.BEGINNERYour First API CallWalk through every step of a real LLM API call — authentication, request structure, response parsing, parameter tuning, multi-turn chat, and error handling — with working Python and JavaScript code.BEGINNERAPI ErrorsRecognize every failure mode an LLM call can hit — status codes, stop reasons, refusals, cutoffs — and know the right fix for each.INTERMEDIATEChoosing a Model TierBuild a mental model of provider lineups so you can match each task to the cheapest tier that still does the job.INTERMEDIATEAPI KeysKnow exactly what an API key is, where to get one from each provider, and the habits that stop yours from leaking onto GitHub.BEGINNERAPI Data PrivacyGet a straight answer on what happens to data you send an LLM API — retention windows, training policies, and the enterprise switches that change them.BEGINNERThe Messages ArrayRead any chat API request and know exactly what the system, user, and assistant roles do and why message order matters.BEGINNERMulti-Turn ConversationsLearn why the API forgets everything between calls and how real chat apps fake memory by resending and trimming history.BEGINNERSDK vs Raw HTTPDecide whether to use a provider's official SDK or plain HTTP calls, and understand what the SDK is quietly doing for you.BEGINNERClaude vs GPT vs GeminiCompare the three major providers on the dimensions that matter to builders and pick a default with a clear upgrade path.INTERMEDIATESampling ParametersUnderstand the three randomness knobs in an LLM request body — how each reshapes the token probabilities, how they interact, and which ones to leave alone.INTERMEDIATEmax_tokens & TruncationLearn exactly what the max_tokens parameter caps, why mid-sentence cutoffs happen, and how to size it so structured output never truncates.BEGINNERCounting Tokens Pre-RequestMeasure how many tokens a request will use before you send it, so you can budget context, predict cost, and never hit an overflow error in production.INTERMEDIATEtiktokenYou will understand how tiktoken turns text into the same tokens a model sees, so you can count tokens to estimate cost and stay inside the context window.INTERMEDIATE