Skip to content
← Free FDE training guides

Free learning / 45-minute SDK 101 lab

SDK 101: what happens when you call the method?

Separate the client SDK, API, endpoint and model. Compare raw HTTP with a real client library, observe retries and timeouts, and decide which responses your application can use.

No account needed. Use your own copy for writing and keep the original as a reference.

Engineering lab library / Run locally

See what the SDK actually sends.

Compare raw HTTP and a client method, then inspect a retry, bad request, timeout and unexpected body. Change one policy at a time and explain the result.

Real SDK and local HTTP with authored responses. Installation needs registry access; execution uses loopback only, with no model or provider credential.

  1. Start here / Real library, SDK or framework · Scripted inputs

    SDK requests and response decisions

    Observe a real client sending HTTP requests, retrying a 503, surfacing a 400 and timing out; inspect an unexpected 200 response.

    Node.js 24 · Anthropic SDK 0.131.0 · Registry access for installation

You have a small application and want it to ask a model for a draft. You can write an HTTP request yourself, or install a library that prepares the request for you. That library is a client SDK, short for software development kit. Think of it like a database driver: useful code in your application that knows how to talk to a service. Installing the driver does not install the database. Installing a model-provider client SDK does not install the model.

This original 45-minute lab uses the real Anthropic TypeScript SDK from JavaScript. It sends actual HTTP requests to a tiny server on your own computer. The server returns authored examples, not model output. You will see the request, a retry, an error and a timeout before introducing an agent framework.

Prefer to see the boundary first? Open SDK 101, choose Try it, and predict the requests and acceptance decision. The visual uses recordings from this lab, including the two changes in section 5. Return here to reproduce them with the real client.

1. Name the pieces before using them

PieceWhat it isWhere it is in this lab
Your applicationThe code deciding what work to request and what result to acceptThe run and decide functions
Client SDKAn installed library that prepares requests and handles responses@anthropic-ai/sdk
APIThe service's agreed request and response contractA small local imitation of the Messages HTTP contract
EndpointThe address receiving a requestA temporary port on 127.0.0.1, the loopback address
ModelA trained system that performs inferenceAbsent; the server returns fixed fictional text
Agent loopApplication control that can choose and repeat steps using resultsAbsent; each case requests one operation

An SDK is not a language. The TypeScript SDK also runs in server-side JavaScript, as this exercise shows. An API is not necessarily an SDK: you can call an HTTP API with fetch. A client SDK typically saves you from hand-writing parts of that integration. An Agent SDK is a different abstraction that may supply a tool loop and runtime. The similarly named products do not do the same job.

In a real hosted-model integration, the endpoint normally belongs to the provider or an approved gateway. Here the destination is deliberately local so you can inspect transport behavior without a provider account or bill.

UNDERSTAND THE SYSTEM

One method call. Separate transport and acceptance.

Follow a client library from a function call to an HTTP exchange and an application decision. Each frame is a separate recorded case from the local SDK lab, not five steps of one request. The installed client is real; the endpoint returns authored responses and runs no model.

FOLLOW THE WORK

Watch one example, step by step.

5 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Your code

Your application asks the library to perform an operation. The function call is local; the work it initiates crosses HTTP. In this lab, each case calls once and does not run an agent loop.

CONNECTED TO
  • Method: Client SDK
