The whole hunk
from line 82, old and new numbered
/
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