Claude API / OpenAI API Basics

Call LLM APIs confidently: requests and responses, messages, parameters, streaming, tool use, errors and retries, cost, security and testing, with the real Anthropic and OpenAI SDKs run against a local stand-in server.

Start course →

Syllabus

How LLM APIs Work

  1. What an LLM API Is
  2. API Keys, Environment Variables and Safe Setup
  3. A Raw HTTP Call: What the SDK Does for You
  4. Anthropic and OpenAI Side by Side

Messages, Parameters and Output

  1. Your First Call With Each SDK
  2. Roles, System Prompts and Conversation History
  3. Parameters: max_tokens, Temperature, Top-p, Stop
  4. Structured Output and Validating Replies

Streaming Responses

  1. How Streaming Works
  2. Streaming in Applications: UI, Backends and Cancellation

Tool Use (Function Calling)

  1. How Tool Use Works
  2. A Complete Tool Loop With the Anthropic SDK
  3. A Complete Tool Loop With the OpenAI SDK
  4. Designing and Securing Tools

Reliability: Errors, Retries and Limits

  1. Error Types and Which to Retry
  2. Exponential Backoff With Jitter
  3. Rate Limits, Concurrency and Timeouts
  4. Fallbacks and Graceful Degradation

Cost, Tokens and Performance

  1. Tokens, Pricing and Estimating Cost
  2. Tracking Usage and Setting Budgets
  3. Reducing Cost and Latency: Caching, Batching, Model Choice

Security, Testing and Production

  1. Protecting Keys and Logs
  2. Treating Model Output and Inputs as Untrusted
  3. Privacy, Data Handling and Compliance
  4. Testing Your Integration With a Stand-In Server

Putting It Together

  1. Case Study: A Support-Reply Drafting Endpoint
  2. Revision: Cheat Sheet and Self-Check