Read the full worked example
  1. 01
    A returned draft still needs review

    In the sdk case, one invocation sends one HTTP request. The server returns 200 with nonempty text and end_turn. The application chooses review-draft. These checks make the authored draft available for review; they do not verify its truth or prove inference occurred.

    RECORDED SDK CASE: 1 request · 200 · review-draft

  2. 02
    The retry lives inside the call

    In retry, the first request receives 503. One allowed retry lets the client send a second request, which receives 200. The application receives the final result. By contrast, the recorded 400 case makes one attempt even with one retry allowed. A limit permits retries; it does not require repeating every error.

    RECORDED RETRY CASE: 1 call · 2 requests · 503 → 200

  3. 03
    No response is not no work

    In timeout, the server records one request but sends no response. With retries disabled and a 500 ms timeout, the client raises APIConnectionTimeoutError. The application retains outcome-unknown. Receipt is established by this fixture's separate server record, not by the timeout itself. A real integration needs its destination's reconciliation contract.

    RECORDED TIMEOUT CASE: 1 request observed · no HTTP status

  4. 04
    Valid JSON can be the wrong answer shape

    In unexpected-body, the endpoint returns 200 and an object with an unexpected field. The client parses the JSON; the application chooses inspect-response and accepts no text. Static TypeScript declarations do not validate this runtime body. Retrying unchanged is not a substitute for finding the contract mismatch.

    RECORDED UNEXPECTED-BODY CASE: 200 · parsed JSON · text withheld

  5. 05
    Text can arrive before the task is complete

    The changed-copy experiment alters only stop_reason to max_tokens. HTTP still returns 200 and the body still contains text, but this application's normal-completion rule withholds it. Compare with the first frame. The fixture's usage fields are authored numbers, not measured tokens, billing or model performance.

    RECORDED COMPLETION EDIT: 200 · max_tokens · text withheld

Read the connections in plain English
  1. 01
    Your code → Client SDK

    The application invokes the client method once for this case.

  2. 02
    Client SDK → Local endpoint

    The client sends the selected request fields to the configured endpoint.

  3. 03
    Local endpoint → HTTP response

    A received response contributes its status and body. This path is not highlighted for the timeout case because the server never answered.

  4. 04
    HTTP response → Client SDK

    For an eligible failure, the configured client may send another request within the same method invocation. Repetition is not automatically safe for every business operation.

  5. 05
    HTTP response → Application check

    The response path inspects the parsed body under the application contract.

  6. 06
    Application check → Next action

    Report the supported outcome instead of treating every returned value as a useful answer.

  7. 07
    Client SDK → Application check

    A terminal SDK error goes to the application catch handler. In timeout, there is no HTTP response and the response-only decide function does not run.

Check your understanding: The SDK returned HTTP 200 and a typed object. Can your workflow now tell the user their task is complete?

Only if the application has the evidence required by that task. In these recordings, 200 appears with a reviewable draft, an unusable shape and text withheld by this app's completion rule. Inspect the runtime result and completion condition; then apply the task's factual, authorization and side-effect checks. A parsed object and a successful HTTP status alone do not establish a completed business action.

2. Prepare the small local experiment

Download fde-sdk-request-lab.mjs into a new, empty folder. Open a terminal in that folder with Node.js 24 installed. Install the exact version tested for this workbook, then run the checks and cases:

Code example
node --version
npm init -y
npm install --ignore-scripts --save-exact @anthropic-ai/sdk@0.131.0
node fde-sdk-request-lab.mjs test
node fde-sdk-request-lab.mjs demo

Installation needs registry access. After installation, the exercise uses only loopback HTTP. The program opens a temporary local port for each case and closes it afterward. It accepts no destination argument, refuses other endpoints and redirects, and explicitly supplies a useless lab placeholder instead of reading your provider credentials. Do not add a real key or change it to a hosted endpoint.

Version 0.131.0 is the reproducible lab baseline, not a claim to be the latest release. The official SDK documentation linked below is the place to check current versions and supported configuration. This lab adds no cloud resource or model.

3. Compare raw HTTP with the SDK method

First run only these two cases:

Code example
node fde-sdk-request-lab.mjs raw-http
node fde-sdk-request-lab.mjs sdk

Each result now pairs the selected requests with authored responses by attempt number. An empty response list means no HTTP response was recorded; it is not a status of zero. The SDK path reads the actual HTTP status with .withResponse(), separately from the application's acceptance rule.

Both should record one POST to /v1/messages, with the same model, max_tokens, messages and API version. Compare the requests arrays. The model identifier local-fixture-not-a-model is a marker for this exercise, not a usable provider model name.

Open the code. The raw path builds headers, serializes the body and parses the HTTP response. The SDK path calls client.messages.create(body). The SDK handles that transport work, but an HTTP request still crosses the boundary. The selected fields match; the lab does not claim every SDK-added header is identical.

The text “Authored reply: forms are at reception” comes from the reply object in this file. The usage numbers there are fictional fixture values, not measured token counts or billing. Neither the SDK call nor its response proves a model ran.

4. Observe retries, errors and missing responses

Predict the attempt count and application decision before running each case:

