csharp changedcli-sdks-libraries/sdks/csharp
Nearest release: v2.1.307, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+8added
Lines−8removed
From line
53
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits9to this page, all time
The whole hunk
from line 53, old and new numbered
/
from line 53
5353}
5454```
5555
56For authentication options including Workload Identity Federation, see [Authentication](https://platform.claude.com/docs/en/manage-claude/authentication). If your API key is a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) with access to multiple workspaces, set the workspace ID in the `anthropic-workspace-id` request header; [Select a workspace](https://platform.claude.com/docs/en/manage-claude/authentication#select-a-workspace) shows the per-request option for this SDK.
56For authentication options including Workload Identity Federation, see [Authentication](https://platform.claude.com/docs/en/manage-claude/authentication). If your API key is a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) that isn't scoped to a workspace, set the workspace ID in the `anthropic-workspace-id` request header; [Select a workspace](https://platform.claude.com/docs/en/manage-claude/authentication#select-a-workspace) shows the per-request option for this SDK.
5757
5858## Client configuration
5959
from line 104
104104Console.WriteLine(message);
105105```
106106
107Using a [`with` expression](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/with-expression) makes it easy to construct the modified options.
107You can use a [`with` expression](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/with-expression) to construct the modified options.
108108
109109The `WithOptions` method does not affect the original client or service.
110110
from line 152
152152
153153Additionally, all 4xx errors inherit from `Anthropic4xxException`.
154154
155* `AnthropicSseException`: thrown for errors encountered during SSE streaming after a successful initial HTTP response.
155* `AnthropicSseException`: Errors encountered during SSE streaming after a successful initial HTTP response.
156156
157157* `AnthropicIOException`: I/O networking errors.
158158
from line 172
172172* 429 Rate Limit
173173* 5xx Internal
174174
175The API may also explicitly instruct the SDK to retry or not retry a request.
175The API might also explicitly instruct the SDK to retry or not retry a request.
176176
177177To set a custom number of retries, configure the client using the `MaxRetries` property:
178178
from line 263
263263
264264## Response validation
265265
266In rare cases, the API may return a response that doesn't match the expected type. By default, the SDK does not throw an exception in this case. It throws `AnthropicInvalidDataException` only if you directly access the property.
266In rare cases, the API might return a response that doesn't match the expected type. By default, the SDK does not throw an exception in this case. It throws `AnthropicInvalidDataException` only if you directly access the property.
267267
268268If you would prefer to check that the response is completely well-typed upfront, then either call `Validate`:
269269
from line 296
296296
297297## IChatClient integration
298298
299The SDK provides an implementation of the `IChatClient` interface from the `Microsoft.Extensions.AI.Abstractions` library. This enables `AnthropicClient` (and `Anthropic.Services.IBetaService`) to be used with other libraries that integrate with these core abstractions. For example, tools in the MCP C# SDK (`ModelContextProtocol`) library can be used directly with an `AnthropicClient` exposed through `IChatClient`.
299The SDK provides an implementation of the `IChatClient` interface from the `Microsoft.Extensions.AI.Abstractions` library. This allows `AnthropicClient` (and `Anthropic.Services.IBetaService`) to be used with other libraries that integrate with these core abstractions. For example, tools in the MCP C# SDK (`ModelContextProtocol`) library can be used directly with an `AnthropicClient` exposed through `IChatClient`.
300300
301301```csharp
302302using Anthropic;
from line 324
324324
325325To send a request to the Claude API, build an instance of a `Params` class and pass it to the corresponding client method. When the response is received, it's deserialized into an instance of a C# class.
326326
327For example, `client.Messages.Create` should be called with an instance of `MessageCreateParams`, and it will return an instance of `Task<Message>`.
327For example, `client.Messages.Create` should be called with an instance of `MessageCreateParams`, and it returns an instance of `Task<Message>`.
328328
329329## Advanced usage
330330
331331### Binary responses
332332
333The SDK defines methods that return binary responses, which are used for API responses that shouldn't necessarily be parsed, like non-JSON data.
333The SDK defines methods that return binary responses, which are used for API responses that shouldn't necessarily be parsed, such as non-JSON data.
334334
335335These methods return `HttpResponse`:
336336
No line in this hunk matches that.