Sweep 22 Sep 2026 · 15:52Z Build v2.1.280 501 read Stable v2.1.267 Latest v2.1.280 Next v2.1.280 Feeds RSS JSON llms.txt Unofficial
Reading a new release v2.1.280 Building the pages · 4/6 1043 findings $36.88 so far
One capture · api

One read of Claude Developer Platform

51 pages moved out of 629 read.

api-20260917T220709Z

Pages moved 51 significant first
Pages read 629 in this capture
Captured 22:07 UTC
Corpus hash 0ed65feb02a6 corpus-hash

What this read moved

1–25 of 51

This capture is too large to show at once. Changes 1-25 of 51 are below, significant first; the rest are on the following screens.

about-claude/use-case-guides/content-moderation Changed · +4 / -4 lines

from line 780
780780 
781781 // Parse the JSON response from Claude. The SDK decodes each content block
782782 // into its concrete class, so find the TextBlock before reading the text.
783 $textBlock = array_find($response->content, fn ($block) => $block instanceof TextBlock)
783 $textBlock = array_find($response->content, fn ($block) => $block instanceof \Anthropic\Messages\TextBlock)
784784 ?? throw new RuntimeException('Expected a text block in the response.');
785785 $assessment = json_decode($textBlock->text, associative: true, flags: JSON_THROW_ON_ERROR);
786786 
from line 1333
13331333 
13341334 // Parse the JSON response from Claude. The SDK decodes each content block
13351335 // into its concrete class, so find the TextBlock before reading the text.
1336 $textBlock = array_find($response->content, fn ($block) => $block instanceof TextBlock)
1336 $textBlock = array_find($response->content, fn ($block) => $block instanceof \Anthropic\Messages\TextBlock)
13371337 ?? throw new RuntimeException('Expected a text block in the response.');
13381338 $assessment = json_decode($textBlock->text, associative: true, flags: JSON_THROW_ON_ERROR);
13391339 
from line 2073
20732073 
20742074 // Parse the JSON response from Claude. The SDK decodes each content block
20752075 // into its concrete class, so find the TextBlock before reading the text.
2076 $textBlock = array_find($response->content, fn ($block) => $block instanceof TextBlock)
2076 $textBlock = array_find($response->content, fn ($block) => $block instanceof \Anthropic\Messages\TextBlock)
20772077 ?? throw new RuntimeException('Expected a text block in the response.');
20782078 $assessment = json_decode($textBlock->text, associative: true, flags: JSON_THROW_ON_ERROR);
20792079 
from line 2648
26482648 
26492649 // Parse the JSON response from Claude. The SDK decodes each content block
26502650 // into its concrete class, so find the TextBlock before reading the text.
2651 $textBlock = array_find($response->content, fn ($block) => $block instanceof TextBlock)
2651 $textBlock = array_find($response->content, fn ($block) => $block instanceof \Anthropic\Messages\TextBlock)
26522652 ?? throw new RuntimeException('Expected a text block in the response.');
26532653 
26542654 return json_decode($textBlock->text, associative: true, flags: JSON_THROW_ON_ERROR);

agents-and-tools/mcp-connector Changed · +9 / -3 lines

from line 658
658658 </Tab>
659659 
660660 <Tab title="Java">
661 The helpers live in the separate `anthropic-java-mcp` artifact, which requires Java 17 or later (the core SDK supports Java 8):
661 The helpers live in the separate `anthropic-java-mcp` artifact, which requires Java 17 or later (the base SDK supports Java 8). Add it alongside the base `anthropic-java` dependency:
662662 
663663 <Tabs>
664664 <Tab title="Gradle">
665665 ```kotlin
666 implementation("com.anthropic:anthropic-java-mcp:2.60.0")
666 implementation("com.anthropic:anthropic-java:2.63.0")
667 implementation("com.anthropic:anthropic-java-mcp:2.63.0")
667668 ```
668669 </Tab>
669670 
from line 672
671672 ```xml
672673 <dependency>
673674 <groupId>com.anthropic</groupId>
675 <artifactId>anthropic-java</artifactId>
676 <version>2.63.0</version>
677 </dependency>
678 <dependency>
679 <groupId>com.anthropic</groupId>
674680 <artifactId>anthropic-java-mcp</artifactId>
675 <version>2.60.0</version>
681 <version>2.63.0</version>
676682 </dependency>
677683 ```
678684 </Tab>

agents-and-tools/tool-use/advisor-tool Changed · +2 / -25 lines