CaseLocal server behaviorExpected observationApplication decision
retryFirst 503, then 2002 HTTP attempts with maxRetries: 1review-draft
bad-request4001 attempt; BadRequestError with status 400inspect-error
timeoutReceives the request but does not answer1 attempt; APIConnectionTimeoutError, no HTTP statusoutcome-unknown
unexpected-body200 with valid JSON in the wrong shape1 attempt; parsed object fails the application's checkinspect-response
Code example
node fde-sdk-request-lab.mjs retry
node fde-sdk-request-lab.mjs bad-request
node fde-sdk-request-lab.mjs timeout
node fde-sdk-request-lab.mjs unexpected-body

A retry is an additional attempt, so one retry can mean two requests. This lab's first 503 does no model work. That does not establish how a real provider handles a lost response or duplicate operation. Do not infer free retries or exactly-once effects from this local example.

The timeout case waits 500 milliseconds with retries disabled. The server's request record proves receipt in this experiment, even though the client gets no response. In production, a client timeout alone cannot tell you whether remote work started or finished. Record that uncertainty and use the service's documented status, reconciliation or idempotency mechanism where one exists.

An HTTP 200 means the server returned a successful status, not that your user has a usable answer. This SDK baseline parses the unexpected JSON without enforcing our application's acceptance rule. The separate decide function requires a normally finished nonempty text response. It is a deliberately narrow check, not a full provider schema validator, factual review or tool-execution loop.

5. Change the policy and predict the consequence

Make a separate copy before changing the file. Restore the original between these two experiments:

  1. Set RETRY_LIMIT from 1 to 0, then run retry. Expect one attempt, a 503 error and inspect-error. The server's second response is never reached. What did the client policy change, and what did it leave unchanged?
  2. In the authored reply, change stop_reason from end_turn to max_tokens, then run sdk. The server still returns 200, but decide should withhold the text and choose inspect-response. Explain why transport success and normal completion are different observations.

The test command checks the original baseline and the retry-limit experiment; changing the normal-completion fixture intentionally invalidates the baseline's accepted-draft expectation. Keep that failed expectation as evidence, then restore the original file.

Write one small integration card: the installed client version, endpoint owner, request route, retry limit, timeout, accepted response shape and an explicit action for unknown outcomes. Record no real keys or private prompts. Ask a partner to point to the line that crosses HTTP and the line that accepts the response.

6. Connect this to agent and cloud engineering

A LangChain agent can call a provider adapter; LangGraph can coordinate a workflow; an MCP client can exchange protocol messages with a tool server. None removes the need to understand each connection's request, errors and authority. An SDK retry is transport behavior, not evidence of an agent planning another step.

The cloud response lab compares selected GCP, AWS and Azure response contracts. Those services have distinct identifiers, authentication and SDKs. Do not replace only a base URL and assume this Anthropic Messages example becomes a universal cloud adapter.

With Academy access, continue to the SDK lesson, then the first LangChain agent. Keep the integration card beside the workflow diagram so a framework name never hides where data goes.

7. Check the primary references

Checked 21 October 2026. This workbook, local fixture and teaching code are original LockedIn Labs material. The exercise demonstrates the installed client against its local fixture; it does not certify a production integration.

Before you move on

Keep the evidence of your work.

  • Six actual local request traces with attempt counts and decisions.
  • Two changed-copy comparisons and an explanation of unknown outcomes.
  • An integration card separating transport limits from response acceptance.

Keep these in your own working copy. Reading this page does not save work or record completion.

Suggested next free session

Streaming 101: when is a response actually finished?

Distinguish visible progress from completion when a response arrives in parts. This is a suggested sequence; choose the practice that addresses your current gap.

Open the next free guide

Free account

Give your practice a home.

Try a role exercise with account drafts and a downloadable worksheet. Keep the files you made in this guide in your own working copy.

Create a free learning account

Guided training · by application

Build toward a program.

Request structured lessons and a training seat. Scope, schedule, feedback arrangements and tuition are confirmed in writing before you commit.

Explore a training application
Have Academy access?

Use your existing training seat to open worked explanations and practice in the related lesson. Creating a free account does not grant a seat.

Open the related Academy lesson →
Back to top ↑