Blog
4 min read

What Is an SDK? SDK vs API, Explained for Beginners

An SDK is a ready-made toolkit for using a service from your code. What an SDK contains, how it differs from an API, real examples from Stripe and Anthropic, how to install one, and why AI tools sometimes invent SDK functions that don't exist.

When your app needs to take payments, send email or call an AI model, the documentation will usually say: "Install our SDK." Here's what that means, and how it relates to the API you've probably heard about too.

The short version

  • An API is the service's front door: the set of requests it accepts and the responses it sends back.
  • An SDK (software development kit) is a ready-made toolkit for using that front door from your programming language.

You can always use an API without an SDK. The SDK just saves you from doing the fiddly parts by hand.

An analogy

The API is a restaurant's ordering counter: it accepts orders in a specific format and hands back food.

The SDK is a friendly waiter who already knows the format. You say "a burger, no onions," and the waiter writes the order correctly, takes it to the counter, waits, deals with "sorry, we're out — try again in a minute," and brings you the burger on a plate.

What an SDK actually does for you

Calling an API directly means building an HTTP request yourself: the right URL, headers, authentication, JSON body, error handling, retries. An SDK wraps all of that in normal functions.

Here's a call to Claude without an SDK — a raw HTTP request:

const res = await fetch("https://api.anthropic.com/v1/messages", {
  method: "POST",
  headers: {
    "x-api-key": process.env.ANTHROPIC_API_KEY,
    "anthropic-version": "2023-06-01",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello" }],
  }),
});
const data = await res.json();

And with Anthropic's official TypeScript SDK:

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY from the environment

const response = await client.messages.create({
  model: "claude-opus-5-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

The SDK version reads your key automatically, sets the right headers, retries when the service is briefly busy, throws clear typed errors, and — in TypeScript — tells your editor exactly what fields exist. That's the value.

What's usually in an SDK

  • Client libraries — the functions you call (client.messages.create, stripe.customers.create).
  • Types — so your editor autocompletes and catches typos.
  • Authentication handling — reading keys from environment variables.
  • Retries and timeouts — for temporary failures.
  • Helpers — streaming, pagination, webhook signature checking.
  • Sometimes command-line tools and examples.

Installing one

SDKs are distributed through your language's package manager:

npm install @anthropic-ai/sdk   # JavaScript / TypeScript
pip install anthropic           # Python

The package then appears in your package.json (see npm and package.json explained) or requirements.txt.

Use the official SDK where one exists. Look for the package name in the service's own documentation rather than searching npm — lookalike packages exist, and some are malicious.

SDK vs API vs library vs framework

  • API: the service's interface. Not something you install.
  • SDK: a toolkit for one service's API.
  • Library: any reusable code you install (an SDK is a kind of library).
  • Framework: a structure your whole app is built inside, like Next.js. See what is a framework?

Why AI tools get SDKs wrong

AI coding tools learned SDKs from code written months or years ago. SDKs change: functions get renamed, parameters move, old versions are retired. So an AI tool may confidently write a call that used to work, or one that never existed.

Signs of this: an error like client.chat is not a function, or a parameter the service rejects. The fix:

  1. Check the installed version in package.json.
  2. Ask your AI tool to read the SDK's current documentation, or paste the relevant example in.
  3. Be extra careful with package names the AI suggests — see AI hallucinated a package.

The summary

  • An API is the service's interface; an SDK is a toolkit that makes calling it easy from your language.
  • SDKs handle authentication, headers, retries, errors and types for you.
  • Install the official one from the service's own docs.
  • If AI-written SDK code fails, check the SDK version and current docs first.

EasySpawn gives Claude Code a real server where it can install SDKs, run your code against the actual service, and read the real error — instead of guessing whether a function exists. See how it works or join the waitlist.

Related: What Is an API? · What Is an API Key? · How to Add an AI Chatbot to Your App · What Is JSON?

Keep reading