├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .github ├── CODEOWNERS └── workflows │ ├── ci.yml │ ├── create-releases.yml │ ├── publish-pypi.yml │ └── release-doctor.yml ├── .gitignore ├── .python-version ├── .release-please-manifest.json ├── .stats.yml ├── Brewfile ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── api.md ├── bin ├── check-release-environment └── publish-pypi ├── examples ├── .keep ├── batch_results.py ├── bedrock.py ├── images.py ├── logo.png ├── mcp.py ├── messages.py ├── messages_stream.py ├── text_completions_demo_async.py ├── text_completions_demo_sync.py ├── text_completions_streaming.py ├── thinking.py ├── thinking_stream.py ├── tools.py ├── tools_stream.py ├── vertex.py ├── web_search.py └── web_search_stream.py ├── helpers.md ├── mypy.ini ├── pyproject.toml ├── release-please-config.json ├── requirements-dev.lock ├── scripts ├── bootstrap ├── format ├── lint ├── mock ├── test └── utils │ ├── ruffen-docs.py │ └── upload-artifact.sh ├── src └── anthropic │ ├── __init__.py │ ├── _base_client.py │ ├── _client.py │ ├── _compat.py │ ├── _constants.py │ ├── _decoders │ └── jsonl.py │ ├── _exceptions.py │ ├── _files.py │ ├── _legacy_response.py │ ├── _models.py │ ├── _qs.py │ ├── _resource.py │ ├── _response.py │ ├── _streaming.py │ ├── _types.py │ ├── _utils │ ├── __init__.py │ ├── _logs.py │ ├── _proxy.py │ ├── _reflection.py │ ├── _resources_proxy.py │ ├── _streams.py │ ├── _sync.py │ ├── _transform.py │ ├── _typing.py │ └── _utils.py │ ├── _version.py │ ├── lib │ ├── .keep │ ├── __init__.py │ ├── _extras │ │ ├── __init__.py │ │ ├── _common.py │ │ └── _google_auth.py │ ├── bedrock │ │ ├── __init__.py │ │ ├── _auth.py │ │ ├── _beta.py │ │ ├── _beta_messages.py │ │ ├── _client.py │ │ ├── _stream.py │ │ └── _stream_decoder.py │ ├── streaming │ │ ├── __init__.py │ │ ├── _beta_messages.py │ │ ├── _beta_types.py │ │ ├── _messages.py │ │ └── _types.py │ └── vertex │ │ ├── __init__.py │ │ ├── _auth.py │ │ ├── _beta.py │ │ ├── _beta_messages.py │ │ └── _client.py │ ├── pagination.py │ ├── py.typed │ ├── resources │ ├── __init__.py │ ├── beta │ │ ├── __init__.py │ │ ├── beta.py │ │ ├── files.py │ │ ├── messages │ │ │ ├── __init__.py │ │ │ ├── batches.py │ │ │ └── messages.py │ │ └── models.py │ ├── completions.py │ ├── messages │ │ ├── __init__.py │ │ ├── batches.py │ │ └── messages.py │ └── models.py │ └── types │ ├── __init__.py │ ├── anthropic_beta_param.py │ ├── base64_image_source_param.py │ ├── base64_pdf_source_param.py │ ├── beta │ ├── __init__.py │ ├── beta_base64_image_source_param.py │ ├── beta_base64_pdf_block_param.py │ ├── beta_base64_pdf_source_param.py │ ├── beta_cache_control_ephemeral_param.py │ ├── beta_cache_creation.py │ ├── beta_citation_char_location.py │ ├── beta_citation_char_location_param.py │ ├── beta_citation_content_block_location.py │ ├── beta_citation_content_block_location_param.py │ ├── beta_citation_page_location.py │ ├── beta_citation_page_location_param.py │ ├── beta_citation_web_search_result_location_param.py │ ├── beta_citations_config_param.py │ ├── beta_citations_delta.py │ ├── beta_citations_web_search_result_location.py │ ├── beta_code_execution_output_block.py │ ├── beta_code_execution_output_block_param.py │ ├── beta_code_execution_result_block.py │ ├── beta_code_execution_result_block_param.py │ ├── beta_code_execution_tool_20250522_param.py │ ├── beta_code_execution_tool_result_block.py │ ├── beta_code_execution_tool_result_block_content.py │ ├── beta_code_execution_tool_result_block_param.py │ ├── beta_code_execution_tool_result_block_param_content_param.py │ ├── beta_code_execution_tool_result_error.py │ ├── beta_code_execution_tool_result_error_code.py │ ├── beta_code_execution_tool_result_error_param.py │ ├── beta_container.py │ ├── beta_container_upload_block.py │ ├── beta_container_upload_block_param.py │ ├── beta_content_block.py │ ├── beta_content_block_param.py │ ├── beta_content_block_source_content_param.py │ ├── beta_content_block_source_param.py │ ├── beta_file_document_source_param.py │ ├── beta_file_image_source_param.py │ ├── beta_image_block_param.py │ ├── beta_input_json_delta.py │ ├── beta_mcp_tool_result_block.py │ ├── beta_mcp_tool_use_block.py │ ├── beta_mcp_tool_use_block_param.py │ ├── beta_message.py │ ├── beta_message_delta_usage.py │ ├── beta_message_param.py │ ├── beta_message_tokens_count.py │ ├── beta_metadata_param.py │ ├── beta_model_info.py │ ├── beta_plain_text_source_param.py │ ├── beta_raw_content_block_delta.py │ ├── beta_raw_content_block_delta_event.py │ ├── beta_raw_content_block_start_event.py │ ├── beta_raw_content_block_stop_event.py │ ├── beta_raw_message_delta_event.py │ ├── beta_raw_message_start_event.py │ ├── beta_raw_message_stop_event.py │ ├── beta_raw_message_stream_event.py │ ├── beta_redacted_thinking_block.py │ ├── beta_redacted_thinking_block_param.py │ ├── beta_request_mcp_server_tool_configuration_param.py │ ├── beta_request_mcp_server_url_definition_param.py │ ├── beta_request_mcp_tool_result_block_param.py │ ├── beta_server_tool_usage.py │ ├── beta_server_tool_use_block.py │ ├── beta_server_tool_use_block_param.py │ ├── beta_signature_delta.py │ ├── beta_stop_reason.py │ ├── beta_text_block.py │ ├── beta_text_block_param.py │ ├── beta_text_citation.py │ ├── beta_text_citation_param.py │ ├── beta_text_delta.py │ ├── beta_thinking_block.py │ ├── beta_thinking_block_param.py │ ├── beta_thinking_config_disabled_param.py │ ├── beta_thinking_config_enabled_param.py │ ├── beta_thinking_config_param.py │ ├── beta_thinking_delta.py │ ├── beta_tool_bash_20241022_param.py │ ├── beta_tool_bash_20250124_param.py │ ├── beta_tool_choice_any_param.py │ ├── beta_tool_choice_auto_param.py │ ├── beta_tool_choice_none_param.py │ ├── beta_tool_choice_param.py │ ├── beta_tool_choice_tool_param.py │ ├── beta_tool_computer_use_20241022_param.py │ ├── beta_tool_computer_use_20250124_param.py │ ├── beta_tool_param.py │ ├── beta_tool_result_block_param.py │ ├── beta_tool_text_editor_20241022_param.py │ ├── beta_tool_text_editor_20250124_param.py │ ├── beta_tool_text_editor_20250429_param.py │ ├── beta_tool_union_param.py │ ├── beta_tool_use_block.py │ ├── beta_tool_use_block_param.py │ ├── beta_url_image_source_param.py │ ├── beta_url_pdf_source_param.py │ ├── beta_usage.py │ ├── beta_web_search_result_block.py │ ├── beta_web_search_result_block_param.py │ ├── beta_web_search_tool_20250305_param.py │ ├── beta_web_search_tool_request_error_param.py │ ├── beta_web_search_tool_result_block.py │ ├── beta_web_search_tool_result_block_content.py │ ├── beta_web_search_tool_result_block_param.py │ ├── beta_web_search_tool_result_block_param_content_param.py │ ├── beta_web_search_tool_result_error.py │ ├── beta_web_search_tool_result_error_code.py │ ├── deleted_file.py │ ├── file_list_params.py │ ├── file_metadata.py │ ├── file_upload_params.py │ ├── message_count_tokens_params.py │ ├── message_create_params.py │ ├── messages │ │ ├── __init__.py │ │ ├── batch_create_params.py │ │ ├── batch_list_params.py │ │ ├── beta_deleted_message_batch.py │ │ ├── beta_message_batch.py │ │ ├── beta_message_batch_canceled_result.py │ │ ├── beta_message_batch_errored_result.py │ │ ├── beta_message_batch_expired_result.py │ │ ├── beta_message_batch_individual_response.py │ │ ├── beta_message_batch_request_counts.py │ │ ├── beta_message_batch_result.py │ │ └── beta_message_batch_succeeded_result.py │ └── model_list_params.py │ ├── beta_api_error.py │ ├── beta_authentication_error.py │ ├── beta_billing_error.py │ ├── beta_error.py │ ├── beta_error_response.py │ ├── beta_gateway_timeout_error.py │ ├── beta_invalid_request_error.py │ ├── beta_not_found_error.py │ ├── beta_overloaded_error.py │ ├── beta_permission_error.py │ ├── beta_rate_limit_error.py │ ├── cache_control_ephemeral_param.py │ ├── citation_char_location.py │ ├── citation_char_location_param.py │ ├── citation_content_block_location.py │ ├── citation_content_block_location_param.py │ ├── citation_page_location.py │ ├── citation_page_location_param.py │ ├── citation_web_search_result_location_param.py │ ├── citations_config_param.py │ ├── citations_delta.py │ ├── citations_web_search_result_location.py │ ├── completion.py │ ├── completion_create_params.py │ ├── content_block.py │ ├── content_block_delta_event.py │ ├── content_block_param.py │ ├── content_block_source_content_param.py │ ├── content_block_source_param.py │ ├── content_block_start_event.py │ ├── content_block_stop_event.py │ ├── document_block_param.py │ ├── image_block_param.py │ ├── input_json_delta.py │ ├── message.py │ ├── message_count_tokens_params.py │ ├── message_count_tokens_tool_param.py │ ├── message_create_params.py │ ├── message_delta_event.py │ ├── message_delta_usage.py │ ├── message_param.py │ ├── message_start_event.py │ ├── message_stop_event.py │ ├── message_stream_event.py │ ├── message_tokens_count.py │ ├── messages │ ├── __init__.py │ ├── batch_create_params.py │ ├── batch_list_params.py │ ├── deleted_message_batch.py │ ├── message_batch.py │ ├── message_batch_canceled_result.py │ ├── message_batch_errored_result.py │ ├── message_batch_expired_result.py │ ├── message_batch_individual_response.py │ ├── message_batch_request_counts.py │ ├── message_batch_result.py │ └── message_batch_succeeded_result.py │ ├── metadata_param.py │ ├── model.py │ ├── model_info.py │ ├── model_list_params.py │ ├── model_param.py │ ├── plain_text_source_param.py │ ├── raw_content_block_delta.py │ ├── raw_content_block_delta_event.py │ ├── raw_content_block_start_event.py │ ├── raw_content_block_stop_event.py │ ├── raw_message_delta_event.py │ ├── raw_message_start_event.py │ ├── raw_message_stop_event.py │ ├── raw_message_stream_event.py │ ├── redacted_thinking_block.py │ ├── redacted_thinking_block_param.py │ ├── server_tool_usage.py │ ├── server_tool_use_block.py │ ├── server_tool_use_block_param.py │ ├── shared │ ├── __init__.py │ ├── api_error_object.py │ ├── authentication_error.py │ ├── billing_error.py │ ├── error_object.py │ ├── error_response.py │ ├── gateway_timeout_error.py │ ├── invalid_request_error.py │ ├── not_found_error.py │ ├── overloaded_error.py │ ├── permission_error.py │ └── rate_limit_error.py │ ├── signature_delta.py │ ├── stop_reason.py │ ├── text_block.py │ ├── text_block_param.py │ ├── text_citation.py │ ├── text_citation_param.py │ ├── text_delta.py │ ├── thinking_block.py │ ├── thinking_block_param.py │ ├── thinking_config_disabled_param.py │ ├── thinking_config_enabled_param.py │ ├── thinking_config_param.py │ ├── thinking_delta.py │ ├── tool_bash_20250124_param.py │ ├── tool_choice_any_param.py │ ├── tool_choice_auto_param.py │ ├── tool_choice_none_param.py │ ├── tool_choice_param.py │ ├── tool_choice_tool_param.py │ ├── tool_param.py │ ├── tool_result_block_param.py │ ├── tool_text_editor_20250124_param.py │ ├── tool_union_param.py │ ├── tool_use_block.py │ ├── tool_use_block_param.py │ ├── url_image_source_param.py │ ├── url_pdf_source_param.py │ ├── usage.py │ ├── web_search_result_block.py │ ├── web_search_result_block_param.py │ ├── web_search_tool_20250305_param.py │ ├── web_search_tool_request_error_param.py │ ├── web_search_tool_result_block.py │ ├── web_search_tool_result_block_content.py │ ├── web_search_tool_result_block_param.py │ ├── web_search_tool_result_block_param_content_param.py │ └── web_search_tool_result_error.py ├── tests ├── __init__.py ├── api_resources │ ├── __init__.py │ ├── beta │ │ ├── __init__.py │ │ ├── messages │ │ │ ├── __init__.py │ │ │ └── test_batches.py │ │ ├── test_files.py │ │ ├── test_messages.py │ │ └── test_models.py │ ├── messages │ │ ├── __init__.py │ │ └── test_batches.py │ ├── test_completions.py │ ├── test_messages.py │ └── test_models.py ├── conftest.py ├── decoders │ └── test_jsonl.py ├── lib │ ├── streaming │ │ ├── test_beta_messages.py │ │ └── test_messages.py │ ├── test_bedrock.py │ └── test_vertex.py ├── sample_file.txt ├── test_client.py ├── test_deepcopy.py ├── test_extract_files.py ├── test_files.py ├── test_legacy_response.py ├── test_models.py ├── test_qs.py ├── test_required_args.py ├── test_response.py ├── test_streaming.py ├── test_transform.py ├── test_utils │ ├── test_proxy.py │ └── test_typing.py └── utils.py └── uv.lock /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG VARIANT="3.9" 2 | FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} 3 | 4 | USER vscode 5 | 6 | COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ 7 | 8 | RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc 9 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/devcontainers/templates/tree/main/src/debian 3 | { 4 | "name": "Debian", 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | "context": ".." 8 | }, 9 | 10 | "postStartCommand": "uv sync --all-extras", 11 | 12 | "customizations": { 13 | "vscode": { 14 | "extensions": [ 15 | "ms-python.python" 16 | ], 17 | "settings": { 18 | "terminal.integrated.shell.linux": "/bin/bash", 19 | "python.pythonPath": ".venv/bin/python", 20 | "python.defaultInterpreterPath": ".venv/bin/python", 21 | "python.typeChecking": "basic", 22 | "terminal.integrated.env.linux": { 23 | "PATH": "${env:PATH}" 24 | } 25 | } 26 | } 27 | }, 28 | "features": { 29 | "ghcr.io/devcontainers/features/node:1": {} 30 | } 31 | 32 | // Features to add to the dev container. More info: https://containers.dev/features. 33 | // "features": {}, 34 | 35 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 36 | // "forwardPorts": [], 37 | 38 | // Configure tool-specific properties. 39 | // "customizations": {}, 40 | 41 | // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. 42 | // "remoteUser": "root" 43 | } 44 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file is used to automatically assign reviewers to PRs 2 | # For more information see: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 3 | 4 | * @anthropics/sdk 5 | -------------------------------------------------------------------------------- /.github/workflows/create-releases.yml: -------------------------------------------------------------------------------- 1 | name: Create releases 2 | on: 3 | schedule: 4 | - cron: '0 5 * * *' # every day at 5am UTC 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | release: 11 | name: release 12 | if: github.ref == 'refs/heads/main' && github.repository == 'anthropics/anthropic-sdk-python' 13 | runs-on: ubuntu-latest 14 | environment: production-release 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - uses: stainless-api/trigger-release-please@v1 20 | id: release 21 | with: 22 | repo: ${{ github.event.repository.full_name }} 23 | stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} 24 | 25 | - name: Install uv 26 | if: ${{ steps.release.outputs.releases_created }} 27 | uses: astral-sh/setup-uv@v5 28 | with: 29 | version: '0.5.23' 30 | 31 | - name: Publish to PyPI 32 | if: ${{ steps.release.outputs.releases_created }} 33 | run: | 34 | bash ./bin/publish-pypi 35 | env: 36 | PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN || secrets.PYPI_TOKEN }} 37 | -------------------------------------------------------------------------------- /.github/workflows/publish-pypi.yml: -------------------------------------------------------------------------------- 1 | # workflow for re-running publishing to PyPI in case it fails for some reason 2 | # you can run this workflow by navigating to https://www.github.com/anthropics/anthropic-sdk-python/actions/workflows/publish-pypi.yml 3 | name: Publish PyPI 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | publish: 9 | name: publish 10 | runs-on: ubuntu-latest 11 | environment: production-release 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Install uv 17 | uses: astral-sh/setup-uv@v5 18 | with: 19 | version: '0.5.23' 20 | 21 | - name: Publish to PyPI 22 | run: | 23 | bash ./bin/publish-pypi 24 | env: 25 | PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN || secrets.PYPI_TOKEN }} 26 | -------------------------------------------------------------------------------- /.github/workflows/release-doctor.yml: -------------------------------------------------------------------------------- 1 | name: Release Doctor 2 | on: 3 | push: 4 | branches: 5 | - main 6 | workflow_dispatch: 7 | 8 | jobs: 9 | release_doctor: 10 | name: release doctor 11 | runs-on: ubuntu-latest 12 | environment: production-release 13 | if: github.repository == 'anthropics/anthropic-sdk-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Check release environment 19 | run: | 20 | bash ./bin/check-release-environment 21 | env: 22 | STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} 23 | PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN || secrets.PYPI_TOKEN }} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .prism.log 2 | .vscode 3 | _dev 4 | 5 | __pycache__ 6 | .mypy_cache 7 | 8 | dist 9 | 10 | .venv 11 | .idea 12 | 13 | .env 14 | .envrc 15 | codegen.log 16 | Brewfile.lock.json 17 | -------------------------------------------------------------------------------- /.python-version: -------------------------------------------------------------------------------- 1 | 3.9.18 2 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | ".": "0.52.2" 3 | } -------------------------------------------------------------------------------- /.stats.yml: -------------------------------------------------------------------------------- 1 | configured_endpoints: 26 2 | openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-1fdf23e8226430012c21819427e8d1ed16c08c0fb2d4abf69b8e318a42e99552.yml 3 | openapi_spec_hash: 836bbb4ab7c33c37456d1842876d7aba 4 | config_hash: 91be78a9c3fd8dcdc0137a2cf6950153 5 | -------------------------------------------------------------------------------- /Brewfile: -------------------------------------------------------------------------------- 1 | brew "uv" 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2023 Anthropic, PBC. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 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 the security of our services. 24 | 25 | --- 26 | 27 | Thank you for helping us keep the SDKs and systems they interact with secure. 28 | -------------------------------------------------------------------------------- /bin/check-release-environment: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | errors=() 4 | 5 | if [ -z "${STAINLESS_API_KEY}" ]; then 6 | errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.") 7 | fi 8 | 9 | if [ -z "${PYPI_TOKEN}" ]; then 10 | errors+=("The ANTHROPIC_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.") 11 | fi 12 | 13 | lenErrors=${#errors[@]} 14 | 15 | if [[ lenErrors -gt 0 ]]; then 16 | echo -e "Found the following errors in the release environment:\n" 17 | 18 | for error in "${errors[@]}"; do 19 | echo -e "- $error\n" 20 | done 21 | 22 | exit 1 23 | fi 24 | 25 | echo "The environment is ready to push releases!" 26 | -------------------------------------------------------------------------------- /bin/publish-pypi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux 4 | rm -rf dist 5 | mkdir -p dist 6 | uv build 7 | uv publish --token=$PYPI_TOKEN 8 | -------------------------------------------------------------------------------- /examples/.keep: -------------------------------------------------------------------------------- 1 | File generated from our OpenAPI spec by Stainless. 2 | 3 | This directory can be used to store example files demonstrating usage of this SDK. 4 | It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. -------------------------------------------------------------------------------- /examples/batch_results.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | 4 | import rich 5 | 6 | from anthropic import Anthropic 7 | 8 | client = Anthropic() 9 | 10 | try: 11 | batch_id = sys.argv[1] 12 | except IndexError as exc: 13 | raise RuntimeError("must specify a message batch ID, `python examples/batch_results.py msgbatch_123`") from exc 14 | 15 | s = time.monotonic() 16 | 17 | result_stream = client.beta.messages.batches.results(batch_id) 18 | for result in result_stream: 19 | rich.print(result) 20 | -------------------------------------------------------------------------------- /examples/images.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | from anthropic import Anthropic 4 | 5 | client = Anthropic() 6 | 7 | response = client.messages.create( 8 | max_tokens=1024, 9 | messages=[ 10 | { 11 | "role": "user", 12 | "content": [ 13 | { 14 | "type": "text", 15 | "text": "Hello!", 16 | }, 17 | { 18 | "type": "image", 19 | "source": { 20 | "type": "base64", 21 | "media_type": "image/png", 22 | "data": Path(__file__).parent.joinpath("logo.png"), 23 | }, 24 | }, 25 | ], 26 | }, 27 | ], 28 | model="claude-3-5-sonnet-latest", 29 | ) 30 | print(response.model_dump_json(indent=2)) 31 | -------------------------------------------------------------------------------- /examples/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthropics/anthropic-sdk-python/a1f61dd577cc78b2a4c26bc4eb80a875eca4aee6/examples/logo.png -------------------------------------------------------------------------------- /examples/mcp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S rye run python 2 | 3 | from anthropic import Anthropic 4 | 5 | anthropic = Anthropic() 6 | 7 | response = anthropic.beta.messages.create( 8 | model="claude-3-7-sonnet-20250219", 9 | max_tokens=1000, 10 | messages=[ 11 | { 12 | "role": "user", 13 | "content": 'Calculate 1+2', 14 | }, 15 | ], 16 | mcp_servers=[ 17 | { 18 | "type": "url", 19 | "url": "http://example-server.modelcontextprotocol.io/sse", 20 | "authorization_token": "YOUR_TOKEN", 21 | "name": "example", 22 | "tool_configuration": { # Optional, by default all tools are enabled 23 | "enabled": True, 24 | "allowed_tools": ['echo', 'add'], # Optional 25 | }, 26 | } 27 | ], 28 | extra_headers={ 29 | "anthropic-beta": "mcp-client-2025-04-04", 30 | }, 31 | ) 32 | print(response.content) 33 | -------------------------------------------------------------------------------- /examples/messages.py: -------------------------------------------------------------------------------- 1 | from anthropic import Anthropic 2 | 3 | client = Anthropic() 4 | 5 | response = client.messages.create( 6 | max_tokens=1024, 7 | messages=[ 8 | { 9 | "role": "user", 10 | "content": "Hello!", 11 | } 12 | ], 13 | model="claude-3-5-sonnet-latest", 14 | ) 15 | print(response) 16 | 17 | response2 = client.messages.create( 18 | max_tokens=1024, 19 | messages=[ 20 | { 21 | "role": "user", 22 | "content": "Hello!", 23 | }, 24 | { 25 | "role": response.role, 26 | "content": response.content, 27 | }, 28 | { 29 | "role": "user", 30 | "content": "How are you?", 31 | }, 32 | ], 33 | model="claude-3-5-sonnet-latest", 34 | ) 35 | print(response2) 36 | -------------------------------------------------------------------------------- /examples/messages_stream.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S rye run python 2 | 3 | import asyncio 4 | 5 | from anthropic import AsyncAnthropic 6 | 7 | client = AsyncAnthropic() 8 | 9 | 10 | async def main() -> None: 11 | async with client.messages.stream( 12 | max_tokens=1024, 13 | messages=[ 14 | { 15 | "role": "user", 16 | "content": "Say hello there!", 17 | } 18 | ], 19 | model="claude-3-5-sonnet-latest", 20 | ) as stream: 21 | async for event in stream: 22 | if event.type == "text": 23 | print(event.text, end="", flush=True) 24 | elif event.type == "content_block_stop": 25 | print() 26 | print("\ncontent block finished accumulating:", event.content_block) 27 | print() 28 | 29 | # you can still get the accumulated final message outside of 30 | # the context manager, as long as the entire stream was consumed 31 | # inside of the context manager 32 | accumulated = await stream.get_final_message() 33 | print("accumulated message: ", accumulated.to_json()) 34 | 35 | 36 | asyncio.run(main()) 37 | -------------------------------------------------------------------------------- /examples/text_completions_demo_async.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S poetry run python 2 | 3 | import asyncio 4 | 5 | import anthropic 6 | from anthropic import AsyncAnthropic 7 | 8 | 9 | async def main() -> None: 10 | client = AsyncAnthropic() 11 | 12 | res = await client.completions.create( 13 | model="claude-2.1", 14 | prompt=f"{anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? {anthropic.AI_PROMPT}", 15 | max_tokens_to_sample=1000, 16 | ) 17 | print(res.completion) 18 | 19 | 20 | asyncio.run(main()) 21 | -------------------------------------------------------------------------------- /examples/text_completions_demo_sync.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S poetry run python 2 | 3 | import anthropic 4 | from anthropic import Anthropic 5 | 6 | 7 | def main() -> None: 8 | client = Anthropic() 9 | 10 | res = client.completions.create( 11 | model="claude-2.1", 12 | prompt=f"{anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? {anthropic.AI_PROMPT}", 13 | max_tokens_to_sample=1000, 14 | ) 15 | print(res.completion) 16 | 17 | 18 | main() 19 | -------------------------------------------------------------------------------- /examples/thinking.py: -------------------------------------------------------------------------------- 1 | import anthropic 2 | 3 | client = anthropic.Anthropic() 4 | 5 | response = client.messages.create( 6 | model="claude-3-7-sonnet-20250219", 7 | max_tokens=3200, 8 | thinking={"type": "enabled", "budget_tokens": 1600}, 9 | messages=[{"role": "user", "content": "Create a haiku about Anthropic."}], 10 | ) 11 | 12 | for block in response.content: 13 | if block.type == "thinking": 14 | print(f"Thinking: {block.thinking}") 15 | elif block.type == "text": 16 | print(f"Text: {block.text}") 17 | -------------------------------------------------------------------------------- /examples/thinking_stream.py: -------------------------------------------------------------------------------- 1 | import anthropic 2 | 3 | client = anthropic.Anthropic() 4 | 5 | with client.messages.stream( 6 | model="claude-3-7-sonnet-20250219", 7 | max_tokens=3200, 8 | thinking={"type": "enabled", "budget_tokens": 1600}, 9 | messages=[{"role": "user", "content": "Create a haiku about Anthropic."}], 10 | ) as stream: 11 | thinking = "not-started" 12 | 13 | for event in stream: 14 | if event.type == "thinking": 15 | if thinking == "not-started": 16 | print("Thinking:\n---------") 17 | thinking = "started" 18 | 19 | print(event.thinking, end="", flush=True) 20 | elif event.type == "text": 21 | if thinking != "finished": 22 | print("\n\nText:\n-----") 23 | thinking = "finished" 24 | 25 | print(event.text, end="", flush=True) 26 | -------------------------------------------------------------------------------- /examples/tools_stream.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | 3 | from anthropic import AsyncAnthropic 4 | 5 | client = AsyncAnthropic() 6 | 7 | 8 | async def main() -> None: 9 | async with client.messages.stream( 10 | max_tokens=1024, 11 | model="claude-3-5-sonnet-latest", 12 | tools=[ 13 | { 14 | "name": "get_weather", 15 | "description": "Get the weather at a specific location", 16 | "input_schema": { 17 | "type": "object", 18 | "properties": { 19 | "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, 20 | "unit": { 21 | "type": "string", 22 | "enum": ["celsius", "fahrenheit"], 23 | "description": "Unit for the output", 24 | }, 25 | }, 26 | "required": ["location"], 27 | }, 28 | } 29 | ], 30 | messages=[{"role": "user", "content": "What is the weather in SF?"}], 31 | ) as stream: 32 | async for event in stream: 33 | if event.type == "input_json": 34 | print(f"delta: {repr(event.partial_json)}") 35 | print(f"snapshot: {event.snapshot}") 36 | 37 | print() 38 | 39 | 40 | asyncio.run(main()) 41 | -------------------------------------------------------------------------------- /examples/vertex.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | 3 | from anthropic import AnthropicVertex, AsyncAnthropicVertex 4 | 5 | 6 | def sync_client() -> None: 7 | print("------ Sync Vertex ------") 8 | 9 | client = AnthropicVertex() 10 | 11 | message = client.messages.create( 12 | model="claude-3-sonnet@20240229", 13 | max_tokens=100, 14 | messages=[ 15 | { 16 | "role": "user", 17 | "content": "Hello!", 18 | } 19 | ], 20 | ) 21 | print(message.to_json()) 22 | 23 | 24 | async def async_client() -> None: 25 | print("------ Async Vertex ------") 26 | 27 | client = AsyncAnthropicVertex() 28 | 29 | message = await client.messages.create( 30 | model="claude-3-sonnet@20240229", 31 | max_tokens=1024, 32 | messages=[ 33 | { 34 | "role": "user", 35 | "content": "Hello!", 36 | } 37 | ], 38 | ) 39 | print(message.to_json()) 40 | 41 | 42 | sync_client() 43 | asyncio.run(async_client()) 44 | -------------------------------------------------------------------------------- /examples/web_search.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from anthropic import Anthropic 4 | 5 | client = Anthropic() 6 | 7 | # Create a message with web search enabled 8 | message = client.messages.create( 9 | model="claude-3-5-sonnet-latest", 10 | max_tokens=1024, 11 | messages=[{"role": "user", "content": "What's the weather in New York?"}], 12 | tools=[ 13 | { 14 | "name": "web_search", 15 | "type": "web_search_20250305", 16 | } 17 | ], 18 | ) 19 | 20 | # Print the full response 21 | print("\nFull response:") 22 | print(message.model_dump_json(indent=2)) 23 | 24 | # Extract and print the content 25 | print("\nResponse content:") 26 | for content_block in message.content: 27 | if content_block.type == "text": 28 | print(content_block.text) 29 | 30 | # Print usage information 31 | print("\nUsage statistics:") 32 | print(f"Input tokens: {message.usage.input_tokens}") 33 | print(f"Output tokens: {message.usage.output_tokens}") 34 | if message.usage.server_tool_use: 35 | print(f"Web search requests: {message.usage.server_tool_use.web_search_requests}") 36 | -------------------------------------------------------------------------------- /scripts/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then 8 | brew bundle check >/dev/null 2>&1 || { 9 | echo "==> Installing Homebrew dependencies…" 10 | brew bundle 11 | } 12 | fi 13 | 14 | echo "==> Installing Python…" 15 | uv python install 16 | 17 | echo "==> Installing Python dependencies…" 18 | uv sync --all-extras 19 | 20 | echo "==> Exporting Python dependencies…" 21 | # note: `--no-hashes` is required because of https://github.com/pypa/pip/issues/4995 22 | uv export -o requirements-dev.lock --no-hashes 23 | -------------------------------------------------------------------------------- /scripts/format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | echo "==> Running ruff" 8 | uv run ruff format 9 | uv run ruff check --fix . 10 | # run formatting again to fix any inconsistencies when imports are stripped 11 | uv run ruff format 12 | 13 | echo "==> Formatting docs" 14 | uv run python scripts/utils/ruffen-docs.py README.md api.md 15 | -------------------------------------------------------------------------------- /scripts/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | echo "==> Running ruff" 8 | uv run ruff check . 9 | 10 | echo "==> Running pyright" 11 | uv run pyright 12 | 13 | echo "==> Running mypy" 14 | uv run mypy . 15 | 16 | echo "==> Making sure it imports" 17 | uv run python -c 'import anthropic' 18 | -------------------------------------------------------------------------------- /scripts/mock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | if [[ -n "$1" && "$1" != '--'* ]]; then 8 | URL="$1" 9 | shift 10 | else 11 | URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" 12 | fi 13 | 14 | # Check if the URL is empty 15 | if [ -z "$URL" ]; then 16 | echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" 17 | exit 1 18 | fi 19 | 20 | echo "==> Starting mock server with URL ${URL}" 21 | 22 | # Run prism mock on the given spec 23 | if [ "$1" == "--daemon" ]; then 24 | npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log & 25 | 26 | # Wait for server to come online 27 | echo -n "Waiting for server" 28 | while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do 29 | echo -n "." 30 | sleep 0.1 31 | done 32 | 33 | if grep -q "✖ fatal" ".prism.log"; then 34 | cat .prism.log 35 | exit 1 36 | fi 37 | 38 | echo 39 | else 40 | npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" 41 | fi 42 | -------------------------------------------------------------------------------- /scripts/utils/upload-artifact.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -exuo pipefail 3 | 4 | RESPONSE=$(curl -X POST "$URL" \ 5 | -H "Authorization: Bearer $AUTH" \ 6 | -H "Content-Type: application/json") 7 | 8 | SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url') 9 | 10 | if [[ "$SIGNED_URL" == "null" ]]; then 11 | echo -e "\033[31mFailed to get signed URL.\033[0m" 12 | exit 1 13 | fi 14 | 15 | UPLOAD_RESPONSE=$(tar -cz . | curl -v -X PUT \ 16 | -H "Content-Type: application/gzip" \ 17 | --data-binary @- "$SIGNED_URL" 2>&1) 18 | 19 | if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then 20 | echo -e "\033[32mUploaded build to Stainless storage.\033[0m" 21 | echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/anthropic-python/$SHA'\033[0m" 22 | else 23 | echo -e "\033[31mFailed to upload artifact.\033[0m" 24 | exit 1 25 | fi 26 | -------------------------------------------------------------------------------- /src/anthropic/_constants.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | import httpx 4 | 5 | RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response" 6 | OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to" 7 | 8 | # default timeout is 10 minutes 9 | DEFAULT_TIMEOUT = httpx.Timeout(timeout=10 * 60, connect=5.0) 10 | DEFAULT_MAX_RETRIES = 2 11 | DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=1000, max_keepalive_connections=100) 12 | 13 | INITIAL_RETRY_DELAY = 0.5 14 | MAX_RETRY_DELAY = 8.0 15 | 16 | HUMAN_PROMPT = "\n\nHuman:" 17 | 18 | AI_PROMPT = "\n\nAssistant:" 19 | 20 | MODEL_NONSTREAMING_TOKENS = { 21 | "claude-opus-4-20250514": 8_192, 22 | "claude-opus-4-0": 8_192, 23 | "claude-4-opus-20250514": 8_192, 24 | "anthropic.claude-opus-4-20250514-v1:0": 8_192, 25 | "claude-opus-4@20250514": 8_192, 26 | } 27 | -------------------------------------------------------------------------------- /src/anthropic/_resource.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | import time 6 | 7 | import anyio 8 | 9 | from ._base_client import SyncAPIClient, AsyncAPIClient 10 | 11 | 12 | class SyncAPIResource: 13 | _client: SyncAPIClient 14 | 15 | def __init__(self, client: SyncAPIClient) -> None: 16 | self._client = client 17 | self._get = client.get 18 | self._post = client.post 19 | self._patch = client.patch 20 | self._put = client.put 21 | self._delete = client.delete 22 | self._get_api_list = client.get_api_list 23 | 24 | def _sleep(self, seconds: float) -> None: 25 | time.sleep(seconds) 26 | 27 | 28 | class AsyncAPIResource: 29 | _client: AsyncAPIClient 30 | 31 | def __init__(self, client: AsyncAPIClient) -> None: 32 | self._client = client 33 | self._get = client.get 34 | self._post = client.post 35 | self._patch = client.patch 36 | self._put = client.put 37 | self._delete = client.delete 38 | self._get_api_list = client.get_api_list 39 | 40 | async def _sleep(self, seconds: float) -> None: 41 | await anyio.sleep(seconds) 42 | -------------------------------------------------------------------------------- /src/anthropic/_utils/_logs.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | 4 | logger: logging.Logger = logging.getLogger("anthropic") 5 | httpx_logger: logging.Logger = logging.getLogger("httpx") 6 | 7 | 8 | def _basic_config() -> None: 9 | # e.g. [2023-10-05 14:12:26 - anthropic._base_client:818 - DEBUG] HTTP Request: POST http://127.0.0.1:4010/foo/bar "200 OK" 10 | logging.basicConfig( 11 | format="[%(asctime)s - %(name)s:%(lineno)d - %(levelname)s] %(message)s", 12 | datefmt="%Y-%m-%d %H:%M:%S", 13 | ) 14 | 15 | 16 | def setup_logging() -> None: 17 | env = os.environ.get("ANTHROPIC_LOG") 18 | if env == "debug": 19 | _basic_config() 20 | logger.setLevel(logging.DEBUG) 21 | httpx_logger.setLevel(logging.DEBUG) 22 | elif env == "info": 23 | _basic_config() 24 | logger.setLevel(logging.INFO) 25 | httpx_logger.setLevel(logging.INFO) 26 | -------------------------------------------------------------------------------- /src/anthropic/_utils/_resources_proxy.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any 4 | from typing_extensions import override 5 | 6 | from ._proxy import LazyProxy 7 | 8 | 9 | class ResourcesProxy(LazyProxy[Any]): 10 | """A proxy for the `anthropic.resources` module. 11 | 12 | This is used so that we can lazily import `anthropic.resources` only when 13 | needed *and* so that users can just import `anthropic` and reference `anthropic.resources` 14 | """ 15 | 16 | @override 17 | def __load__(self) -> Any: 18 | import importlib 19 | 20 | mod = importlib.import_module("anthropic.resources") 21 | return mod 22 | 23 | 24 | resources = ResourcesProxy().__as_proxied__() 25 | -------------------------------------------------------------------------------- /src/anthropic/_utils/_streams.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from typing_extensions import Iterator, AsyncIterator 3 | 4 | 5 | def consume_sync_iterator(iterator: Iterator[Any]) -> None: 6 | for _ in iterator: 7 | ... 8 | 9 | 10 | async def consume_async_iterator(iterator: AsyncIterator[Any]) -> None: 11 | async for _ in iterator: 12 | ... 13 | -------------------------------------------------------------------------------- /src/anthropic/_version.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | __title__ = "anthropic" 4 | __version__ = "0.52.2" # x-release-please-version 5 | -------------------------------------------------------------------------------- /src/anthropic/lib/.keep: -------------------------------------------------------------------------------- 1 | File generated from our OpenAPI spec by Stainless. 2 | 3 | This directory can be used to store custom files to expand the SDK. 4 | It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. -------------------------------------------------------------------------------- /src/anthropic/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthropics/anthropic-sdk-python/a1f61dd577cc78b2a4c26bc4eb80a875eca4aee6/src/anthropic/lib/__init__.py -------------------------------------------------------------------------------- /src/anthropic/lib/_extras/__init__.py: -------------------------------------------------------------------------------- 1 | from ._google_auth import google_auth as google_auth 2 | -------------------------------------------------------------------------------- /src/anthropic/lib/_extras/_common.py: -------------------------------------------------------------------------------- 1 | from ..._exceptions import AnthropicError 2 | 3 | INSTRUCTIONS = """ 4 | 5 | Anthropic error: missing required dependency `{library}`. 6 | 7 | $ pip install anthropic[{extra}] 8 | """ 9 | 10 | 11 | class MissingDependencyError(AnthropicError): 12 | def __init__(self, *, library: str, extra: str) -> None: 13 | super().__init__(INSTRUCTIONS.format(library=library, extra=extra)) 14 | -------------------------------------------------------------------------------- /src/anthropic/lib/_extras/_google_auth.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import TYPE_CHECKING, Any 4 | from typing_extensions import ClassVar, override 5 | 6 | from ._common import MissingDependencyError 7 | from ..._utils import LazyProxy 8 | 9 | if TYPE_CHECKING: 10 | import google.auth # type: ignore 11 | 12 | google_auth = google.auth 13 | 14 | 15 | class GoogleAuthProxy(LazyProxy[Any]): 16 | should_cache: ClassVar[bool] = True 17 | 18 | @override 19 | def __load__(self) -> Any: 20 | try: 21 | import google.auth # type: ignore 22 | except ImportError as err: 23 | raise MissingDependencyError(extra="vertex", library="google-auth") from err 24 | 25 | return google.auth 26 | 27 | 28 | if not TYPE_CHECKING: 29 | google_auth = GoogleAuthProxy() 30 | -------------------------------------------------------------------------------- /src/anthropic/lib/bedrock/__init__.py: -------------------------------------------------------------------------------- 1 | from ._client import AnthropicBedrock as AnthropicBedrock, AsyncAnthropicBedrock as AsyncAnthropicBedrock 2 | -------------------------------------------------------------------------------- /src/anthropic/lib/bedrock/_stream.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import TypeVar 4 | 5 | import httpx 6 | 7 | from ..._client import Anthropic, AsyncAnthropic 8 | from ..._streaming import Stream, AsyncStream 9 | from ._stream_decoder import AWSEventStreamDecoder 10 | 11 | _T = TypeVar("_T") 12 | 13 | 14 | class BedrockStream(Stream[_T]): 15 | def __init__( 16 | self, 17 | *, 18 | cast_to: type[_T], 19 | response: httpx.Response, 20 | client: Anthropic, 21 | ) -> None: 22 | super().__init__(cast_to=cast_to, response=response, client=client) 23 | 24 | self._decoder = AWSEventStreamDecoder() 25 | 26 | 27 | class AsyncBedrockStream(AsyncStream[_T]): 28 | def __init__( 29 | self, 30 | *, 31 | cast_to: type[_T], 32 | response: httpx.Response, 33 | client: AsyncAnthropic, 34 | ) -> None: 35 | super().__init__(cast_to=cast_to, response=response, client=client) 36 | 37 | self._decoder = AWSEventStreamDecoder() 38 | -------------------------------------------------------------------------------- /src/anthropic/lib/streaming/__init__.py: -------------------------------------------------------------------------------- 1 | from ._types import ( 2 | TextEvent as TextEvent, 3 | InputJsonEvent as InputJsonEvent, 4 | MessageStopEvent as MessageStopEvent, 5 | MessageStreamEvent as MessageStreamEvent, 6 | ContentBlockStopEvent as ContentBlockStopEvent, 7 | ) 8 | from ._messages import ( 9 | MessageStream as MessageStream, 10 | AsyncMessageStream as AsyncMessageStream, 11 | MessageStreamManager as MessageStreamManager, 12 | AsyncMessageStreamManager as AsyncMessageStreamManager, 13 | ) 14 | from ._beta_types import ( 15 | BetaTextEvent as BetaTextEvent, 16 | BetaInputJsonEvent as BetaInputJsonEvent, 17 | BetaMessageStopEvent as BetaMessageStopEvent, 18 | BetaMessageStreamEvent as BetaMessageStreamEvent, 19 | BetaContentBlockStopEvent as BetaContentBlockStopEvent, 20 | ) 21 | from ._beta_messages import ( 22 | BetaMessageStream as BetaMessageStream, 23 | BetaAsyncMessageStream as BetaAsyncMessageStream, 24 | BetaMessageStreamManager as BetaMessageStreamManager, 25 | BetaAsyncMessageStreamManager as BetaAsyncMessageStreamManager, 26 | ) 27 | -------------------------------------------------------------------------------- /src/anthropic/lib/vertex/__init__.py: -------------------------------------------------------------------------------- 1 | from ._client import AnthropicVertex as AnthropicVertex, AsyncAnthropicVertex as AsyncAnthropicVertex 2 | -------------------------------------------------------------------------------- /src/anthropic/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthropics/anthropic-sdk-python/a1f61dd577cc78b2a4c26bc4eb80a875eca4aee6/src/anthropic/py.typed -------------------------------------------------------------------------------- /src/anthropic/resources/beta/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .batches import ( 4 | Batches, 5 | AsyncBatches, 6 | BatchesWithRawResponse, 7 | AsyncBatchesWithRawResponse, 8 | BatchesWithStreamingResponse, 9 | AsyncBatchesWithStreamingResponse, 10 | ) 11 | from .messages import ( 12 | Messages, 13 | AsyncMessages, 14 | MessagesWithRawResponse, 15 | AsyncMessagesWithRawResponse, 16 | MessagesWithStreamingResponse, 17 | AsyncMessagesWithStreamingResponse, 18 | ) 19 | 20 | __all__ = [ 21 | "Batches", 22 | "AsyncBatches", 23 | "BatchesWithRawResponse", 24 | "AsyncBatchesWithRawResponse", 25 | "BatchesWithStreamingResponse", 26 | "AsyncBatchesWithStreamingResponse", 27 | "Messages", 28 | "AsyncMessages", 29 | "MessagesWithRawResponse", 30 | "AsyncMessagesWithRawResponse", 31 | "MessagesWithStreamingResponse", 32 | "AsyncMessagesWithStreamingResponse", 33 | ] 34 | -------------------------------------------------------------------------------- /src/anthropic/resources/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .batches import ( 4 | Batches, 5 | AsyncBatches, 6 | BatchesWithRawResponse, 7 | AsyncBatchesWithRawResponse, 8 | BatchesWithStreamingResponse, 9 | AsyncBatchesWithStreamingResponse, 10 | ) 11 | from .messages import ( 12 | DEPRECATED_MODELS, 13 | Messages, 14 | AsyncMessages, 15 | MessagesWithRawResponse, 16 | AsyncMessagesWithRawResponse, 17 | MessagesWithStreamingResponse, 18 | AsyncMessagesWithStreamingResponse, 19 | ) 20 | 21 | __all__ = [ 22 | "Batches", 23 | "AsyncBatches", 24 | "BatchesWithRawResponse", 25 | "AsyncBatchesWithRawResponse", 26 | "BatchesWithStreamingResponse", 27 | "AsyncBatchesWithStreamingResponse", 28 | "Messages", 29 | "AsyncMessages", 30 | "MessagesWithRawResponse", 31 | "AsyncMessagesWithRawResponse", 32 | "MessagesWithStreamingResponse", 33 | "AsyncMessagesWithStreamingResponse", 34 | "DEPRECATED_MODELS", 35 | ] 36 | -------------------------------------------------------------------------------- /src/anthropic/types/anthropic_beta_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import Literal, TypeAlias 7 | 8 | __all__ = ["AnthropicBetaParam"] 9 | 10 | AnthropicBetaParam: TypeAlias = Union[ 11 | str, 12 | Literal[ 13 | "message-batches-2024-09-24", 14 | "prompt-caching-2024-07-31", 15 | "computer-use-2024-10-22", 16 | "computer-use-2025-01-24", 17 | "pdfs-2024-09-25", 18 | "token-counting-2024-11-01", 19 | "token-efficient-tools-2025-02-19", 20 | "output-128k-2025-02-19", 21 | "files-api-2025-04-14", 22 | "mcp-client-2025-04-04", 23 | "dev-full-thinking-2025-05-14", 24 | "interleaved-thinking-2025-05-14", 25 | "code-execution-2025-05-22", 26 | "extended-cache-ttl-2025-04-11", 27 | ], 28 | ] 29 | -------------------------------------------------------------------------------- /src/anthropic/types/base64_image_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import Literal, Required, Annotated, TypedDict 7 | 8 | from .._types import Base64FileInput 9 | from .._utils import PropertyInfo 10 | from .._models import set_pydantic_config 11 | 12 | __all__ = ["Base64ImageSourceParam"] 13 | 14 | 15 | class Base64ImageSourceParam(TypedDict, total=False): 16 | data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]] 17 | 18 | media_type: Required[Literal["image/jpeg", "image/png", "image/gif", "image/webp"]] 19 | 20 | type: Required[Literal["base64"]] 21 | 22 | 23 | set_pydantic_config(Base64ImageSourceParam, {"arbitrary_types_allowed": True}) 24 | -------------------------------------------------------------------------------- /src/anthropic/types/base64_pdf_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import Literal, Required, Annotated, TypedDict 7 | 8 | from .._types import Base64FileInput 9 | from .._utils import PropertyInfo 10 | from .._models import set_pydantic_config 11 | 12 | __all__ = ["Base64PDFSourceParam"] 13 | 14 | 15 | class Base64PDFSourceParam(TypedDict, total=False): 16 | data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]] 17 | 18 | media_type: Required[Literal["application/pdf"]] 19 | 20 | type: Required[Literal["base64"]] 21 | 22 | 23 | set_pydantic_config(Base64PDFSourceParam, {"arbitrary_types_allowed": True}) 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_base64_image_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import Literal, Required, Annotated, TypedDict 7 | 8 | from ..._types import Base64FileInput 9 | from ..._utils import PropertyInfo 10 | from ..._models import set_pydantic_config 11 | 12 | __all__ = ["BetaBase64ImageSourceParam"] 13 | 14 | 15 | class BetaBase64ImageSourceParam(TypedDict, total=False): 16 | data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]] 17 | 18 | media_type: Required[Literal["image/jpeg", "image/png", "image/gif", "image/webp"]] 19 | 20 | type: Required[Literal["base64"]] 21 | 22 | 23 | set_pydantic_config(BetaBase64ImageSourceParam, {"arbitrary_types_allowed": True}) 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_base64_pdf_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Optional 6 | from typing_extensions import Literal, Required, TypeAlias, TypedDict 7 | 8 | from .beta_url_pdf_source_param import BetaURLPDFSourceParam 9 | from .beta_citations_config_param import BetaCitationsConfigParam 10 | from .beta_base64_pdf_source_param import BetaBase64PDFSourceParam 11 | from .beta_plain_text_source_param import BetaPlainTextSourceParam 12 | from .beta_content_block_source_param import BetaContentBlockSourceParam 13 | from .beta_file_document_source_param import BetaFileDocumentSourceParam 14 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 15 | 16 | __all__ = ["BetaBase64PDFBlockParam", "Source"] 17 | 18 | Source: TypeAlias = Union[ 19 | BetaBase64PDFSourceParam, 20 | BetaPlainTextSourceParam, 21 | BetaContentBlockSourceParam, 22 | BetaURLPDFSourceParam, 23 | BetaFileDocumentSourceParam, 24 | ] 25 | 26 | 27 | class BetaBase64PDFBlockParam(TypedDict, total=False): 28 | source: Required[Source] 29 | 30 | type: Required[Literal["document"]] 31 | 32 | cache_control: Optional[BetaCacheControlEphemeralParam] 33 | """Create a cache control breakpoint at this content block.""" 34 | 35 | citations: BetaCitationsConfigParam 36 | 37 | context: Optional[str] 38 | 39 | title: Optional[str] 40 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_base64_pdf_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import Literal, Required, Annotated, TypedDict 7 | 8 | from ..._types import Base64FileInput 9 | from ..._utils import PropertyInfo 10 | from ..._models import set_pydantic_config 11 | 12 | __all__ = ["BetaBase64PDFSourceParam"] 13 | 14 | 15 | class BetaBase64PDFSourceParam(TypedDict, total=False): 16 | data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]] 17 | 18 | media_type: Required[Literal["application/pdf"]] 19 | 20 | type: Required[Literal["base64"]] 21 | 22 | 23 | set_pydantic_config(BetaBase64PDFSourceParam, {"arbitrary_types_allowed": True}) 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_cache_control_ephemeral_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaCacheControlEphemeralParam"] 8 | 9 | 10 | class BetaCacheControlEphemeralParam(TypedDict, total=False): 11 | type: Required[Literal["ephemeral"]] 12 | 13 | ttl: Literal["5m", "1h"] 14 | """The time-to-live for the cache control breakpoint. 15 | 16 | This may be one the following values: 17 | 18 | - `5m`: 5 minutes 19 | - `1h`: 1 hour 20 | 21 | Defaults to `5m`. 22 | """ 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_cache_creation.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ..._models import BaseModel 4 | 5 | __all__ = ["BetaCacheCreation"] 6 | 7 | 8 | class BetaCacheCreation(BaseModel): 9 | ephemeral_1h_input_tokens: int 10 | """The number of input tokens used to create the 1 hour cache entry.""" 11 | 12 | ephemeral_5m_input_tokens: int 13 | """The number of input tokens used to create the 5 minute cache entry.""" 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_char_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["BetaCitationCharLocation"] 9 | 10 | 11 | class BetaCitationCharLocation(BaseModel): 12 | cited_text: str 13 | 14 | document_index: int 15 | 16 | document_title: Optional[str] = None 17 | 18 | end_char_index: int 19 | 20 | start_char_index: int 21 | 22 | type: Literal["char_location"] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_char_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["BetaCitationCharLocationParam"] 9 | 10 | 11 | class BetaCitationCharLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | document_index: Required[int] 15 | 16 | document_title: Required[Optional[str]] 17 | 18 | end_char_index: Required[int] 19 | 20 | start_char_index: Required[int] 21 | 22 | type: Required[Literal["char_location"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_content_block_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["BetaCitationContentBlockLocation"] 9 | 10 | 11 | class BetaCitationContentBlockLocation(BaseModel): 12 | cited_text: str 13 | 14 | document_index: int 15 | 16 | document_title: Optional[str] = None 17 | 18 | end_block_index: int 19 | 20 | start_block_index: int 21 | 22 | type: Literal["content_block_location"] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_content_block_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["BetaCitationContentBlockLocationParam"] 9 | 10 | 11 | class BetaCitationContentBlockLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | document_index: Required[int] 15 | 16 | document_title: Required[Optional[str]] 17 | 18 | end_block_index: Required[int] 19 | 20 | start_block_index: Required[int] 21 | 22 | type: Required[Literal["content_block_location"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_page_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["BetaCitationPageLocation"] 9 | 10 | 11 | class BetaCitationPageLocation(BaseModel): 12 | cited_text: str 13 | 14 | document_index: int 15 | 16 | document_title: Optional[str] = None 17 | 18 | end_page_number: int 19 | 20 | start_page_number: int 21 | 22 | type: Literal["page_location"] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_page_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["BetaCitationPageLocationParam"] 9 | 10 | 11 | class BetaCitationPageLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | document_index: Required[int] 15 | 16 | document_title: Required[Optional[str]] 17 | 18 | end_page_number: Required[int] 19 | 20 | start_page_number: Required[int] 21 | 22 | type: Required[Literal["page_location"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citation_web_search_result_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["BetaCitationWebSearchResultLocationParam"] 9 | 10 | 11 | class BetaCitationWebSearchResultLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | encrypted_index: Required[str] 15 | 16 | title: Required[Optional[str]] 17 | 18 | type: Required[Literal["web_search_result_location"]] 19 | 20 | url: Required[str] 21 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citations_config_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import TypedDict 6 | 7 | __all__ = ["BetaCitationsConfigParam"] 8 | 9 | 10 | class BetaCitationsConfigParam(TypedDict, total=False): 11 | enabled: bool 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citations_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Literal, Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from ..._models import BaseModel 8 | from .beta_citation_char_location import BetaCitationCharLocation 9 | from .beta_citation_page_location import BetaCitationPageLocation 10 | from .beta_citation_content_block_location import BetaCitationContentBlockLocation 11 | from .beta_citations_web_search_result_location import BetaCitationsWebSearchResultLocation 12 | 13 | __all__ = ["BetaCitationsDelta", "Citation"] 14 | 15 | Citation: TypeAlias = Annotated[ 16 | Union[ 17 | BetaCitationCharLocation, 18 | BetaCitationPageLocation, 19 | BetaCitationContentBlockLocation, 20 | BetaCitationsWebSearchResultLocation, 21 | ], 22 | PropertyInfo(discriminator="type"), 23 | ] 24 | 25 | 26 | class BetaCitationsDelta(BaseModel): 27 | citation: Citation 28 | 29 | type: Literal["citations_delta"] 30 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_citations_web_search_result_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["BetaCitationsWebSearchResultLocation"] 9 | 10 | 11 | class BetaCitationsWebSearchResultLocation(BaseModel): 12 | cited_text: str 13 | 14 | encrypted_index: str 15 | 16 | title: Optional[str] = None 17 | 18 | type: Literal["web_search_result_location"] 19 | 20 | url: str 21 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_output_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaCodeExecutionOutputBlock"] 8 | 9 | 10 | class BetaCodeExecutionOutputBlock(BaseModel): 11 | file_id: str 12 | 13 | type: Literal["code_execution_output"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_output_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaCodeExecutionOutputBlockParam"] 8 | 9 | 10 | class BetaCodeExecutionOutputBlockParam(TypedDict, total=False): 11 | file_id: Required[str] 12 | 13 | type: Required[Literal["code_execution_output"]] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import List 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | from .beta_code_execution_output_block import BetaCodeExecutionOutputBlock 8 | 9 | __all__ = ["BetaCodeExecutionResultBlock"] 10 | 11 | 12 | class BetaCodeExecutionResultBlock(BaseModel): 13 | content: List[BetaCodeExecutionOutputBlock] 14 | 15 | return_code: int 16 | 17 | stderr: str 18 | 19 | stdout: str 20 | 21 | type: Literal["code_execution_result"] 22 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Iterable 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_code_execution_output_block_param import BetaCodeExecutionOutputBlockParam 9 | 10 | __all__ = ["BetaCodeExecutionResultBlockParam"] 11 | 12 | 13 | class BetaCodeExecutionResultBlockParam(TypedDict, total=False): 14 | content: Required[Iterable[BetaCodeExecutionOutputBlockParam]] 15 | 16 | return_code: Required[int] 17 | 18 | stderr: Required[str] 19 | 20 | stdout: Required[str] 21 | 22 | type: Required[Literal["code_execution_result"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_20250522_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaCodeExecutionTool20250522Param"] 11 | 12 | 13 | class BetaCodeExecutionTool20250522Param(TypedDict, total=False): 14 | name: Required[Literal["code_execution"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["code_execution_20250522"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .beta_code_execution_tool_result_block_content import BetaCodeExecutionToolResultBlockContent 7 | 8 | __all__ = ["BetaCodeExecutionToolResultBlock"] 9 | 10 | 11 | class BetaCodeExecutionToolResultBlock(BaseModel): 12 | content: BetaCodeExecutionToolResultBlockContent 13 | 14 | tool_use_id: str 15 | 16 | type: Literal["code_execution_tool_result"] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_block_content.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import TypeAlias 5 | 6 | from .beta_code_execution_result_block import BetaCodeExecutionResultBlock 7 | from .beta_code_execution_tool_result_error import BetaCodeExecutionToolResultError 8 | 9 | __all__ = ["BetaCodeExecutionToolResultBlockContent"] 10 | 11 | BetaCodeExecutionToolResultBlockContent: TypeAlias = Union[ 12 | BetaCodeExecutionToolResultError, BetaCodeExecutionResultBlock 13 | ] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | from .beta_code_execution_tool_result_block_param_content_param import BetaCodeExecutionToolResultBlockParamContentParam 10 | 11 | __all__ = ["BetaCodeExecutionToolResultBlockParam"] 12 | 13 | 14 | class BetaCodeExecutionToolResultBlockParam(TypedDict, total=False): 15 | content: Required[BetaCodeExecutionToolResultBlockParamContentParam] 16 | 17 | tool_use_id: Required[str] 18 | 19 | type: Required[Literal["code_execution_tool_result"]] 20 | 21 | cache_control: Optional[BetaCacheControlEphemeralParam] 22 | """Create a cache control breakpoint at this content block.""" 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_block_param_content_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .beta_code_execution_result_block_param import BetaCodeExecutionResultBlockParam 9 | from .beta_code_execution_tool_result_error_param import BetaCodeExecutionToolResultErrorParam 10 | 11 | __all__ = ["BetaCodeExecutionToolResultBlockParamContentParam"] 12 | 13 | BetaCodeExecutionToolResultBlockParamContentParam: TypeAlias = Union[ 14 | BetaCodeExecutionToolResultErrorParam, BetaCodeExecutionResultBlockParam 15 | ] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .beta_code_execution_tool_result_error_code import BetaCodeExecutionToolResultErrorCode 7 | 8 | __all__ = ["BetaCodeExecutionToolResultError"] 9 | 10 | 11 | class BetaCodeExecutionToolResultError(BaseModel): 12 | error_code: BetaCodeExecutionToolResultErrorCode 13 | 14 | type: Literal["code_execution_tool_result_error"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_error_code.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal, TypeAlias 4 | 5 | __all__ = ["BetaCodeExecutionToolResultErrorCode"] 6 | 7 | BetaCodeExecutionToolResultErrorCode: TypeAlias = Literal[ 8 | "invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded" 9 | ] 10 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_code_execution_tool_result_error_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | from .beta_code_execution_tool_result_error_code import BetaCodeExecutionToolResultErrorCode 8 | 9 | __all__ = ["BetaCodeExecutionToolResultErrorParam"] 10 | 11 | 12 | class BetaCodeExecutionToolResultErrorParam(TypedDict, total=False): 13 | error_code: Required[BetaCodeExecutionToolResultErrorCode] 14 | 15 | type: Required[Literal["code_execution_tool_result_error"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_container.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from datetime import datetime 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaContainer"] 8 | 9 | 10 | class BetaContainer(BaseModel): 11 | id: str 12 | """Identifier for the container used in this request""" 13 | 14 | expires_at: datetime 15 | """The time at which the container will expire.""" 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_container_upload_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaContainerUploadBlock"] 8 | 9 | 10 | class BetaContainerUploadBlock(BaseModel): 11 | file_id: str 12 | 13 | type: Literal["container_upload"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_container_upload_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaContainerUploadBlockParam"] 11 | 12 | 13 | class BetaContainerUploadBlockParam(TypedDict, total=False): 14 | file_id: Required[str] 15 | 16 | type: Required[Literal["container_upload"]] 17 | 18 | cache_control: Optional[BetaCacheControlEphemeralParam] 19 | """Create a cache control breakpoint at this content block.""" 20 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_content_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from .beta_text_block import BetaTextBlock 8 | from .beta_thinking_block import BetaThinkingBlock 9 | from .beta_tool_use_block import BetaToolUseBlock 10 | from .beta_mcp_tool_use_block import BetaMCPToolUseBlock 11 | from .beta_mcp_tool_result_block import BetaMCPToolResultBlock 12 | from .beta_server_tool_use_block import BetaServerToolUseBlock 13 | from .beta_container_upload_block import BetaContainerUploadBlock 14 | from .beta_redacted_thinking_block import BetaRedactedThinkingBlock 15 | from .beta_web_search_tool_result_block import BetaWebSearchToolResultBlock 16 | from .beta_code_execution_tool_result_block import BetaCodeExecutionToolResultBlock 17 | 18 | __all__ = ["BetaContentBlock"] 19 | 20 | BetaContentBlock: TypeAlias = Annotated[ 21 | Union[ 22 | BetaTextBlock, 23 | BetaToolUseBlock, 24 | BetaServerToolUseBlock, 25 | BetaWebSearchToolResultBlock, 26 | BetaCodeExecutionToolResultBlock, 27 | BetaMCPToolUseBlock, 28 | BetaMCPToolResultBlock, 29 | BetaContainerUploadBlock, 30 | BetaThinkingBlock, 31 | BetaRedactedThinkingBlock, 32 | ], 33 | PropertyInfo(discriminator="type"), 34 | ] 35 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_content_block_source_content_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .beta_text_block_param import BetaTextBlockParam 9 | from .beta_image_block_param import BetaImageBlockParam 10 | 11 | __all__ = ["BetaContentBlockSourceContentParam"] 12 | 13 | BetaContentBlockSourceContentParam: TypeAlias = Union[BetaTextBlockParam, BetaImageBlockParam] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_content_block_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_content_block_source_content_param import BetaContentBlockSourceContentParam 9 | 10 | __all__ = ["BetaContentBlockSourceParam"] 11 | 12 | 13 | class BetaContentBlockSourceParam(TypedDict, total=False): 14 | content: Required[Union[str, Iterable[BetaContentBlockSourceContentParam]]] 15 | 16 | type: Required[Literal["content"]] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_file_document_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaFileDocumentSourceParam"] 8 | 9 | 10 | class BetaFileDocumentSourceParam(TypedDict, total=False): 11 | file_id: Required[str] 12 | 13 | type: Required[Literal["file"]] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_file_image_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaFileImageSourceParam"] 8 | 9 | 10 | class BetaFileImageSourceParam(TypedDict, total=False): 11 | file_id: Required[str] 12 | 13 | type: Required[Literal["file"]] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_image_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Optional 6 | from typing_extensions import Literal, Required, TypeAlias, TypedDict 7 | 8 | from .beta_url_image_source_param import BetaURLImageSourceParam 9 | from .beta_file_image_source_param import BetaFileImageSourceParam 10 | from .beta_base64_image_source_param import BetaBase64ImageSourceParam 11 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 12 | 13 | __all__ = ["BetaImageBlockParam", "Source"] 14 | 15 | Source: TypeAlias = Union[BetaBase64ImageSourceParam, BetaURLImageSourceParam, BetaFileImageSourceParam] 16 | 17 | 18 | class BetaImageBlockParam(TypedDict, total=False): 19 | source: Required[Source] 20 | 21 | type: Required[Literal["image"]] 22 | 23 | cache_control: Optional[BetaCacheControlEphemeralParam] 24 | """Create a cache control breakpoint at this content block.""" 25 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_input_json_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaInputJSONDelta"] 8 | 9 | 10 | class BetaInputJSONDelta(BaseModel): 11 | partial_json: str 12 | 13 | type: Literal["input_json_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_mcp_tool_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import List, Union 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | from .beta_text_block import BetaTextBlock 8 | 9 | __all__ = ["BetaMCPToolResultBlock"] 10 | 11 | 12 | class BetaMCPToolResultBlock(BaseModel): 13 | content: Union[str, List[BetaTextBlock]] 14 | 15 | is_error: bool 16 | 17 | tool_use_id: str 18 | 19 | type: Literal["mcp_tool_result"] 20 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_mcp_tool_use_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaMCPToolUseBlock"] 8 | 9 | 10 | class BetaMCPToolUseBlock(BaseModel): 11 | id: str 12 | 13 | input: object 14 | 15 | name: str 16 | """The name of the MCP tool""" 17 | 18 | server_name: str 19 | """The name of the MCP server""" 20 | 21 | type: Literal["mcp_tool_use"] 22 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_mcp_tool_use_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaMCPToolUseBlockParam"] 11 | 12 | 13 | class BetaMCPToolUseBlockParam(TypedDict, total=False): 14 | id: Required[str] 15 | 16 | input: Required[object] 17 | 18 | name: Required[str] 19 | 20 | server_name: Required[str] 21 | """The name of the MCP server""" 22 | 23 | type: Required[Literal["mcp_tool_use"]] 24 | 25 | cache_control: Optional[BetaCacheControlEphemeralParam] 26 | """Create a cache control breakpoint at this content block.""" 27 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_message_delta_usage.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | 5 | from ..._models import BaseModel 6 | from .beta_server_tool_usage import BetaServerToolUsage 7 | 8 | __all__ = ["BetaMessageDeltaUsage"] 9 | 10 | 11 | class BetaMessageDeltaUsage(BaseModel): 12 | cache_creation_input_tokens: Optional[int] = None 13 | """The cumulative number of input tokens used to create the cache entry.""" 14 | 15 | cache_read_input_tokens: Optional[int] = None 16 | """The cumulative number of input tokens read from the cache.""" 17 | 18 | input_tokens: Optional[int] = None 19 | """The cumulative number of input tokens which were used.""" 20 | 21 | output_tokens: int 22 | """The cumulative number of output tokens which were used.""" 23 | 24 | server_tool_use: Optional[BetaServerToolUsage] = None 25 | """The number of server tool requests.""" 26 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_message_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_content_block_param import BetaContentBlockParam 9 | 10 | __all__ = ["BetaMessageParam"] 11 | 12 | 13 | class BetaMessageParam(TypedDict, total=False): 14 | content: Required[Union[str, Iterable[BetaContentBlockParam]]] 15 | 16 | role: Required[Literal["user", "assistant"]] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_message_tokens_count.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ..._models import BaseModel 4 | 5 | __all__ = ["BetaMessageTokensCount"] 6 | 7 | 8 | class BetaMessageTokensCount(BaseModel): 9 | input_tokens: int 10 | """ 11 | The total number of tokens across the provided list of messages, system prompt, 12 | and tools. 13 | """ 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_metadata_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import TypedDict 7 | 8 | __all__ = ["BetaMetadataParam"] 9 | 10 | 11 | class BetaMetadataParam(TypedDict, total=False): 12 | user_id: Optional[str] 13 | """An external identifier for the user who is associated with the request. 14 | 15 | This should be a uuid, hash value, or other opaque identifier. Anthropic may use 16 | this id to help detect abuse. Do not include any identifying information such as 17 | name, email address, or phone number. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_model_info.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from datetime import datetime 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["BetaModelInfo"] 9 | 10 | 11 | class BetaModelInfo(BaseModel): 12 | id: str 13 | """Unique model identifier.""" 14 | 15 | created_at: datetime 16 | """RFC 3339 datetime string representing the time at which the model was released. 17 | 18 | May be set to an epoch value if the release date is unknown. 19 | """ 20 | 21 | display_name: str 22 | """A human-readable name for the model.""" 23 | 24 | type: Literal["model"] 25 | """Object type. 26 | 27 | For Models, this is always `"model"`. 28 | """ 29 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_plain_text_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaPlainTextSourceParam"] 8 | 9 | 10 | class BetaPlainTextSourceParam(TypedDict, total=False): 11 | data: Required[str] 12 | 13 | media_type: Required[Literal["text/plain"]] 14 | 15 | type: Required[Literal["text"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_raw_content_block_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from .beta_text_delta import BetaTextDelta 8 | from .beta_thinking_delta import BetaThinkingDelta 9 | from .beta_citations_delta import BetaCitationsDelta 10 | from .beta_signature_delta import BetaSignatureDelta 11 | from .beta_input_json_delta import BetaInputJSONDelta 12 | 13 | __all__ = ["BetaRawContentBlockDelta"] 14 | 15 | BetaRawContentBlockDelta: TypeAlias = Annotated[ 16 | Union[BetaTextDelta, BetaInputJSONDelta, BetaCitationsDelta, BetaThinkingDelta, BetaSignatureDelta], 17 | PropertyInfo(discriminator="type"), 18 | ] 19 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_raw_content_block_delta_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .beta_raw_content_block_delta import BetaRawContentBlockDelta 7 | 8 | __all__ = ["BetaRawContentBlockDeltaEvent"] 9 | 10 | 11 | class BetaRawContentBlockDeltaEvent(BaseModel): 12 | delta: BetaRawContentBlockDelta 13 | 14 | index: int 15 | 16 | type: Literal["content_block_delta"] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_raw_content_block_stop_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaRawContentBlockStopEvent"] 8 | 9 | 10 | class BetaRawContentBlockStopEvent(BaseModel): 11 | index: int 12 | 13 | type: Literal["content_block_stop"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_raw_message_start_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .beta_message import BetaMessage 7 | 8 | __all__ = ["BetaRawMessageStartEvent"] 9 | 10 | 11 | class BetaRawMessageStartEvent(BaseModel): 12 | message: BetaMessage 13 | 14 | type: Literal["message_start"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_raw_message_stop_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaRawMessageStopEvent"] 8 | 9 | 10 | class BetaRawMessageStopEvent(BaseModel): 11 | type: Literal["message_stop"] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_raw_message_stream_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from .beta_raw_message_stop_event import BetaRawMessageStopEvent 8 | from .beta_raw_message_delta_event import BetaRawMessageDeltaEvent 9 | from .beta_raw_message_start_event import BetaRawMessageStartEvent 10 | from .beta_raw_content_block_stop_event import BetaRawContentBlockStopEvent 11 | from .beta_raw_content_block_delta_event import BetaRawContentBlockDeltaEvent 12 | from .beta_raw_content_block_start_event import BetaRawContentBlockStartEvent 13 | 14 | __all__ = ["BetaRawMessageStreamEvent"] 15 | 16 | BetaRawMessageStreamEvent: TypeAlias = Annotated[ 17 | Union[ 18 | BetaRawMessageStartEvent, 19 | BetaRawMessageDeltaEvent, 20 | BetaRawMessageStopEvent, 21 | BetaRawContentBlockStartEvent, 22 | BetaRawContentBlockDeltaEvent, 23 | BetaRawContentBlockStopEvent, 24 | ], 25 | PropertyInfo(discriminator="type"), 26 | ] 27 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_redacted_thinking_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaRedactedThinkingBlock"] 8 | 9 | 10 | class BetaRedactedThinkingBlock(BaseModel): 11 | data: str 12 | 13 | type: Literal["redacted_thinking"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_redacted_thinking_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaRedactedThinkingBlockParam"] 8 | 9 | 10 | class BetaRedactedThinkingBlockParam(TypedDict, total=False): 11 | data: Required[str] 12 | 13 | type: Required[Literal["redacted_thinking"]] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_request_mcp_server_tool_configuration_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import List, Optional 6 | from typing_extensions import TypedDict 7 | 8 | __all__ = ["BetaRequestMCPServerToolConfigurationParam"] 9 | 10 | 11 | class BetaRequestMCPServerToolConfigurationParam(TypedDict, total=False): 12 | allowed_tools: Optional[List[str]] 13 | 14 | enabled: Optional[bool] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_request_mcp_server_url_definition_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_request_mcp_server_tool_configuration_param import BetaRequestMCPServerToolConfigurationParam 9 | 10 | __all__ = ["BetaRequestMCPServerURLDefinitionParam"] 11 | 12 | 13 | class BetaRequestMCPServerURLDefinitionParam(TypedDict, total=False): 14 | name: Required[str] 15 | 16 | type: Required[Literal["url"]] 17 | 18 | url: Required[str] 19 | 20 | authorization_token: Optional[str] 21 | 22 | tool_configuration: Optional[BetaRequestMCPServerToolConfigurationParam] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_request_mcp_tool_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable, Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_text_block_param import BetaTextBlockParam 9 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 10 | 11 | __all__ = ["BetaRequestMCPToolResultBlockParam"] 12 | 13 | 14 | class BetaRequestMCPToolResultBlockParam(TypedDict, total=False): 15 | tool_use_id: Required[str] 16 | 17 | type: Required[Literal["mcp_tool_result"]] 18 | 19 | cache_control: Optional[BetaCacheControlEphemeralParam] 20 | """Create a cache control breakpoint at this content block.""" 21 | 22 | content: Union[str, Iterable[BetaTextBlockParam]] 23 | 24 | is_error: bool 25 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_server_tool_usage.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ..._models import BaseModel 4 | 5 | __all__ = ["BetaServerToolUsage"] 6 | 7 | 8 | class BetaServerToolUsage(BaseModel): 9 | web_search_requests: int 10 | """The number of web search tool requests.""" 11 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_server_tool_use_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaServerToolUseBlock"] 8 | 9 | 10 | class BetaServerToolUseBlock(BaseModel): 11 | id: str 12 | 13 | input: object 14 | 15 | name: Literal["web_search", "code_execution"] 16 | 17 | type: Literal["server_tool_use"] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_server_tool_use_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaServerToolUseBlockParam"] 11 | 12 | 13 | class BetaServerToolUseBlockParam(TypedDict, total=False): 14 | id: Required[str] 15 | 16 | input: Required[object] 17 | 18 | name: Required[Literal["web_search", "code_execution"]] 19 | 20 | type: Required[Literal["server_tool_use"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_signature_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaSignatureDelta"] 8 | 9 | 10 | class BetaSignatureDelta(BaseModel): 11 | signature: str 12 | 13 | type: Literal["signature_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_stop_reason.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal, TypeAlias 4 | 5 | __all__ = ["BetaStopReason"] 6 | 7 | BetaStopReason: TypeAlias = Literal["end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal"] 8 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_text_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import List, Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | from .beta_text_citation import BetaTextCitation 8 | 9 | __all__ = ["BetaTextBlock"] 10 | 11 | 12 | class BetaTextBlock(BaseModel): 13 | citations: Optional[List[BetaTextCitation]] = None 14 | """Citations supporting the text block. 15 | 16 | The type of citation returned will depend on the type of document being cited. 17 | Citing a PDF results in `page_location`, plain text results in `char_location`, 18 | and content document results in `content_block_location`. 19 | """ 20 | 21 | text: str 22 | 23 | type: Literal["text"] 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_text_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Iterable, Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_text_citation_param import BetaTextCitationParam 9 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 10 | 11 | __all__ = ["BetaTextBlockParam"] 12 | 13 | 14 | class BetaTextBlockParam(TypedDict, total=False): 15 | text: Required[str] 16 | 17 | type: Required[Literal["text"]] 18 | 19 | cache_control: Optional[BetaCacheControlEphemeralParam] 20 | """Create a cache control breakpoint at this content block.""" 21 | 22 | citations: Optional[Iterable[BetaTextCitationParam]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_text_citation.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from .beta_citation_char_location import BetaCitationCharLocation 8 | from .beta_citation_page_location import BetaCitationPageLocation 9 | from .beta_citation_content_block_location import BetaCitationContentBlockLocation 10 | from .beta_citations_web_search_result_location import BetaCitationsWebSearchResultLocation 11 | 12 | __all__ = ["BetaTextCitation"] 13 | 14 | BetaTextCitation: TypeAlias = Annotated[ 15 | Union[ 16 | BetaCitationCharLocation, 17 | BetaCitationPageLocation, 18 | BetaCitationContentBlockLocation, 19 | BetaCitationsWebSearchResultLocation, 20 | ], 21 | PropertyInfo(discriminator="type"), 22 | ] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_text_citation_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .beta_citation_char_location_param import BetaCitationCharLocationParam 9 | from .beta_citation_page_location_param import BetaCitationPageLocationParam 10 | from .beta_citation_content_block_location_param import BetaCitationContentBlockLocationParam 11 | from .beta_citation_web_search_result_location_param import BetaCitationWebSearchResultLocationParam 12 | 13 | __all__ = ["BetaTextCitationParam"] 14 | 15 | BetaTextCitationParam: TypeAlias = Union[ 16 | BetaCitationCharLocationParam, 17 | BetaCitationPageLocationParam, 18 | BetaCitationContentBlockLocationParam, 19 | BetaCitationWebSearchResultLocationParam, 20 | ] 21 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_text_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaTextDelta"] 8 | 9 | 10 | class BetaTextDelta(BaseModel): 11 | text: str 12 | 13 | type: Literal["text_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_thinking_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaThinkingBlock"] 8 | 9 | 10 | class BetaThinkingBlock(BaseModel): 11 | signature: str 12 | 13 | thinking: str 14 | 15 | type: Literal["thinking"] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_thinking_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaThinkingBlockParam"] 8 | 9 | 10 | class BetaThinkingBlockParam(TypedDict, total=False): 11 | signature: Required[str] 12 | 13 | thinking: Required[str] 14 | 15 | type: Required[Literal["thinking"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_thinking_config_disabled_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaThinkingConfigDisabledParam"] 8 | 9 | 10 | class BetaThinkingConfigDisabledParam(TypedDict, total=False): 11 | type: Required[Literal["disabled"]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_thinking_config_enabled_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaThinkingConfigEnabledParam"] 8 | 9 | 10 | class BetaThinkingConfigEnabledParam(TypedDict, total=False): 11 | budget_tokens: Required[int] 12 | """Determines how many tokens Claude can use for its internal reasoning process. 13 | 14 | Larger budgets can enable more thorough analysis for complex problems, improving 15 | response quality. 16 | 17 | Must be ≥1024 and less than `max_tokens`. 18 | 19 | See 20 | [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking) 21 | for details. 22 | """ 23 | 24 | type: Required[Literal["enabled"]] 25 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_thinking_config_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .beta_thinking_config_enabled_param import BetaThinkingConfigEnabledParam 9 | from .beta_thinking_config_disabled_param import BetaThinkingConfigDisabledParam 10 | 11 | __all__ = ["BetaThinkingConfigParam"] 12 | 13 | BetaThinkingConfigParam: TypeAlias = Union[BetaThinkingConfigEnabledParam, BetaThinkingConfigDisabledParam] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_thinking_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaThinkingDelta"] 8 | 9 | 10 | class BetaThinkingDelta(BaseModel): 11 | thinking: str 12 | 13 | type: Literal["thinking_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_bash_20241022_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolBash20241022Param"] 11 | 12 | 13 | class BetaToolBash20241022Param(TypedDict, total=False): 14 | name: Required[Literal["bash"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["bash_20241022"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_bash_20250124_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolBash20250124Param"] 11 | 12 | 13 | class BetaToolBash20250124Param(TypedDict, total=False): 14 | name: Required[Literal["bash"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["bash_20250124"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_choice_any_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaToolChoiceAnyParam"] 8 | 9 | 10 | class BetaToolChoiceAnyParam(TypedDict, total=False): 11 | type: Required[Literal["any"]] 12 | 13 | disable_parallel_tool_use: bool 14 | """Whether to disable parallel tool use. 15 | 16 | Defaults to `false`. If set to `true`, the model will output exactly one tool 17 | use. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_choice_auto_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaToolChoiceAutoParam"] 8 | 9 | 10 | class BetaToolChoiceAutoParam(TypedDict, total=False): 11 | type: Required[Literal["auto"]] 12 | 13 | disable_parallel_tool_use: bool 14 | """Whether to disable parallel tool use. 15 | 16 | Defaults to `false`. If set to `true`, the model will output at most one tool 17 | use. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_choice_none_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaToolChoiceNoneParam"] 8 | 9 | 10 | class BetaToolChoiceNoneParam(TypedDict, total=False): 11 | type: Required[Literal["none"]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_choice_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .beta_tool_choice_any_param import BetaToolChoiceAnyParam 9 | from .beta_tool_choice_auto_param import BetaToolChoiceAutoParam 10 | from .beta_tool_choice_none_param import BetaToolChoiceNoneParam 11 | from .beta_tool_choice_tool_param import BetaToolChoiceToolParam 12 | 13 | __all__ = ["BetaToolChoiceParam"] 14 | 15 | BetaToolChoiceParam: TypeAlias = Union[ 16 | BetaToolChoiceAutoParam, BetaToolChoiceAnyParam, BetaToolChoiceToolParam, BetaToolChoiceNoneParam 17 | ] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_choice_tool_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaToolChoiceToolParam"] 8 | 9 | 10 | class BetaToolChoiceToolParam(TypedDict, total=False): 11 | name: Required[str] 12 | """The name of the tool to use.""" 13 | 14 | type: Required[Literal["tool"]] 15 | 16 | disable_parallel_tool_use: bool 17 | """Whether to disable parallel tool use. 18 | 19 | Defaults to `false`. If set to `true`, the model will output exactly one tool 20 | use. 21 | """ 22 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_computer_use_20241022_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolComputerUse20241022Param"] 11 | 12 | 13 | class BetaToolComputerUse20241022Param(TypedDict, total=False): 14 | display_height_px: Required[int] 15 | """The height of the display in pixels.""" 16 | 17 | display_width_px: Required[int] 18 | """The width of the display in pixels.""" 19 | 20 | name: Required[Literal["computer"]] 21 | """Name of the tool. 22 | 23 | This is how the tool will be called by the model and in `tool_use` blocks. 24 | """ 25 | 26 | type: Required[Literal["computer_20241022"]] 27 | 28 | cache_control: Optional[BetaCacheControlEphemeralParam] 29 | """Create a cache control breakpoint at this content block.""" 30 | 31 | display_number: Optional[int] 32 | """The X11 display number (e.g. 0, 1) for the display.""" 33 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_computer_use_20250124_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolComputerUse20250124Param"] 11 | 12 | 13 | class BetaToolComputerUse20250124Param(TypedDict, total=False): 14 | display_height_px: Required[int] 15 | """The height of the display in pixels.""" 16 | 17 | display_width_px: Required[int] 18 | """The width of the display in pixels.""" 19 | 20 | name: Required[Literal["computer"]] 21 | """Name of the tool. 22 | 23 | This is how the tool will be called by the model and in `tool_use` blocks. 24 | """ 25 | 26 | type: Required[Literal["computer_20250124"]] 27 | 28 | cache_control: Optional[BetaCacheControlEphemeralParam] 29 | """Create a cache control breakpoint at this content block.""" 30 | 31 | display_number: Optional[int] 32 | """The X11 display number (e.g. 0, 1) for the display.""" 33 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable, Optional 6 | from typing_extensions import Literal, Required, TypeAlias, TypedDict 7 | 8 | from .beta_text_block_param import BetaTextBlockParam 9 | from .beta_image_block_param import BetaImageBlockParam 10 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 11 | 12 | __all__ = ["BetaToolResultBlockParam", "Content"] 13 | 14 | Content: TypeAlias = Union[BetaTextBlockParam, BetaImageBlockParam] 15 | 16 | 17 | class BetaToolResultBlockParam(TypedDict, total=False): 18 | tool_use_id: Required[str] 19 | 20 | type: Required[Literal["tool_result"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | 25 | content: Union[str, Iterable[Content]] 26 | 27 | is_error: bool 28 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_text_editor_20241022_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolTextEditor20241022Param"] 11 | 12 | 13 | class BetaToolTextEditor20241022Param(TypedDict, total=False): 14 | name: Required[Literal["str_replace_editor"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["text_editor_20241022"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_text_editor_20250124_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolTextEditor20250124Param"] 11 | 12 | 13 | class BetaToolTextEditor20250124Param(TypedDict, total=False): 14 | name: Required[Literal["str_replace_editor"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["text_editor_20250124"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_text_editor_20250429_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolTextEditor20250429Param"] 11 | 12 | 13 | class BetaToolTextEditor20250429Param(TypedDict, total=False): 14 | name: Required[Literal["str_replace_based_edit_tool"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["text_editor_20250429"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_use_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BetaToolUseBlock"] 8 | 9 | 10 | class BetaToolUseBlock(BaseModel): 11 | id: str 12 | 13 | input: object 14 | 15 | name: str 16 | 17 | type: Literal["tool_use"] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_tool_use_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | 10 | __all__ = ["BetaToolUseBlockParam"] 11 | 12 | 13 | class BetaToolUseBlockParam(TypedDict, total=False): 14 | id: Required[str] 15 | 16 | input: Required[object] 17 | 18 | name: Required[str] 19 | 20 | type: Required[Literal["tool_use"]] 21 | 22 | cache_control: Optional[BetaCacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_url_image_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaURLImageSourceParam"] 8 | 9 | 10 | class BetaURLImageSourceParam(TypedDict, total=False): 11 | type: Required[Literal["url"]] 12 | 13 | url: Required[str] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_url_pdf_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["BetaURLPDFSourceParam"] 8 | 9 | 10 | class BetaURLPDFSourceParam(TypedDict, total=False): 11 | type: Required[Literal["url"]] 12 | 13 | url: Required[str] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_usage.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | from .beta_cache_creation import BetaCacheCreation 8 | from .beta_server_tool_usage import BetaServerToolUsage 9 | 10 | __all__ = ["BetaUsage"] 11 | 12 | 13 | class BetaUsage(BaseModel): 14 | cache_creation: Optional[BetaCacheCreation] = None 15 | """Breakdown of cached tokens by TTL""" 16 | 17 | cache_creation_input_tokens: Optional[int] = None 18 | """The number of input tokens used to create the cache entry.""" 19 | 20 | cache_read_input_tokens: Optional[int] = None 21 | """The number of input tokens read from the cache.""" 22 | 23 | input_tokens: int 24 | """The number of input tokens which were used.""" 25 | 26 | output_tokens: int 27 | """The number of output tokens which were used.""" 28 | 29 | server_tool_use: Optional[BetaServerToolUsage] = None 30 | """The number of server tool requests.""" 31 | 32 | service_tier: Optional[Literal["standard", "priority", "batch"]] = None 33 | """If the request used the priority, standard, or batch tier.""" 34 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["BetaWebSearchResultBlock"] 9 | 10 | 11 | class BetaWebSearchResultBlock(BaseModel): 12 | encrypted_content: str 13 | 14 | page_age: Optional[str] = None 15 | 16 | title: str 17 | 18 | type: Literal["web_search_result"] 19 | 20 | url: str 21 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["BetaWebSearchResultBlockParam"] 9 | 10 | 11 | class BetaWebSearchResultBlockParam(TypedDict, total=False): 12 | encrypted_content: Required[str] 13 | 14 | title: Required[str] 15 | 16 | type: Required[Literal["web_search_result"]] 17 | 18 | url: Required[str] 19 | 20 | page_age: Optional[str] 21 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_request_error_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | from .beta_web_search_tool_result_error_code import BetaWebSearchToolResultErrorCode 8 | 9 | __all__ = ["BetaWebSearchToolRequestErrorParam"] 10 | 11 | 12 | class BetaWebSearchToolRequestErrorParam(TypedDict, total=False): 13 | error_code: Required[BetaWebSearchToolResultErrorCode] 14 | 15 | type: Required[Literal["web_search_tool_result_error"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .beta_web_search_tool_result_block_content import BetaWebSearchToolResultBlockContent 7 | 8 | __all__ = ["BetaWebSearchToolResultBlock"] 9 | 10 | 11 | class BetaWebSearchToolResultBlock(BaseModel): 12 | content: BetaWebSearchToolResultBlockContent 13 | 14 | tool_use_id: str 15 | 16 | type: Literal["web_search_tool_result"] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_result_block_content.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import List, Union 4 | from typing_extensions import TypeAlias 5 | 6 | from .beta_web_search_result_block import BetaWebSearchResultBlock 7 | from .beta_web_search_tool_result_error import BetaWebSearchToolResultError 8 | 9 | __all__ = ["BetaWebSearchToolResultBlockContent"] 10 | 11 | BetaWebSearchToolResultBlockContent: TypeAlias = Union[BetaWebSearchToolResultError, List[BetaWebSearchResultBlock]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam 9 | from .beta_web_search_tool_result_block_param_content_param import BetaWebSearchToolResultBlockParamContentParam 10 | 11 | __all__ = ["BetaWebSearchToolResultBlockParam"] 12 | 13 | 14 | class BetaWebSearchToolResultBlockParam(TypedDict, total=False): 15 | content: Required[BetaWebSearchToolResultBlockParamContentParam] 16 | 17 | tool_use_id: Required[str] 18 | 19 | type: Required[Literal["web_search_tool_result"]] 20 | 21 | cache_control: Optional[BetaCacheControlEphemeralParam] 22 | """Create a cache control breakpoint at this content block.""" 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_result_block_param_content_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable 6 | from typing_extensions import TypeAlias 7 | 8 | from .beta_web_search_result_block_param import BetaWebSearchResultBlockParam 9 | from .beta_web_search_tool_request_error_param import BetaWebSearchToolRequestErrorParam 10 | 11 | __all__ = ["BetaWebSearchToolResultBlockParamContentParam"] 12 | 13 | BetaWebSearchToolResultBlockParamContentParam: TypeAlias = Union[ 14 | Iterable[BetaWebSearchResultBlockParam], BetaWebSearchToolRequestErrorParam 15 | ] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_result_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .beta_web_search_tool_result_error_code import BetaWebSearchToolResultErrorCode 7 | 8 | __all__ = ["BetaWebSearchToolResultError"] 9 | 10 | 11 | class BetaWebSearchToolResultError(BaseModel): 12 | error_code: BetaWebSearchToolResultErrorCode 13 | 14 | type: Literal["web_search_tool_result_error"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/beta_web_search_tool_result_error_code.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal, TypeAlias 4 | 5 | __all__ = ["BetaWebSearchToolResultErrorCode"] 6 | 7 | BetaWebSearchToolResultErrorCode: TypeAlias = Literal[ 8 | "invalid_tool_input", "unavailable", "max_uses_exceeded", "too_many_requests", "query_too_long" 9 | ] 10 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/deleted_file.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["DeletedFile"] 9 | 10 | 11 | class DeletedFile(BaseModel): 12 | id: str 13 | """ID of the deleted file.""" 14 | 15 | type: Optional[Literal["file_deleted"]] = None 16 | """Deleted object type. 17 | 18 | For file deletion, this is always `"file_deleted"`. 19 | """ 20 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/file_list_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import List 6 | from typing_extensions import Annotated, TypedDict 7 | 8 | from ..._utils import PropertyInfo 9 | from ..anthropic_beta_param import AnthropicBetaParam 10 | 11 | __all__ = ["FileListParams"] 12 | 13 | 14 | class FileListParams(TypedDict, total=False): 15 | after_id: str 16 | """ID of the object to use as a cursor for pagination. 17 | 18 | When provided, returns the page of results immediately after this object. 19 | """ 20 | 21 | before_id: str 22 | """ID of the object to use as a cursor for pagination. 23 | 24 | When provided, returns the page of results immediately before this object. 25 | """ 26 | 27 | limit: int 28 | """Number of items to return per page. 29 | 30 | Defaults to `20`. Ranges from `1` to `1000`. 31 | """ 32 | 33 | betas: Annotated[List[AnthropicBetaParam], PropertyInfo(alias="anthropic-beta")] 34 | """Optional header to specify the beta version(s) you want to use.""" 35 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/file_metadata.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from datetime import datetime 5 | from typing_extensions import Literal 6 | 7 | from ..._models import BaseModel 8 | 9 | __all__ = ["FileMetadata"] 10 | 11 | 12 | class FileMetadata(BaseModel): 13 | id: str 14 | """Unique object identifier. 15 | 16 | The format and length of IDs may change over time. 17 | """ 18 | 19 | created_at: datetime 20 | """RFC 3339 datetime string representing when the file was created.""" 21 | 22 | filename: str 23 | """Original filename of the uploaded file.""" 24 | 25 | mime_type: str 26 | """MIME type of the file.""" 27 | 28 | size_bytes: int 29 | """Size of the file in bytes.""" 30 | 31 | type: Literal["file"] 32 | """Object type. 33 | 34 | For files, this is always `"file"`. 35 | """ 36 | 37 | downloadable: Optional[bool] = None 38 | """Whether the file can be downloaded.""" 39 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/file_upload_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import List 6 | from typing_extensions import Required, Annotated, TypedDict 7 | 8 | from ..._types import FileTypes 9 | from ..._utils import PropertyInfo 10 | from ..anthropic_beta_param import AnthropicBetaParam 11 | 12 | __all__ = ["FileUploadParams"] 13 | 14 | 15 | class FileUploadParams(TypedDict, total=False): 16 | file: Required[FileTypes] 17 | """The file to upload""" 18 | 19 | betas: Annotated[List[AnthropicBetaParam], PropertyInfo(alias="anthropic-beta")] 20 | """Optional header to specify the beta version(s) you want to use.""" 21 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from .batch_list_params import BatchListParams as BatchListParams 6 | from .beta_message_batch import BetaMessageBatch as BetaMessageBatch 7 | from .batch_create_params import BatchCreateParams as BatchCreateParams 8 | from .beta_message_batch_result import BetaMessageBatchResult as BetaMessageBatchResult 9 | from .beta_deleted_message_batch import BetaDeletedMessageBatch as BetaDeletedMessageBatch 10 | from .beta_message_batch_errored_result import BetaMessageBatchErroredResult as BetaMessageBatchErroredResult 11 | from .beta_message_batch_expired_result import BetaMessageBatchExpiredResult as BetaMessageBatchExpiredResult 12 | from .beta_message_batch_request_counts import BetaMessageBatchRequestCounts as BetaMessageBatchRequestCounts 13 | from .beta_message_batch_canceled_result import BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult 14 | from .beta_message_batch_succeeded_result import BetaMessageBatchSucceededResult as BetaMessageBatchSucceededResult 15 | from .beta_message_batch_individual_response import ( 16 | BetaMessageBatchIndividualResponse as BetaMessageBatchIndividualResponse, 17 | ) 18 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/batch_list_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import List 6 | from typing_extensions import Annotated, TypedDict 7 | 8 | from ...._utils import PropertyInfo 9 | from ...anthropic_beta_param import AnthropicBetaParam 10 | 11 | __all__ = ["BatchListParams"] 12 | 13 | 14 | class BatchListParams(TypedDict, total=False): 15 | after_id: str 16 | """ID of the object to use as a cursor for pagination. 17 | 18 | When provided, returns the page of results immediately after this object. 19 | """ 20 | 21 | before_id: str 22 | """ID of the object to use as a cursor for pagination. 23 | 24 | When provided, returns the page of results immediately before this object. 25 | """ 26 | 27 | limit: int 28 | """Number of items to return per page. 29 | 30 | Defaults to `20`. Ranges from `1` to `1000`. 31 | """ 32 | 33 | betas: Annotated[List[AnthropicBetaParam], PropertyInfo(alias="anthropic-beta")] 34 | """Optional header to specify the beta version(s) you want to use.""" 35 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_deleted_message_batch.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ...._models import BaseModel 6 | 7 | __all__ = ["BetaDeletedMessageBatch"] 8 | 9 | 10 | class BetaDeletedMessageBatch(BaseModel): 11 | id: str 12 | """ID of the Message Batch.""" 13 | 14 | type: Literal["message_batch_deleted"] 15 | """Deleted object type. 16 | 17 | For Message Batches, this is always `"message_batch_deleted"`. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_canceled_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ...._models import BaseModel 6 | 7 | __all__ = ["BetaMessageBatchCanceledResult"] 8 | 9 | 10 | class BetaMessageBatchCanceledResult(BaseModel): 11 | type: Literal["canceled"] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_errored_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ...._models import BaseModel 6 | from ...beta_error_response import BetaErrorResponse 7 | 8 | __all__ = ["BetaMessageBatchErroredResult"] 9 | 10 | 11 | class BetaMessageBatchErroredResult(BaseModel): 12 | error: BetaErrorResponse 13 | 14 | type: Literal["errored"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_expired_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ...._models import BaseModel 6 | 7 | __all__ = ["BetaMessageBatchExpiredResult"] 8 | 9 | 10 | class BetaMessageBatchExpiredResult(BaseModel): 11 | type: Literal["expired"] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_individual_response.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ...._models import BaseModel 4 | from .beta_message_batch_result import BetaMessageBatchResult 5 | 6 | __all__ = ["BetaMessageBatchIndividualResponse"] 7 | 8 | 9 | class BetaMessageBatchIndividualResponse(BaseModel): 10 | custom_id: str 11 | """Developer-provided ID created for each request in a Message Batch. 12 | 13 | Useful for matching results to requests, as results may be given out of request 14 | order. 15 | 16 | Must be unique for each request within the Message Batch. 17 | """ 18 | 19 | result: BetaMessageBatchResult 20 | """Processing result for this request. 21 | 22 | Contains a Message output if processing was successful, an error response if 23 | processing failed, or the reason why processing was not attempted, such as 24 | cancellation or expiration. 25 | """ 26 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_request_counts.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ...._models import BaseModel 4 | 5 | __all__ = ["BetaMessageBatchRequestCounts"] 6 | 7 | 8 | class BetaMessageBatchRequestCounts(BaseModel): 9 | canceled: int 10 | """Number of requests in the Message Batch that have been canceled. 11 | 12 | This is zero until processing of the entire Message Batch has ended. 13 | """ 14 | 15 | errored: int 16 | """Number of requests in the Message Batch that encountered an error. 17 | 18 | This is zero until processing of the entire Message Batch has ended. 19 | """ 20 | 21 | expired: int 22 | """Number of requests in the Message Batch that have expired. 23 | 24 | This is zero until processing of the entire Message Batch has ended. 25 | """ 26 | 27 | processing: int 28 | """Number of requests in the Message Batch that are processing.""" 29 | 30 | succeeded: int 31 | """Number of requests in the Message Batch that have completed successfully. 32 | 33 | This is zero until processing of the entire Message Batch has ended. 34 | """ 35 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ...._utils import PropertyInfo 7 | from .beta_message_batch_errored_result import BetaMessageBatchErroredResult 8 | from .beta_message_batch_expired_result import BetaMessageBatchExpiredResult 9 | from .beta_message_batch_canceled_result import BetaMessageBatchCanceledResult 10 | from .beta_message_batch_succeeded_result import BetaMessageBatchSucceededResult 11 | 12 | __all__ = ["BetaMessageBatchResult"] 13 | 14 | BetaMessageBatchResult: TypeAlias = Annotated[ 15 | Union[ 16 | BetaMessageBatchSucceededResult, 17 | BetaMessageBatchErroredResult, 18 | BetaMessageBatchCanceledResult, 19 | BetaMessageBatchExpiredResult, 20 | ], 21 | PropertyInfo(discriminator="type"), 22 | ] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/messages/beta_message_batch_succeeded_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ...._models import BaseModel 6 | from ..beta_message import BetaMessage 7 | 8 | __all__ = ["BetaMessageBatchSucceededResult"] 9 | 10 | 11 | class BetaMessageBatchSucceededResult(BaseModel): 12 | message: BetaMessage 13 | 14 | type: Literal["succeeded"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta/model_list_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import List 6 | from typing_extensions import Annotated, TypedDict 7 | 8 | from ..._utils import PropertyInfo 9 | from ..anthropic_beta_param import AnthropicBetaParam 10 | 11 | __all__ = ["ModelListParams"] 12 | 13 | 14 | class ModelListParams(TypedDict, total=False): 15 | after_id: str 16 | """ID of the object to use as a cursor for pagination. 17 | 18 | When provided, returns the page of results immediately after this object. 19 | """ 20 | 21 | before_id: str 22 | """ID of the object to use as a cursor for pagination. 23 | 24 | When provided, returns the page of results immediately before this object. 25 | """ 26 | 27 | limit: int 28 | """Number of items to return per page. 29 | 30 | Defaults to `20`. Ranges from `1` to `1000`. 31 | """ 32 | 33 | betas: Annotated[List[AnthropicBetaParam], PropertyInfo(alias="anthropic-beta")] 34 | """Optional header to specify the beta version(s) you want to use.""" 35 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_api_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaAPIError"] 8 | 9 | 10 | class BetaAPIError(BaseModel): 11 | message: str 12 | 13 | type: Literal["api_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_authentication_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaAuthenticationError"] 8 | 9 | 10 | class BetaAuthenticationError(BaseModel): 11 | message: str 12 | 13 | type: Literal["authentication_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_billing_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaBillingError"] 8 | 9 | 10 | class BetaBillingError(BaseModel): 11 | message: str 12 | 13 | type: Literal["billing_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .beta_api_error import BetaAPIError 8 | from .beta_billing_error import BetaBillingError 9 | from .beta_not_found_error import BetaNotFoundError 10 | from .beta_overloaded_error import BetaOverloadedError 11 | from .beta_permission_error import BetaPermissionError 12 | from .beta_rate_limit_error import BetaRateLimitError 13 | from .beta_authentication_error import BetaAuthenticationError 14 | from .beta_gateway_timeout_error import BetaGatewayTimeoutError 15 | from .beta_invalid_request_error import BetaInvalidRequestError 16 | 17 | __all__ = ["BetaError"] 18 | 19 | BetaError: TypeAlias = Annotated[ 20 | Union[ 21 | BetaInvalidRequestError, 22 | BetaAuthenticationError, 23 | BetaBillingError, 24 | BetaPermissionError, 25 | BetaNotFoundError, 26 | BetaRateLimitError, 27 | BetaGatewayTimeoutError, 28 | BetaAPIError, 29 | BetaOverloadedError, 30 | ], 31 | PropertyInfo(discriminator="type"), 32 | ] 33 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_error_response.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | from .beta_error import BetaError 7 | 8 | __all__ = ["BetaErrorResponse"] 9 | 10 | 11 | class BetaErrorResponse(BaseModel): 12 | error: BetaError 13 | 14 | type: Literal["error"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_gateway_timeout_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaGatewayTimeoutError"] 8 | 9 | 10 | class BetaGatewayTimeoutError(BaseModel): 11 | message: str 12 | 13 | type: Literal["timeout_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_invalid_request_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaInvalidRequestError"] 8 | 9 | 10 | class BetaInvalidRequestError(BaseModel): 11 | message: str 12 | 13 | type: Literal["invalid_request_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_not_found_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaNotFoundError"] 8 | 9 | 10 | class BetaNotFoundError(BaseModel): 11 | message: str 12 | 13 | type: Literal["not_found_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_overloaded_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaOverloadedError"] 8 | 9 | 10 | class BetaOverloadedError(BaseModel): 11 | message: str 12 | 13 | type: Literal["overloaded_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_permission_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaPermissionError"] 8 | 9 | 10 | class BetaPermissionError(BaseModel): 11 | message: str 12 | 13 | type: Literal["permission_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/beta_rate_limit_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["BetaRateLimitError"] 8 | 9 | 10 | class BetaRateLimitError(BaseModel): 11 | message: str 12 | 13 | type: Literal["rate_limit_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/cache_control_ephemeral_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["CacheControlEphemeralParam"] 8 | 9 | 10 | class CacheControlEphemeralParam(TypedDict, total=False): 11 | type: Required[Literal["ephemeral"]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_char_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | 8 | __all__ = ["CitationCharLocation"] 9 | 10 | 11 | class CitationCharLocation(BaseModel): 12 | cited_text: str 13 | 14 | document_index: int 15 | 16 | document_title: Optional[str] = None 17 | 18 | end_char_index: int 19 | 20 | start_char_index: int 21 | 22 | type: Literal["char_location"] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_char_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["CitationCharLocationParam"] 9 | 10 | 11 | class CitationCharLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | document_index: Required[int] 15 | 16 | document_title: Required[Optional[str]] 17 | 18 | end_char_index: Required[int] 19 | 20 | start_char_index: Required[int] 21 | 22 | type: Required[Literal["char_location"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_content_block_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | 8 | __all__ = ["CitationContentBlockLocation"] 9 | 10 | 11 | class CitationContentBlockLocation(BaseModel): 12 | cited_text: str 13 | 14 | document_index: int 15 | 16 | document_title: Optional[str] = None 17 | 18 | end_block_index: int 19 | 20 | start_block_index: int 21 | 22 | type: Literal["content_block_location"] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_content_block_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["CitationContentBlockLocationParam"] 9 | 10 | 11 | class CitationContentBlockLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | document_index: Required[int] 15 | 16 | document_title: Required[Optional[str]] 17 | 18 | end_block_index: Required[int] 19 | 20 | start_block_index: Required[int] 21 | 22 | type: Required[Literal["content_block_location"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_page_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | 8 | __all__ = ["CitationPageLocation"] 9 | 10 | 11 | class CitationPageLocation(BaseModel): 12 | cited_text: str 13 | 14 | document_index: int 15 | 16 | document_title: Optional[str] = None 17 | 18 | end_page_number: int 19 | 20 | start_page_number: int 21 | 22 | type: Literal["page_location"] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_page_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["CitationPageLocationParam"] 9 | 10 | 11 | class CitationPageLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | document_index: Required[int] 15 | 16 | document_title: Required[Optional[str]] 17 | 18 | end_page_number: Required[int] 19 | 20 | start_page_number: Required[int] 21 | 22 | type: Required[Literal["page_location"]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/citation_web_search_result_location_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["CitationWebSearchResultLocationParam"] 9 | 10 | 11 | class CitationWebSearchResultLocationParam(TypedDict, total=False): 12 | cited_text: Required[str] 13 | 14 | encrypted_index: Required[str] 15 | 16 | title: Required[Optional[str]] 17 | 18 | type: Required[Literal["web_search_result_location"]] 19 | 20 | url: Required[str] 21 | -------------------------------------------------------------------------------- /src/anthropic/types/citations_config_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import TypedDict 6 | 7 | __all__ = ["CitationsConfigParam"] 8 | 9 | 10 | class CitationsConfigParam(TypedDict, total=False): 11 | enabled: bool 12 | -------------------------------------------------------------------------------- /src/anthropic/types/citations_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Literal, Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .._models import BaseModel 8 | from .citation_char_location import CitationCharLocation 9 | from .citation_page_location import CitationPageLocation 10 | from .citation_content_block_location import CitationContentBlockLocation 11 | from .citations_web_search_result_location import CitationsWebSearchResultLocation 12 | 13 | __all__ = ["CitationsDelta", "Citation"] 14 | 15 | Citation: TypeAlias = Annotated[ 16 | Union[CitationCharLocation, CitationPageLocation, CitationContentBlockLocation, CitationsWebSearchResultLocation], 17 | PropertyInfo(discriminator="type"), 18 | ] 19 | 20 | 21 | class CitationsDelta(BaseModel): 22 | citation: Citation 23 | 24 | type: Literal["citations_delta"] 25 | -------------------------------------------------------------------------------- /src/anthropic/types/citations_web_search_result_location.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | 8 | __all__ = ["CitationsWebSearchResultLocation"] 9 | 10 | 11 | class CitationsWebSearchResultLocation(BaseModel): 12 | cited_text: str 13 | 14 | encrypted_index: str 15 | 16 | title: Optional[str] = None 17 | 18 | type: Literal["web_search_result_location"] 19 | 20 | url: str 21 | -------------------------------------------------------------------------------- /src/anthropic/types/completion.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .model import Model 7 | from .._models import BaseModel 8 | 9 | __all__ = ["Completion"] 10 | 11 | 12 | class Completion(BaseModel): 13 | id: str 14 | """Unique object identifier. 15 | 16 | The format and length of IDs may change over time. 17 | """ 18 | 19 | completion: str 20 | """The resulting completion up to and excluding the stop sequences.""" 21 | 22 | model: Model 23 | """ 24 | The model that will complete your prompt.\n\nSee 25 | [models](https://docs.anthropic.com/en/docs/models-overview) for additional 26 | details and options. 27 | """ 28 | 29 | stop_reason: Optional[str] = None 30 | """The reason that we stopped. 31 | 32 | This may be one the following values: 33 | 34 | - `"stop_sequence"`: we reached a stop sequence — either provided by you via the 35 | `stop_sequences` parameter, or a stop sequence built into the model 36 | - `"max_tokens"`: we exceeded `max_tokens_to_sample` or the model's maximum 37 | """ 38 | 39 | type: Literal["completion"] 40 | """Object type. 41 | 42 | For Text Completions, this is always `"completion"`. 43 | """ 44 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .text_block import TextBlock 8 | from .thinking_block import ThinkingBlock 9 | from .tool_use_block import ToolUseBlock 10 | from .server_tool_use_block import ServerToolUseBlock 11 | from .redacted_thinking_block import RedactedThinkingBlock 12 | from .web_search_tool_result_block import WebSearchToolResultBlock 13 | 14 | __all__ = ["ContentBlock"] 15 | 16 | ContentBlock: TypeAlias = Annotated[ 17 | Union[TextBlock, ToolUseBlock, ServerToolUseBlock, WebSearchToolResultBlock, ThinkingBlock, RedactedThinkingBlock], 18 | PropertyInfo(discriminator="type"), 19 | ] 20 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block_delta_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_content_block_delta_event import RawContentBlockDeltaEvent 4 | 5 | __all__ = ["ContentBlockDeltaEvent"] 6 | 7 | ContentBlockDeltaEvent = RawContentBlockDeltaEvent 8 | """The RawContentBlockDeltaEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .text_block_param import TextBlockParam 9 | from .image_block_param import ImageBlockParam 10 | from .document_block_param import DocumentBlockParam 11 | from .thinking_block_param import ThinkingBlockParam 12 | from .tool_use_block_param import ToolUseBlockParam 13 | from .tool_result_block_param import ToolResultBlockParam 14 | from .server_tool_use_block_param import ServerToolUseBlockParam 15 | from .redacted_thinking_block_param import RedactedThinkingBlockParam 16 | from .web_search_tool_result_block_param import WebSearchToolResultBlockParam 17 | 18 | __all__ = ["ContentBlockParam"] 19 | 20 | ContentBlockParam: TypeAlias = Union[ 21 | ServerToolUseBlockParam, 22 | WebSearchToolResultBlockParam, 23 | TextBlockParam, 24 | ImageBlockParam, 25 | ToolUseBlockParam, 26 | ToolResultBlockParam, 27 | DocumentBlockParam, 28 | ThinkingBlockParam, 29 | RedactedThinkingBlockParam, 30 | ] 31 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block_source_content_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .text_block_param import TextBlockParam 9 | from .image_block_param import ImageBlockParam 10 | 11 | __all__ = ["ContentBlockSourceContentParam"] 12 | 13 | ContentBlockSourceContentParam: TypeAlias = Union[TextBlockParam, ImageBlockParam] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .content_block_source_content_param import ContentBlockSourceContentParam 9 | 10 | __all__ = ["ContentBlockSourceParam"] 11 | 12 | 13 | class ContentBlockSourceParam(TypedDict, total=False): 14 | content: Required[Union[str, Iterable[ContentBlockSourceContentParam]]] 15 | 16 | type: Required[Literal["content"]] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block_start_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_content_block_start_event import RawContentBlockStartEvent 4 | 5 | __all__ = ["ContentBlockStartEvent"] 6 | 7 | ContentBlockStartEvent = RawContentBlockStartEvent 8 | """The RawContentBlockStartEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/content_block_stop_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_content_block_stop_event import RawContentBlockStopEvent 4 | 5 | __all__ = ["ContentBlockStopEvent"] 6 | 7 | ContentBlockStopEvent = RawContentBlockStopEvent 8 | """The RawContentBlockStopEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/document_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Optional 6 | from typing_extensions import Literal, Required, TypeAlias, TypedDict 7 | 8 | from .url_pdf_source_param import URLPDFSourceParam 9 | from .citations_config_param import CitationsConfigParam 10 | from .base64_pdf_source_param import Base64PDFSourceParam 11 | from .plain_text_source_param import PlainTextSourceParam 12 | from .content_block_source_param import ContentBlockSourceParam 13 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 14 | 15 | __all__ = ["DocumentBlockParam", "Source"] 16 | 17 | Source: TypeAlias = Union[Base64PDFSourceParam, PlainTextSourceParam, ContentBlockSourceParam, URLPDFSourceParam] 18 | 19 | 20 | class DocumentBlockParam(TypedDict, total=False): 21 | source: Required[Source] 22 | 23 | type: Required[Literal["document"]] 24 | 25 | cache_control: Optional[CacheControlEphemeralParam] 26 | """Create a cache control breakpoint at this content block.""" 27 | 28 | citations: CitationsConfigParam 29 | 30 | context: Optional[str] 31 | 32 | title: Optional[str] 33 | -------------------------------------------------------------------------------- /src/anthropic/types/image_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Optional 6 | from typing_extensions import Literal, Required, TypeAlias, TypedDict 7 | 8 | from .url_image_source_param import URLImageSourceParam 9 | from .base64_image_source_param import Base64ImageSourceParam 10 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 11 | 12 | __all__ = ["ImageBlockParam", "Source"] 13 | 14 | Source: TypeAlias = Union[Base64ImageSourceParam, URLImageSourceParam] 15 | 16 | 17 | class ImageBlockParam(TypedDict, total=False): 18 | source: Required[Source] 19 | 20 | type: Required[Literal["image"]] 21 | 22 | cache_control: Optional[CacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/input_json_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["InputJSONDelta", "InputJsonDelta"] 8 | 9 | 10 | class InputJSONDelta(BaseModel): 11 | partial_json: str 12 | 13 | type: Literal["input_json_delta"] 14 | 15 | 16 | InputJsonDelta = InputJSONDelta 17 | -------------------------------------------------------------------------------- /src/anthropic/types/message_count_tokens_tool_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .tool_param import ToolParam 9 | from .tool_bash_20250124_param import ToolBash20250124Param 10 | from .web_search_tool_20250305_param import WebSearchTool20250305Param 11 | from .tool_text_editor_20250124_param import ToolTextEditor20250124Param 12 | 13 | __all__ = ["MessageCountTokensToolParam"] 14 | 15 | MessageCountTokensToolParam: TypeAlias = Union[ 16 | ToolParam, ToolBash20250124Param, ToolTextEditor20250124Param, WebSearchTool20250305Param 17 | ] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/message_delta_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_message_delta_event import RawMessageDeltaEvent 4 | 5 | __all__ = ["MessageDeltaEvent"] 6 | 7 | MessageDeltaEvent = RawMessageDeltaEvent 8 | """The RawMessageDeltaEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/message_delta_usage.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | 5 | from .._models import BaseModel 6 | from .server_tool_usage import ServerToolUsage 7 | 8 | __all__ = ["MessageDeltaUsage"] 9 | 10 | 11 | class MessageDeltaUsage(BaseModel): 12 | cache_creation_input_tokens: Optional[int] = None 13 | """The cumulative number of input tokens used to create the cache entry.""" 14 | 15 | cache_read_input_tokens: Optional[int] = None 16 | """The cumulative number of input tokens read from the cache.""" 17 | 18 | input_tokens: Optional[int] = None 19 | """The cumulative number of input tokens which were used.""" 20 | 21 | output_tokens: int 22 | """The cumulative number of output tokens which were used.""" 23 | 24 | server_tool_use: Optional[ServerToolUsage] = None 25 | """The number of server tool requests.""" 26 | -------------------------------------------------------------------------------- /src/anthropic/types/message_start_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_message_start_event import RawMessageStartEvent 4 | 5 | __all__ = ["MessageStartEvent"] 6 | 7 | MessageStartEvent = RawMessageStartEvent 8 | """The RawMessageStartEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/message_stop_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_message_stop_event import RawMessageStopEvent 4 | 5 | __all__ = ["MessageStopEvent"] 6 | 7 | MessageStopEvent = RawMessageStopEvent 8 | """The RawMessageStopEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/message_stream_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .raw_message_stream_event import RawMessageStreamEvent 4 | 5 | __all__ = ["MessageStreamEvent"] 6 | 7 | MessageStreamEvent = RawMessageStreamEvent 8 | """The RawMessageStreamEvent type should be used instead""" 9 | -------------------------------------------------------------------------------- /src/anthropic/types/message_tokens_count.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .._models import BaseModel 4 | 5 | __all__ = ["MessageTokensCount"] 6 | 7 | 8 | class MessageTokensCount(BaseModel): 9 | input_tokens: int 10 | """ 11 | The total number of tokens across the provided list of messages, system prompt, 12 | and tools. 13 | """ 14 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from .message_batch import MessageBatch as MessageBatch 6 | from .batch_list_params import BatchListParams as BatchListParams 7 | from .batch_create_params import BatchCreateParams as BatchCreateParams 8 | from .message_batch_result import MessageBatchResult as MessageBatchResult 9 | from .deleted_message_batch import DeletedMessageBatch as DeletedMessageBatch 10 | from .message_batch_errored_result import MessageBatchErroredResult as MessageBatchErroredResult 11 | from .message_batch_expired_result import MessageBatchExpiredResult as MessageBatchExpiredResult 12 | from .message_batch_request_counts import MessageBatchRequestCounts as MessageBatchRequestCounts 13 | from .message_batch_canceled_result import MessageBatchCanceledResult as MessageBatchCanceledResult 14 | from .message_batch_succeeded_result import MessageBatchSucceededResult as MessageBatchSucceededResult 15 | from .message_batch_individual_response import MessageBatchIndividualResponse as MessageBatchIndividualResponse 16 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/batch_create_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Iterable 6 | from typing_extensions import Required, TypedDict 7 | 8 | from ..message_create_params import MessageCreateParamsNonStreaming 9 | 10 | __all__ = ["BatchCreateParams", "Request"] 11 | 12 | 13 | class BatchCreateParams(TypedDict, total=False): 14 | requests: Required[Iterable[Request]] 15 | """List of requests for prompt completion. 16 | 17 | Each is an individual request to create a Message. 18 | """ 19 | 20 | 21 | class Request(TypedDict, total=False): 22 | custom_id: Required[str] 23 | """Developer-provided ID created for each request in a Message Batch. 24 | 25 | Useful for matching results to requests, as results may be given out of request 26 | order. 27 | 28 | Must be unique for each request within the Message Batch. 29 | """ 30 | 31 | params: Required[MessageCreateParamsNonStreaming] 32 | """Messages API creation parameters for the individual request. 33 | 34 | See the [Messages API reference](/en/api/messages) for full documentation on 35 | available parameters. 36 | """ 37 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/batch_list_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import TypedDict 6 | 7 | __all__ = ["BatchListParams"] 8 | 9 | 10 | class BatchListParams(TypedDict, total=False): 11 | after_id: str 12 | """ID of the object to use as a cursor for pagination. 13 | 14 | When provided, returns the page of results immediately after this object. 15 | """ 16 | 17 | before_id: str 18 | """ID of the object to use as a cursor for pagination. 19 | 20 | When provided, returns the page of results immediately before this object. 21 | """ 22 | 23 | limit: int 24 | """Number of items to return per page. 25 | 26 | Defaults to `20`. Ranges from `1` to `1000`. 27 | """ 28 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/deleted_message_batch.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["DeletedMessageBatch"] 8 | 9 | 10 | class DeletedMessageBatch(BaseModel): 11 | id: str 12 | """ID of the Message Batch.""" 13 | 14 | type: Literal["message_batch_deleted"] 15 | """Deleted object type. 16 | 17 | For Message Batches, this is always `"message_batch_deleted"`. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_canceled_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["MessageBatchCanceledResult"] 8 | 9 | 10 | class MessageBatchCanceledResult(BaseModel): 11 | type: Literal["canceled"] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_errored_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from ..shared.error_response import ErrorResponse 7 | 8 | __all__ = ["MessageBatchErroredResult"] 9 | 10 | 11 | class MessageBatchErroredResult(BaseModel): 12 | error: ErrorResponse 13 | 14 | type: Literal["errored"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_expired_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["MessageBatchExpiredResult"] 8 | 9 | 10 | class MessageBatchExpiredResult(BaseModel): 11 | type: Literal["expired"] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_individual_response.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ..._models import BaseModel 4 | from .message_batch_result import MessageBatchResult 5 | 6 | __all__ = ["MessageBatchIndividualResponse"] 7 | 8 | 9 | class MessageBatchIndividualResponse(BaseModel): 10 | custom_id: str 11 | """Developer-provided ID created for each request in a Message Batch. 12 | 13 | Useful for matching results to requests, as results may be given out of request 14 | order. 15 | 16 | Must be unique for each request within the Message Batch. 17 | """ 18 | 19 | result: MessageBatchResult 20 | """Processing result for this request. 21 | 22 | Contains a Message output if processing was successful, an error response if 23 | processing failed, or the reason why processing was not attempted, such as 24 | cancellation or expiration. 25 | """ 26 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_request_counts.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from ..._models import BaseModel 4 | 5 | __all__ = ["MessageBatchRequestCounts"] 6 | 7 | 8 | class MessageBatchRequestCounts(BaseModel): 9 | canceled: int 10 | """Number of requests in the Message Batch that have been canceled. 11 | 12 | This is zero until processing of the entire Message Batch has ended. 13 | """ 14 | 15 | errored: int 16 | """Number of requests in the Message Batch that encountered an error. 17 | 18 | This is zero until processing of the entire Message Batch has ended. 19 | """ 20 | 21 | expired: int 22 | """Number of requests in the Message Batch that have expired. 23 | 24 | This is zero until processing of the entire Message Batch has ended. 25 | """ 26 | 27 | processing: int 28 | """Number of requests in the Message Batch that are processing.""" 29 | 30 | succeeded: int 31 | """Number of requests in the Message Batch that have completed successfully. 32 | 33 | This is zero until processing of the entire Message Batch has ended. 34 | """ 35 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from .message_batch_errored_result import MessageBatchErroredResult 8 | from .message_batch_expired_result import MessageBatchExpiredResult 9 | from .message_batch_canceled_result import MessageBatchCanceledResult 10 | from .message_batch_succeeded_result import MessageBatchSucceededResult 11 | 12 | __all__ = ["MessageBatchResult"] 13 | 14 | MessageBatchResult: TypeAlias = Annotated[ 15 | Union[ 16 | MessageBatchSucceededResult, MessageBatchErroredResult, MessageBatchCanceledResult, MessageBatchExpiredResult 17 | ], 18 | PropertyInfo(discriminator="type"), 19 | ] 20 | -------------------------------------------------------------------------------- /src/anthropic/types/messages/message_batch_succeeded_result.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..message import Message 6 | from ..._models import BaseModel 7 | 8 | __all__ = ["MessageBatchSucceededResult"] 9 | 10 | 11 | class MessageBatchSucceededResult(BaseModel): 12 | message: Message 13 | 14 | type: Literal["succeeded"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/metadata_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import TypedDict 7 | 8 | __all__ = ["MetadataParam"] 9 | 10 | 11 | class MetadataParam(TypedDict, total=False): 12 | user_id: Optional[str] 13 | """An external identifier for the user who is associated with the request. 14 | 15 | This should be a uuid, hash value, or other opaque identifier. Anthropic may use 16 | this id to help detect abuse. Do not include any identifying information such as 17 | name, email address, or phone number. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/model.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Literal, TypeAlias 5 | 6 | __all__ = ["Model"] 7 | 8 | Model: TypeAlias = Union[ 9 | Literal[ 10 | "claude-3-7-sonnet-latest", 11 | "claude-3-7-sonnet-20250219", 12 | "claude-3-5-haiku-latest", 13 | "claude-3-5-haiku-20241022", 14 | "claude-sonnet-4-20250514", 15 | "claude-sonnet-4-0", 16 | "claude-4-sonnet-20250514", 17 | "claude-3-5-sonnet-latest", 18 | "claude-3-5-sonnet-20241022", 19 | "claude-3-5-sonnet-20240620", 20 | "claude-opus-4-0", 21 | "claude-opus-4-20250514", 22 | "claude-4-opus-20250514", 23 | "claude-3-opus-latest", 24 | "claude-3-opus-20240229", 25 | "claude-3-sonnet-20240229", 26 | "claude-3-haiku-20240307", 27 | "claude-2.1", 28 | "claude-2.0", 29 | ], 30 | str, 31 | ] 32 | -------------------------------------------------------------------------------- /src/anthropic/types/model_info.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from datetime import datetime 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | 8 | __all__ = ["ModelInfo"] 9 | 10 | 11 | class ModelInfo(BaseModel): 12 | id: str 13 | """Unique model identifier.""" 14 | 15 | created_at: datetime 16 | """RFC 3339 datetime string representing the time at which the model was released. 17 | 18 | May be set to an epoch value if the release date is unknown. 19 | """ 20 | 21 | display_name: str 22 | """A human-readable name for the model.""" 23 | 24 | type: Literal["model"] 25 | """Object type. 26 | 27 | For Models, this is always `"model"`. 28 | """ 29 | -------------------------------------------------------------------------------- /src/anthropic/types/model_list_params.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import List 6 | from typing_extensions import Annotated, TypedDict 7 | 8 | from .._utils import PropertyInfo 9 | from .anthropic_beta_param import AnthropicBetaParam 10 | 11 | __all__ = ["ModelListParams"] 12 | 13 | 14 | class ModelListParams(TypedDict, total=False): 15 | after_id: str 16 | """ID of the object to use as a cursor for pagination. 17 | 18 | When provided, returns the page of results immediately after this object. 19 | """ 20 | 21 | before_id: str 22 | """ID of the object to use as a cursor for pagination. 23 | 24 | When provided, returns the page of results immediately before this object. 25 | """ 26 | 27 | limit: int 28 | """Number of items to return per page. 29 | 30 | Defaults to `20`. Ranges from `1` to `1000`. 31 | """ 32 | 33 | betas: Annotated[List[AnthropicBetaParam], PropertyInfo(alias="anthropic-beta")] 34 | """Optional header to specify the beta version(s) you want to use.""" 35 | -------------------------------------------------------------------------------- /src/anthropic/types/model_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import Literal, TypeAlias 7 | 8 | __all__ = ["ModelParam"] 9 | 10 | ModelParam: TypeAlias = Union[ 11 | Literal[ 12 | "claude-3-7-sonnet-latest", 13 | "claude-3-7-sonnet-20250219", 14 | "claude-3-5-haiku-latest", 15 | "claude-3-5-haiku-20241022", 16 | "claude-sonnet-4-20250514", 17 | "claude-sonnet-4-0", 18 | "claude-4-sonnet-20250514", 19 | "claude-3-5-sonnet-latest", 20 | "claude-3-5-sonnet-20241022", 21 | "claude-3-5-sonnet-20240620", 22 | "claude-opus-4-0", 23 | "claude-opus-4-20250514", 24 | "claude-4-opus-20250514", 25 | "claude-3-opus-latest", 26 | "claude-3-opus-20240229", 27 | "claude-3-sonnet-20240229", 28 | "claude-3-haiku-20240307", 29 | "claude-2.1", 30 | "claude-2.0", 31 | ], 32 | str, 33 | ] 34 | -------------------------------------------------------------------------------- /src/anthropic/types/plain_text_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["PlainTextSourceParam"] 8 | 9 | 10 | class PlainTextSourceParam(TypedDict, total=False): 11 | data: Required[str] 12 | 13 | media_type: Required[Literal["text/plain"]] 14 | 15 | type: Required[Literal["text"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_content_block_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .text_delta import TextDelta 8 | from .thinking_delta import ThinkingDelta 9 | from .citations_delta import CitationsDelta 10 | from .signature_delta import SignatureDelta 11 | from .input_json_delta import InputJSONDelta 12 | 13 | __all__ = ["RawContentBlockDelta"] 14 | 15 | RawContentBlockDelta: TypeAlias = Annotated[ 16 | Union[TextDelta, InputJSONDelta, CitationsDelta, ThinkingDelta, SignatureDelta], PropertyInfo(discriminator="type") 17 | ] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_content_block_delta_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | from .raw_content_block_delta import RawContentBlockDelta 7 | 8 | __all__ = ["RawContentBlockDeltaEvent"] 9 | 10 | 11 | class RawContentBlockDeltaEvent(BaseModel): 12 | delta: RawContentBlockDelta 13 | 14 | index: int 15 | 16 | type: Literal["content_block_delta"] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_content_block_start_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Literal, Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .._models import BaseModel 8 | from .text_block import TextBlock 9 | from .thinking_block import ThinkingBlock 10 | from .tool_use_block import ToolUseBlock 11 | from .server_tool_use_block import ServerToolUseBlock 12 | from .redacted_thinking_block import RedactedThinkingBlock 13 | from .web_search_tool_result_block import WebSearchToolResultBlock 14 | 15 | __all__ = ["RawContentBlockStartEvent", "ContentBlock"] 16 | 17 | ContentBlock: TypeAlias = Annotated[ 18 | Union[TextBlock, ToolUseBlock, ServerToolUseBlock, WebSearchToolResultBlock, ThinkingBlock, RedactedThinkingBlock], 19 | PropertyInfo(discriminator="type"), 20 | ] 21 | 22 | 23 | class RawContentBlockStartEvent(BaseModel): 24 | content_block: ContentBlock 25 | 26 | index: int 27 | 28 | type: Literal["content_block_start"] 29 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_content_block_stop_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["RawContentBlockStopEvent"] 8 | 9 | 10 | class RawContentBlockStopEvent(BaseModel): 11 | index: int 12 | 13 | type: Literal["content_block_stop"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_message_delta_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | from .stop_reason import StopReason 8 | from .message_delta_usage import MessageDeltaUsage 9 | 10 | __all__ = ["RawMessageDeltaEvent", "Delta"] 11 | 12 | 13 | class Delta(BaseModel): 14 | stop_reason: Optional[StopReason] = None 15 | 16 | stop_sequence: Optional[str] = None 17 | 18 | 19 | class RawMessageDeltaEvent(BaseModel): 20 | delta: Delta 21 | 22 | type: Literal["message_delta"] 23 | 24 | usage: MessageDeltaUsage 25 | """Billing and rate-limit usage. 26 | 27 | Anthropic's API bills and rate-limits by token counts, as tokens represent the 28 | underlying cost to our systems. 29 | 30 | Under the hood, the API transforms requests into a format suitable for the 31 | model. The model's output then goes through a parsing stage before becoming an 32 | API response. As a result, the token counts in `usage` will not match one-to-one 33 | with the exact visible content of an API request or response. 34 | 35 | For example, `output_tokens` will be non-zero, even for an empty string response 36 | from Claude. 37 | 38 | Total input tokens in a request is the summation of `input_tokens`, 39 | `cache_creation_input_tokens`, and `cache_read_input_tokens`. 40 | """ 41 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_message_start_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .message import Message 6 | from .._models import BaseModel 7 | 8 | __all__ = ["RawMessageStartEvent"] 9 | 10 | 11 | class RawMessageStartEvent(BaseModel): 12 | message: Message 13 | 14 | type: Literal["message_start"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_message_stop_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["RawMessageStopEvent"] 8 | 9 | 10 | class RawMessageStopEvent(BaseModel): 11 | type: Literal["message_stop"] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/raw_message_stream_event.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .raw_message_stop_event import RawMessageStopEvent 8 | from .raw_message_delta_event import RawMessageDeltaEvent 9 | from .raw_message_start_event import RawMessageStartEvent 10 | from .raw_content_block_stop_event import RawContentBlockStopEvent 11 | from .raw_content_block_delta_event import RawContentBlockDeltaEvent 12 | from .raw_content_block_start_event import RawContentBlockStartEvent 13 | 14 | __all__ = ["RawMessageStreamEvent"] 15 | 16 | RawMessageStreamEvent: TypeAlias = Annotated[ 17 | Union[ 18 | RawMessageStartEvent, 19 | RawMessageDeltaEvent, 20 | RawMessageStopEvent, 21 | RawContentBlockStartEvent, 22 | RawContentBlockDeltaEvent, 23 | RawContentBlockStopEvent, 24 | ], 25 | PropertyInfo(discriminator="type"), 26 | ] 27 | -------------------------------------------------------------------------------- /src/anthropic/types/redacted_thinking_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["RedactedThinkingBlock"] 8 | 9 | 10 | class RedactedThinkingBlock(BaseModel): 11 | data: str 12 | 13 | type: Literal["redacted_thinking"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/redacted_thinking_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["RedactedThinkingBlockParam"] 8 | 9 | 10 | class RedactedThinkingBlockParam(TypedDict, total=False): 11 | data: Required[str] 12 | 13 | type: Required[Literal["redacted_thinking"]] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/server_tool_usage.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .._models import BaseModel 4 | 5 | __all__ = ["ServerToolUsage"] 6 | 7 | 8 | class ServerToolUsage(BaseModel): 9 | web_search_requests: int 10 | """The number of web search tool requests.""" 11 | -------------------------------------------------------------------------------- /src/anthropic/types/server_tool_use_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["ServerToolUseBlock"] 8 | 9 | 10 | class ServerToolUseBlock(BaseModel): 11 | id: str 12 | 13 | input: object 14 | 15 | name: Literal["web_search"] 16 | 17 | type: Literal["server_tool_use"] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/server_tool_use_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 9 | 10 | __all__ = ["ServerToolUseBlockParam"] 11 | 12 | 13 | class ServerToolUseBlockParam(TypedDict, total=False): 14 | id: Required[str] 15 | 16 | input: Required[object] 17 | 18 | name: Required[Literal["web_search"]] 19 | 20 | type: Required[Literal["server_tool_use"]] 21 | 22 | cache_control: Optional[CacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from .error_object import ErrorObject as ErrorObject 4 | from .billing_error import BillingError as BillingError 5 | from .error_response import ErrorResponse as ErrorResponse 6 | from .not_found_error import NotFoundError as NotFoundError 7 | from .api_error_object import APIErrorObject as APIErrorObject 8 | from .overloaded_error import OverloadedError as OverloadedError 9 | from .permission_error import PermissionError as PermissionError 10 | from .rate_limit_error import RateLimitError as RateLimitError 11 | from .authentication_error import AuthenticationError as AuthenticationError 12 | from .gateway_timeout_error import GatewayTimeoutError as GatewayTimeoutError 13 | from .invalid_request_error import InvalidRequestError as InvalidRequestError 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/api_error_object.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["APIErrorObject"] 8 | 9 | 10 | class APIErrorObject(BaseModel): 11 | message: str 12 | 13 | type: Literal["api_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/authentication_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["AuthenticationError"] 8 | 9 | 10 | class AuthenticationError(BaseModel): 11 | message: str 12 | 13 | type: Literal["authentication_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/billing_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["BillingError"] 8 | 9 | 10 | class BillingError(BaseModel): 11 | message: str 12 | 13 | type: Literal["billing_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/error_object.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from ..._utils import PropertyInfo 7 | from .billing_error import BillingError 8 | from .not_found_error import NotFoundError 9 | from .api_error_object import APIErrorObject 10 | from .overloaded_error import OverloadedError 11 | from .permission_error import PermissionError 12 | from .rate_limit_error import RateLimitError 13 | from .authentication_error import AuthenticationError 14 | from .gateway_timeout_error import GatewayTimeoutError 15 | from .invalid_request_error import InvalidRequestError 16 | 17 | __all__ = ["ErrorObject"] 18 | 19 | ErrorObject: TypeAlias = Annotated[ 20 | Union[ 21 | InvalidRequestError, 22 | AuthenticationError, 23 | BillingError, 24 | PermissionError, 25 | NotFoundError, 26 | RateLimitError, 27 | GatewayTimeoutError, 28 | APIErrorObject, 29 | OverloadedError, 30 | ], 31 | PropertyInfo(discriminator="type"), 32 | ] 33 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/error_response.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | from .error_object import ErrorObject 7 | 8 | __all__ = ["ErrorResponse"] 9 | 10 | 11 | class ErrorResponse(BaseModel): 12 | error: ErrorObject 13 | 14 | type: Literal["error"] 15 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/gateway_timeout_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["GatewayTimeoutError"] 8 | 9 | 10 | class GatewayTimeoutError(BaseModel): 11 | message: str 12 | 13 | type: Literal["timeout_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/invalid_request_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["InvalidRequestError"] 8 | 9 | 10 | class InvalidRequestError(BaseModel): 11 | message: str 12 | 13 | type: Literal["invalid_request_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/not_found_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["NotFoundError"] 8 | 9 | 10 | class NotFoundError(BaseModel): 11 | message: str 12 | 13 | type: Literal["not_found_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/overloaded_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["OverloadedError"] 8 | 9 | 10 | class OverloadedError(BaseModel): 11 | message: str 12 | 13 | type: Literal["overloaded_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/permission_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["PermissionError"] 8 | 9 | 10 | class PermissionError(BaseModel): 11 | message: str 12 | 13 | type: Literal["permission_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/shared/rate_limit_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from ..._models import BaseModel 6 | 7 | __all__ = ["RateLimitError"] 8 | 9 | 10 | class RateLimitError(BaseModel): 11 | message: str 12 | 13 | type: Literal["rate_limit_error"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/signature_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["SignatureDelta"] 8 | 9 | 10 | class SignatureDelta(BaseModel): 11 | signature: str 12 | 13 | type: Literal["signature_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/stop_reason.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal, TypeAlias 4 | 5 | __all__ = ["StopReason"] 6 | 7 | StopReason: TypeAlias = Literal["end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal"] 8 | -------------------------------------------------------------------------------- /src/anthropic/types/text_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import List, Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | from .text_citation import TextCitation 8 | 9 | __all__ = ["TextBlock"] 10 | 11 | 12 | class TextBlock(BaseModel): 13 | citations: Optional[List[TextCitation]] = None 14 | """Citations supporting the text block. 15 | 16 | The type of citation returned will depend on the type of document being cited. 17 | Citing a PDF results in `page_location`, plain text results in `char_location`, 18 | and content document results in `content_block_location`. 19 | """ 20 | 21 | text: str 22 | 23 | type: Literal["text"] 24 | -------------------------------------------------------------------------------- /src/anthropic/types/text_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Iterable, Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .text_citation_param import TextCitationParam 9 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 10 | 11 | __all__ = ["TextBlockParam"] 12 | 13 | 14 | class TextBlockParam(TypedDict, total=False): 15 | text: Required[str] 16 | 17 | type: Required[Literal["text"]] 18 | 19 | cache_control: Optional[CacheControlEphemeralParam] 20 | """Create a cache control breakpoint at this content block.""" 21 | 22 | citations: Optional[Iterable[TextCitationParam]] 23 | -------------------------------------------------------------------------------- /src/anthropic/types/text_citation.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Union 4 | from typing_extensions import Annotated, TypeAlias 5 | 6 | from .._utils import PropertyInfo 7 | from .citation_char_location import CitationCharLocation 8 | from .citation_page_location import CitationPageLocation 9 | from .citation_content_block_location import CitationContentBlockLocation 10 | from .citations_web_search_result_location import CitationsWebSearchResultLocation 11 | 12 | __all__ = ["TextCitation"] 13 | 14 | TextCitation: TypeAlias = Annotated[ 15 | Union[CitationCharLocation, CitationPageLocation, CitationContentBlockLocation, CitationsWebSearchResultLocation], 16 | PropertyInfo(discriminator="type"), 17 | ] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/text_citation_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .citation_char_location_param import CitationCharLocationParam 9 | from .citation_page_location_param import CitationPageLocationParam 10 | from .citation_content_block_location_param import CitationContentBlockLocationParam 11 | from .citation_web_search_result_location_param import CitationWebSearchResultLocationParam 12 | 13 | __all__ = ["TextCitationParam"] 14 | 15 | TextCitationParam: TypeAlias = Union[ 16 | CitationCharLocationParam, 17 | CitationPageLocationParam, 18 | CitationContentBlockLocationParam, 19 | CitationWebSearchResultLocationParam, 20 | ] 21 | -------------------------------------------------------------------------------- /src/anthropic/types/text_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["TextDelta"] 8 | 9 | 10 | class TextDelta(BaseModel): 11 | text: str 12 | 13 | type: Literal["text_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/thinking_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["ThinkingBlock"] 8 | 9 | 10 | class ThinkingBlock(BaseModel): 11 | signature: str 12 | 13 | thinking: str 14 | 15 | type: Literal["thinking"] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/thinking_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ThinkingBlockParam"] 8 | 9 | 10 | class ThinkingBlockParam(TypedDict, total=False): 11 | signature: Required[str] 12 | 13 | thinking: Required[str] 14 | 15 | type: Required[Literal["thinking"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/thinking_config_disabled_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ThinkingConfigDisabledParam"] 8 | 9 | 10 | class ThinkingConfigDisabledParam(TypedDict, total=False): 11 | type: Required[Literal["disabled"]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/thinking_config_enabled_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ThinkingConfigEnabledParam"] 8 | 9 | 10 | class ThinkingConfigEnabledParam(TypedDict, total=False): 11 | budget_tokens: Required[int] 12 | """Determines how many tokens Claude can use for its internal reasoning process. 13 | 14 | Larger budgets can enable more thorough analysis for complex problems, improving 15 | response quality. 16 | 17 | Must be ≥1024 and less than `max_tokens`. 18 | 19 | See 20 | [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking) 21 | for details. 22 | """ 23 | 24 | type: Required[Literal["enabled"]] 25 | -------------------------------------------------------------------------------- /src/anthropic/types/thinking_config_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .thinking_config_enabled_param import ThinkingConfigEnabledParam 9 | from .thinking_config_disabled_param import ThinkingConfigDisabledParam 10 | 11 | __all__ = ["ThinkingConfigParam"] 12 | 13 | ThinkingConfigParam: TypeAlias = Union[ThinkingConfigEnabledParam, ThinkingConfigDisabledParam] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/thinking_delta.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["ThinkingDelta"] 8 | 9 | 10 | class ThinkingDelta(BaseModel): 11 | thinking: str 12 | 13 | type: Literal["thinking_delta"] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_bash_20250124_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 9 | 10 | __all__ = ["ToolBash20250124Param"] 11 | 12 | 13 | class ToolBash20250124Param(TypedDict, total=False): 14 | name: Required[Literal["bash"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["bash_20250124"]] 21 | 22 | cache_control: Optional[CacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_choice_any_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ToolChoiceAnyParam"] 8 | 9 | 10 | class ToolChoiceAnyParam(TypedDict, total=False): 11 | type: Required[Literal["any"]] 12 | 13 | disable_parallel_tool_use: bool 14 | """Whether to disable parallel tool use. 15 | 16 | Defaults to `false`. If set to `true`, the model will output exactly one tool 17 | use. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_choice_auto_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ToolChoiceAutoParam"] 8 | 9 | 10 | class ToolChoiceAutoParam(TypedDict, total=False): 11 | type: Required[Literal["auto"]] 12 | 13 | disable_parallel_tool_use: bool 14 | """Whether to disable parallel tool use. 15 | 16 | Defaults to `false`. If set to `true`, the model will output at most one tool 17 | use. 18 | """ 19 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_choice_none_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ToolChoiceNoneParam"] 8 | 9 | 10 | class ToolChoiceNoneParam(TypedDict, total=False): 11 | type: Required[Literal["none"]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_choice_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .tool_choice_any_param import ToolChoiceAnyParam 9 | from .tool_choice_auto_param import ToolChoiceAutoParam 10 | from .tool_choice_none_param import ToolChoiceNoneParam 11 | from .tool_choice_tool_param import ToolChoiceToolParam 12 | 13 | __all__ = ["ToolChoiceParam"] 14 | 15 | ToolChoiceParam: TypeAlias = Union[ToolChoiceAutoParam, ToolChoiceAnyParam, ToolChoiceToolParam, ToolChoiceNoneParam] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_choice_tool_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["ToolChoiceToolParam"] 8 | 9 | 10 | class ToolChoiceToolParam(TypedDict, total=False): 11 | name: Required[str] 12 | """The name of the tool to use.""" 13 | 14 | type: Required[Literal["tool"]] 15 | 16 | disable_parallel_tool_use: bool 17 | """Whether to disable parallel tool use. 18 | 19 | Defaults to `false`. If set to `true`, the model will output exactly one tool 20 | use. 21 | """ 22 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable, Optional 6 | from typing_extensions import Literal, Required, TypeAlias, TypedDict 7 | 8 | from .text_block_param import TextBlockParam 9 | from .image_block_param import ImageBlockParam 10 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 11 | 12 | __all__ = ["ToolResultBlockParam", "Content"] 13 | 14 | Content: TypeAlias = Union[TextBlockParam, ImageBlockParam] 15 | 16 | 17 | class ToolResultBlockParam(TypedDict, total=False): 18 | tool_use_id: Required[str] 19 | 20 | type: Required[Literal["tool_result"]] 21 | 22 | cache_control: Optional[CacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | 25 | content: Union[str, Iterable[Content]] 26 | 27 | is_error: bool 28 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_text_editor_20250124_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 9 | 10 | __all__ = ["ToolTextEditor20250124Param"] 11 | 12 | 13 | class ToolTextEditor20250124Param(TypedDict, total=False): 14 | name: Required[Literal["str_replace_editor"]] 15 | """Name of the tool. 16 | 17 | This is how the tool will be called by the model and in `tool_use` blocks. 18 | """ 19 | 20 | type: Required[Literal["text_editor_20250124"]] 21 | 22 | cache_control: Optional[CacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_union_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | from typing_extensions import TypeAlias 7 | 8 | from .tool_param import ToolParam 9 | from .tool_bash_20250124_param import ToolBash20250124Param 10 | from .web_search_tool_20250305_param import WebSearchTool20250305Param 11 | from .tool_text_editor_20250124_param import ToolTextEditor20250124Param 12 | 13 | __all__ = ["ToolUnionParam"] 14 | 15 | ToolUnionParam: TypeAlias = Union[ 16 | ToolParam, ToolBash20250124Param, ToolTextEditor20250124Param, WebSearchTool20250305Param 17 | ] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_use_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["ToolUseBlock"] 8 | 9 | 10 | class ToolUseBlock(BaseModel): 11 | id: str 12 | 13 | input: object 14 | 15 | name: str 16 | 17 | type: Literal["tool_use"] 18 | -------------------------------------------------------------------------------- /src/anthropic/types/tool_use_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 9 | 10 | __all__ = ["ToolUseBlockParam"] 11 | 12 | 13 | class ToolUseBlockParam(TypedDict, total=False): 14 | id: Required[str] 15 | 16 | input: Required[object] 17 | 18 | name: Required[str] 19 | 20 | type: Required[Literal["tool_use"]] 21 | 22 | cache_control: Optional[CacheControlEphemeralParam] 23 | """Create a cache control breakpoint at this content block.""" 24 | -------------------------------------------------------------------------------- /src/anthropic/types/url_image_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["URLImageSourceParam"] 8 | 9 | 10 | class URLImageSourceParam(TypedDict, total=False): 11 | type: Required[Literal["url"]] 12 | 13 | url: Required[str] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/url_pdf_source_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["URLPDFSourceParam"] 8 | 9 | 10 | class URLPDFSourceParam(TypedDict, total=False): 11 | type: Required[Literal["url"]] 12 | 13 | url: Required[str] 14 | -------------------------------------------------------------------------------- /src/anthropic/types/usage.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | from .server_tool_usage import ServerToolUsage 8 | 9 | __all__ = ["Usage"] 10 | 11 | 12 | class Usage(BaseModel): 13 | cache_creation_input_tokens: Optional[int] = None 14 | """The number of input tokens used to create the cache entry.""" 15 | 16 | cache_read_input_tokens: Optional[int] = None 17 | """The number of input tokens read from the cache.""" 18 | 19 | input_tokens: int 20 | """The number of input tokens which were used.""" 21 | 22 | output_tokens: int 23 | """The number of output tokens which were used.""" 24 | 25 | server_tool_use: Optional[ServerToolUsage] = None 26 | """The number of server tool requests.""" 27 | 28 | service_tier: Optional[Literal["standard", "priority", "batch"]] = None 29 | """If the request used the priority, standard, or batch tier.""" 30 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import Optional 4 | from typing_extensions import Literal 5 | 6 | from .._models import BaseModel 7 | 8 | __all__ = ["WebSearchResultBlock"] 9 | 10 | 11 | class WebSearchResultBlock(BaseModel): 12 | encrypted_content: str 13 | 14 | page_age: Optional[str] = None 15 | 16 | title: str 17 | 18 | type: Literal["web_search_result"] 19 | 20 | url: str 21 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | __all__ = ["WebSearchResultBlockParam"] 9 | 10 | 11 | class WebSearchResultBlockParam(TypedDict, total=False): 12 | encrypted_content: Required[str] 13 | 14 | title: Required[str] 15 | 16 | type: Required[Literal["web_search_result"]] 17 | 18 | url: Required[str] 19 | 20 | page_age: Optional[str] 21 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_tool_request_error_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing_extensions import Literal, Required, TypedDict 6 | 7 | __all__ = ["WebSearchToolRequestErrorParam"] 8 | 9 | 10 | class WebSearchToolRequestErrorParam(TypedDict, total=False): 11 | error_code: Required[ 12 | Literal["invalid_tool_input", "unavailable", "max_uses_exceeded", "too_many_requests", "query_too_long"] 13 | ] 14 | 15 | type: Required[Literal["web_search_tool_result_error"]] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_tool_result_block.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | from .web_search_tool_result_block_content import WebSearchToolResultBlockContent 7 | 8 | __all__ = ["WebSearchToolResultBlock"] 9 | 10 | 11 | class WebSearchToolResultBlock(BaseModel): 12 | content: WebSearchToolResultBlockContent 13 | 14 | tool_use_id: str 15 | 16 | type: Literal["web_search_tool_result"] 17 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_tool_result_block_content.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing import List, Union 4 | from typing_extensions import TypeAlias 5 | 6 | from .web_search_result_block import WebSearchResultBlock 7 | from .web_search_tool_result_error import WebSearchToolResultError 8 | 9 | __all__ = ["WebSearchToolResultBlockContent"] 10 | 11 | WebSearchToolResultBlockContent: TypeAlias = Union[WebSearchToolResultError, List[WebSearchResultBlock]] 12 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_tool_result_block_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | from typing_extensions import Literal, Required, TypedDict 7 | 8 | from .cache_control_ephemeral_param import CacheControlEphemeralParam 9 | from .web_search_tool_result_block_param_content_param import WebSearchToolResultBlockParamContentParam 10 | 11 | __all__ = ["WebSearchToolResultBlockParam"] 12 | 13 | 14 | class WebSearchToolResultBlockParam(TypedDict, total=False): 15 | content: Required[WebSearchToolResultBlockParamContentParam] 16 | 17 | tool_use_id: Required[str] 18 | 19 | type: Required[Literal["web_search_tool_result"]] 20 | 21 | cache_control: Optional[CacheControlEphemeralParam] 22 | """Create a cache control breakpoint at this content block.""" 23 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_tool_result_block_param_content_param.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union, Iterable 6 | from typing_extensions import TypeAlias 7 | 8 | from .web_search_result_block_param import WebSearchResultBlockParam 9 | from .web_search_tool_request_error_param import WebSearchToolRequestErrorParam 10 | 11 | __all__ = ["WebSearchToolResultBlockParamContentParam"] 12 | 13 | WebSearchToolResultBlockParamContentParam: TypeAlias = Union[ 14 | Iterable[WebSearchResultBlockParam], WebSearchToolRequestErrorParam 15 | ] 16 | -------------------------------------------------------------------------------- /src/anthropic/types/web_search_tool_result_error.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | 3 | from typing_extensions import Literal 4 | 5 | from .._models import BaseModel 6 | 7 | __all__ = ["WebSearchToolResultError"] 8 | 9 | 10 | class WebSearchToolResultError(BaseModel): 11 | error_code: Literal["invalid_tool_input", "unavailable", "max_uses_exceeded", "too_many_requests", "query_too_long"] 12 | 13 | type: Literal["web_search_tool_result_error"] 14 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | -------------------------------------------------------------------------------- /tests/api_resources/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | -------------------------------------------------------------------------------- /tests/api_resources/beta/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | -------------------------------------------------------------------------------- /tests/api_resources/beta/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | -------------------------------------------------------------------------------- /tests/api_resources/messages/__init__.py: -------------------------------------------------------------------------------- 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 | -------------------------------------------------------------------------------- /tests/sample_file.txt: -------------------------------------------------------------------------------- 1 | Hello, world! 2 | -------------------------------------------------------------------------------- /tests/test_utils/test_proxy.py: -------------------------------------------------------------------------------- 1 | import operator 2 | from typing import Any 3 | from typing_extensions import override 4 | 5 | from anthropic._utils import LazyProxy 6 | 7 | 8 | class RecursiveLazyProxy(LazyProxy[Any]): 9 | @override 10 | def __load__(self) -> Any: 11 | return self 12 | 13 | def __call__(self, *_args: Any, **_kwds: Any) -> Any: 14 | raise RuntimeError("This should never be called!") 15 | 16 | 17 | def test_recursive_proxy() -> None: 18 | proxy = RecursiveLazyProxy() 19 | assert repr(proxy) == "RecursiveLazyProxy" 20 | assert str(proxy) == "RecursiveLazyProxy" 21 | assert dir(proxy) == [] 22 | assert type(proxy).__name__ == "RecursiveLazyProxy" 23 | assert type(operator.attrgetter("name.foo.bar.baz")(proxy)).__name__ == "RecursiveLazyProxy" 24 | 25 | 26 | def test_isinstance_does_not_error() -> None: 27 | class AlwaysErrorProxy(LazyProxy[Any]): 28 | @override 29 | def __load__(self) -> Any: 30 | raise RuntimeError("Mocking missing dependency") 31 | 32 | proxy = AlwaysErrorProxy() 33 | assert not isinstance(proxy, dict) 34 | assert isinstance(proxy, LazyProxy) 35 | --------------------------------------------------------------------------------