anthropic 0.0.0 → 0.1.0.pre.beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ignore +2 -0
- data/CHANGELOG.md +648 -6
- data/README.md +311 -70
- data/SECURITY.md +27 -0
- data/lib/anthropic/bedrock.rb +5 -0
- data/lib/anthropic/client.rb +102 -12
- data/lib/anthropic/errors.rb +192 -0
- data/lib/anthropic/file_part.rb +55 -0
- data/lib/anthropic/helpers/bedrock/client.rb +259 -0
- data/lib/anthropic/helpers/vertex/client.rb +218 -0
- data/lib/anthropic/internal/jsonl_stream.rb +26 -0
- data/lib/anthropic/internal/page.rb +99 -0
- data/lib/anthropic/internal/stream.rb +58 -0
- data/lib/anthropic/internal/transport/base_client.rb +558 -0
- data/lib/anthropic/internal/transport/pooled_net_requester.rb +209 -0
- data/lib/anthropic/internal/type/array_of.rb +162 -0
- data/lib/anthropic/internal/type/base_model.rb +481 -0
- data/lib/anthropic/internal/type/base_page.rb +55 -0
- data/lib/anthropic/internal/type/base_stream.rb +90 -0
- data/lib/anthropic/internal/type/boolean.rb +71 -0
- data/lib/anthropic/internal/type/converter.rb +292 -0
- data/lib/anthropic/internal/type/enum.rb +145 -0
- data/lib/anthropic/internal/type/file_input.rb +103 -0
- data/lib/anthropic/internal/type/hash_of.rb +182 -0
- data/lib/anthropic/internal/type/request_parameters.rb +42 -0
- data/lib/anthropic/internal/type/union.rb +252 -0
- data/lib/anthropic/internal/type/unknown.rb +75 -0
- data/lib/anthropic/internal/util.rb +907 -0
- data/lib/anthropic/internal.rb +20 -0
- data/lib/anthropic/models/anthropic_beta.rb +47 -0
- data/lib/anthropic/models/api_error_object.rb +21 -0
- data/lib/anthropic/models/authentication_error.rb +21 -0
- data/lib/anthropic/models/base64_image_source.rb +40 -0
- data/lib/anthropic/models/base64_pdf_source.rb +27 -0
- data/lib/anthropic/models/beta/beta_base64_image_source.rb +44 -0
- data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +73 -0
- data/lib/anthropic/models/beta/beta_base64_pdf_source.rb +31 -0
- data/lib/anthropic/models/beta/beta_cache_control_ephemeral.rb +19 -0
- data/lib/anthropic/models/beta/beta_citation_char_location.rb +49 -0
- data/lib/anthropic/models/beta/beta_citation_char_location_param.rb +49 -0
- data/lib/anthropic/models/beta/beta_citation_content_block_location.rb +49 -0
- data/lib/anthropic/models/beta/beta_citation_content_block_location_param.rb +49 -0
- data/lib/anthropic/models/beta/beta_citation_page_location.rb +49 -0
- data/lib/anthropic/models/beta/beta_citation_page_location_param.rb +49 -0
- data/lib/anthropic/models/beta/beta_citation_web_search_result_location_param.rb +43 -0
- data/lib/anthropic/models/beta/beta_citations_config_param.rb +19 -0
- data/lib/anthropic/models/beta/beta_citations_delta.rb +43 -0
- data/lib/anthropic/models/beta/beta_citations_web_search_result_location.rb +43 -0
- data/lib/anthropic/models/beta/beta_content_block.rb +30 -0
- data/lib/anthropic/models/beta/beta_content_block_param.rb +36 -0
- data/lib/anthropic/models/beta/beta_content_block_source.rb +41 -0
- data/lib/anthropic/models/beta/beta_content_block_source_content.rb +22 -0
- data/lib/anthropic/models/beta/beta_image_block_param.rb +48 -0
- data/lib/anthropic/models/beta/beta_input_json_delta.rb +25 -0
- data/lib/anthropic/models/beta/beta_message.rb +148 -0
- data/lib/anthropic/models/beta/beta_message_delta_usage.rb +52 -0
- data/lib/anthropic/models/beta/beta_message_param.rb +52 -0
- data/lib/anthropic/models/beta/beta_message_tokens_count.rb +25 -0
- data/lib/anthropic/models/beta/beta_metadata.rb +27 -0
- data/lib/anthropic/models/beta/beta_model_info.rb +51 -0
- data/lib/anthropic/models/beta/beta_plain_text_source.rb +31 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_delta.rb +28 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_delta_event.rb +31 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +53 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_stop_event.rb +25 -0
- data/lib/anthropic/models/beta/beta_raw_message_delta_event.rb +68 -0
- data/lib/anthropic/models/beta/beta_raw_message_start_event.rb +25 -0
- data/lib/anthropic/models/beta/beta_raw_message_stop_event.rb +19 -0
- data/lib/anthropic/models/beta/beta_raw_message_stream_event.rb +30 -0
- data/lib/anthropic/models/beta/beta_redacted_thinking_block.rb +25 -0
- data/lib/anthropic/models/beta/beta_redacted_thinking_block_param.rb +25 -0
- data/lib/anthropic/models/beta/beta_server_tool_usage.rb +20 -0
- data/lib/anthropic/models/beta/beta_server_tool_use_block.rb +37 -0
- data/lib/anthropic/models/beta/beta_server_tool_use_block_param.rb +48 -0
- data/lib/anthropic/models/beta/beta_signature_delta.rb +25 -0
- data/lib/anthropic/models/beta/beta_stop_reason.rb +23 -0
- data/lib/anthropic/models/beta/beta_text_block.rb +43 -0
- data/lib/anthropic/models/beta/beta_text_block_param.rb +43 -0
- data/lib/anthropic/models/beta/beta_text_citation.rb +26 -0
- data/lib/anthropic/models/beta/beta_text_citation_param.rb +26 -0
- data/lib/anthropic/models/beta/beta_text_delta.rb +25 -0
- data/lib/anthropic/models/beta/beta_thinking_block.rb +31 -0
- data/lib/anthropic/models/beta/beta_thinking_block_param.rb +31 -0
- data/lib/anthropic/models/beta/beta_thinking_config_disabled.rb +19 -0
- data/lib/anthropic/models/beta/beta_thinking_config_enabled.rb +38 -0
- data/lib/anthropic/models/beta/beta_thinking_config_param.rb +31 -0
- data/lib/anthropic/models/beta/beta_thinking_delta.rb +25 -0
- data/lib/anthropic/models/beta/beta_tool.rb +96 -0
- data/lib/anthropic/models/beta/beta_tool_bash_20241022.rb +40 -0
- data/lib/anthropic/models/beta/beta_tool_bash_20250124.rb +40 -0
- data/lib/anthropic/models/beta/beta_tool_choice.rb +32 -0
- data/lib/anthropic/models/beta/beta_tool_choice_any.rb +35 -0
- data/lib/anthropic/models/beta/beta_tool_choice_auto.rb +35 -0
- data/lib/anthropic/models/beta/beta_tool_choice_none.rb +21 -0
- data/lib/anthropic/models/beta/beta_tool_choice_tool.rb +43 -0
- data/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rb +64 -0
- data/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rb +64 -0
- data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +79 -0
- data/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rb +40 -0
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rb +40 -0
- data/lib/anthropic/models/beta/beta_tool_union.rb +32 -0
- data/lib/anthropic/models/beta/beta_tool_use_block.rb +37 -0
- data/lib/anthropic/models/beta/beta_tool_use_block_param.rb +48 -0
- data/lib/anthropic/models/beta/beta_url_image_source.rb +25 -0
- data/lib/anthropic/models/beta/beta_url_pdf_source.rb +25 -0
- data/lib/anthropic/models/beta/beta_usage.rb +52 -0
- data/lib/anthropic/models/beta/beta_web_search_result_block.rb +43 -0
- data/lib/anthropic/models/beta/beta_web_search_result_block_param.rb +43 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_20250305.rb +126 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_request_error.rb +39 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_block.rb +31 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_block_content.rb +24 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_block_param.rb +41 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_block_param_content.rb +26 -0
- data/lib/anthropic/models/beta/beta_web_search_tool_result_error.rb +39 -0
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +292 -0
- data/lib/anthropic/models/beta/message_create_params.rb +351 -0
- data/lib/anthropic/models/beta/messages/batch_cancel_params.rb +26 -0
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +424 -0
- data/lib/anthropic/models/beta/messages/batch_delete_params.rb +26 -0
- data/lib/anthropic/models/beta/messages/batch_list_params.rb +57 -0
- data/lib/anthropic/models/beta/messages/batch_results_params.rb +26 -0
- data/lib/anthropic/models/beta/messages/batch_retrieve_params.rb +26 -0
- data/lib/anthropic/models/beta/messages/beta_deleted_message_batch.rb +34 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch.rb +133 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_canceled_result.rb +19 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_errored_result.rb +25 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_expired_result.rb +19 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_individual_response.rb +43 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_request_counts.rb +63 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_result.rb +31 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_succeeded_result.rb +25 -0
- data/lib/anthropic/models/beta/model_list_params.rb +55 -0
- data/lib/anthropic/models/beta/model_retrieve_params.rb +24 -0
- data/lib/anthropic/models/beta_api_error.rb +21 -0
- data/lib/anthropic/models/beta_authentication_error.rb +21 -0
- data/lib/anthropic/models/beta_billing_error.rb +21 -0
- data/lib/anthropic/models/beta_error.rb +32 -0
- data/lib/anthropic/models/beta_error_response.rb +21 -0
- data/lib/anthropic/models/beta_gateway_timeout_error.rb +21 -0
- data/lib/anthropic/models/beta_invalid_request_error.rb +21 -0
- data/lib/anthropic/models/beta_not_found_error.rb +21 -0
- data/lib/anthropic/models/beta_overloaded_error.rb +21 -0
- data/lib/anthropic/models/beta_permission_error.rb +21 -0
- data/lib/anthropic/models/beta_rate_limit_error.rb +21 -0
- data/lib/anthropic/models/billing_error.rb +21 -0
- data/lib/anthropic/models/cache_control_ephemeral.rb +15 -0
- data/lib/anthropic/models/citation_char_location.rb +45 -0
- data/lib/anthropic/models/citation_char_location_param.rb +45 -0
- data/lib/anthropic/models/citation_content_block_location.rb +45 -0
- data/lib/anthropic/models/citation_content_block_location_param.rb +45 -0
- data/lib/anthropic/models/citation_page_location.rb +45 -0
- data/lib/anthropic/models/citation_page_location_param.rb +45 -0
- data/lib/anthropic/models/citation_web_search_result_location_param.rb +39 -0
- data/lib/anthropic/models/citations_config_param.rb +15 -0
- data/lib/anthropic/models/citations_delta.rb +39 -0
- data/lib/anthropic/models/citations_web_search_result_location.rb +39 -0
- data/lib/anthropic/models/completion.rb +66 -0
- data/lib/anthropic/models/completion_create_params.rb +133 -0
- data/lib/anthropic/models/content_block.rb +26 -0
- data/lib/anthropic/models/content_block_param.rb +32 -0
- data/lib/anthropic/models/content_block_source.rb +37 -0
- data/lib/anthropic/models/content_block_source_content.rb +18 -0
- data/lib/anthropic/models/document_block_param.rb +69 -0
- data/lib/anthropic/models/error_object.rb +32 -0
- data/lib/anthropic/models/error_response.rb +21 -0
- data/lib/anthropic/models/gateway_timeout_error.rb +21 -0
- data/lib/anthropic/models/image_block_param.rb +44 -0
- data/lib/anthropic/models/input_json_delta.rb +21 -0
- data/lib/anthropic/models/invalid_request_error.rb +21 -0
- data/lib/anthropic/models/message.rb +144 -0
- data/lib/anthropic/models/message_count_tokens_params.rb +254 -0
- data/lib/anthropic/models/message_count_tokens_tool.rb +20 -0
- data/lib/anthropic/models/message_create_params.rb +339 -0
- data/lib/anthropic/models/message_delta_usage.rb +48 -0
- data/lib/anthropic/models/message_param.rb +49 -0
- data/lib/anthropic/models/message_tokens_count.rb +21 -0
- data/lib/anthropic/models/messages/batch_cancel_params.rb +16 -0
- data/lib/anthropic/models/messages/batch_create_params.rb +406 -0
- data/lib/anthropic/models/messages/batch_delete_params.rb +16 -0
- data/lib/anthropic/models/messages/batch_list_params.rb +47 -0
- data/lib/anthropic/models/messages/batch_results_params.rb +16 -0
- data/lib/anthropic/models/messages/batch_retrieve_params.rb +16 -0
- data/lib/anthropic/models/messages/deleted_message_batch.rb +32 -0
- data/lib/anthropic/models/messages/message_batch.rb +130 -0
- data/lib/anthropic/models/messages/message_batch_canceled_result.rb +19 -0
- data/lib/anthropic/models/messages/message_batch_errored_result.rb +25 -0
- data/lib/anthropic/models/messages/message_batch_expired_result.rb +19 -0
- data/lib/anthropic/models/messages/message_batch_individual_response.rb +42 -0
- data/lib/anthropic/models/messages/message_batch_request_counts.rb +63 -0
- data/lib/anthropic/models/messages/message_batch_result.rb +31 -0
- data/lib/anthropic/models/messages/message_batch_succeeded_result.rb +25 -0
- data/lib/anthropic/models/metadata.rb +23 -0
- data/lib/anthropic/models/model.rb +96 -0
- data/lib/anthropic/models/model_info.rb +47 -0
- data/lib/anthropic/models/model_list_params.rb +53 -0
- data/lib/anthropic/models/model_retrieve_params.rb +22 -0
- data/lib/anthropic/models/not_found_error.rb +21 -0
- data/lib/anthropic/models/overloaded_error.rb +21 -0
- data/lib/anthropic/models/permission_error.rb +21 -0
- data/lib/anthropic/models/plain_text_source.rb +27 -0
- data/lib/anthropic/models/rate_limit_error.rb +21 -0
- data/lib/anthropic/models/raw_content_block_delta.rb +24 -0
- data/lib/anthropic/models/raw_content_block_delta_event.rb +27 -0
- data/lib/anthropic/models/raw_content_block_start_event.rb +49 -0
- data/lib/anthropic/models/raw_content_block_stop_event.rb +21 -0
- data/lib/anthropic/models/raw_message_delta_event.rb +64 -0
- data/lib/anthropic/models/raw_message_start_event.rb +21 -0
- data/lib/anthropic/models/raw_message_stop_event.rb +15 -0
- data/lib/anthropic/models/raw_message_stream_event.rb +26 -0
- data/lib/anthropic/models/redacted_thinking_block.rb +21 -0
- data/lib/anthropic/models/redacted_thinking_block_param.rb +21 -0
- data/lib/anthropic/models/server_tool_usage.rb +16 -0
- data/lib/anthropic/models/server_tool_use_block.rb +33 -0
- data/lib/anthropic/models/server_tool_use_block_param.rb +44 -0
- data/lib/anthropic/models/signature_delta.rb +21 -0
- data/lib/anthropic/models/stop_reason.rb +19 -0
- data/lib/anthropic/models/text_block.rb +41 -0
- data/lib/anthropic/models/text_block_param.rb +39 -0
- data/lib/anthropic/models/text_citation.rb +22 -0
- data/lib/anthropic/models/text_citation_param.rb +22 -0
- data/lib/anthropic/models/text_delta.rb +21 -0
- data/lib/anthropic/models/thinking_block.rb +27 -0
- data/lib/anthropic/models/thinking_block_param.rb +27 -0
- data/lib/anthropic/models/thinking_config_disabled.rb +15 -0
- data/lib/anthropic/models/thinking_config_enabled.rb +34 -0
- data/lib/anthropic/models/thinking_config_param.rb +27 -0
- data/lib/anthropic/models/thinking_delta.rb +21 -0
- data/lib/anthropic/models/tool.rb +92 -0
- data/lib/anthropic/models/tool_bash_20250124.rb +36 -0
- data/lib/anthropic/models/tool_choice.rb +28 -0
- data/lib/anthropic/models/tool_choice_any.rb +31 -0
- data/lib/anthropic/models/tool_choice_auto.rb +31 -0
- data/lib/anthropic/models/tool_choice_none.rb +17 -0
- data/lib/anthropic/models/tool_choice_tool.rb +39 -0
- data/lib/anthropic/models/tool_result_block_param.rb +73 -0
- data/lib/anthropic/models/tool_text_editor_20250124.rb +36 -0
- data/lib/anthropic/models/tool_union.rb +20 -0
- data/lib/anthropic/models/tool_use_block.rb +33 -0
- data/lib/anthropic/models/tool_use_block_param.rb +44 -0
- data/lib/anthropic/models/url_image_source.rb +21 -0
- data/lib/anthropic/models/url_pdf_source.rb +21 -0
- data/lib/anthropic/models/usage.rb +48 -0
- data/lib/anthropic/models/web_search_result_block.rb +39 -0
- data/lib/anthropic/models/web_search_result_block_param.rb +39 -0
- data/lib/anthropic/models/web_search_tool_20250305.rb +122 -0
- data/lib/anthropic/models/web_search_tool_request_error.rb +35 -0
- data/lib/anthropic/models/web_search_tool_result_block.rb +27 -0
- data/lib/anthropic/models/web_search_tool_result_block_content.rb +19 -0
- data/lib/anthropic/models/web_search_tool_result_block_param.rb +37 -0
- data/lib/anthropic/models/web_search_tool_result_block_param_content.rb +20 -0
- data/lib/anthropic/models/web_search_tool_result_error.rb +35 -0
- data/lib/anthropic/models.rb +261 -0
- data/lib/anthropic/request_options.rb +77 -0
- data/lib/anthropic/resources/beta/messages/batches.rb +218 -0
- data/lib/anthropic/resources/beta/messages.rb +200 -0
- data/lib/anthropic/resources/beta/models.rb +80 -0
- data/lib/anthropic/resources/beta.rb +22 -0
- data/lib/anthropic/resources/completions.rb +132 -0
- data/lib/anthropic/resources/messages/batches.rb +193 -0
- data/lib/anthropic/resources/messages.rb +184 -0
- data/lib/anthropic/resources/models.rb +78 -0
- data/lib/anthropic/version.rb +3 -1
- data/lib/anthropic/vertex.rb +5 -0
- data/lib/anthropic.rb +286 -47
- data/manifest.yaml +15 -0
- data/rbi/anthropic/bedrock.rbi +5 -0
- data/rbi/anthropic/client.rbi +74 -0
- data/rbi/anthropic/errors.rbi +162 -0
- data/rbi/anthropic/file_part.rbi +37 -0
- data/rbi/anthropic/helpers/bedrock/client.rbi +82 -0
- data/rbi/anthropic/helpers/vertex/client.rbi +58 -0
- data/rbi/anthropic/internal/jsonl_stream.rbi +17 -0
- data/rbi/anthropic/internal/page.rbi +28 -0
- data/rbi/anthropic/internal/stream.rbi +20 -0
- data/rbi/anthropic/internal/transport/base_client.rbi +310 -0
- data/rbi/anthropic/internal/transport/pooled_net_requester.rbi +79 -0
- data/rbi/anthropic/internal/type/array_of.rbi +104 -0
- data/rbi/anthropic/internal/type/base_model.rbi +304 -0
- data/rbi/anthropic/internal/type/base_page.rbi +42 -0
- data/rbi/anthropic/internal/type/base_stream.rbi +68 -0
- data/rbi/anthropic/internal/type/boolean.rbi +56 -0
- data/rbi/anthropic/internal/type/converter.rbi +162 -0
- data/rbi/anthropic/internal/type/enum.rbi +82 -0
- data/rbi/anthropic/internal/type/file_input.rbi +59 -0
- data/rbi/anthropic/internal/type/hash_of.rbi +104 -0
- data/rbi/anthropic/internal/type/request_parameters.rbi +29 -0
- data/rbi/anthropic/internal/type/union.rbi +116 -0
- data/rbi/anthropic/internal/type/unknown.rbi +56 -0
- data/rbi/anthropic/internal/util.rbi +485 -0
- data/rbi/anthropic/internal.rbi +18 -0
- data/rbi/anthropic/models/anthropic_beta.rbi +54 -0
- data/rbi/anthropic/models/api_error_object.rbi +26 -0
- data/rbi/anthropic/models/authentication_error.rbi +26 -0
- data/rbi/anthropic/models/base64_image_source.rbi +82 -0
- data/rbi/anthropic/models/base64_pdf_source.rbi +35 -0
- data/rbi/anthropic/models/beta/beta_base64_image_source.rbi +95 -0
- data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +134 -0
- data/rbi/anthropic/models/beta/beta_base64_pdf_source.rbi +42 -0
- data/rbi/anthropic/models/beta/beta_cache_control_ephemeral.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_citation_char_location.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_citation_char_location_param.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_citation_content_block_location.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_citation_content_block_location_param.rbi +73 -0
- data/rbi/anthropic/models/beta/beta_citation_page_location.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_citation_page_location_param.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_citation_web_search_result_location_param.rbi +67 -0
- data/rbi/anthropic/models/beta/beta_citations_config_param.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_citations_delta.rbi +73 -0
- data/rbi/anthropic/models/beta/beta_citations_web_search_result_location.rbi +67 -0
- data/rbi/anthropic/models/beta/beta_content_block.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_content_block_param.rbi +36 -0
- data/rbi/anthropic/models/beta/beta_content_block_source.rbi +80 -0
- data/rbi/anthropic/models/beta/beta_content_block_source_content.rbi +29 -0
- data/rbi/anthropic/models/beta/beta_image_block_param.rbi +101 -0
- data/rbi/anthropic/models/beta/beta_input_json_delta.rbi +35 -0
- data/rbi/anthropic/models/beta/beta_message.rbi +245 -0
- data/rbi/anthropic/models/beta/beta_message_delta_usage.rbi +85 -0
- data/rbi/anthropic/models/beta/beta_message_param.rbi +99 -0
- data/rbi/anthropic/models/beta/beta_message_tokens_count.rbi +36 -0
- data/rbi/anthropic/models/beta/beta_metadata.rbi +39 -0
- data/rbi/anthropic/models/beta/beta_model_info.rbi +66 -0
- data/rbi/anthropic/models/beta/beta_plain_text_source.rbi +42 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_delta.rbi +32 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_delta_event.rbi +57 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +89 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_stop_event.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_raw_message_delta_event.rbi +135 -0
- data/rbi/anthropic/models/beta/beta_raw_message_start_event.rbi +45 -0
- data/rbi/anthropic/models/beta/beta_raw_message_stop_event.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_raw_message_stream_event.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_redacted_thinking_block.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_redacted_thinking_block_param.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_server_tool_usage.rbi +34 -0
- data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +50 -0
- data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +78 -0
- data/rbi/anthropic/models/beta/beta_signature_delta.rbi +35 -0
- data/rbi/anthropic/models/beta/beta_stop_reason.rbi +37 -0
- data/rbi/anthropic/models/beta/beta_text_block.rbi +78 -0
- data/rbi/anthropic/models/beta/beta_text_block_param.rbi +105 -0
- data/rbi/anthropic/models/beta/beta_text_citation.rbi +31 -0
- data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +31 -0
- data/rbi/anthropic/models/beta/beta_text_delta.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_thinking_block.rbi +44 -0
- data/rbi/anthropic/models/beta/beta_thinking_block_param.rbi +44 -0
- data/rbi/anthropic/models/beta/beta_thinking_config_disabled.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_thinking_config_enabled.rbi +56 -0
- data/rbi/anthropic/models/beta/beta_thinking_config_param.rbi +38 -0
- data/rbi/anthropic/models/beta/beta_thinking_delta.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_tool.rbi +165 -0
- data/rbi/anthropic/models/beta/beta_tool_bash_20241022.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_tool_bash_20250124.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_tool_choice.rbi +31 -0
- data/rbi/anthropic/models/beta/beta_tool_choice_any.rbi +56 -0
- data/rbi/anthropic/models/beta/beta_tool_choice_auto.rbi +56 -0
- data/rbi/anthropic/models/beta/beta_tool_choice_none.rbi +31 -0
- data/rbi/anthropic/models/beta/beta_tool_choice_tool.rbi +68 -0
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20241022.rbi +96 -0
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20250124.rbi +96 -0
- data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +152 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20241022.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250124.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_tool_union.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_tool_use_block.rbi +50 -0
- data/rbi/anthropic/models/beta/beta_tool_use_block_param.rbi +78 -0
- data/rbi/anthropic/models/beta/beta_url_image_source.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_url_pdf_source.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_usage.rbi +82 -0
- data/rbi/anthropic/models/beta/beta_web_search_result_block.rbi +66 -0
- data/rbi/anthropic/models/beta/beta_web_search_result_block_param.rbi +66 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_20250305.rbi +201 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_request_error.rbi +100 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_block.rbi +59 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_block_content.rbi +40 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_block_param.rbi +89 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_block_param_content.rbi +40 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_error.rbi +100 -0
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +649 -0
- data/rbi/anthropic/models/beta/message_create_params.rbi +748 -0
- data/rbi/anthropic/models/beta/messages/batch_cancel_params.rbi +65 -0
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +897 -0
- data/rbi/anthropic/models/beta/messages/batch_delete_params.rbi +65 -0
- data/rbi/anthropic/models/beta/messages/batch_list_params.rbi +106 -0
- data/rbi/anthropic/models/beta/messages/batch_results_params.rbi +65 -0
- data/rbi/anthropic/models/beta/messages/batch_retrieve_params.rbi +65 -0
- data/rbi/anthropic/models/beta/messages/beta_deleted_message_batch.rbi +44 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch.rbi +214 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_canceled_result.rbi +30 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_errored_result.rbi +45 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_expired_result.rbi +30 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_individual_response.rbi +77 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_request_counts.rbi +92 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_result.rbi +38 -0
- data/rbi/anthropic/models/beta/messages/beta_message_batch_succeeded_result.rbi +45 -0
- data/rbi/anthropic/models/beta/model_list_params.rbi +103 -0
- data/rbi/anthropic/models/beta/model_retrieve_params.rbi +62 -0
- data/rbi/anthropic/models/beta_api_error.rbi +26 -0
- data/rbi/anthropic/models/beta_authentication_error.rbi +29 -0
- data/rbi/anthropic/models/beta_billing_error.rbi +26 -0
- data/rbi/anthropic/models/beta_error.rbi +28 -0
- data/rbi/anthropic/models/beta_error_response.rbi +46 -0
- data/rbi/anthropic/models/beta_gateway_timeout_error.rbi +29 -0
- data/rbi/anthropic/models/beta_invalid_request_error.rbi +29 -0
- data/rbi/anthropic/models/beta_not_found_error.rbi +26 -0
- data/rbi/anthropic/models/beta_overloaded_error.rbi +26 -0
- data/rbi/anthropic/models/beta_permission_error.rbi +26 -0
- data/rbi/anthropic/models/beta_rate_limit_error.rbi +26 -0
- data/rbi/anthropic/models/billing_error.rbi +26 -0
- data/rbi/anthropic/models/cache_control_ephemeral.rbi +23 -0
- data/rbi/anthropic/models/citation_char_location.rbi +65 -0
- data/rbi/anthropic/models/citation_char_location_param.rbi +68 -0
- data/rbi/anthropic/models/citation_content_block_location.rbi +68 -0
- data/rbi/anthropic/models/citation_content_block_location_param.rbi +68 -0
- data/rbi/anthropic/models/citation_page_location.rbi +65 -0
- data/rbi/anthropic/models/citation_page_location_param.rbi +68 -0
- data/rbi/anthropic/models/citation_web_search_result_location_param.rbi +62 -0
- data/rbi/anthropic/models/citations_config_param.rbi +26 -0
- data/rbi/anthropic/models/citations_delta.rbi +66 -0
- data/rbi/anthropic/models/citations_web_search_result_location.rbi +62 -0
- data/rbi/anthropic/models/completion.rbi +93 -0
- data/rbi/anthropic/models/completion_create_params.rbi +217 -0
- data/rbi/anthropic/models/content_block.rbi +25 -0
- data/rbi/anthropic/models/content_block_param.rbi +28 -0
- data/rbi/anthropic/models/content_block_source.rbi +66 -0
- data/rbi/anthropic/models/content_block_source_content.rbi +22 -0
- data/rbi/anthropic/models/document_block_param.rbi +120 -0
- data/rbi/anthropic/models/error_object.rbi +28 -0
- data/rbi/anthropic/models/error_response.rbi +46 -0
- data/rbi/anthropic/models/gateway_timeout_error.rbi +26 -0
- data/rbi/anthropic/models/image_block_param.rbi +80 -0
- data/rbi/anthropic/models/input_json_delta.rbi +28 -0
- data/rbi/anthropic/models/invalid_request_error.rbi +26 -0
- data/rbi/anthropic/models/message.rbi +236 -0
- data/rbi/anthropic/models/message_count_tokens_params.rbi +571 -0
- data/rbi/anthropic/models/message_count_tokens_tool.rbi +25 -0
- data/rbi/anthropic/models/message_create_params.rbi +697 -0
- data/rbi/anthropic/models/message_delta_usage.rbi +76 -0
- data/rbi/anthropic/models/message_param.rbi +81 -0
- data/rbi/anthropic/models/message_tokens_count.rbi +29 -0
- data/rbi/anthropic/models/messages/batch_cancel_params.rbi +32 -0
- data/rbi/anthropic/models/messages/batch_create_params.rbi +843 -0
- data/rbi/anthropic/models/messages/batch_delete_params.rbi +32 -0
- data/rbi/anthropic/models/messages/batch_list_params.rbi +81 -0
- data/rbi/anthropic/models/messages/batch_results_params.rbi +32 -0
- data/rbi/anthropic/models/messages/batch_retrieve_params.rbi +32 -0
- data/rbi/anthropic/models/messages/deleted_message_batch.rbi +42 -0
- data/rbi/anthropic/models/messages/message_batch.rbi +208 -0
- data/rbi/anthropic/models/messages/message_batch_canceled_result.rbi +30 -0
- data/rbi/anthropic/models/messages/message_batch_errored_result.rbi +42 -0
- data/rbi/anthropic/models/messages/message_batch_expired_result.rbi +30 -0
- data/rbi/anthropic/models/messages/message_batch_individual_response.rbi +74 -0
- data/rbi/anthropic/models/messages/message_batch_request_counts.rbi +92 -0
- data/rbi/anthropic/models/messages/message_batch_result.rbi +36 -0
- data/rbi/anthropic/models/messages/message_batch_succeeded_result.rbi +40 -0
- data/rbi/anthropic/models/metadata.rbi +35 -0
- data/rbi/anthropic/models/model.rbi +68 -0
- data/rbi/anthropic/models/model_info.rbi +62 -0
- data/rbi/anthropic/models/model_list_params.rbi +95 -0
- data/rbi/anthropic/models/model_retrieve_params.rbi +54 -0
- data/rbi/anthropic/models/not_found_error.rbi +26 -0
- data/rbi/anthropic/models/overloaded_error.rbi +26 -0
- data/rbi/anthropic/models/permission_error.rbi +26 -0
- data/rbi/anthropic/models/plain_text_source.rbi +35 -0
- data/rbi/anthropic/models/rate_limit_error.rbi +26 -0
- data/rbi/anthropic/models/raw_content_block_delta.rbi +26 -0
- data/rbi/anthropic/models/raw_content_block_delta_event.rbi +53 -0
- data/rbi/anthropic/models/raw_content_block_start_event.rbi +83 -0
- data/rbi/anthropic/models/raw_content_block_stop_event.rbi +29 -0
- data/rbi/anthropic/models/raw_message_delta_event.rbi +119 -0
- data/rbi/anthropic/models/raw_message_start_event.rbi +33 -0
- data/rbi/anthropic/models/raw_message_stop_event.rbi +23 -0
- data/rbi/anthropic/models/raw_message_stream_event.rbi +27 -0
- data/rbi/anthropic/models/redacted_thinking_block.rbi +26 -0
- data/rbi/anthropic/models/redacted_thinking_block_param.rbi +29 -0
- data/rbi/anthropic/models/server_tool_usage.rbi +27 -0
- data/rbi/anthropic/models/server_tool_use_block.rbi +43 -0
- data/rbi/anthropic/models/server_tool_use_block_param.rbi +71 -0
- data/rbi/anthropic/models/signature_delta.rbi +26 -0
- data/rbi/anthropic/models/stop_reason.rbi +23 -0
- data/rbi/anthropic/models/text_block.rbi +67 -0
- data/rbi/anthropic/models/text_block_param.rbi +95 -0
- data/rbi/anthropic/models/text_citation.rbi +23 -0
- data/rbi/anthropic/models/text_citation_param.rbi +23 -0
- data/rbi/anthropic/models/text_delta.rbi +26 -0
- data/rbi/anthropic/models/thinking_block.rbi +35 -0
- data/rbi/anthropic/models/thinking_block_param.rbi +35 -0
- data/rbi/anthropic/models/thinking_config_disabled.rbi +23 -0
- data/rbi/anthropic/models/thinking_config_enabled.rbi +49 -0
- data/rbi/anthropic/models/thinking_config_param.rbi +32 -0
- data/rbi/anthropic/models/thinking_delta.rbi +26 -0
- data/rbi/anthropic/models/tool.rbi +142 -0
- data/rbi/anthropic/models/tool_bash_20250124.rbi +62 -0
- data/rbi/anthropic/models/tool_choice.rbi +25 -0
- data/rbi/anthropic/models/tool_choice_any.rbi +49 -0
- data/rbi/anthropic/models/tool_choice_auto.rbi +49 -0
- data/rbi/anthropic/models/tool_choice_none.rbi +24 -0
- data/rbi/anthropic/models/tool_choice_tool.rbi +57 -0
- data/rbi/anthropic/models/tool_result_block_param.rbi +127 -0
- data/rbi/anthropic/models/tool_text_editor_20250124.rbi +62 -0
- data/rbi/anthropic/models/tool_union.rbi +23 -0
- data/rbi/anthropic/models/tool_use_block.rbi +43 -0
- data/rbi/anthropic/models/tool_use_block_param.rbi +68 -0
- data/rbi/anthropic/models/url_image_source.rbi +26 -0
- data/rbi/anthropic/models/url_pdf_source.rbi +26 -0
- data/rbi/anthropic/models/usage.rbi +74 -0
- data/rbi/anthropic/models/web_search_result_block.rbi +59 -0
- data/rbi/anthropic/models/web_search_result_block_param.rbi +62 -0
- data/rbi/anthropic/models/web_search_tool_20250305.rbi +181 -0
- data/rbi/anthropic/models/web_search_tool_request_error.rbi +88 -0
- data/rbi/anthropic/models/web_search_tool_result_block.rbi +50 -0
- data/rbi/anthropic/models/web_search_tool_result_block_content.rbi +31 -0
- data/rbi/anthropic/models/web_search_tool_result_block_param.rbi +80 -0
- data/rbi/anthropic/models/web_search_tool_result_block_param_content.rbi +33 -0
- data/rbi/anthropic/models/web_search_tool_result_error.rbi +90 -0
- data/rbi/anthropic/models.rbi +229 -0
- data/rbi/anthropic/request_options.rbi +59 -0
- data/rbi/anthropic/resources/beta/messages/batches.rbi +186 -0
- data/rbi/anthropic/resources/beta/messages.rbi +830 -0
- data/rbi/anthropic/resources/beta/models.rbi +64 -0
- data/rbi/anthropic/resources/beta.rbi +18 -0
- data/rbi/anthropic/resources/completions.rbi +199 -0
- data/rbi/anthropic/resources/messages/batches.rbi +156 -0
- data/rbi/anthropic/resources/messages.rbi +806 -0
- data/rbi/anthropic/resources/models.rbi +62 -0
- data/rbi/anthropic/version.rbi +5 -0
- data/rbi/anthropic/vertex.rbi +5 -0
- data/sig/anthropic/bedrock.rbs +3 -0
- data/sig/anthropic/client.rbs +39 -0
- data/sig/anthropic/errors.rbs +101 -0
- data/sig/anthropic/file_part.rbs +21 -0
- data/sig/anthropic/helpers/bedrock/client.rbs +43 -0
- data/sig/anthropic/helpers/vertex/client.rbs +36 -0
- data/sig/anthropic/internal/jsonl_stream.rbs +9 -0
- data/sig/anthropic/internal/page.rbs +17 -0
- data/sig/anthropic/internal/stream.rbs +9 -0
- data/sig/anthropic/internal/transport/base_client.rbs +131 -0
- data/sig/anthropic/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/anthropic/internal/type/array_of.rbs +48 -0
- data/sig/anthropic/internal/type/base_model.rbs +102 -0
- data/sig/anthropic/internal/type/base_page.rbs +24 -0
- data/sig/anthropic/internal/type/base_stream.rbs +33 -0
- data/sig/anthropic/internal/type/boolean.rbs +26 -0
- data/sig/anthropic/internal/type/converter.rbs +56 -0
- data/sig/anthropic/internal/type/enum.rbs +32 -0
- data/sig/anthropic/internal/type/file_input.rbs +25 -0
- data/sig/anthropic/internal/type/hash_of.rbs +48 -0
- data/sig/anthropic/internal/type/request_parameters.rbs +19 -0
- data/sig/anthropic/internal/type/union.rbs +52 -0
- data/sig/anthropic/internal/type/unknown.rbs +26 -0
- data/sig/anthropic/internal/util.rbs +185 -0
- data/sig/anthropic/internal.rbs +9 -0
- data/sig/anthropic/models/anthropic_beta.rbs +29 -0
- data/sig/anthropic/models/api_error_object.rbs +13 -0
- data/sig/anthropic/models/authentication_error.rbs +13 -0
- data/sig/anthropic/models/base64_image_source.rbs +38 -0
- data/sig/anthropic/models/base64_pdf_source.rbs +20 -0
- data/sig/anthropic/models/beta/beta_base64_image_source.rbs +42 -0
- data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +56 -0
- data/sig/anthropic/models/beta/beta_base64_pdf_source.rbs +24 -0
- data/sig/anthropic/models/beta/beta_cache_control_ephemeral.rbs +15 -0
- data/sig/anthropic/models/beta/beta_citation_char_location.rbs +40 -0
- data/sig/anthropic/models/beta/beta_citation_char_location_param.rbs +40 -0
- data/sig/anthropic/models/beta/beta_citation_content_block_location.rbs +40 -0
- data/sig/anthropic/models/beta/beta_citation_content_block_location_param.rbs +40 -0
- data/sig/anthropic/models/beta/beta_citation_page_location.rbs +40 -0
- data/sig/anthropic/models/beta/beta_citation_page_location_param.rbs +40 -0
- data/sig/anthropic/models/beta/beta_citation_web_search_result_location_param.rbs +36 -0
- data/sig/anthropic/models/beta/beta_citations_config_param.rbs +17 -0
- data/sig/anthropic/models/beta/beta_citations_delta.rbs +36 -0
- data/sig/anthropic/models/beta/beta_citations_web_search_result_location.rbs +36 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +21 -0
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +24 -0
- data/sig/anthropic/models/beta/beta_content_block_source.rbs +36 -0
- data/sig/anthropic/models/beta/beta_content_block_source_content.rbs +17 -0
- data/sig/anthropic/models/beta/beta_image_block_param.rbs +38 -0
- data/sig/anthropic/models/beta/beta_input_json_delta.rbs +18 -0
- data/sig/anthropic/models/beta/beta_message.rbs +48 -0
- data/sig/anthropic/models/beta/beta_message_delta_usage.rbs +36 -0
- data/sig/anthropic/models/beta/beta_message_param.rbs +46 -0
- data/sig/anthropic/models/beta/beta_message_tokens_count.rbs +15 -0
- data/sig/anthropic/models/beta/beta_metadata.rbs +15 -0
- data/sig/anthropic/models/beta/beta_model_info.rbs +27 -0
- data/sig/anthropic/models/beta/beta_plain_text_source.rbs +24 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_delta.rbs +20 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_delta_event.rbs +28 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +42 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_stop_event.rbs +18 -0
- data/sig/anthropic/models/beta/beta_raw_message_delta_event.rbs +45 -0
- data/sig/anthropic/models/beta/beta_raw_message_start_event.rbs +21 -0
- data/sig/anthropic/models/beta/beta_raw_message_stop_event.rbs +15 -0
- data/sig/anthropic/models/beta/beta_raw_message_stream_event.rbs +21 -0
- data/sig/anthropic/models/beta/beta_redacted_thinking_block.rbs +18 -0
- data/sig/anthropic/models/beta/beta_redacted_thinking_block_param.rbs +18 -0
- data/sig/anthropic/models/beta/beta_server_tool_usage.rbs +15 -0
- data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +27 -0
- data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +36 -0
- data/sig/anthropic/models/beta/beta_signature_delta.rbs +17 -0
- data/sig/anthropic/models/beta/beta_stop_reason.rbs +28 -0
- data/sig/anthropic/models/beta/beta_text_block.rbs +28 -0
- data/sig/anthropic/models/beta/beta_text_block_param.rbs +32 -0
- data/sig/anthropic/models/beta/beta_text_citation.rbs +19 -0
- data/sig/anthropic/models/beta/beta_text_citation_param.rbs +19 -0
- data/sig/anthropic/models/beta/beta_text_delta.rbs +17 -0
- data/sig/anthropic/models/beta/beta_thinking_block.rbs +24 -0
- data/sig/anthropic/models/beta/beta_thinking_block_param.rbs +24 -0
- data/sig/anthropic/models/beta/beta_thinking_config_disabled.rbs +15 -0
- data/sig/anthropic/models/beta/beta_thinking_config_enabled.rbs +18 -0
- data/sig/anthropic/models/beta/beta_thinking_config_param.rbs +17 -0
- data/sig/anthropic/models/beta/beta_thinking_delta.rbs +17 -0
- data/sig/anthropic/models/beta/beta_tool.rbs +58 -0
- data/sig/anthropic/models/beta/beta_tool_bash_20241022.rbs +28 -0
- data/sig/anthropic/models/beta/beta_tool_bash_20250124.rbs +28 -0
- data/sig/anthropic/models/beta/beta_tool_choice.rbs +19 -0
- data/sig/anthropic/models/beta/beta_tool_choice_any.rbs +20 -0
- data/sig/anthropic/models/beta/beta_tool_choice_auto.rbs +20 -0
- data/sig/anthropic/models/beta/beta_tool_choice_none.rbs +15 -0
- data/sig/anthropic/models/beta/beta_tool_choice_tool.rbs +26 -0
- data/sig/anthropic/models/beta/beta_tool_computer_use_20241022.rbs +40 -0
- data/sig/anthropic/models/beta/beta_tool_computer_use_20250124.rbs +40 -0
- data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +64 -0
- data/sig/anthropic/models/beta/beta_tool_text_editor_20241022.rbs +28 -0
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250124.rbs +28 -0
- data/sig/anthropic/models/beta/beta_tool_union.rbs +23 -0
- data/sig/anthropic/models/beta/beta_tool_use_block.rbs +27 -0
- data/sig/anthropic/models/beta/beta_tool_use_block_param.rbs +36 -0
- data/sig/anthropic/models/beta/beta_url_image_source.rbs +17 -0
- data/sig/anthropic/models/beta/beta_url_pdf_source.rbs +17 -0
- data/sig/anthropic/models/beta/beta_usage.rbs +36 -0
- data/sig/anthropic/models/beta/beta_web_search_result_block.rbs +36 -0
- data/sig/anthropic/models/beta/beta_web_search_result_block_param.rbs +36 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_20250305.rbs +73 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_request_error.rbs +43 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_block.rbs +28 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_block_content.rbs +19 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_block_param.rbs +32 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_block_param_content.rbs +19 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_error.rbs +43 -0
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +93 -0
- data/sig/anthropic/models/beta/message_create_params.rbs +113 -0
- data/sig/anthropic/models/beta/messages/batch_cancel_params.rbs +27 -0
- data/sig/anthropic/models/beta/messages/batch_create_params.rbs +152 -0
- data/sig/anthropic/models/beta/messages/batch_delete_params.rbs +27 -0
- data/sig/anthropic/models/beta/messages/batch_list_params.rbs +47 -0
- data/sig/anthropic/models/beta/messages/batch_results_params.rbs +27 -0
- data/sig/anthropic/models/beta/messages/batch_retrieve_params.rbs +27 -0
- data/sig/anthropic/models/beta/messages/beta_deleted_message_batch.rbs +18 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch.rbs +68 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_canceled_result.rbs +15 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_errored_result.rbs +21 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_expired_result.rbs +15 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_individual_response.rbs +24 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_request_counts.rbs +36 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_result.rbs +19 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_succeeded_result.rbs +21 -0
- data/sig/anthropic/models/beta/model_list_params.rbs +45 -0
- data/sig/anthropic/models/beta/model_retrieve_params.rbs +25 -0
- data/sig/anthropic/models/beta_api_error.rbs +13 -0
- data/sig/anthropic/models/beta_authentication_error.rbs +14 -0
- data/sig/anthropic/models/beta_billing_error.rbs +13 -0
- data/sig/anthropic/models/beta_error.rbs +20 -0
- data/sig/anthropic/models/beta_error_response.rbs +17 -0
- data/sig/anthropic/models/beta_gateway_timeout_error.rbs +13 -0
- data/sig/anthropic/models/beta_invalid_request_error.rbs +14 -0
- data/sig/anthropic/models/beta_not_found_error.rbs +13 -0
- data/sig/anthropic/models/beta_overloaded_error.rbs +13 -0
- data/sig/anthropic/models/beta_permission_error.rbs +13 -0
- data/sig/anthropic/models/beta_rate_limit_error.rbs +13 -0
- data/sig/anthropic/models/billing_error.rbs +13 -0
- data/sig/anthropic/models/cache_control_ephemeral.rbs +11 -0
- data/sig/anthropic/models/citation_char_location.rbs +36 -0
- data/sig/anthropic/models/citation_char_location_param.rbs +36 -0
- data/sig/anthropic/models/citation_content_block_location.rbs +36 -0
- data/sig/anthropic/models/citation_content_block_location_param.rbs +36 -0
- data/sig/anthropic/models/citation_page_location.rbs +36 -0
- data/sig/anthropic/models/citation_page_location_param.rbs +36 -0
- data/sig/anthropic/models/citation_web_search_result_location_param.rbs +32 -0
- data/sig/anthropic/models/citations_config_param.rbs +13 -0
- data/sig/anthropic/models/citations_delta.rbs +29 -0
- data/sig/anthropic/models/citations_web_search_result_location.rbs +32 -0
- data/sig/anthropic/models/completion.rbs +32 -0
- data/sig/anthropic/models/completion_create_params.rbs +67 -0
- data/sig/anthropic/models/content_block.rbs +17 -0
- data/sig/anthropic/models/content_block_param.rbs +20 -0
- data/sig/anthropic/models/content_block_source.rbs +28 -0
- data/sig/anthropic/models/content_block_source_content.rbs +12 -0
- data/sig/anthropic/models/document_block_param.rbs +52 -0
- data/sig/anthropic/models/error_object.rbs +20 -0
- data/sig/anthropic/models/error_response.rbs +17 -0
- data/sig/anthropic/models/gateway_timeout_error.rbs +13 -0
- data/sig/anthropic/models/image_block_param.rbs +32 -0
- data/sig/anthropic/models/input_json_delta.rbs +13 -0
- data/sig/anthropic/models/invalid_request_error.rbs +14 -0
- data/sig/anthropic/models/message.rbs +44 -0
- data/sig/anthropic/models/message_count_tokens_params.rbs +67 -0
- data/sig/anthropic/models/message_count_tokens_tool.rbs +15 -0
- data/sig/anthropic/models/message_create_params.rbs +101 -0
- data/sig/anthropic/models/message_delta_usage.rbs +32 -0
- data/sig/anthropic/models/message_param.rbs +41 -0
- data/sig/anthropic/models/message_tokens_count.rbs +11 -0
- data/sig/anthropic/models/messages/batch_cancel_params.rbs +15 -0
- data/sig/anthropic/models/messages/batch_create_params.rbs +137 -0
- data/sig/anthropic/models/messages/batch_delete_params.rbs +15 -0
- data/sig/anthropic/models/messages/batch_list_params.rbs +33 -0
- data/sig/anthropic/models/messages/batch_results_params.rbs +15 -0
- data/sig/anthropic/models/messages/batch_retrieve_params.rbs +15 -0
- data/sig/anthropic/models/messages/deleted_message_batch.rbs +15 -0
- data/sig/anthropic/models/messages/message_batch.rbs +68 -0
- data/sig/anthropic/models/messages/message_batch_canceled_result.rbs +15 -0
- data/sig/anthropic/models/messages/message_batch_errored_result.rbs +21 -0
- data/sig/anthropic/models/messages/message_batch_expired_result.rbs +15 -0
- data/sig/anthropic/models/messages/message_batch_individual_response.rbs +24 -0
- data/sig/anthropic/models/messages/message_batch_request_counts.rbs +36 -0
- data/sig/anthropic/models/messages/message_batch_result.rbs +19 -0
- data/sig/anthropic/models/messages/message_batch_succeeded_result.rbs +18 -0
- data/sig/anthropic/models/metadata.rbs +11 -0
- data/sig/anthropic/models/model.rbs +61 -0
- data/sig/anthropic/models/model_info.rbs +23 -0
- data/sig/anthropic/models/model_list_params.rbs +43 -0
- data/sig/anthropic/models/model_retrieve_params.rbs +23 -0
- data/sig/anthropic/models/not_found_error.rbs +13 -0
- data/sig/anthropic/models/overloaded_error.rbs +13 -0
- data/sig/anthropic/models/permission_error.rbs +13 -0
- data/sig/anthropic/models/plain_text_source.rbs +20 -0
- data/sig/anthropic/models/rate_limit_error.rbs +13 -0
- data/sig/anthropic/models/raw_content_block_delta.rbs +16 -0
- data/sig/anthropic/models/raw_content_block_delta_event.rbs +24 -0
- data/sig/anthropic/models/raw_content_block_start_event.rbs +38 -0
- data/sig/anthropic/models/raw_content_block_stop_event.rbs +14 -0
- data/sig/anthropic/models/raw_message_delta_event.rbs +38 -0
- data/sig/anthropic/models/raw_message_start_event.rbs +17 -0
- data/sig/anthropic/models/raw_message_stop_event.rbs +11 -0
- data/sig/anthropic/models/raw_message_stream_event.rbs +17 -0
- data/sig/anthropic/models/redacted_thinking_block.rbs +13 -0
- data/sig/anthropic/models/redacted_thinking_block_param.rbs +14 -0
- data/sig/anthropic/models/server_tool_usage.rbs +11 -0
- data/sig/anthropic/models/server_tool_use_block.rbs +23 -0
- data/sig/anthropic/models/server_tool_use_block_param.rbs +32 -0
- data/sig/anthropic/models/signature_delta.rbs +13 -0
- data/sig/anthropic/models/stop_reason.rbs +24 -0
- data/sig/anthropic/models/text_block.rbs +24 -0
- data/sig/anthropic/models/text_block_param.rbs +28 -0
- data/sig/anthropic/models/text_citation.rbs +15 -0
- data/sig/anthropic/models/text_citation_param.rbs +15 -0
- data/sig/anthropic/models/text_delta.rbs +13 -0
- data/sig/anthropic/models/thinking_block.rbs +20 -0
- data/sig/anthropic/models/thinking_block_param.rbs +20 -0
- data/sig/anthropic/models/thinking_config_disabled.rbs +11 -0
- data/sig/anthropic/models/thinking_config_enabled.rbs +13 -0
- data/sig/anthropic/models/thinking_config_param.rbs +12 -0
- data/sig/anthropic/models/thinking_delta.rbs +13 -0
- data/sig/anthropic/models/tool.rbs +54 -0
- data/sig/anthropic/models/tool_bash_20250124.rbs +24 -0
- data/sig/anthropic/models/tool_choice.rbs +15 -0
- data/sig/anthropic/models/tool_choice_any.rbs +15 -0
- data/sig/anthropic/models/tool_choice_auto.rbs +15 -0
- data/sig/anthropic/models/tool_choice_none.rbs +11 -0
- data/sig/anthropic/models/tool_choice_tool.rbs +22 -0
- data/sig/anthropic/models/tool_result_block_param.rbs +57 -0
- data/sig/anthropic/models/tool_text_editor_20250124.rbs +24 -0
- data/sig/anthropic/models/tool_union.rbs +15 -0
- data/sig/anthropic/models/tool_use_block.rbs +23 -0
- data/sig/anthropic/models/tool_use_block_param.rbs +32 -0
- data/sig/anthropic/models/url_image_source.rbs +13 -0
- data/sig/anthropic/models/url_pdf_source.rbs +13 -0
- data/sig/anthropic/models/usage.rbs +32 -0
- data/sig/anthropic/models/web_search_result_block.rbs +32 -0
- data/sig/anthropic/models/web_search_result_block_param.rbs +32 -0
- data/sig/anthropic/models/web_search_tool_20250305.rbs +69 -0
- data/sig/anthropic/models/web_search_tool_request_error.rbs +39 -0
- data/sig/anthropic/models/web_search_tool_result_block.rbs +24 -0
- data/sig/anthropic/models/web_search_tool_result_block_content.rbs +15 -0
- data/sig/anthropic/models/web_search_tool_result_block_param.rbs +28 -0
- data/sig/anthropic/models/web_search_tool_result_block_param_content.rbs +15 -0
- data/sig/anthropic/models/web_search_tool_result_error.rbs +39 -0
- data/sig/anthropic/models.rbs +221 -0
- data/sig/anthropic/request_options.rbs +34 -0
- data/sig/anthropic/resources/beta/messages/batches.rbs +49 -0
- data/sig/anthropic/resources/beta/messages.rbs +56 -0
- data/sig/anthropic/resources/beta/models.rbs +23 -0
- data/sig/anthropic/resources/beta.rbs +11 -0
- data/sig/anthropic/resources/completions.rbs +33 -0
- data/sig/anthropic/resources/messages/batches.rbs +41 -0
- data/sig/anthropic/resources/messages.rbs +51 -0
- data/sig/anthropic/resources/models.rbs +21 -0
- data/sig/anthropic/version.rbs +3 -0
- data/sig/anthropic/vertex.rbs +3 -0
- metadata +801 -56
- data/.circleci/config.yml +0 -45
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/dependabot.yml +0 -15
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -26
- data/CODE_OF_CONDUCT.md +0 -74
- data/CONTRIBUTING.md +0 -3
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -84
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/anthropic.gemspec +0 -30
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/anthropic/compatibility.rb +0 -9
- data/lib/anthropic/http.rb +0 -93
- data/lib/ruby/anthropic.rb +0 -2
- data/pull_request_template.md +0 -5
data/README.md
CHANGED
@@ -1,138 +1,379 @@
|
|
1
|
-
# Anthropic
|
1
|
+
# Anthropic Ruby API library
|
2
2
|
|
3
|
-
[
|
4
|
-
[](https://github.com/alexrudall/anthropic/blob/main/LICENSE.txt)
|
5
|
-
[](https://circleci.com/gh/alexrudall/anthropic)
|
3
|
+
The Anthropic Ruby library provides convenient access to the Anthropic REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/anthropics/anthropic-sdk-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
6
4
|
|
7
|
-
|
5
|
+
## Documentation
|
8
6
|
|
9
|
-
|
7
|
+
Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/anthropic).
|
10
8
|
|
11
|
-
|
9
|
+
The REST API documentation can be found on [docs.anthropic.com](https://docs.anthropic.com/claude/reference/).
|
12
10
|
|
13
|
-
|
11
|
+
## Installation
|
14
12
|
|
15
|
-
|
13
|
+
To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
Add this line to your application's Gemfile:
|
15
|
+
<!-- x-release-please-start-version -->
|
20
16
|
|
21
17
|
```ruby
|
22
|
-
gem "anthropic"
|
18
|
+
gem "anthropic", "~> 0.1.0.pre.beta.9"
|
23
19
|
```
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
$ bundle install
|
21
|
+
<!-- x-release-please-end -->
|
28
22
|
|
29
|
-
|
23
|
+
## Feedback
|
30
24
|
|
31
|
-
|
25
|
+
If you have recommendations, notice bugs, find things confusing, or anything else, create a github issue. Don't be shy -- we're very open to hearing any thoughts and musings you have!
|
32
26
|
|
33
|
-
|
27
|
+
Feel free to make an issue for more substantial issues. For smaller issues or stream-of-thought, you can use the [pinned issue here](https://github.com/anthropics/anthropic-sdk-ruby/issues/85).
|
34
28
|
|
35
|
-
|
29
|
+
## Usage
|
36
30
|
|
37
31
|
```ruby
|
32
|
+
require "bundler/setup"
|
38
33
|
require "anthropic"
|
34
|
+
|
35
|
+
anthropic = Anthropic::Client.new(
|
36
|
+
api_key: ENV["ANTHROPIC_API_KEY"] # This is the default and can be omitted
|
37
|
+
)
|
38
|
+
|
39
|
+
message = anthropic.messages.create(
|
40
|
+
max_tokens: 1024,
|
41
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
42
|
+
model: :"claude-3-7-sonnet-latest"
|
43
|
+
)
|
44
|
+
|
45
|
+
puts(message.content)
|
39
46
|
```
|
40
47
|
|
41
|
-
|
48
|
+
### Streaming
|
42
49
|
|
43
|
-
|
44
|
-
- If you belong to multiple organizations, you can get your Organization ID from [https://platform.anthropic.com/account/org-settings](https://platform.anthropic.com/account/org-settings)
|
50
|
+
We provide support for streaming responses using Server-Sent Events (SSE).
|
45
51
|
|
46
|
-
|
52
|
+
**coming soon**: `anthropic.messages.stream` will have [Python SDK](https://github.com/anthropics/anthropic-sdk-python?tab=readme-ov-file#streaming-helpers) style streaming response helpers.
|
47
53
|
|
48
|
-
|
54
|
+
```ruby
|
55
|
+
stream = anthropic.messages.stream_raw(
|
56
|
+
max_tokens: 1024,
|
57
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
58
|
+
model: :"claude-3-7-sonnet-latest"
|
59
|
+
)
|
60
|
+
|
61
|
+
stream.each do |message|
|
62
|
+
puts(message.type)
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
### Pagination
|
67
|
+
|
68
|
+
List methods in the Anthropic API are paginated.
|
69
|
+
|
70
|
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
page = anthropic.beta.messages.batches.list(limit: 20)
|
74
|
+
|
75
|
+
# Fetch single item from page.
|
76
|
+
batch = page.data[0]
|
77
|
+
puts(batch.id)
|
78
|
+
|
79
|
+
# Automatically fetches more pages as needed.
|
80
|
+
page.auto_paging_each do |batch|
|
81
|
+
puts(batch.id)
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
Alternatively, you can use the `#next_page?` and `#next_page` methods for more granular control working with pages.
|
49
86
|
|
50
87
|
```ruby
|
51
|
-
|
88
|
+
if page.next_page?
|
89
|
+
new_page = page.next_page
|
90
|
+
puts(new_page.data[0].id)
|
91
|
+
end
|
52
92
|
```
|
53
93
|
|
54
|
-
###
|
94
|
+
### Handling errors
|
55
95
|
|
56
|
-
|
96
|
+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Anthropic::Errors::APIError` will be thrown:
|
57
97
|
|
58
98
|
```ruby
|
59
|
-
|
60
|
-
|
99
|
+
begin
|
100
|
+
message = anthropic.messages.create(
|
101
|
+
max_tokens: 1024,
|
102
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
103
|
+
model: :"claude-3-7-sonnet-latest"
|
104
|
+
)
|
105
|
+
rescue Anthropic::Errors::APIConnectionError => e
|
106
|
+
puts("The server could not be reached")
|
107
|
+
puts(e.cause) # an underlying Exception, likely raised within `net/http`
|
108
|
+
rescue Anthropic::Errors::RateLimitError => e
|
109
|
+
puts("A 429 status code was received; we should back off a bit.")
|
110
|
+
rescue Anthropic::Errors::APIStatusError => e
|
111
|
+
puts("Another non-200-range status code was received")
|
112
|
+
puts(e.status)
|
61
113
|
end
|
62
114
|
```
|
63
115
|
|
64
|
-
|
116
|
+
Error codes are as follows:
|
117
|
+
|
118
|
+
| Cause | Error Type |
|
119
|
+
| ---------------- | -------------------------- |
|
120
|
+
| HTTP 400 | `BadRequestError` |
|
121
|
+
| HTTP 401 | `AuthenticationError` |
|
122
|
+
| HTTP 403 | `PermissionDeniedError` |
|
123
|
+
| HTTP 404 | `NotFoundError` |
|
124
|
+
| HTTP 409 | `ConflictError` |
|
125
|
+
| HTTP 422 | `UnprocessableEntityError` |
|
126
|
+
| HTTP 429 | `RateLimitError` |
|
127
|
+
| HTTP >= 500 | `InternalServerError` |
|
128
|
+
| Other HTTP error | `APIStatusError` |
|
129
|
+
| Timeout | `APITimeoutError` |
|
130
|
+
| Network error | `APIConnectionError` |
|
131
|
+
|
132
|
+
### Retries
|
133
|
+
|
134
|
+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
|
135
|
+
|
136
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
|
137
|
+
|
138
|
+
You can use the `max_retries` option to configure or disable this:
|
65
139
|
|
66
140
|
```ruby
|
67
|
-
|
141
|
+
# Configure the default for all requests:
|
142
|
+
anthropic = Anthropic::Client.new(
|
143
|
+
max_retries: 0 # default is 2
|
144
|
+
)
|
145
|
+
|
146
|
+
# Or, configure per-request:
|
147
|
+
anthropic.messages.create(
|
148
|
+
max_tokens: 1024,
|
149
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
150
|
+
model: :"claude-3-7-sonnet-latest",
|
151
|
+
request_options: {max_retries: 5}
|
152
|
+
)
|
68
153
|
```
|
69
154
|
|
70
|
-
|
155
|
+
### Timeouts
|
71
156
|
|
72
|
-
|
157
|
+
By default, requests will time out after 600 seconds. You can use the timeout option to configure or disable this:
|
73
158
|
|
74
159
|
```ruby
|
75
|
-
|
76
|
-
|
77
|
-
|
160
|
+
# Configure the default for all requests:
|
161
|
+
anthropic = Anthropic::Client.new(
|
162
|
+
timeout: nil # default is 600
|
163
|
+
)
|
164
|
+
|
165
|
+
# Or, configure per-request:
|
166
|
+
anthropic.messages.create(
|
167
|
+
max_tokens: 1024,
|
168
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
169
|
+
model: :"claude-3-7-sonnet-latest",
|
170
|
+
request_options: {timeout: 5}
|
78
171
|
)
|
79
172
|
```
|
80
173
|
|
81
|
-
|
174
|
+
On timeout, `Anthropic::Errors::APITimeoutError` is raised.
|
175
|
+
|
176
|
+
Note that requests that time out are retried by default.
|
177
|
+
|
178
|
+
## AWS Bedrock
|
179
|
+
|
180
|
+
This library also provides support for the [Anthropic Bedrock API](https://aws.amazon.com/bedrock/claude/) if you install this library with the `aws-sdk-bedrockruntime` gem.
|
181
|
+
|
182
|
+
You can then instantiate a separate `Anthropic::BedrockClient` class, and use AWS's standard guide for configuring credentials (see [the aws-sdk-ruby gem README](https://github.com/aws/aws-sdk-ruby?tab=readme-ov-file#configuration) or [AWS Documentation](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html#credchain)). It has the same API as the base `Anthropic::Client` class.
|
183
|
+
|
184
|
+
Note that the model ID required is different for Bedrock models, and, depending on the model you want to use, you will need to use either the AWS's model ID for Anthropic models -- which can be found in [AWS's Bedrock model catalog](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) -- or an inference profile id (e.g. `us.anthropic.claude-3-5-haiku-20241022-v1:0` for Claude 3.5 Haiku).
|
82
185
|
|
83
186
|
```ruby
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
187
|
+
require "bundler/setup"
|
188
|
+
require "anthropic"
|
189
|
+
|
190
|
+
anthropic = Anthropic::BedrockClient.new
|
191
|
+
|
192
|
+
message = anthropic.messages.create(
|
193
|
+
max_tokens: 1024,
|
194
|
+
messages: [
|
195
|
+
{
|
196
|
+
role: "user",
|
197
|
+
content: "Hello, Claude"
|
198
|
+
}
|
199
|
+
],
|
200
|
+
model: "anthropic.claude-3-5-sonnet-20241022-v2:0"
|
201
|
+
)
|
202
|
+
|
203
|
+
puts(message)
|
204
|
+
```
|
205
|
+
|
206
|
+
For more examples see [`examples/bedrock`](examples/bedrock).
|
207
|
+
|
208
|
+
## Google Vertex
|
209
|
+
|
210
|
+
This library also provides support for the [Anthropic Vertex API](https://cloud.google.com/vertex-ai?hl=en) if you install this library with the `googleauth` gem.
|
211
|
+
|
212
|
+
You can then import and instantiate a separate `Anthropic::VertexClient` class, and use Google's guide for configuring [Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc). It has the same API as the base `Anthropic::Client` class.
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
require "bundler/setup"
|
216
|
+
require "anthropic"
|
217
|
+
|
218
|
+
anthropic = Anthropic::VertexClient.new(region: "us-east5", project_id: "my-project-id")
|
219
|
+
|
220
|
+
message = anthropic.messages.create(
|
221
|
+
max_tokens: 1024,
|
222
|
+
messages: [
|
223
|
+
{
|
224
|
+
role: "user",
|
225
|
+
content: "Hello, Claude"
|
226
|
+
}
|
227
|
+
],
|
228
|
+
model: "claude-3-7-sonnet@20250219"
|
229
|
+
)
|
230
|
+
|
231
|
+
puts(message)
|
91
232
|
```
|
92
233
|
|
93
|
-
|
234
|
+
For more examples see [`examples/vertex`](examples/vertex).
|
235
|
+
|
236
|
+
## Advanced concepts
|
237
|
+
|
238
|
+
### BaseModel
|
239
|
+
|
240
|
+
All parameter and response objects inherit from `Anthropic::Internal::Type::BaseModel`, which provides several conveniences, including:
|
241
|
+
|
242
|
+
1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
|
243
|
+
|
244
|
+
2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
|
245
|
+
|
246
|
+
3. Both instances and the classes themselves can be pretty-printed.
|
247
|
+
|
248
|
+
4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
|
94
249
|
|
95
|
-
|
250
|
+
### Making custom or undocumented requests
|
251
|
+
|
252
|
+
#### Undocumented properties
|
253
|
+
|
254
|
+
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
|
255
|
+
|
256
|
+
> [!WARNING]
|
257
|
+
>
|
258
|
+
> The `extra_` parameters of the same name overrides the documented parameters. For security reasons, ensure these methods are only used with trusted input data.
|
259
|
+
|
260
|
+
```ruby
|
261
|
+
message =
|
262
|
+
anthropic.messages.create(
|
263
|
+
max_tokens: 1024,
|
264
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
265
|
+
model: :"claude-3-7-sonnet-latest",
|
266
|
+
request_options: {
|
267
|
+
extra_query: {my_query_parameter: value},
|
268
|
+
extra_body: {my_body_parameter: value},
|
269
|
+
extra_headers: {"my-header": value}
|
270
|
+
}
|
271
|
+
)
|
272
|
+
|
273
|
+
puts(message[:my_undocumented_property])
|
274
|
+
```
|
275
|
+
|
276
|
+
#### Undocumented request params
|
277
|
+
|
278
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request as seen in examples above.
|
279
|
+
|
280
|
+
#### Undocumented endpoints
|
281
|
+
|
282
|
+
To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:
|
96
283
|
|
97
284
|
```ruby
|
98
|
-
response = client.
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
# => [", there lived a great"]
|
285
|
+
response = client.request(
|
286
|
+
method: :post,
|
287
|
+
path: '/undocumented/endpoint',
|
288
|
+
query: {"dog": "woof"},
|
289
|
+
headers: {"useful-header": "interesting-value"},
|
290
|
+
body: {"hello": "world"}
|
291
|
+
)
|
106
292
|
```
|
107
293
|
|
108
|
-
|
294
|
+
### Concurrency & connection pooling
|
295
|
+
|
296
|
+
The `Anthropic::Client` instances are threadsafe, but only are fork-safe when there are no in-flight HTTP requests.
|
109
297
|
|
110
|
-
|
298
|
+
Each instance of `Anthropic::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
|
111
299
|
|
112
|
-
|
300
|
+
When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
|
113
301
|
|
114
|
-
|
302
|
+
Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
|
115
303
|
|
116
|
-
|
304
|
+
## Sorbet
|
117
305
|
|
118
|
-
|
306
|
+
This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
|
119
307
|
|
120
|
-
|
308
|
+
You can provide typesafe request parameters like so:
|
121
309
|
|
310
|
+
```ruby
|
311
|
+
anthropic.messages.create(
|
312
|
+
max_tokens: 1024,
|
313
|
+
messages: [Anthropic::MessageParam.new(role: "user", content: "Hello, Claude")],
|
314
|
+
model: :"claude-3-7-sonnet-latest"
|
315
|
+
)
|
122
316
|
```
|
123
|
-
|
317
|
+
|
318
|
+
Or, equivalently:
|
319
|
+
|
320
|
+
```ruby
|
321
|
+
# Hashes work, but are not typesafe:
|
322
|
+
anthropic.messages.create(
|
323
|
+
max_tokens: 1024,
|
324
|
+
messages: [{role: "user", content: "Hello, Claude"}],
|
325
|
+
model: :"claude-3-7-sonnet-latest"
|
326
|
+
)
|
327
|
+
|
328
|
+
# You can also splat a full Params class:
|
329
|
+
params = Anthropic::MessageCreateParams.new(
|
330
|
+
max_tokens: 1024,
|
331
|
+
messages: [Anthropic::MessageParam.new(role: "user", content: "Hello, Claude")],
|
332
|
+
model: :"claude-3-7-sonnet-latest"
|
333
|
+
)
|
334
|
+
anthropic.messages.create(**params)
|
124
335
|
```
|
125
336
|
|
126
|
-
|
337
|
+
### Enums
|
127
338
|
|
128
|
-
|
339
|
+
Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
|
340
|
+
|
341
|
+
```ruby
|
342
|
+
# :"image/jpeg"
|
343
|
+
puts(Anthropic::Base64ImageSource::MediaType::IMAGE_JPEG)
|
344
|
+
|
345
|
+
# Revealed type: `T.all(Anthropic::Base64ImageSource::MediaType, Symbol)`
|
346
|
+
T.reveal_type(Anthropic::Base64ImageSource::MediaType::IMAGE_JPEG)
|
347
|
+
```
|
129
348
|
|
130
|
-
|
349
|
+
Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
|
131
350
|
|
132
|
-
|
351
|
+
```ruby
|
352
|
+
Anthropic::Base64ImageSource.new(
|
353
|
+
media_type: Anthropic::Base64ImageSource::MediaType::IMAGE_JPEG,
|
354
|
+
# …
|
355
|
+
)
|
356
|
+
|
357
|
+
Anthropic::Base64ImageSource.new(
|
358
|
+
media_type: :"image/jpeg",
|
359
|
+
# …
|
360
|
+
)
|
361
|
+
```
|
362
|
+
|
363
|
+
## Versioning
|
364
|
+
|
365
|
+
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
|
366
|
+
|
367
|
+
This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
|
368
|
+
|
369
|
+
## Requirements
|
370
|
+
|
371
|
+
Ruby 3.2.0 or higher.
|
372
|
+
|
373
|
+
## Contributing
|
133
374
|
|
134
|
-
|
375
|
+
See [the contributing documentation](https://github.com/anthropics/anthropic-sdk-ruby/tree/main/CONTRIBUTING.md).
|
135
376
|
|
136
|
-
##
|
377
|
+
## Acknowledgements
|
137
378
|
|
138
|
-
|
379
|
+
Thank you [@alexrudall](https://github.com/alexrudall) for giving feedback, donating the `anthropic` Ruby Gem name, and paving the way by building the first Anthropic Ruby SDK.
|
data/SECURITY.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Reporting Security Issues
|
4
|
+
|
5
|
+
This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
|
6
|
+
|
7
|
+
To report a security issue, please contact the Stainless team at security@stainless.com.
|
8
|
+
|
9
|
+
## Responsible Disclosure
|
10
|
+
|
11
|
+
We appreciate the efforts of security researchers and individuals who help us maintain the security of
|
12
|
+
SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible
|
13
|
+
disclosure practices by allowing us a reasonable amount of time to investigate and address the issue
|
14
|
+
before making any information public.
|
15
|
+
|
16
|
+
## Reporting Non-SDK Related Security Issues
|
17
|
+
|
18
|
+
If you encounter security issues that are not directly related to SDKs but pertain to the services
|
19
|
+
or products provided by Anthropic please follow the respective company's security reporting guidelines.
|
20
|
+
|
21
|
+
### Anthropic Terms and Policies
|
22
|
+
|
23
|
+
Please contact support@anthropic.com for any questions or concerns regarding security of our services.
|
24
|
+
|
25
|
+
---
|
26
|
+
|
27
|
+
Thank you for helping us keep the SDKs and systems they interact with secure.
|
data/lib/anthropic/client.rb
CHANGED
@@ -1,18 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Anthropic
|
2
|
-
class Client
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
class Client < Anthropic::Internal::Transport::BaseClient
|
5
|
+
# Default max number of retries to attempt after a failed retryable request.
|
6
|
+
DEFAULT_MAX_RETRIES = 2
|
7
|
+
|
8
|
+
# Default per-request timeout.
|
9
|
+
DEFAULT_TIMEOUT_IN_SECONDS = 600.0
|
10
|
+
|
11
|
+
# Default initial retry delay in seconds.
|
12
|
+
# Overall delay is calculated using exponential backoff + jitter.
|
13
|
+
DEFAULT_INITIAL_RETRY_DELAY = 0.5
|
14
|
+
|
15
|
+
# Default max retry delay in seconds.
|
16
|
+
DEFAULT_MAX_RETRY_DELAY = 8.0
|
17
|
+
|
18
|
+
# @return [String, nil]
|
19
|
+
attr_reader :api_key
|
20
|
+
|
21
|
+
# @return [String, nil]
|
22
|
+
attr_reader :auth_token
|
23
|
+
|
24
|
+
# @return [Anthropic::Resources::Completions]
|
25
|
+
attr_reader :completions
|
26
|
+
|
27
|
+
# @return [Anthropic::Resources::Messages]
|
28
|
+
attr_reader :messages
|
29
|
+
|
30
|
+
# @return [Anthropic::Resources::Models]
|
31
|
+
attr_reader :models
|
32
|
+
|
33
|
+
# @return [Anthropic::Resources::Beta]
|
34
|
+
attr_reader :beta
|
35
|
+
|
36
|
+
# @api private
|
37
|
+
#
|
38
|
+
# @return [Hash{String=>String}]
|
39
|
+
private def auth_headers
|
40
|
+
{**api_key_auth, **bearer_auth}
|
41
|
+
end
|
42
|
+
|
43
|
+
# @api private
|
44
|
+
#
|
45
|
+
# @return [Hash{String=>String}]
|
46
|
+
private def api_key_auth
|
47
|
+
{"x-api-key" => @api_key}
|
48
|
+
end
|
49
|
+
|
50
|
+
# @api private
|
51
|
+
#
|
52
|
+
# @return [Hash{String=>String}]
|
53
|
+
private def bearer_auth
|
54
|
+
return {} if @auth_token.nil?
|
55
|
+
|
56
|
+
{"authorization" => "Bearer #{@auth_token}"}
|
12
57
|
end
|
13
58
|
|
14
|
-
|
15
|
-
|
59
|
+
# Creates and returns a new client for interacting with the API.
|
60
|
+
#
|
61
|
+
# @param api_key [String, nil] Defaults to `ENV["ANTHROPIC_API_KEY"]`
|
62
|
+
#
|
63
|
+
# @param auth_token [String, nil] Defaults to `ENV["ANTHROPIC_AUTH_TOKEN"]`
|
64
|
+
#
|
65
|
+
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
|
66
|
+
# `"https://api.example.com/v2/"`. Defaults to `ENV["ANTHROPIC_BASE_URL"]`
|
67
|
+
#
|
68
|
+
# @param max_retries [Integer] Max number of retries to attempt after a failed retryable request.
|
69
|
+
#
|
70
|
+
# @param timeout [Float]
|
71
|
+
#
|
72
|
+
# @param initial_retry_delay [Float]
|
73
|
+
#
|
74
|
+
# @param max_retry_delay [Float]
|
75
|
+
def initialize(
|
76
|
+
api_key: ENV["ANTHROPIC_API_KEY"],
|
77
|
+
auth_token: ENV["ANTHROPIC_AUTH_TOKEN"],
|
78
|
+
base_url: ENV["ANTHROPIC_BASE_URL"],
|
79
|
+
max_retries: self.class::DEFAULT_MAX_RETRIES,
|
80
|
+
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
|
81
|
+
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
|
82
|
+
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
|
83
|
+
)
|
84
|
+
base_url ||= "https://api.anthropic.com"
|
85
|
+
|
86
|
+
headers = {
|
87
|
+
"anthropic-version" => "2023-06-01"
|
88
|
+
}
|
89
|
+
|
90
|
+
@api_key = api_key&.to_s
|
91
|
+
@auth_token = auth_token&.to_s
|
92
|
+
|
93
|
+
super(
|
94
|
+
base_url: base_url,
|
95
|
+
timeout: timeout,
|
96
|
+
max_retries: max_retries,
|
97
|
+
initial_retry_delay: initial_retry_delay,
|
98
|
+
max_retry_delay: max_retry_delay,
|
99
|
+
headers: headers
|
100
|
+
)
|
101
|
+
|
102
|
+
@completions = Anthropic::Resources::Completions.new(client: self)
|
103
|
+
@messages = Anthropic::Resources::Messages.new(client: self)
|
104
|
+
@models = Anthropic::Resources::Models.new(client: self)
|
105
|
+
@beta = Anthropic::Resources::Beta.new(client: self)
|
16
106
|
end
|
17
107
|
end
|
18
108
|
end
|