You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0967d63
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: skills/claude-api/csharp/claude-api/files-api.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
-
# Files API — C#
1
+
# Files API - C#
2
2
3
-
## Files API (Beta)
3
+
## Files API
4
+
5
+
> **Out of beta.** In current SDKs `client.Beta.Files` has breaking shape changes from previous versions, matching the stable `client.Files` - migrate per the Files API row in `shared/live-sources.md`. Examples below predate this.
4
6
5
7
Files live under `client.Beta.Files` (namespace `Anthropic.Models.Beta.Files`). `BinaryContent` implicit-converts from `Stream` and `byte[]`.
6
8
@@ -17,7 +19,7 @@ new BetaRequestDocumentBlock {
17
19
}
18
20
```
19
21
20
-
The non-beta `DocumentBlockParamSource` union has no file-ID variant — file references need `client.Beta.Messages.Create()`.
22
+
The non-beta `DocumentBlockParamSource` union has no file-ID variant - file references need `client.Beta.Messages.Create()`.
Copy file name to clipboardExpand all lines: skills/claude-api/csharp/claude-api/streaming.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Streaming — C#
1
+
# Streaming - C#
2
2
3
3
## Streaming
4
4
@@ -22,7 +22,7 @@ await foreach (RawMessageStreamEvent streamEvent in client.Messages.CreateStream
22
22
}
23
23
```
24
24
25
-
**`RawMessageStreamEvent` TryPick methods** (naming drops the `Message`/`Raw` prefix): `TryPickStart`, `TryPickDelta`, `TryPickStop`, `TryPickContentBlockStart`, `TryPickContentBlockDelta`, `TryPickContentBlockStop`. There is no `TryPickMessageStop`— use `TryPickStop`.
25
+
**`RawMessageStreamEvent` TryPick methods** (naming drops the `Message`/`Raw` prefix): `TryPickStart`, `TryPickDelta`, `TryPickStop`, `TryPickContentBlockStart`, `TryPickContentBlockDelta`, `TryPickContentBlockStop`. There is no `TryPickMessageStop`- use `TryPickStop`.
Copy file name to clipboardExpand all lines: skills/claude-api/csharp/claude-api/tool-use.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Tool Use — C#
1
+
# Tool Use - C#
2
2
3
3
For conceptual overview (tool definitions, tool choice, tips), see [shared/tool-use-concepts.md](../../shared/tool-use-concepts.md).
4
4
5
5
## Tool Use
6
6
7
7
### Defining a tool
8
8
9
-
`Tool` (NOT `ToolParam`) with an `InputSchema` record. `InputSchema.Type` is auto-set to `"object"` by the constructor — don't set it. `ToolUnion` has an implicit conversion from `Tool`, triggered by the collection expression `[...]`.
9
+
`Tool` (NOT `ToolParam`) with an `InputSchema` record. `InputSchema.Type` is auto-set to `"object"` by the constructor - don't set it. `ToolUnion` has an implicit conversion from `Tool`, triggered by the collection expression `[...]`.
10
10
11
11
```csharp
12
12
usingSystem.Text.Json;
@@ -38,14 +38,14 @@ Derived from `anthropic-sdk-csharp/src/Anthropic/Models/Messages/Tool.cs` and `T
38
38
See [shared tool use concepts](../../shared/tool-use-concepts.md) for the loop pattern.
39
39
### Converting response content to the follow-up assistant message
40
40
41
-
When echoing Claude's response back in the assistant turn, **there is no `.ToParam()` helper**— manually reconstruct each `ContentBlock` variant as its `*Param` counterpart. Do NOT use `new ContentBlockParam(block.Json)`: it compiles and serializes, but `.Value` stays `null` so `TryPick*`/`Validate()` fail (degraded JSON pass-through, not the typed path).
41
+
When echoing Claude's response back in the assistant turn, **there is no `.ToParam()` helper**- manually reconstruct each `ContentBlock` variant as its `*Param` counterpart. Do NOT use `new ContentBlockParam(block.Json)`: it compiles and serializes, but `.Value` stays `null` so `TryPick*`/`Validate()` fail (degraded JSON pass-through, not the typed path).
`ToolResultBlockParam` has no tuple constructor — use the object initializer. `Content` is a string-or-list union; a plain `string` implicitly converts.
100
+
`ToolResultBlockParam` has no tuple constructor - use the object initializer. `Content` is a string-or-list union; a plain `string` implicitly converts.
101
101
102
102
---
103
103
@@ -122,7 +122,7 @@ OutputConfig = new OutputConfig {
122
122
123
123
## Anthropic-Defined Tools
124
124
125
-
Web search, bash, text editor, and code execution are Anthropic-defined tools with built-in schemas. Web search and code execution are server-executed; bash and text editor are client-executed (you handle the `tool_use` locally — see `shared/tool-use-concepts.md`). Type names are version-suffixed; constructors auto-set `name`/`type`. **Wrap each in `new ToolUnion(...)` explicitly.**
125
+
Web search, bash, text editor, and code execution are Anthropic-defined tools with built-in schemas. Web search and code execution are server-executed; bash and text editor are client-executed (you handle the `tool_use` locally - see `shared/tool-use-concepts.md`). Type names are version-suffixed; constructors auto-set `name`/`type`. **Wrap each in `new ToolUnion(...)` explicitly.**
The C# SDK provides a `BetaToolRunner` for automatic tool execution loops. Define tools with raw JSON schemas, and the runner handles the API call → tool execution → result feedback loop.
142
+
The C# SDK provides a `BetaToolRunner` for automatic tool execution loops. Define tools with raw JSON schemas, and the runner handles the API call -> tool execution -> result feedback loop.
> **Fable 5, Claude Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, and Sonnet 4.6:** Use adaptive thinking. `budget_tokens` is removed on Fable 5, Claude Opus 5, Opus 4.8, and 4.7 (400 if sent); deprecated on Opus 4.6 and Sonnet 4.6.
186
-
> **Claude Opus 5:** thinking is on by default — omitting `"thinking"` runs adaptive (`{"type": "adaptive"}` is equivalent), unlike Opus 4.8/4.7 where omitting it meant no thinking. `{"type": "disabled"}` is accepted only at effort `high` or lower; pairing it with `xhigh`/`max` returns a 400.
186
+
> **Claude Opus 5:** thinking is on by default - omitting `"thinking"` runs adaptive (`{"type": "adaptive"}` is equivalent), unlike Opus 4.8/4.7 where omitting it meant no thinking. `{"type": "disabled"}` is accepted only at effort `high` or lower; pairing it with `xhigh`/`max` returns a 400.
187
187
> **Older models:** Use `"type": "enabled"` with `"budget_tokens": N` (must be < `max_tokens`, min 1024).
## Refusal Fallbacks (Claude Fable 5) — opt in by default
211
+
## Refusal Fallbacks (Claude Fable 5.1) - opt in by default
212
212
213
-
On `claude-fable-5`, safety classifiers may decline a request (HTTP 200 with `stop_reason: "refusal"`). Fallbacks are **opt-in**: without them the request simply stops. Include the `fallbacks` parameter and its beta header by default — on a policy decline the API re-runs the same request on the fallback model inside the same call. A decline before any output isn't billed (a mid-stream decline bills the streamed partial); the rescue bills at the fallback model's own rates.
213
+
On `claude-fable-5-1`, safety classifiers may decline a request (HTTP 200 with `stop_reason: "refusal"`). Fallbacks are **opt-in**: without them the request simply stops. Include the `fallbacks` parameter and its beta header by default - on a policy decline the API re-runs the same request on the fallback model inside the same call. A decline before any output isn't billed (a mid-stream decline bills the streamed partial); the rescue bills at the fallback model's own rates.
The header must be exactly `server-side-fallback-2026-06-01`**for this array form**; the newer `fallbacks: "default"` scalar form uses `server-side-fallback-2026-07-01` instead (see `shared/model-migration.md`→ Migrating to Claude Opus 5 → New API features), and pairing either header with the other form returns a 400. The parameter is rejected on the Batches API and unavailable on Amazon Bedrock, Vertex AI, and Microsoft Foundry. Full semantics (sticky routing, billing, streaming, echoing fallback turns back): `shared/model-migration.md`→ Migrating to Claude Fable 5 →`refusal` stop reason.
245
+
The header must be exactly `server-side-fallback-2026-06-01`**for this array form**; the newer `fallbacks: "default"` scalar form uses `server-side-fallback-2026-07-01` instead (see `shared/model-migration.md`-> Migrating to Claude Opus 5 -> New API features), and pairing either header with the other form returns a 400. The parameter is rejected on the Batches API and unavailable on Amazon Bedrock, Vertex AI, and Microsoft Foundry. Full semantics (sticky routing, billing, streaming, echoing fallback turns back): `shared/model-migration.md`-> Migrating to Claude Fable 5.1 ->`refusal` stop reason.
Copy file name to clipboardExpand all lines: skills/claude-api/curl/managed-agents.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Managed Agents — cURL / Raw HTTP
1
+
# Managed Agents - cURL / Raw HTTP
2
2
3
3
Use these examples when the user needs raw HTTP requests or is working without an SDK.
4
4
@@ -55,7 +55,7 @@ curl -X POST https://api.anthropic.com/v1/environments \
55
55
56
56
## Create an Agent (required first step)
57
57
58
-
> ⚠️**There is no inline agent config.** Under `managed-agents-2026-04-01`, `model`/`system`/`tools` are top-level fields on `POST /v1/agents`, not on the session. Always create the agent first — the session only takes `"agent": {"type": "agent", "id": "..."}`.
58
+
> Warning:**There is no inline agent config.** Under `managed-agents-2026-04-01`, `model`/`system`/`tools` are top-level fields on `POST /v1/agents`, not on the session. Always create the agent first - the session only takes `"agent": {"type": "agent", "id": "..."}`.
59
59
60
60
### Minimal
61
61
@@ -68,7 +68,7 @@ curl -X POST https://api.anthropic.com/v1/agents \
68
68
"model": "claude-opus-5",
69
69
"tools": [{ "type": "agent_toolset_20260401" }]
70
70
}'
71
-
#→ { "id": "agent_abc123", ... }
71
+
#-> { "id": "agent_abc123", ... }
72
72
73
73
# 2. Start a session
74
74
curl -X POST https://api.anthropic.com/v1/sessions \
@@ -77,7 +77,7 @@ curl -X POST https://api.anthropic.com/v1/sessions \
# Trace: https://platform.claude.com/workspaces/default/sessions/sesn_abc123 (swap 'default' for your workspace ID if the API key is not in the Default workspace)
82
82
```
83
83
@@ -143,13 +143,13 @@ curl -X POST https://api.anthropic.com/v1/sessions \
143
143
}
144
144
}'
145
145
146
-
# Change the cap — higher or lower, but it must exceed the consumed list cost.
146
+
# Change the cap - higher or lower, but it must exceed the consumed list cost.
147
147
# An accepted update resumes work paused at budget_reached
148
148
curl -X POST https://api.anthropic.com/v1/sessions/$SESSION_ID \
0 commit comments