Follow Discord
Sweep 10 Nov 2026 · 02:18Z Build v2.1.322 539 read Stable v2.1.311 Latest v2.1.322 Next v2.1.322 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

middleware changedcli-sdks-libraries/middleware

Recorded here
Lines+4added
Lines−4removed
From line 25 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits13to this page, all time

The whole hunk

from line 25, old and new numbered
/
lines
from line 25
2525 - claude-sonnet-4-5-20250929
2626 supportedPlatforms:
2727 Claude API: stable
28 Amazon Bedrock: stable
29 Amazon Bedrock (bedrock-runtime): stable
2830 Claude Platform on AWS: stable
2931 Claude Models on Google Cloud (Anthropic managed): stable
30 Amazon Bedrock: stable
31 Amazon Bedrock (InvokeModel): stable
3232 Claude Models on Google Cloud (Google managed): stable
3333 Microsoft Foundry: stable
3434---
3535 
36The Claude SDK provides a middleware (or interceptor) hook that lets you run code before a request is sent and after the response is received. Use middleware for cross-cutting concerns such as logging, custom retries, request annotation, and refusal fallback handling.
36The Anthropic SDK provides a middleware (or interceptor) hook that runs your code before the SDK sends a request and after it receives the response. Use middleware for cross-cutting concerns such as logging, custom retries, request annotation, and retrying a declined request on a [fallback model](https://platform.claude.com/docs/en/cli-sdks-libraries/middleware#built-in-middleware).
3737 
3838```mermaid
3939sequenceDiagram
from line 202
202202 
203203When you register multiple middleware, they apply in the order given: the first middleware’s “before” code runs first, and its “after” code runs last. Middleware registered on the client runs before middleware passed as a per-request option.
204204 
205In the Go SDK, repeated `option.WithMiddleware` calls concatenate (client first, then method). In the other SDKs, pass an array; later entries wrap inner.
205To register more than one middleware, pass them all, as in `middleware=[first, second]` (typescript, ruby: `middleware: [first, second]`; csharp: `Handlers = [first, second]`; go: `option.WithMiddleware(first, second)`; java: `.addInterceptor(first).addInterceptor(second)`; php: `'middleware' => [$first, $second]`).
206206 
207207## Replacing the HTTP client
208208 
Feedback