from line 566
566566 }
567567 
568568 // Append the full response content, including any advisor_tool_result blocks.
569 // BetaMessage.ToParam drops advisor result content as of anthropic-sdk-go
570 // v1.61.0, so re-parse each response block's raw JSON into a param block instead.
571 assistantContent := make([]anthropic.BetaContentBlockParamUnion, len(response.Content))
572 for i, block := range response.Content {
573 if err := json.Unmarshal([]byte(block.RawJSON()), &assistantContent[i]); err != nil {
574 log.Fatal(err)
575 }
576 }
577 messages = append(messages, anthropic.BetaMessageParam{
578 Role: anthropic.BetaMessageParamRoleAssistant,
579 Content: assistantContent,
580 })
569 messages = append(messages, response.ToParam())
581570 
582571 // Continue the conversation
583572 messages = append(messages, anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Now add a max-in-flight limit of 10.")))
from line 992
1003992 log.Fatal(err)
1004993 }
1005994 
1006 // Append the full response content, including any advisor_tool_result blocks.
1007 // BetaMessage.ToParam drops advisor result content as of anthropic-sdk-go
1008 // v1.61.0, so re-parse each response block's raw JSON into a param block instead.
1009 assistantContent := make([]anthropic.BetaContentBlockParamUnion, len(response.Content))
1010 for i, block := range response.Content {
1011 if err := json.Unmarshal([]byte(block.RawJSON()), &assistantContent[i]); err != nil {
1012 log.Fatal(err)
1013 }
1014 }
1015 messages = append(messages, anthropic.BetaMessageParam{
1016 Role: anthropic.BetaMessageParamRoleAssistant,
1017 Content: assistantContent,
1018 })
995 messages = append(messages, response.ToParam())
1019996 
1020997 for _, block := range response.Content {
1021998 if block.Type == "server_tool_use" && block.Name == "advisor" {

agents-and-tools/tool-use/computer-use-tool Changed · +24 / -19 lines

from line 929
929929 
930930 
931931 def handle_computer_action(name, tool_input):
932 if name == "screenshot":
933 return capture_screenshot()
934 elif name == "left_click":
935 # coordinate is optional; without it, click where the cursor already is
936 return click(tool_input.get("coordinate"))
937 elif name == "type":
938 return type_text(tool_input["text"])
932 match name:
933 case "screenshot":
934 return capture_screenshot()
935 case "left_click":
936 # coordinate is optional; without it, click where the cursor already is
937 return click(tool_input.get("coordinate"))
938 case "type":
939 return type_text(tool_input["text"])
939940 # Handle other actions as needed
940941 raise ValueError(f"Unknown or unimplemented member: {name}")
941942 ```
from line 977
976977 ): string | Anthropic.ImageBlockParam[] {
977978 const params: object =
978979 typeof input === "object" && input !== null ? input : {};
979 if (action === "screenshot") {
980 return captureScreenshot();
981 } else if (action === "left_click") {
982 // coordinate is optional on the toolset; without one, click at the cursor
983 if ("coordinate" in params && Array.isArray(params.coordinate)) {
984 const [x, y] = params.coordinate;
985 return clickAt(x, y);
986 }
987 return clickAtCursor();
988 } else if (action === "type" && "text" in params) {
989 return typeText(String(params.text));
980 switch (action) {
981 case "screenshot":
982 return captureScreenshot();
983 case "left_click":
984 // coordinate is optional on the toolset; without one, click at the cursor
985 if ("coordinate" in params && Array.isArray(params.coordinate)) {
986 const [x, y] = params.coordinate;
987 return clickAt(x, y);
988 }
989 return clickAtCursor();
990 case "type":
991 if ("text" in params) {
992 return typeText(String(params.text));
993 }
994 break;
990995 }
991996 // Handle other actions as needed
992997 throw new Error(`Unknown or unimplemented member: ${action}`);
from line 1500
14951500 $failed = false;
14961501 foreach ($response->content as $block) {
14971502 // This example declares only the computer toolset; route other tools here if you add them.
1498 if (!($block instanceof ToolUseBlock) || $block->toolsetName !== 'computer') {
1503 if (!($block instanceof \Anthropic\Messages\ToolUseBlock) || $block->toolsetName !== 'computer') {
14991504 continue;
15001505 }
15011506 $result = ['type' => 'tool_result', 'tool_use_id' => $block->id, 'toolset_name' => 'computer'];

agents-and-tools/tool-use/fine-grained-tool-streaming Changed · +84 / -68 lines

from line 402
402402 $toolInputs = [];
403403 
404404 foreach ($stream as $event) {
405 if (
406 $event instanceof RawContentBlockStartEvent
407 && $event->contentBlock instanceof ToolUseBlock
408 ) {
409 $toolInputs[$event->index] = '';
410 } elseif (
411 $event instanceof RawContentBlockDeltaEvent
412 && $event->delta instanceof InputJSONDelta
413 ) {
414 echo $event->delta->partialJSON;
415 $toolInputs[$event->index] .= $event->delta->partialJSON;
405 switch (true) {
406 case $event instanceof RawContentBlockStartEvent:
407 if ($event->contentBlock instanceof ToolUseBlock) {
408 $toolInputs[$event->index] = '';
409 }
410 break;
411 case $event instanceof RawContentBlockDeltaEvent:
412 if ($event->delta instanceof InputJSONDelta) {
413 echo $event->delta->partialJSON;
414 $toolInputs[$event->index] .= $event->delta->partialJSON;
415 }
416 break;
416417 }
417418 }
418419 
from line 571
570571 });
571572 
572573 for await (const event of stream) {
573 if (event.type === "content_block_start" && event.content_block.type === "tool_use") {
574 toolInputs.set(event.index, "");
575 } else if (event.type === "content_block_delta" && event.delta.type === "input_json_delta") {
576 toolInputs.set(
577 event.index,
578 (toolInputs.get(event.index) ?? "") + event.delta.partial_json
579 );
580 } else if (event.type === "content_block_stop" && toolInputs.has(event.index)) {
581 const rawInput = toolInputs.get(event.index)!;
582 try {
583 console.log("Tool input:", JSON.parse(rawInput));
584 } catch {
585 // The accumulated string is not guaranteed to be valid JSON.
586 // See "Handling invalid JSON in tool responses" on this page.
587 console.log("Invalid tool input:", rawInput);
588 }
574 switch (event.type) {
575 case "content_block_start":
576 if (event.content_block.type === "tool_use") {
577 toolInputs.set(event.index, "");
578 }
579 break;
580 case "content_block_delta":
581 if (event.delta.type === "input_json_delta") {
582 toolInputs.set(
583 event.index,
584 (toolInputs.get(event.index) ?? "") + event.delta.partial_json
585 );
586 }
587 break;
588 case "content_block_stop":
589 if (toolInputs.has(event.index)) {
590 const rawInput = toolInputs.get(event.index)!;
591 try {
592 console.log("Tool input:", JSON.parse(rawInput));
593 } catch {
594 // The accumulated string is not guaranteed to be valid JSON.
595 // See "Handling invalid JSON in tool responses" on this page.
596 console.log("Invalid tool input:", rawInput);
597 }
598 }
599 break;
589600 }
590601 }
591602 ```
from line 753
742753 var eventIterator = streamResponse.stream().iterator();
743754 while (eventIterator.hasNext()) {
744755 RawMessageStreamEvent event = eventIterator.next();
745 if (event.isContentBlockStart()) {
746 var blockStart = event.asContentBlockStart();
747 if (blockStart.contentBlock().isToolUse()) {
748 toolInputs.put(blockStart.index(), new StringBuilder());
756 switch (event.type().value()) {
757 case CONTENT_BLOCK_START -> {
758 var blockStart = event.asContentBlockStart();
759 if (blockStart.contentBlock().isToolUse()) {
760 toolInputs.put(blockStart.index(), new StringBuilder());
761 }
749762 }
750 } else if (event.isContentBlockDelta()) {
751 var blockDelta = event.asContentBlockDelta();
752 if (blockDelta.delta().isInputJson() && toolInputs.containsKey(blockDelta.index())) {
753 toolInputs.get(blockDelta.index()).append(blockDelta.delta().asInputJson().partialJson());
763 case CONTENT_BLOCK_DELTA -> {
764 var blockDelta = event.asContentBlockDelta();
765 if (blockDelta.delta().isInputJson() && toolInputs.containsKey(blockDelta.index())) {
766 toolInputs.get(blockDelta.index()).append(blockDelta.delta().asInputJson().partialJson());
767 }
754768 }
755 } else if (event.isContentBlockStop()) {
756 var blockStop = event.asContentBlockStop();
757 if (toolInputs.containsKey(blockStop.index())) {
758 String accumulated = toolInputs.get(blockStop.index()).toString();
759 try {
760 IO.println("Tool input: " + objectMapper.readTree(accumulated));
761 } catch (JsonProcessingException e) {
762 // The accumulated string is not guaranteed to be valid JSON.
763 // See "Handling invalid JSON in tool responses" on this page.
764 IO.println("Invalid tool input: " + accumulated);
769 case CONTENT_BLOCK_STOP -> {
770 var blockStop = event.asContentBlockStop();
771 if (toolInputs.containsKey(blockStop.index())) {
772 String accumulated = toolInputs.get(blockStop.index()).toString();
773 try {
774 IO.println("Tool input: " + objectMapper.readTree(accumulated));
775 } catch (JsonProcessingException e) {
776 // The accumulated string is not guaranteed to be valid JSON.
777 // See "Handling invalid JSON in tool responses" on this page.
778 IO.println("Invalid tool input: " + accumulated);
779 }
765780 }
766781 }
767782 }
from line 818
803818 );
804819 
805820 foreach ($stream as $event) {
806 if (
807 $event instanceof RawContentBlockStartEvent
808 && $event->contentBlock instanceof ToolUseBlock
809 ) {
810 $toolInputs[$event->index] = '';
811 } elseif (
812 $event instanceof RawContentBlockDeltaEvent
813 && $event->delta instanceof InputJSONDelta
814 ) {
815 $toolInputs[$event->index] .= $event->delta->partialJSON;
816 } elseif (
817 $event instanceof RawContentBlockStopEvent
818 && isset($toolInputs[$event->index])
819 ) {
820 $accumulated = $toolInputs[$event->index];
821 try {
822 $parsed = json_decode($accumulated, associative: true, flags: JSON_THROW_ON_ERROR);
823 echo "Tool input: " . json_encode($parsed) . "\n";
824 } catch (JsonException $e) {
825 // The accumulated string is not guaranteed to be valid JSON.
826 // See "Handling invalid JSON in tool responses" on this page.
827 echo "Invalid tool input: {$accumulated}\n";
828 }
821 switch (true) {
822 case $event instanceof RawContentBlockStartEvent:
823 if ($event->contentBlock instanceof ToolUseBlock) {
824 $toolInputs[$event->index] = '';
825 }
826 break;
827 case $event instanceof RawContentBlockDeltaEvent:
828 if ($event->delta instanceof InputJSONDelta) {
829 $toolInputs[$event->index] .= $event->delta->partialJSON;
830 }
831 break;
832 case $event instanceof RawContentBlockStopEvent:
833 if (isset($toolInputs[$event->index])) {
834 $accumulated = $toolInputs[$event->index];
835 try {
836 $parsed = json_decode($accumulated, associative: true, flags: JSON_THROW_ON_ERROR);
837 echo "Tool input: " . json_encode($parsed) . "\n";
838 } catch (JsonException $e) {
839 // The accumulated string is not guaranteed to be valid JSON.
840 // See "Handling invalid JSON in tool responses" on this page.
841 echo "Invalid tool input: {$accumulated}\n";
842 }
843 }
844 break;
829845 }
830846 }
831847 ```

agents-and-tools/tool-use/text-editor-tool Changed · +26 / -20 lines

from line 1504
15041504 command = input_params.get("command", "")
15051505 file_path = input_params.get("path", "")
15061506 
1507 if command == "view":
1508 # Read and return file contents
1509 pass
1510 elif command == "str_replace":
1511 # Replace text in file
1512 pass
1513 elif command == "create":
1514 # Create new file
1515 pass
1516 elif command == "insert":
1517 # Insert text at location
1518 pass
1507 match command:
1508 case "view":
1509 # Read and return file contents
1510 pass
1511 case "str_replace":
1512 # Replace text in file
1513 pass
1514 case "create":
1515 # Create new file
1516 pass
1517 case "insert":
1518 # Insert text at location
1519 pass
15191520 ```
15201521 
15211522 ```typescript TypeScript
from line 1525
15241525 const command = inputParams.command ?? "";
15251526 const filePath = inputParams.path ?? "";
15261527 
1527 if (command === "view") {
1528 // Read and return file contents
1529 } else if (command === "str_replace") {
1530 // Replace text in file
1531 } else if (command === "create") {
1532 // Create new file
1533 } else if (command === "insert") {
1534 // Insert text at location
1528 switch (command) {
1529 case "view":
1530 // Read and return file contents
1531 break;
1532 case "str_replace":
1533 // Replace text in file
1534 break;
1535 case "create":
1536 // Create new file
1537 break;
1538 case "insert":
1539 // Insert text at location
1540 break;
15351541 }
15361542 }
15371543 ```

agents-and-tools/tool-use/tool-runner Changed · +10 / -5 lines

from line 438
438438 <?php
439439 
440440 use Anthropic\Client;
441 use Anthropic\Beta\Messages\BetaTextBlock;
442 use Anthropic\Beta\Messages\BetaToolUseBlock;
441443 use Anthropic\Lib\Tools\BetaRunnableTool;
442444 use Anthropic\Messages\Model;
443445 
from line 497
495497 
496498 foreach ($runner as $message) {
497499 foreach ($message->content as $block) {
498 if ($block->type === 'text') {
499 echo $block->text, "\n";
500 } elseif ($block->type === 'tool_use') {
501 echo "[Tool call: {$block->name}]\n";
500 switch (true) {
501 case $block instanceof BetaTextBlock:
502 echo $block->text, "\n";
503 break;
504 case $block instanceof BetaToolUseBlock:
505 echo "[Tool call: {$block->name}]\n";
506 break;
502507 }
503508 }
504509 }
from line 1456
14511456 foreach ($runner as $message) {
14521457 $toolResults = [];
14531458 foreach ($message->content as $block) {
1454 if ($block instanceof BetaToolUseBlock) {
1459 if ($block instanceof \Anthropic\Beta\Messages\BetaToolUseBlock) {
14551460 $toolResults[] = [
14561461 'type' => 'tool_result',
14571462 'tool_use_id' => $block->id,

api/beta-headers Changed · +9 / -1 lines

from line 168
168168anthropic-beta: feature1,feature2,feature3
169169```
170170 
171When using an SDK, list each feature in the `betas` parameter (for example, `betas=["feature1", "feature2"]`). With the CLI, pass a single `--beta` flag with the feature names separated by commas (for example, `--beta feature1,feature2`). Avoid repeating the flag: currently only the first flag's value takes effect.
171You can also send the `anthropic-beta` header more than once in the same request. The Claude API reads every `anthropic-beta` header, so the following is equivalent to the previous example:
172 
173```http
174anthropic-beta: feature1
175anthropic-beta: feature2
176anthropic-beta: feature3
177```
178 
179When using an SDK, list each feature in the `betas` parameter (for example, `betas=["feature1", "feature2"]`). With the CLI, pass a single `--beta` flag with the feature names separated by commas (for example, `--beta feature1,feature2`). You can also repeat the flag (for example, `--beta feature1 --beta feature2`).
172180 
173181### Endpoint-specific headers
174182 

api/compliance Changed · +506 / -12 lines

This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.

from line 19
1919 
2020#### Query parameters
2121 
22- `activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 499 more`
22- `activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 501 more`
2323 
2424 Filter activities by type. See the response `data` schema for the additional fields each type returns. Cannot be combined with `exclude_activity_types[]`.
2525 
from line 1063
10631063 
10641064 The "Auto" permission mode in Cowork was enabled for the organization, allowing members to let Claude approve its own actions after a safety check.
10651065 
1066 - `"org_cowork_browser_pane_disabled"`
1067 
1068 The in-app browser in Cowork was disabled for the organization, so Claude can no longer open or use websites in a browser pane during members' Cowork sessions.
1069 
1070 - `"org_cowork_browser_pane_enabled"`
1071 
1072 The in-app browser in Cowork was enabled for the organization, letting Claude open and use websites in a browser pane during members' Cowork sessions.
1073 
10661074 - `"org_cowork_disabled"`
10671075 
10681076 Organization cowork was disabled.
from line 2094
20862094 
20872095 format: date-time
20882096 
2089- `exclude_activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 499 more`
2097- `exclude_activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 501 more`
20902098 
20912099 Exclude activities of these types. Cannot be combined with `activity_types[]`.
20922100 
from line 3138
31303138 
31313139 The "Auto" permission mode in Cowork was enabled for the organization, allowing members to let Claude approve its own actions after a safety check.
31323140 
3141 - `"org_cowork_browser_pane_disabled"`
3142 
3143 The in-app browser in Cowork was disabled for the organization, so Claude can no longer open or use websites in a browser pane during members' Cowork sessions.
3144 
3145 - `"org_cowork_browser_pane_enabled"`
3146 
3147 The in-app browser in Cowork was enabled for the organization, letting Claude open and use websites in a browser pane during members' Cowork sessions.
3148 
31333149 - `"org_cowork_disabled"`
31343150 
31353151 Organization cowork was disabled.
from line 4161
41454161 
41464162#### Returns
41474163 
4148- `data: optional array of AbuseDecisionReceived or AccountDeleted or AdminAPIKeyCreated or 499 more`
4164- `data: optional array of AbuseDecisionReceived or AccountDeleted or AdminAPIKeyCreated or 501 more`
41494165 
41504166 List of activity records. Each element's `type` field identifies which activity it is and which additional fields are present.
41514167 
from line 8745
87298745 
87308746 - `user_agent: optional string or null`
87318747 
8732 - `audience: array of ArtifactSharingAudienceOrganization or ArtifactSharingAudienceUsers or ArtifactSharingAudienceAnyoneWithLink`
8748 - `audience: array of Organization or Users or AnyoneWithLink`
87338749 
87348750 The artifact's sharing audience after the change. If empty, the artifact is visible only to its owner.
87358751 
8736 - `ArtifactSharingAudienceOrganization object`
8752 - `Organization object`
87378753 
87388754 Sharing audience: visible to the owning organization.
87398755 
from line 8757
87418757 
87428758 default: organization
87438759 
8744 - `ArtifactSharingAudienceUsers object`
8760 - `Users object`
87458761 
87468762 Sharing audience: visible to an explicit allowlist of users.
87478763 
from line 8765
87498765 
87508766 default: users
87518767 
8752 - `ArtifactSharingAudienceAnyoneWithLink object`
8768 - `AnyoneWithLink object`
87538769 
8754 Sharing audience: anyone with the link, including anonymous viewers
8755 (an artifact shared to the open internet).
8770 Sharing audience: anyone with the link, including anonymous viewers (an artifact shared to the open internet).
87568771 
87578772 - `type: optional "anyone_with_link"`
87588773 
from line 9917
99029917 
99039918 - `ip_address: optional string or null`
99049919 
9905 - `user_agent: optional string or null`
9906 
9907 - `FederatedActor object`
9908 
9909 An external identity asserted by a trusted provider — a cloud-provider
9910 gateway or a customer-registered federation issuer — acting without an
9911 Anthropic-provisioned account or service account.
9912 
9913 - `type: optional "federated_actor"`
9914 
9915 default: federated_actor
9916 
9917 - `provider: FederatedActorAwsProvider or FederatedActorAzureProvider or FederatedActorGcpProvider or FederatedActorOidcProvider`
9918 
9919 - `FederatedActorAwsProvider object`
9920 
9921 Asserting party: the AWS account the organization is bound to.
9922 
9923 - `type: optional "aws
9920 - `user_agen

api/compliance/activities Changed · +5718 / -4776 lines

This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.

from line 17
1717 
1818### Query parameters
1919 
20- `activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 499 more`
20- `activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 501 more`
2121 
2222 Filter activities by type. See the response `data` schema for the additional fields each type returns. Cannot be combined with `exclude_activity_types[]`.
2323 
from line 1061
10611061 
10621062 The "Auto" permission mode in Cowork was enabled for the organization, allowing members to let Claude approve its own actions after a safety check.
10631063 
1064 - `"org_cowork_browser_pane_disabled"`
1065 
1066 The in-app browser in Cowork was disabled for the organization, so Claude can no longer open or use websites in a browser pane during members' Cowork sessions.
1067 
1068 - `"org_cowork_browser_pane_enabled"`
1069 
1070 The in-app browser in Cowork was enabled for the organization, letting Claude open and use websites in a browser pane during members' Cowork sessions.
1071 
10641072 - `"org_cowork_disabled"`
10651073 
10661074 Organization cowork was disabled.
from line 2092
20842092 
20852093 format: date-time
20862094 
2087- `exclude_activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 499 more`
2095- `exclude_activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 501 more`
20882096 
20892097 Exclude activities of these types. Cannot be combined with `activity_types[]`.
20902098 
from line 3136
31283136 
31293137 The "Auto" permission mode in Cowork was enabled for the organization, allowing members to let Claude approve its own actions after a safety check.
31303138 
3139 - `"org_cowork_browser_pane_disabled"`
3140 
3141 The in-app browser in Cowork was disabled for the organization, so Claude can no longer open or use websites in a browser pane during members' Cowork sessions.
3142 
3143 - `"org_cowork_browser_pane_enabled"`
3144 
3145 The in-app browser in Cowork was enabled for the organization, letting Claude open and use websites in a browser pane during members' Cowork sessions.
3146 
31313147 - `"org_cowork_disabled"`
31323148 
31333149 Organization cowork was disabled.
from line 4159
41434159 
41444160### Returns
41454161 
4146- `data: optional array of AbuseDecisionReceived or AccountDeleted or AdminAPIKeyCreated or 499 more`
4162- `data: optional array of AbuseDecisionReceived or AccountDeleted or AdminAPIKeyCreated or 501 more`
41474163 
41484164 List of activity records. Each element's `type` field identifies which activity it is and which additional fields are present.
41494165 
from line 8743
87278743 
87288744 - `user_agent: optional string or null`
87298745 
8730 - `audience: array of ArtifactSharingAudienceOrganization or ArtifactSharingAudienceUsers or ArtifactSharingAudienceAnyoneWithLink`
8746 - `audience: array of Organization or Users or AnyoneWithLink`
87318747 
87328748 The artifact's sharing audience after the change. If empty, the artifact is visible only to its owner.
87338749 
8734 - `ArtifactSharingAudienceOrganization object`
8750 - `Organization object`
87358751 
87368752 Sharing audience: visible to the owning organization.
87378753 
from line 8755
87398755 
87408756 default: organization
87418757 
8742 - `ArtifactSharingAudienceUsers object`
8758 - `Users object`
87438759 
87448760 Sharing audience: visible to an explicit allowlist of users.
87458761 
from line 8763
87478763 
87488764 default: users
87498765 
8750 - `ArtifactSharingAudienceAnyoneWithLink object`
8766 - `AnyoneWithLink object`
87518767 
8752 Sharing audience: anyone with the link, including anonymous viewers
8753 (an artifact shared to the open internet).
8768 Sharing audience: anyone with the link, including anonymous viewers (an artifact shared to the open internet).
87548769 
87558770 - `type: optional "anyone_with_link"`
87568771 
from line 9917
99029917 
99039918 - `user_agent: optional string or null`
99049919 
9905 - `FederatedActor object`
9906 
9907 An external identity asserted by a trusted provider — a cloud-provider
9908 gateway or a customer-registered federation issuer — acting without an
9909 Anthropic-provisioned account or service account.
9910 
9911 - `type: optional "federated_actor"`
9912 
9913 default: federated_actor
9914 
9915 - `provider: FederatedActorAwsProvider or FederatedActorAzureProvider or FederatedActorGcpProvider or FederatedActorOidcProvider`
9916 
9917 - `FederatedActorAwsProvider object`
9918 
9919 Asserting party: the AWS account the organization is bound to.
9920 
9921 - `type: optional "aws"`
9922 
9923 default: aws
9924 
9925
9920

api/compliance/activities/list Changed · +489 / -10 lines

This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.

from line 15
1515 
1616## Query parameters
1717 
18- `activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 499 more`
18- `activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 501 more`
1919 
2020 Filter activities by type. See the response `data` schema for the additional fields each type returns. Cannot be combined with `exclude_activity_types[]`.
2121 
from line 1059
10591059 
10601060 The "Auto" permission mode in Cowork was enabled for the organization, allowing members to let Claude approve its own actions after a safety check.
10611061 
1062 - `"org_cowork_browser_pane_disabled"`
1063 
1064 The in-app browser in Cowork was disabled for the organization, so Claude can no longer open or use websites in a browser pane during members' Cowork sessions.
1065 
1066 - `"org_cowork_browser_pane_enabled"`
1067 
1068 The in-app browser in Cowork was enabled for the organization, letting Claude open and use websites in a browser pane during members' Cowork sessions.
1069 
10621070 - `"org_cowork_disabled"`
10631071 
10641072 Organization cowork was disabled.
from line 2090
20822090 
20832091 format: date-time
20842092 
2085- `exclude_activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 499 more`
2093- `exclude_activity_types: optional array of "abuse_decision_received" or "account_deleted" or "admin_api_key_created" or 501 more`
20862094 
20872095 Exclude activities of these types. Cannot be combined with `activity_types[]`.
20882096 
from line 3134
31263134 
31273135 The "Auto" permission mode in Cowork was enabled for the organization, allowing members to let Claude approve its own actions after a safety check.
31283136 
3137 - `"org_cowork_browser_pane_disabled"`
3138 
3139 The in-app browser in Cowork was disabled for the organization, so Claude can no longer open or use websites in a browser pane during members' Cowork sessions.
3140 
3141 - `"org_cowork_browser_pane_enabled"`
3142 
3143 The in-app browser in Cowork was enabled for the organization, letting Claude open and use websites in a browser pane during members' Cowork sessions.
3144 
31293145 - `"org_cowork_disabled"`
31303146 
31313147 Organization cowork was disabled.
from line 4157
41414157 
41424158## Returns
41434159 
4144- `data: optional array of AbuseDecisionReceived or AccountDeleted or AdminAPIKeyCreated or 499 more`
4160- `data: optional array of AbuseDecisionReceived or AccountDeleted or AdminAPIKeyCreated or 501 more`
41454161 
41464162 List of activity records. Each element's `type` field identifies which activity it is and which additional fields are present.
41474163 
from line 8741
87258741 
87268742 - `user_agent: optional string or null`
87278743 
8728 - `audience: array of ArtifactSharingAudienceOrganization or ArtifactSharingAudienceUsers or ArtifactSharingAudienceAnyoneWithLink`
8744 - `audience: array of Organization or Users or AnyoneWithLink`
87298745 
87308746 The artifact's sharing audience after the change. If empty, the artifact is visible only to its owner.
87318747 
8732 - `ArtifactSharingAudienceOrganization object`
8748 - `Organization object`
87338749 
87348750 Sharing audience: visible to the owning organization.
87358751 
from line 8753
87378753 
87388754 default: organization
87398755 
8740 - `ArtifactSharingAudienceUsers object`
8756 - `Users object`
87418757 
87428758 Sharing audience: visible to an explicit allowlist of users.
87438759 
from line 8761
87458761 
87468762 default: users
87478763 
8748 - `ArtifactSharingAudienceAnyoneWithLink object`
8764 - `AnyoneWithLink object`
87498765 
8750 Sharing audience: anyone with the link, including anonymous viewers
8751 (an artifact shared to the open internet).
8766 Sharing audience: anyone with the link, including anonymous viewers (an artifact shared to the open internet).
87528767 
87538768 - `type: optional "anyone_with_link"`
87548769 
from line 9915
99009915 
99019916 - `user_agent: optional string or null`
99029917 
9903 - `FederatedActor object`
9904 
9905 An external identity asserted by a trusted provider — a cloud-provider
9906 gateway or a customer-registered federation issuer — acting without an
9907 Anthropic-provisioned account or service account.
9908 
9909 - `type: optional "federated_actor"`
9910 
9911 default: federated_actor
9912 
9913 - `provider: FederatedActorAwsProvider or FederatedActorAzureProvider or FederatedActorGcpProvider or FederatedActorOidcProvider`
9914 
9915 - `FederatedActorAwsProvider object`
9916 
9917 Asserting party: the AWS account the organization is bound to.
9918 
9919 - `type: optional "aws"`
9920 
9921 default: aws
9922 
9918

api/compliance/organizations Changed · +17 / -2 lines

from line 472
472472is configured in the admin console. Settings an organization's
473473administrators cannot change (for example, ones controlled by Anthropic
474474policy or not available to the organization) are omitted from the list.
475Settings that report a compliance arrangement with Anthropic are the
476exception: the HIPAA and Access Transparency settings are always included;
477the API zero data retention setting is reported for Claude Console
478organizations, and the Claude Code zero data retention and customer-managed
479encryption keys (CMEK) settings for Claude Enterprise organizations. Each
480reports whether the arrangement is in place at the organization level; a
481retention setting on an individual workspace is not reflected.
475482 
476483The organization must belong to the API key's organization hierarchy;
477484unknown organizations and organizations outside the hierarchy return 404.
from line 551
544551 
545552 default: boolean
546553 
547 - `name: "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or "artifact_connectors_enabled" or 53 more`
554 - `name: "access_transparency_enabled" or "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or 57 more`
548555 
556 - `"access_transparency_enabled"`
557 
549558 - `"ai_powered_artifacts_enabled"`
550559 
551560 - `"api_workbench_feedback_collection_enabled"`
552561 
562 - `"api_zero_data_retention_enabled"`
563 
553564 - `"artifact_connectors_enabled"`
554565 
555566 - `"ask_your_org_enabled"`
from line 599
588599 
589600 - `"claude_design_enabled"`
590601 
602 - `"claude_enterprise_claude_code_zero_data_retention_enabled"`
603 
591604 - `"claude_in_slack_enabled"`
592605 
593606 - `"claude_science_custom_connectors_enabled"`
from line 619
606619 
607620 - `"claude_science_ssh_hosts_enabled"`
608621 
622 - `"cmek_enabled"`
623 
609624 - `"code_execution_enabled"`
610625 
611626 - `"code_execution_network_egress_enabled"`
from line 827
812827 "organization_id": "organization_id",
813828 "settings": [
814829 {
815 "name": "ai_powered_artifacts_enabled",
830 "name": "access_transparency_enabled",
816831 "value": true,
817832 "type": "boolean"
818833 }

api/compliance/organizations/settings Changed · +34 / -4 lines

from line 16
1616is configured in the admin console. Settings an organization's
1717administrators cannot change (for example, ones controlled by Anthropic
1818policy or not available to the organization) are omitted from the list.
19Settings that report a compliance arrangement with Anthropic are the
20exception: the HIPAA and Access Transparency settings are always included;
21the API zero data retention setting is reported for Claude Console
22organizations, and the Claude Code zero data retention and customer-managed
23encryption keys (CMEK) settings for Claude Enterprise organizations. Each
24reports whether the arrangement is in place at the organization level; a
25retention setting on an individual workspace is not reflected.
1926 
2027The organization must belong to the API key's organization hierarchy;
2128unknown organizations and organizations outside the hierarchy return 404.
from line 95
8895 
8996 default: boolean
9097 
91 - `name: "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or "artifact_connectors_enabled" or 53 more`
98 - `name: "access_transparency_enabled" or "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or 57 more`
9299 
100 - `"access_transparency_enabled"`
101 
93102 - `"ai_powered_artifacts_enabled"`
94103 
95104 - `"api_workbench_feedback_collection_enabled"`
96105 
106 - `"api_zero_data_retention_enabled"`
107 
97108 - `"artifact_connectors_enabled"`
98109 
99110 - `"ask_your_org_enabled"`
from line 143
132143 
133144 - `"claude_design_enabled"`
134145 
146 - `"claude_enterprise_claude_code_zero_data_retention_enabled"`
147 
135148 - `"claude_in_slack_enabled"`
136149 
137150 - `"claude_science_custom_connectors_enabled"`
from line 163
150163 
151164 - `"claude_science_ssh_hosts_enabled"`
152165 
166 - `"cmek_enabled"`
167 
153168 - `"code_execution_enabled"`
154169 
155170 - `"code_execution_network_egress_enabled"`
from line 371
356371 "organization_id": "organization_id",
357372 "settings": [
358373 {
359 "name": "ai_powered_artifacts_enabled",
374 "name": "access_transparency_enabled",
360375 "value": true,
361376 "type": "boolean"
362377 }
from line 391
376391 Settings appear at most once each, in a fixed relative order, and values
377392 reflect the enforced state. A setting the organization's administrators
378393 cannot change — for example, one controlled by Anthropic policy or not
379 available to the organization — is omitted from the list.
394 available to the organization — is omitted from the list. Settings that
395 report a compliance arrangement with Anthropic are the exception: the
396 HIPAA and Access Transparency settings are always included; the API zero
397 data retention setting is reported for Claude Console organizations, and
398 the Claude Code zero data retention and customer-managed encryption keys
399 (CMEK) settings for Claude Enterprise organizations. Each reports whether
400 the arrangement is in place at the organization level; a retention setting
401 on an individual workspace is not reflected.
380402 
381403 - `type: optional "effective_organization_settings"`
382404 
from line 456
434456 
435457 default: boolean
436458 
437 - `name: "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or "artifact_connectors_enabled" or 53 more`
459 - `name: "access_transparency_enabled" or "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or 57 more`
438460 
461 - `"access_transparency_enabled"`
462 
439463 - `"ai_powered_artifacts_enabled"`
440464 
441465 - `"api_workbench_feedback_collection_enabled"`
442466 
467 - `"api_zero_data_retention_enabled"`
468 
443469 - `"artifact_connectors_enabled"`
444470 
445471 - `"ask_your_org_enabled"`
from line 504
478504 
479505 - `"claude_design_enabled"`
480506 
507 - `"claude_enterprise_claude_code_zero_data_retention_enabled"`
508 
481509 - `"claude_in_slack_enabled"`
482510 
483511 - `"claude_science_custom_connectors_enabled"`
from line 523
495523 - `"claude_science_scientific_model_endpoints_enabled"`
496524 
497525 - `"claude_science_ssh_hosts_enabled"`
526 
527 - `"cmek_enabled"`
498528 
499529 - `"code_execution_enabled"`
500530 

api/compliance/organizations/settings/retrieve Changed · +17 / -2 lines

from line 14
1414is configured in the admin console. Settings an organization's
1515administrators cannot change (for example, ones controlled by Anthropic
1616policy or not available to the organization) are omitted from the list.
17Settings that report a compliance arrangement with Anthropic are the
18exception: the HIPAA and Access Transparency settings are always included;
19the API zero data retention setting is reported for Claude Console
20organizations, and the Claude Code zero data retention and customer-managed
21encryption keys (CMEK) settings for Claude Enterprise organizations. Each
22reports whether the arrangement is in place at the organization level; a
23retention setting on an individual workspace is not reflected.
1724 
1825The organization must belong to the API key's organization hierarchy;
1926unknown organizations and organizations outside the hierarchy return 404.
from line 93
8693 
8794 default: boolean
8895 
89 - `name: "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or "artifact_connectors_enabled" or 53 more`
96 - `name: "access_transparency_enabled" or "ai_powered_artifacts_enabled" or "api_workbench_feedback_collection_enabled" or 57 more`
9097 
98 - `"access_transparency_enabled"`
99 
91100 - `"ai_powered_artifacts_enabled"`
92101 
93102 - `"api_workbench_feedback_collection_enabled"`
94103 
104 - `"api_zero_data_retention_enabled"`
105 
95106 - `"artifact_connectors_enabled"`
96107 
97108 - `"ask_your_org_enabled"`
from line 141
130141 
131142 - `"claude_design_enabled"`
132143 
144 - `"claude_enterprise_claude_code_zero_data_retention_enabled"`
145 
133146 - `"claude_in_slack_enabled"`
134147 
135148 - `"claude_science_custom_connectors_enabled"`
from line 161
148161 
149162 - `"claude_science_ssh_hosts_enabled"`
150163 
164 - `"cmek_enabled"`
165 
151166 - `"code_execution_enabled"`
152167 
153168 - `"code_execution_network_egress_enabled"`
from line 369
354369 "organization_id": "organization_id",
355370 "settings": [
356371 {
357 "name": "ai_powered_artifacts_enabled",
372 "name": "access_transparency_enabled",
358373 "value": true,
359374 "type": "boolean"
360375 }

build-with-claude/batch-processing Changed · +29 / -23 lines

from line 82
8282The Batches API offers significant cost savings. All usage is charged at 50% of the standard API prices.
8383 
8484| Model | Batch input | Batch output |
85| ------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------- |
85| :------------------------------------------------------------------------------------------------------------------------------------ | :----------- | :------------ |
8686| Claude Fable 5.1 | $5 / MTok | $25 / MTok |
8787| Claude Mythos 5.1 ([limited availability](https://anthropic.com/glasswing)) | $5 / MTok | $25 / MTok |
8888| Claude Fable 5 | $5 / MTok | $25 / MTok |
from line 751
751751 for result in client.messages.batches.results(
752752 "msgbatch_01HkcTjaV5uDC8jWR4ZsDV8d",
753753 ):
754 match result.result.type:
754 outcome = result.result
755 match outcome.type:
755756 case "succeeded":
756757 print(f"Success! {result.custom_id}")
757758 case "errored":
758 if result.result.error.error.type == "invalid_request_error":
759 if outcome.error.error.type == "invalid_request_error":
759760 # Request body must be fixed before re-sending request
760761 print(f"Validation error {result.custom_id}")
761762 else:
from line 864
863864 streamResponse
864865 .stream()
865866 .forEach(result -> {
866 if (result.result().isSucceeded()) {
867 System.out.println("Success! " + result.customId());
868 } else if (result.result().isErrored()) {
869 if (result.result().asErrored().error().error().isInvalidRequestError()) {
870 // Request body must be fixed before re-sending request
871 System.out.println("Validation error: " + result.customId());
872 } else {
873 // Request can be retried directly
874 System.out.println("Server error: " + result.customId());
867 switch (result.result().type().value()) {
868 case SUCCEEDED -> System.out.println("Success! " + result.customId());
869 case ERRORED -> {
870 if (result.result().asErrored().error().error().isInvalidRequestError()) {
871 // Request body must be fixed before re-sending request
872 System.out.println("Validation error: " + result.customId());
873 } else {
874 // Request can be retried directly
875 System.out.println("Server error: " + result.customId());
876 }
875877 }
876 } else if (result.result().isExpired()) {
877 System.out.println("Request expired: " + result.customId());
878 case EXPIRED -> System.out.println("Request expired: " + result.customId());
878879 }
879880 });
880881 }
from line 882
881882 ```
882883 
883884 ```php PHP
885 use Anthropic\Messages\Batches\MessageBatchErroredResult;
886 use Anthropic\Messages\Batches\MessageBatchExpiredResult;
887 use Anthropic\Messages\Batches\MessageBatchSucceededResult;
888 
884889 $client = new Client();
885890 
886891 foreach ($client->messages->batches->resultsStream(messageBatchID: 'msgbatch_01HkcTjaV5uDC8jWR4ZsDV8d') as $result) {
887 switch ($result->result->type) {
888 case "succeeded":
892 switch (true) {
893 case $result->result instanceof MessageBatchSucceededResult:
889894 echo "Success! {$result->customID}\n";
890895 break;
891 case "errored":
896 case $result->result instanceof MessageBatchErroredResult:
892897 if ($result->result->error->error->type === "invalid_request_error") {
893898 echo "Validation error: {$result->customID}\n";
894899 } else {
from line 900
895900 echo "Server error: {$result->customID}\n";
896901 }
897902 break;
898 case "expired":
903 case $result->result instanceof MessageBatchExpiredResult:
899904 echo "Request expired: {$result->customID}\n";
900905 break;
901906 }
from line 911
906911 client = Anthropic::Client.new
907912 
908913 client.messages.batches.results_streaming("msgbatch_01HkcTjaV5uDC8jWR4ZsDV8d").each do |result|
909 case result.result.type
910 when :succeeded
914 outcome = result.result
915 case outcome
916 when Anthropic::Models::Messages::MessageBatchSucceededResult
911917 puts "Success! #{result.custom_id}"
912 when :errored
913 if result.result.error.type == :invalid_request
918 when Anthropic::Models::Messages::MessageBatchErroredResult
919 if outcome.error.type == :invalid_request
914920 puts "Validation error: #{result.custom_id}"
915921 else
916922 puts "Server error: #{result.custom_id}"
917923 end
918 when :expired
924 when Anthropic::Models::Messages::MessageBatchExpiredResult
919925 puts "Request expired: #{result.custom_id}"
920926 end
921927 end

build-with-claude/cache-diagnostics Changed · +10 / -5 lines

from line 680
680680 
681681 $diagnostics = null;
682682 foreach ($stream as $event) {
683 if ($event instanceof BetaRawMessageStartEvent) {
684 // diagnostics arrives on the message_start event's embedded BetaMessage
685 $diagnostics = $event->message->diagnostics;
686 } elseif ($event instanceof BetaRawContentBlockDeltaEvent && $event->delta instanceof BetaTextDelta) {
687 echo $event->delta->text;
683 switch (true) {
684 case $event instanceof \Anthropic\Beta\Messages\BetaRawMessageStartEvent:
685 // diagnostics arrives on the message_start event's embedded BetaMessage
686 $diagnostics = $event->message->diagnostics;
687 break;
688 case $event instanceof \Anthropic\Beta\Messages\BetaRawContentBlockDeltaEvent:
689 if ($event->delta instanceof \Anthropic\Beta\Messages\BetaTextDelta) {
690 echo $event->delta->text;
691 }
692 break;
688693 }
689694 }
690695 echo PHP_EOL;

build-with-claude/claude-in-amazon-bedrock Changed · +8 / -2 lines

from line 102
102102 <Tabs>
103103 <Tab title="Gradle">
104104 ```kotlin
105 implementation("com.anthropic:anthropic-java-bedrock:2.60.0")
105 implementation("com.anthropic:anthropic-java:2.63.0")
106 implementation("com.anthropic:anthropic-java-bedrock:2.63.0")
106107 ```
107108 </Tab>
108109 
from line 111
110111 ```xml
111112 <dependency>
112113 <groupId>com.anthropic</groupId>
114 <artifactId>anthropic-java</artifactId>
115 <version>2.63.0</version>
116 </dependency>
117 <dependency>
118 <groupId>com.anthropic</groupId>
113119 <artifactId>anthropic-java-bedrock</artifactId>
114 <version>2.60.0</version>
120 <version>2.63.0</version>
115121 </dependency>
116122 ```
117123 </Tab>

build-with-claude/claude-in-microsoft-foundry Changed · +8 / -2 lines

from line 77
7777 <Tabs>
7878 <Tab title="Gradle">
7979 ```kotlin
80 implementation("com.anthropic:anthropic-java-foundry:2.60.0")
80 implementation("com.anthropic:anthropic-java:2.63.0")
81 implementation("com.anthropic:anthropic-java-foundry:2.63.0")
8182 
8283 // For Entra ID authentication, also add the Azure Identity library
8384 implementation("com.azure:azure-identity:1.18.3")
from line 89
8889 ```xml
8990 <dependency>
9091 <groupId>com.anthropic</groupId>
92 <artifactId>anthropic-java</artifactId>
93 <version>2.63.0</version>
94 </dependency>
95 <dependency>
96 <groupId>com.anthropic</groupId>
9197 <artifactId>anthropic-java-foundry</artifactId>
92 <version>2.60.0</version>
98 <version>2.63.0</version>
9399 </dependency>
94100 <!-- For Entra ID authentication, also add the Azure Identity library -->
95101 <dependency>

build-with-claude/claude-on-amazon-bedrock-legacy Changed · +8 / -2 lines

from line 54
5454 <Tab title="Java">
5555 <CodeGroup>
5656 ```groovy Gradle
57 implementation("com.anthropic:anthropic-java-bedrock:2.60.0")
57 implementation("com.anthropic:anthropic-java:2.63.0")
58 implementation("com.anthropic:anthropic-java-bedrock:2.63.0")
5859 ```
5960 
6061 ```xml Maven
6162 <dependency>
6263 <groupId>com.anthropic</groupId>
64 <artifactId>anthropic-java</artifactId>
65 <version>2.63.0</version>
66 </dependency>
67 <dependency>
68 <groupId>com.anthropic</groupId>
6369 <artifactId>anthropic-java-bedrock</artifactId>
64 <version>2.60.0</version>
70 <version>2.63.0</version>
6571 </dependency>
6672 ```
6773 

build-with-claude/claude-on-vertex-ai Changed · +4 / -4 lines

from line 45
4545 <Tab title="Java">
4646 <CodeGroup exclude="shell, python, typescript, csharp, go, php, ruby">
4747 ```groovy Gradle
48 implementation("com.anthropic:anthropic-java:2.60.0")
49 implementation("com.anthropic:anthropic-java-vertex:2.60.0")
48 implementation("com.anthropic:anthropic-java:2.63.0")
49 implementation("com.anthropic:anthropic-java-vertex:2.63.0")
5050 ```
5151 
5252 ```xml Maven
from line 53
5353 <dependency>
5454 <groupId>com.anthropic</groupId>
5555 <artifactId>anthropic-java</artifactId>
56 <version>2.60.0</version>
56 <version>2.63.0</version>
5757 </dependency>
5858 <dependency>
5959 <groupId>com.anthropic</groupId>
6060 <artifactId>anthropic-java-vertex</artifactId>
61 <version>2.60.0</version>
61 <version>2.63.0</version>
6262 </dependency>
6363 ```
6464 

build-with-claude/claude-platform-on-aws Changed · +15 / -9 lines

from line 111
111111 
112112* **Create the new organization first.** Sign up through the AWS Console (see [Set up your account](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#set-up-your-account)). If your move involves a private offer, complete sign-up before the offer is accepted: discounts apply from acceptance, not retroactively. See [Private offers](https://platform.claude.com/docs/en/about-claude/pricing#private-offers).
113113* **Recreate access and configuration.** API keys, workspaces, and Claude Console settings don't carry over from an existing organization. Create workspaces in the new organization and switch your applications to [Claude Platform on AWS authentication](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#authentication).
114* **Update your integration.** Claude Platform on AWS serves the Claude API (`/v1/{endpoint}`), so request and response shapes are unchanged from the first-party Claude API. What changes is the base URL, the authentication method, and the required `anthropic-workspace-id` header; see [Making requests](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#making-requests). Some platform features differ; see [Features not supported](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#features-not-supported).
114* **Update your integration.** Claude Platform on AWS serves the Claude API (`/v1/{endpoint}`), so request and response shapes are unchanged from the first-party Claude API. What changes is the base URL, the authentication method, and the `anthropic-workspace-id` header on inference and resource requests; see [Making requests](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#making-requests). Some platform features differ; see [Features not supported](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#features-not-supported).
115115* **Cut over on your own schedule.** The new organization is independent of your existing one, and both can serve traffic in parallel. There's no need for a hard cutover: shift workloads gradually until all of your traffic is on the new organization.
116116 
117117Once the new organization is running, the differences are concentrated in billing and authentication, which are handled through AWS:
from line 305
305305 
306306 <Tab title="Java">
307307 ```kotlin Gradle
308 implementation("com.anthropic:anthropic-java-aws:2.60.0")
308 implementation("com.anthropic:anthropic-java:2.63.0")
309 implementation("com.anthropic:anthropic-java-aws:2.63.0")
309310 ```
310311 
311312 ```xml Maven
312313 <dependency>
313314 <groupId>com.anthropic</groupId>
315 <artifactId>anthropic-java</artifactId>
316 <version>2.63.0</version>
317 </dependency>
318 <dependency>
319 <groupId>com.anthropic</groupId>
314320 <artifactId>anthropic-java-aws</artifactId>
315 <version>2.60.0</version>
321 <version>2.63.0</version>
316322 </dependency>
317323 ```
318324 </Tab>
from line 345
339345The following models are available on Claude Platform on AWS:
340346 
341347| Model | Model ID |
342| ----------------- | ----------------- |
348| :---------------- | :---------------- |
343349| Claude Fable 5.1 | claude-fable-5-1 |
344350| Claude Fable 5 | claude-fable-5 |
345351| Claude Opus 5 | claude-opus-5 |
from line 352
346352| Claude Opus 4.8 | claude-opus-4-8 |
347353| Claude Opus 4.7 | claude-opus-4-7 |
348354| Claude Opus 4.6 | claude-opus-4-6 |
355| Claude Opus 4.5 | claude-opus-4-5 |
349356| Claude Sonnet 5 | claude-sonnet-5 |
350357| Claude Sonnet 4.6 | claude-sonnet-4-6 |
351| Claude Opus 4.5 | claude-opus-4-5 |
352358| Claude Sonnet 4.5 | claude-sonnet-4-5 |
353359| Claude Haiku 4.5 | claude-haiku-4-5 |
354360 
from line 368
362368 
363369## Making requests
364370 
365Claude Platform on AWS uses the same API endpoints as the first-party Claude API. The differences are the base URL, the authentication method, and a required `anthropic-workspace-id` header that identifies which [workspace](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#workspaces) the request targets.
371Claude Platform on AWS uses the same API endpoints as the first-party Claude API. The differences are the base URL, the authentication method, and the `anthropic-workspace-id` header, which identifies the [workspace](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#workspaces) a request targets. The header is required on inference and resource requests, such as calls to the Messages API, Models API, Files API, and Claude Managed Agents endpoints. Requests to the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) workspace and external key endpoints don't require it.
366372 
367373Before running these examples, complete the steps in [Before making API calls](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#before-making-api-calls).
368374 
from line 780
774780 
775781### Managing workspaces
776782 
777Create additional workspaces, rename a workspace, or archive a workspace from the AWS Console **Workspaces** page or with the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) workspace endpoints. A new workspace is bound to the AWS region of the endpoint you call to create it (see [Workspace scoping](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#workspace-scoping)). With the Admin role, you can also create, rename, and archive workspaces from the Claude Console **Workspaces** page.
783Create additional workspaces, rename a workspace, or archive a workspace from the AWS Console **Workspaces** page or with the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) workspace endpoints. These endpoints don't require the `anthropic-workspace-id` header. Create and list act on the organization; get, update, and archive take the workspace ID in the URL path. A new workspace is bound to the AWS region of the endpoint you call to create it (see [Workspace scoping](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#workspace-scoping)). With the Admin role, you can also create, rename, and archive workspaces from the Claude Console **Workspaces** page.
778784 
779785## Using the Claude Console
780786 
from line 830
824830 
825831Organizations on Claude Platform on AWS are placed on the Start tier. Anthropic manages rate limits directly, not through AWS quota systems.
826832 
827Organizations on Claude Platform on AWS do not move between usage tiers automatically. Usage-based tier advancement applies to first-party Claude API organizations, not to organizations billed through AWS Marketplace. The self-service **Request rate limit increase** flow in the Claude Console is also not available: the Rate limits page directs you to your Anthropic account representative instead.
833Organizations on Claude Platform on AWS can move to a higher usage tier automatically as they build a history of paid AWS Marketplace invoices. The self-service **Request rate limit increase** flow in the Claude Console is not available: the Rate limits page directs you to your Anthropic account representative instead.
828834 
829835To request higher limits, contact your Anthropic account representative or [Anthropic support](https://support.claude.com). Include the following in your request:
830836 
from line 1050
10441050| **SDK package** | `anthropic[bedrock]`, `@anthropic-ai/bedrock-sdk`, and others | `anthropic[bedrock]`, `@anthropic-ai/bedrock-sdk`, or AWS SDK | `anthropic[aws]`, `@anthropic-ai/aws-sdk`, and others (see [Install an SDK](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#install-an-sdk)) |
10451051| **SigV4 service name** | `bedrock-mantle` | `bedrock` | `aws-external-anthropic` |
10461052| **Streaming format** | SSE | AWS EventStream | SSE (same as Claude API) |
1047| **Workspace header** | Not applicable | Not applicable | `anthropic-workspace-id` required |
1053| **Workspace header** | Not applicable | Not applicable | `anthropic-workspace-id`, required on inference and resource requests |
10481054| **Region availability** | See [Amazon Bedrock regions](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html) | See [Amazon Bedrock regions](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html) | All AWS commercial regions |
10491055| **Anthropic organization** | None required | None required | New organization created at sign-up. Existing organizations can't be converted (see [Moving from an existing Anthropic organization](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws#moving-from-an-existing-anthropic-organization)) |
10501056 

build-with-claude/compaction Changed · +282 / -47 lines

from line 1755
17551755 context_management={"edits": [{"type": "compact_20260112"}]},
17561756 ) as stream:
17571757 for event in stream:
1758 if event.type == "content_block_start":
1759 if event.content_block.type == "compaction":
1760 print("Compaction started...")
1761 elif event.content_block.type == "text":
1762 print("Text response started...")
1758 match event.type:
1759 case "content_block_start":
1760 block = event.content_block
1761 match block.type:
1762 case "compaction":
1763 print("Compaction started...")
1764 case "text":
1765 print("Text response started...")
17631766 
1764 elif event.type == "content_block_delta":
1765 if event.delta.type == "compaction_delta":
1766 print(f"Compaction complete: {len(event.delta.content or '')} chars")
1767 elif event.delta.type == "text_delta":
1768 print(event.delta.text, end="", flush=True)
1767 case "content_block_delta":
1768 delta = event.delta
1769 match delta.type:
1770 case "compaction_delta":
1771 print(f"Compaction complete: {len(delta.content or '')} chars")
1772 case "text_delta":
1773 print(delta.text, end="", flush=True)
17691774 
17701775 # Get the final accumulated message
17711776 message = stream.get_final_message()
from line 1794
17891794 });
17901795 
17911796 for await (const event of stream) {
1792 if (event.type === "content_block_start") {
1793 if (event.content_block.type === "compaction") {
1794 console.log("Compaction started...");
1795 } else if (event.content_block.type === "text") {
1796 console.log("Text response started...");
1797 }
1798 } else if (event.type === "content_block_delta") {
1799 if (event.delta.type === "compaction_delta") {
1800 console.log(`Compaction complete: ${event.delta.content?.length ?? 0} chars`);
1801 } else if (event.delta.type === "text_delta") {
1802 process.stdout.write(event.delta.text);
1803 }
1797 switch (event.type) {
1798 case "content_block_start":
1799 switch (event.content_block.type) {
1800 case "compaction":
1801 console.log("Compaction started...");
1802 break;
1803 case "text":
1804 console.log("Text response started...");
1805 break;
1806 }
1807 break;
1808 case "content_block_delta":
1809 switch (event.delta.type) {
1810 case "compaction_delta":
1811 console.log(`Compaction complete: ${event.delta.content?.length ?? 0} chars`);
1812 break;
1813 case "text_delta":
1814 process.stdout.write(event.delta.text);
1815 break;
1816 }
1817 break;
18041818 }
18051819 }
18061820 
from line 1949
19351949 ```
19361950 
19371951 ```php PHP
1952 use Anthropic\Beta\Messages\BetaCompactionBlock;
1953 use Anthropic\Beta\Messages\BetaCompactionContentBlockDelta;
1954 use Anthropic\Beta\Messages\BetaRawContentBlockDeltaEvent;
1955 use Anthropic\Beta\Messages\BetaRawContentBlockStartEvent;
1956 use Anthropic\Beta\Messages\BetaTextBlock;
1957 use Anthropic\Beta\Messages\BetaTextDelta;
1958 
19381959 $client = new Client();
19391960 $messages = [['role' => 'user', 'content' => 'Hello, Claude']];
19401961 
from line 1972
19511972 );
19521973 
19531974 foreach ($stream as $event) {
1954 if ($event->type === 'content_block_start') {
1955 if ($event->contentBlock->type === 'compaction') {
1956 echo "Compaction started...\n";
1957 } elseif ($event->contentBlock->type === 'text') {
1958 echo "Text response started...\n";
1959 }
1960 } elseif ($event->type === 'content_block_delta') {
1961 if ($event->delta->type === 'compaction_delta') {
1962 echo "Compaction complete: " . strlen($event->delta->content ?? '') . " chars\n";
1963 } elseif ($event->delta->type === 'text_delta') {
1964 echo $event->delta->text;
1965 }
1975 switch (true) {
1976 case $event instanceof BetaRawContentBlockStartEvent:
1977 switch (true) {
1978 case $event->contentBlock instanceof BetaCompactionBlock:
1979 echo "Compaction started...\n";
1980 break;
1981 case $event->contentBlock instanceof BetaTextBlock:
1982 echo "Text response started...\n";
1983 break;
1984 }
1985 break;
1986 case $event instanceof BetaRawContentBlockDeltaEvent:
1987 switch (true) {
1988 case $event->delta instanceof BetaCompactionContentBlockDelta:
1989 echo "Compaction complete: " . strlen($event->delta->content ?? '') . " chars\n";
1990 break;
1991 case $event->delta instanceof BetaTextDelta:
1992 echo $event->delta->text;
1993 break;
1994 }
1995 break;
19661996 }
19671997 }
19681998 ```
from line 2012
19822012 )
19832013 
19842014 stream.each do |event|
1985 case event.type
1986 when :content_block_start
1987 if event.content_block.type == :compaction
2015 case event
2016 when Anthropic::Models::BetaRawContentBlockStartEvent
2017 case event.content_block
2018 when Anthropic::Models::BetaCompactionBlock
19882019 puts "Compaction started..."
1989 elsif event.content_block.type == :text
2020 when Anthropic::Models::BetaTextBlock
19902021 puts "Text response started..."
19912022 end
1992 when :content_block_delta
1993 if event.delta.type == :compaction_delta
1994 puts "Compaction complete: #{(event.delta.content || "").length} chars"
1995 elsif event.delta.type == :text_delta
1996 print event.delta.text
2023 when Anthropic::Models::BetaRawContentBlockDeltaEvent
2024 delta = event.delta
2025 case delta
2026 when Anthropic::Models::BetaCompactionContentBlockDelta
2027 puts "Compaction complete: #{(delta.content || "").length} chars"
2028 when Anthropic::Models::BetaTextDelta
2029 print delta.text
19972030 end
19982031 end
19992032 end
from line 3454
34213454 
34223455### Request a summary
34233456 
3424Send the conversation as it stands with `"compaction": {"type": "summarize"}`. The API summarizes every message in the request once, generates no reply after it, and returns the block alone with `stop_reason` `"compaction"`. Send the same `system` prompt and `tools` that you use for the rest of the conversation. The summarizer reads them, and on models with preserved thinking, the turns you keep stay valid only if they match:
3457Send the conversation as it stands with `"compaction": {"type": "summarize"}`. The API summarizes every message in the request once, generates no reply after it, and returns the block alone with `stop_reason` `"compaction"`. Send the same `system` prompt and `tools` that you use for the rest of the conversation. The summarizer reads them, and on models with preserved thinking, the turns you keep stay valid only if they match. The conversation in this example has no `system` prompt or tools, so the request sends neither:
34253458 
3426<CodeGroup exclude="python, typescript, csharp, go, java, php, ruby">
3459<CodeGroup>
34273460 ```bash cURL
3461 # max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
34283462 curl https://api.anthropic.com/v1/messages \
34293463 -H "x-api-key: $ANTHROPIC_API_KEY" \
34303464 -H "anthropic-version: 2023-06-01" \
from line 3484
34503484 <File filename="request.yaml">
34513485 ```yaml
34523486 model: claude-opus-5
3487 # max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
34533488 max_tokens: 4096
34543489 messages:
34553490 - role: user
from line 3498
34633498 ```
34643499 </File>
34653500 </MultiFileExample>
3501 
3502 ```python Python
3503 from anthropic.types.beta import BetaMessageParam
3504 
3505 client = anthropic.Anthropic()
3506 
3507 history: list[BetaMessageParam] = [
3508 {
3509 "role": "user",
3510 "content": "I am building a recipe app. Help me name the main entities in the data model.",
3511 },
3512 {
3513 "role": "assistant",
3514 "content": "Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe.",
3515 },
3516 {"role": "user", "content": "Good. Now suggest field names for Recipe."},
3517 ]
3518 
3519 response = client.beta.messages.create(
3520 model="claude-opus-5",
3521 # max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3522 max_tokens=4096,
3523 betas=["compact-2026-09-04"],
3524 messages=history,
3525 compaction={"type": "summarize"},
3526 )
3527 print(f"Stop reason: {response.stop_reason}")
3528 ```
3529 
3530 ```typescript TypeScript
3531 const client = new Anthropic();
3532 
3533 const history: Anthropic.Beta.Messages.BetaMessageParam[] = [
3534 {
3535 role: "user",
3536 content: "I am building a recipe app. Help me name the main entities in the data model."
3537 },
3538 {
3539 role: "assistant",
3540 content:
3541 "Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe."
3542 },
3543 { role: "user", content: "Good. Now suggest field names for Recipe." }
3544 ];
3545 
3546 const response = await client.beta.messages.create({
3547 model: "claude-opus-5",
3548 // max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3549 max_tokens: 4096,
3550 betas: ["compact-2026-09-04"],
3551 messages: history,
3552 compaction: { type: "summarize" }
3553 });
3554 console.log(`Stop reason: ${response.stop_reason}`);
3555 ```
3556 
3557 ```csharp C#
3558 using Anthropic.Models.Beta;
3559 using Anthropic.Models.Beta.Messages;
3560 using Model = Anthropic.Models.Messages.Model;
3561 
3562 AnthropicClient client = new();
3563 
3564 List<BetaMessageParam> history =
3565 [
3566 new()
3567 {
3568 Role = Role.User,
3569 Content = "I am building a recipe app. Help me name the main entities in the data model.",
3570 },
3571 new()
3572 {
3573 Role = Role.Assistant,
3574 Content = "Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe.",
3575 },
3576 new() { Role = Role.User, Content = "Good. Now suggest field names for Recipe." },
3577 ];
3578 
3579 var response = await client.Beta.Messages.Create(new MessageCreateParams
3580 {
3581 Model = Model.ClaudeOpus5,
3582 // max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3583 MaxTokens = 4096,
3584 Betas = [AnthropicBeta.Compact2026_09_04],
3585 Messages = history,
3586 Compaction = new BetaCompactionConfig(), // type defaults to "summarize"
3587 });
3588 
3589 Console.WriteLine($"Stop reason: {response.StopReason?.Raw()}");
3590 ```
3591 
3592 ```go Go
3593 client := anthropic.NewClient()
3594 
3595 history := []anthropic.BetaMessageParam{
3596 anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("I am building a recipe app. Help me name the main entities in the data model.")),
3597 {
3598 Role: anthropic.BetaMessageParamRoleAssistant,
3599 Content: []anthropic.BetaContentBlockParamUnion{anthropic.NewBetaTextBlock("Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe.")},
3600 },
3601 anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Good. Now suggest field names for Recipe.")),
3602 }
3603 
3604 response, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{
3605 Model: anthropic.ModelClaudeOpus5,
3606 // max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3607 MaxTokens: 4096,
3608 Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaCompact2026_09_04},
3609 Messages: history,
3610 Compaction: anthropic.BetaCompactionConfigUnionParam{
3611 OfSummarize: &anthropic.BetaSummarizeCompactionParam{},
3612 },
3613 })
3614 if err != nil {
3615 log.Fatal(err)
3616 }
3617 fmt.Println("Stop reason:", response.StopReason)
3618 ```
3619 
3620 ```java Java
3621 import com.anthropic.models.beta.AnthropicBeta;
3622 import com.anthropic.models.beta.messages.BetaCompactionConfig;
3623 import com.anthropic.models.beta.messages.MessageCreateParams;
3624 
3625 void main() {
3626 var client = AnthropicOkHttpClient.fromEnv();
3627 
3628 var params = MessageCreateParams.builder()
3629 .model(Model.CLAUDE_OPUS_5)
3630 // max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3631 .maxTokens(4096)
3632 .addBeta(AnthropicBeta.COMPACT_2026_09_04)
3633 .addUserMessage("I am building a recipe app. Help me name the main entities in the data model.")
3634 .addAssistantMessage("Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe.")
3635 .addUserMessage("Good. Now suggest field names for Recipe.")
3636 .compaction(BetaCompactionConfig.builder().build()) // type defaults to "summarize"
3637 .build();
3638 
3639 var response = client.beta().messages().create(params);
3640 response.stopReason().ifPresent(reason -> IO.println("Stop reason: " + reason));
3641 }
3642 ```
3643 
3644 ```php PHP
3645 use Anthropic\Beta\AnthropicBeta;
3646 use Anthropic\Beta\Messages\BetaCompactionConfig;
3647 use Anthropic\Beta\Messages\BetaMessageParam;
3648 use Anthropic\Beta\Messages\BetaMessageParam\Role;
3649 
3650 $client = new Client();
3651 
3652 $history = [
3653 BetaMessageParam::with(
3654 role: Role::USER,
3655 content: 'I am building a recipe app. Help me name the main entities in the data model.',
3656 ),
3657 BetaMessageParam::with(
3658 role: Role::ASSISTANT,
3659 content: 'Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe.',
3660 ),
3661 BetaMessageParam::with(role: Role::USER, content: 'Good. Now suggest field names for Recipe.'),
3662 ];
3663 
3664 $response = $client->beta->messages->create(
3665 model: Model::CLAUDE_OPUS_5,
3666 // max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3667 maxTokens: 4096,
3668 betas: [AnthropicBeta::COMPACT_2026_09_04],
3669 messages: $history,
3670 compaction: BetaCompactionConfig::with(), // type defaults to 'summarize'
3671 );
3672 
3673 echo "Stop reason: {$response->stopReason}", PHP_EOL;
3674 ```
3675 
3676 ```ruby Ruby
3677 client = Anthropic::Client.new
3678 
3679 history = [
3680 {
3681 role: "user",
3682 content: "I am building a recipe app. Help me name the main entities in the data model."
3683 },
3684 {
3685 role: "assistant",
3686 content: "Start with Recipe, Ingredient, and Step. Add a RecipeIngredient entry that holds the quantity and unit for each ingredient in a recipe."
3687 },
3688 { role: "user", content: "Good. Now suggest field names for Recipe." }
3689 ]
3690 
3691 response = client.beta.messages.create(
3692 model: Anthropic::Model::CLAUDE_OPUS_5,
3693 # max_tokens caps the whole call, including any thinking, so allow several thousand tokens.
3694 max_tokens: 4096,
3695 betas: [Anthropic::AnthropicBeta::COMPACT_2026_09_04],
3696 messages: history,
3697 compaction: { type: "summarize" }
3698 )
3699 puts "Stop reason: #{response.stop_reason}"
3700 ```
34663701</CodeGroup>
34673702 
34683703```json Response

build-with-claude/extended-thinking Changed · +14 / -12 lines

from line 110
110110 
111111 // The response contains summarized thinking blocks and text blocks
112112 for (const block of response.content) {
113 if (block.type === "thinking") {
114 console.log(`\nThinking summary: ${block.thinking}`);
115 } else if (block.type === "text") {
116 console.log(`\nResponse: ${block.text}`);
113 switch (block.type) {
114 case "thinking":
115 console.log(`\nThinking summary: ${block.thinking}`);
116 break;
117 case "text":
118 console.log(`\nResponse: ${block.text}`);
119 break;
117120 }
118121 }
119122 ```
from line 225
222225 
223226 // The response contains summarized thinking blocks and text blocks
224227 foreach ($response->content as $block) {
225 echo match ($block->type) {
226 'thinking' => "\nThinking summary: {$block->thinking}",
227 'text' => "\nResponse: {$block->text}",
228 echo match (true) {
229 $block instanceof \Anthropic\Messages\ThinkingBlock => "\nThinking summary: {$block->thinking}",
230 $block instanceof \Anthropic\Messages\TextBlock => "\nResponse: {$block->text}",
228231 default => '',
229232 };
230233 }
from line 254
251254 # The response contains summarized thinking blocks and text blocks
252255 response.content.each do |block|
253256 case block
254 in {type: :thinking, thinking:}
255 puts "\nThinking summary: #{thinking}"
256 in {type: :text, text:}
257 puts "\nResponse: #{text}"
258 else
257 when Anthropic::Models::ThinkingBlock
258 puts "\nThinking summary: #{block.thinking}"
259 when Anthropic::Models::TextBlock
260 puts "\nResponse: #{block.text}"
259261 end
260262 end
261263 ```

build-with-claude/handling-stop-reasons Changed · +58 / -44 lines

from line 2078
20782078<CodeGroup exclude="shell">
20792079 ```python Python
20802080 def handle_response(response):
2081 if response.stop_reason == "tool_use":
2082 return handle_tool_use(response)
2083 elif response.stop_reason == "max_tokens":
2084 return handle_truncation(response)
2085 elif response.stop_reason == "model_context_window_exceeded":
2086 return handle_context_limit(response)
2087 elif response.stop_reason == "pause_turn":
2088 return handle_pause(response)
2089 elif response.stop_reason == "refusal":
2090 return handle_refusal(response)
2091 else:
2092 # Handle end_turn and other cases
2093 return next(
2094 (block.text for block in response.content if block.type == "text"), ""
2095 )
2081 match response.stop_reason:
2082 case "tool_use":
2083 return handle_tool_use(response)
2084 case "max_tokens":
2085 return handle_truncation(response)
2086 case "model_context_window_exceeded":
2087 return handle_context_limit(response)
2088 case "pause_turn":
2089 return handle_pause(response)
2090 case "refusal":
2091 return handle_refusal(response)
2092 case _:
2093 # Handle end_turn and other cases
2094 return next(
2095 (block.text for block in response.content if block.type == "text"),
2096 "",
2097 )
20962098 ```
20972099 
20982100 ```typescript TypeScript
from line 2655
26532655 
26542656 except anthropic.APIStatusError as e:
26552657 # Handle actual errors
2656 if e.status_code == 429:
2657 print("Rate limit exceeded")
2658 elif e.status_code == 500:
2659 print("Server error")
2658 match e.status_code:
2659 case 429:
2660 print("Rate limit exceeded")
2661 case 500:
2662 print("Server error")
26602663 ```
26612664 
26622665 ```typescript TypeScript
from line 2679
26762679 } catch (err) {
26772680 // Handle actual errors
26782681 if (err instanceof Anthropic.APIError) {
2679 if (err.status === 429) {
2680 console.log("Rate limit exceeded");
2681 } else if (err.status === 500) {
2682 console.log("Server error");
2682 switch (err.status) {
2683 case 429:
2684 console.log("Rate limit exceeded");
2685 break;
2686 case 500:
2687 console.log("Server error");
2688 break;
26832689 }
26842690 } else {
26852691 throw err;
from line 2965
29592965 );
29602966 
29612967 foreach ($stream as $event) {
2962 if ($event instanceof RawMessageDeltaEvent && $event->delta->stopReason !== null) {
2968 if ($event instanceof \Anthropic\Messages\RawMessageDeltaEvent && $event->delta->stopReason !== null) {
29632969 echo "Stream ended with: {$event->delta->stopReason}", PHP_EOL;
29642970 }
29652971 }
from line 3464
34583464 max_tokens=20000, # Python SDK requires streaming for max_tokens above ~21k
34593465 )
34603466 
3461 if response.stop_reason == "model_context_window_exceeded":
3462 # Got the maximum possible tokens given input size
3463 print(
3464 f"Generated {response.usage.output_tokens} tokens (context limit reached)"
3465 )
3466 elif response.stop_reason == "max_tokens":
3467 # Got exactly the requested tokens
3468 print(f"Generated {response.usage.output_tokens} tokens (max_tokens reached)")
3469 else:
3470 # Natural completion
3471 print(f"Generated {response.usage.output_tokens} tokens (natural completion)")
3467 match response.stop_reason:
3468 case "model_context_window_exceeded":
3469 # Got the maximum possible tokens given input size
3470 print(
3471 f"Generated {response.usage.output_tokens} tokens (context limit reached)"
3472 )
3473 case "max_tokens":
3474 # Got exactly the requested tokens
3475 print(
3476 f"Generated {response.usage.output_tokens} tokens (max_tokens reached)"
3477 )
3478 case _:
3479 # Natural completion
3480 print(
3481 f"Generated {response.usage.output_tokens} tokens (natural completion)"
3482 )
34723483 
34733484 return next((block.text for block in response.content if block.type == "text"), "")
34743485 ```
from line 3493
34823493 });
34833494 
34843495 const tokens = response.usage.output_tokens;
3485 if (response.stop_reason === "model_context_window_exceeded") {
3486 // Got the maximum possible tokens given input size
3487 console.log(`Generated ${tokens} tokens (context limit reached)`);
3488 } else if (response.stop_reason === "max_tokens") {
3489 // Got exactly the requested tokens
3490 console.log(`Generated ${tokens} tokens (max_tokens reached)`);
3491 } else {
3492 // Natural completion
3493 console.log(`Generated ${tokens} tokens (natural completion)`);
3496 switch (response.stop_reason) {
3497 case "model_context_window_exceeded":
3498 // Got the maximum possible tokens given input size
3499 console.log(`Generated ${tokens} tokens (context limit reached)`);
3500 break;
3501 case "max_tokens":
3502 // Got exactly the requested tokens
3503 console.log(`Generated ${tokens} tokens (max_tokens reached)`);
3504 break;
3505 default:
3506 // Natural completion
3507 console.log(`Generated ${tokens} tokens (natural completion)`);
34943508 }
34953509 
34963510 const textBlock = response.content.find(

build-with-claude/mid-conversation-effort-example Changed · +49 / -41 lines

from line 247
247247 
248248 ```php PHP
249249 use Anthropic\Client;
250 use Anthropic\Messages\TextBlock;
251250 use Anthropic\Messages\ToolUseBlock;
252251 
253252 $client = new Client();
from line 1412
14131412 # so reshape each block to the request schema before echoing it back.
14141413 def assistant_content_param(content)
14151414 content.map do |block|
1416 case block.type
1417 when :tool_use
1415 case block
1416 when Anthropic::Models::ToolUseBlock
14181417 input = parse_tool_input(block.input)
14191418 {type: "tool_use", id: block.id, name: block.name, input: input}
1420 when :text
1419 when Anthropic::Models::TextBlock
14211420 {type: "text", text: block.text}
1422 when :thinking
1421 when Anthropic::Models::ThinkingBlock
14231422 {type: "thinking", thinking: block.thinking, signature: block.signature}
1424 when :redacted_thinking then {type: "redacted_thinking", data: block.data}
1423 when Anthropic::Models::RedactedThinkingBlock then {type: "redacted_thinking", data: block.data}
14251424 else
14261425 block.to_h
14271426 end
from line 1468
14691468 for block in response.content:
14701469 if block.type != "tool_use":
14711470 continue
1472 if block.name == "report_findings":
1473 report = json.dumps(block.input, indent=2)
1474 output, is_error = "Findings recorded.", False
1475 elif block.name == "bash":
1476 output, is_error = handle_bash_block(block)
1477 else:
1478 output, is_error = f"unknown tool: {block.name}", True
1471 match block.name:
1472 case "report_findings":
1473 report = json.dumps(block.input, indent=2)
1474 output, is_error = "Findings recorded.", False
1475 case "bash":
1476 output, is_error = handle_bash_block(block)
1477 case _:
1478 output, is_error = f"unknown tool: {block.name}", True
14791479 tool_results.append(
14801480 {
14811481 "type": "tool_result",
from line 1535
15351535 }
15361536 let output: string;
15371537 let isError: boolean;
1538 if (block.name === "report_findings") {
1539 report = JSON.stringify(block.input, null, 2);
1540 output = "Findings recorded.";
1541 isError = false;
1542 } else if (block.name === "bash") {
1543 ({ output, isError } = await handleBashBlock(block));
1544 } else {
1545 output = `unknown tool: ${block.name}`;
1546 isError = true;
1538 switch (block.name) {
1539 case "report_findings":
1540 report = JSON.stringify(block.input, null, 2);
1541 output = "Findings recorded.";
1542 isError = false;
1543 break;
1544 case "bash":
1545 ({ output, isError } = await handleBashBlock(block));
1546 break;
1547 default:
1548 output = `unknown tool: ${block.name}`;
1549 isError = true;
15471550 }
15481551 toolResults.push({
15491552 type: "tool_result",
from line 1835
18321835 }
18331836 }
18341837 foreach ($jsonBuffers as $index => $buffer) {
1835 if ($buffer !== '' && $blocks[$index] instanceof ToolUseBlock) {
1838 if ($buffer !== '' && $blocks[$index] instanceof \Anthropic\Messages\ToolUseBlock) {
18361839 $decoded = json_decode($buffer, true);
18371840 $blocks[$index] = $blocks[$index]->withInput(is_array($decoded) ? $decoded : []);
18381841 }
from line 1872
18691872 if ($stopReason !== 'tool_use') {
18701873 $text = '';
18711874 foreach ($content as $block) {
1872 if ($block instanceof TextBlock) {
1875 if ($block instanceof \Anthropic\Messages\TextBlock) {
18731876 $text .= $block->text;
18741877 }
18751878 }
from line 1884
18811884 $report = null;
18821885 $toolResults = [];
18831886 foreach ($content as $block) {
1884 if (!$block instanceof ToolUseBlock) {
1887 if (!$block instanceof \Anthropic\Messages\ToolUseBlock) {
18851888 continue;
18861889 }
18871890 if ($block->name === 'report_findings') {
from line 3027
30243027 for block in response.content:
30253028 if block.type != "tool_use":
30263029 continue
3027 if block.name == "Workflow":
3028 output, is_error = run_workflow(self.model, block.input.get("subtasks", []))
3029 elif block.name == "bash":
3030 output, is_error = handle_bash_block(block)
3031 else:
3032 output, is_error = f"unknown tool: {block.name}", True
3030 match block.name:
3031 case "Workflow":
3032 output, is_error = run_workflow(self.model, block.input.get("subtasks", []))
3033 case "bash":
3034 output, is_error = handle_bash_block(block)
3035 case _:
3036 output, is_error = f"unknown tool: {block.name}", True
30333037 tool_results.append(
30343038 {
30353039 "type": "tool_result",
from line 3146
31423146 }
31433147 let output: string;
31443148 let isError: boolean;
3145 if (block.name === "Workflow") {
3146 const input = block.input as { subtasks?: unknown };
3147 ({ output, isError } = await runWorkflow(this.model, input.subtasks ?? []));
3148 } else if (block.name === "bash") {
3149 ({ output, isError } = await handleBashBlock(block));
3150 } else {
3151 output = `unknown tool: ${block.name}`;
3152 isError = true;
3149 switch (block.name) {
3150 case "Workflow": {
3151 const input = block.input as { subtasks?: unknown };
3152 ({ output, isError } = await runWorkflow(this.model, input.subtasks ?? []));
3153 break;
3154 }
3155 case "bash":
3156 ({ output, isError } = await handleBashBlock(block));
3157 break;
3158 default:
3159 output = `unknown tool: ${block.name}`;
3160 isError = true;
31533161 }
31543162 toolResults.push({
31553163 type: "tool_result",
from line 3650
36423650 if ($stopReason !== 'tool_use') {
36433651 $text = '';
36443652 foreach ($content as $block) {
3645 if ($block instanceof TextBlock) {
3653 if ($block instanceof \Anthropic\Messages\TextBlock) {
36463654 $text .= $block->text;
36473655 }
36483656 }
from line 3664
36563664 
36573665 $toolResults = [];
36583666 foreach ($content as $block) {
3659 if (!$block instanceof ToolUseBlock) {
3667 if (!$block instanceof \Anthropic\Messages\ToolUseBlock) {
36603668 continue;
36613669 }
36623670 if ($block->name === 'Workflow') {