[
  {
    "path": ".devcontainer/devcontainer.json",
    "content": "// For format details, see https://aka.ms/devcontainer.json. For config options, see the\n// README at: https://github.com/devcontainers/templates/tree/main/src/debian\n{\n  \"name\": \"Development\",\n  \"image\": \"mcr.microsoft.com/devcontainers/go:1.23-bookworm\",\n  \"postCreateCommand\": \"go mod tidy\"\n}\n"
  },
  {
    "path": ".github/CODEOWNERS",
    "content": "# This file is used to automatically assign reviewers to PRs\n# For more information see: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners\n\n* @anthropics/sdk\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\non:\n  push:\n    branches:\n      - '**'\n      - '!integrated/**'\n      - '!stl-preview-head/**'\n      - '!stl-preview-base/**'\n      - '!generated'\n      - '!codegen/**'\n      - 'codegen/stl/**'\n  pull_request:\n    branches-ignore:\n      - 'stl-preview-head/**'\n      - 'stl-preview-base/**'\n\njobs:\n  build:\n    timeout-minutes: 10\n    name: build\n    permissions:\n      contents: read\n      id-token: write\n    runs-on: ${{ github.repository == 'stainless-sdks/anthropic-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}\n    if: |-\n      github.repository == 'stainless-sdks/anthropic-go' &&\n      (github.event_name == 'push' || github.event.pull_request.head.repo.fork)\n    steps:\n      - uses: actions/checkout@v6\n\n      - name: Get GitHub OIDC Token\n        if: |-\n          github.repository == 'stainless-sdks/anthropic-go' &&\n          !startsWith(github.ref, 'refs/heads/stl/')\n        id: github-oidc\n        uses: actions/github-script@v8\n        with:\n          script: core.setOutput('github_token', await core.getIDToken());\n\n      - name: Upload tarball\n        if: |-\n          github.repository == 'stainless-sdks/anthropic-go' &&\n          !startsWith(github.ref, 'refs/heads/stl/')\n        env:\n          URL: https://pkg.stainless.com/s\n          AUTH: ${{ steps.github-oidc.outputs.github_token }}\n          SHA: ${{ github.sha }}\n        run: ./scripts/utils/upload-artifact.sh\n  lint:\n    timeout-minutes: 10\n    name: lint\n    runs-on: ${{ github.repository == 'stainless-sdks/anthropic-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}\n    if: github.event_name == 'push' || github.event.pull_request.head.repo.fork\n\n    steps:\n      - uses: actions/checkout@v6\n\n      - name: Setup go\n        uses: actions/setup-go@v5\n        with:\n          go-version-file: ./go.mod\n\n      - name: Run lints\n        run: ./scripts/lint\n  test:\n    timeout-minutes: 10\n    name: test\n    runs-on: ${{ github.repository == 'stainless-sdks/anthropic-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}\n    if: github.event_name == 'push' || github.event.pull_request.head.repo.fork\n    steps:\n      - uses: actions/checkout@v6\n\n      - name: Setup go\n        uses: actions/setup-go@v5\n        with:\n          go-version-file: ./go.mod\n\n      - name: Bootstrap\n        run: ./scripts/bootstrap\n\n      - name: Run tests\n        run: ./scripts/test\n"
  },
  {
    "path": ".github/workflows/claude.yml",
    "content": "name: Claude Code\n\non:\n  issue_comment:\n    types: [created]\n  pull_request_review_comment:\n    types: [created]\n  issues:\n    types: [opened, assigned]\n  pull_request_review:\n    types: [submitted]\n\njobs:\n  claude:\n    if: |\n      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||\n      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||\n      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||\n      (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      pull-requests: read\n      issues: read\n      id-token: write\n      actions: read # Required for Claude to read CI results on PRs\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 1\n\n      - name: Run Claude Code\n        id: claude\n        uses: anthropics/claude-code-action@v1\n        with:\n          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}\n\n          # This is an optional setting that allows Claude to read CI results on PRs\n          additional_permissions: |\n            actions: read\n\n          # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.\n          # prompt: 'Update the pull request description to include a summary of changes.'\n\n          # Optional: Add claude_args to customize behavior and configuration\n          # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md\n          # or https://code.claude.com/docs/en/cli-reference for available options\n          # claude_args: '--allowed-tools Bash(gh pr:*)'\n\n"
  },
  {
    "path": ".github/workflows/create-releases.yml",
    "content": "name: Create releases\non:\n  schedule:\n    - cron: '0 5 * * *' # every day at 5am UTC\n  push:\n    branches:\n      - main\n\njobs:\n  release:\n    name: release\n    if: github.ref == 'refs/heads/main' && github.repository == 'anthropics/anthropic-sdk-go'\n    runs-on: ubuntu-latest\n    environment: production-release\n\n    steps:\n      - uses: actions/checkout@v6\n\n      - uses: stainless-api/trigger-release-please@v1\n        id: release\n        with:\n          repo: ${{ github.event.repository.full_name }}\n          stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}\n\n      - name: Generate godocs\n        if: ${{ steps.release.outputs.releases_created }}\n        run: |\n          # x-release-please-start-version\n          version=$(jq -r '. | to_entries[0] | .value' .release-please-manifest.json)\n          curl -X POST https://pkg.go.dev/fetch/github.com/anthropics/anthropic-sdk-go@v${version}\n          # x-release-please-end\n"
  },
  {
    "path": ".github/workflows/detect-breaking-changes.yml",
    "content": "name: CI\non:\n  pull_request:\n    branches:\n      - main\n      - next\n\njobs:\n  detect_breaking_changes:\n    runs-on: 'ubuntu-latest'\n    name: detect-breaking-changes\n    if: github.repository == 'anthropics/anthropic-sdk-go'\n    steps:\n      - name: Calculate fetch-depth\n        run: |\n          echo \"FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)\" >> $GITHUB_ENV\n\n      - uses: actions/checkout@v6\n        with:\n          # Ensure we can check out the pull request base in the script below.\n          fetch-depth: ${{ env.FETCH_DEPTH }}\n\n      - name: Setup go\n        uses: actions/setup-go@v5\n        with:\n          go-version-file: ./go.mod\n\n      - name: Detect breaking changes\n        run: |\n          # Try to check out previous versions of the breaking change detection script. This ensures that\n          # we still detect breaking changes when entire files and their tests are removed.\n          git checkout \"${{ github.event.pull_request.base.sha }}\" -- ./scripts/detect-breaking-changes 2>/dev/null || true\n          ./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }}"
  },
  {
    "path": ".gitignore",
    "content": ".prism.log\ncodegen.log\nBrewfile.lock.json\n.idea/\n"
  },
  {
    "path": ".release-please-manifest.json",
    "content": "{\n  \".\": \"1.27.1\"\n}\n"
  },
  {
    "path": ".stats.yml",
    "content": "configured_endpoints: 34\nopenapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-dd2dcd00a757075370a7e4a7f469a1e2d067c2118684c3b70d7906a8f5cf518b.yml\nopenapi_spec_hash: ebeeaa9a9bf7603f0bbcce30389e27ca\nconfig_hash: f292746941a1c02183ee7646c37753af\n"
  },
  {
    "path": "Brewfile",
    "content": "brew \"go\"\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n## 1.27.1 (2026-03-18)\n\nFull Changelog: [v1.27.0...v1.27.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.27.0...v1.27.1)\n\n### Chores\n\n* **internal:** regenerate SDK with no functional changes ([c963fd0](https://github.com/anthropics/anthropic-sdk-go/commit/c963fd0fd1e591bfd572f100a3a444ba40fe4ad4))\n* **internal:** tweak CI branches ([95e3410](https://github.com/anthropics/anthropic-sdk-go/commit/95e3410a6892afae8b1b4631d05b5bfd4bf12eb2))\n\n## 1.27.0 (2026-03-16)\n\nFull Changelog: [v1.26.0...v1.27.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.26.0...v1.27.0)\n\n### Features\n\n* **api:** change array_format to brackets ([ca5ae6e](https://github.com/anthropics/anthropic-sdk-go/commit/ca5ae6eaf8243aece877d33eb88653db2e439a36))\n* **api:** chore(config): clean up model enum list ([#31](https://github.com/anthropics/anthropic-sdk-go/issues/31)) ([1db4ea7](https://github.com/anthropics/anthropic-sdk-go/commit/1db4ea7956259bb217bc2523a5244b6029c4bd15))\n* **api:** GA thinking-display-setting ([1924af2](https://github.com/anthropics/anthropic-sdk-go/commit/1924af22e00fad68ccf31a3809c8cab8d442c048))\n* **api:** remove publishing section from cli target ([514282e](https://github.com/anthropics/anthropic-sdk-go/commit/514282e1728881f7ef4c6782f3000ca0ec632d53))\n* **tests:** update mock server ([cf24ced](https://github.com/anthropics/anthropic-sdk-go/commit/cf24ced2844da5d0f645e7a2afbabb936c891892))\n\n\n### Bug Fixes\n\n* allow canceling a request while it is waiting to retry ([32ee053](https://github.com/anthropics/anthropic-sdk-go/commit/32ee05317970d99df3147c65c2055efabe354472))\n* **client:** update model reference from claude-3-7-sonnet-latest to claude-sonnet-4-5 ([2f42e73](https://github.com/anthropics/anthropic-sdk-go/commit/2f42e7336295d898d18c66ddd6f9f70bab108cc6))\n\n\n### Chores\n\n* **client:** reorganize code in Messages files to lead to less conflicts ([c677bb5](https://github.com/anthropics/anthropic-sdk-go/commit/c677bb58a3da8f17f0dbc630b5b28faed995aa6b))\n* **internal:** codegen related update ([c978aac](https://github.com/anthropics/anthropic-sdk-go/commit/c978aacf53bbcf6555ba97bdc6bdfc9be9d8f98d))\n* **internal:** codegen related update ([4ac31a2](https://github.com/anthropics/anthropic-sdk-go/commit/4ac31a2fb9dc45a41bcbaa25dfbf8848119768ec))\n* **internal:** codegen related update ([5b2b2fa](https://github.com/anthropics/anthropic-sdk-go/commit/5b2b2fa276ad9365ddcb53270f307db05e5b6363))\n* **internal:** codegen related update ([9678c6c](https://github.com/anthropics/anthropic-sdk-go/commit/9678c6c5d375f66cb569a537a0766a5ed4d8f7f0))\n* **internal:** codegen related update ([f6035d2](https://github.com/anthropics/anthropic-sdk-go/commit/f6035d2bb0c50cf97cea78fb3fe854289b11a34c))\n* **internal:** codegen related update ([9246bbb](https://github.com/anthropics/anthropic-sdk-go/commit/9246bbb15553cee531b5caef2c7876e84a8fe8f2))\n* **internal:** move custom custom `json` tags to `api` ([4392627](https://github.com/anthropics/anthropic-sdk-go/commit/4392627107c43726c242923c16b0f5ac2b432082))\n* **tests:** unskip tests that are now supported in steady ([b0ca374](https://github.com/anthropics/anthropic-sdk-go/commit/b0ca37403486c65ae171d2b330ff82c938fe9b58))\n\n\n### Documentation\n\n* streamline README, centralize documentation at docs.anthropic.com ([33f6943](https://github.com/anthropics/anthropic-sdk-go/commit/33f69431abd96025134d8967c20a1f313af3382d)), closes [#587](https://github.com/anthropics/anthropic-sdk-go/issues/587)\n\n## 1.26.0 (2026-02-19)\n\nFull Changelog: [v1.25.1...v1.26.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.25.1...v1.26.0)\n\n### Features\n\n* **api:** Add top-level cache control (automatic caching) ([75f9f70](https://github.com/anthropics/anthropic-sdk-go/commit/75f9f70045587c458ec2e3491b4eb88bc3329e9e))\n* **client:** add BetaToolRunner for automatic tool use loops ([#603](https://github.com/anthropics/anthropic-sdk-go/issues/603)) ([e44128a](https://github.com/anthropics/anthropic-sdk-go/commit/e44128a1a3c1d9b4710b4a024ace8121258b32b6))\n\n\n### Chores\n\n* **internal:** codegen related update ([6247d2f](https://github.com/anthropics/anthropic-sdk-go/commit/6247d2febe87242ee9d3ba49875ff62a5be9a626))\n\n## 1.25.1 (2026-02-19)\n\nFull Changelog: [v1.25.0...v1.25.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.25.0...v1.25.1)\n\n### Bug Fixes\n\n* **client:** use correct format specifier for header serialization ([9115a61](https://github.com/anthropics/anthropic-sdk-go/commit/9115a6154d0b1ba94370911822986b2ef8584e9a))\n\n## 1.25.0 (2026-02-18)\n\nFull Changelog: [v1.24.0...v1.25.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.24.0...v1.25.0)\n\n### Features\n\n* **api:** fix shared UserLocation and error code types ([cb98cd0](https://github.com/anthropics/anthropic-sdk-go/commit/cb98cd00c359c0181d7b39bdb057e7b06015aa33))\n\n## 1.24.0 (2026-02-18)\n\nFull Changelog: [v1.23.0...v1.24.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.23.0...v1.24.0)\n\n### Features\n\n* **api:** manual updates ([54d01f5](https://github.com/anthropics/anthropic-sdk-go/commit/54d01f5187ef9ec49f803edfe643bf1bf1e91072))\n\n## 1.23.0 (2026-02-17)\n\nFull Changelog: [v1.22.1...v1.23.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.22.1...v1.23.0)\n\n### Features\n\n* **api:** Releasing claude-sonnet-4-6 ([782d5a5](https://github.com/anthropics/anthropic-sdk-go/commit/782d5a5dc4c1f63cfef3afc5d257b08f8cf3fadc))\n\n\n### Bug Fixes\n\n* **api:** fix spec errors ([15e6a5a](https://github.com/anthropics/anthropic-sdk-go/commit/15e6a5a0b4fb426f126f7b26b087709ea7ba00ac))\n* remove duplicate ServerToolUseBlock struct declaration ([#595](https://github.com/anthropics/anthropic-sdk-go/issues/595)) ([d4ece8a](https://github.com/anthropics/anthropic-sdk-go/commit/d4ece8ae310dd0369a5ea05671295ae2c23a53d9))\n\n## 1.22.1 (2026-02-10)\n\nFull Changelog: [v1.22.0...v1.22.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.22.0...v1.22.1)\n\n### Bug Fixes\n\n* **encoder:** correctly serialize NullStruct ([1435f8a](https://github.com/anthropics/anthropic-sdk-go/commit/1435f8ac4d272561c7e689cc6bb4e3794414ba57))\n\n## 1.22.0 (2026-02-07)\n\nFull Changelog: [v1.21.0...v1.22.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.21.0...v1.22.0)\n\n### Features\n\n* **api:** enabling fast-mode in claude-opus-4-6 ([ebe6433](https://github.com/anthropics/anthropic-sdk-go/commit/ebe6433768cab86dcc02b71159aaa347a8d473ec))\n\n## 1.21.0 (2026-02-05)\n\nFull Changelog: [v1.20.0...v1.21.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.20.0...v1.21.0)\n\n### Features\n\n* **api:** Release Claude Opus 4.6, adaptive thinking, and other features ([e899e64](https://github.com/anthropics/anthropic-sdk-go/commit/e899e64cd402eb004909d632e68acc4b0587f53c))\n\n\n### Chores\n\n* **ci:** remove claude-code-review workflow ([31db702](https://github.com/anthropics/anthropic-sdk-go/commit/31db70249f691b161f326f550dc26cdcce54dd30))\n\n## 1.20.0 (2026-01-29)\n\nFull Changelog: [v1.19.0...v1.20.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.19.0...v1.20.0)\n\n### Features\n\n* **api:** add support for Structured Outputs in the Messages API ([10c3821](https://github.com/anthropics/anthropic-sdk-go/commit/10c382188df98d7b045aec525bdc47f3df25d576))\n* **api:** migrate sending message format in output_config rather than output_format ([f996db4](https://github.com/anthropics/anthropic-sdk-go/commit/f996db402bc1f868b11d877014a6c51d977c557f))\n* **client:** add a convenient param.SetJSON helper ([427514e](https://github.com/anthropics/anthropic-sdk-go/commit/427514ea6dde81f4eb374967577b5a4cf380f627))\n* **encoder:** support bracket encoding form-data object members ([eaaeadf](https://github.com/anthropics/anthropic-sdk-go/commit/eaaeadf6dd67119ca4406f0fb0337c16d9011b8f))\n\n\n### Bug Fixes\n\n* **accumulator:** revert to marshal accumulator on stop events ([#563](https://github.com/anthropics/anthropic-sdk-go/issues/563)) ([096a8a8](https://github.com/anthropics/anthropic-sdk-go/commit/096a8a8b20b530359c214e06272938bcf8a98c59))\n* **client:** retain streaming when user sets request body ([6d073fe](https://github.com/anthropics/anthropic-sdk-go/commit/6d073fe49f351c26c7f3fa8337e661c6a3600c68))\n* **docs:** add missing pointer prefix to api.md return types ([23aaf6d](https://github.com/anthropics/anthropic-sdk-go/commit/23aaf6de59f0c13c79dbe4fc1d764b47cfd83834))\n* **mcp:** correct code tool API endpoint ([6c8a083](https://github.com/anthropics/anthropic-sdk-go/commit/6c8a0831e6f084d316179a9288c4fa1c5420ea59))\n* rename param to avoid collision ([6d1cf75](https://github.com/anthropics/anthropic-sdk-go/commit/6d1cf75d5a407d5eb19c70e3778ab82bca74d0d5))\n* streaming endpoints should pass through errors correctly ([e584c87](https://github.com/anthropics/anthropic-sdk-go/commit/e584c87ec001ee8991ca17b8236a6ef3deb78ea7))\n* **to-param:** remove panics and add cases ([#524](https://github.com/anthropics/anthropic-sdk-go/issues/524)) ([f689816](https://github.com/anthropics/anthropic-sdk-go/commit/f6898163047854d39cec7c08ec5ab993bab463fc))\n\n\n### Chores\n\n* add float64 to valid types for RegisterFieldValidator ([b6bec73](https://github.com/anthropics/anthropic-sdk-go/commit/b6bec73c5ed18698884b990fc3dc6398a3784177))\n* **ci:** Add Claude Code GitHub Workflow ([a151836](https://github.com/anthropics/anthropic-sdk-go/commit/a151836056343974d15eda64180fc776ba0f169d))\n* **client:** improve example values ([8af69b8](https://github.com/anthropics/anthropic-sdk-go/commit/8af69b851f4a60334ed75542c2eacbe69c01893c))\n* **client:** mark claude-3-5-haiku as deprecated ([dcac65c](https://github.com/anthropics/anthropic-sdk-go/commit/dcac65c8dd82f232c2997456319c16357874f37b))\n* elide duplicate aliases ([c8e2ee1](https://github.com/anthropics/anthropic-sdk-go/commit/c8e2ee14de53b5636eadccb2a890e4464e30b8d4))\n* **internal:** codegen related update ([931c976](https://github.com/anthropics/anthropic-sdk-go/commit/931c9769f1ff0557a8eff333463e1847b15f7953))\n* **internal:** update `actions/checkout` version ([3bd83ec](https://github.com/anthropics/anthropic-sdk-go/commit/3bd83eca53f1ec0b759c2568601286405821dcbc))\n* **internal:** use different example values for some enums ([f2d46b8](https://github.com/anthropics/anthropic-sdk-go/commit/f2d46b87de1a57ed1790cad3134b5e340f22fd73))\n\n## 1.19.0 (2025-11-24)\n\nFull Changelog: [v1.18.1...v1.19.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.18.1...v1.19.0)\n\n### Features\n\n* **api:** adds support for Claude Opus 4.5, Effort, Advance Tool Use Features, Autocompaction, and Computer Use v5 ([a03391c](https://github.com/anthropics/anthropic-sdk-go/commit/a03391cb00b8c78c79fd8bfe447f00d78f37db25))\n\n## 1.18.1 (2025-11-19)\n\nFull Changelog: [v1.18.0...v1.18.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.18.0...v1.18.1)\n\n### Bug Fixes\n\n* **structured outputs:** use correct beta header ([09ec0a6](https://github.com/anthropics/anthropic-sdk-go/commit/09ec0a647b1a108bb7c74e4c7b1016502ca781bb))\n\n## 1.18.0 (2025-11-14)\n\nFull Changelog: [v1.17.0...v1.18.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.17.0...v1.18.0)\n\n### Features\n\n* **api:** add support for structured outputs beta ([fb9cfb4](https://github.com/anthropics/anthropic-sdk-go/commit/fb9cfb4e4b571d5fec7da9874610aa8820aee80c))\n\n\n### Chores\n\n* bump gjson version ([69b5e0e](https://github.com/anthropics/anthropic-sdk-go/commit/69b5e0e40757884bece66397fb6ca769f4e00118))\n\n## 1.17.0 (2025-11-05)\n\nFull Changelog: [v1.16.0...v1.17.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.16.0...v1.17.0)\n\n### Features\n\n* **bedrock:** re-route beta headers through request body ([00a2bf3](https://github.com/anthropics/anthropic-sdk-go/commit/00a2bf35b34aa49f1514493cf0638b467c4f4eec))\n\n\n### Chores\n\n* **internal:** grammar fix (it's -&gt; its) ([687bc29](https://github.com/anthropics/anthropic-sdk-go/commit/687bc299cacb84349eb2684df46994c06f9ba962))\n\n## 1.16.0 (2025-10-29)\n\nFull Changelog: [v1.15.0...v1.16.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.15.0...v1.16.0)\n\n### Features\n\n* **api:** add ability to clear thinking in context management ([6082754](https://github.com/anthropics/anthropic-sdk-go/commit/6082754e9b6a04570a93efdb5339853c71f1fe94))\n\n## 1.15.0 (2025-10-28)\n\nFull Changelog: [v1.14.0...v1.15.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.14.0...v1.15.0)\n\n### Features\n\n* **api:** adding support for agent skills ([5660b52](https://github.com/anthropics/anthropic-sdk-go/commit/5660b5252a4de07f3343c9089b148b16cda794d4))\n\n\n### Chores\n\n* **api:** mark older sonnet models as deprecated ([f13c5bd](https://github.com/anthropics/anthropic-sdk-go/commit/f13c5bd18ebb169c59913985537ca025634ef7eb))\n\n## 1.14.0 (2025-10-15)\n\nFull Changelog: [v1.13.0...v1.14.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.13.0...v1.14.0)\n\n### Features\n\n* **api:** manual updates ([3eac8aa](https://github.com/anthropics/anthropic-sdk-go/commit/3eac8aaee0dbb3f4a5e30b039d60503614365a82))\n\n\n### Chores\n\n* **client:** add context-management-2025-06-27 beta header ([eeba6fa](https://github.com/anthropics/anthropic-sdk-go/commit/eeba6fa95ca9eedf16897b413950fc5f80d0d8cb))\n* **client:** add model-context-window-exceeded-2025-08-26 beta header ([7d5a37d](https://github.com/anthropics/anthropic-sdk-go/commit/7d5a37d895b769739d23b6e91f6c0a806cade710))\n\n## 1.13.0 (2025-09-29)\n\nFull Changelog: [v1.12.0...v1.13.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.12.0...v1.13.0)\n\n### Features\n\n* **api:** adds support for Claude Sonnet 4.5 and context management features ([3d5d51a](https://github.com/anthropics/anthropic-sdk-go/commit/3d5d51ad6ee64b34c7cc361a9dfd6f45966987dd))\n\n\n### Bug Fixes\n\n* bugfix for setting JSON keys with special characters ([c868b92](https://github.com/anthropics/anthropic-sdk-go/commit/c868b921190f8d371cc93d12e019daf5a7463306))\n* **internal:** unmarshal correctly when there are multiple discriminators ([ecc3ce3](https://github.com/anthropics/anthropic-sdk-go/commit/ecc3ce31a9ed98b8f2b66b5e1489fce510528f77))\n* use slices.Concat instead of sometimes modifying r.Options ([88e7186](https://github.com/anthropics/anthropic-sdk-go/commit/88e7186cad944290498a3381c829df36d26a1cce))\n\n\n### Chores\n\n* bump minimum go version to 1.22 ([87af8f3](https://github.com/anthropics/anthropic-sdk-go/commit/87af8f397ae68ce72a76a07a735d21495aad8799))\n* do not install brew dependencies in ./scripts/bootstrap by default ([c689348](https://github.com/anthropics/anthropic-sdk-go/commit/c689348cc4b5ec7ab3512261e4e3cc50d208a02c))\n* **internal:** fix tests ([bfc6eaf](https://github.com/anthropics/anthropic-sdk-go/commit/bfc6eafeff58664f0d6f155f96286f3993e60f89))\n* update more docs for 1.22 ([d67c50d](https://github.com/anthropics/anthropic-sdk-go/commit/d67c50d49082b4b28bdabc44943853431cd5205c))\n\n## 1.12.0 (2025-09-10)\n\nFull Changelog: [v1.11.0...v1.12.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.11.0...v1.12.0)\n\n### Features\n\n* **api:** adds support for web_fetch_20250910 tool ([6d5e237](https://github.com/anthropics/anthropic-sdk-go/commit/6d5e2370e14e1d125ebebcf741b721e88dc0e810))\n\n\n### Chores\n\n* tmp ([07b65e9](https://github.com/anthropics/anthropic-sdk-go/commit/07b65e9b178a1c280fc96e3f2a7bf30bd9932329))\n\n## 1.11.0 (2025-09-05)\n\nFull Changelog: [v1.10.0...v1.11.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.10.0...v1.11.0)\n\n### Features\n\n* **api:** adds support for Documents in tool results ([7161c2c](https://github.com/anthropics/anthropic-sdk-go/commit/7161c2ce9843b80374186dc83fd84a8dfebda45f))\n\n\n### Bug Fixes\n\n* **client:** fix issue in Go with nested document content params ([b442cc3](https://github.com/anthropics/anthropic-sdk-go/commit/b442cc3fd41ee53a18f8ccec868ae1057dae53a8))\n* use release please annotations on more places ([31a09b0](https://github.com/anthropics/anthropic-sdk-go/commit/31a09b07991cc92d38517c80320d154246779a76))\n\n## 1.10.0 (2025-09-02)\n\nFull Changelog: [v1.9.1...v1.10.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.9.1...v1.10.0)\n\n### Features\n\n* **api:** makes 1 hour TTL Cache Control generally available ([c28a9a3](https://github.com/anthropics/anthropic-sdk-go/commit/c28a9a3272acb1973f2a2fb768157ab27a8f440d))\n* **client:** adds support for code-execution-2025-08-26 tool ([066a126](https://github.com/anthropics/anthropic-sdk-go/commit/066a126a92a8e09f10742f13e0db36724a96c788))\n* use custom decoder for []ContentBlockParamUnion ([#464](https://github.com/anthropics/anthropic-sdk-go/issues/464)) ([4731597](https://github.com/anthropics/anthropic-sdk-go/commit/473159792468018c709da311d7ac27139cf851e6))\n\n\n### Bug Fixes\n\n* close body before retrying ([c970e10](https://github.com/anthropics/anthropic-sdk-go/commit/c970e10ff45c04c38a5a2c87fe85a8c191e06f80))\n\n\n### Chores\n\n* deprecate older claude-3-5 sonnet models ([#453](https://github.com/anthropics/anthropic-sdk-go/issues/453)) ([e49d59b](https://github.com/anthropics/anthropic-sdk-go/commit/e49d59b14be89dcfb858b565e5183ecf9c1e246b))\n\n## 1.9.1 (2025-08-12)\n\nFull Changelog: [v1.9.0...v1.9.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.9.0...v1.9.1)\n\n## 1.9.0 (2025-08-12)\n\nFull Changelog: [v1.8.0...v1.9.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.8.0...v1.9.0)\n\n### Features\n\n* **betas:** add context-1m-2025-08-07 ([c086118](https://github.com/anthropics/anthropic-sdk-go/commit/c086118c9acd55ec711b29a08f165b358e56332b))\n\n\n### Chores\n\n* **internal:** detect breaking changes when removing endpoints ([91ea519](https://github.com/anthropics/anthropic-sdk-go/commit/91ea5197646ffd3d807610f11bab8726092e7a4b))\n* **internal:** update comment in script ([de412b0](https://github.com/anthropics/anthropic-sdk-go/commit/de412b007a097ce7d3231e0ccdf7d57572f78199))\n* update @stainless-api/prism-cli to v5.15.0 ([555556f](https://github.com/anthropics/anthropic-sdk-go/commit/555556f4ce77d406e904733b30c782039dacb837))\n\n## 1.8.0 (2025-08-08)\n\nFull Changelog: [v1.7.0...v1.8.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.7.0...v1.8.0)\n\n### Features\n\n* **api:** search result content blocks ([0907804](https://github.com/anthropics/anthropic-sdk-go/commit/0907804ae58405abc4f4c0acb76464da3abdd00b))\n* **client:** support optional json html escaping ([8da877c](https://github.com/anthropics/anthropic-sdk-go/commit/8da877cb04c62d081d36a1f8cb5eea7922a396ce))\n\n## 1.7.0 (2025-08-05)\n\nFull Changelog: [v1.6.2...v1.7.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.6.2...v1.7.0)\n\n### Features\n\n* **api:** add claude-opus-4-1-20250805 ([72c9d29](https://github.com/anthropics/anthropic-sdk-go/commit/72c9d29255cb59d11b132062df00889a63dd609e))\n* **api:** adds support for text_editor_20250728 tool ([be56278](https://github.com/anthropics/anthropic-sdk-go/commit/be56278e456ff5eb034852e17a4642be612e30a2))\n* **api:** removed older deprecated models ([88a397a](https://github.com/anthropics/anthropic-sdk-go/commit/88a397acb01a7557fbd6852f85ece295a7c2a2b7))\n* **docs:** add File Upload example ([bade71b](https://github.com/anthropics/anthropic-sdk-go/commit/bade71b64850e8fa4410c404f263d4252cdbb82d))\n* update streaming error message to say 'required' not 'recommended' ([0fb3d30](https://github.com/anthropics/anthropic-sdk-go/commit/0fb3d30814f8aead1237283a994f405c1103aff2))\n* update streaming error message to say 'required' not 'recommended' ([b23f6df](https://github.com/anthropics/anthropic-sdk-go/commit/b23f6df73098c6fe3aa599beb73973b699c4b2a4))\n\n\n### Bug Fixes\n\n* **client:** process custom base url ahead of time ([2165b1a](https://github.com/anthropics/anthropic-sdk-go/commit/2165b1ac1c78491be85fdc6b49c63ab027caeed6))\n\n\n### Chores\n\n* **client:** add TextEditor_20250429 tool ([20424fc](https://github.com/anthropics/anthropic-sdk-go/commit/20424fc340b4f10b208f5ba8ee2d2b4a6f9e546d))\n* **internal:** version bump ([e03b3bd](https://github.com/anthropics/anthropic-sdk-go/commit/e03b3bdd13e207925a9da2b12b830ce9bb6ed88b))\n\n## 1.6.2 (2025-07-18)\n\nFull Changelog: [v1.6.1...v1.6.2](https://github.com/anthropics/anthropic-sdk-go/compare/v1.6.1...v1.6.2)\n\n### Chores\n\n* **internal:** version bump ([defc645](https://github.com/anthropics/anthropic-sdk-go/commit/defc6458496679762e07ce8dc9838335e4bd8268))\n\n## 1.6.1 (2025-07-18)\n\nFull Changelog: [v1.6.0...v1.6.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.6.0...v1.6.1)\n\n### Chores\n\n* **internal:** version bump ([459dd39](https://github.com/anthropics/anthropic-sdk-go/commit/459dd391b281273af9027a23e39b78c422dace0b))\n\n## 1.6.0 (2025-07-18)\n\nFull Changelog: [v1.5.0...v1.6.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.5.0...v1.6.0)\n\n### Features\n\n* **client:** expand max streaming buffer size ([8b206e2](https://github.com/anthropics/anthropic-sdk-go/commit/8b206e2267b83af7e9f7f56f029497bd403608fe))\n\n\n### Bug Fixes\n\n* **api:** revert change to NewToolResultBlock ([b4167e7](https://github.com/anthropics/anthropic-sdk-go/commit/b4167e7b3bb80927b3f397c0b6fb00f7340272a0))\n* **client:** fix default timeout logic to match other languages ([47e47f5](https://github.com/anthropics/anthropic-sdk-go/commit/47e47f54f8bd1a58413c82137713bedf88e2d4d2))\n* **tests:** make sure to build examples in scripts/lint ([69bcb13](https://github.com/anthropics/anthropic-sdk-go/commit/69bcb139fcf661bff527d345e9876c26c784befc))\n\n\n### Chores\n\n* **api:** update BetaCitationSearchResultLocation ([5d040a7](https://github.com/anthropics/anthropic-sdk-go/commit/5d040a7698b11ee059c175ce4a806509a9ae8e5b))\n* **internal:** fix lint script for tests ([f54301d](https://github.com/anthropics/anthropic-sdk-go/commit/f54301d9f251fa6e409852605f2d301c50d3466d))\n* **internal:** restructure things to avoid conflicts ([5f1bead](https://github.com/anthropics/anthropic-sdk-go/commit/5f1bead6fd696504d63ebbbf21c1a55c707a3df7))\n* lint tests ([4a64d14](https://github.com/anthropics/anthropic-sdk-go/commit/4a64d14e7988ba0c2343d7abc65f15da41bafb24))\n* lint tests in subpackages ([4ae61a6](https://github.com/anthropics/anthropic-sdk-go/commit/4ae61a601cf94e459bc431e07c9b7e25557af493))\n\n\n### Documentation\n\n* model in examples ([da9d5af](https://github.com/anthropics/anthropic-sdk-go/commit/da9d5af61544a6f25d9284ee6eee25f5d1364e8a))\n* model in examples ([fe2da16](https://github.com/anthropics/anthropic-sdk-go/commit/fe2da16e4bf05ee7029b1be33059bf3a4e76c300))\n\n## 1.5.0 (2025-07-03)\n\nFull Changelog: [v1.4.0...v1.5.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.4.0...v1.5.0)\n\n### Features\n\n* add RequestID to API errors ([884f13b](https://github.com/anthropics/anthropic-sdk-go/commit/884f13b87969c94bd3ed1343c17c84e69b676de8))\n* **api:** add support for Search Result Content Blocks ([1f6ab8a](https://github.com/anthropics/anthropic-sdk-go/commit/1f6ab8aa2f3a29ca92920545933fc028b4701d20))\n* **api:** api update ([27a18f2](https://github.com/anthropics/anthropic-sdk-go/commit/27a18f25697da82de75d5800a9077353bb5319a6))\n* **api:** manual updates ([926b094](https://github.com/anthropics/anthropic-sdk-go/commit/926b094724c0443e8c2d19fc2c885d296254c01a))\n* **client:** add debug log helper ([e427bb3](https://github.com/anthropics/anthropic-sdk-go/commit/e427bb35859880729e16cca16499accc3bb19a1b))\n* **client:** add escape hatch for null slice & maps ([9e3ded0](https://github.com/anthropics/anthropic-sdk-go/commit/9e3ded03652bfd8fc5e63095f0849995907537fb))\n* **vertex:** support global region endpoint ([3c0b86d](https://github.com/anthropics/anthropic-sdk-go/commit/3c0b86dc60bd05d12e854b8ec0fac79418532c78))\n\n\n### Bug Fixes\n\n* **client:** deprecate BetaBase64PDFBlock in favor of BetaRequestDocumentBlock ([5d8fd96](https://github.com/anthropics/anthropic-sdk-go/commit/5d8fd9661585c1894aeb4e80670d577ab1cc3582))\n* don't try to deserialize as json when ResponseBodyInto is []byte ([0e7ce7b](https://github.com/anthropics/anthropic-sdk-go/commit/0e7ce7b16f5af7afc94333cdef6958a08875a71d))\n* **pagination:** check if page data is empty in GetNextPage ([d64dc0a](https://github.com/anthropics/anthropic-sdk-go/commit/d64dc0a334da95f82a665f9cef9f6a2f58f39878))\n\n\n### Chores\n\n* **api:** mark claude-3-opus-20240229 as deprecated ([1472af8](https://github.com/anthropics/anthropic-sdk-go/commit/1472af8504ae2f48b562e4122e641b9207240d30))\n* **ci:** enable for pull requests ([cdb1340](https://github.com/anthropics/anthropic-sdk-go/commit/cdb134079026cfa467d5f0299ee5e551fb50628a))\n* **ci:** only run for pushes and fork pull requests ([d7d44ff](https://github.com/anthropics/anthropic-sdk-go/commit/d7d44ffb621e183f611fabe3ac6f0df06d99d459))\n* fix documentation of null map ([c79ab28](https://github.com/anthropics/anthropic-sdk-go/commit/c79ab28a977f1bbda336bfffdd9fdc7ee6adccaf))\n* **internal:** add breaking change detection ([49a1855](https://github.com/anthropics/anthropic-sdk-go/commit/49a1855d3d3f107ea69dc6c4e28a82dd36a9e2af))\n\n\n### Documentation\n\n* simplify message creation syntax in README example ([#203](https://github.com/anthropics/anthropic-sdk-go/issues/203)) ([c4aef2e](https://github.com/anthropics/anthropic-sdk-go/commit/c4aef2e9c75a6cdfdfd8928bbc164b384051fc53))\n* update models and non-beta ([a7bc60e](https://github.com/anthropics/anthropic-sdk-go/commit/a7bc60e1beb087c6cc0843e99d3d3e4b51b1859d))\n\n\n### Refactors\n\n* improve Error() method to avoid code duplication ([43651c2](https://github.com/anthropics/anthropic-sdk-go/commit/43651c2804801454d24674baf62e05fc9e27e366))\n\n## 1.4.0 (2025-06-04)\n\nFull Changelog: [v1.3.0...v1.4.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.3.0...v1.4.0)\n\n### Features\n\n* **client:** allow overriding unions ([079149c](https://github.com/anthropics/anthropic-sdk-go/commit/079149c673981891ecd35906cd610f8d4a4b69a9))\n\n\n### Chores\n\n* **internal:** codegen related update ([853ba1f](https://github.com/anthropics/anthropic-sdk-go/commit/853ba1f46d2b6c476ee04d9c061368e708cc9e18))\n\n## 1.3.0 (2025-06-03)\n\nFull Changelog: [v1.2.2...v1.3.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.2.2...v1.3.0)\n\n### Features\n\n* **client:** add support for new text_editor_20250429 tool ([b33c543](https://github.com/anthropics/anthropic-sdk-go/commit/b33c543f7dc3b74c3322b6f84c189b81f67b6154))\n\n## 1.2.2 (2025-06-02)\n\nFull Changelog: [v1.2.1...v1.2.2](https://github.com/anthropics/anthropic-sdk-go/compare/v1.2.1...v1.2.2)\n\n### Bug Fixes\n\n* **client:** access subunions properly ([f29c162](https://github.com/anthropics/anthropic-sdk-go/commit/f29c1627fe94c6371937659d02f1af7b55583d60))\n* fix error ([bbc002c](https://github.com/anthropics/anthropic-sdk-go/commit/bbc002ccbbf9df681201d9b8ba806c37338c0fd3))\n\n\n### Chores\n\n* make go mod tidy continue on error ([ac184b4](https://github.com/anthropics/anthropic-sdk-go/commit/ac184b4f7afee4015d133a05ce819a8dac35be52))\n\n## 1.2.1 (2025-05-23)\n\nFull Changelog: [v1.2.0...v1.2.1](https://github.com/anthropics/anthropic-sdk-go/compare/v1.2.0...v1.2.1)\n\n### Chores\n\n* **examples:** clean up MCP example ([66f406a](https://github.com/anthropics/anthropic-sdk-go/commit/66f406a04b9756281e7716e9b635c3e3f29397fb))\n* **internal:** fix release workflows ([6a0ff4c](https://github.com/anthropics/anthropic-sdk-go/commit/6a0ff4cad1c1b4ab6435df80fccd945d6ce07be7))\n\n## 1.2.0 (2025-05-22)\n\nFull Changelog: [v1.1.0...v1.2.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.1.0...v1.2.0)\n\n### Features\n\n* **api:** add claude 4 models, files API, code execution tool, MCP connector and more ([b2e5cbf](https://github.com/anthropics/anthropic-sdk-go/commit/b2e5cbffd9d05228c2c2569974a6fa260c3f46be))\n\n\n### Bug Fixes\n\n* **tests:** fix model testing for anthropic.CalculateNonStreamingTimeout ([9956842](https://github.com/anthropics/anthropic-sdk-go/commit/995684240b77284a4590b1b9ae34a85e525d1e52))\n\n## 1.1.0 (2025-05-22)\n\nFull Changelog: [v1.0.0...v1.1.0](https://github.com/anthropics/anthropic-sdk-go/compare/v1.0.0...v1.1.0)\n\n### Features\n\n* **api:** add claude 4 models, files API, code execution tool, MCP connector and more ([2740935](https://github.com/anthropics/anthropic-sdk-go/commit/2740935f444de2d46103a7c777ea75e7e214872e))\n\n\n### Bug Fixes\n\n* **tests:** fix model testing for anthropic.CalculateNonStreamingTimeout ([f1aa0a1](https://github.com/anthropics/anthropic-sdk-go/commit/f1aa0a1a32d1ca87b87a7d688daab31f2a36071c))\n\n## 1.0.0 (2025-05-21)\n\nFull Changelog: [v0.2.0-beta.4...v1.0.0](https://github.com/anthropics/anthropic-sdk-go/compare/v0.2.0-beta.4...v1.0.0)\n\n### ⚠ BREAKING CHANGES\n\n* **client:** rename variant constructors\n* **client:** remove is present\n\n### Features\n\n* **client:** improve variant constructor names ([227c96b](https://github.com/anthropics/anthropic-sdk-go/commit/227c96bf50e14827e112c31ad0f512354477a409))\n* **client:** rename variant constructors ([078fad6](https://github.com/anthropics/anthropic-sdk-go/commit/078fad6558642a20b5fb3e82186b03c2efc0ab47))\n\n\n### Bug Fixes\n\n* **client:** correctly set stream key for multipart ([f17bfe0](https://github.com/anthropics/anthropic-sdk-go/commit/f17bfe0aac0fb8228d9cad87ccca0deb7449a824))\n* **client:** don't panic on marshal with extra null field ([d67a151](https://github.com/anthropics/anthropic-sdk-go/commit/d67a151a6ef0870918c5eaf84ce996cb5b1860b7))\n* **client:** elide nil citations array ([09cadec](https://github.com/anthropics/anthropic-sdk-go/commit/09cadec3c076d74bda74e67c345a1aee1fdb7ce4))\n* **client:** fix bug with empty tool inputs and citation deltas in Accumulate ([f4ac348](https://github.com/anthropics/anthropic-sdk-go/commit/f4ac348658fb83485d6555c63f90920599c98d99))\n* **client:** increase max stream buffer size ([18a6ccf](https://github.com/anthropics/anthropic-sdk-go/commit/18a6ccf1961922a342467800c737fa000bdd254e))\n* **client:** remove is present ([385d99f](https://github.com/anthropics/anthropic-sdk-go/commit/385d99fa225c755d9af737425ad2ef4d66ad5ba9))\n* **client:** resolve naming collisions in union variants ([2cb6904](https://github.com/anthropics/anthropic-sdk-go/commit/2cb69048a6b583954934bc2926186564b5c74bf6))\n* **client:** use scanner for streaming ([82a2840](https://github.com/anthropics/anthropic-sdk-go/commit/82a2840ce0f8aa8bd63f7697c566f437c06bb132))\n\n\n### Chores\n\n* **examples:** remove fmt ([872e055](https://github.com/anthropics/anthropic-sdk-go/commit/872e0550171942c405786c7eedb23b8270f6e8de))\n* formatting ([1ce0ee8](https://github.com/anthropics/anthropic-sdk-go/commit/1ce0ee863c5df658909d81b138dc1ebedb78844a))\n* improve devcontainer setup ([9021490](https://github.com/anthropics/anthropic-sdk-go/commit/90214901d77ba57901e77d6ea31aafb06c120f2c))\n\n\n### Documentation\n\n* upgrade security note to warning ([#346](https://github.com/anthropics/anthropic-sdk-go/issues/346)) ([83e70de](https://github.com/anthropics/anthropic-sdk-go/commit/83e70decfb5da14a1ecf78402302f7f0600515ea))\n\n## 0.2.0-beta.4 (2025-05-18)\n\nFull Changelog: [v0.2.0-beta.3...v0.2.0-beta.4](https://github.com/anthropics/anthropic-sdk-go/compare/v0.2.0-beta.3...v0.2.0-beta.4)\n\n### ⚠ BREAKING CHANGES\n\n* **client:** clearer array variant names\n* **client:** rename resp package\n* **client:** improve core function names\n* **client:** improve union variant names\n* **client:** improve param subunions & deduplicate types\n\n### Features\n\n* **api:** adds web search capabilities to the Claude API ([9ca314a](https://github.com/anthropics/anthropic-sdk-go/commit/9ca314a74998f24b5f17427698a8fa709b103581))\n* **api:** extract ContentBlockDelta events into their own schemas ([#165](https://github.com/anthropics/anthropic-sdk-go/issues/165)) ([6d75486](https://github.com/anthropics/anthropic-sdk-go/commit/6d75486e9f524f5511f787181106a679e3414498))\n* **api:** manual updates ([d405f97](https://github.com/anthropics/anthropic-sdk-go/commit/d405f97373cd7ae863a7400441d1d79c85f0ddd5))\n* **api:** manual updates ([e1326cd](https://github.com/anthropics/anthropic-sdk-go/commit/e1326cdd756beb871e939af8be8b45fd3d5fdc9a))\n* **api:** manual updates ([a92a382](https://github.com/anthropics/anthropic-sdk-go/commit/a92a382976d595dd32208109b480bf26dbbdc00f))\n* **api:** manual updates ([59bd507](https://github.com/anthropics/anthropic-sdk-go/commit/59bd5071282403373ddca9333fafc9efc90a16d6))\n* **client:** add dynamic streaming buffer to handle large lines ([510e099](https://github.com/anthropics/anthropic-sdk-go/commit/510e099e19fa71411502650eb387f1fee79f5d0d))\n* **client:** add escape hatch to omit required param fields ([#175](https://github.com/anthropics/anthropic-sdk-go/issues/175)) ([6df8184](https://github.com/anthropics/anthropic-sdk-go/commit/6df8184947d6568260fa0bc22a89a27d10eaacd0))\n* **client:** add helper method to generate constant structs ([015e8bc](https://github.com/anthropics/anthropic-sdk-go/commit/015e8bc7f74582fb5a3d69021ad3d61e96d65b36))\n* **client:** add support for endpoint-specific base URLs in python ([44645c9](https://github.com/anthropics/anthropic-sdk-go/commit/44645c9fd0b883db4deeb88bfee6922ec9845ace))\n* **client:** add support for reading base URL from environment variable ([835e632](https://github.com/anthropics/anthropic-sdk-go/commit/835e6326b658cd40590cd8bbed0932ab219e6d2d))\n* **client:** clearer array variant names ([1fdea8f](https://github.com/anthropics/anthropic-sdk-go/commit/1fdea8f9fedc470a917d12607b3b7ebe3f0f6439))\n* **client:** experimental support for unmarshalling into param structs ([94c8fa4](https://github.com/anthropics/anthropic-sdk-go/commit/94c8fa41ecb4792cb7da043bde2c0f5ddafe84b0))\n* **client:** improve param subunions & deduplicate types ([8daacf6](https://github.com/anthropics/anthropic-sdk-go/commit/8daacf6866e8bc706ec29e17046e53d4ed100364))\n* **client:** make response union's AsAny method type safe ([#174](https://github.com/anthropics/anthropic-sdk-go/issues/174)) ([f410ed0](https://github.com/anthropics/anthropic-sdk-go/commit/f410ed025ee57a05b0cec8d72a1cb43d30e564a6))\n* **client:** rename resp package ([8e7d278](https://github.com/anthropics/anthropic-sdk-go/commit/8e7d2788e9be7b954d07de731e7b27ad2e2a9e8e))\n* **client:** support custom http clients ([#177](https://github.com/anthropics/anthropic-sdk-go/issues/177)) ([ff7a793](https://github.com/anthropics/anthropic-sdk-go/commit/ff7a793b43b99dc148b30e408edfdc19e19c28b2))\n* **client:** support more time formats ([af2df86](https://github.com/anthropics/anthropic-sdk-go/commit/af2df86f24acbe6b9cdcc4e055c3ff754303e0ef))\n* **client:** support param struct overrides ([#167](https://github.com/anthropics/anthropic-sdk-go/issues/167)) ([e0d5eb0](https://github.com/anthropics/anthropic-sdk-go/commit/e0d5eb098c6441e99d53c6d997c7bcca460a238b))\n* **client:** support unions in query and forms ([#171](https://github.com/anthropics/anthropic-sdk-go/issues/171)) ([6bf1ce3](https://github.com/anthropics/anthropic-sdk-go/commit/6bf1ce36f0155dba20afd4b63bf96c4527e2baa5))\n\n\n### Bug Fixes\n\n* **client:** clean up reader resources ([2234386](https://github.com/anthropics/anthropic-sdk-go/commit/223438673ade3be3435bebf7063fd34ddf3dfb8e))\n* **client:** correctly update body in WithJSONSet ([f531c77](https://github.com/anthropics/anthropic-sdk-go/commit/f531c77c15859b1f2e61d654f4d9956cdfafa082))\n* **client:** deduplicate stop reason type ([#155](https://github.com/anthropics/anthropic-sdk-go/issues/155)) ([0f985ad](https://github.com/anthropics/anthropic-sdk-go/commit/0f985ad54ef47849d7d478c84d34c7350a4349b5))\n* **client:** fix bug where types occasionally wouldn't generate ([8988713](https://github.com/anthropics/anthropic-sdk-go/commit/8988713904ce73d3c82de635d98da48b98532366))\n* **client:** improve core function names ([0a2777f](https://github.com/anthropics/anthropic-sdk-go/commit/0a2777fd597a5eb74bcf6b1da48a9ff1988059de))\n* **client:** improve union variant names ([92718fd](https://github.com/anthropics/anthropic-sdk-go/commit/92718fd4058fd8535fd888a56f83fc2d3ec505ef))\n* **client:** include path for type names in example code ([5bbe836](https://github.com/anthropics/anthropic-sdk-go/commit/5bbe83639793878aa0ea52e8ff06b1d9ee72ed7c))\n* **client:** resolve issue with optional multipart files ([e2af94c](https://github.com/anthropics/anthropic-sdk-go/commit/e2af94c840a8f9da566c781fc99c57084e490ec1))\n* **client:** return error on bad custom url instead of panic ([#169](https://github.com/anthropics/anthropic-sdk-go/issues/169)) ([b086b55](https://github.com/anthropics/anthropic-sdk-go/commit/b086b55f4886474282d4e2ea9ee3495cbf25ec6b))\n* **client:** support multipart encoding array formats ([#170](https://github.com/anthropics/anthropic-sdk-go/issues/170)) ([611a25a](https://github.com/anthropics/anthropic-sdk-go/commit/611a25a427fc5303bb311fa4a2fec836d55b0933))\n* **client:** time format encoding fix ([d589846](https://github.com/anthropics/anthropic-sdk-go/commit/d589846c1a08ad56d639d60736e2b8e190f7f2b1))\n* **client:** unmarshal responses properly ([8344a1c](https://github.com/anthropics/anthropic-sdk-go/commit/8344a1c58dd497abbed8e9e689efca544256eaa8))\n* **client:** unmarshal stream events into fresh memory ([#168](https://github.com/anthropics/anthropic-sdk-go/issues/168)) ([9cc1257](https://github.com/anthropics/anthropic-sdk-go/commit/9cc1257a67340e446ac415ec9ddddded24bb1f9a))\n* handle empty bodies in WithJSONSet ([0bad01e](https://github.com/anthropics/anthropic-sdk-go/commit/0bad01e40a2a4b5b376ba27513d7e16d604459d9))\n* **internal:** fix type changes ([d8ef353](https://github.com/anthropics/anthropic-sdk-go/commit/d8ef3531840ac1dc0541d3b1cf0015d1db29e2b6))\n* **pagination:** handle errors when applying options ([2381476](https://github.com/anthropics/anthropic-sdk-go/commit/2381476e64991e781b696890c98f78001e256b3b))\n\n\n### Chores\n\n* **ci:** add timeout thresholds for CI jobs ([335e9f0](https://github.com/anthropics/anthropic-sdk-go/commit/335e9f0af2275f1af21aa7062afb50bee81771b6))\n* **ci:** only use depot for staging repos ([6818451](https://github.com/anthropics/anthropic-sdk-go/commit/68184515143aa1e4473208f794fa593668c94df4))\n* **ci:** run on more branches and use depot runners ([b0ca09d](https://github.com/anthropics/anthropic-sdk-go/commit/b0ca09d1d39a8de390c47be804847a7647ca3c67))\n* **client:** use new opt conversion ([#184](https://github.com/anthropics/anthropic-sdk-go/issues/184)) ([58dc74f](https://github.com/anthropics/anthropic-sdk-go/commit/58dc74f951aa6a0eb4355a0213c8695bfa7cb0ed))\n* **docs:** doc improvements ([#173](https://github.com/anthropics/anthropic-sdk-go/issues/173)) ([aebe8f6](https://github.com/anthropics/anthropic-sdk-go/commit/aebe8f68afa3de4460cda6e4032c7859e13cda81))\n* **docs:** document pre-request options ([8f5eb18](https://github.com/anthropics/anthropic-sdk-go/commit/8f5eb188146bd46ba990558a7e2348c8697d6405))\n* **docs:** readme improvements ([#176](https://github.com/anthropics/anthropic-sdk-go/issues/176)) ([b5769ff](https://github.com/anthropics/anthropic-sdk-go/commit/b5769ffcf5ef5345659ae848b875227718ea2425))\n* **docs:** update file uploads in README ([#166](https://github.com/anthropics/anthropic-sdk-go/issues/166)) ([a4a36bf](https://github.com/anthropics/anthropic-sdk-go/commit/a4a36bfbefa5a166774c23d8c5428fb55c1b4abe))\n* **docs:** update respjson package name ([28910b5](https://github.com/anthropics/anthropic-sdk-go/commit/28910b57821cab670561a25bee413375187ed747))\n* **internal:** expand CI branch coverage ([#178](https://github.com/anthropics/anthropic-sdk-go/issues/178)) ([900e2df](https://github.com/anthropics/anthropic-sdk-go/commit/900e2df3eb2d3e1309d85fdcf807998f701bea8a))\n* **internal:** reduce CI branch coverage ([343f6c6](https://github.com/anthropics/anthropic-sdk-go/commit/343f6c6c295dc3d39f65aae481bc10969dbb5694))\n* **internal:** remove CI condition ([#160](https://github.com/anthropics/anthropic-sdk-go/issues/160)) ([adfa1e2](https://github.com/anthropics/anthropic-sdk-go/commit/adfa1e2e349842aa88262af70b209d1a59dbb419))\n* **internal:** update config ([#157](https://github.com/anthropics/anthropic-sdk-go/issues/157)) ([46f0194](https://github.com/anthropics/anthropic-sdk-go/commit/46f019497bd9533390c4b9f0ebee6863263ce009))\n* **readme:** improve formatting ([66be9bb](https://github.com/anthropics/anthropic-sdk-go/commit/66be9bbb17ccc9d878e79b3c39605da3e2846297))\n\n\n### Documentation\n\n* remove or fix invalid readme examples ([142576c](https://github.com/anthropics/anthropic-sdk-go/commit/142576c73b4dab5b84a2bf2481506ad642ad31cc))\n* update documentation links to be more uniform ([457122b](https://github.com/anthropics/anthropic-sdk-go/commit/457122b79646dc17fa8752c98dbf4991edffc548))\n\n## 0.2.0-beta.3 (2025-03-27)\n\nFull Changelog: [v0.2.0-beta.2...v0.2.0-beta.3](https://github.com/anthropics/anthropic-sdk-go/compare/v0.2.0-beta.2...v0.2.0-beta.3)\n\n### Chores\n\n* add hash of OpenAPI spec/config inputs to .stats.yml ([#154](https://github.com/anthropics/anthropic-sdk-go/issues/154)) ([76b91b5](https://github.com/anthropics/anthropic-sdk-go/commit/76b91b56fbf42fe8982e7b861885db179b1bdcc5))\n* fix typos ([#152](https://github.com/anthropics/anthropic-sdk-go/issues/152)) ([1cf6a6a](https://github.com/anthropics/anthropic-sdk-go/commit/1cf6a6ae25231b88d2eedbe0758f1281cbe439d8))\n\n## 0.2.0-beta.2 (2025-03-25)\n\nFull Changelog: [v0.2.0-beta.1...v0.2.0-beta.2](https://github.com/anthropics/anthropic-sdk-go/compare/v0.2.0-beta.1...v0.2.0-beta.2)\n\n### Bug Fixes\n\n* **client:** use raw json for tool input ([1013c2b](https://github.com/anthropics/anthropic-sdk-go/commit/1013c2bdb87a27d2420dbe0dcadc57d1fe3589f2))\n\n\n### Chores\n\n* add request options to client tests ([#150](https://github.com/anthropics/anthropic-sdk-go/issues/150)) ([7c70ae1](https://github.com/anthropics/anthropic-sdk-go/commit/7c70ae134a345aff775694abcad255c76e7dfcba))\n\n## 0.2.0-beta.1 (2025-03-25)\n\nFull Changelog: [v0.2.0-alpha.13...v0.2.0-beta.1](https://github.com/anthropics/anthropic-sdk-go/compare/v0.2.0-alpha.13...v0.2.0-beta.1)\n\n### ⚠ BREAKING CHANGES\n\n* **api:** migrate to v2\n\n### Features\n\n* add SKIP_BREW env var to ./scripts/bootstrap ([#137](https://github.com/anthropics/anthropic-sdk-go/issues/137)) ([4057111](https://github.com/anthropics/anthropic-sdk-go/commit/40571110129d5c66f171ead36f5d725663262bc4))\n* **api:** migrate to v2 ([fcd95eb](https://github.com/anthropics/anthropic-sdk-go/commit/fcd95eb8f45d0ffedcd1e47cd0879d7e66783540))\n* **client:** accept RFC6838 JSON content types ([#139](https://github.com/anthropics/anthropic-sdk-go/issues/139)) ([78d17cd](https://github.com/anthropics/anthropic-sdk-go/commit/78d17cd4122893ba62b1e14714a1da004c128344))\n* **client:** allow custom baseurls without trailing slash ([#135](https://github.com/anthropics/anthropic-sdk-go/issues/135)) ([9b30fce](https://github.com/anthropics/anthropic-sdk-go/commit/9b30fce0a71a35910315e02cd3a2f2afc1fd7962))\n* **client:** improve default client options support ([07f82a6](https://github.com/anthropics/anthropic-sdk-go/commit/07f82a6f9e07bf9aadf4ca150287887cb9e75bc4))\n* **client:** improve default client options support ([#142](https://github.com/anthropics/anthropic-sdk-go/issues/142)) ([f261355](https://github.com/anthropics/anthropic-sdk-go/commit/f261355e497748bcb112eecb67a95d7c7c5075c0))\n* **client:** support v2 ([#147](https://github.com/anthropics/anthropic-sdk-go/issues/147)) ([6b3af98](https://github.com/anthropics/anthropic-sdk-go/commit/6b3af98e02a9b6126bd715d43f83b8adf8b861e8))\n\n\n### Chores\n\n* **docs:** clarify breaking changes ([#146](https://github.com/anthropics/anthropic-sdk-go/issues/146)) ([a2586b4](https://github.com/anthropics/anthropic-sdk-go/commit/a2586b4beb2b9a0ad252e90223fbb471e6c25bc1))\n* **internal:** codegen metadata ([ce0eca2](https://github.com/anthropics/anthropic-sdk-go/commit/ce0eca25c6a83fca9ececccb41faf04e74566e2d))\n* **internal:** remove extra empty newlines ([#143](https://github.com/anthropics/anthropic-sdk-go/issues/143)) ([2ed1584](https://github.com/anthropics/anthropic-sdk-go/commit/2ed1584c7d80fddf2ef5143eabbd33b8f1a4603d))\n\n\n### Refactors\n\n* tidy up dependencies ([#140](https://github.com/anthropics/anthropic-sdk-go/issues/140)) ([289cc1b](https://github.com/anthropics/anthropic-sdk-go/commit/289cc1b007094421305dfc4ef01ae68bb2d50ee5))\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "## Contributing to documentation\n\nThe documentation for this SDK lives at [platform.claude.com/docs/en/api/sdks/go](https://platform.claude.com/docs/en/api/sdks/go). To suggest changes, open an issue.\n\n## Setting up the environment\n\nTo set up the repository, run:\n\n```sh\n$ ./scripts/bootstrap\n$ ./scripts/lint\n```\n\nThis will install all the required dependencies and build the SDK.\n\nYou can also [install go 1.22+ manually](https://go.dev/doc/install).\n\n## Modifying/Adding code\n\nMost of the SDK is generated code. Modifications to code will be persisted between generations, but may\nresult in merge conflicts between manual patches and changes from the generator. The generator will never\nmodify the contents of the `lib/` and `examples/` directories.\n\n## Adding and running examples\n\nAll files in the `examples/` directory are not modified by the generator and can be freely edited or added to.\n\n```go\n# add an example to examples/<your-example>/main.go\n\npackage main\n\nfunc main() {\n  // ...\n}\n```\n\n```sh\n$ go run ./examples/<your-example>\n```\n\n## Using the repository from source\n\nTo use a local version of this library from source in another project, edit the `go.mod` with a replace\ndirective. This can be done through the CLI with the following:\n\n```sh\n$ go mod edit -replace github.com/anthropics/anthropic-sdk-go=/path/to/anthropic-sdk-go\n```\n\n## Running tests\n\nMost tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests.\n\n```sh\n$ ./scripts/mock\n```\n\n```sh\n$ ./scripts/test\n```\n\n## Formatting\n\nThis library uses the standard gofmt code formatter:\n\n```sh\n$ ./scripts/format\n```\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright 2023 Anthropic, PBC.\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n\n"
  },
  {
    "path": "README.md",
    "content": "# Claude SDK for Go\n\n<!-- x-release-please-start-version -->\n\n<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\"><img src=\"https://pkg.go.dev/badge/github.com/anthropics/anthropic-sdk-go.svg\" alt=\"Go Reference\"></a>\n\n<!-- x-release-please-end -->\n\nThe Claude SDK for Go provides access to the [Claude API](https://docs.anthropic.com/en/api/) from Go applications.\n\n## Documentation\n\nFull documentation is available at **[platform.claude.com/docs/en/api/sdks/go](https://platform.claude.com/docs/en/api/sdks/go)**.\n\n## Installation\n\n<!-- x-release-please-start-version -->\n\n```go\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go\" // imported as anthropic\n)\n```\n\n<!-- x-release-please-end -->\n\nOr explicitly add the dependency:\n\n<!-- x-release-please-start-version -->\n\n```sh\ngo get -u 'github.com/anthropics/anthropic-sdk-go@v1.27.1'\n```\n\n<!-- x-release-please-end -->\n\n## Getting started\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"), // defaults to os.LookupEnv(\"ANTHROPIC_API_KEY\")\n\t)\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(\"What is a quaternion?\")),\n\t\t},\n\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.Content)\n}\n```\n\n## Requirements\n\nGo 1.22+\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# Security Policy\n\n## Reporting Security Issues\n\nThis 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.\n\nTo report a security issue, please contact the Stainless team at security@stainless.com.\n\n## Responsible Disclosure\n\nWe appreciate the efforts of security researchers and individuals who help us maintain the security of\nSDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible\ndisclosure practices by allowing us a reasonable amount of time to investigate and address the issue\nbefore making any information public.\n\n## Reporting Non-SDK Related Security Issues\n\nIf you encounter security issues that are not directly related to SDKs but pertain to the services\nor products provided by Anthropic, please follow the respective company's security reporting guidelines.\n\n### Anthropic Terms and Policies\n\nPlease contact support@anthropic.com for any questions or concerns regarding the security of our services.\n\n---\n\nThank you for helping us keep the SDKs and systems they interact with secure.\n"
  },
  {
    "path": "aliases.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apierror\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared\"\n)\n\n// aliased to make [param.APIUnion] private when embedding\ntype paramUnion = param.APIUnion\n\n// aliased to make [param.APIObject] private when embedding\ntype paramObj = param.APIObject\n\ntype Error = apierror.Error\n\n// This is an alias to an internal type.\ntype APIErrorObject = shared.APIErrorObject\n\n// This is an alias to an internal type.\ntype AuthenticationError = shared.AuthenticationError\n\n// This is an alias to an internal type.\ntype BillingError = shared.BillingError\n\n// This is an alias to an internal type.\ntype ErrorObjectUnion = shared.ErrorObjectUnion\n\n// This is an alias to an internal type.\ntype ErrorResponse = shared.ErrorResponse\n\n// This is an alias to an internal type.\ntype GatewayTimeoutError = shared.GatewayTimeoutError\n\n// This is an alias to an internal type.\ntype InvalidRequestError = shared.InvalidRequestError\n\n// This is an alias to an internal type.\ntype NotFoundError = shared.NotFoundError\n\n// This is an alias to an internal type.\ntype OverloadedError = shared.OverloadedError\n\n// This is an alias to an internal type.\ntype PermissionError = shared.PermissionError\n\n// This is an alias to an internal type.\ntype RateLimitError = shared.RateLimitError\n\n// Backward-compatible type aliases for renamed types.\n// These ensure existing code continues to compile after\n// UserLocation and ErrorCode types were consolidated.\n\ntype WebSearchToolRequestErrorErrorCode = WebSearchToolResultErrorCode\ntype WebSearchToolResultErrorErrorCode = WebSearchToolResultErrorCode\ntype WebSearchTool20250305UserLocationParam = UserLocationParam\ntype WebSearchTool20260209UserLocationParam = UserLocationParam\n\nconst WebSearchToolRequestErrorErrorCodeInvalidToolInput = WebSearchToolResultErrorCodeInvalidToolInput\nconst WebSearchToolRequestErrorErrorCodeUnavailable = WebSearchToolResultErrorCodeUnavailable\nconst WebSearchToolRequestErrorErrorCodeMaxUsesExceeded = WebSearchToolResultErrorCodeMaxUsesExceeded\nconst WebSearchToolRequestErrorErrorCodeTooManyRequests = WebSearchToolResultErrorCodeTooManyRequests\nconst WebSearchToolRequestErrorErrorCodeQueryTooLong = WebSearchToolResultErrorCodeQueryTooLong\nconst WebSearchToolRequestErrorErrorCodeRequestTooLarge = WebSearchToolResultErrorCodeRequestTooLarge\nconst WebSearchToolResultErrorErrorCodeInvalidToolInput = WebSearchToolResultErrorCodeInvalidToolInput\nconst WebSearchToolResultErrorErrorCodeUnavailable = WebSearchToolResultErrorCodeUnavailable\nconst WebSearchToolResultErrorErrorCodeMaxUsesExceeded = WebSearchToolResultErrorCodeMaxUsesExceeded\nconst WebSearchToolResultErrorErrorCodeTooManyRequests = WebSearchToolResultErrorCodeTooManyRequests\nconst WebSearchToolResultErrorErrorCodeQueryTooLong = WebSearchToolResultErrorCodeQueryTooLong\nconst WebSearchToolResultErrorErrorCodeRequestTooLarge = WebSearchToolResultErrorCodeRequestTooLarge\n"
  },
  {
    "path": "api.md",
    "content": "# Shared Response Types\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#APIErrorObject\">APIErrorObject</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#AuthenticationError\">AuthenticationError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#BillingError\">BillingError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#ErrorObjectUnion\">ErrorObjectUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#ErrorResponse\">ErrorResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#GatewayTimeoutError\">GatewayTimeoutError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#InvalidRequestError\">InvalidRequestError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#NotFoundError\">NotFoundError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#OverloadedError\">OverloadedError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#PermissionError\">PermissionError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared\">shared</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/shared#RateLimitError\">RateLimitError</a>\n\n# Messages\n\nParams Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Base64ImageSourceParam\">Base64ImageSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Base64PDFSourceParam\">Base64PDFSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionOutputBlockParam\">BashCodeExecutionOutputBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionResultBlockParam\">BashCodeExecutionResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionToolResultBlockParam\">BashCodeExecutionToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionToolResultErrorCode\">BashCodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionToolResultErrorParam\">BashCodeExecutionToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CacheControlEphemeralParam\">CacheControlEphemeralParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationCharLocationParam\">CitationCharLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationContentBlockLocationParam\">CitationContentBlockLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationPageLocationParam\">CitationPageLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationSearchResultLocationParam\">CitationSearchResultLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationWebSearchResultLocationParam\">CitationWebSearchResultLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationsConfigParam\">CitationsConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionOutputBlockParam\">CodeExecutionOutputBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionResultBlockParam\">CodeExecutionResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionTool20250522Param\">CodeExecutionTool20250522Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionTool20250825Param\">CodeExecutionTool20250825Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionTool20260120Param\">CodeExecutionTool20260120Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultBlockParam\">CodeExecutionToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultBlockParamContentUnion\">CodeExecutionToolResultBlockParamContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultErrorCode\">CodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultErrorParam\">CodeExecutionToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContainerUploadBlockParam\">ContainerUploadBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockParamUnion\">ContentBlockParamUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockSourceParam\">ContentBlockSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockSourceContentItemUnionParam\">ContentBlockSourceContentItemUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DirectCallerParam\">DirectCallerParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DocumentBlockParam\">DocumentBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#EncryptedCodeExecutionResultBlockParam\">EncryptedCodeExecutionResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ImageBlockParam\">ImageBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#JSONOutputFormatParam\">JSONOutputFormatParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MemoryTool20250818Param\">MemoryTool20250818Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageCountTokensToolUnionParam\">MessageCountTokensToolUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageParam\">MessageParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MetadataParam\">MetadataParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Model\">Model</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#OutputConfigParam\">OutputConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#PlainTextSourceParam\">PlainTextSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#RedactedThinkingBlockParam\">RedactedThinkingBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#SearchResultBlockParam\">SearchResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolCallerParam\">ServerToolCallerParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolCaller20260120Param\">ServerToolCaller20260120Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolUseBlockParam\">ServerToolUseBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextBlockParam\">TextBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextCitationParamUnion\">TextCitationParamUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionCreateResultBlockParam\">TextEditorCodeExecutionCreateResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionStrReplaceResultBlockParam\">TextEditorCodeExecutionStrReplaceResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionToolResultBlockParam\">TextEditorCodeExecutionToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionToolResultErrorCode\">TextEditorCodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionToolResultErrorParam\">TextEditorCodeExecutionToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionViewResultBlockParam\">TextEditorCodeExecutionViewResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingBlockParam\">ThinkingBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingConfigAdaptiveParam\">ThinkingConfigAdaptiveParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingConfigDisabledParam\">ThinkingConfigDisabledParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingConfigEnabledParam\">ThinkingConfigEnabledParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingConfigParamUnion\">ThinkingConfigParamUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolParam\">ToolParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolBash20250124Param\">ToolBash20250124Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolChoiceUnionParam\">ToolChoiceUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolChoiceAnyParam\">ToolChoiceAnyParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolChoiceAutoParam\">ToolChoiceAutoParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolChoiceNoneParam\">ToolChoiceNoneParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolChoiceToolParam\">ToolChoiceToolParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolReferenceBlockParam\">ToolReferenceBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolResultBlockParam\">ToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolBm25_20251119Param\">ToolSearchToolBm25_20251119Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolRegex20251119Param\">ToolSearchToolRegex20251119Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolResultBlockParam\">ToolSearchToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolResultErrorCode\">ToolSearchToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolResultErrorParam\">ToolSearchToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolSearchResultBlockParam\">ToolSearchToolSearchResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolTextEditor20250124Param\">ToolTextEditor20250124Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolTextEditor20250429Param\">ToolTextEditor20250429Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolTextEditor20250728Param\">ToolTextEditor20250728Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolUnionParam\">ToolUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolUseBlockParam\">ToolUseBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#URLImageSourceParam\">URLImageSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#URLPDFSourceParam\">URLPDFSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#UserLocationParam\">UserLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchBlockParam\">WebFetchBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchTool20250910Param\">WebFetchTool20250910Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchTool20260209Param\">WebFetchTool20260209Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchTool20260309Param\">WebFetchTool20260309Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchToolResultBlockParam\">WebFetchToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchToolResultErrorBlockParam\">WebFetchToolResultErrorBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchToolResultErrorCode\">WebFetchToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchResultBlockParam\">WebSearchResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchTool20250305Param\">WebSearchTool20250305Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchTool20260209Param\">WebSearchTool20260209Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolRequestErrorParam\">WebSearchToolRequestErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultBlockParam\">WebSearchToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultBlockParamContentUnion\">WebSearchToolResultBlockParamContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultErrorCode\">WebSearchToolResultErrorCode</a>\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Base64PDFSource\">Base64PDFSource</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionOutputBlock\">BashCodeExecutionOutputBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionResultBlock\">BashCodeExecutionResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionToolResultBlock\">BashCodeExecutionToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionToolResultError\">BashCodeExecutionToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BashCodeExecutionToolResultErrorCode\">BashCodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CacheCreation\">CacheCreation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationCharLocation\">CitationCharLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationContentBlockLocation\">CitationContentBlockLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationPageLocation\">CitationPageLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationsConfig\">CitationsConfig</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationsDelta\">CitationsDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationsSearchResultLocation\">CitationsSearchResultLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CitationsWebSearchResultLocation\">CitationsWebSearchResultLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionOutputBlock\">CodeExecutionOutputBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionResultBlock\">CodeExecutionResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultBlock\">CodeExecutionToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultBlockContentUnion\">CodeExecutionToolResultBlockContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultError\">CodeExecutionToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CodeExecutionToolResultErrorCode\">CodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Container\">Container</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContainerUploadBlock\">ContainerUploadBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockUnion\">ContentBlockUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DirectCaller\">DirectCaller</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DocumentBlock\">DocumentBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#EncryptedCodeExecutionResultBlock\">EncryptedCodeExecutionResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#InputJSONDelta\">InputJSONDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Message\">Message</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageDeltaUsage\">MessageDeltaUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageTokensCount\">MessageTokensCount</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Model\">Model</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#PlainTextSource\">PlainTextSource</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#RawContentBlockDeltaUnion\">RawContentBlockDeltaUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockDeltaEvent\">ContentBlockDeltaEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockStartEvent\">ContentBlockStartEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContentBlockStopEvent\">ContentBlockStopEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageDeltaEvent\">MessageDeltaEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageStartEvent\">MessageStartEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageStopEvent\">MessageStopEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageStreamEventUnion\">MessageStreamEventUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#RedactedThinkingBlock\">RedactedThinkingBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolCaller\">ServerToolCaller</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolCaller20260120\">ServerToolCaller20260120</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolUsage\">ServerToolUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ServerToolUseBlock\">ServerToolUseBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#SignatureDelta\">SignatureDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#StopReason\">StopReason</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextBlock\">TextBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextCitationUnion\">TextCitationUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextDelta\">TextDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionCreateResultBlock\">TextEditorCodeExecutionCreateResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionStrReplaceResultBlock\">TextEditorCodeExecutionStrReplaceResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionToolResultBlock\">TextEditorCodeExecutionToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionToolResultError\">TextEditorCodeExecutionToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionToolResultErrorCode\">TextEditorCodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#TextEditorCodeExecutionViewResultBlock\">TextEditorCodeExecutionViewResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingBlock\">ThinkingBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingDelta\">ThinkingDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolReferenceBlock\">ToolReferenceBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolResultBlock\">ToolSearchToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolResultError\">ToolSearchToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolResultErrorCode\">ToolSearchToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolSearchToolSearchResultBlock\">ToolSearchToolSearchResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ToolUseBlock\">ToolUseBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Usage\">Usage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchBlock\">WebFetchBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchToolResultBlock\">WebFetchToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchToolResultErrorBlock\">WebFetchToolResultErrorBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebFetchToolResultErrorCode\">WebFetchToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchResultBlock\">WebSearchResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultBlock\">WebSearchToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultBlockContentUnion\">WebSearchToolResultBlockContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultError\">WebSearchToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#WebSearchToolResultErrorCode\">WebSearchToolResultErrorCode</a>\n\nMethods:\n\n- <code title=\"post /v1/messages\">client.Messages.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageService.New\">New</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageNewParams\">MessageNewParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#Message\">Message</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"post /v1/messages/count_tokens\">client.Messages.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageService.CountTokens\">CountTokens</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageCountTokensParams\">MessageCountTokensParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageTokensCount\">MessageTokensCount</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n## Batches\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DeletedMessageBatch\">DeletedMessageBatch</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatch\">MessageBatch</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchCanceledResult\">MessageBatchCanceledResult</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchErroredResult\">MessageBatchErroredResult</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchExpiredResult\">MessageBatchExpiredResult</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchIndividualResponse\">MessageBatchIndividualResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchRequestCounts\">MessageBatchRequestCounts</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchResultUnion\">MessageBatchResultUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchSucceededResult\">MessageBatchSucceededResult</a>\n\nMethods:\n\n- <code title=\"post /v1/messages/batches\">client.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchService.New\">New</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchNewParams\">MessageBatchNewParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatch\">MessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/messages/batches/{message_batch_id}\">client.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchService.Get\">Get</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatch\">MessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/messages/batches\">client.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchListParams\">MessageBatchListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#Page\">Page</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatch\">MessageBatch</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"delete /v1/messages/batches/{message_batch_id}\">client.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchService.Delete\">Delete</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DeletedMessageBatch\">DeletedMessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"post /v1/messages/batches/{message_batch_id}/cancel\">client.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchService.Cancel\">Cancel</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatch\">MessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/messages/batches/{message_batch_id}/results\">client.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchService.Results\">Results</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#MessageBatchIndividualResponse\">MessageBatchIndividualResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n# Models\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#CapabilitySupport\">CapabilitySupport</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ContextManagementCapability\">ContextManagementCapability</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#EffortCapability\">EffortCapability</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelCapabilities\">ModelCapabilities</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelInfo\">ModelInfo</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingCapability\">ThinkingCapability</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ThinkingTypes\">ThinkingTypes</a>\n\nMethods:\n\n- <code title=\"get /v1/models/{model_id}\">client.Models.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelService.Get\">Get</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, modelID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelGetParams\">ModelGetParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelInfo\">ModelInfo</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/models\">client.Models.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelListParams\">ModelListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#Page\">Page</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#ModelInfo\">ModelInfo</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n# Beta\n\nParams Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#AnthropicBeta\">AnthropicBeta</a>\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaAPIError\">BetaAPIError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaAuthenticationError\">BetaAuthenticationError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBillingError\">BetaBillingError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaErrorUnion\">BetaErrorUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaErrorResponse\">BetaErrorResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaGatewayTimeoutError\">BetaGatewayTimeoutError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaInvalidRequestError\">BetaInvalidRequestError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaNotFoundError\">BetaNotFoundError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaOverloadedError\">BetaOverloadedError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaPermissionError\">BetaPermissionError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRateLimitError\">BetaRateLimitError</a>\n\n## Models\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCapabilitySupport\">BetaCapabilitySupport</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContextManagementCapability\">BetaContextManagementCapability</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaEffortCapability\">BetaEffortCapability</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelCapabilities\">BetaModelCapabilities</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelInfo\">BetaModelInfo</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingCapability\">BetaThinkingCapability</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingTypes\">BetaThinkingTypes</a>\n\nMethods:\n\n- <code title=\"get /v1/models/{model_id}?beta=true\">client.Beta.Models.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelService.Get\">Get</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, modelID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelGetParams\">BetaModelGetParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelInfo\">BetaModelInfo</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/models?beta=true\">client.Beta.Models.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelListParams\">BetaModelListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#Page\">Page</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaModelInfo\">BetaModelInfo</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n## Messages\n\nParams Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaAllThinkingTurnsParam\">BetaAllThinkingTurnsParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBase64ImageSourceParam\">BetaBase64ImageSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBase64PDFSourceParam\">BetaBase64PDFSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionOutputBlockParam\">BetaBashCodeExecutionOutputBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionResultBlockParam\">BetaBashCodeExecutionResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionToolResultBlockParam\">BetaBashCodeExecutionToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionToolResultErrorParam\">BetaBashCodeExecutionToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCacheControlEphemeralParam\">BetaCacheControlEphemeralParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationCharLocationParam\">BetaCitationCharLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationContentBlockLocationParam\">BetaCitationContentBlockLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationPageLocationParam\">BetaCitationPageLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationSearchResultLocationParam\">BetaCitationSearchResultLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationWebSearchResultLocationParam\">BetaCitationWebSearchResultLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationsConfigParam\">BetaCitationsConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaClearThinking20251015EditParam\">BetaClearThinking20251015EditParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaClearToolUses20250919EditParam\">BetaClearToolUses20250919EditParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionOutputBlockParam\">BetaCodeExecutionOutputBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionResultBlockParam\">BetaCodeExecutionResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionTool20250522Param\">BetaCodeExecutionTool20250522Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionTool20250825Param\">BetaCodeExecutionTool20250825Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionTool20260120Param\">BetaCodeExecutionTool20260120Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultBlockParam\">BetaCodeExecutionToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultBlockParamContentUnion\">BetaCodeExecutionToolResultBlockParamContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultErrorCode\">BetaCodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultErrorParam\">BetaCodeExecutionToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCompact20260112EditParam\">BetaCompact20260112EditParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCompactionBlockParam\">BetaCompactionBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContainerParams\">BetaContainerParams</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContainerUploadBlockParam\">BetaContainerUploadBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContentBlockParamUnion\">BetaContentBlockParamUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContentBlockSourceParam\">BetaContentBlockSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContentBlockSourceContentUnionParam\">BetaContentBlockSourceContentUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContextManagementConfigParam\">BetaContextManagementConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaDirectCallerParam\">BetaDirectCallerParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaEncryptedCodeExecutionResultBlockParam\">BetaEncryptedCodeExecutionResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileDocumentSourceParam\">BetaFileDocumentSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileImageSourceParam\">BetaFileImageSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaImageBlockParam\">BetaImageBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaInputTokensClearAtLeastParam\">BetaInputTokensClearAtLeastParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaInputTokensTriggerParam\">BetaInputTokensTriggerParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaJSONOutputFormatParam\">BetaJSONOutputFormatParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMCPToolConfigParam\">BetaMCPToolConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMCPToolDefaultConfigParam\">BetaMCPToolDefaultConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMCPToolUseBlockParam\">BetaMCPToolUseBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMCPToolsetParam\">BetaMCPToolsetParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818Param\">BetaMemoryTool20250818Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageParam\">BetaMessageParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMetadataParam\">BetaMetadataParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaOutputConfigParam\">BetaOutputConfigParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaPlainTextSourceParam\">BetaPlainTextSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRedactedThinkingBlockParam\">BetaRedactedThinkingBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRequestDocumentBlockParam\">BetaRequestDocumentBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRequestMCPServerToolConfigurationParam\">BetaRequestMCPServerToolConfigurationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRequestMCPServerURLDefinitionParam\">BetaRequestMCPServerURLDefinitionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRequestMCPToolResultBlockParam\">BetaRequestMCPToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSearchResultBlockParam\">BetaSearchResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolCallerParam\">BetaServerToolCallerParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolCaller20260120Param\">BetaServerToolCaller20260120Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolUseBlockParam\">BetaServerToolUseBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillParams\">BetaSkillParams</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextBlockParam\">BetaTextBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextCitationParamUnion\">BetaTextCitationParamUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionCreateResultBlockParam\">BetaTextEditorCodeExecutionCreateResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionStrReplaceResultBlockParam\">BetaTextEditorCodeExecutionStrReplaceResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionToolResultBlockParam\">BetaTextEditorCodeExecutionToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionToolResultErrorParam\">BetaTextEditorCodeExecutionToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionViewResultBlockParam\">BetaTextEditorCodeExecutionViewResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingBlockParam\">BetaThinkingBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingConfigAdaptiveParam\">BetaThinkingConfigAdaptiveParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingConfigDisabledParam\">BetaThinkingConfigDisabledParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingConfigEnabledParam\">BetaThinkingConfigEnabledParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingConfigParamUnion\">BetaThinkingConfigParamUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingTurnsParam\">BetaThinkingTurnsParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolParam\">BetaToolParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolBash20241022Param\">BetaToolBash20241022Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolBash20250124Param\">BetaToolBash20250124Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolChoiceUnionParam\">BetaToolChoiceUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolChoiceAnyParam\">BetaToolChoiceAnyParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolChoiceAutoParam\">BetaToolChoiceAutoParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolChoiceNoneParam\">BetaToolChoiceNoneParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolChoiceToolParam\">BetaToolChoiceToolParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolComputerUse20241022Param\">BetaToolComputerUse20241022Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolComputerUse20250124Param\">BetaToolComputerUse20250124Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolComputerUse20251124Param\">BetaToolComputerUse20251124Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolReferenceBlockParam\">BetaToolReferenceBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolResultBlockParam\">BetaToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolBm25_20251119Param\">BetaToolSearchToolBm25_20251119Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolRegex20251119Param\">BetaToolSearchToolRegex20251119Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolResultBlockParam\">BetaToolSearchToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolResultErrorParam\">BetaToolSearchToolResultErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolSearchResultBlockParam\">BetaToolSearchToolSearchResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolTextEditor20241022Param\">BetaToolTextEditor20241022Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolTextEditor20250124Param\">BetaToolTextEditor20250124Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolTextEditor20250429Param\">BetaToolTextEditor20250429Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolTextEditor20250728Param\">BetaToolTextEditor20250728Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolUnionParam\">BetaToolUnionParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolUseBlockParam\">BetaToolUseBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolUsesKeepParam\">BetaToolUsesKeepParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolUsesTriggerParam\">BetaToolUsesTriggerParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaURLImageSourceParam\">BetaURLImageSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaURLPDFSourceParam\">BetaURLPDFSourceParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaUserLocationParam\">BetaUserLocationParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchBlockParam\">BetaWebFetchBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchTool20250910Param\">BetaWebFetchTool20250910Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchTool20260209Param\">BetaWebFetchTool20260209Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchTool20260309Param\">BetaWebFetchTool20260309Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchToolResultBlockParam\">BetaWebFetchToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchToolResultErrorBlockParam\">BetaWebFetchToolResultErrorBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchToolResultErrorCode\">BetaWebFetchToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchResultBlockParam\">BetaWebSearchResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchTool20250305Param\">BetaWebSearchTool20250305Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchTool20260209Param\">BetaWebSearchTool20260209Param</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolRequestErrorParam\">BetaWebSearchToolRequestErrorParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultBlockParam\">BetaWebSearchToolResultBlockParam</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultBlockParamContentUnion\">BetaWebSearchToolResultBlockParamContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultErrorCode\">BetaWebSearchToolResultErrorCode</a>\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBase64PDFSource\">BetaBase64PDFSource</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionOutputBlock\">BetaBashCodeExecutionOutputBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionResultBlock\">BetaBashCodeExecutionResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionToolResultBlock\">BetaBashCodeExecutionToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaBashCodeExecutionToolResultError\">BetaBashCodeExecutionToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCacheCreation\">BetaCacheCreation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationCharLocation\">BetaCitationCharLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationConfig\">BetaCitationConfig</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationContentBlockLocation\">BetaCitationContentBlockLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationPageLocation\">BetaCitationPageLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationSearchResultLocation\">BetaCitationSearchResultLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationsDelta\">BetaCitationsDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCitationsWebSearchResultLocation\">BetaCitationsWebSearchResultLocation</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaClearThinking20251015EditResponse\">BetaClearThinking20251015EditResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaClearToolUses20250919EditResponse\">BetaClearToolUses20250919EditResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionOutputBlock\">BetaCodeExecutionOutputBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionResultBlock\">BetaCodeExecutionResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultBlock\">BetaCodeExecutionToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultBlockContentUnion\">BetaCodeExecutionToolResultBlockContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultError\">BetaCodeExecutionToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCodeExecutionToolResultErrorCode\">BetaCodeExecutionToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCompactionBlock\">BetaCompactionBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCompactionContentBlockDelta\">BetaCompactionContentBlockDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCompactionIterationUsage\">BetaCompactionIterationUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContainer\">BetaContainer</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContainerUploadBlock\">BetaContainerUploadBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContentBlockUnion\">BetaContentBlockUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaContextManagementResponse\">BetaContextManagementResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaCountTokensContextManagementResponse\">BetaCountTokensContextManagementResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaDirectCaller\">BetaDirectCaller</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaDocumentBlock\">BetaDocumentBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaEncryptedCodeExecutionResultBlock\">BetaEncryptedCodeExecutionResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaInputJSONDelta\">BetaInputJSONDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaIterationsUsage\">BetaIterationsUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMCPToolResultBlock\">BetaMCPToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMCPToolUseBlock\">BetaMCPToolUseBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818CommandUnion\">BetaMemoryTool20250818CommandUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818CreateCommand\">BetaMemoryTool20250818CreateCommand</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818DeleteCommand\">BetaMemoryTool20250818DeleteCommand</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818InsertCommand\">BetaMemoryTool20250818InsertCommand</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818RenameCommand\">BetaMemoryTool20250818RenameCommand</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818StrReplaceCommand\">BetaMemoryTool20250818StrReplaceCommand</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMemoryTool20250818ViewCommand\">BetaMemoryTool20250818ViewCommand</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessage\">BetaMessage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageDeltaUsage\">BetaMessageDeltaUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageIterationUsage\">BetaMessageIterationUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageTokensCount\">BetaMessageTokensCount</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaPlainTextSource\">BetaPlainTextSource</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawContentBlockDeltaUnion\">BetaRawContentBlockDeltaUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawContentBlockDeltaEvent\">BetaRawContentBlockDeltaEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawContentBlockStartEvent\">BetaRawContentBlockStartEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawContentBlockStopEvent\">BetaRawContentBlockStopEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawMessageDeltaEvent\">BetaRawMessageDeltaEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawMessageStartEvent\">BetaRawMessageStartEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawMessageStopEvent\">BetaRawMessageStopEvent</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRawMessageStreamEventUnion\">BetaRawMessageStreamEventUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaRedactedThinkingBlock\">BetaRedactedThinkingBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolCaller\">BetaServerToolCaller</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolCaller20260120\">BetaServerToolCaller20260120</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolUsage\">BetaServerToolUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaServerToolUseBlock\">BetaServerToolUseBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSignatureDelta\">BetaSignatureDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkill\">BetaSkill</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaStopReason\">BetaStopReason</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextBlock\">BetaTextBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextCitationUnion\">BetaTextCitationUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextDelta\">BetaTextDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionCreateResultBlock\">BetaTextEditorCodeExecutionCreateResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionStrReplaceResultBlock\">BetaTextEditorCodeExecutionStrReplaceResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionToolResultBlock\">BetaTextEditorCodeExecutionToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionToolResultError\">BetaTextEditorCodeExecutionToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaTextEditorCodeExecutionViewResultBlock\">BetaTextEditorCodeExecutionViewResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingBlock\">BetaThinkingBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaThinkingDelta\">BetaThinkingDelta</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolReferenceBlock\">BetaToolReferenceBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolResultBlock\">BetaToolSearchToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolResultError\">BetaToolSearchToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolSearchToolSearchResultBlock\">BetaToolSearchToolSearchResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaToolUseBlock\">BetaToolUseBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaUsage\">BetaUsage</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchBlock\">BetaWebFetchBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchToolResultBlock\">BetaWebFetchToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchToolResultErrorBlock\">BetaWebFetchToolResultErrorBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebFetchToolResultErrorCode\">BetaWebFetchToolResultErrorCode</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchResultBlock\">BetaWebSearchResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultBlock\">BetaWebSearchToolResultBlock</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultBlockContentUnion\">BetaWebSearchToolResultBlockContentUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultError\">BetaWebSearchToolResultError</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaWebSearchToolResultErrorCode\">BetaWebSearchToolResultErrorCode</a>\n\nMethods:\n\n- <code title=\"post /v1/messages?beta=true\">client.Beta.Messages.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageService.New\">New</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageNewParams\">BetaMessageNewParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessage\">BetaMessage</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"post /v1/messages/count_tokens?beta=true\">client.Beta.Messages.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageService.CountTokens\">CountTokens</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageCountTokensParams\">BetaMessageCountTokensParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageTokensCount\">BetaMessageTokensCount</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n### Batches\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaDeletedMessageBatch\">BetaDeletedMessageBatch</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatch\">BetaMessageBatch</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchCanceledResult\">BetaMessageBatchCanceledResult</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchErroredResult\">BetaMessageBatchErroredResult</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchExpiredResult\">BetaMessageBatchExpiredResult</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchIndividualResponse\">BetaMessageBatchIndividualResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchRequestCounts\">BetaMessageBatchRequestCounts</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchResultUnion\">BetaMessageBatchResultUnion</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchSucceededResult\">BetaMessageBatchSucceededResult</a>\n\nMethods:\n\n- <code title=\"post /v1/messages/batches?beta=true\">client.Beta.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchService.New\">New</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchNewParams\">BetaMessageBatchNewParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatch\">BetaMessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/messages/batches/{message_batch_id}?beta=true\">client.Beta.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchService.Get\">Get</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchGetParams\">BetaMessageBatchGetParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatch\">BetaMessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/messages/batches?beta=true\">client.Beta.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchListParams\">BetaMessageBatchListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#Page\">Page</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatch\">BetaMessageBatch</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"delete /v1/messages/batches/{message_batch_id}?beta=true\">client.Beta.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchService.Delete\">Delete</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchDeleteParams\">BetaMessageBatchDeleteParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaDeletedMessageBatch\">BetaDeletedMessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"post /v1/messages/batches/{message_batch_id}/cancel?beta=true\">client.Beta.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchService.Cancel\">Cancel</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchCancelParams\">BetaMessageBatchCancelParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatch\">BetaMessageBatch</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/messages/batches/{message_batch_id}/results?beta=true\">client.Beta.Messages.Batches.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchService.Results\">Results</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, messageBatchID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchResultsParams\">BetaMessageBatchResultsParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaMessageBatchIndividualResponse\">BetaMessageBatchIndividualResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n## Files\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DeletedFile\">DeletedFile</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#FileMetadata\">FileMetadata</a>\n\nMethods:\n\n- <code title=\"get /v1/files?beta=true\">client.Beta.Files.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileListParams\">BetaFileListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#Page\">Page</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#FileMetadata\">FileMetadata</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"delete /v1/files/{file_id}?beta=true\">client.Beta.Files.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileService.Delete\">Delete</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, fileID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileDeleteParams\">BetaFileDeleteParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#DeletedFile\">DeletedFile</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/files/{file_id}/content?beta=true\">client.Beta.Files.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileService.Download\">Download</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, fileID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileDownloadParams\">BetaFileDownloadParams</a>) (\\*http.Response, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/files/{file_id}?beta=true\">client.Beta.Files.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileService.GetMetadata\">GetMetadata</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, fileID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileGetMetadataParams\">BetaFileGetMetadataParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#FileMetadata\">FileMetadata</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"post /v1/files?beta=true\">client.Beta.Files.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileService.Upload\">Upload</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaFileUploadParams\">BetaFileUploadParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#FileMetadata\">FileMetadata</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n## Skills\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillNewResponse\">BetaSkillNewResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillGetResponse\">BetaSkillGetResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillListResponse\">BetaSkillListResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillDeleteResponse\">BetaSkillDeleteResponse</a>\n\nMethods:\n\n- <code title=\"post /v1/skills?beta=true\">client.Beta.Skills.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillService.New\">New</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillNewParams\">BetaSkillNewParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillNewResponse\">BetaSkillNewResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/skills/{skill_id}?beta=true\">client.Beta.Skills.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillService.Get\">Get</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, skillID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, query <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillGetParams\">BetaSkillGetParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillGetResponse\">BetaSkillGetResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/skills?beta=true\">client.Beta.Skills.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillListParams\">BetaSkillListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#PageCursor\">PageCursor</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillListResponse\">BetaSkillListResponse</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"delete /v1/skills/{skill_id}?beta=true\">client.Beta.Skills.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillService.Delete\">Delete</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, skillID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, body <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillDeleteParams\">BetaSkillDeleteParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillDeleteResponse\">BetaSkillDeleteResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n\n### Versions\n\nResponse Types:\n\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionNewResponse\">BetaSkillVersionNewResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionGetResponse\">BetaSkillVersionGetResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionListResponse\">BetaSkillVersionListResponse</a>\n- <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionDeleteResponse\">BetaSkillVersionDeleteResponse</a>\n\nMethods:\n\n- <code title=\"post /v1/skills/{skill_id}/versions?beta=true\">client.Beta.Skills.Versions.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionService.New\">New</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, skillID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionNewParams\">BetaSkillVersionNewParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionNewResponse\">BetaSkillVersionNewResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/skills/{skill_id}/versions/{version}?beta=true\">client.Beta.Skills.Versions.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionService.Get\">Get</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, version <a href=\"https://pkg.go.dev/builtin#string\">string</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionGetParams\">BetaSkillVersionGetParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionGetResponse\">BetaSkillVersionGetResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"get /v1/skills/{skill_id}/versions?beta=true\">client.Beta.Skills.Versions.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionService.List\">List</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, skillID <a href=\"https://pkg.go.dev/builtin#string\">string</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionListParams\">BetaSkillVersionListParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination\">pagination</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/packages/pagination#PageCursor\">PageCursor</a>[<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionListResponse\">BetaSkillVersionListResponse</a>], <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n- <code title=\"delete /v1/skills/{skill_id}/versions/{version}?beta=true\">client.Beta.Skills.Versions.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionService.Delete\">Delete</a>(ctx <a href=\"https://pkg.go.dev/context\">context</a>.<a href=\"https://pkg.go.dev/context#Context\">Context</a>, version <a href=\"https://pkg.go.dev/builtin#string\">string</a>, params <a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionDeleteParams\">BetaSkillVersionDeleteParams</a>) (\\*<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go\">anthropic</a>.<a href=\"https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#BetaSkillVersionDeleteResponse\">BetaSkillVersionDeleteResponse</a>, <a href=\"https://pkg.go.dev/builtin#error\">error</a>)</code>\n"
  },
  {
    "path": "bedrock/bedrock.go",
    "content": "package bedrock\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"crypto/sha256\"\n\t\"encoding/base64\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/aws/aws-sdk-go-v2/aws\"\n\t\"github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream\"\n\t\"github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/eventstreamapi\"\n\tv4 \"github.com/aws/aws-sdk-go-v2/aws/signer/v4\"\n\t\"github.com/aws/aws-sdk-go-v2/config\"\n\t\"github.com/aws/smithy-go/auth/bearer\"\n\t\"github.com/tidwall/gjson\"\n\t\"github.com/tidwall/sjson\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/ssestream\"\n)\n\nconst DefaultVersion = \"bedrock-2023-05-31\"\n\nvar DefaultEndpoints = map[string]bool{\n\t\"/v1/complete\": true,\n\t\"/v1/messages\": true,\n}\n\nfunc NewStaticBearerTokenProvider(token string) *bearer.StaticTokenProvider {\n\treturn &bearer.StaticTokenProvider{\n\t\tToken: bearer.Token{\n\t\t\tValue:     token,\n\t\t\tCanExpire: false,\n\t\t},\n\t}\n}\n\ntype eventstreamChunk struct {\n\tBytes string `json:\"bytes\"`\n\tP     string `json:\"p\"`\n}\n\ntype eventstreamDecoder struct {\n\teventstream.Decoder\n\n\trc  io.ReadCloser\n\tevt ssestream.Event\n\terr error\n}\n\nfunc (e *eventstreamDecoder) Close() error {\n\treturn e.rc.Close()\n}\n\nfunc (e *eventstreamDecoder) Err() error {\n\treturn e.err\n}\n\nfunc (e *eventstreamDecoder) Next() bool {\n\tif e.err != nil {\n\t\treturn false\n\t}\n\n\tmsg, err := e.Decoder.Decode(e.rc, nil)\n\tif err != nil {\n\t\te.err = err\n\t\treturn false\n\t}\n\n\tmessageType := msg.Headers.Get(eventstreamapi.MessageTypeHeader)\n\tif messageType == nil {\n\t\te.err = fmt.Errorf(\"%s event header not present\", eventstreamapi.MessageTypeHeader)\n\t\treturn false\n\t}\n\n\tswitch messageType.String() {\n\tcase eventstreamapi.EventMessageType:\n\t\teventType := msg.Headers.Get(eventstreamapi.EventTypeHeader)\n\t\tif eventType == nil {\n\t\t\te.err = fmt.Errorf(\"%s event header not present\", eventstreamapi.EventTypeHeader)\n\t\t\treturn false\n\t\t}\n\n\t\tif eventType.String() == \"chunk\" {\n\t\t\tchunk := eventstreamChunk{}\n\t\t\terr = json.Unmarshal(msg.Payload, &chunk)\n\t\t\tif err != nil {\n\t\t\t\te.err = err\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tdecoded, err := base64.StdEncoding.DecodeString(chunk.Bytes)\n\t\t\tif err != nil {\n\t\t\t\te.err = err\n\t\t\t\treturn false\n\t\t\t}\n\t\t\te.evt = ssestream.Event{\n\t\t\t\tType: gjson.GetBytes(decoded, \"type\").String(),\n\t\t\t\tData: decoded,\n\t\t\t}\n\t\t}\n\n\tcase eventstreamapi.ExceptionMessageType:\n\t\t// See https://github.com/aws/aws-sdk-go-v2/blob/885de40869f9bcee29ad11d60967aa0f1b571d46/service/iotsitewise/deserializers.go#L15511C1-L15567C2\n\t\texceptionType := msg.Headers.Get(eventstreamapi.ExceptionTypeHeader)\n\t\tif exceptionType == nil {\n\t\t\te.err = fmt.Errorf(\"%s event header not present\", eventstreamapi.ExceptionTypeHeader)\n\t\t\treturn false\n\t\t}\n\n\t\t// See https://github.com/aws/aws-sdk-go-v2/blob/885de40869f9bcee29ad11d60967aa0f1b571d46/aws/protocol/restjson/decoder_util.go#L15-L48k\n\t\tvar errInfo struct {\n\t\t\tCode    string\n\t\t\tType    string `json:\"__type\"`\n\t\t\tMessage string\n\t\t}\n\t\terr = json.Unmarshal(msg.Payload, &errInfo)\n\t\tif err != nil && err != io.EOF {\n\t\t\te.err = fmt.Errorf(\"received exception %s: parsing exception payload failed: %w\", exceptionType.String(), err)\n\t\t\treturn false\n\t\t}\n\n\t\terrorCode := \"UnknownError\"\n\t\terrorMessage := errorCode\n\t\tif ev := exceptionType.String(); len(ev) > 0 {\n\t\t\terrorCode = ev\n\t\t} else if len(errInfo.Code) > 0 {\n\t\t\terrorCode = errInfo.Code\n\t\t} else if len(errInfo.Type) > 0 {\n\t\t\terrorCode = errInfo.Type\n\t\t}\n\n\t\tif len(errInfo.Message) > 0 {\n\t\t\terrorMessage = errInfo.Message\n\t\t}\n\t\te.err = fmt.Errorf(\"received exception %s: %s\", errorCode, errorMessage)\n\t\treturn false\n\n\tcase eventstreamapi.ErrorMessageType:\n\t\terrorCode := \"UnknownError\"\n\t\terrorMessage := errorCode\n\t\tif header := msg.Headers.Get(eventstreamapi.ErrorCodeHeader); header != nil {\n\t\t\terrorCode = header.String()\n\t\t}\n\t\tif header := msg.Headers.Get(eventstreamapi.ErrorMessageHeader); header != nil {\n\t\t\terrorMessage = header.String()\n\t\t}\n\t\te.err = fmt.Errorf(\"received error %s: %s\", errorCode, errorMessage)\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc (e *eventstreamDecoder) Event() ssestream.Event {\n\treturn e.evt\n}\n\nvar (\n\t_ ssestream.Decoder = &eventstreamDecoder{}\n)\n\nfunc init() {\n\tssestream.RegisterDecoder(\"application/vnd.amazon.eventstream\", func(rc io.ReadCloser) ssestream.Decoder {\n\t\treturn &eventstreamDecoder{rc: rc}\n\t})\n}\n\n// WithLoadDefaultConfig returns a request option which loads the default config for Amazon and registers\n// middleware that intercepts request to the Messages API so that this SDK can be used with Amazon Bedrock.\n//\n// If you already have an [aws.Config], it is recommended that you instead call [WithConfig] directly.\nfunc WithLoadDefaultConfig(ctx context.Context, optFns ...func(*config.LoadOptions) error) option.RequestOption {\n\tcfg, err := config.LoadDefaultConfig(ctx, optFns...)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn WithConfig(cfg)\n}\n\n// WithConfig returns a request option that uses the provided config and registers middleware to\n// intercept requests to the Messages API, enabling this SDK to work with Amazon Bedrock.\n//\n// Authentication is determined as follows: if the AWS_BEARER_TOKEN_BEDROCK environment variable is\n// set, it is used for bearer token authentication. Otherwise, if cfg.BearerAuthTokenProvider is set,\n// it is used. If neither is available, cfg.Credentials is used for AWS SigV4 signing and must be set.\nfunc WithConfig(cfg aws.Config) option.RequestOption {\n\tvar credentialErr error\n\n\tif cfg.BearerAuthTokenProvider == nil {\n\t\tif token := os.Getenv(\"AWS_BEARER_TOKEN_BEDROCK\"); token != \"\" {\n\t\t\tcfg.BearerAuthTokenProvider = NewStaticBearerTokenProvider(token)\n\t\t}\n\t} else if cfg.BearerAuthTokenProvider == nil && cfg.Credentials == nil {\n\t\tcredentialErr = fmt.Errorf(\"expected AWS credentials to be set\")\n\t}\n\n\tsigner := v4.NewSigner()\n\tmiddleware := bedrockMiddleware(signer, cfg)\n\n\treturn requestconfig.RequestOptionFunc(func(rc *requestconfig.RequestConfig) error {\n\t\tif credentialErr != nil {\n\t\t\treturn credentialErr\n\t\t}\n\t\treturn rc.Apply(\n\t\t\toption.WithBaseURL(fmt.Sprintf(\"https://bedrock-runtime.%s.amazonaws.com\", cfg.Region)),\n\t\t\toption.WithMiddleware(middleware),\n\t\t)\n\t})\n}\n\nfunc bedrockMiddleware(signer *v4.Signer, cfg aws.Config) option.Middleware {\n\treturn func(r *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {\n\t\tvar body []byte\n\t\tif r.Body != nil {\n\t\t\tbody, err = io.ReadAll(r.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tr.Body.Close()\n\n\t\t\tif !gjson.GetBytes(body, \"anthropic_version\").Exists() {\n\t\t\t\tbody, _ = sjson.SetBytes(body, \"anthropic_version\", DefaultVersion)\n\t\t\t}\n\n\t\t\t// pull the betas off of the header (if set) and put them in the body\n\t\t\tif betaHeader := r.Header.Values(\"anthropic-beta\"); len(betaHeader) > 0 {\n\t\t\t\tr.Header.Del(\"anthropic-beta\")\n\t\t\t\tbody, err = sjson.SetBytes(body, \"anthropic_beta\", betaHeader)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif r.Method == http.MethodPost && DefaultEndpoints[r.URL.Path] {\n\t\t\t\tmodel := gjson.GetBytes(body, \"model\").String()\n\t\t\t\tstream := gjson.GetBytes(body, \"stream\").Bool()\n\n\t\t\t\tbody, _ = sjson.DeleteBytes(body, \"model\")\n\t\t\t\tbody, _ = sjson.DeleteBytes(body, \"stream\")\n\n\t\t\t\tvar method string\n\t\t\t\tif stream {\n\t\t\t\t\tmethod = \"invoke-with-response-stream\"\n\t\t\t\t} else {\n\t\t\t\t\tmethod = \"invoke\"\n\t\t\t\t}\n\n\t\t\t\tr.URL.Path = fmt.Sprintf(\"/model/%s/%s\", model, method)\n\t\t\t\tr.URL.RawPath = fmt.Sprintf(\"/model/%s/%s\", url.QueryEscape(model), method)\n\t\t\t}\n\n\t\t\treader := bytes.NewReader(body)\n\t\t\tr.Body = io.NopCloser(reader)\n\t\t\tr.GetBody = func() (io.ReadCloser, error) {\n\t\t\t\t_, err := reader.Seek(0, 0)\n\t\t\t\treturn io.NopCloser(reader), err\n\t\t\t}\n\t\t\tr.ContentLength = int64(len(body))\n\t\t}\n\n\t\t// Use bearer token authentication if configured, otherwise fall back to SigV4\n\t\tif cfg.BearerAuthTokenProvider != nil {\n\t\t\ttoken, err := cfg.BearerAuthTokenProvider.RetrieveBearerToken(r.Context())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tr.Header.Set(\"Authorization\", \"Bearer \"+token.Value)\n\t\t} else {\n\t\t\tctx := r.Context()\n\t\t\tcredentials, err := cfg.Credentials.Retrieve(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\thash := sha256.Sum256(body)\n\t\t\terr = signer.SignHTTP(ctx, credentials, r, hex.EncodeToString(hash[:]), \"bedrock\", cfg.Region, time.Now())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\treturn next(r)\n\t}\n}\n"
  },
  {
    "path": "bedrock/bedrock_test.go",
    "content": "package bedrock\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"testing\"\n\n\t\"github.com/aws/aws-sdk-go-v2/aws\"\n\tv4 \"github.com/aws/aws-sdk-go-v2/aws/signer/v4\"\n\t\"github.com/aws/aws-sdk-go-v2/credentials\"\n)\n\nfunc TestBedrockURLEncoding(t *testing.T) {\n\ttestCases := []struct {\n\t\tname            string\n\t\tmodel           string\n\t\tstream          bool\n\t\texpectedPath    string\n\t\texpectedRawPath string\n\t}{\n\t\t{\n\t\t\tname:            \"regular model name\",\n\t\t\tmodel:           \"claude-3-sonnet\",\n\t\t\tstream:          false,\n\t\t\texpectedPath:    \"/model/claude-3-sonnet/invoke\",\n\t\t\texpectedRawPath: \"/model/claude-3-sonnet/invoke\",\n\t\t},\n\t\t{\n\t\t\tname:            \"regular model name with streaming\",\n\t\t\tmodel:           \"claude-3-sonnet\",\n\t\t\tstream:          true,\n\t\t\texpectedPath:    \"/model/claude-3-sonnet/invoke-with-response-stream\",\n\t\t\texpectedRawPath: \"/model/claude-3-sonnet/invoke-with-response-stream\",\n\t\t},\n\t\t{\n\t\t\tname:            \"inference profile ARN with slashes\",\n\t\t\tmodel:           \"arn:aws:bedrock:us-east-1:947123456126:application-inference-profile/xv9example4b\",\n\t\t\tstream:          false,\n\t\t\texpectedPath:    \"/model/arn:aws:bedrock:us-east-1:947123456126:application-inference-profile/xv9example4b/invoke\",\n\t\t\texpectedRawPath: \"/model/arn%3Aaws%3Abedrock%3Aus-east-1%3A947123456126%3Aapplication-inference-profile%2Fxv9example4b/invoke\",\n\t\t},\n\t\t{\n\t\t\tname:            \"inference profile ARN with streaming\",\n\t\t\tmodel:           \"arn:aws:bedrock:us-east-1:947123456126:application-inference-profile/xv9example4b\",\n\t\t\tstream:          true,\n\t\t\texpectedPath:    \"/model/arn:aws:bedrock:us-east-1:947123456126:application-inference-profile/xv9example4b/invoke-with-response-stream\",\n\t\t\texpectedRawPath: \"/model/arn%3Aaws%3Abedrock%3Aus-east-1%3A947123456126%3Aapplication-inference-profile%2Fxv9example4b/invoke-with-response-stream\",\n\t\t},\n\t\t{\n\t\t\tname:            \"foundation model ARN with colons\",\n\t\t\tmodel:           \"arn:aws:bedrock:us-east-1:123456789012:foundation-model/anthropic.claude-3-sonnet-20240229-v1:0\",\n\t\t\tstream:          false,\n\t\t\texpectedPath:    \"/model/arn:aws:bedrock:us-east-1:123456789012:foundation-model/anthropic.claude-3-sonnet-20240229-v1:0/invoke\",\n\t\t\texpectedRawPath: \"/model/arn%3Aaws%3Abedrock%3Aus-east-1%3A123456789012%3Afoundation-model%2Fanthropic.claude-3-sonnet-20240229-v1%3A0/invoke\",\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\t// Create a mock AWS config\n\t\t\tcfg := aws.Config{\n\t\t\t\tRegion: \"us-east-1\",\n\t\t\t\tCredentials: credentials.StaticCredentialsProvider{\n\t\t\t\t\tValue: aws.Credentials{\n\t\t\t\t\t\tAccessKeyID:     \"test-access-key\",\n\t\t\t\t\t\tSecretAccessKey: \"test-secret-key\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tsigner := v4.NewSigner()\n\t\t\tmiddleware := bedrockMiddleware(signer, cfg)\n\n\t\t\t// Create request body\n\t\t\trequestBody := map[string]any{\n\t\t\t\t\"model\":  tc.model,\n\t\t\t\t\"stream\": tc.stream,\n\t\t\t\t\"messages\": []map[string]string{\n\t\t\t\t\t{\"role\": \"user\", \"content\": \"Hello\"},\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tbodyBytes, err := json.Marshal(requestBody)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to marshal request body: %v\", err)\n\t\t\t}\n\n\t\t\t// Create HTTP request\n\t\t\treq, err := http.NewRequest(\"POST\", \"https://bedrock-runtime.us-east-1.amazonaws.com/v1/messages\", bytes.NewReader(bodyBytes))\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to create request: %v\", err)\n\t\t\t}\n\t\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\t\t\t// Apply middleware\n\t\t\t_, err = middleware(req, func(r *http.Request) (*http.Response, error) {\n\t\t\t\t// Verify the URL paths are set correctly\n\t\t\t\tif r.URL.Path != tc.expectedPath {\n\t\t\t\t\tt.Errorf(\"Expected Path %q, got %q\", tc.expectedPath, r.URL.Path)\n\t\t\t\t}\n\n\t\t\t\tif r.URL.RawPath != tc.expectedRawPath {\n\t\t\t\t\tt.Errorf(\"Expected RawPath %q, got %q\", tc.expectedRawPath, r.URL.RawPath)\n\t\t\t\t}\n\n\t\t\t\t// Verify that the URL string contains the properly encoded path\n\t\t\t\turlString := r.URL.String()\n\t\t\t\texpectedURL := fmt.Sprintf(\"https://bedrock-runtime.us-east-1.amazonaws.com%s\", tc.expectedRawPath)\n\t\t\t\tif urlString != expectedURL {\n\t\t\t\t\tt.Errorf(\"Expected URL %q, got %q\", expectedURL, urlString)\n\t\t\t\t}\n\n\t\t\t\t// Return a dummy response\n\t\t\t\treturn &http.Response{\n\t\t\t\t\tStatusCode: 200,\n\t\t\t\t\tBody:       http.NoBody,\n\t\t\t\t}, nil\n\t\t\t})\n\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Middleware failed: %v\", err)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestBedrockBetaHeadersReRoutedThroughBody(t *testing.T) {\n\t// Create a mock AWS config\n\tcfg := aws.Config{\n\t\tRegion: \"us-east-1\",\n\t\tCredentials: credentials.StaticCredentialsProvider{\n\t\t\tValue: aws.Credentials{\n\t\t\t\tAccessKeyID:     \"test-access-key\",\n\t\t\t\tSecretAccessKey: \"test-secret-key\",\n\t\t\t},\n\t\t},\n\t}\n\n\tsigner := v4.NewSigner()\n\tmiddleware := bedrockMiddleware(signer, cfg)\n\n\t// Create HTTP request with beta headers\n\ttype fakeRequest struct {\n\t\tModel         string              `json:\"model\"`\n\t\tAnthropicBeta []string            `json:\"anthropic_beta,omitempty\"`\n\t\tMessages      []map[string]string `json:\"messages\"`\n\t}\n\treqBody := fakeRequest{\n\t\tModel: \"fake-model\",\n\t\tMessages: []map[string]string{\n\t\t\t{\"role\": \"user\", \"content\": \"Hello\"},\n\t\t},\n\t}\n\trequestBodyBytes, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to marshal request body: %v\", err)\n\t}\n\n\treq, err := http.NewRequest(\"POST\", \"https://bedrock-runtime.us-east-1.amazonaws.com/v1/messages\", bytes.NewReader(requestBodyBytes))\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to create request: %v\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"anthropic-beta\", \"beta-feature-1\")\n\treq.Header.Add(\"anthropic-beta\", \"beta-feature-2\")\n\n\t// Apply middleware\n\t_, err = middleware(req, func(r *http.Request) (*http.Response, error) {\n\t\t// Read the modified body\n\t\tbodyBytes, err := io.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Failed to read request body: %v\", err)\n\t\t}\n\t\tvar modifiedBody fakeRequest\n\t\terr = json.Unmarshal(bodyBytes, &modifiedBody)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Failed to unmarshal modified body: %v\", err)\n\t\t}\n\n\t\t// Verify that the anthropic_beta field is present in the body\n\t\texpectedBetas := []string{\"beta-feature-1\", \"beta-feature-2\"}\n\t\tif len(modifiedBody.AnthropicBeta) != len(expectedBetas) {\n\t\t\tt.Fatalf(\"Expected %d beta features, got %d\", len(expectedBetas), len(modifiedBody.AnthropicBeta))\n\t\t}\n\t\tfor i, beta := range expectedBetas {\n\t\t\tif modifiedBody.AnthropicBeta[i] != beta {\n\t\t\t\tt.Errorf(\"Expected beta feature %q, got %q\", beta, modifiedBody.AnthropicBeta[i])\n\t\t\t}\n\t\t}\n\n\t\t// Return a dummy response\n\t\treturn &http.Response{\n\t\t\tStatusCode: 200,\n\t\t\tBody:       http.NoBody,\n\t\t}, nil\n\t})\n\n\tif err != nil {\n\t\tt.Fatalf(\"Middleware failed: %v\", err)\n\t}\n}\n\nfunc TestBedrockBearerToken(t *testing.T) {\n\ttoken := \"test-bearer-token\"\n\tregion := \"us-west-2\"\n\n\tcfg := aws.Config{\n\t\tRegion:                  region,\n\t\tBearerAuthTokenProvider: NewStaticBearerTokenProvider(token),\n\t}\n\tmiddleware := bedrockMiddleware(nil, cfg)\n\n\trequestBody := map[string]any{\n\t\t\"model\": \"claude-3-sonnet\",\n\t\t\"messages\": []map[string]string{\n\t\t\t{\"role\": \"user\", \"content\": \"Hello\"},\n\t\t},\n\t}\n\n\tbodyBytes, err := json.Marshal(requestBody)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to marshal request body: %v\", err)\n\t}\n\n\treq, err := http.NewRequest(\"POST\", \"https://bedrock-runtime.us-west-2.amazonaws.com/v1/messages\", bytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to create request: %v\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\t_, err = middleware(req, func(r *http.Request) (*http.Response, error) {\n\t\tauthHeader := r.Header.Get(\"Authorization\")\n\t\texpectedAuth := \"Bearer \" + token\n\t\tif authHeader != expectedAuth {\n\t\t\tt.Errorf(\"Expected Authorization header %q, got %q\", expectedAuth, authHeader)\n\t\t}\n\n\t\tif r.Header.Get(\"X-Amz-Date\") != \"\" {\n\t\t\tt.Error(\"Expected no AWS SigV4 headers when using bearer token\")\n\t\t}\n\n\t\treturn &http.Response{\n\t\t\tStatusCode: 200,\n\t\t\tBody:       http.NoBody,\n\t\t}, nil\n\t})\n\n\tif err != nil {\n\t\tt.Fatalf(\"Middleware failed: %v\", err)\n\t}\n}\n"
  },
  {
    "path": "beta.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"encoding/json\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// BetaService contains methods and other services that help with interacting with\n// the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaService] method instead.\ntype BetaService struct {\n\tOptions  []option.RequestOption\n\tModels   BetaModelService\n\tMessages BetaMessageService\n\tFiles    BetaFileService\n\tSkills   BetaSkillService\n}\n\n// NewBetaService generates a new service that applies the given options to each\n// request. These options are applied after the parent client's options (if there\n// is one), and before any request-specific options.\nfunc NewBetaService(opts ...option.RequestOption) (r BetaService) {\n\tr = BetaService{}\n\tr.Options = opts\n\tr.Models = NewBetaModelService(opts...)\n\tr.Messages = NewBetaMessageService(opts...)\n\tr.Files = NewBetaFileService(opts...)\n\tr.Skills = NewBetaSkillService(opts...)\n\treturn\n}\n\ntype AnthropicBeta = string\n\nconst (\n\tAnthropicBetaMessageBatches2024_09_24             AnthropicBeta = \"message-batches-2024-09-24\"\n\tAnthropicBetaPromptCaching2024_07_31              AnthropicBeta = \"prompt-caching-2024-07-31\"\n\tAnthropicBetaComputerUse2024_10_22                AnthropicBeta = \"computer-use-2024-10-22\"\n\tAnthropicBetaComputerUse2025_01_24                AnthropicBeta = \"computer-use-2025-01-24\"\n\tAnthropicBetaPDFs2024_09_25                       AnthropicBeta = \"pdfs-2024-09-25\"\n\tAnthropicBetaTokenCounting2024_11_01              AnthropicBeta = \"token-counting-2024-11-01\"\n\tAnthropicBetaTokenEfficientTools2025_02_19        AnthropicBeta = \"token-efficient-tools-2025-02-19\"\n\tAnthropicBetaOutput128k2025_02_19                 AnthropicBeta = \"output-128k-2025-02-19\"\n\tAnthropicBetaFilesAPI2025_04_14                   AnthropicBeta = \"files-api-2025-04-14\"\n\tAnthropicBetaMCPClient2025_04_04                  AnthropicBeta = \"mcp-client-2025-04-04\"\n\tAnthropicBetaMCPClient2025_11_20                  AnthropicBeta = \"mcp-client-2025-11-20\"\n\tAnthropicBetaDevFullThinking2025_05_14            AnthropicBeta = \"dev-full-thinking-2025-05-14\"\n\tAnthropicBetaInterleavedThinking2025_05_14        AnthropicBeta = \"interleaved-thinking-2025-05-14\"\n\tAnthropicBetaCodeExecution2025_05_22              AnthropicBeta = \"code-execution-2025-05-22\"\n\tAnthropicBetaExtendedCacheTTL2025_04_11           AnthropicBeta = \"extended-cache-ttl-2025-04-11\"\n\tAnthropicBetaContext1m2025_08_07                  AnthropicBeta = \"context-1m-2025-08-07\"\n\tAnthropicBetaContextManagement2025_06_27          AnthropicBeta = \"context-management-2025-06-27\"\n\tAnthropicBetaModelContextWindowExceeded2025_08_26 AnthropicBeta = \"model-context-window-exceeded-2025-08-26\"\n\tAnthropicBetaSkills2025_10_02                     AnthropicBeta = \"skills-2025-10-02\"\n\tAnthropicBetaFastMode2026_02_01                   AnthropicBeta = \"fast-mode-2026-02-01\"\n)\n\ntype BetaAPIError struct {\n\tMessage string            `json:\"message\" api:\"required\"`\n\tType    constant.APIError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaAPIError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaAPIError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaAuthenticationError struct {\n\tMessage string                       `json:\"message\" api:\"required\"`\n\tType    constant.AuthenticationError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaAuthenticationError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaAuthenticationError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBillingError struct {\n\tMessage string                `json:\"message\" api:\"required\"`\n\tType    constant.BillingError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaBillingError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaBillingError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaErrorUnion contains all possible properties and values from\n// [BetaInvalidRequestError], [BetaAuthenticationError], [BetaBillingError],\n// [BetaPermissionError], [BetaNotFoundError], [BetaRateLimitError],\n// [BetaGatewayTimeoutError], [BetaAPIError], [BetaOverloadedError].\n//\n// Use the [BetaErrorUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaErrorUnion struct {\n\tMessage string `json:\"message\"`\n\t// Any of \"invalid_request_error\", \"authentication_error\", \"billing_error\",\n\t// \"permission_error\", \"not_found_error\", \"rate_limit_error\", \"timeout_error\",\n\t// \"api_error\", \"overloaded_error\".\n\tType string `json:\"type\"`\n\tJSON struct {\n\t\tMessage respjson.Field\n\t\tType    respjson.Field\n\t\traw     string\n\t} `json:\"-\"`\n}\n\n// anyBetaError is implemented by each variant of [BetaErrorUnion] to add type\n// safety for the return type of [BetaErrorUnion.AsAny]\ntype anyBetaError interface {\n\timplBetaErrorUnion()\n}\n\nfunc (BetaInvalidRequestError) implBetaErrorUnion() {}\nfunc (BetaAuthenticationError) implBetaErrorUnion() {}\nfunc (BetaBillingError) implBetaErrorUnion()        {}\nfunc (BetaPermissionError) implBetaErrorUnion()     {}\nfunc (BetaNotFoundError) implBetaErrorUnion()       {}\nfunc (BetaRateLimitError) implBetaErrorUnion()      {}\nfunc (BetaGatewayTimeoutError) implBetaErrorUnion() {}\nfunc (BetaAPIError) implBetaErrorUnion()            {}\nfunc (BetaOverloadedError) implBetaErrorUnion()     {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaErrorUnion.AsAny().(type) {\n//\tcase anthropic.BetaInvalidRequestError:\n//\tcase anthropic.BetaAuthenticationError:\n//\tcase anthropic.BetaBillingError:\n//\tcase anthropic.BetaPermissionError:\n//\tcase anthropic.BetaNotFoundError:\n//\tcase anthropic.BetaRateLimitError:\n//\tcase anthropic.BetaGatewayTimeoutError:\n//\tcase anthropic.BetaAPIError:\n//\tcase anthropic.BetaOverloadedError:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaErrorUnion) AsAny() anyBetaError {\n\tswitch u.Type {\n\tcase \"invalid_request_error\":\n\t\treturn u.AsInvalidRequestError()\n\tcase \"authentication_error\":\n\t\treturn u.AsAuthenticationError()\n\tcase \"billing_error\":\n\t\treturn u.AsBillingError()\n\tcase \"permission_error\":\n\t\treturn u.AsPermissionError()\n\tcase \"not_found_error\":\n\t\treturn u.AsNotFoundError()\n\tcase \"rate_limit_error\":\n\t\treturn u.AsRateLimitError()\n\tcase \"timeout_error\":\n\t\treturn u.AsTimeoutError()\n\tcase \"api_error\":\n\t\treturn u.AsAPIError()\n\tcase \"overloaded_error\":\n\t\treturn u.AsOverloadedError()\n\t}\n\treturn nil\n}\n\nfunc (u BetaErrorUnion) AsInvalidRequestError() (v BetaInvalidRequestError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsAuthenticationError() (v BetaAuthenticationError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsBillingError() (v BetaBillingError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsPermissionError() (v BetaPermissionError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsNotFoundError() (v BetaNotFoundError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsRateLimitError() (v BetaRateLimitError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsTimeoutError() (v BetaGatewayTimeoutError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsAPIError() (v BetaAPIError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaErrorUnion) AsOverloadedError() (v BetaOverloadedError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaErrorUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaErrorUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaErrorResponse struct {\n\tError     BetaErrorUnion `json:\"error\" api:\"required\"`\n\tRequestID string         `json:\"request_id\" api:\"required\"`\n\tType      constant.Error `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tError       respjson.Field\n\t\tRequestID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaErrorResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaErrorResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaGatewayTimeoutError struct {\n\tMessage string                `json:\"message\" api:\"required\"`\n\tType    constant.TimeoutError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaGatewayTimeoutError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaGatewayTimeoutError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaInvalidRequestError struct {\n\tMessage string                       `json:\"message\" api:\"required\"`\n\tType    constant.InvalidRequestError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaInvalidRequestError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaInvalidRequestError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaNotFoundError struct {\n\tMessage string                 `json:\"message\" api:\"required\"`\n\tType    constant.NotFoundError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaNotFoundError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaNotFoundError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaOverloadedError struct {\n\tMessage string                   `json:\"message\" api:\"required\"`\n\tType    constant.OverloadedError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaOverloadedError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaOverloadedError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaPermissionError struct {\n\tMessage string                   `json:\"message\" api:\"required\"`\n\tType    constant.PermissionError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaPermissionError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaPermissionError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRateLimitError struct {\n\tMessage string                  `json:\"message\" api:\"required\"`\n\tType    constant.RateLimitError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRateLimitError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRateLimitError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n"
  },
  {
    "path": "betafile.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiform\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// BetaFileService contains methods and other services that help with interacting\n// with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaFileService] method instead.\ntype BetaFileService struct {\n\tOptions []option.RequestOption\n}\n\n// NewBetaFileService generates a new service that applies the given options to\n// each request. These options are applied after the parent client's options (if\n// there is one), and before any request-specific options.\nfunc NewBetaFileService(opts ...option.RequestOption) (r BetaFileService) {\n\tr = BetaFileService{}\n\tr.Options = opts\n\treturn\n}\n\n// List Files\nfunc (r *BetaFileService) List(ctx context.Context, params BetaFileListParams, opts ...option.RequestOption) (res *pagination.Page[FileMetadata], err error) {\n\tvar raw *http.Response\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"files-api-2025-04-14\"), option.WithResponseInto(&raw)}, opts...)\n\tpath := \"v1/files?beta=true\"\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List Files\nfunc (r *BetaFileService) ListAutoPaging(ctx context.Context, params BetaFileListParams, opts ...option.RequestOption) *pagination.PageAutoPager[FileMetadata] {\n\treturn pagination.NewPageAutoPager(r.List(ctx, params, opts...))\n}\n\n// Delete File\nfunc (r *BetaFileService) Delete(ctx context.Context, fileID string, body BetaFileDeleteParams, opts ...option.RequestOption) (res *DeletedFile, err error) {\n\tfor _, v := range body.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"files-api-2025-04-14\")}, opts...)\n\tif fileID == \"\" {\n\t\terr = errors.New(\"missing required file_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/files/%s?beta=true\", fileID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Download File\nfunc (r *BetaFileService) Download(ctx context.Context, fileID string, query BetaFileDownloadParams, opts ...option.RequestOption) (res *http.Response, err error) {\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"files-api-2025-04-14\"), option.WithHeader(\"Accept\", \"application/binary\")}, opts...)\n\tif fileID == \"\" {\n\t\terr = errors.New(\"missing required file_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/files/%s/content?beta=true\", fileID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Get File Metadata\nfunc (r *BetaFileService) GetMetadata(ctx context.Context, fileID string, query BetaFileGetMetadataParams, opts ...option.RequestOption) (res *FileMetadata, err error) {\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"files-api-2025-04-14\")}, opts...)\n\tif fileID == \"\" {\n\t\terr = errors.New(\"missing required file_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/files/%s?beta=true\", fileID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Upload File\nfunc (r *BetaFileService) Upload(ctx context.Context, params BetaFileUploadParams, opts ...option.RequestOption) (res *FileMetadata, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"files-api-2025-04-14\")}, opts...)\n\tpath := \"v1/files?beta=true\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\ntype DeletedFile struct {\n\t// ID of the deleted file.\n\tID string `json:\"id\" api:\"required\"`\n\t// Deleted object type.\n\t//\n\t// For file deletion, this is always `\"file_deleted\"`.\n\t//\n\t// Any of \"file_deleted\".\n\tType DeletedFileType `json:\"type\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r DeletedFile) RawJSON() string { return r.JSON.raw }\nfunc (r *DeletedFile) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Deleted object type.\n//\n// For file deletion, this is always `\"file_deleted\"`.\ntype DeletedFileType string\n\nconst (\n\tDeletedFileTypeFileDeleted DeletedFileType = \"file_deleted\"\n)\n\ntype FileMetadata struct {\n\t// Unique object identifier.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// RFC 3339 datetime string representing when the file was created.\n\tCreatedAt time.Time `json:\"created_at\" api:\"required\" format:\"date-time\"`\n\t// Original filename of the uploaded file.\n\tFilename string `json:\"filename\" api:\"required\"`\n\t// MIME type of the file.\n\tMimeType string `json:\"mime_type\" api:\"required\"`\n\t// Size of the file in bytes.\n\tSizeBytes int64 `json:\"size_bytes\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For files, this is always `\"file\"`.\n\tType constant.File `json:\"type\" api:\"required\"`\n\t// Whether the file can be downloaded.\n\tDownloadable bool `json:\"downloadable\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID           respjson.Field\n\t\tCreatedAt    respjson.Field\n\t\tFilename     respjson.Field\n\t\tMimeType     respjson.Field\n\t\tSizeBytes    respjson.Field\n\t\tType         respjson.Field\n\t\tDownloadable respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r FileMetadata) RawJSON() string { return r.JSON.raw }\nfunc (r *FileMetadata) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaFileListParams struct {\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately after this object.\n\tAfterID param.Opt[string] `query:\"after_id,omitzero\" json:\"-\"`\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately before this object.\n\tBeforeID param.Opt[string] `query:\"before_id,omitzero\" json:\"-\"`\n\t// Number of items to return per page.\n\t//\n\t// Defaults to `20`. Ranges from `1` to `1000`.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [BetaFileListParams]'s query parameters as `url.Values`.\nfunc (r BetaFileListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n\ntype BetaFileDeleteParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaFileDownloadParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaFileGetMetadataParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaFileUploadParams struct {\n\t// The file to upload\n\tFile io.Reader `json:\"file,omitzero\" api:\"required\" format:\"binary\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaFileUploadParams) MarshalMultipart() (data []byte, contentType string, err error) {\n\tbuf := bytes.NewBuffer(nil)\n\twriter := multipart.NewWriter(buf)\n\terr = apiform.MarshalRoot(r, writer)\n\tif err == nil {\n\t\terr = apiform.WriteExtras(writer, r.ExtraFields())\n\t}\n\tif err != nil {\n\t\twriter.Close()\n\t\treturn nil, \"\", err\n\t}\n\terr = writer.Close()\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\treturn buf.Bytes(), writer.FormDataContentType(), nil\n}\n"
  },
  {
    "path": "betafile_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestBetaFileListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Files.List(context.TODO(), anthropic.BetaFileListParams{\n\t\tAfterID:  anthropic.String(\"after_id\"),\n\t\tBeforeID: anthropic.String(\"before_id\"),\n\t\tLimit:    anthropic.Int(1),\n\t\tBetas:    []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaFileDeleteWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Files.Delete(\n\t\tcontext.TODO(),\n\t\t\"file_id\",\n\t\tanthropic.BetaFileDeleteParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaFileDownloadWithOptionalParams(t *testing.T) {\n\tserver := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(200)\n\t\tw.Write([]byte(\"abc\"))\n\t}))\n\tdefer server.Close()\n\tbaseURL := server.URL\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\tresp, err := client.Beta.Files.Download(\n\t\tcontext.TODO(),\n\t\t\"file_id\",\n\t\tanthropic.BetaFileDownloadParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n\tdefer resp.Body.Close()\n\n\tb, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n\tif !bytes.Equal(b, []byte(\"abc\")) {\n\t\tt.Fatalf(\"return value not %s: %s\", \"abc\", b)\n\t}\n}\n\nfunc TestBetaFileGetMetadataWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Files.GetMetadata(\n\t\tcontext.TODO(),\n\t\t\"file_id\",\n\t\tanthropic.BetaFileGetMetadataParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaFileUploadWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Files.Upload(context.TODO(), anthropic.BetaFileUploadParams{\n\t\tFile:  io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "betamessage.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/paramutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/ssestream\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// BetaMessageService contains methods and other services that help with\n// interacting with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaMessageService] method instead.\ntype BetaMessageService struct {\n\tOptions []option.RequestOption\n\tBatches BetaMessageBatchService\n}\n\n// NewBetaMessageService generates a new service that applies the given options to\n// each request. These options are applied after the parent client's options (if\n// there is one), and before any request-specific options.\nfunc NewBetaMessageService(opts ...option.RequestOption) (r BetaMessageService) {\n\tr = BetaMessageService{}\n\tr.Options = opts\n\tr.Batches = NewBetaMessageBatchService(opts...)\n\treturn\n}\n\n// Send a structured list of input messages with text and/or image content, and the\n// model will generate the next message in the conversation.\n//\n// The Messages API can be used for either single queries or stateless multi-turn\n// conversations.\n//\n// Learn more about the Messages API in our\n// [user guide](https://docs.claude.com/en/docs/initial-setup)\n//\n// Note: If you choose to set a timeout for this request, we recommend 10 minutes.\nfunc (r *BetaMessageService) New(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (res *BetaMessage, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\n\t// For non-streaming requests, calculate the appropriate timeout based on maxTokens\n\t// and check against model-specific limits\n\ttimeout, timeoutErr := CalculateNonStreamingTimeout(int(params.MaxTokens), params.Model, opts)\n\tif timeoutErr != nil {\n\t\treturn nil, timeoutErr\n\t}\n\topts = append(opts, option.WithRequestTimeout(timeout))\n\n\tpath := \"v1/messages?beta=true\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\n// Send a structured list of input messages with text and/or image content, and the\n// model will generate the next message in the conversation.\n//\n// The Messages API can be used for either single queries or stateless multi-turn\n// conversations.\n//\n// Learn more about the Messages API in our\n// [user guide](https://docs.claude.com/en/docs/initial-setup)\n//\n// Note: If you choose to set a timeout for this request, we recommend 10 minutes.\nfunc (r *BetaMessageService) NewStreaming(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[BetaRawMessageStreamEventUnion]) {\n\tvar (\n\t\traw *http.Response\n\t\terr error\n\t)\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append(opts, option.WithJSONSet(\"stream\", true))\n\tpath := \"v1/messages?beta=true\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...)\n\treturn ssestream.NewStream[BetaRawMessageStreamEventUnion](ssestream.NewDecoder(raw), err)\n}\n\n// Count the number of tokens in a Message.\n//\n// The Token Count API can be used to count the number of tokens in a Message,\n// including tools, images, and documents, without creating it.\n//\n// Learn more about token counting in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)\nfunc (r *BetaMessageService) CountTokens(ctx context.Context, params BetaMessageCountTokensParams, opts ...option.RequestOption) (res *BetaMessageTokensCount, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\tpath := \"v1/messages/count_tokens?beta=true\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\nfunc NewBetaAllThinkingTurnsParam() BetaAllThinkingTurnsParam {\n\treturn BetaAllThinkingTurnsParam{\n\t\tType: \"all\",\n\t}\n}\n\n// This struct has a constant value, construct it with\n// [NewBetaAllThinkingTurnsParam].\ntype BetaAllThinkingTurnsParam struct {\n\tType constant.All `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaAllThinkingTurnsParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaAllThinkingTurnsParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaAllThinkingTurnsParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Data, MediaType, Type are required.\ntype BetaBase64ImageSourceParam struct {\n\tData string `json:\"data\" api:\"required\" format:\"byte\"`\n\t// Any of \"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\".\n\tMediaType BetaBase64ImageSourceMediaType `json:\"media_type,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"base64\".\n\tType constant.Base64 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaBase64ImageSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaBase64ImageSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaBase64ImageSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBase64ImageSourceMediaType string\n\nconst (\n\tBetaBase64ImageSourceMediaTypeImageJPEG BetaBase64ImageSourceMediaType = \"image/jpeg\"\n\tBetaBase64ImageSourceMediaTypeImagePNG  BetaBase64ImageSourceMediaType = \"image/png\"\n\tBetaBase64ImageSourceMediaTypeImageGIF  BetaBase64ImageSourceMediaType = \"image/gif\"\n\tBetaBase64ImageSourceMediaTypeImageWebP BetaBase64ImageSourceMediaType = \"image/webp\"\n)\n\ntype BetaBase64PDFSource struct {\n\tData      string                  `json:\"data\" api:\"required\" format:\"byte\"`\n\tMediaType constant.ApplicationPDF `json:\"media_type\" api:\"required\"`\n\tType      constant.Base64         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tMediaType   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaBase64PDFSource) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaBase64PDFSource) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this BetaBase64PDFSource to a BetaBase64PDFSourceParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// BetaBase64PDFSourceParam.Overrides()\nfunc (r BetaBase64PDFSource) ToParam() BetaBase64PDFSourceParam {\n\treturn param.Override[BetaBase64PDFSourceParam](json.RawMessage(r.RawJSON()))\n}\n\n// The properties Data, MediaType, Type are required.\ntype BetaBase64PDFSourceParam struct {\n\tData string `json:\"data\" api:\"required\" format:\"byte\"`\n\t// This field can be elided, and will marshal its zero value as \"application/pdf\".\n\tMediaType constant.ApplicationPDF `json:\"media_type\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"base64\".\n\tType constant.Base64 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaBase64PDFSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaBase64PDFSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaBase64PDFSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBashCodeExecutionOutputBlock struct {\n\tFileID string                           `json:\"file_id\" api:\"required\"`\n\tType   constant.BashCodeExecutionOutput `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tFileID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaBashCodeExecutionOutputBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaBashCodeExecutionOutputBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties FileID, Type are required.\ntype BetaBashCodeExecutionOutputBlockParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_output\".\n\tType constant.BashCodeExecutionOutput `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaBashCodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaBashCodeExecutionOutputBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaBashCodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBashCodeExecutionResultBlock struct {\n\tContent    []BetaBashCodeExecutionOutputBlock `json:\"content\" api:\"required\"`\n\tReturnCode int64                              `json:\"return_code\" api:\"required\"`\n\tStderr     string                             `json:\"stderr\" api:\"required\"`\n\tStdout     string                             `json:\"stdout\" api:\"required\"`\n\tType       constant.BashCodeExecutionResult   `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tReturnCode  respjson.Field\n\t\tStderr      respjson.Field\n\t\tStdout      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaBashCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaBashCodeExecutionResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ReturnCode, Stderr, Stdout, Type are required.\ntype BetaBashCodeExecutionResultBlockParam struct {\n\tContent    []BetaBashCodeExecutionOutputBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tReturnCode int64                                   `json:\"return_code\" api:\"required\"`\n\tStderr     string                                  `json:\"stderr\" api:\"required\"`\n\tStdout     string                                  `json:\"stdout\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_result\".\n\tType constant.BashCodeExecutionResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaBashCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaBashCodeExecutionResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaBashCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBashCodeExecutionToolResultBlock struct {\n\tContent   BetaBashCodeExecutionToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                           `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.BashCodeExecutionToolResult             `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaBashCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaBashCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaBashCodeExecutionToolResultBlockContentUnion contains all possible\n// properties and values from [BetaBashCodeExecutionToolResultError],\n// [BetaBashCodeExecutionResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaBashCodeExecutionToolResultBlockContentUnion struct {\n\t// This field is from variant [BetaBashCodeExecutionToolResultError].\n\tErrorCode BetaBashCodeExecutionToolResultErrorErrorCode `json:\"error_code\"`\n\tType      string                                        `json:\"type\"`\n\t// This field is from variant [BetaBashCodeExecutionResultBlock].\n\tContent []BetaBashCodeExecutionOutputBlock `json:\"content\"`\n\t// This field is from variant [BetaBashCodeExecutionResultBlock].\n\tReturnCode int64 `json:\"return_code\"`\n\t// This field is from variant [BetaBashCodeExecutionResultBlock].\n\tStderr string `json:\"stderr\"`\n\t// This field is from variant [BetaBashCodeExecutionResultBlock].\n\tStdout string `json:\"stdout\"`\n\tJSON   struct {\n\t\tErrorCode  respjson.Field\n\t\tType       respjson.Field\n\t\tContent    respjson.Field\n\t\tReturnCode respjson.Field\n\t\tStderr     respjson.Field\n\t\tStdout     respjson.Field\n\t\traw        string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaBashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError() (v BetaBashCodeExecutionToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaBashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock() (v BetaBashCodeExecutionResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaBashCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaBashCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BetaBashCodeExecutionToolResultBlockParam struct {\n\tContent   BetaBashCodeExecutionToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                                `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_tool_result\".\n\tType constant.BashCodeExecutionToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaBashCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaBashCodeExecutionToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaBashCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaBashCodeExecutionToolResultBlockParamContentUnion struct {\n\tOfRequestBashCodeExecutionToolResultError *BetaBashCodeExecutionToolResultErrorParam `json:\",omitzero,inline\"`\n\tOfRequestBashCodeExecutionResultBlock     *BetaBashCodeExecutionResultBlockParam     `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestBashCodeExecutionToolResultError, u.OfRequestBashCodeExecutionResultBlock)\n}\nfunc (u *BetaBashCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaBashCodeExecutionToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestBashCodeExecutionToolResultError) {\n\t\treturn u.OfRequestBashCodeExecutionToolResultError\n\t} else if !param.IsOmitted(u.OfRequestBashCodeExecutionResultBlock) {\n\t\treturn u.OfRequestBashCodeExecutionResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestBashCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) GetContent() []BetaBashCodeExecutionOutputBlockParam {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64 {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.ReturnCode\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) GetStderr() *string {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.Stderr\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) GetStdout() *string {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.Stdout\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaBashCodeExecutionToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestBashCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BetaBashCodeExecutionToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"output_file_too_large\".\n\tErrorCode BetaBashCodeExecutionToolResultErrorErrorCode `json:\"error_code\" api:\"required\"`\n\tType      constant.BashCodeExecutionToolResultError     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaBashCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaBashCodeExecutionToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBashCodeExecutionToolResultErrorErrorCode string\n\nconst (\n\tBetaBashCodeExecutionToolResultErrorErrorCodeInvalidToolInput      BetaBashCodeExecutionToolResultErrorErrorCode = \"invalid_tool_input\"\n\tBetaBashCodeExecutionToolResultErrorErrorCodeUnavailable           BetaBashCodeExecutionToolResultErrorErrorCode = \"unavailable\"\n\tBetaBashCodeExecutionToolResultErrorErrorCodeTooManyRequests       BetaBashCodeExecutionToolResultErrorErrorCode = \"too_many_requests\"\n\tBetaBashCodeExecutionToolResultErrorErrorCodeExecutionTimeExceeded BetaBashCodeExecutionToolResultErrorErrorCode = \"execution_time_exceeded\"\n\tBetaBashCodeExecutionToolResultErrorErrorCodeOutputFileTooLarge    BetaBashCodeExecutionToolResultErrorErrorCode = \"output_file_too_large\"\n)\n\n// The properties ErrorCode, Type are required.\ntype BetaBashCodeExecutionToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"output_file_too_large\".\n\tErrorCode BetaBashCodeExecutionToolResultErrorParamErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_tool_result_error\".\n\tType constant.BashCodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaBashCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaBashCodeExecutionToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaBashCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaBashCodeExecutionToolResultErrorParamErrorCode string\n\nconst (\n\tBetaBashCodeExecutionToolResultErrorParamErrorCodeInvalidToolInput      BetaBashCodeExecutionToolResultErrorParamErrorCode = \"invalid_tool_input\"\n\tBetaBashCodeExecutionToolResultErrorParamErrorCodeUnavailable           BetaBashCodeExecutionToolResultErrorParamErrorCode = \"unavailable\"\n\tBetaBashCodeExecutionToolResultErrorParamErrorCodeTooManyRequests       BetaBashCodeExecutionToolResultErrorParamErrorCode = \"too_many_requests\"\n\tBetaBashCodeExecutionToolResultErrorParamErrorCodeExecutionTimeExceeded BetaBashCodeExecutionToolResultErrorParamErrorCode = \"execution_time_exceeded\"\n\tBetaBashCodeExecutionToolResultErrorParamErrorCodeOutputFileTooLarge    BetaBashCodeExecutionToolResultErrorParamErrorCode = \"output_file_too_large\"\n)\n\nfunc NewBetaCacheControlEphemeralParam() BetaCacheControlEphemeralParam {\n\treturn BetaCacheControlEphemeralParam{\n\t\tType: \"ephemeral\",\n\t}\n}\n\n// This struct has a constant value, construct it with\n// [NewBetaCacheControlEphemeralParam].\ntype BetaCacheControlEphemeralParam struct {\n\t// The time-to-live for the cache control breakpoint.\n\t//\n\t// This may be one the following values:\n\t//\n\t// - `5m`: 5 minutes\n\t// - `1h`: 1 hour\n\t//\n\t// Defaults to `5m`.\n\t//\n\t// Any of \"5m\", \"1h\".\n\tTTL  BetaCacheControlEphemeralTTL `json:\"ttl,omitzero\"`\n\tType constant.Ephemeral           `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCacheControlEphemeralParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCacheControlEphemeralParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCacheControlEphemeralParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The time-to-live for the cache control breakpoint.\n//\n// This may be one the following values:\n//\n// - `5m`: 5 minutes\n// - `1h`: 1 hour\n//\n// Defaults to `5m`.\ntype BetaCacheControlEphemeralTTL string\n\nconst (\n\tBetaCacheControlEphemeralTTLTTL5m BetaCacheControlEphemeralTTL = \"5m\"\n\tBetaCacheControlEphemeralTTLTTL1h BetaCacheControlEphemeralTTL = \"1h\"\n)\n\ntype BetaCacheCreation struct {\n\t// The number of input tokens used to create the 1 hour cache entry.\n\tEphemeral1hInputTokens int64 `json:\"ephemeral_1h_input_tokens\" api:\"required\"`\n\t// The number of input tokens used to create the 5 minute cache entry.\n\tEphemeral5mInputTokens int64 `json:\"ephemeral_5m_input_tokens\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tEphemeral1hInputTokens respjson.Field\n\t\tEphemeral5mInputTokens respjson.Field\n\t\tExtraFields            map[string]respjson.Field\n\t\traw                    string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCacheCreation) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCacheCreation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationCharLocation struct {\n\tCitedText      string                `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex  int64                 `json:\"document_index\" api:\"required\"`\n\tDocumentTitle  string                `json:\"document_title\" api:\"required\"`\n\tEndCharIndex   int64                 `json:\"end_char_index\" api:\"required\"`\n\tFileID         string                `json:\"file_id\" api:\"required\"`\n\tStartCharIndex int64                 `json:\"start_char_index\" api:\"required\"`\n\tType           constant.CharLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText      respjson.Field\n\t\tDocumentIndex  respjson.Field\n\t\tDocumentTitle  respjson.Field\n\t\tEndCharIndex   respjson.Field\n\t\tFileID         respjson.Field\n\t\tStartCharIndex respjson.Field\n\t\tType           respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationCharLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationCharLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, DocumentIndex, DocumentTitle, EndCharIndex,\n// StartCharIndex, Type are required.\ntype BetaCitationCharLocationParam struct {\n\tDocumentTitle  param.Opt[string] `json:\"document_title,omitzero\" api:\"required\"`\n\tCitedText      string            `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex  int64             `json:\"document_index\" api:\"required\"`\n\tEndCharIndex   int64             `json:\"end_char_index\" api:\"required\"`\n\tStartCharIndex int64             `json:\"start_char_index\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"char_location\".\n\tType constant.CharLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCitationCharLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCitationCharLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCitationCharLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationConfig struct {\n\tEnabled bool `json:\"enabled\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tEnabled     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationConfig) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationConfig) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationContentBlockLocation struct {\n\tCitedText       string                        `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64                         `json:\"document_index\" api:\"required\"`\n\tDocumentTitle   string                        `json:\"document_title\" api:\"required\"`\n\tEndBlockIndex   int64                         `json:\"end_block_index\" api:\"required\"`\n\tFileID          string                        `json:\"file_id\" api:\"required\"`\n\tStartBlockIndex int64                         `json:\"start_block_index\" api:\"required\"`\n\tType            constant.ContentBlockLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText       respjson.Field\n\t\tDocumentIndex   respjson.Field\n\t\tDocumentTitle   respjson.Field\n\t\tEndBlockIndex   respjson.Field\n\t\tFileID          respjson.Field\n\t\tStartBlockIndex respjson.Field\n\t\tType            respjson.Field\n\t\tExtraFields     map[string]respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationContentBlockLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationContentBlockLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, DocumentIndex, DocumentTitle, EndBlockIndex,\n// StartBlockIndex, Type are required.\ntype BetaCitationContentBlockLocationParam struct {\n\tDocumentTitle   param.Opt[string] `json:\"document_title,omitzero\" api:\"required\"`\n\tCitedText       string            `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64             `json:\"document_index\" api:\"required\"`\n\tEndBlockIndex   int64             `json:\"end_block_index\" api:\"required\"`\n\tStartBlockIndex int64             `json:\"start_block_index\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"content_block_location\".\n\tType constant.ContentBlockLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCitationContentBlockLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCitationContentBlockLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCitationContentBlockLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationPageLocation struct {\n\tCitedText       string                `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64                 `json:\"document_index\" api:\"required\"`\n\tDocumentTitle   string                `json:\"document_title\" api:\"required\"`\n\tEndPageNumber   int64                 `json:\"end_page_number\" api:\"required\"`\n\tFileID          string                `json:\"file_id\" api:\"required\"`\n\tStartPageNumber int64                 `json:\"start_page_number\" api:\"required\"`\n\tType            constant.PageLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText       respjson.Field\n\t\tDocumentIndex   respjson.Field\n\t\tDocumentTitle   respjson.Field\n\t\tEndPageNumber   respjson.Field\n\t\tFileID          respjson.Field\n\t\tStartPageNumber respjson.Field\n\t\tType            respjson.Field\n\t\tExtraFields     map[string]respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationPageLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationPageLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, DocumentIndex, DocumentTitle, EndPageNumber,\n// StartPageNumber, Type are required.\ntype BetaCitationPageLocationParam struct {\n\tDocumentTitle   param.Opt[string] `json:\"document_title,omitzero\" api:\"required\"`\n\tCitedText       string            `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64             `json:\"document_index\" api:\"required\"`\n\tEndPageNumber   int64             `json:\"end_page_number\" api:\"required\"`\n\tStartPageNumber int64             `json:\"start_page_number\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"page_location\".\n\tType constant.PageLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCitationPageLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCitationPageLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCitationPageLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationSearchResultLocation struct {\n\tCitedText         string                        `json:\"cited_text\" api:\"required\"`\n\tEndBlockIndex     int64                         `json:\"end_block_index\" api:\"required\"`\n\tSearchResultIndex int64                         `json:\"search_result_index\" api:\"required\"`\n\tSource            string                        `json:\"source\" api:\"required\"`\n\tStartBlockIndex   int64                         `json:\"start_block_index\" api:\"required\"`\n\tTitle             string                        `json:\"title\" api:\"required\"`\n\tType              constant.SearchResultLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText         respjson.Field\n\t\tEndBlockIndex     respjson.Field\n\t\tSearchResultIndex respjson.Field\n\t\tSource            respjson.Field\n\t\tStartBlockIndex   respjson.Field\n\t\tTitle             respjson.Field\n\t\tType              respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationSearchResultLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationSearchResultLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, EndBlockIndex, SearchResultIndex, Source,\n// StartBlockIndex, Title, Type are required.\ntype BetaCitationSearchResultLocationParam struct {\n\tTitle             param.Opt[string] `json:\"title,omitzero\" api:\"required\"`\n\tCitedText         string            `json:\"cited_text\" api:\"required\"`\n\tEndBlockIndex     int64             `json:\"end_block_index\" api:\"required\"`\n\tSearchResultIndex int64             `json:\"search_result_index\" api:\"required\"`\n\tSource            string            `json:\"source\" api:\"required\"`\n\tStartBlockIndex   int64             `json:\"start_block_index\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"search_result_location\".\n\tType constant.SearchResultLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCitationSearchResultLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCitationSearchResultLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCitationSearchResultLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, EncryptedIndex, Title, Type, URL are required.\ntype BetaCitationWebSearchResultLocationParam struct {\n\tTitle          param.Opt[string] `json:\"title,omitzero\" api:\"required\"`\n\tCitedText      string            `json:\"cited_text\" api:\"required\"`\n\tEncryptedIndex string            `json:\"encrypted_index\" api:\"required\"`\n\tURL            string            `json:\"url\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_result_location\".\n\tType constant.WebSearchResultLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCitationWebSearchResultLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCitationWebSearchResultLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCitationWebSearchResultLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationsConfigParam struct {\n\tEnabled param.Opt[bool] `json:\"enabled,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaCitationsConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCitationsConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCitationsConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationsDelta struct {\n\tCitation BetaCitationsDeltaCitationUnion `json:\"citation\" api:\"required\"`\n\tType     constant.CitationsDelta         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitation    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationsDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationsDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaCitationsDeltaCitationUnion contains all possible properties and values from\n// [BetaCitationCharLocation], [BetaCitationPageLocation],\n// [BetaCitationContentBlockLocation], [BetaCitationsWebSearchResultLocation],\n// [BetaCitationSearchResultLocation].\n//\n// Use the [BetaCitationsDeltaCitationUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaCitationsDeltaCitationUnion struct {\n\tCitedText     string `json:\"cited_text\"`\n\tDocumentIndex int64  `json:\"document_index\"`\n\tDocumentTitle string `json:\"document_title\"`\n\t// This field is from variant [BetaCitationCharLocation].\n\tEndCharIndex int64  `json:\"end_char_index\"`\n\tFileID       string `json:\"file_id\"`\n\t// This field is from variant [BetaCitationCharLocation].\n\tStartCharIndex int64 `json:\"start_char_index\"`\n\t// Any of \"char_location\", \"page_location\", \"content_block_location\",\n\t// \"web_search_result_location\", \"search_result_location\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaCitationPageLocation].\n\tEndPageNumber int64 `json:\"end_page_number\"`\n\t// This field is from variant [BetaCitationPageLocation].\n\tStartPageNumber int64 `json:\"start_page_number\"`\n\tEndBlockIndex   int64 `json:\"end_block_index\"`\n\tStartBlockIndex int64 `json:\"start_block_index\"`\n\t// This field is from variant [BetaCitationsWebSearchResultLocation].\n\tEncryptedIndex string `json:\"encrypted_index\"`\n\tTitle          string `json:\"title\"`\n\t// This field is from variant [BetaCitationsWebSearchResultLocation].\n\tURL string `json:\"url\"`\n\t// This field is from variant [BetaCitationSearchResultLocation].\n\tSearchResultIndex int64 `json:\"search_result_index\"`\n\t// This field is from variant [BetaCitationSearchResultLocation].\n\tSource string `json:\"source\"`\n\tJSON   struct {\n\t\tCitedText         respjson.Field\n\t\tDocumentIndex     respjson.Field\n\t\tDocumentTitle     respjson.Field\n\t\tEndCharIndex      respjson.Field\n\t\tFileID            respjson.Field\n\t\tStartCharIndex    respjson.Field\n\t\tType              respjson.Field\n\t\tEndPageNumber     respjson.Field\n\t\tStartPageNumber   respjson.Field\n\t\tEndBlockIndex     respjson.Field\n\t\tStartBlockIndex   respjson.Field\n\t\tEncryptedIndex    respjson.Field\n\t\tTitle             respjson.Field\n\t\tURL               respjson.Field\n\t\tSearchResultIndex respjson.Field\n\t\tSource            respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// anyBetaCitationsDeltaCitation is implemented by each variant of\n// [BetaCitationsDeltaCitationUnion] to add type safety for the return type of\n// [BetaCitationsDeltaCitationUnion.AsAny]\ntype anyBetaCitationsDeltaCitation interface {\n\timplBetaCitationsDeltaCitationUnion()\n}\n\nfunc (BetaCitationCharLocation) implBetaCitationsDeltaCitationUnion()             {}\nfunc (BetaCitationPageLocation) implBetaCitationsDeltaCitationUnion()             {}\nfunc (BetaCitationContentBlockLocation) implBetaCitationsDeltaCitationUnion()     {}\nfunc (BetaCitationsWebSearchResultLocation) implBetaCitationsDeltaCitationUnion() {}\nfunc (BetaCitationSearchResultLocation) implBetaCitationsDeltaCitationUnion()     {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaCitationsDeltaCitationUnion.AsAny().(type) {\n//\tcase anthropic.BetaCitationCharLocation:\n//\tcase anthropic.BetaCitationPageLocation:\n//\tcase anthropic.BetaCitationContentBlockLocation:\n//\tcase anthropic.BetaCitationsWebSearchResultLocation:\n//\tcase anthropic.BetaCitationSearchResultLocation:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaCitationsDeltaCitationUnion) AsAny() anyBetaCitationsDeltaCitation {\n\tswitch u.Type {\n\tcase \"char_location\":\n\t\treturn u.AsCharLocation()\n\tcase \"page_location\":\n\t\treturn u.AsPageLocation()\n\tcase \"content_block_location\":\n\t\treturn u.AsContentBlockLocation()\n\tcase \"web_search_result_location\":\n\t\treturn u.AsWebSearchResultLocation()\n\tcase \"search_result_location\":\n\t\treturn u.AsSearchResultLocation()\n\t}\n\treturn nil\n}\n\nfunc (u BetaCitationsDeltaCitationUnion) AsCharLocation() (v BetaCitationCharLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaCitationsDeltaCitationUnion) AsPageLocation() (v BetaCitationPageLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaCitationsDeltaCitationUnion) AsContentBlockLocation() (v BetaCitationContentBlockLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaCitationsDeltaCitationUnion) AsWebSearchResultLocation() (v BetaCitationsWebSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaCitationsDeltaCitationUnion) AsSearchResultLocation() (v BetaCitationSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaCitationsDeltaCitationUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaCitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCitationsWebSearchResultLocation struct {\n\tCitedText      string                           `json:\"cited_text\" api:\"required\"`\n\tEncryptedIndex string                           `json:\"encrypted_index\" api:\"required\"`\n\tTitle          string                           `json:\"title\" api:\"required\"`\n\tType           constant.WebSearchResultLocation `json:\"type\" api:\"required\"`\n\tURL            string                           `json:\"url\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText      respjson.Field\n\t\tEncryptedIndex respjson.Field\n\t\tTitle          respjson.Field\n\t\tType           respjson.Field\n\t\tURL            respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCitationsWebSearchResultLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCitationsWebSearchResultLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The property Type is required.\ntype BetaClearThinking20251015EditParam struct {\n\t// Number of most recent assistant turns to keep thinking blocks for. Older turns\n\t// will have their thinking blocks removed.\n\tKeep BetaClearThinking20251015EditKeepUnionParam `json:\"keep,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"clear_thinking_20251015\".\n\tType constant.ClearThinking20251015 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaClearThinking20251015EditParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaClearThinking20251015EditParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaClearThinking20251015EditParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaClearThinking20251015EditKeepUnionParam struct {\n\tOfThinkingTurns    *BetaThinkingTurnsParam    `json:\",omitzero,inline\"`\n\tOfAllThinkingTurns *BetaAllThinkingTurnsParam `json:\",omitzero,inline\"`\n\t// Construct this variant with constant.ValueOf[constant.All]()\n\tOfAll constant.All `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaClearThinking20251015EditKeepUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfThinkingTurns, u.OfAllThinkingTurns, u.OfAll)\n}\nfunc (u *BetaClearThinking20251015EditKeepUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaClearThinking20251015EditKeepUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfThinkingTurns) {\n\t\treturn u.OfThinkingTurns\n\t} else if !param.IsOmitted(u.OfAllThinkingTurns) {\n\t\treturn u.OfAllThinkingTurns\n\t} else if !param.IsOmitted(u.OfAll) {\n\t\treturn &u.OfAll\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaClearThinking20251015EditKeepUnionParam) GetValue() *int64 {\n\tif vt := u.OfThinkingTurns; vt != nil {\n\t\treturn &vt.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaClearThinking20251015EditKeepUnionParam) GetType() *string {\n\tif vt := u.OfThinkingTurns; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfAllThinkingTurns; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BetaClearThinking20251015EditResponse struct {\n\t// Number of input tokens cleared by this edit.\n\tClearedInputTokens int64 `json:\"cleared_input_tokens\" api:\"required\"`\n\t// Number of thinking turns that were cleared.\n\tClearedThinkingTurns int64 `json:\"cleared_thinking_turns\" api:\"required\"`\n\t// The type of context management edit applied.\n\tType constant.ClearThinking20251015 `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tClearedInputTokens   respjson.Field\n\t\tClearedThinkingTurns respjson.Field\n\t\tType                 respjson.Field\n\t\tExtraFields          map[string]respjson.Field\n\t\traw                  string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaClearThinking20251015EditResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaClearThinking20251015EditResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The property Type is required.\ntype BetaClearToolUses20250919EditParam struct {\n\t// Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)\n\tClearToolInputs BetaClearToolUses20250919EditClearToolInputsUnionParam `json:\"clear_tool_inputs,omitzero\"`\n\t// Tool names whose uses are preserved from clearing\n\tExcludeTools []string `json:\"exclude_tools,omitzero\"`\n\t// Minimum number of tokens that must be cleared when triggered. Context will only\n\t// be modified if at least this many tokens can be removed.\n\tClearAtLeast BetaInputTokensClearAtLeastParam `json:\"clear_at_least,omitzero\"`\n\t// Number of tool uses to retain in the conversation\n\tKeep BetaToolUsesKeepParam `json:\"keep,omitzero\"`\n\t// Condition that triggers the context management strategy\n\tTrigger BetaClearToolUses20250919EditTriggerUnionParam `json:\"trigger,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"clear_tool_uses_20250919\".\n\tType constant.ClearToolUses20250919 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaClearToolUses20250919EditParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaClearToolUses20250919EditParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaClearToolUses20250919EditParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaClearToolUses20250919EditClearToolInputsUnionParam struct {\n\tOfBool        param.Opt[bool] `json:\",omitzero,inline\"`\n\tOfStringArray []string        `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaClearToolUses20250919EditClearToolInputsUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfBool, u.OfStringArray)\n}\nfunc (u *BetaClearToolUses20250919EditClearToolInputsUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaClearToolUses20250919EditClearToolInputsUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfBool) {\n\t\treturn &u.OfBool.Value\n\t} else if !param.IsOmitted(u.OfStringArray) {\n\t\treturn &u.OfStringArray\n\t}\n\treturn nil\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaClearToolUses20250919EditTriggerUnionParam struct {\n\tOfInputTokens *BetaInputTokensTriggerParam `json:\",omitzero,inline\"`\n\tOfToolUses    *BetaToolUsesTriggerParam    `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaClearToolUses20250919EditTriggerUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfInputTokens, u.OfToolUses)\n}\nfunc (u *BetaClearToolUses20250919EditTriggerUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaClearToolUses20250919EditTriggerUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfInputTokens) {\n\t\treturn u.OfInputTokens\n\t} else if !param.IsOmitted(u.OfToolUses) {\n\t\treturn u.OfToolUses\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaClearToolUses20250919EditTriggerUnionParam) GetType() *string {\n\tif vt := u.OfInputTokens; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolUses; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaClearToolUses20250919EditTriggerUnionParam) GetValue() *int64 {\n\tif vt := u.OfInputTokens; vt != nil {\n\t\treturn (*int64)(&vt.Value)\n\t} else if vt := u.OfToolUses; vt != nil {\n\t\treturn (*int64)(&vt.Value)\n\t}\n\treturn nil\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaClearToolUses20250919EditTriggerUnionParam](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaInputTokensTriggerParam](\"input_tokens\"),\n\t\tapijson.Discriminator[BetaToolUsesTriggerParam](\"tool_uses\"),\n\t)\n}\n\n\nfunc init() {\n\tapijson.RegisterUnion[BetaContentBlockParamUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaTextBlockParam](\"text\"),\n\t\tapijson.Discriminator[BetaImageBlockParam](\"image\"),\n\t\tapijson.Discriminator[BetaRequestDocumentBlockParam](\"document\"),\n\t\tapijson.Discriminator[BetaSearchResultBlockParam](\"search_result\"),\n\t\tapijson.Discriminator[BetaThinkingBlockParam](\"thinking\"),\n\t\tapijson.Discriminator[BetaRedactedThinkingBlockParam](\"redacted_thinking\"),\n\t\tapijson.Discriminator[BetaToolUseBlockParam](\"tool_use\"),\n\t\tapijson.Discriminator[BetaToolResultBlockParam](\"tool_result\"),\n\t\tapijson.Discriminator[BetaServerToolUseBlockParam](\"server_tool_use\"),\n\t\tapijson.Discriminator[BetaWebSearchToolResultBlockParam](\"web_search_tool_result\"),\n\t\tapijson.Discriminator[BetaWebFetchToolResultBlockParam](\"web_fetch_tool_result\"),\n\t\tapijson.Discriminator[BetaCodeExecutionToolResultBlockParam](\"code_execution_tool_result\"),\n\t\tapijson.Discriminator[BetaBashCodeExecutionToolResultBlockParam](\"bash_code_execution_tool_result\"),\n\t\tapijson.Discriminator[BetaTextEditorCodeExecutionToolResultBlockParam](\"text_editor_code_execution_tool_result\"),\n\t\tapijson.Discriminator[BetaToolSearchToolResultBlockParam](\"tool_search_tool_result\"),\n\t\tapijson.Discriminator[BetaMCPToolUseBlockParam](\"mcp_tool_use\"),\n\t\tapijson.Discriminator[BetaRequestMCPToolResultBlockParam](\"mcp_tool_result\"),\n\t\tapijson.Discriminator[BetaContainerUploadBlockParam](\"container_upload\"),\n\t\tapijson.Discriminator[BetaCompactionBlockParam](\"compaction\"),\n\t)\n}\n\n\nfunc init() {\n\tapijson.RegisterUnion[BetaContextManagementConfigEditUnionParam](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaClearToolUses20250919EditParam](\"clear_tool_uses_20250919\"),\n\t\tapijson.Discriminator[BetaClearThinking20251015EditParam](\"clear_thinking_20251015\"),\n\t\tapijson.Discriminator[BetaCompact20260112EditParam](\"compact_20260112\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaImageBlockParamSourceUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaBase64ImageSourceParam](\"base64\"),\n\t\tapijson.Discriminator[BetaURLImageSourceParam](\"url\"),\n\t\tapijson.Discriminator[BetaFileImageSourceParam](\"file\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaRequestDocumentBlockSourceUnionParam](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaBase64PDFSourceParam](\"base64\"),\n\t\tapijson.Discriminator[BetaPlainTextSourceParam](\"text\"),\n\t\tapijson.Discriminator[BetaContentBlockSourceParam](\"content\"),\n\t\tapijson.Discriminator[BetaURLPDFSourceParam](\"url\"),\n\t\tapijson.Discriminator[BetaFileDocumentSourceParam](\"file\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaServerToolUseBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaDirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[BetaServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[BetaServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaTextCitationParamUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaCitationCharLocationParam](\"char_location\"),\n\t\tapijson.Discriminator[BetaCitationPageLocationParam](\"page_location\"),\n\t\tapijson.Discriminator[BetaCitationContentBlockLocationParam](\"content_block_location\"),\n\t\tapijson.Discriminator[BetaCitationWebSearchResultLocationParam](\"web_search_result_location\"),\n\t\tapijson.Discriminator[BetaCitationSearchResultLocationParam](\"search_result_location\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaThinkingConfigParamUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaThinkingConfigEnabledParam](\"enabled\"),\n\t\tapijson.Discriminator[BetaThinkingConfigDisabledParam](\"disabled\"),\n\t\tapijson.Discriminator[BetaThinkingConfigAdaptiveParam](\"adaptive\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaToolChoiceUnionParam](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaToolChoiceAutoParam](\"auto\"),\n\t\tapijson.Discriminator[BetaToolChoiceAnyParam](\"any\"),\n\t\tapijson.Discriminator[BetaToolChoiceToolParam](\"tool\"),\n\t\tapijson.Discriminator[BetaToolChoiceNoneParam](\"none\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaToolResultBlockParamContentUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaTextBlockParam](\"text\"),\n\t\tapijson.Discriminator[BetaImageBlockParam](\"image\"),\n\t\tapijson.Discriminator[BetaSearchResultBlockParam](\"search_result\"),\n\t\tapijson.Discriminator[BetaRequestDocumentBlockParam](\"document\"),\n\t\tapijson.Discriminator[BetaToolReferenceBlockParam](\"tool_reference\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaToolUseBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaDirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[BetaServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[BetaServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaWebFetchToolResultBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaDirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[BetaServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[BetaServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[BetaWebSearchToolResultBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[BetaDirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[BetaServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[BetaServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\ntype BetaClearToolUses20250919EditResponse struct {\n\t// Number of input tokens cleared by this edit.\n\tClearedInputTokens int64 `json:\"cleared_input_tokens\" api:\"required\"`\n\t// Number of tool uses that were cleared.\n\tClearedToolUses int64 `json:\"cleared_tool_uses\" api:\"required\"`\n\t// The type of context management edit applied.\n\tType constant.ClearToolUses20250919 `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tClearedInputTokens respjson.Field\n\t\tClearedToolUses    respjson.Field\n\t\tType               respjson.Field\n\t\tExtraFields        map[string]respjson.Field\n\t\traw                string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaClearToolUses20250919EditResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaClearToolUses20250919EditResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCodeExecutionOutputBlock struct {\n\tFileID string                       `json:\"file_id\" api:\"required\"`\n\tType   constant.CodeExecutionOutput `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tFileID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCodeExecutionOutputBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCodeExecutionOutputBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties FileID, Type are required.\ntype BetaCodeExecutionOutputBlockParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_output\".\n\tType constant.CodeExecutionOutput `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionOutputBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCodeExecutionResultBlock struct {\n\tContent    []BetaCodeExecutionOutputBlock `json:\"content\" api:\"required\"`\n\tReturnCode int64                          `json:\"return_code\" api:\"required\"`\n\tStderr     string                         `json:\"stderr\" api:\"required\"`\n\tStdout     string                         `json:\"stdout\" api:\"required\"`\n\tType       constant.CodeExecutionResult   `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tReturnCode  respjson.Field\n\t\tStderr      respjson.Field\n\t\tStdout      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCodeExecutionResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ReturnCode, Stderr, Stdout, Type are required.\ntype BetaCodeExecutionResultBlockParam struct {\n\tContent    []BetaCodeExecutionOutputBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tReturnCode int64                               `json:\"return_code\" api:\"required\"`\n\tStderr     string                              `json:\"stderr\" api:\"required\"`\n\tStdout     string                              `json:\"stdout\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_result\".\n\tType constant.CodeExecutionResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaCodeExecutionTool20250522Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"code_execution\".\n\tName constant.CodeExecution `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20250522\".\n\tType constant.CodeExecution20250522 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionTool20250522Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionTool20250522Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionTool20250522Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaCodeExecutionTool20250825Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"code_execution\".\n\tName constant.CodeExecution `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20250825\".\n\tType constant.CodeExecution20250825 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionTool20250825Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionTool20250825Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionTool20250825Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Code execution tool with REPL state persistence (daemon mode + gVisor\n// checkpoint).\n//\n// The properties Name, Type are required.\ntype BetaCodeExecutionTool20260120Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"code_execution\".\n\tName constant.CodeExecution `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20260120\".\n\tType constant.CodeExecution20260120 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionTool20260120Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionTool20260120Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionTool20260120Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCodeExecutionToolResultBlock struct {\n\t// Code execution result with encrypted stdout for PFC + web_search results.\n\tContent   BetaCodeExecutionToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                       `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.CodeExecutionToolResult             `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaCodeExecutionToolResultBlockContentUnion contains all possible properties\n// and values from [BetaCodeExecutionToolResultError],\n// [BetaCodeExecutionResultBlock], [BetaEncryptedCodeExecutionResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaCodeExecutionToolResultBlockContentUnion struct {\n\t// This field is from variant [BetaCodeExecutionToolResultError].\n\tErrorCode  BetaCodeExecutionToolResultErrorCode `json:\"error_code\"`\n\tType       string                               `json:\"type\"`\n\tContent    []BetaCodeExecutionOutputBlock       `json:\"content\"`\n\tReturnCode int64                                `json:\"return_code\"`\n\tStderr     string                               `json:\"stderr\"`\n\t// This field is from variant [BetaCodeExecutionResultBlock].\n\tStdout string `json:\"stdout\"`\n\t// This field is from variant [BetaEncryptedCodeExecutionResultBlock].\n\tEncryptedStdout string `json:\"encrypted_stdout\"`\n\tJSON            struct {\n\t\tErrorCode       respjson.Field\n\t\tType            respjson.Field\n\t\tContent         respjson.Field\n\t\tReturnCode      respjson.Field\n\t\tStderr          respjson.Field\n\t\tStdout          respjson.Field\n\t\tEncryptedStdout respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v BetaCodeExecutionToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v BetaCodeExecutionResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock() (v BetaEncryptedCodeExecutionResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BetaCodeExecutionToolResultBlockParam struct {\n\t// Code execution result with encrypted stdout for PFC + web_search results.\n\tContent   BetaCodeExecutionToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                            `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_tool_result\".\n\tType constant.CodeExecutionToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc BetaNewCodeExecutionToolRequestError(errorCode BetaCodeExecutionToolResultErrorCode) BetaCodeExecutionToolResultBlockParamContentUnion {\n\tvar variant BetaCodeExecutionToolResultErrorParam\n\tvariant.ErrorCode = errorCode\n\treturn BetaCodeExecutionToolResultBlockParamContentUnion{OfError: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaCodeExecutionToolResultBlockParamContentUnion struct {\n\tOfError                                    *BetaCodeExecutionToolResultErrorParam      `json:\",omitzero,inline\"`\n\tOfResultBlock                              *BetaCodeExecutionResultBlockParam          `json:\",omitzero,inline\"`\n\tOfRequestEncryptedCodeExecutionResultBlock *BetaEncryptedCodeExecutionResultBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfError, u.OfResultBlock, u.OfRequestEncryptedCodeExecutionResultBlock)\n}\nfunc (u *BetaCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaCodeExecutionToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfError) {\n\t\treturn u.OfError\n\t} else if !param.IsOmitted(u.OfResultBlock) {\n\t\treturn u.OfResultBlock\n\t} else if !param.IsOmitted(u.OfRequestEncryptedCodeExecutionResultBlock) {\n\t\treturn u.OfRequestEncryptedCodeExecutionResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetStdout() *string {\n\tif vt := u.OfResultBlock; vt != nil {\n\t\treturn &vt.Stdout\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetEncryptedStdout() *string {\n\tif vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.EncryptedStdout\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64 {\n\tif vt := u.OfResultBlock; vt != nil {\n\t\treturn (*int64)(&vt.ReturnCode)\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn (*int64)(&vt.ReturnCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetStderr() *string {\n\tif vt := u.OfResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Stderr)\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Stderr)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's Content property, if present.\nfunc (u BetaCodeExecutionToolResultBlockParamContentUnion) GetContent() []BetaCodeExecutionOutputBlockParam {\n\tif vt := u.OfResultBlock; vt != nil {\n\t\treturn vt.Content\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn vt.Content\n\t}\n\treturn nil\n}\n\ntype BetaCodeExecutionToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode BetaCodeExecutionToolResultErrorCode  `json:\"error_code\" api:\"required\"`\n\tType      constant.CodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCodeExecutionToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCodeExecutionToolResultErrorCode string\n\nconst (\n\tBetaCodeExecutionToolResultErrorCodeInvalidToolInput      BetaCodeExecutionToolResultErrorCode = \"invalid_tool_input\"\n\tBetaCodeExecutionToolResultErrorCodeUnavailable           BetaCodeExecutionToolResultErrorCode = \"unavailable\"\n\tBetaCodeExecutionToolResultErrorCodeTooManyRequests       BetaCodeExecutionToolResultErrorCode = \"too_many_requests\"\n\tBetaCodeExecutionToolResultErrorCodeExecutionTimeExceeded BetaCodeExecutionToolResultErrorCode = \"execution_time_exceeded\"\n)\n\n// The properties ErrorCode, Type are required.\ntype BetaCodeExecutionToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode BetaCodeExecutionToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_tool_result_error\".\n\tType constant.CodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCodeExecutionToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Automatically compact older context when reaching the configured trigger\n// threshold.\n//\n// The property Type is required.\ntype BetaCompact20260112EditParam struct {\n\t// Additional instructions for summarization.\n\tInstructions param.Opt[string] `json:\"instructions,omitzero\"`\n\t// Whether to pause after compaction and return the compaction block to the user.\n\tPauseAfterCompaction param.Opt[bool] `json:\"pause_after_compaction,omitzero\"`\n\t// When to trigger compaction. Defaults to 150000 input tokens.\n\tTrigger BetaInputTokensTriggerParam `json:\"trigger,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"compact_20260112\".\n\tType constant.Compact20260112 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCompact20260112EditParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCompact20260112EditParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCompact20260112EditParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// A compaction block returned when autocompact is triggered.\n//\n// When content is None, it indicates the compaction failed to produce a valid\n// summary (e.g., malformed output from the model). Clients may round-trip\n// compaction blocks with null content; the server treats them as no-ops.\ntype BetaCompactionBlock struct {\n\t// Summary of compacted content, or null if compaction failed\n\tContent string              `json:\"content\" api:\"required\"`\n\tType    constant.Compaction `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCompactionBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCompactionBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// A compaction block containing summary of previous context.\n//\n// Users should round-trip these blocks from responses to subsequent requests to\n// maintain context across compaction boundaries.\n//\n// When content is None, the block represents a failed compaction. The server\n// treats these as no-ops. Empty string content is not allowed.\n//\n// The properties Content, Type are required.\ntype BetaCompactionBlockParam struct {\n\t// Summary of previously compacted content, or null if compaction failed\n\tContent param.Opt[string] `json:\"content,omitzero\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"compaction\".\n\tType constant.Compaction `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaCompactionBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaCompactionBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaCompactionBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCompactionContentBlockDelta struct {\n\tContent string                   `json:\"content\" api:\"required\"`\n\tType    constant.CompactionDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCompactionContentBlockDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCompactionContentBlockDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Token usage for a compaction iteration.\ntype BetaCompactionIterationUsage struct {\n\t// Breakdown of cached tokens by TTL\n\tCacheCreation BetaCacheCreation `json:\"cache_creation\" api:\"required\"`\n\t// The number of input tokens used to create the cache entry.\n\tCacheCreationInputTokens int64 `json:\"cache_creation_input_tokens\" api:\"required\"`\n\t// The number of input tokens read from the cache.\n\tCacheReadInputTokens int64 `json:\"cache_read_input_tokens\" api:\"required\"`\n\t// The number of input tokens which were used.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// The number of output tokens which were used.\n\tOutputTokens int64 `json:\"output_tokens\" api:\"required\"`\n\t// Usage for a compaction iteration\n\tType constant.Compaction `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCacheCreation            respjson.Field\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tType                     respjson.Field\n\t\tExtraFields              map[string]respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCompactionIterationUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCompactionIterationUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Information about the container used in the request (for the code execution\n// tool)\ntype BetaContainer struct {\n\t// Identifier for the container used in this request\n\tID string `json:\"id\" api:\"required\"`\n\t// The time at which the container will expire.\n\tExpiresAt time.Time `json:\"expires_at\" api:\"required\" format:\"date-time\"`\n\t// Skills loaded in the container\n\tSkills []BetaSkill `json:\"skills\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tExpiresAt   respjson.Field\n\t\tSkills      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaContainer) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaContainer) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Container parameters with skills to be loaded.\ntype BetaContainerParams struct {\n\t// Container id\n\tID param.Opt[string] `json:\"id,omitzero\"`\n\t// List of skills to load in the container\n\tSkills []BetaSkillParams `json:\"skills,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaContainerParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaContainerParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaContainerParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Response model for a file uploaded to the container.\ntype BetaContainerUploadBlock struct {\n\tFileID string                   `json:\"file_id\" api:\"required\"`\n\tType   constant.ContainerUpload `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tFileID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaContainerUploadBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaContainerUploadBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// A content block that represents a file to be uploaded to the container Files\n// uploaded via this block will be available in the container's input directory.\n//\n// The properties FileID, Type are required.\ntype BetaContainerUploadBlockParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"container_upload\".\n\tType constant.ContainerUpload `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaContainerUploadBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaContainerUploadBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaContainerUploadBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaContentBlockUnion contains all possible properties and values from\n// [BetaTextBlock], [BetaThinkingBlock], [BetaRedactedThinkingBlock],\n// [BetaToolUseBlock], [BetaServerToolUseBlock], [BetaWebSearchToolResultBlock],\n// [BetaWebFetchToolResultBlock], [BetaCodeExecutionToolResultBlock],\n// [BetaBashCodeExecutionToolResultBlock],\n// [BetaTextEditorCodeExecutionToolResultBlock], [BetaToolSearchToolResultBlock],\n// [BetaMCPToolUseBlock], [BetaMCPToolResultBlock], [BetaContainerUploadBlock],\n// [BetaCompactionBlock].\n//\n// Use the [BetaContentBlockUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaContentBlockUnion struct {\n\t// This field is from variant [BetaTextBlock].\n\tCitations []BetaTextCitationUnion `json:\"citations\"`\n\t// This field is from variant [BetaTextBlock].\n\tText string `json:\"text\"`\n\t// Any of \"text\", \"thinking\", \"redacted_thinking\", \"tool_use\", \"server_tool_use\",\n\t// \"web_search_tool_result\", \"web_fetch_tool_result\", \"code_execution_tool_result\",\n\t// \"bash_code_execution_tool_result\", \"text_editor_code_execution_tool_result\",\n\t// \"tool_search_tool_result\", \"mcp_tool_use\", \"mcp_tool_result\",\n\t// \"container_upload\", \"compaction\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaThinkingBlock].\n\tSignature string `json:\"signature\"`\n\t// This field is from variant [BetaThinkingBlock].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [BetaRedactedThinkingBlock].\n\tData string `json:\"data\"`\n\tID   string `json:\"id\"`\n\t// necessary custom code modification\n\tInput json.RawMessage `json:\"input\"`\n\tName  string          `json:\"name\"`\n\t// This field is a union of [BetaToolUseBlockCallerUnion],\n\t// [BetaServerToolUseBlockCallerUnion], [BetaWebSearchToolResultBlockCallerUnion],\n\t// [BetaWebFetchToolResultBlockCallerUnion]\n\tCaller BetaContentBlockUnionCaller `json:\"caller\"`\n\t// This field is a union of [BetaWebSearchToolResultBlockContentUnion],\n\t// [BetaWebFetchToolResultBlockContentUnion],\n\t// [BetaCodeExecutionToolResultBlockContentUnion],\n\t// [BetaBashCodeExecutionToolResultBlockContentUnion],\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion],\n\t// [BetaToolSearchToolResultBlockContentUnion],\n\t// [BetaMCPToolResultBlockContentUnion], [string]\n\tContent   BetaContentBlockUnionContent `json:\"content\"`\n\tToolUseID string                       `json:\"tool_use_id\"`\n\t// This field is from variant [BetaMCPToolUseBlock].\n\tServerName string `json:\"server_name\"`\n\t// This field is from variant [BetaMCPToolResultBlock].\n\tIsError bool `json:\"is_error\"`\n\t// This field is from variant [BetaContainerUploadBlock].\n\tFileID string `json:\"file_id\"`\n\tJSON   struct {\n\t\tCitations  respjson.Field\n\t\tText       respjson.Field\n\t\tType       respjson.Field\n\t\tSignature  respjson.Field\n\t\tThinking   respjson.Field\n\t\tData       respjson.Field\n\t\tID         respjson.Field\n\t\tInput      respjson.Field\n\t\tName       respjson.Field\n\t\tCaller     respjson.Field\n\t\tContent    respjson.Field\n\t\tToolUseID  respjson.Field\n\t\tServerName respjson.Field\n\t\tIsError    respjson.Field\n\t\tFileID     respjson.Field\n\t\traw        string\n\t} `json:\"-\"`\n}\n\n// anyBetaContentBlock is implemented by each variant of [BetaContentBlockUnion] to\n// add type safety for the return type of [BetaContentBlockUnion.AsAny]\ntype anyBetaContentBlock interface {\n\timplBetaContentBlockUnion()\n\ttoParamUnion() BetaContentBlockParamUnion\n}\n\nfunc (BetaTextBlock) implBetaContentBlockUnion()                              {}\nfunc (BetaThinkingBlock) implBetaContentBlockUnion()                          {}\nfunc (BetaRedactedThinkingBlock) implBetaContentBlockUnion()                  {}\nfunc (BetaToolUseBlock) implBetaContentBlockUnion()                           {}\nfunc (BetaServerToolUseBlock) implBetaContentBlockUnion()                     {}\nfunc (BetaWebSearchToolResultBlock) implBetaContentBlockUnion()               {}\nfunc (BetaWebFetchToolResultBlock) implBetaContentBlockUnion()                {}\nfunc (BetaCodeExecutionToolResultBlock) implBetaContentBlockUnion()           {}\nfunc (BetaBashCodeExecutionToolResultBlock) implBetaContentBlockUnion()       {}\nfunc (BetaTextEditorCodeExecutionToolResultBlock) implBetaContentBlockUnion() {}\nfunc (BetaToolSearchToolResultBlock) implBetaContentBlockUnion()              {}\nfunc (BetaMCPToolUseBlock) implBetaContentBlockUnion()                        {}\nfunc (BetaMCPToolResultBlock) implBetaContentBlockUnion()                     {}\nfunc (BetaContainerUploadBlock) implBetaContentBlockUnion()                   {}\nfunc (BetaCompactionBlock) implBetaContentBlockUnion()                        {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaContentBlockUnion.AsAny().(type) {\n//\tcase anthropic.BetaTextBlock:\n//\tcase anthropic.BetaThinkingBlock:\n//\tcase anthropic.BetaRedactedThinkingBlock:\n//\tcase anthropic.BetaToolUseBlock:\n//\tcase anthropic.BetaServerToolUseBlock:\n//\tcase anthropic.BetaWebSearchToolResultBlock:\n//\tcase anthropic.BetaWebFetchToolResultBlock:\n//\tcase anthropic.BetaCodeExecutionToolResultBlock:\n//\tcase anthropic.BetaBashCodeExecutionToolResultBlock:\n//\tcase anthropic.BetaTextEditorCodeExecutionToolResultBlock:\n//\tcase anthropic.BetaToolSearchToolResultBlock:\n//\tcase anthropic.BetaMCPToolUseBlock:\n//\tcase anthropic.BetaMCPToolResultBlock:\n//\tcase anthropic.BetaContainerUploadBlock:\n//\tcase anthropic.BetaCompactionBlock:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaContentBlockUnion) AsAny() anyBetaContentBlock {\n\tswitch u.Type {\n\tcase \"text\":\n\t\treturn u.AsText()\n\tcase \"thinking\":\n\t\treturn u.AsThinking()\n\tcase \"redacted_thinking\":\n\t\treturn u.AsRedactedThinking()\n\tcase \"tool_use\":\n\t\treturn u.AsToolUse()\n\tcase \"server_tool_use\":\n\t\treturn u.AsServerToolUse()\n\tcase \"web_search_tool_result\":\n\t\treturn u.AsWebSearchToolResult()\n\tcase \"web_fetch_tool_result\":\n\t\treturn u.AsWebFetchToolResult()\n\tcase \"code_execution_tool_result\":\n\t\treturn u.AsCodeExecutionToolResult()\n\tcase \"bash_code_execution_tool_result\":\n\t\treturn u.AsBashCodeExecutionToolResult()\n\tcase \"text_editor_code_execution_tool_result\":\n\t\treturn u.AsTextEditorCodeExecutionToolResult()\n\tcase \"tool_search_tool_result\":\n\t\treturn u.AsToolSearchToolResult()\n\tcase \"mcp_tool_use\":\n\t\treturn u.AsMCPToolUse()\n\tcase \"mcp_tool_result\":\n\t\treturn u.AsMCPToolResult()\n\tcase \"container_upload\":\n\t\treturn u.AsContainerUpload()\n\tcase \"compaction\":\n\t\treturn u.AsCompaction()\n\t}\n\treturn nil\n}\n\nfunc (u BetaContentBlockUnion) AsText() (v BetaTextBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsThinking() (v BetaThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsRedactedThinking() (v BetaRedactedThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsToolUse() (v BetaToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsServerToolUse() (v BetaServerToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsWebSearchToolResult() (v BetaWebSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsWebFetchToolResult() (v BetaWebFetchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsBashCodeExecutionToolResult() (v BetaBashCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v BetaTextEditorCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsToolSearchToolResult() (v BetaToolSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsMCPToolUse() (v BetaMCPToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContentBlockUnion) AsCompaction() (v BetaCompactionBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaContentBlockUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaContentBlockUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaContentBlockUnionCaller is an implicit subunion of [BetaContentBlockUnion].\n// BetaContentBlockUnionCaller provides convenient access to the sub-properties of\n// the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaContentBlockUnion].\ntype BetaContentBlockUnionCaller struct {\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaContentBlockUnionCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaContentBlockUnionContent is an implicit subunion of [BetaContentBlockUnion].\n// BetaContentBlockUnionContent provides convenient access to the sub-properties of\n// the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfBetaWebSearchResultBlockArray OfString\n// OfBetaMCPToolResultBlockContent]\ntype BetaContentBlockUnionContent struct {\n\t// This field will be present if the value is a [[]BetaWebSearchResultBlock]\n\t// instead of an object.\n\tOfBetaWebSearchResultBlockArray []BetaWebSearchResultBlock `json:\",inline\"`\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field will be present if the value is a [[]BetaTextBlock] instead of an\n\t// object.\n\tOfBetaMCPToolResultBlockContent []BetaTextBlock `json:\",inline\"`\n\tErrorCode                       string          `json:\"error_code\"`\n\tType                            string          `json:\"type\"`\n\t// This field is a union of [BetaDocumentBlock], [[]BetaCodeExecutionOutputBlock],\n\t// [[]BetaCodeExecutionOutputBlock], [[]BetaBashCodeExecutionOutputBlock], [string]\n\tContent BetaContentBlockUnionContentContent `json:\"content\"`\n\t// This field is from variant [BetaWebFetchToolResultBlockContentUnion].\n\tRetrievedAt string `json:\"retrieved_at\"`\n\t// This field is from variant [BetaWebFetchToolResultBlockContentUnion].\n\tURL        string `json:\"url\"`\n\tReturnCode int64  `json:\"return_code\"`\n\tStderr     string `json:\"stderr\"`\n\tStdout     string `json:\"stdout\"`\n\t// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].\n\tEncryptedStdout string `json:\"encrypted_stdout\"`\n\tErrorMessage    string `json:\"error_message\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tFileType BetaTextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tNumLines int64 `json:\"num_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tStartLine int64 `json:\"start_line\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tTotalLines int64 `json:\"total_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tIsFileUpdate bool `json:\"is_file_update\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tLines []string `json:\"lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewLines int64 `json:\"new_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewStart int64 `json:\"new_start\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldLines int64 `json:\"old_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldStart int64 `json:\"old_start\"`\n\t// This field is from variant [BetaToolSearchToolResultBlockContentUnion].\n\tToolReferences []BetaToolReferenceBlock `json:\"tool_references\"`\n\tJSON           struct {\n\t\tOfBetaWebSearchResultBlockArray respjson.Field\n\t\tOfString                        respjson.Field\n\t\tOfBetaMCPToolResultBlockContent respjson.Field\n\t\tErrorCode                       respjson.Field\n\t\tType                            respjson.Field\n\t\tContent                         respjson.Field\n\t\tRetrievedAt                     respjson.Field\n\t\tURL                             respjson.Field\n\t\tReturnCode                      respjson.Field\n\t\tStderr                          respjson.Field\n\t\tStdout                          respjson.Field\n\t\tEncryptedStdout                 respjson.Field\n\t\tErrorMessage                    respjson.Field\n\t\tFileType                        respjson.Field\n\t\tNumLines                        respjson.Field\n\t\tStartLine                       respjson.Field\n\t\tTotalLines                      respjson.Field\n\t\tIsFileUpdate                    respjson.Field\n\t\tLines                           respjson.Field\n\t\tNewLines                        respjson.Field\n\t\tNewStart                        respjson.Field\n\t\tOldLines                        respjson.Field\n\t\tOldStart                        respjson.Field\n\t\tToolReferences                  respjson.Field\n\t\traw                             string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaContentBlockUnionContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaContentBlockUnionContentContent is an implicit subunion of\n// [BetaContentBlockUnion]. BetaContentBlockUnionContentContent provides convenient\n// access to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfContent OfString]\ntype BetaContentBlockUnionContentContent struct {\n\t// This field will be present if the value is a [[]BetaCodeExecutionOutputBlock]\n\t// instead of an object.\n\tOfContent []BetaCodeExecutionOutputBlock `json:\",inline\"`\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tCitations BetaCitationConfig `json:\"citations\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tSource BetaDocumentBlockSourceUnion `json:\"source\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tTitle string `json:\"title\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tType constant.Document `json:\"type\"`\n\tJSON struct {\n\t\tOfContent respjson.Field\n\t\tOfString  respjson.Field\n\t\tCitations respjson.Field\n\t\tSource    respjson.Field\n\t\tTitle     respjson.Field\n\t\tType      respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaContentBlockUnionContentContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc NewBetaTextBlock(text string) BetaContentBlockParamUnion {\n\tvar variant BetaTextBlockParam\n\tvariant.Text = text\n\treturn BetaContentBlockParamUnion{OfText: &variant}\n}\n\nfunc NewBetaImageBlock[\n\tT BetaBase64ImageSourceParam | BetaURLImageSourceParam | BetaFileImageSourceParam,\n](source T) BetaContentBlockParamUnion {\n\tvar image BetaImageBlockParam\n\tswitch v := any(source).(type) {\n\tcase BetaBase64ImageSourceParam:\n\t\timage.Source.OfBase64 = &v\n\tcase BetaURLImageSourceParam:\n\t\timage.Source.OfURL = &v\n\tcase BetaFileImageSourceParam:\n\t\timage.Source.OfFile = &v\n\t}\n\treturn BetaContentBlockParamUnion{OfImage: &image}\n}\n\nfunc NewBetaDocumentBlock[\n\tT BetaBase64PDFSourceParam | BetaPlainTextSourceParam | BetaContentBlockSourceParam | BetaURLPDFSourceParam | BetaFileDocumentSourceParam,\n](source T) BetaContentBlockParamUnion {\n\tvar document BetaRequestDocumentBlockParam\n\tswitch v := any(source).(type) {\n\tcase BetaBase64PDFSourceParam:\n\t\tdocument.Source.OfBase64 = &v\n\tcase BetaPlainTextSourceParam:\n\t\tdocument.Source.OfText = &v\n\tcase BetaContentBlockSourceParam:\n\t\tdocument.Source.OfContent = &v\n\tcase BetaURLPDFSourceParam:\n\t\tdocument.Source.OfURL = &v\n\tcase BetaFileDocumentSourceParam:\n\t\tdocument.Source.OfFile = &v\n\t}\n\treturn BetaContentBlockParamUnion{OfDocument: &document}\n}\n\nfunc NewBetaSearchResultBlock(content []BetaTextBlockParam, source string, title string) BetaContentBlockParamUnion {\n\tvar searchResult BetaSearchResultBlockParam\n\tsearchResult.Content = content\n\tsearchResult.Source = source\n\tsearchResult.Title = title\n\treturn BetaContentBlockParamUnion{OfSearchResult: &searchResult}\n}\n\nfunc NewBetaThinkingBlock(signature string, thinking string) BetaContentBlockParamUnion {\n\tvar variant BetaThinkingBlockParam\n\tvariant.Signature = signature\n\tvariant.Thinking = thinking\n\treturn BetaContentBlockParamUnion{OfThinking: &variant}\n}\n\nfunc NewBetaRedactedThinkingBlock(data string) BetaContentBlockParamUnion {\n\tvar redactedThinking BetaRedactedThinkingBlockParam\n\tredactedThinking.Data = data\n\treturn BetaContentBlockParamUnion{OfRedactedThinking: &redactedThinking}\n}\n\nfunc NewBetaToolUseBlock(id string, input any, name string) BetaContentBlockParamUnion {\n\tvar toolUse BetaToolUseBlockParam\n\ttoolUse.ID = id\n\ttoolUse.Input = input\n\ttoolUse.Name = name\n\treturn BetaContentBlockParamUnion{OfToolUse: &toolUse}\n}\n\nfunc NewBetaToolResultBlock(toolUseID string, content string, isError bool) BetaContentBlockParamUnion {\n\tvar toolBlock BetaToolResultBlockParam\n\ttoolBlock.ToolUseID = toolUseID\n\ttoolBlock.Content = []BetaToolResultBlockParamContentUnion{\n\t\t{OfText: &BetaTextBlockParam{Text: content}},\n\t}\n\ttoolBlock.IsError = Bool(isError)\n\treturn BetaContentBlockParamUnion{OfToolResult: &toolBlock}\n}\n\nfunc NewBetaServerToolUseBlock(id string, input any, name BetaServerToolUseBlockParamName) BetaContentBlockParamUnion {\n\tvar serverToolUse BetaServerToolUseBlockParam\n\tserverToolUse.ID = id\n\tserverToolUse.Input = input\n\tserverToolUse.Name = name\n\treturn BetaContentBlockParamUnion{OfServerToolUse: &serverToolUse}\n}\n\nfunc NewBetaWebSearchToolResultBlock[\n\tT []BetaWebSearchResultBlockParam | BetaWebSearchToolRequestErrorParam,\n](content T, toolUseID string) BetaContentBlockParamUnion {\n\tvar webSearchToolResult BetaWebSearchToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase []BetaWebSearchResultBlockParam:\n\t\twebSearchToolResult.Content.OfResultBlock = v\n\tcase BetaWebSearchToolRequestErrorParam:\n\t\twebSearchToolResult.Content.OfError = &v\n\t}\n\twebSearchToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfWebSearchToolResult: &webSearchToolResult}\n}\n\nfunc NewBetaWebFetchToolResultBlock[\n\tT BetaWebFetchToolResultErrorBlockParam | BetaWebFetchBlockParam,\n](content T, toolUseID string) BetaContentBlockParamUnion {\n\tvar webFetchToolResult BetaWebFetchToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase BetaWebFetchToolResultErrorBlockParam:\n\t\twebFetchToolResult.Content.OfRequestWebFetchToolResultError = &v\n\tcase BetaWebFetchBlockParam:\n\t\twebFetchToolResult.Content.OfRequestWebFetchResultBlock = &v\n\t}\n\twebFetchToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfWebFetchToolResult: &webFetchToolResult}\n}\n\nfunc NewBetaCodeExecutionToolResultBlock[\n\tT BetaCodeExecutionToolResultErrorParam | BetaCodeExecutionResultBlockParam | BetaEncryptedCodeExecutionResultBlockParam,\n](content T, toolUseID string) BetaContentBlockParamUnion {\n\tvar codeExecutionToolResult BetaCodeExecutionToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase BetaCodeExecutionToolResultErrorParam:\n\t\tcodeExecutionToolResult.Content.OfError = &v\n\tcase BetaCodeExecutionResultBlockParam:\n\t\tcodeExecutionToolResult.Content.OfResultBlock = &v\n\tcase BetaEncryptedCodeExecutionResultBlockParam:\n\t\tcodeExecutionToolResult.Content.OfRequestEncryptedCodeExecutionResultBlock = &v\n\t}\n\tcodeExecutionToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfCodeExecutionToolResult: &codeExecutionToolResult}\n}\n\nfunc NewBetaBashCodeExecutionToolResultBlock[\n\tT BetaBashCodeExecutionToolResultErrorParam | BetaBashCodeExecutionResultBlockParam,\n](content T, toolUseID string) BetaContentBlockParamUnion {\n\tvar bashCodeExecutionToolResult BetaBashCodeExecutionToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase BetaBashCodeExecutionToolResultErrorParam:\n\t\tbashCodeExecutionToolResult.Content.OfRequestBashCodeExecutionToolResultError = &v\n\tcase BetaBashCodeExecutionResultBlockParam:\n\t\tbashCodeExecutionToolResult.Content.OfRequestBashCodeExecutionResultBlock = &v\n\t}\n\tbashCodeExecutionToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfBashCodeExecutionToolResult: &bashCodeExecutionToolResult}\n}\n\nfunc NewBetaTextEditorCodeExecutionToolResultBlock[\n\tT BetaTextEditorCodeExecutionToolResultErrorParam | BetaTextEditorCodeExecutionViewResultBlockParam | BetaTextEditorCodeExecutionCreateResultBlockParam | BetaTextEditorCodeExecutionStrReplaceResultBlockParam,\n](content T, toolUseID string) BetaContentBlockParamUnion {\n\tvar textEditorCodeExecutionToolResult BetaTextEditorCodeExecutionToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase BetaTextEditorCodeExecutionToolResultErrorParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionToolResultError = &v\n\tcase BetaTextEditorCodeExecutionViewResultBlockParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionViewResultBlock = &v\n\tcase BetaTextEditorCodeExecutionCreateResultBlockParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionCreateResultBlock = &v\n\tcase BetaTextEditorCodeExecutionStrReplaceResultBlockParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionStrReplaceResultBlock = &v\n\t}\n\ttextEditorCodeExecutionToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfTextEditorCodeExecutionToolResult: &textEditorCodeExecutionToolResult}\n}\n\nfunc NewBetaToolSearchToolResultBlock[\n\tT BetaToolSearchToolResultErrorParam | BetaToolSearchToolSearchResultBlockParam,\n](content T, toolUseID string) BetaContentBlockParamUnion {\n\tvar toolSearchToolResult BetaToolSearchToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase BetaToolSearchToolResultErrorParam:\n\t\ttoolSearchToolResult.Content.OfRequestToolSearchToolResultError = &v\n\tcase BetaToolSearchToolSearchResultBlockParam:\n\t\ttoolSearchToolResult.Content.OfRequestToolSearchToolSearchResultBlock = &v\n\t}\n\ttoolSearchToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfToolSearchToolResult: &toolSearchToolResult}\n}\n\nfunc NewBetaMCPToolResultBlock(toolUseID string) BetaContentBlockParamUnion {\n\tvar mcpToolResult BetaRequestMCPToolResultBlockParam\n\tmcpToolResult.ToolUseID = toolUseID\n\treturn BetaContentBlockParamUnion{OfMCPToolResult: &mcpToolResult}\n}\n\nfunc NewBetaContainerUploadBlock(fileID string) BetaContentBlockParamUnion {\n\tvar containerUpload BetaContainerUploadBlockParam\n\tcontainerUpload.FileID = fileID\n\treturn BetaContentBlockParamUnion{OfContainerUpload: &containerUpload}\n}\n\nfunc NewBetaCompactionBlock(content string) BetaContentBlockParamUnion {\n\tvar compaction BetaCompactionBlockParam\n\tcompaction.Content = param.NewOpt(content)\n\treturn BetaContentBlockParamUnion{OfCompaction: &compaction}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaContentBlockParamUnion struct {\n\tOfText                              *BetaTextBlockParam                              `json:\",omitzero,inline\"`\n\tOfImage                             *BetaImageBlockParam                             `json:\",omitzero,inline\"`\n\tOfDocument                          *BetaRequestDocumentBlockParam                   `json:\",omitzero,inline\"`\n\tOfSearchResult                      *BetaSearchResultBlockParam                      `json:\",omitzero,inline\"`\n\tOfThinking                          *BetaThinkingBlockParam                          `json:\",omitzero,inline\"`\n\tOfRedactedThinking                  *BetaRedactedThinkingBlockParam                  `json:\",omitzero,inline\"`\n\tOfToolUse                           *BetaToolUseBlockParam                           `json:\",omitzero,inline\"`\n\tOfToolResult                        *BetaToolResultBlockParam                        `json:\",omitzero,inline\"`\n\tOfServerToolUse                     *BetaServerToolUseBlockParam                     `json:\",omitzero,inline\"`\n\tOfWebSearchToolResult               *BetaWebSearchToolResultBlockParam               `json:\",omitzero,inline\"`\n\tOfWebFetchToolResult                *BetaWebFetchToolResultBlockParam                `json:\",omitzero,inline\"`\n\tOfCodeExecutionToolResult           *BetaCodeExecutionToolResultBlockParam           `json:\",omitzero,inline\"`\n\tOfBashCodeExecutionToolResult       *BetaBashCodeExecutionToolResultBlockParam       `json:\",omitzero,inline\"`\n\tOfTextEditorCodeExecutionToolResult *BetaTextEditorCodeExecutionToolResultBlockParam `json:\",omitzero,inline\"`\n\tOfToolSearchToolResult              *BetaToolSearchToolResultBlockParam              `json:\",omitzero,inline\"`\n\tOfMCPToolUse                        *BetaMCPToolUseBlockParam                        `json:\",omitzero,inline\"`\n\tOfMCPToolResult                     *BetaRequestMCPToolResultBlockParam              `json:\",omitzero,inline\"`\n\tOfContainerUpload                   *BetaContainerUploadBlockParam                   `json:\",omitzero,inline\"`\n\tOfCompaction                        *BetaCompactionBlockParam                        `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaContentBlockParamUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfText,\n\t\tu.OfImage,\n\t\tu.OfDocument,\n\t\tu.OfSearchResult,\n\t\tu.OfThinking,\n\t\tu.OfRedactedThinking,\n\t\tu.OfToolUse,\n\t\tu.OfToolResult,\n\t\tu.OfServerToolUse,\n\t\tu.OfWebSearchToolResult,\n\t\tu.OfWebFetchToolResult,\n\t\tu.OfCodeExecutionToolResult,\n\t\tu.OfBashCodeExecutionToolResult,\n\t\tu.OfTextEditorCodeExecutionToolResult,\n\t\tu.OfToolSearchToolResult,\n\t\tu.OfMCPToolUse,\n\t\tu.OfMCPToolResult,\n\t\tu.OfContainerUpload,\n\t\tu.OfCompaction)\n}\nfunc (u *BetaContentBlockParamUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaContentBlockParamUnion) asAny() any {\n\tif !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfImage) {\n\t\treturn u.OfImage\n\t} else if !param.IsOmitted(u.OfDocument) {\n\t\treturn u.OfDocument\n\t} else if !param.IsOmitted(u.OfSearchResult) {\n\t\treturn u.OfSearchResult\n\t} else if !param.IsOmitted(u.OfThinking) {\n\t\treturn u.OfThinking\n\t} else if !param.IsOmitted(u.OfRedactedThinking) {\n\t\treturn u.OfRedactedThinking\n\t} else if !param.IsOmitted(u.OfToolUse) {\n\t\treturn u.OfToolUse\n\t} else if !param.IsOmitted(u.OfToolResult) {\n\t\treturn u.OfToolResult\n\t} else if !param.IsOmitted(u.OfServerToolUse) {\n\t\treturn u.OfServerToolUse\n\t} else if !param.IsOmitted(u.OfWebSearchToolResult) {\n\t\treturn u.OfWebSearchToolResult\n\t} else if !param.IsOmitted(u.OfWebFetchToolResult) {\n\t\treturn u.OfWebFetchToolResult\n\t} else if !param.IsOmitted(u.OfCodeExecutionToolResult) {\n\t\treturn u.OfCodeExecutionToolResult\n\t} else if !param.IsOmitted(u.OfBashCodeExecutionToolResult) {\n\t\treturn u.OfBashCodeExecutionToolResult\n\t} else if !param.IsOmitted(u.OfTextEditorCodeExecutionToolResult) {\n\t\treturn u.OfTextEditorCodeExecutionToolResult\n\t} else if !param.IsOmitted(u.OfToolSearchToolResult) {\n\t\treturn u.OfToolSearchToolResult\n\t} else if !param.IsOmitted(u.OfMCPToolUse) {\n\t\treturn u.OfMCPToolUse\n\t} else if !param.IsOmitted(u.OfMCPToolResult) {\n\t\treturn u.OfMCPToolResult\n\t} else if !param.IsOmitted(u.OfContainerUpload) {\n\t\treturn u.OfContainerUpload\n\t} else if !param.IsOmitted(u.OfCompaction) {\n\t\treturn u.OfCompaction\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetText() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.Text\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetContext() *string {\n\tif vt := u.OfDocument; vt != nil && vt.Context.Valid() {\n\t\treturn &vt.Context.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetSignature() *string {\n\tif vt := u.OfThinking; vt != nil {\n\t\treturn &vt.Signature\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetThinking() *string {\n\tif vt := u.OfThinking; vt != nil {\n\t\treturn &vt.Thinking\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetData() *string {\n\tif vt := u.OfRedactedThinking; vt != nil {\n\t\treturn &vt.Data\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetServerName() *string {\n\tif vt := u.OfMCPToolUse; vt != nil {\n\t\treturn &vt.ServerName\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetFileID() *string {\n\tif vt := u.OfContainerUpload; vt != nil {\n\t\treturn &vt.FileID\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetType() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfThinking; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRedactedThinking; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolUse; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMCPToolUse; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMCPToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfContainerUpload; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCompaction; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetTitle() *string {\n\tif vt := u.OfDocument; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Title)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetID() *string {\n\tif vt := u.OfToolUse; vt != nil {\n\t\treturn (*string)(&vt.ID)\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn (*string)(&vt.ID)\n\t} else if vt := u.OfMCPToolUse; vt != nil {\n\t\treturn (*string)(&vt.ID)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetName() *string {\n\tif vt := u.OfToolUse; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfMCPToolUse; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetToolUseID() *string {\n\tif vt := u.OfToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfMCPToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContentBlockParamUnion) GetIsError() *bool {\n\tif vt := u.OfToolResult; vt != nil && vt.IsError.Valid() {\n\t\treturn &vt.IsError.Value\n\t} else if vt := u.OfMCPToolResult; vt != nil && vt.IsError.Valid() {\n\t\treturn &vt.IsError.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u BetaContentBlockParamUnion) GetCacheControl() *BetaCacheControlEphemeralParam {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolUse; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMCPToolUse; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMCPToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfContainerUpload; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCompaction; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaContentBlockParamUnion) GetCitations() (res betaContentBlockParamUnionCitations) {\n\tif vt := u.OfText; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Citations\n\t}\n\treturn\n}\n\n// Can have the runtime types [*[]BetaTextCitationParamUnion],\n// [*BetaCitationsConfigParam]\ntype betaContentBlockParamUnionCitations struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *[]anthropic.BetaTextCitationParamUnion:\n//\tcase *anthropic.BetaCitationsConfigParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaContentBlockParamUnionCitations) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionCitations) GetEnabled() *bool {\n\tswitch vt := u.any.(type) {\n\tcase *BetaCitationsConfigParam:\n\t\treturn paramutil.AddrIfPresent(vt.Enabled)\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaContentBlockParamUnion) GetSource() (res betaContentBlockParamUnionSource) {\n\tif vt := u.OfImage; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Source\n\t}\n\treturn\n}\n\n// Can have the runtime types [*BetaBase64ImageSourceParam],\n// [*BetaURLImageSourceParam], [*BetaFileImageSourceParam],\n// [*BetaBase64PDFSourceParam], [*BetaPlainTextSourceParam],\n// [*BetaContentBlockSourceParam], [*BetaURLPDFSourceParam],\n// [*BetaFileDocumentSourceParam], [*string]\ntype betaContentBlockParamUnionSource struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.BetaBase64ImageSourceParam:\n//\tcase *anthropic.BetaURLImageSourceParam:\n//\tcase *anthropic.BetaFileImageSourceParam:\n//\tcase *anthropic.BetaBase64PDFSourceParam:\n//\tcase *anthropic.BetaPlainTextSourceParam:\n//\tcase *anthropic.BetaContentBlockSourceParam:\n//\tcase *anthropic.BetaURLPDFSourceParam:\n//\tcase *anthropic.BetaFileDocumentSourceParam:\n//\tcase *string:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaContentBlockParamUnionSource) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionSource) GetContent() *BetaContentBlockSourceContentUnionParam {\n\tswitch vt := u.any.(type) {\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetContent()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionSource) GetData() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetData()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetData()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionSource) GetMediaType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetMediaType()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetMediaType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionSource) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetType()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionSource) GetURL() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetURL()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetURL()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionSource) GetFileID() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetFileID()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetFileID()\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaContentBlockParamUnion) GetContent() (res betaContentBlockParamUnionContent) {\n\tif vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Content\n\t} else if vt := u.OfToolResult; vt != nil {\n\t\tres.any = &vt.Content\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfMCPToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfCompaction; vt != nil && vt.Content.Valid() {\n\t\tres.any = &vt.Content.Value\n\t}\n\treturn\n}\n\n// Can have the runtime types [_[]BetaTextBlockParam],\n// [_[]BetaToolResultBlockParamContentUnion], [*[]BetaWebSearchResultBlockParam],\n// [*BetaWebFetchToolResultErrorBlockParam], [*BetaWebFetchBlockParam],\n// [*BetaCodeExecutionToolResultErrorParam], [*BetaCodeExecutionResultBlockParam],\n// [*BetaEncryptedCodeExecutionResultBlockParam],\n// [*BetaBashCodeExecutionToolResultErrorParam],\n// [*BetaBashCodeExecutionResultBlockParam],\n// [*BetaTextEditorCodeExecutionToolResultErrorParam],\n// [*BetaTextEditorCodeExecutionViewResultBlockParam],\n// [*BetaTextEditorCodeExecutionCreateResultBlockParam],\n// [*BetaTextEditorCodeExecutionStrReplaceResultBlockParam],\n// [*BetaToolSearchToolResultErrorParam],\n// [*BetaToolSearchToolSearchResultBlockParam], [*string]\ntype betaContentBlockParamUnionContent struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *[]anthropic.BetaTextBlockParam:\n//\tcase *[]anthropic.BetaToolResultBlockParamContentUnion:\n//\tcase *[]anthropic.BetaWebSearchResultBlockParam:\n//\tcase *anthropic.BetaWebFetchToolResultErrorBlockParam:\n//\tcase *anthropic.BetaWebFetchBlockParam:\n//\tcase *anthropic.BetaCodeExecutionToolResultErrorParam:\n//\tcase *anthropic.BetaCodeExecutionResultBlockParam:\n//\tcase *anthropic.BetaEncryptedCodeExecutionResultBlockParam:\n//\tcase *anthropic.BetaBashCodeExecutionToolResultErrorParam:\n//\tcase *anthropic.BetaBashCodeExecutionResultBlockParam:\n//\tcase *anthropic.BetaTextEditorCodeExecutionToolResultErrorParam:\n//\tcase *anthropic.BetaTextEditorCodeExecutionViewResultBlockParam:\n//\tcase *anthropic.BetaTextEditorCodeExecutionCreateResultBlockParam:\n//\tcase *anthropic.BetaTextEditorCodeExecutionStrReplaceResultBlockParam:\n//\tcase *anthropic.BetaToolSearchToolResultErrorParam:\n//\tcase *anthropic.BetaToolSearchToolSearchResultBlockParam:\n//\tcase *string:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaContentBlockParamUnionContent) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetURL() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaWebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetURL()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetRetrievedAt() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaWebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetRetrievedAt()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetEncryptedStdout() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetEncryptedStdout()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetErrorMessage() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorMessage()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetFileType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetFileType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetNumLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetNumLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetStartLine() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStartLine()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetTotalLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetTotalLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetIsFileUpdate() *bool {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetIsFileUpdate()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetLines() []string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetNewLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetNewLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetNewStart() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetNewStart()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetOldLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetOldLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetOldStart() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetOldStart()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetToolReferences() []BetaToolReferenceBlockParam {\n\tswitch vt := u.any.(type) {\n\tcase *BetaToolSearchToolResultBlockParamContentUnion:\n\t\treturn vt.GetToolReferences()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetErrorCode() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaWebSearchToolResultBlockParamContentUnion:\n\t\tif vt.OfError != nil {\n\t\t\treturn (*string)(&vt.OfError.ErrorCode)\n\t\t}\n\tcase *BetaWebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *BetaBashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *BetaToolSearchToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaWebSearchToolResultBlockParamContentUnion:\n\t\tif vt.OfError != nil {\n\t\t\treturn (*string)(&vt.OfError.Type)\n\t\t}\n\tcase *BetaWebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *BetaBashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *BetaToolSearchToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetReturnCode() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetReturnCode()\n\tcase *BetaBashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetReturnCode()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetStderr() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStderr()\n\tcase *BetaBashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStderr()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionContent) GetStdout() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStdout()\n\tcase *BetaBashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStdout()\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u betaContentBlockParamUnionContent) GetContent() (res betaContentBlockParamUnionContentContent) {\n\tswitch vt := u.any.(type) {\n\tcase *BetaWebFetchToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\tcase *BetaCodeExecutionToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\tcase *BetaBashCodeExecutionToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\tcase *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\t}\n\treturn res\n}\n\n// Can have the runtime types [*BetaRequestDocumentBlockParam],\n// [_[]BetaCodeExecutionOutputBlockParam],\n// [_[]BetaBashCodeExecutionOutputBlockParam], [*string]\ntype betaContentBlockParamUnionContentContent struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.BetaRequestDocumentBlockParam:\n//\tcase *[]anthropic.BetaCodeExecutionOutputBlockParam:\n//\tcase *[]anthropic.BetaBashCodeExecutionOutputBlockParam:\n//\tcase *string:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaContentBlockParamUnionContentContent) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's Input property, if present.\nfunc (u BetaContentBlockParamUnion) GetInput() *any {\n\tif vt := u.OfToolUse; vt != nil {\n\t\treturn &vt.Input\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn &vt.Input\n\t} else if vt := u.OfMCPToolUse; vt != nil {\n\t\treturn &vt.Input\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaContentBlockParamUnion) GetCaller() (res betaContentBlockParamUnionCaller) {\n\tif vt := u.OfToolUse; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t}\n\treturn\n}\n\n// Can have the runtime types [*BetaDirectCallerParam],\n// [*BetaServerToolCallerParam], [*BetaServerToolCaller20260120Param]\ntype betaContentBlockParamUnionCaller struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.BetaDirectCallerParam:\n//\tcase *anthropic.BetaServerToolCallerParam:\n//\tcase *anthropic.BetaServerToolCaller20260120Param:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaContentBlockParamUnionCaller) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionCaller) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaToolUseBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\tcase *BetaServerToolUseBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\tcase *BetaWebSearchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\tcase *BetaWebFetchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContentBlockParamUnionCaller) GetToolID() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaToolUseBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\tcase *BetaServerToolUseBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\tcase *BetaWebSearchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\tcase *BetaWebFetchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\t}\n\treturn nil\n}\n\n// The properties Content, Type are required.\ntype BetaContentBlockSourceParam struct {\n\tContent BetaContentBlockSourceContentUnionParam `json:\"content,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"content\".\n\tType constant.Content `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaContentBlockSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaContentBlockSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaContentBlockSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaContentBlockSourceContentUnionParam struct {\n\tOfString                        param.Opt[string]                         `json:\",omitzero,inline\"`\n\tOfBetaContentBlockSourceContent []BetaContentBlockSourceContentUnionParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaContentBlockSourceContentUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfString, u.OfBetaContentBlockSourceContent)\n}\nfunc (u *BetaContentBlockSourceContentUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaContentBlockSourceContentUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t} else if !param.IsOmitted(u.OfBetaContentBlockSourceContent) {\n\t\treturn &u.OfBetaContentBlockSourceContent\n\t}\n\treturn nil\n}\n\ntype BetaContextManagementConfigParam struct {\n\t// List of context management edits to apply\n\tEdits []BetaContextManagementConfigEditUnionParam `json:\"edits,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaContextManagementConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaContextManagementConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaContextManagementConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaContextManagementConfigEditUnionParam struct {\n\tOfClearToolUses20250919 *BetaClearToolUses20250919EditParam `json:\",omitzero,inline\"`\n\tOfClearThinking20251015 *BetaClearThinking20251015EditParam `json:\",omitzero,inline\"`\n\tOfCompact20260112       *BetaCompact20260112EditParam       `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaContextManagementConfigEditUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfClearToolUses20250919, u.OfClearThinking20251015, u.OfCompact20260112)\n}\nfunc (u *BetaContextManagementConfigEditUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaContextManagementConfigEditUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfClearToolUses20250919) {\n\t\treturn u.OfClearToolUses20250919\n\t} else if !param.IsOmitted(u.OfClearThinking20251015) {\n\t\treturn u.OfClearThinking20251015\n\t} else if !param.IsOmitted(u.OfCompact20260112) {\n\t\treturn u.OfCompact20260112\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContextManagementConfigEditUnionParam) GetClearAtLeast() *BetaInputTokensClearAtLeastParam {\n\tif vt := u.OfClearToolUses20250919; vt != nil {\n\t\treturn &vt.ClearAtLeast\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContextManagementConfigEditUnionParam) GetClearToolInputs() *BetaClearToolUses20250919EditClearToolInputsUnionParam {\n\tif vt := u.OfClearToolUses20250919; vt != nil {\n\t\treturn &vt.ClearToolInputs\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContextManagementConfigEditUnionParam) GetExcludeTools() []string {\n\tif vt := u.OfClearToolUses20250919; vt != nil {\n\t\treturn vt.ExcludeTools\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContextManagementConfigEditUnionParam) GetInstructions() *string {\n\tif vt := u.OfCompact20260112; vt != nil && vt.Instructions.Valid() {\n\t\treturn &vt.Instructions.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContextManagementConfigEditUnionParam) GetPauseAfterCompaction() *bool {\n\tif vt := u.OfCompact20260112; vt != nil && vt.PauseAfterCompaction.Valid() {\n\t\treturn &vt.PauseAfterCompaction.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaContextManagementConfigEditUnionParam) GetType() *string {\n\tif vt := u.OfClearToolUses20250919; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfClearThinking20251015; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCompact20260112; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaContextManagementConfigEditUnionParam) GetKeep() (res betaContextManagementConfigEditUnionParamKeep) {\n\tif vt := u.OfClearToolUses20250919; vt != nil {\n\t\tres.any = &vt.Keep\n\t} else if vt := u.OfClearThinking20251015; vt != nil {\n\t\tres.any = vt.Keep.asAny()\n\t}\n\treturn\n}\n\n// Can have the runtime types [*BetaToolUsesKeepParam], [*string]\ntype betaContextManagementConfigEditUnionParamKeep struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.BetaToolUsesKeepParam:\n//\tcase *string:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaContextManagementConfigEditUnionParamKeep) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContextManagementConfigEditUnionParamKeep) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaToolUsesKeepParam:\n\t\treturn (*string)(&vt.Type)\n\tcase *BetaClearThinking20251015EditKeepUnionParam:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaContextManagementConfigEditUnionParamKeep) GetValue() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *BetaToolUsesKeepParam:\n\t\treturn (*int64)(&vt.Value)\n\tcase *BetaClearThinking20251015EditKeepUnionParam:\n\t\treturn vt.GetValue()\n\t}\n\treturn nil\n}\n\ntype BetaContextManagementResponse struct {\n\t// List of context management edits that were applied.\n\tAppliedEdits []BetaContextManagementResponseAppliedEditUnion `json:\"applied_edits\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tAppliedEdits respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaContextManagementResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaContextManagementResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaContextManagementResponseAppliedEditUnion contains all possible properties\n// and values from [BetaClearToolUses20250919EditResponse],\n// [BetaClearThinking20251015EditResponse].\n//\n// Use the [BetaContextManagementResponseAppliedEditUnion.AsAny] method to switch\n// on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaContextManagementResponseAppliedEditUnion struct {\n\tClearedInputTokens int64 `json:\"cleared_input_tokens\"`\n\t// This field is from variant [BetaClearToolUses20250919EditResponse].\n\tClearedToolUses int64 `json:\"cleared_tool_uses\"`\n\t// Any of \"clear_tool_uses_20250919\", \"clear_thinking_20251015\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaClearThinking20251015EditResponse].\n\tClearedThinkingTurns int64 `json:\"cleared_thinking_turns\"`\n\tJSON                 struct {\n\t\tClearedInputTokens   respjson.Field\n\t\tClearedToolUses      respjson.Field\n\t\tType                 respjson.Field\n\t\tClearedThinkingTurns respjson.Field\n\t\traw                  string\n\t} `json:\"-\"`\n}\n\n// anyBetaContextManagementResponseAppliedEdit is implemented by each variant of\n// [BetaContextManagementResponseAppliedEditUnion] to add type safety for the\n// return type of [BetaContextManagementResponseAppliedEditUnion.AsAny]\ntype anyBetaContextManagementResponseAppliedEdit interface {\n\timplBetaContextManagementResponseAppliedEditUnion()\n}\n\nfunc (BetaClearToolUses20250919EditResponse) implBetaContextManagementResponseAppliedEditUnion() {}\nfunc (BetaClearThinking20251015EditResponse) implBetaContextManagementResponseAppliedEditUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaContextManagementResponseAppliedEditUnion.AsAny().(type) {\n//\tcase anthropic.BetaClearToolUses20250919EditResponse:\n//\tcase anthropic.BetaClearThinking20251015EditResponse:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaContextManagementResponseAppliedEditUnion) AsAny() anyBetaContextManagementResponseAppliedEdit {\n\tswitch u.Type {\n\tcase \"clear_tool_uses_20250919\":\n\t\treturn u.AsClearToolUses20250919()\n\tcase \"clear_thinking_20251015\":\n\t\treturn u.AsClearThinking20251015()\n\t}\n\treturn nil\n}\n\nfunc (u BetaContextManagementResponseAppliedEditUnion) AsClearToolUses20250919() (v BetaClearToolUses20250919EditResponse) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaContextManagementResponseAppliedEditUnion) AsClearThinking20251015() (v BetaClearThinking20251015EditResponse) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaContextManagementResponseAppliedEditUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaContextManagementResponseAppliedEditUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaCountTokensContextManagementResponse struct {\n\t// The original token count before context management was applied\n\tOriginalInputTokens int64 `json:\"original_input_tokens\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tOriginalInputTokens respjson.Field\n\t\tExtraFields         map[string]respjson.Field\n\t\traw                 string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCountTokensContextManagementResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCountTokensContextManagementResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Tool invocation directly from the model.\ntype BetaDirectCaller struct {\n\tType constant.Direct `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaDirectCaller) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaDirectCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this BetaDirectCaller to a BetaDirectCallerParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// BetaDirectCallerParam.Overrides()\nfunc (r BetaDirectCaller) ToParam() BetaDirectCallerParam {\n\treturn param.Override[BetaDirectCallerParam](json.RawMessage(r.RawJSON()))\n}\n\nfunc NewBetaDirectCallerParam() BetaDirectCallerParam {\n\treturn BetaDirectCallerParam{\n\t\tType: \"direct\",\n\t}\n}\n\n// Tool invocation directly from the model.\n//\n// This struct has a constant value, construct it with [NewBetaDirectCallerParam].\ntype BetaDirectCallerParam struct {\n\tType constant.Direct `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaDirectCallerParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaDirectCallerParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaDirectCallerParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaDocumentBlock struct {\n\t// Citation configuration for the document\n\tCitations BetaCitationConfig           `json:\"citations\" api:\"required\"`\n\tSource    BetaDocumentBlockSourceUnion `json:\"source\" api:\"required\"`\n\t// The title of the document\n\tTitle string            `json:\"title\" api:\"required\"`\n\tType  constant.Document `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitations   respjson.Field\n\t\tSource      respjson.Field\n\t\tTitle       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaDocumentBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaDocumentBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaDocumentBlockSourceUnion contains all possible properties and values from\n// [BetaBase64PDFSource], [BetaPlainTextSource].\n//\n// Use the [BetaDocumentBlockSourceUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaDocumentBlockSourceUnion struct {\n\tData      string `json:\"data\"`\n\tMediaType string `json:\"media_type\"`\n\t// Any of \"base64\", \"text\".\n\tType string `json:\"type\"`\n\tJSON struct {\n\t\tData      respjson.Field\n\t\tMediaType respjson.Field\n\t\tType      respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\n// anyBetaDocumentBlockSource is implemented by each variant of\n// [BetaDocumentBlockSourceUnion] to add type safety for the return type of\n// [BetaDocumentBlockSourceUnion.AsAny]\ntype anyBetaDocumentBlockSource interface {\n\timplBetaDocumentBlockSourceUnion()\n}\n\nfunc (BetaBase64PDFSource) implBetaDocumentBlockSourceUnion() {}\nfunc (BetaPlainTextSource) implBetaDocumentBlockSourceUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaDocumentBlockSourceUnion.AsAny().(type) {\n//\tcase anthropic.BetaBase64PDFSource:\n//\tcase anthropic.BetaPlainTextSource:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaDocumentBlockSourceUnion) AsAny() anyBetaDocumentBlockSource {\n\tswitch u.Type {\n\tcase \"base64\":\n\t\treturn u.AsBase64()\n\tcase \"text\":\n\t\treturn u.AsText()\n\t}\n\treturn nil\n}\n\nfunc (u BetaDocumentBlockSourceUnion) AsBase64() (v BetaBase64PDFSource) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaDocumentBlockSourceUnion) AsText() (v BetaPlainTextSource) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaDocumentBlockSourceUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaDocumentBlockSourceUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Code execution result with encrypted stdout for PFC + web_search results.\ntype BetaEncryptedCodeExecutionResultBlock struct {\n\tContent         []BetaCodeExecutionOutputBlock        `json:\"content\" api:\"required\"`\n\tEncryptedStdout string                                `json:\"encrypted_stdout\" api:\"required\"`\n\tReturnCode      int64                                 `json:\"return_code\" api:\"required\"`\n\tStderr          string                                `json:\"stderr\" api:\"required\"`\n\tType            constant.EncryptedCodeExecutionResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent         respjson.Field\n\t\tEncryptedStdout respjson.Field\n\t\tReturnCode      respjson.Field\n\t\tStderr          respjson.Field\n\t\tType            respjson.Field\n\t\tExtraFields     map[string]respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaEncryptedCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaEncryptedCodeExecutionResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Code execution result with encrypted stdout for PFC + web_search results.\n//\n// The properties Content, EncryptedStdout, ReturnCode, Stderr, Type are required.\ntype BetaEncryptedCodeExecutionResultBlockParam struct {\n\tContent         []BetaCodeExecutionOutputBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tEncryptedStdout string                              `json:\"encrypted_stdout\" api:\"required\"`\n\tReturnCode      int64                               `json:\"return_code\" api:\"required\"`\n\tStderr          string                              `json:\"stderr\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"encrypted_code_execution_result\".\n\tType constant.EncryptedCodeExecutionResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaEncryptedCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaEncryptedCodeExecutionResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaEncryptedCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties FileID, Type are required.\ntype BetaFileDocumentSourceParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"file\".\n\tType constant.File `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaFileDocumentSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaFileDocumentSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaFileDocumentSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties FileID, Type are required.\ntype BetaFileImageSourceParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"file\".\n\tType constant.File `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaFileImageSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaFileImageSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaFileImageSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Source, Type are required.\ntype BetaImageBlockParam struct {\n\tSource BetaImageBlockParamSourceUnion `json:\"source,omitzero\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"image\".\n\tType constant.Image `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaImageBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaImageBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaImageBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaImageBlockParamSourceUnion struct {\n\tOfBase64 *BetaBase64ImageSourceParam `json:\",omitzero,inline\"`\n\tOfURL    *BetaURLImageSourceParam    `json:\",omitzero,inline\"`\n\tOfFile   *BetaFileImageSourceParam   `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaImageBlockParamSourceUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfBase64, u.OfURL, u.OfFile)\n}\nfunc (u *BetaImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaImageBlockParamSourceUnion) asAny() any {\n\tif !param.IsOmitted(u.OfBase64) {\n\t\treturn u.OfBase64\n\t} else if !param.IsOmitted(u.OfURL) {\n\t\treturn u.OfURL\n\t} else if !param.IsOmitted(u.OfFile) {\n\t\treturn u.OfFile\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaImageBlockParamSourceUnion) GetData() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn &vt.Data\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaImageBlockParamSourceUnion) GetMediaType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.MediaType)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaImageBlockParamSourceUnion) GetURL() *string {\n\tif vt := u.OfURL; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaImageBlockParamSourceUnion) GetFileID() *string {\n\tif vt := u.OfFile; vt != nil {\n\t\treturn &vt.FileID\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaImageBlockParamSourceUnion) GetType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfURL; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfFile; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BetaInputJSONDelta struct {\n\tPartialJSON string                  `json:\"partial_json\" api:\"required\"`\n\tType        constant.InputJSONDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tPartialJSON respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaInputJSONDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaInputJSONDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, Value are required.\ntype BetaInputTokensClearAtLeastParam struct {\n\tValue int64 `json:\"value\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"input_tokens\".\n\tType constant.InputTokens `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaInputTokensClearAtLeastParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaInputTokensClearAtLeastParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaInputTokensClearAtLeastParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, Value are required.\ntype BetaInputTokensTriggerParam struct {\n\tValue int64 `json:\"value\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"input_tokens\".\n\tType constant.InputTokens `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaInputTokensTriggerParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaInputTokensTriggerParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaInputTokensTriggerParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaIterationsUsage []BetaIterationsUsageItemUnion\n\n// BetaIterationsUsageItemUnion contains all possible properties and values from\n// [BetaMessageIterationUsage], [BetaCompactionIterationUsage].\n//\n// Use the [BetaIterationsUsageItemUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaIterationsUsageItemUnion struct {\n\t// This field is from variant [BetaMessageIterationUsage].\n\tCacheCreation            BetaCacheCreation `json:\"cache_creation\"`\n\tCacheCreationInputTokens int64             `json:\"cache_creation_input_tokens\"`\n\tCacheReadInputTokens     int64             `json:\"cache_read_input_tokens\"`\n\tInputTokens              int64             `json:\"input_tokens\"`\n\tOutputTokens             int64             `json:\"output_tokens\"`\n\t// Any of \"message\", \"compaction\".\n\tType string `json:\"type\"`\n\tJSON struct {\n\t\tCacheCreation            respjson.Field\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tType                     respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// anyBetaIterationsUsageItem is implemented by each variant of\n// [BetaIterationsUsageItemUnion] to add type safety for the return type of\n// [BetaIterationsUsageItemUnion.AsAny]\ntype anyBetaIterationsUsageItem interface {\n\timplBetaIterationsUsageItemUnion()\n}\n\nfunc (BetaMessageIterationUsage) implBetaIterationsUsageItemUnion()    {}\nfunc (BetaCompactionIterationUsage) implBetaIterationsUsageItemUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaIterationsUsageItemUnion.AsAny().(type) {\n//\tcase anthropic.BetaMessageIterationUsage:\n//\tcase anthropic.BetaCompactionIterationUsage:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaIterationsUsageItemUnion) AsAny() anyBetaIterationsUsageItem {\n\tswitch u.Type {\n\tcase \"message\":\n\t\treturn u.AsMessage()\n\tcase \"compaction\":\n\t\treturn u.AsCompaction()\n\t}\n\treturn nil\n}\n\nfunc (u BetaIterationsUsageItemUnion) AsMessage() (v BetaMessageIterationUsage) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaIterationsUsageItemUnion) AsCompaction() (v BetaCompactionIterationUsage) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaIterationsUsageItemUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaIterationsUsageItemUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Schema, Type are required.\ntype BetaJSONOutputFormatParam struct {\n\t// The JSON schema of the format\n\tSchema map[string]any `json:\"schema,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"json_schema\".\n\tType constant.JSONSchema `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaJSONOutputFormatParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaJSONOutputFormatParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaJSONOutputFormatParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Configuration for a specific tool in an MCP toolset.\ntype BetaMCPToolConfigParam struct {\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\tEnabled      param.Opt[bool] `json:\"enabled,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaMCPToolConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMCPToolConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMCPToolConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Default configuration for tools in an MCP toolset.\ntype BetaMCPToolDefaultConfigParam struct {\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\tEnabled      param.Opt[bool] `json:\"enabled,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaMCPToolDefaultConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMCPToolDefaultConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMCPToolDefaultConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMCPToolResultBlock struct {\n\tContent   BetaMCPToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tIsError   bool                               `json:\"is_error\" api:\"required\"`\n\tToolUseID string                             `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.MCPToolResult             `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tIsError     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMCPToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMCPToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaMCPToolResultBlockContentUnion contains all possible properties and values\n// from [string], [[]BetaTextBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfString OfBetaMCPToolResultBlockContent]\ntype BetaMCPToolResultBlockContentUnion struct {\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field will be present if the value is a [[]BetaTextBlock] instead of an\n\t// object.\n\tOfBetaMCPToolResultBlockContent []BetaTextBlock `json:\",inline\"`\n\tJSON                            struct {\n\t\tOfString                        respjson.Field\n\t\tOfBetaMCPToolResultBlockContent respjson.Field\n\t\traw                             string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaMCPToolResultBlockContentUnion) AsString() (v string) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMCPToolResultBlockContentUnion) AsBetaMCPToolResultBlockContent() (v []BetaTextBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaMCPToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaMCPToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMCPToolUseBlock struct {\n\tID    string `json:\"id\" api:\"required\"`\n\tInput any    `json:\"input\" api:\"required\"`\n\t// The name of the MCP tool\n\tName string `json:\"name\" api:\"required\"`\n\t// The name of the MCP server\n\tServerName string              `json:\"server_name\" api:\"required\"`\n\tType       constant.MCPToolUse `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tInput       respjson.Field\n\t\tName        respjson.Field\n\t\tServerName  respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMCPToolUseBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMCPToolUseBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ID, Input, Name, ServerName, Type are required.\ntype BetaMCPToolUseBlockParam struct {\n\tID    string `json:\"id\" api:\"required\"`\n\tInput any    `json:\"input,omitzero\" api:\"required\"`\n\tName  string `json:\"name\" api:\"required\"`\n\t// The name of the MCP server\n\tServerName string `json:\"server_name\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"mcp_tool_use\".\n\tType constant.MCPToolUse `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaMCPToolUseBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMCPToolUseBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMCPToolUseBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Configuration for a group of tools from an MCP server.\n//\n// Allows configuring enabled status and defer_loading for all tools from an MCP\n// server, with optional per-tool overrides.\n//\n// The properties MCPServerName, Type are required.\ntype BetaMCPToolsetParam struct {\n\t// Name of the MCP server to configure tools for\n\tMCPServerName string `json:\"mcp_server_name\" api:\"required\"`\n\t// Configuration overrides for specific tools, keyed by tool name\n\tConfigs map[string]BetaMCPToolConfigParam `json:\"configs,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Default configuration applied to all tools from this server\n\tDefaultConfig BetaMCPToolDefaultConfigParam `json:\"default_config,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"mcp_toolset\".\n\tType constant.MCPToolset `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaMCPToolsetParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMCPToolsetParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMCPToolsetParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaMemoryTool20250818Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"memory\".\n\tName constant.Memory `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"memory_20250818\".\n\tType constant.Memory20250818 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaMemoryTool20250818Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMemoryTool20250818Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMemoryTool20250818Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaMemoryTool20250818CommandUnion contains all possible properties and values\n// from [BetaMemoryTool20250818ViewCommand], [BetaMemoryTool20250818CreateCommand],\n// [BetaMemoryTool20250818StrReplaceCommand],\n// [BetaMemoryTool20250818InsertCommand], [BetaMemoryTool20250818DeleteCommand],\n// [BetaMemoryTool20250818RenameCommand].\n//\n// Use the [BetaMemoryTool20250818CommandUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaMemoryTool20250818CommandUnion struct {\n\t// Any of \"view\", \"create\", \"str_replace\", \"insert\", \"delete\", \"rename\".\n\tCommand string `json:\"command\"`\n\tPath    string `json:\"path\"`\n\t// This field is from variant [BetaMemoryTool20250818ViewCommand].\n\tViewRange []int64 `json:\"view_range\"`\n\t// This field is from variant [BetaMemoryTool20250818CreateCommand].\n\tFileText string `json:\"file_text\"`\n\t// This field is from variant [BetaMemoryTool20250818StrReplaceCommand].\n\tNewStr string `json:\"new_str\"`\n\t// This field is from variant [BetaMemoryTool20250818StrReplaceCommand].\n\tOldStr string `json:\"old_str\"`\n\t// This field is from variant [BetaMemoryTool20250818InsertCommand].\n\tInsertLine int64 `json:\"insert_line\"`\n\t// This field is from variant [BetaMemoryTool20250818InsertCommand].\n\tInsertText string `json:\"insert_text\"`\n\t// This field is from variant [BetaMemoryTool20250818RenameCommand].\n\tNewPath string `json:\"new_path\"`\n\t// This field is from variant [BetaMemoryTool20250818RenameCommand].\n\tOldPath string `json:\"old_path\"`\n\tJSON    struct {\n\t\tCommand    respjson.Field\n\t\tPath       respjson.Field\n\t\tViewRange  respjson.Field\n\t\tFileText   respjson.Field\n\t\tNewStr     respjson.Field\n\t\tOldStr     respjson.Field\n\t\tInsertLine respjson.Field\n\t\tInsertText respjson.Field\n\t\tNewPath    respjson.Field\n\t\tOldPath    respjson.Field\n\t\traw        string\n\t} `json:\"-\"`\n}\n\n// anyBetaMemoryTool20250818Command is implemented by each variant of\n// [BetaMemoryTool20250818CommandUnion] to add type safety for the return type of\n// [BetaMemoryTool20250818CommandUnion.AsAny]\ntype anyBetaMemoryTool20250818Command interface {\n\timplBetaMemoryTool20250818CommandUnion()\n}\n\nfunc (BetaMemoryTool20250818ViewCommand) implBetaMemoryTool20250818CommandUnion()       {}\nfunc (BetaMemoryTool20250818CreateCommand) implBetaMemoryTool20250818CommandUnion()     {}\nfunc (BetaMemoryTool20250818StrReplaceCommand) implBetaMemoryTool20250818CommandUnion() {}\nfunc (BetaMemoryTool20250818InsertCommand) implBetaMemoryTool20250818CommandUnion()     {}\nfunc (BetaMemoryTool20250818DeleteCommand) implBetaMemoryTool20250818CommandUnion()     {}\nfunc (BetaMemoryTool20250818RenameCommand) implBetaMemoryTool20250818CommandUnion()     {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaMemoryTool20250818CommandUnion.AsAny().(type) {\n//\tcase anthropic.BetaMemoryTool20250818ViewCommand:\n//\tcase anthropic.BetaMemoryTool20250818CreateCommand:\n//\tcase anthropic.BetaMemoryTool20250818StrReplaceCommand:\n//\tcase anthropic.BetaMemoryTool20250818InsertCommand:\n//\tcase anthropic.BetaMemoryTool20250818DeleteCommand:\n//\tcase anthropic.BetaMemoryTool20250818RenameCommand:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaMemoryTool20250818CommandUnion) AsAny() anyBetaMemoryTool20250818Command {\n\tswitch u.Command {\n\tcase \"view\":\n\t\treturn u.AsView()\n\tcase \"create\":\n\t\treturn u.AsCreate()\n\tcase \"str_replace\":\n\t\treturn u.AsStrReplace()\n\tcase \"insert\":\n\t\treturn u.AsInsert()\n\tcase \"delete\":\n\t\treturn u.AsDelete()\n\tcase \"rename\":\n\t\treturn u.AsRename()\n\t}\n\treturn nil\n}\n\nfunc (u BetaMemoryTool20250818CommandUnion) AsView() (v BetaMemoryTool20250818ViewCommand) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMemoryTool20250818CommandUnion) AsCreate() (v BetaMemoryTool20250818CreateCommand) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMemoryTool20250818CommandUnion) AsStrReplace() (v BetaMemoryTool20250818StrReplaceCommand) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMemoryTool20250818CommandUnion) AsInsert() (v BetaMemoryTool20250818InsertCommand) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMemoryTool20250818CommandUnion) AsDelete() (v BetaMemoryTool20250818DeleteCommand) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMemoryTool20250818CommandUnion) AsRename() (v BetaMemoryTool20250818RenameCommand) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaMemoryTool20250818CommandUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaMemoryTool20250818CommandUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMemoryTool20250818CreateCommand struct {\n\t// Command type identifier\n\tCommand constant.Create `json:\"command\" api:\"required\"`\n\t// Content to write to the file\n\tFileText string `json:\"file_text\" api:\"required\"`\n\t// Path where the file should be created\n\tPath string `json:\"path\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCommand     respjson.Field\n\t\tFileText    respjson.Field\n\t\tPath        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMemoryTool20250818CreateCommand) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMemoryTool20250818CreateCommand) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMemoryTool20250818DeleteCommand struct {\n\t// Command type identifier\n\tCommand constant.Delete `json:\"command\" api:\"required\"`\n\t// Path to the file or directory to delete\n\tPath string `json:\"path\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCommand     respjson.Field\n\t\tPath        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMemoryTool20250818DeleteCommand) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMemoryTool20250818DeleteCommand) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMemoryTool20250818InsertCommand struct {\n\t// Command type identifier\n\tCommand constant.Insert `json:\"command\" api:\"required\"`\n\t// Line number where text should be inserted\n\tInsertLine int64 `json:\"insert_line\" api:\"required\"`\n\t// Text to insert at the specified line\n\tInsertText string `json:\"insert_text\" api:\"required\"`\n\t// Path to the file where text should be inserted\n\tPath string `json:\"path\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCommand     respjson.Field\n\t\tInsertLine  respjson.Field\n\t\tInsertText  respjson.Field\n\t\tPath        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMemoryTool20250818InsertCommand) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMemoryTool20250818InsertCommand) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMemoryTool20250818RenameCommand struct {\n\t// Command type identifier\n\tCommand constant.Rename `json:\"command\" api:\"required\"`\n\t// New path for the file or directory\n\tNewPath string `json:\"new_path\" api:\"required\"`\n\t// Current path of the file or directory\n\tOldPath string `json:\"old_path\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCommand     respjson.Field\n\t\tNewPath     respjson.Field\n\t\tOldPath     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMemoryTool20250818RenameCommand) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMemoryTool20250818RenameCommand) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMemoryTool20250818StrReplaceCommand struct {\n\t// Command type identifier\n\tCommand constant.StrReplace `json:\"command\" api:\"required\"`\n\t// Text to replace with\n\tNewStr string `json:\"new_str\" api:\"required\"`\n\t// Text to search for and replace\n\tOldStr string `json:\"old_str\" api:\"required\"`\n\t// Path to the file where text should be replaced\n\tPath string `json:\"path\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCommand     respjson.Field\n\t\tNewStr      respjson.Field\n\t\tOldStr      respjson.Field\n\t\tPath        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMemoryTool20250818StrReplaceCommand) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMemoryTool20250818StrReplaceCommand) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMemoryTool20250818ViewCommand struct {\n\t// Command type identifier\n\tCommand constant.View `json:\"command\" api:\"required\"`\n\t// Path to directory or file to view\n\tPath string `json:\"path\" api:\"required\"`\n\t// Optional line range for viewing specific lines\n\tViewRange []int64 `json:\"view_range\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCommand     respjson.Field\n\t\tPath        respjson.Field\n\t\tViewRange   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMemoryTool20250818ViewCommand) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMemoryTool20250818ViewCommand) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessage struct {\n\t// Unique object identifier.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// Information about the container used in the request (for the code execution\n\t// tool)\n\tContainer BetaContainer `json:\"container\" api:\"required\"`\n\t// Content generated by the model.\n\t//\n\t// This is an array of content blocks, each of which has a `type` that determines\n\t// its shape.\n\t//\n\t// Example:\n\t//\n\t// ```json\n\t// [{ \"type\": \"text\", \"text\": \"Hi, I'm Claude.\" }]\n\t// ```\n\t//\n\t// If the request input `messages` ended with an `assistant` turn, then the\n\t// response `content` will continue directly from that last turn. You can use this\n\t// to constrain the model's output.\n\t//\n\t// For example, if the input `messages` were:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Then the response `content` might be:\n\t//\n\t// ```json\n\t// [{ \"type\": \"text\", \"text\": \"B)\" }]\n\t// ```\n\tContent []BetaContentBlockUnion `json:\"content\" api:\"required\"`\n\t// Context management response.\n\t//\n\t// Information about context management strategies applied during the request.\n\tContextManagement BetaContextManagementResponse `json:\"context_management\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model\" api:\"required\"`\n\t// Conversational role of the generated message.\n\t//\n\t// This will always be `\"assistant\"`.\n\tRole constant.Assistant `json:\"role\" api:\"required\"`\n\t// The reason that we stopped.\n\t//\n\t// This may be one the following values:\n\t//\n\t//   - `\"end_turn\"`: the model reached a natural stopping point\n\t//   - `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n\t//   - `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n\t//   - `\"tool_use\"`: the model invoked one or more tools\n\t//   - `\"pause_turn\"`: we paused a long-running turn. You may provide the response\n\t//     back as-is in a subsequent request to let the model continue.\n\t//   - `\"refusal\"`: when streaming classifiers intervene to handle potential policy\n\t//     violations\n\t//\n\t// In non-streaming mode this value is always non-null. In streaming mode, it is\n\t// null in the `message_start` event and non-null otherwise.\n\t//\n\t// Any of \"end_turn\", \"max_tokens\", \"stop_sequence\", \"tool_use\", \"pause_turn\",\n\t// \"compaction\", \"refusal\", \"model_context_window_exceeded\".\n\tStopReason BetaStopReason `json:\"stop_reason\" api:\"required\"`\n\t// Which custom stop sequence was generated, if any.\n\t//\n\t// This value will be a non-null string if one of your custom stop sequences was\n\t// generated.\n\tStopSequence string `json:\"stop_sequence\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Messages, this is always `\"message\"`.\n\tType constant.Message `json:\"type\" api:\"required\"`\n\t// Billing and rate-limit usage.\n\t//\n\t// Anthropic's API bills and rate-limits by token counts, as tokens represent the\n\t// underlying cost to our systems.\n\t//\n\t// Under the hood, the API transforms requests into a format suitable for the\n\t// model. The model's output then goes through a parsing stage before becoming an\n\t// API response. As a result, the token counts in `usage` will not match one-to-one\n\t// with the exact visible content of an API request or response.\n\t//\n\t// For example, `output_tokens` will be non-zero, even for an empty string response\n\t// from Claude.\n\t//\n\t// Total input tokens in a request is the summation of `input_tokens`,\n\t// `cache_creation_input_tokens`, and `cache_read_input_tokens`.\n\tUsage BetaUsage `json:\"usage\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID                respjson.Field\n\t\tContainer         respjson.Field\n\t\tContent           respjson.Field\n\t\tContextManagement respjson.Field\n\t\tModel             respjson.Field\n\t\tRole              respjson.Field\n\t\tStopReason        respjson.Field\n\t\tStopSequence      respjson.Field\n\t\tType              respjson.Field\n\t\tUsage             respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessage) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n\ntype BetaMessageDeltaUsage struct {\n\t// The cumulative number of input tokens used to create the cache entry.\n\tCacheCreationInputTokens int64 `json:\"cache_creation_input_tokens\" api:\"required\"`\n\t// The cumulative number of input tokens read from the cache.\n\tCacheReadInputTokens int64 `json:\"cache_read_input_tokens\" api:\"required\"`\n\t// The cumulative number of input tokens which were used.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// Per-iteration token usage breakdown.\n\t//\n\t// Each entry represents one sampling iteration, with its own input/output token\n\t// counts and cache statistics. This allows you to:\n\t//\n\t// - Determine which iterations exceeded long context thresholds (>=200k tokens)\n\t// - Calculate the true context window size from the last iteration\n\t// - Understand token accumulation across server-side tool use loops\n\tIterations BetaIterationsUsage `json:\"iterations\" api:\"required\"`\n\t// The cumulative number of output tokens which were used.\n\tOutputTokens int64 `json:\"output_tokens\" api:\"required\"`\n\t// The number of server tool requests.\n\tServerToolUse BetaServerToolUsage `json:\"server_tool_use\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tIterations               respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tServerToolUse            respjson.Field\n\t\tExtraFields              map[string]respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageDeltaUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageDeltaUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Token usage for a sampling iteration.\ntype BetaMessageIterationUsage struct {\n\t// Breakdown of cached tokens by TTL\n\tCacheCreation BetaCacheCreation `json:\"cache_creation\" api:\"required\"`\n\t// The number of input tokens used to create the cache entry.\n\tCacheCreationInputTokens int64 `json:\"cache_creation_input_tokens\" api:\"required\"`\n\t// The number of input tokens read from the cache.\n\tCacheReadInputTokens int64 `json:\"cache_read_input_tokens\" api:\"required\"`\n\t// The number of input tokens which were used.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// The number of output tokens which were used.\n\tOutputTokens int64 `json:\"output_tokens\" api:\"required\"`\n\t// Usage for a sampling iteration\n\tType constant.Message `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCacheCreation            respjson.Field\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tType                     respjson.Field\n\t\tExtraFields              map[string]respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageIterationUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageIterationUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, Role are required.\ntype BetaMessageParam struct {\n\tContent []BetaContentBlockParamUnion `json:\"content,omitzero\" api:\"required\"`\n\t// Any of \"user\", \"assistant\".\n\tRole BetaMessageParamRole `json:\"role,omitzero\" api:\"required\"`\n\tparamObj\n}\n\nfunc NewBetaUserMessage(blocks ...BetaContentBlockParamUnion) BetaMessageParam {\n\treturn BetaMessageParam{\n\t\tRole:    BetaMessageParamRoleUser,\n\t\tContent: blocks,\n\t}\n}\n\nfunc (r BetaMessageParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMessageParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMessageParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageParamRole string\n\nconst (\n\tBetaMessageParamRoleUser      BetaMessageParamRole = \"user\"\n\tBetaMessageParamRoleAssistant BetaMessageParamRole = \"assistant\"\n)\n\ntype BetaMessageTokensCount struct {\n\t// Information about context management applied to the message.\n\tContextManagement BetaCountTokensContextManagementResponse `json:\"context_management\" api:\"required\"`\n\t// The total number of tokens across the provided list of messages, system prompt,\n\t// and tools.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContextManagement respjson.Field\n\t\tInputTokens       respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageTokensCount) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageTokensCount) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMetadataParam struct {\n\t// An external identifier for the user who is associated with the request.\n\t//\n\t// This should be a uuid, hash value, or other opaque identifier. Anthropic may use\n\t// this id to help detect abuse. Do not include any identifying information such as\n\t// name, email address, or phone number.\n\tUserID param.Opt[string] `json:\"user_id,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaMetadataParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMetadataParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMetadataParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaOutputConfigParam struct {\n\t// All possible effort levels.\n\t//\n\t// Any of \"low\", \"medium\", \"high\", \"max\".\n\tEffort BetaOutputConfigEffort `json:\"effort,omitzero\"`\n\t// A schema to specify Claude's output format in responses. See\n\t// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\tFormat BetaJSONOutputFormatParam `json:\"format,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaOutputConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaOutputConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaOutputConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// All possible effort levels.\ntype BetaOutputConfigEffort string\n\nconst (\n\tBetaOutputConfigEffortLow    BetaOutputConfigEffort = \"low\"\n\tBetaOutputConfigEffortMedium BetaOutputConfigEffort = \"medium\"\n\tBetaOutputConfigEffortHigh   BetaOutputConfigEffort = \"high\"\n\tBetaOutputConfigEffortMax    BetaOutputConfigEffort = \"max\"\n)\n\ntype BetaPlainTextSource struct {\n\tData      string             `json:\"data\" api:\"required\"`\n\tMediaType constant.TextPlain `json:\"media_type\" api:\"required\"`\n\tType      constant.Text      `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tMediaType   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaPlainTextSource) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaPlainTextSource) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this BetaPlainTextSource to a BetaPlainTextSourceParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// BetaPlainTextSourceParam.Overrides()\nfunc (r BetaPlainTextSource) ToParam() BetaPlainTextSourceParam {\n\treturn param.Override[BetaPlainTextSourceParam](json.RawMessage(r.RawJSON()))\n}\n\n// The properties Data, MediaType, Type are required.\ntype BetaPlainTextSourceParam struct {\n\tData string `json:\"data\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"text/plain\".\n\tMediaType constant.TextPlain `json:\"media_type\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"text\".\n\tType constant.Text `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaPlainTextSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaPlainTextSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaPlainTextSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawContentBlockDeltaUnion contains all possible properties and values from\n// [BetaTextDelta], [BetaInputJSONDelta], [BetaCitationsDelta],\n// [BetaThinkingDelta], [BetaSignatureDelta], [BetaCompactionContentBlockDelta].\n//\n// Use the [BetaRawContentBlockDeltaUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaRawContentBlockDeltaUnion struct {\n\t// This field is from variant [BetaTextDelta].\n\tText string `json:\"text\"`\n\t// Any of \"text_delta\", \"input_json_delta\", \"citations_delta\", \"thinking_delta\",\n\t// \"signature_delta\", \"compaction_delta\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaInputJSONDelta].\n\tPartialJSON string `json:\"partial_json\"`\n\t// This field is from variant [BetaCitationsDelta].\n\tCitation BetaCitationsDeltaCitationUnion `json:\"citation\"`\n\t// This field is from variant [BetaThinkingDelta].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [BetaSignatureDelta].\n\tSignature string `json:\"signature\"`\n\t// This field is from variant [BetaCompactionContentBlockDelta].\n\tContent string `json:\"content\"`\n\tJSON    struct {\n\t\tText        respjson.Field\n\t\tType        respjson.Field\n\t\tPartialJSON respjson.Field\n\t\tCitation    respjson.Field\n\t\tThinking    respjson.Field\n\t\tSignature   respjson.Field\n\t\tContent     respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// anyBetaRawContentBlockDelta is implemented by each variant of\n// [BetaRawContentBlockDeltaUnion] to add type safety for the return type of\n// [BetaRawContentBlockDeltaUnion.AsAny]\ntype anyBetaRawContentBlockDelta interface {\n\timplBetaRawContentBlockDeltaUnion()\n}\n\nfunc (BetaTextDelta) implBetaRawContentBlockDeltaUnion()                   {}\nfunc (BetaInputJSONDelta) implBetaRawContentBlockDeltaUnion()              {}\nfunc (BetaCitationsDelta) implBetaRawContentBlockDeltaUnion()              {}\nfunc (BetaThinkingDelta) implBetaRawContentBlockDeltaUnion()               {}\nfunc (BetaSignatureDelta) implBetaRawContentBlockDeltaUnion()              {}\nfunc (BetaCompactionContentBlockDelta) implBetaRawContentBlockDeltaUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaRawContentBlockDeltaUnion.AsAny().(type) {\n//\tcase anthropic.BetaTextDelta:\n//\tcase anthropic.BetaInputJSONDelta:\n//\tcase anthropic.BetaCitationsDelta:\n//\tcase anthropic.BetaThinkingDelta:\n//\tcase anthropic.BetaSignatureDelta:\n//\tcase anthropic.BetaCompactionContentBlockDelta:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaRawContentBlockDeltaUnion) AsAny() anyBetaRawContentBlockDelta {\n\tswitch u.Type {\n\tcase \"text_delta\":\n\t\treturn u.AsTextDelta()\n\tcase \"input_json_delta\":\n\t\treturn u.AsInputJSONDelta()\n\tcase \"citations_delta\":\n\t\treturn u.AsCitationsDelta()\n\tcase \"thinking_delta\":\n\t\treturn u.AsThinkingDelta()\n\tcase \"signature_delta\":\n\t\treturn u.AsSignatureDelta()\n\tcase \"compaction_delta\":\n\t\treturn u.AsCompactionDelta()\n\t}\n\treturn nil\n}\n\nfunc (u BetaRawContentBlockDeltaUnion) AsTextDelta() (v BetaTextDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockDeltaUnion) AsInputJSONDelta() (v BetaInputJSONDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockDeltaUnion) AsCitationsDelta() (v BetaCitationsDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockDeltaUnion) AsThinkingDelta() (v BetaThinkingDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockDeltaUnion) AsSignatureDelta() (v BetaSignatureDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockDeltaUnion) AsCompactionDelta() (v BetaCompactionContentBlockDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaRawContentBlockDeltaUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaRawContentBlockDeltaUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawContentBlockDeltaEvent struct {\n\tDelta BetaRawContentBlockDeltaUnion `json:\"delta\" api:\"required\"`\n\tIndex int64                         `json:\"index\" api:\"required\"`\n\tType  constant.ContentBlockDelta    `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tDelta       respjson.Field\n\t\tIndex       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawContentBlockDeltaEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawContentBlockDeltaEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawContentBlockStartEvent struct {\n\t// Response model for a file uploaded to the container.\n\tContentBlock BetaRawContentBlockStartEventContentBlockUnion `json:\"content_block\" api:\"required\"`\n\tIndex        int64                                          `json:\"index\" api:\"required\"`\n\tType         constant.ContentBlockStart                     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContentBlock respjson.Field\n\t\tIndex        respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawContentBlockStartEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawContentBlockStartEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawContentBlockStartEventContentBlockUnion contains all possible properties\n// and values from [BetaTextBlock], [BetaThinkingBlock],\n// [BetaRedactedThinkingBlock], [BetaToolUseBlock], [BetaServerToolUseBlock],\n// [BetaWebSearchToolResultBlock], [BetaWebFetchToolResultBlock],\n// [BetaCodeExecutionToolResultBlock], [BetaBashCodeExecutionToolResultBlock],\n// [BetaTextEditorCodeExecutionToolResultBlock], [BetaToolSearchToolResultBlock],\n// [BetaMCPToolUseBlock], [BetaMCPToolResultBlock], [BetaContainerUploadBlock],\n// [BetaCompactionBlock].\n//\n// Use the [BetaRawContentBlockStartEventContentBlockUnion.AsAny] method to switch\n// on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaRawContentBlockStartEventContentBlockUnion struct {\n\t// This field is from variant [BetaTextBlock].\n\tCitations []BetaTextCitationUnion `json:\"citations\"`\n\t// This field is from variant [BetaTextBlock].\n\tText string `json:\"text\"`\n\t// Any of \"text\", \"thinking\", \"redacted_thinking\", \"tool_use\", \"server_tool_use\",\n\t// \"web_search_tool_result\", \"web_fetch_tool_result\", \"code_execution_tool_result\",\n\t// \"bash_code_execution_tool_result\", \"text_editor_code_execution_tool_result\",\n\t// \"tool_search_tool_result\", \"mcp_tool_use\", \"mcp_tool_result\",\n\t// \"container_upload\", \"compaction\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaThinkingBlock].\n\tSignature string `json:\"signature\"`\n\t// This field is from variant [BetaThinkingBlock].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [BetaRedactedThinkingBlock].\n\tData  string `json:\"data\"`\n\tID    string `json:\"id\"`\n\tInput any    `json:\"input\"`\n\tName  string `json:\"name\"`\n\t// This field is a union of [BetaToolUseBlockCallerUnion],\n\t// [BetaServerToolUseBlockCallerUnion], [BetaWebSearchToolResultBlockCallerUnion],\n\t// [BetaWebFetchToolResultBlockCallerUnion]\n\tCaller BetaRawContentBlockStartEventContentBlockUnionCaller `json:\"caller\"`\n\t// This field is a union of [BetaWebSearchToolResultBlockContentUnion],\n\t// [BetaWebFetchToolResultBlockContentUnion],\n\t// [BetaCodeExecutionToolResultBlockContentUnion],\n\t// [BetaBashCodeExecutionToolResultBlockContentUnion],\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion],\n\t// [BetaToolSearchToolResultBlockContentUnion],\n\t// [BetaMCPToolResultBlockContentUnion], [string]\n\tContent   BetaRawContentBlockStartEventContentBlockUnionContent `json:\"content\"`\n\tToolUseID string                                                `json:\"tool_use_id\"`\n\t// This field is from variant [BetaMCPToolUseBlock].\n\tServerName string `json:\"server_name\"`\n\t// This field is from variant [BetaMCPToolResultBlock].\n\tIsError bool `json:\"is_error\"`\n\t// This field is from variant [BetaContainerUploadBlock].\n\tFileID string `json:\"file_id\"`\n\tJSON   struct {\n\t\tCitations  respjson.Field\n\t\tText       respjson.Field\n\t\tType       respjson.Field\n\t\tSignature  respjson.Field\n\t\tThinking   respjson.Field\n\t\tData       respjson.Field\n\t\tID         respjson.Field\n\t\tInput      respjson.Field\n\t\tName       respjson.Field\n\t\tCaller     respjson.Field\n\t\tContent    respjson.Field\n\t\tToolUseID  respjson.Field\n\t\tServerName respjson.Field\n\t\tIsError    respjson.Field\n\t\tFileID     respjson.Field\n\t\traw        string\n\t} `json:\"-\"`\n}\n\n// anyBetaRawContentBlockStartEventContentBlock is implemented by each variant of\n// [BetaRawContentBlockStartEventContentBlockUnion] to add type safety for the\n// return type of [BetaRawContentBlockStartEventContentBlockUnion.AsAny]\ntype anyBetaRawContentBlockStartEventContentBlock interface {\n\timplBetaRawContentBlockStartEventContentBlockUnion()\n}\n\nfunc (BetaTextBlock) implBetaRawContentBlockStartEventContentBlockUnion()                        {}\nfunc (BetaThinkingBlock) implBetaRawContentBlockStartEventContentBlockUnion()                    {}\nfunc (BetaRedactedThinkingBlock) implBetaRawContentBlockStartEventContentBlockUnion()            {}\nfunc (BetaToolUseBlock) implBetaRawContentBlockStartEventContentBlockUnion()                     {}\nfunc (BetaServerToolUseBlock) implBetaRawContentBlockStartEventContentBlockUnion()               {}\nfunc (BetaWebSearchToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion()         {}\nfunc (BetaWebFetchToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion()          {}\nfunc (BetaCodeExecutionToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion()     {}\nfunc (BetaBashCodeExecutionToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion() {}\nfunc (BetaTextEditorCodeExecutionToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion() {\n}\nfunc (BetaToolSearchToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion() {}\nfunc (BetaMCPToolUseBlock) implBetaRawContentBlockStartEventContentBlockUnion()           {}\nfunc (BetaMCPToolResultBlock) implBetaRawContentBlockStartEventContentBlockUnion()        {}\nfunc (BetaContainerUploadBlock) implBetaRawContentBlockStartEventContentBlockUnion()      {}\nfunc (BetaCompactionBlock) implBetaRawContentBlockStartEventContentBlockUnion()           {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaRawContentBlockStartEventContentBlockUnion.AsAny().(type) {\n//\tcase anthropic.BetaTextBlock:\n//\tcase anthropic.BetaThinkingBlock:\n//\tcase anthropic.BetaRedactedThinkingBlock:\n//\tcase anthropic.BetaToolUseBlock:\n//\tcase anthropic.BetaServerToolUseBlock:\n//\tcase anthropic.BetaWebSearchToolResultBlock:\n//\tcase anthropic.BetaWebFetchToolResultBlock:\n//\tcase anthropic.BetaCodeExecutionToolResultBlock:\n//\tcase anthropic.BetaBashCodeExecutionToolResultBlock:\n//\tcase anthropic.BetaTextEditorCodeExecutionToolResultBlock:\n//\tcase anthropic.BetaToolSearchToolResultBlock:\n//\tcase anthropic.BetaMCPToolUseBlock:\n//\tcase anthropic.BetaMCPToolResultBlock:\n//\tcase anthropic.BetaContainerUploadBlock:\n//\tcase anthropic.BetaCompactionBlock:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsAny() anyBetaRawContentBlockStartEventContentBlock {\n\tswitch u.Type {\n\tcase \"text\":\n\t\treturn u.AsText()\n\tcase \"thinking\":\n\t\treturn u.AsThinking()\n\tcase \"redacted_thinking\":\n\t\treturn u.AsRedactedThinking()\n\tcase \"tool_use\":\n\t\treturn u.AsToolUse()\n\tcase \"server_tool_use\":\n\t\treturn u.AsServerToolUse()\n\tcase \"web_search_tool_result\":\n\t\treturn u.AsWebSearchToolResult()\n\tcase \"web_fetch_tool_result\":\n\t\treturn u.AsWebFetchToolResult()\n\tcase \"code_execution_tool_result\":\n\t\treturn u.AsCodeExecutionToolResult()\n\tcase \"bash_code_execution_tool_result\":\n\t\treturn u.AsBashCodeExecutionToolResult()\n\tcase \"text_editor_code_execution_tool_result\":\n\t\treturn u.AsTextEditorCodeExecutionToolResult()\n\tcase \"tool_search_tool_result\":\n\t\treturn u.AsToolSearchToolResult()\n\tcase \"mcp_tool_use\":\n\t\treturn u.AsMCPToolUse()\n\tcase \"mcp_tool_result\":\n\t\treturn u.AsMCPToolResult()\n\tcase \"container_upload\":\n\t\treturn u.AsContainerUpload()\n\tcase \"compaction\":\n\t\treturn u.AsCompaction()\n\t}\n\treturn nil\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsText() (v BetaTextBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsThinking() (v BetaThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v BetaRedactedThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsToolUse() (v BetaToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsServerToolUse() (v BetaServerToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v BetaWebSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsWebFetchToolResult() (v BetaWebFetchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsBashCodeExecutionToolResult() (v BetaBashCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v BetaTextEditorCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsToolSearchToolResult() (v BetaToolSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolUse() (v BetaMCPToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) AsCompaction() (v BetaCompactionBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaRawContentBlockStartEventContentBlockUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaRawContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawContentBlockStartEventContentBlockUnionCaller is an implicit subunion of\n// [BetaRawContentBlockStartEventContentBlockUnion].\n// BetaRawContentBlockStartEventContentBlockUnionCaller provides convenient access\n// to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaRawContentBlockStartEventContentBlockUnion].\ntype BetaRawContentBlockStartEventContentBlockUnionCaller struct {\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaRawContentBlockStartEventContentBlockUnionCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawContentBlockStartEventContentBlockUnionContent is an implicit subunion of\n// [BetaRawContentBlockStartEventContentBlockUnion].\n// BetaRawContentBlockStartEventContentBlockUnionContent provides convenient access\n// to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaRawContentBlockStartEventContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfBetaWebSearchResultBlockArray OfString\n// OfBetaMCPToolResultBlockContent]\ntype BetaRawContentBlockStartEventContentBlockUnionContent struct {\n\t// This field will be present if the value is a [[]BetaWebSearchResultBlock]\n\t// instead of an object.\n\tOfBetaWebSearchResultBlockArray []BetaWebSearchResultBlock `json:\",inline\"`\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field will be present if the value is a [[]BetaTextBlock] instead of an\n\t// object.\n\tOfBetaMCPToolResultBlockContent []BetaTextBlock `json:\",inline\"`\n\tErrorCode                       string          `json:\"error_code\"`\n\tType                            string          `json:\"type\"`\n\t// This field is a union of [BetaDocumentBlock], [[]BetaCodeExecutionOutputBlock],\n\t// [[]BetaCodeExecutionOutputBlock], [[]BetaBashCodeExecutionOutputBlock], [string]\n\tContent BetaRawContentBlockStartEventContentBlockUnionContentContent `json:\"content\"`\n\t// This field is from variant [BetaWebFetchToolResultBlockContentUnion].\n\tRetrievedAt string `json:\"retrieved_at\"`\n\t// This field is from variant [BetaWebFetchToolResultBlockContentUnion].\n\tURL        string `json:\"url\"`\n\tReturnCode int64  `json:\"return_code\"`\n\tStderr     string `json:\"stderr\"`\n\tStdout     string `json:\"stdout\"`\n\t// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].\n\tEncryptedStdout string `json:\"encrypted_stdout\"`\n\tErrorMessage    string `json:\"error_message\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tFileType BetaTextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tNumLines int64 `json:\"num_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tStartLine int64 `json:\"start_line\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tTotalLines int64 `json:\"total_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tIsFileUpdate bool `json:\"is_file_update\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tLines []string `json:\"lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewLines int64 `json:\"new_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewStart int64 `json:\"new_start\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldLines int64 `json:\"old_lines\"`\n\t// This field is from variant\n\t// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldStart int64 `json:\"old_start\"`\n\t// This field is from variant [BetaToolSearchToolResultBlockContentUnion].\n\tToolReferences []BetaToolReferenceBlock `json:\"tool_references\"`\n\tJSON           struct {\n\t\tOfBetaWebSearchResultBlockArray respjson.Field\n\t\tOfString                        respjson.Field\n\t\tOfBetaMCPToolResultBlockContent respjson.Field\n\t\tErrorCode                       respjson.Field\n\t\tType                            respjson.Field\n\t\tContent                         respjson.Field\n\t\tRetrievedAt                     respjson.Field\n\t\tURL                             respjson.Field\n\t\tReturnCode                      respjson.Field\n\t\tStderr                          respjson.Field\n\t\tStdout                          respjson.Field\n\t\tEncryptedStdout                 respjson.Field\n\t\tErrorMessage                    respjson.Field\n\t\tFileType                        respjson.Field\n\t\tNumLines                        respjson.Field\n\t\tStartLine                       respjson.Field\n\t\tTotalLines                      respjson.Field\n\t\tIsFileUpdate                    respjson.Field\n\t\tLines                           respjson.Field\n\t\tNewLines                        respjson.Field\n\t\tNewStart                        respjson.Field\n\t\tOldLines                        respjson.Field\n\t\tOldStart                        respjson.Field\n\t\tToolReferences                  respjson.Field\n\t\traw                             string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaRawContentBlockStartEventContentBlockUnionContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawContentBlockStartEventContentBlockUnionContentContent is an implicit\n// subunion of [BetaRawContentBlockStartEventContentBlockUnion].\n// BetaRawContentBlockStartEventContentBlockUnionContentContent provides convenient\n// access to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaRawContentBlockStartEventContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfContent OfString]\ntype BetaRawContentBlockStartEventContentBlockUnionContentContent struct {\n\t// This field will be present if the value is a [[]BetaCodeExecutionOutputBlock]\n\t// instead of an object.\n\tOfContent []BetaCodeExecutionOutputBlock `json:\",inline\"`\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tCitations BetaCitationConfig `json:\"citations\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tSource BetaDocumentBlockSourceUnion `json:\"source\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tTitle string `json:\"title\"`\n\t// This field is from variant [BetaDocumentBlock].\n\tType constant.Document `json:\"type\"`\n\tJSON struct {\n\t\tOfContent respjson.Field\n\t\tOfString  respjson.Field\n\t\tCitations respjson.Field\n\t\tSource    respjson.Field\n\t\tTitle     respjson.Field\n\t\tType      respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaRawContentBlockStartEventContentBlockUnionContentContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawContentBlockStopEvent struct {\n\tIndex int64                     `json:\"index\" api:\"required\"`\n\tType  constant.ContentBlockStop `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tIndex       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawContentBlockStopEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawContentBlockStopEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawMessageDeltaEvent struct {\n\t// Information about context management strategies applied during the request\n\tContextManagement BetaContextManagementResponse `json:\"context_management\" api:\"required\"`\n\tDelta             BetaRawMessageDeltaEventDelta `json:\"delta\" api:\"required\"`\n\tType              constant.MessageDelta         `json:\"type\" api:\"required\"`\n\t// Billing and rate-limit usage.\n\t//\n\t// Anthropic's API bills and rate-limits by token counts, as tokens represent the\n\t// underlying cost to our systems.\n\t//\n\t// Under the hood, the API transforms requests into a format suitable for the\n\t// model. The model's output then goes through a parsing stage before becoming an\n\t// API response. As a result, the token counts in `usage` will not match one-to-one\n\t// with the exact visible content of an API request or response.\n\t//\n\t// For example, `output_tokens` will be non-zero, even for an empty string response\n\t// from Claude.\n\t//\n\t// Total input tokens in a request is the summation of `input_tokens`,\n\t// `cache_creation_input_tokens`, and `cache_read_input_tokens`.\n\tUsage BetaMessageDeltaUsage `json:\"usage\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContextManagement respjson.Field\n\t\tDelta             respjson.Field\n\t\tType              respjson.Field\n\t\tUsage             respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawMessageDeltaEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawMessageDeltaEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawMessageDeltaEventDelta struct {\n\t// Information about the container used in the request (for the code execution\n\t// tool)\n\tContainer BetaContainer `json:\"container\" api:\"required\"`\n\t// Any of \"end_turn\", \"max_tokens\", \"stop_sequence\", \"tool_use\", \"pause_turn\",\n\t// \"compaction\", \"refusal\", \"model_context_window_exceeded\".\n\tStopReason   BetaStopReason `json:\"stop_reason\" api:\"required\"`\n\tStopSequence string         `json:\"stop_sequence\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContainer    respjson.Field\n\t\tStopReason   respjson.Field\n\t\tStopSequence respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawMessageDeltaEventDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawMessageDeltaEventDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawMessageStartEvent struct {\n\tMessage BetaMessage           `json:\"message\" api:\"required\"`\n\tType    constant.MessageStart `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawMessageStartEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawMessageStartEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRawMessageStopEvent struct {\n\tType constant.MessageStop `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRawMessageStopEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRawMessageStopEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawMessageStreamEventUnion contains all possible properties and values from\n// [BetaRawMessageStartEvent], [BetaRawMessageDeltaEvent],\n// [BetaRawMessageStopEvent], [BetaRawContentBlockStartEvent],\n// [BetaRawContentBlockDeltaEvent], [BetaRawContentBlockStopEvent].\n//\n// Use the [BetaRawMessageStreamEventUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaRawMessageStreamEventUnion struct {\n\t// This field is from variant [BetaRawMessageStartEvent].\n\tMessage BetaMessage `json:\"message\"`\n\t// Any of \"message_start\", \"message_delta\", \"message_stop\", \"content_block_start\",\n\t// \"content_block_delta\", \"content_block_stop\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaRawMessageDeltaEvent].\n\tContextManagement BetaContextManagementResponse `json:\"context_management\"`\n\t// This field is a union of [BetaRawMessageDeltaEventDelta],\n\t// [BetaRawContentBlockDeltaUnion]\n\tDelta BetaRawMessageStreamEventUnionDelta `json:\"delta\"`\n\t// This field is from variant [BetaRawMessageDeltaEvent].\n\tUsage BetaMessageDeltaUsage `json:\"usage\"`\n\t// This field is from variant [BetaRawContentBlockStartEvent].\n\tContentBlock BetaRawContentBlockStartEventContentBlockUnion `json:\"content_block\"`\n\tIndex        int64                                          `json:\"index\"`\n\tJSON         struct {\n\t\tMessage           respjson.Field\n\t\tType              respjson.Field\n\t\tContextManagement respjson.Field\n\t\tDelta             respjson.Field\n\t\tUsage             respjson.Field\n\t\tContentBlock      respjson.Field\n\t\tIndex             respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// anyBetaRawMessageStreamEvent is implemented by each variant of\n// [BetaRawMessageStreamEventUnion] to add type safety for the return type of\n// [BetaRawMessageStreamEventUnion.AsAny]\ntype anyBetaRawMessageStreamEvent interface {\n\timplBetaRawMessageStreamEventUnion()\n}\n\nfunc (BetaRawMessageStartEvent) implBetaRawMessageStreamEventUnion()      {}\nfunc (BetaRawMessageDeltaEvent) implBetaRawMessageStreamEventUnion()      {}\nfunc (BetaRawMessageStopEvent) implBetaRawMessageStreamEventUnion()       {}\nfunc (BetaRawContentBlockStartEvent) implBetaRawMessageStreamEventUnion() {}\nfunc (BetaRawContentBlockDeltaEvent) implBetaRawMessageStreamEventUnion() {}\nfunc (BetaRawContentBlockStopEvent) implBetaRawMessageStreamEventUnion()  {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaRawMessageStreamEventUnion.AsAny().(type) {\n//\tcase anthropic.BetaRawMessageStartEvent:\n//\tcase anthropic.BetaRawMessageDeltaEvent:\n//\tcase anthropic.BetaRawMessageStopEvent:\n//\tcase anthropic.BetaRawContentBlockStartEvent:\n//\tcase anthropic.BetaRawContentBlockDeltaEvent:\n//\tcase anthropic.BetaRawContentBlockStopEvent:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaRawMessageStreamEventUnion) AsAny() anyBetaRawMessageStreamEvent {\n\tswitch u.Type {\n\tcase \"message_start\":\n\t\treturn u.AsMessageStart()\n\tcase \"message_delta\":\n\t\treturn u.AsMessageDelta()\n\tcase \"message_stop\":\n\t\treturn u.AsMessageStop()\n\tcase \"content_block_start\":\n\t\treturn u.AsContentBlockStart()\n\tcase \"content_block_delta\":\n\t\treturn u.AsContentBlockDelta()\n\tcase \"content_block_stop\":\n\t\treturn u.AsContentBlockStop()\n\t}\n\treturn nil\n}\n\nfunc (u BetaRawMessageStreamEventUnion) AsMessageStart() (v BetaRawMessageStartEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawMessageStreamEventUnion) AsMessageDelta() (v BetaRawMessageDeltaEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawMessageStreamEventUnion) AsMessageStop() (v BetaRawMessageStopEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawMessageStreamEventUnion) AsContentBlockStart() (v BetaRawContentBlockStartEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawMessageStreamEventUnion) AsContentBlockDelta() (v BetaRawContentBlockDeltaEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaRawMessageStreamEventUnion) AsContentBlockStop() (v BetaRawContentBlockStopEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaRawMessageStreamEventUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaRawMessageStreamEventUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaRawMessageStreamEventUnionDelta is an implicit subunion of\n// [BetaRawMessageStreamEventUnion]. BetaRawMessageStreamEventUnionDelta provides\n// convenient access to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [BetaRawMessageStreamEventUnion].\ntype BetaRawMessageStreamEventUnionDelta struct {\n\t// This field is from variant [BetaRawMessageDeltaEventDelta].\n\tContainer BetaContainer `json:\"container\"`\n\t// This field is from variant [BetaRawMessageDeltaEventDelta].\n\tStopReason BetaStopReason `json:\"stop_reason\"`\n\t// This field is from variant [BetaRawMessageDeltaEventDelta].\n\tStopSequence string `json:\"stop_sequence\"`\n\t// This field is from variant [BetaRawContentBlockDeltaUnion].\n\tText string `json:\"text\"`\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaRawContentBlockDeltaUnion].\n\tPartialJSON string `json:\"partial_json\"`\n\t// This field is from variant [BetaRawContentBlockDeltaUnion].\n\tCitation BetaCitationsDeltaCitationUnion `json:\"citation\"`\n\t// This field is from variant [BetaRawContentBlockDeltaUnion].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [BetaRawContentBlockDeltaUnion].\n\tSignature string `json:\"signature\"`\n\t// This field is from variant [BetaRawContentBlockDeltaUnion].\n\tContent string `json:\"content\"`\n\tJSON    struct {\n\t\tContainer    respjson.Field\n\t\tStopReason   respjson.Field\n\t\tStopSequence respjson.Field\n\t\tText         respjson.Field\n\t\tType         respjson.Field\n\t\tPartialJSON  respjson.Field\n\t\tCitation     respjson.Field\n\t\tThinking     respjson.Field\n\t\tSignature    respjson.Field\n\t\tContent      respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\nfunc (r *BetaRawMessageStreamEventUnionDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaRedactedThinkingBlock struct {\n\tData string                    `json:\"data\" api:\"required\"`\n\tType constant.RedactedThinking `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaRedactedThinkingBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaRedactedThinkingBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Data, Type are required.\ntype BetaRedactedThinkingBlockParam struct {\n\tData string `json:\"data\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"redacted_thinking\".\n\tType constant.RedactedThinking `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaRedactedThinkingBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaRedactedThinkingBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaRedactedThinkingBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Source, Type are required.\ntype BetaRequestDocumentBlockParam struct {\n\tSource  BetaRequestDocumentBlockSourceUnionParam `json:\"source,omitzero\" api:\"required\"`\n\tContext param.Opt[string]                        `json:\"context,omitzero\"`\n\tTitle   param.Opt[string]                        `json:\"title,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tCitations    BetaCitationsConfigParam       `json:\"citations,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"document\".\n\tType constant.Document `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaRequestDocumentBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaRequestDocumentBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaRequestDocumentBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaRequestDocumentBlockSourceUnionParam struct {\n\tOfBase64  *BetaBase64PDFSourceParam    `json:\",omitzero,inline\"`\n\tOfText    *BetaPlainTextSourceParam    `json:\",omitzero,inline\"`\n\tOfContent *BetaContentBlockSourceParam `json:\",omitzero,inline\"`\n\tOfURL     *BetaURLPDFSourceParam       `json:\",omitzero,inline\"`\n\tOfFile    *BetaFileDocumentSourceParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaRequestDocumentBlockSourceUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfBase64,\n\t\tu.OfText,\n\t\tu.OfContent,\n\t\tu.OfURL,\n\t\tu.OfFile)\n}\nfunc (u *BetaRequestDocumentBlockSourceUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaRequestDocumentBlockSourceUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfBase64) {\n\t\treturn u.OfBase64\n\t} else if !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfContent) {\n\t\treturn u.OfContent\n\t} else if !param.IsOmitted(u.OfURL) {\n\t\treturn u.OfURL\n\t} else if !param.IsOmitted(u.OfFile) {\n\t\treturn u.OfFile\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaRequestDocumentBlockSourceUnionParam) GetContent() *BetaContentBlockSourceContentUnionParam {\n\tif vt := u.OfContent; vt != nil {\n\t\treturn &vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaRequestDocumentBlockSourceUnionParam) GetURL() *string {\n\tif vt := u.OfURL; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaRequestDocumentBlockSourceUnionParam) GetFileID() *string {\n\tif vt := u.OfFile; vt != nil {\n\t\treturn &vt.FileID\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaRequestDocumentBlockSourceUnionParam) GetData() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.Data)\n\t} else if vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Data)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaRequestDocumentBlockSourceUnionParam) GetMediaType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.MediaType)\n\t} else if vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.MediaType)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaRequestDocumentBlockSourceUnionParam) GetType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfContent; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfURL; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfFile; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BetaRequestMCPServerToolConfigurationParam struct {\n\tEnabled      param.Opt[bool] `json:\"enabled,omitzero\"`\n\tAllowedTools []string        `json:\"allowed_tools,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaRequestMCPServerToolConfigurationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaRequestMCPServerToolConfigurationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaRequestMCPServerToolConfigurationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type, URL are required.\ntype BetaRequestMCPServerURLDefinitionParam struct {\n\tName               string                                     `json:\"name\" api:\"required\"`\n\tURL                string                                     `json:\"url\" api:\"required\"`\n\tAuthorizationToken param.Opt[string]                          `json:\"authorization_token,omitzero\"`\n\tToolConfiguration  BetaRequestMCPServerToolConfigurationParam `json:\"tool_configuration,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"url\".\n\tType constant.URL `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaRequestMCPServerURLDefinitionParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaRequestMCPServerURLDefinitionParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaRequestMCPServerURLDefinitionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ToolUseID, Type are required.\ntype BetaRequestMCPToolResultBlockParam struct {\n\tToolUseID string          `json:\"tool_use_id\" api:\"required\"`\n\tIsError   param.Opt[bool] `json:\"is_error,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam                 `json:\"cache_control,omitzero\"`\n\tContent      BetaRequestMCPToolResultBlockParamContentUnion `json:\"content,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"mcp_tool_result\".\n\tType constant.MCPToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaRequestMCPToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaRequestMCPToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaRequestMCPToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaRequestMCPToolResultBlockParamContentUnion struct {\n\tOfString                        param.Opt[string]    `json:\",omitzero,inline\"`\n\tOfBetaMCPToolResultBlockContent []BetaTextBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaRequestMCPToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfString, u.OfBetaMCPToolResultBlockContent)\n}\nfunc (u *BetaRequestMCPToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaRequestMCPToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t} else if !param.IsOmitted(u.OfBetaMCPToolResultBlockContent) {\n\t\treturn &u.OfBetaMCPToolResultBlockContent\n\t}\n\treturn nil\n}\n\n// The properties Content, Source, Title, Type are required.\ntype BetaSearchResultBlockParam struct {\n\tContent []BetaTextBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tSource  string               `json:\"source\" api:\"required\"`\n\tTitle   string               `json:\"title\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tCitations    BetaCitationsConfigParam       `json:\"citations,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"search_result\".\n\tType constant.SearchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaSearchResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaSearchResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaSearchResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Tool invocation generated by a server-side tool.\ntype BetaServerToolCaller struct {\n\tToolID string                         `json:\"tool_id\" api:\"required\"`\n\tType   constant.CodeExecution20250825 `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaServerToolCaller) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaServerToolCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this BetaServerToolCaller to a BetaServerToolCallerParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// BetaServerToolCallerParam.Overrides()\nfunc (r BetaServerToolCaller) ToParam() BetaServerToolCallerParam {\n\treturn param.Override[BetaServerToolCallerParam](json.RawMessage(r.RawJSON()))\n}\n\n// Tool invocation generated by a server-side tool.\n//\n// The properties ToolID, Type are required.\ntype BetaServerToolCallerParam struct {\n\tToolID string `json:\"tool_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20250825\".\n\tType constant.CodeExecution20250825 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaServerToolCallerParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaServerToolCallerParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaServerToolCallerParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaServerToolCaller20260120 struct {\n\tToolID string                         `json:\"tool_id\" api:\"required\"`\n\tType   constant.CodeExecution20260120 `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaServerToolCaller20260120) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaServerToolCaller20260120) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this BetaServerToolCaller20260120 to a\n// BetaServerToolCaller20260120Param.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// BetaServerToolCaller20260120Param.Overrides()\nfunc (r BetaServerToolCaller20260120) ToParam() BetaServerToolCaller20260120Param {\n\treturn param.Override[BetaServerToolCaller20260120Param](json.RawMessage(r.RawJSON()))\n}\n\n// The properties ToolID, Type are required.\ntype BetaServerToolCaller20260120Param struct {\n\tToolID string `json:\"tool_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20260120\".\n\tType constant.CodeExecution20260120 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaServerToolCaller20260120Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaServerToolCaller20260120Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaServerToolCaller20260120Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaServerToolUsage struct {\n\t// The number of web fetch tool requests.\n\tWebFetchRequests int64 `json:\"web_fetch_requests\" api:\"required\"`\n\t// The number of web search tool requests.\n\tWebSearchRequests int64 `json:\"web_search_requests\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tWebFetchRequests  respjson.Field\n\t\tWebSearchRequests respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaServerToolUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaServerToolUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaServerToolUseBlock struct {\n\tID    string `json:\"id\" api:\"required\"`\n\tInput any    `json:\"input\" api:\"required\"`\n\t// Any of \"web_search\", \"web_fetch\", \"code_execution\", \"bash_code_execution\",\n\t// \"text_editor_code_execution\", \"tool_search_tool_regex\", \"tool_search_tool_bm25\".\n\tName BetaServerToolUseBlockName `json:\"name\" api:\"required\"`\n\tType constant.ServerToolUse     `json:\"type\" api:\"required\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaServerToolUseBlockCallerUnion `json:\"caller\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tInput       respjson.Field\n\t\tName        respjson.Field\n\t\tType        respjson.Field\n\t\tCaller      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaServerToolUseBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaServerToolUseBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaServerToolUseBlockName string\n\nconst (\n\tBetaServerToolUseBlockNameWebSearch               BetaServerToolUseBlockName = \"web_search\"\n\tBetaServerToolUseBlockNameWebFetch                BetaServerToolUseBlockName = \"web_fetch\"\n\tBetaServerToolUseBlockNameCodeExecution           BetaServerToolUseBlockName = \"code_execution\"\n\tBetaServerToolUseBlockNameBashCodeExecution       BetaServerToolUseBlockName = \"bash_code_execution\"\n\tBetaServerToolUseBlockNameTextEditorCodeExecution BetaServerToolUseBlockName = \"text_editor_code_execution\"\n\tBetaServerToolUseBlockNameToolSearchToolRegex     BetaServerToolUseBlockName = \"tool_search_tool_regex\"\n\tBetaServerToolUseBlockNameToolSearchToolBm25      BetaServerToolUseBlockName = \"tool_search_tool_bm25\"\n)\n\n// BetaServerToolUseBlockCallerUnion contains all possible properties and values\n// from [BetaDirectCaller], [BetaServerToolCaller], [BetaServerToolCaller20260120].\n//\n// Use the [BetaServerToolUseBlockCallerUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaServerToolUseBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyBetaServerToolUseBlockCaller is implemented by each variant of\n// [BetaServerToolUseBlockCallerUnion] to add type safety for the return type of\n// [BetaServerToolUseBlockCallerUnion.AsAny]\ntype anyBetaServerToolUseBlockCaller interface {\n\timplBetaServerToolUseBlockCallerUnion()\n}\n\nfunc (BetaDirectCaller) implBetaServerToolUseBlockCallerUnion()             {}\nfunc (BetaServerToolCaller) implBetaServerToolUseBlockCallerUnion()         {}\nfunc (BetaServerToolCaller20260120) implBetaServerToolUseBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaServerToolUseBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.BetaDirectCaller:\n//\tcase anthropic.BetaServerToolCaller:\n//\tcase anthropic.BetaServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaServerToolUseBlockCallerUnion) AsAny() anyBetaServerToolUseBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u BetaServerToolUseBlockCallerUnion) AsDirect() (v BetaDirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaServerToolUseBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaServerToolUseBlockCallerUnion) AsCodeExecution20260120() (v BetaServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaServerToolUseBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaServerToolUseBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ID, Input, Name, Type are required.\ntype BetaServerToolUseBlockParam struct {\n\tID    string `json:\"id\" api:\"required\"`\n\tInput any    `json:\"input,omitzero\" api:\"required\"`\n\t// Any of \"web_search\", \"web_fetch\", \"code_execution\", \"bash_code_execution\",\n\t// \"text_editor_code_execution\", \"tool_search_tool_regex\", \"tool_search_tool_bm25\".\n\tName BetaServerToolUseBlockParamName `json:\"name,omitzero\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaServerToolUseBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"server_tool_use\".\n\tType constant.ServerToolUse `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaServerToolUseBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaServerToolUseBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaServerToolUseBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaServerToolUseBlockParamName string\n\nconst (\n\tBetaServerToolUseBlockParamNameWebSearch               BetaServerToolUseBlockParamName = \"web_search\"\n\tBetaServerToolUseBlockParamNameWebFetch                BetaServerToolUseBlockParamName = \"web_fetch\"\n\tBetaServerToolUseBlockParamNameCodeExecution           BetaServerToolUseBlockParamName = \"code_execution\"\n\tBetaServerToolUseBlockParamNameBashCodeExecution       BetaServerToolUseBlockParamName = \"bash_code_execution\"\n\tBetaServerToolUseBlockParamNameTextEditorCodeExecution BetaServerToolUseBlockParamName = \"text_editor_code_execution\"\n\tBetaServerToolUseBlockParamNameToolSearchToolRegex     BetaServerToolUseBlockParamName = \"tool_search_tool_regex\"\n\tBetaServerToolUseBlockParamNameToolSearchToolBm25      BetaServerToolUseBlockParamName = \"tool_search_tool_bm25\"\n)\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaServerToolUseBlockParamCallerUnion struct {\n\tOfDirect                *BetaDirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *BetaServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *BetaServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaServerToolUseBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *BetaServerToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaServerToolUseBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaServerToolUseBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaServerToolUseBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\ntype BetaSignatureDelta struct {\n\tSignature string                  `json:\"signature\" api:\"required\"`\n\tType      constant.SignatureDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSignature   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSignatureDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSignatureDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// A skill that was loaded in a container (response model).\ntype BetaSkill struct {\n\t// Skill ID\n\tSkillID string `json:\"skill_id\" api:\"required\"`\n\t// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)\n\t//\n\t// Any of \"anthropic\", \"custom\".\n\tType BetaSkillType `json:\"type\" api:\"required\"`\n\t// Skill version or 'latest' for most recent version\n\tVersion string `json:\"version\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSkillID     respjson.Field\n\t\tType        respjson.Field\n\t\tVersion     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkill) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkill) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)\ntype BetaSkillType string\n\nconst (\n\tBetaSkillTypeAnthropic BetaSkillType = \"anthropic\"\n\tBetaSkillTypeCustom    BetaSkillType = \"custom\"\n)\n\n// Specification for a skill to be loaded in a container (request model).\n//\n// The properties SkillID, Type are required.\ntype BetaSkillParams struct {\n\t// Skill ID\n\tSkillID string `json:\"skill_id\" api:\"required\"`\n\t// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)\n\t//\n\t// Any of \"anthropic\", \"custom\".\n\tType BetaSkillParamsType `json:\"type,omitzero\" api:\"required\"`\n\t// Skill version or 'latest' for most recent version\n\tVersion param.Opt[string] `json:\"version,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaSkillParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaSkillParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaSkillParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)\ntype BetaSkillParamsType string\n\nconst (\n\tBetaSkillParamsTypeAnthropic BetaSkillParamsType = \"anthropic\"\n\tBetaSkillParamsTypeCustom    BetaSkillParamsType = \"custom\"\n)\n\ntype BetaStopReason string\n\nconst (\n\tBetaStopReasonEndTurn                    BetaStopReason = \"end_turn\"\n\tBetaStopReasonMaxTokens                  BetaStopReason = \"max_tokens\"\n\tBetaStopReasonStopSequence               BetaStopReason = \"stop_sequence\"\n\tBetaStopReasonToolUse                    BetaStopReason = \"tool_use\"\n\tBetaStopReasonPauseTurn                  BetaStopReason = \"pause_turn\"\n\tBetaStopReasonCompaction                 BetaStopReason = \"compaction\"\n\tBetaStopReasonRefusal                    BetaStopReason = \"refusal\"\n\tBetaStopReasonModelContextWindowExceeded BetaStopReason = \"model_context_window_exceeded\"\n)\n\ntype BetaTextBlock struct {\n\t// Citations supporting the text block.\n\t//\n\t// The type of citation returned will depend on the type of document being cited.\n\t// Citing a PDF results in `page_location`, plain text results in `char_location`,\n\t// and content document results in `content_block_location`.\n\tCitations []BetaTextCitationUnion `json:\"citations\" api:\"required\"`\n\tText      string                  `json:\"text\" api:\"required\"`\n\tType      constant.Text           `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitations   respjson.Field\n\t\tText        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Text, Type are required.\ntype BetaTextBlockParam struct {\n\tText      string                       `json:\"text\" api:\"required\"`\n\tCitations []BetaTextCitationParamUnion `json:\"citations,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"text\".\n\tType constant.Text `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaTextBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaTextBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaTextBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaTextCitationUnion contains all possible properties and values from\n// [BetaCitationCharLocation], [BetaCitationPageLocation],\n// [BetaCitationContentBlockLocation], [BetaCitationsWebSearchResultLocation],\n// [BetaCitationSearchResultLocation].\n//\n// Use the [BetaTextCitationUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaTextCitationUnion struct {\n\tCitedText     string `json:\"cited_text\"`\n\tDocumentIndex int64  `json:\"document_index\"`\n\tDocumentTitle string `json:\"document_title\"`\n\t// This field is from variant [BetaCitationCharLocation].\n\tEndCharIndex int64  `json:\"end_char_index\"`\n\tFileID       string `json:\"file_id\"`\n\t// This field is from variant [BetaCitationCharLocation].\n\tStartCharIndex int64 `json:\"start_char_index\"`\n\t// Any of \"char_location\", \"page_location\", \"content_block_location\",\n\t// \"web_search_result_location\", \"search_result_location\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaCitationPageLocation].\n\tEndPageNumber int64 `json:\"end_page_number\"`\n\t// This field is from variant [BetaCitationPageLocation].\n\tStartPageNumber int64 `json:\"start_page_number\"`\n\tEndBlockIndex   int64 `json:\"end_block_index\"`\n\tStartBlockIndex int64 `json:\"start_block_index\"`\n\t// This field is from variant [BetaCitationsWebSearchResultLocation].\n\tEncryptedIndex string `json:\"encrypted_index\"`\n\tTitle          string `json:\"title\"`\n\t// This field is from variant [BetaCitationsWebSearchResultLocation].\n\tURL string `json:\"url\"`\n\t// This field is from variant [BetaCitationSearchResultLocation].\n\tSearchResultIndex int64 `json:\"search_result_index\"`\n\t// This field is from variant [BetaCitationSearchResultLocation].\n\tSource string `json:\"source\"`\n\tJSON   struct {\n\t\tCitedText         respjson.Field\n\t\tDocumentIndex     respjson.Field\n\t\tDocumentTitle     respjson.Field\n\t\tEndCharIndex      respjson.Field\n\t\tFileID            respjson.Field\n\t\tStartCharIndex    respjson.Field\n\t\tType              respjson.Field\n\t\tEndPageNumber     respjson.Field\n\t\tStartPageNumber   respjson.Field\n\t\tEndBlockIndex     respjson.Field\n\t\tStartBlockIndex   respjson.Field\n\t\tEncryptedIndex    respjson.Field\n\t\tTitle             respjson.Field\n\t\tURL               respjson.Field\n\t\tSearchResultIndex respjson.Field\n\t\tSource            respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// anyBetaTextCitation is implemented by each variant of [BetaTextCitationUnion] to\n// add type safety for the return type of [BetaTextCitationUnion.AsAny]\ntype anyBetaTextCitation interface {\n\timplBetaTextCitationUnion()\n\ttoParamUnion() BetaTextCitationParamUnion\n}\n\nfunc (BetaCitationCharLocation) implBetaTextCitationUnion()             {}\nfunc (BetaCitationPageLocation) implBetaTextCitationUnion()             {}\nfunc (BetaCitationContentBlockLocation) implBetaTextCitationUnion()     {}\nfunc (BetaCitationsWebSearchResultLocation) implBetaTextCitationUnion() {}\nfunc (BetaCitationSearchResultLocation) implBetaTextCitationUnion()     {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaTextCitationUnion.AsAny().(type) {\n//\tcase anthropic.BetaCitationCharLocation:\n//\tcase anthropic.BetaCitationPageLocation:\n//\tcase anthropic.BetaCitationContentBlockLocation:\n//\tcase anthropic.BetaCitationsWebSearchResultLocation:\n//\tcase anthropic.BetaCitationSearchResultLocation:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaTextCitationUnion) AsAny() anyBetaTextCitation {\n\tswitch u.Type {\n\tcase \"char_location\":\n\t\treturn u.AsCharLocation()\n\tcase \"page_location\":\n\t\treturn u.AsPageLocation()\n\tcase \"content_block_location\":\n\t\treturn u.AsContentBlockLocation()\n\tcase \"web_search_result_location\":\n\t\treturn u.AsWebSearchResultLocation()\n\tcase \"search_result_location\":\n\t\treturn u.AsSearchResultLocation()\n\t}\n\treturn nil\n}\n\nfunc (u BetaTextCitationUnion) AsCharLocation() (v BetaCitationCharLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextCitationUnion) AsPageLocation() (v BetaCitationPageLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextCitationUnion) AsContentBlockLocation() (v BetaCitationContentBlockLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextCitationUnion) AsWebSearchResultLocation() (v BetaCitationsWebSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextCitationUnion) AsSearchResultLocation() (v BetaCitationSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaTextCitationUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaTextCitationUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaTextCitationParamUnion struct {\n\tOfCharLocation            *BetaCitationCharLocationParam            `json:\",omitzero,inline\"`\n\tOfPageLocation            *BetaCitationPageLocationParam            `json:\",omitzero,inline\"`\n\tOfContentBlockLocation    *BetaCitationContentBlockLocationParam    `json:\",omitzero,inline\"`\n\tOfWebSearchResultLocation *BetaCitationWebSearchResultLocationParam `json:\",omitzero,inline\"`\n\tOfSearchResultLocation    *BetaCitationSearchResultLocationParam    `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaTextCitationParamUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfCharLocation,\n\t\tu.OfPageLocation,\n\t\tu.OfContentBlockLocation,\n\t\tu.OfWebSearchResultLocation,\n\t\tu.OfSearchResultLocation)\n}\nfunc (u *BetaTextCitationParamUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaTextCitationParamUnion) asAny() any {\n\tif !param.IsOmitted(u.OfCharLocation) {\n\t\treturn u.OfCharLocation\n\t} else if !param.IsOmitted(u.OfPageLocation) {\n\t\treturn u.OfPageLocation\n\t} else if !param.IsOmitted(u.OfContentBlockLocation) {\n\t\treturn u.OfContentBlockLocation\n\t} else if !param.IsOmitted(u.OfWebSearchResultLocation) {\n\t\treturn u.OfWebSearchResultLocation\n\t} else if !param.IsOmitted(u.OfSearchResultLocation) {\n\t\treturn u.OfSearchResultLocation\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetEndCharIndex() *int64 {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn &vt.EndCharIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetStartCharIndex() *int64 {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn &vt.StartCharIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetEndPageNumber() *int64 {\n\tif vt := u.OfPageLocation; vt != nil {\n\t\treturn &vt.EndPageNumber\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetStartPageNumber() *int64 {\n\tif vt := u.OfPageLocation; vt != nil {\n\t\treturn &vt.StartPageNumber\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetEncryptedIndex() *string {\n\tif vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn &vt.EncryptedIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetURL() *string {\n\tif vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetSearchResultIndex() *int64 {\n\tif vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn &vt.SearchResultIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetSource() *string {\n\tif vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn &vt.Source\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetCitedText() *string {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfPageLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetDocumentIndex() *int64 {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn (*int64)(&vt.DocumentIndex)\n\t} else if vt := u.OfPageLocation; vt != nil {\n\t\treturn (*int64)(&vt.DocumentIndex)\n\t} else if vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*int64)(&vt.DocumentIndex)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetDocumentTitle() *string {\n\tif vt := u.OfCharLocation; vt != nil && vt.DocumentTitle.Valid() {\n\t\treturn &vt.DocumentTitle.Value\n\t} else if vt := u.OfPageLocation; vt != nil && vt.DocumentTitle.Valid() {\n\t\treturn &vt.DocumentTitle.Value\n\t} else if vt := u.OfContentBlockLocation; vt != nil && vt.DocumentTitle.Valid() {\n\t\treturn &vt.DocumentTitle.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetType() *string {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfPageLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetEndBlockIndex() *int64 {\n\tif vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*int64)(&vt.EndBlockIndex)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*int64)(&vt.EndBlockIndex)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetStartBlockIndex() *int64 {\n\tif vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*int64)(&vt.StartBlockIndex)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*int64)(&vt.StartBlockIndex)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextCitationParamUnion) GetTitle() *string {\n\tif vt := u.OfWebSearchResultLocation; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t} else if vt := u.OfSearchResultLocation; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t}\n\treturn nil\n}\n\ntype BetaTextDelta struct {\n\tText string             `json:\"text\" api:\"required\"`\n\tType constant.TextDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tText        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionCreateResultBlock struct {\n\tIsFileUpdate bool                                         `json:\"is_file_update\" api:\"required\"`\n\tType         constant.TextEditorCodeExecutionCreateResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tIsFileUpdate respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextEditorCodeExecutionCreateResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextEditorCodeExecutionCreateResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties IsFileUpdate, Type are required.\ntype BetaTextEditorCodeExecutionCreateResultBlockParam struct {\n\tIsFileUpdate bool `json:\"is_file_update\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_create_result\".\n\tType constant.TextEditorCodeExecutionCreateResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaTextEditorCodeExecutionCreateResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaTextEditorCodeExecutionCreateResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaTextEditorCodeExecutionCreateResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionStrReplaceResultBlock struct {\n\tLines    []string                                         `json:\"lines\" api:\"required\"`\n\tNewLines int64                                            `json:\"new_lines\" api:\"required\"`\n\tNewStart int64                                            `json:\"new_start\" api:\"required\"`\n\tOldLines int64                                            `json:\"old_lines\" api:\"required\"`\n\tOldStart int64                                            `json:\"old_start\" api:\"required\"`\n\tType     constant.TextEditorCodeExecutionStrReplaceResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tLines       respjson.Field\n\t\tNewLines    respjson.Field\n\t\tNewStart    respjson.Field\n\t\tOldLines    respjson.Field\n\t\tOldStart    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextEditorCodeExecutionStrReplaceResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextEditorCodeExecutionStrReplaceResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The property Type is required.\ntype BetaTextEditorCodeExecutionStrReplaceResultBlockParam struct {\n\tNewLines param.Opt[int64] `json:\"new_lines,omitzero\"`\n\tNewStart param.Opt[int64] `json:\"new_start,omitzero\"`\n\tOldLines param.Opt[int64] `json:\"old_lines,omitzero\"`\n\tOldStart param.Opt[int64] `json:\"old_start,omitzero\"`\n\tLines    []string         `json:\"lines,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_str_replace_result\".\n\tType constant.TextEditorCodeExecutionStrReplaceResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaTextEditorCodeExecutionStrReplaceResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaTextEditorCodeExecutionStrReplaceResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaTextEditorCodeExecutionStrReplaceResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionToolResultBlock struct {\n\tContent   BetaTextEditorCodeExecutionToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                                 `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.TextEditorCodeExecutionToolResult             `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextEditorCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextEditorCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaTextEditorCodeExecutionToolResultBlockContentUnion contains all possible\n// properties and values from [BetaTextEditorCodeExecutionToolResultError],\n// [BetaTextEditorCodeExecutionViewResultBlock],\n// [BetaTextEditorCodeExecutionCreateResultBlock],\n// [BetaTextEditorCodeExecutionStrReplaceResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaTextEditorCodeExecutionToolResultBlockContentUnion struct {\n\t// This field is from variant [BetaTextEditorCodeExecutionToolResultError].\n\tErrorCode BetaTextEditorCodeExecutionToolResultErrorErrorCode `json:\"error_code\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionToolResultError].\n\tErrorMessage string `json:\"error_message\"`\n\tType         string `json:\"type\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].\n\tContent string `json:\"content\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].\n\tFileType BetaTextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].\n\tNumLines int64 `json:\"num_lines\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].\n\tStartLine int64 `json:\"start_line\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].\n\tTotalLines int64 `json:\"total_lines\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionCreateResultBlock].\n\tIsFileUpdate bool `json:\"is_file_update\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].\n\tLines []string `json:\"lines\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].\n\tNewLines int64 `json:\"new_lines\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].\n\tNewStart int64 `json:\"new_start\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].\n\tOldLines int64 `json:\"old_lines\"`\n\t// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].\n\tOldStart int64 `json:\"old_start\"`\n\tJSON     struct {\n\t\tErrorCode    respjson.Field\n\t\tErrorMessage respjson.Field\n\t\tType         respjson.Field\n\t\tContent      respjson.Field\n\t\tFileType     respjson.Field\n\t\tNumLines     respjson.Field\n\t\tStartLine    respjson.Field\n\t\tTotalLines   respjson.Field\n\t\tIsFileUpdate respjson.Field\n\t\tLines        respjson.Field\n\t\tNewLines     respjson.Field\n\t\tNewStart     respjson.Field\n\t\tOldLines     respjson.Field\n\t\tOldStart     respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError() (v BetaTextEditorCodeExecutionToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock() (v BetaTextEditorCodeExecutionViewResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock() (v BetaTextEditorCodeExecutionCreateResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock() (v BetaTextEditorCodeExecutionStrReplaceResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaTextEditorCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BetaTextEditorCodeExecutionToolResultBlockParam struct {\n\tContent   BetaTextEditorCodeExecutionToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                                      `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_tool_result\".\n\tType constant.TextEditorCodeExecutionToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaTextEditorCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaTextEditorCodeExecutionToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaTextEditorCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaTextEditorCodeExecutionToolResultBlockParamContentUnion struct {\n\tOfRequestTextEditorCodeExecutionToolResultError       *BetaTextEditorCodeExecutionToolResultErrorParam       `json:\",omitzero,inline\"`\n\tOfRequestTextEditorCodeExecutionViewResultBlock       *BetaTextEditorCodeExecutionViewResultBlockParam       `json:\",omitzero,inline\"`\n\tOfRequestTextEditorCodeExecutionCreateResultBlock     *BetaTextEditorCodeExecutionCreateResultBlockParam     `json:\",omitzero,inline\"`\n\tOfRequestTextEditorCodeExecutionStrReplaceResultBlock *BetaTextEditorCodeExecutionStrReplaceResultBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestTextEditorCodeExecutionToolResultError, u.OfRequestTextEditorCodeExecutionViewResultBlock, u.OfRequestTextEditorCodeExecutionCreateResultBlock, u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock)\n}\nfunc (u *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestTextEditorCodeExecutionToolResultError) {\n\t\treturn u.OfRequestTextEditorCodeExecutionToolResultError\n\t} else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionViewResultBlock) {\n\t\treturn u.OfRequestTextEditorCodeExecutionViewResultBlock\n\t} else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionCreateResultBlock) {\n\t\treturn u.OfRequestTextEditorCodeExecutionCreateResultBlock\n\t} else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock) {\n\t\treturn u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorMessage() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil && vt.ErrorMessage.Valid() {\n\t\treturn &vt.ErrorMessage.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetContent() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil {\n\t\treturn &vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetFileType() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil {\n\t\treturn (*string)(&vt.FileType)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetNumLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.NumLines.Valid() {\n\t\treturn &vt.NumLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetStartLine() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.StartLine.Valid() {\n\t\treturn &vt.StartLine.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetTotalLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.TotalLines.Valid() {\n\t\treturn &vt.TotalLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetIsFileUpdate() *bool {\n\tif vt := u.OfRequestTextEditorCodeExecutionCreateResultBlock; vt != nil {\n\t\treturn &vt.IsFileUpdate\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetLines() []string {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil {\n\t\treturn vt.Lines\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.NewLines.Valid() {\n\t\treturn &vt.NewLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewStart() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.NewStart.Valid() {\n\t\treturn &vt.NewStart.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.OldLines.Valid() {\n\t\treturn &vt.OldLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldStart() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.OldStart.Valid() {\n\t\treturn &vt.OldStart.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestTextEditorCodeExecutionCreateResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BetaTextEditorCodeExecutionToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"file_not_found\".\n\tErrorCode    BetaTextEditorCodeExecutionToolResultErrorErrorCode `json:\"error_code\" api:\"required\"`\n\tErrorMessage string                                              `json:\"error_message\" api:\"required\"`\n\tType         constant.TextEditorCodeExecutionToolResultError     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode    respjson.Field\n\t\tErrorMessage respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextEditorCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextEditorCodeExecutionToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionToolResultErrorErrorCode string\n\nconst (\n\tBetaTextEditorCodeExecutionToolResultErrorErrorCodeInvalidToolInput      BetaTextEditorCodeExecutionToolResultErrorErrorCode = \"invalid_tool_input\"\n\tBetaTextEditorCodeExecutionToolResultErrorErrorCodeUnavailable           BetaTextEditorCodeExecutionToolResultErrorErrorCode = \"unavailable\"\n\tBetaTextEditorCodeExecutionToolResultErrorErrorCodeTooManyRequests       BetaTextEditorCodeExecutionToolResultErrorErrorCode = \"too_many_requests\"\n\tBetaTextEditorCodeExecutionToolResultErrorErrorCodeExecutionTimeExceeded BetaTextEditorCodeExecutionToolResultErrorErrorCode = \"execution_time_exceeded\"\n\tBetaTextEditorCodeExecutionToolResultErrorErrorCodeFileNotFound          BetaTextEditorCodeExecutionToolResultErrorErrorCode = \"file_not_found\"\n)\n\n// The properties ErrorCode, Type are required.\ntype BetaTextEditorCodeExecutionToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"file_not_found\".\n\tErrorCode    BetaTextEditorCodeExecutionToolResultErrorParamErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\tErrorMessage param.Opt[string]                                        `json:\"error_message,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_tool_result_error\".\n\tType constant.TextEditorCodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaTextEditorCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaTextEditorCodeExecutionToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaTextEditorCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionToolResultErrorParamErrorCode string\n\nconst (\n\tBetaTextEditorCodeExecutionToolResultErrorParamErrorCodeInvalidToolInput      BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = \"invalid_tool_input\"\n\tBetaTextEditorCodeExecutionToolResultErrorParamErrorCodeUnavailable           BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = \"unavailable\"\n\tBetaTextEditorCodeExecutionToolResultErrorParamErrorCodeTooManyRequests       BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = \"too_many_requests\"\n\tBetaTextEditorCodeExecutionToolResultErrorParamErrorCodeExecutionTimeExceeded BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = \"execution_time_exceeded\"\n\tBetaTextEditorCodeExecutionToolResultErrorParamErrorCodeFileNotFound          BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = \"file_not_found\"\n)\n\ntype BetaTextEditorCodeExecutionViewResultBlock struct {\n\tContent string `json:\"content\" api:\"required\"`\n\t// Any of \"text\", \"image\", \"pdf\".\n\tFileType   BetaTextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\" api:\"required\"`\n\tNumLines   int64                                              `json:\"num_lines\" api:\"required\"`\n\tStartLine  int64                                              `json:\"start_line\" api:\"required\"`\n\tTotalLines int64                                              `json:\"total_lines\" api:\"required\"`\n\tType       constant.TextEditorCodeExecutionViewResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tFileType    respjson.Field\n\t\tNumLines    respjson.Field\n\t\tStartLine   respjson.Field\n\t\tTotalLines  respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaTextEditorCodeExecutionViewResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaTextEditorCodeExecutionViewResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionViewResultBlockFileType string\n\nconst (\n\tBetaTextEditorCodeExecutionViewResultBlockFileTypeText  BetaTextEditorCodeExecutionViewResultBlockFileType = \"text\"\n\tBetaTextEditorCodeExecutionViewResultBlockFileTypeImage BetaTextEditorCodeExecutionViewResultBlockFileType = \"image\"\n\tBetaTextEditorCodeExecutionViewResultBlockFileTypePDF   BetaTextEditorCodeExecutionViewResultBlockFileType = \"pdf\"\n)\n\n// The properties Content, FileType, Type are required.\ntype BetaTextEditorCodeExecutionViewResultBlockParam struct {\n\tContent string `json:\"content\" api:\"required\"`\n\t// Any of \"text\", \"image\", \"pdf\".\n\tFileType   BetaTextEditorCodeExecutionViewResultBlockParamFileType `json:\"file_type,omitzero\" api:\"required\"`\n\tNumLines   param.Opt[int64]                                        `json:\"num_lines,omitzero\"`\n\tStartLine  param.Opt[int64]                                        `json:\"start_line,omitzero\"`\n\tTotalLines param.Opt[int64]                                        `json:\"total_lines,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_view_result\".\n\tType constant.TextEditorCodeExecutionViewResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaTextEditorCodeExecutionViewResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaTextEditorCodeExecutionViewResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaTextEditorCodeExecutionViewResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaTextEditorCodeExecutionViewResultBlockParamFileType string\n\nconst (\n\tBetaTextEditorCodeExecutionViewResultBlockParamFileTypeText  BetaTextEditorCodeExecutionViewResultBlockParamFileType = \"text\"\n\tBetaTextEditorCodeExecutionViewResultBlockParamFileTypeImage BetaTextEditorCodeExecutionViewResultBlockParamFileType = \"image\"\n\tBetaTextEditorCodeExecutionViewResultBlockParamFileTypePDF   BetaTextEditorCodeExecutionViewResultBlockParamFileType = \"pdf\"\n)\n\ntype BetaThinkingBlock struct {\n\tSignature string            `json:\"signature\" api:\"required\"`\n\tThinking  string            `json:\"thinking\" api:\"required\"`\n\tType      constant.Thinking `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSignature   respjson.Field\n\t\tThinking    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaThinkingBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaThinkingBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Signature, Thinking, Type are required.\ntype BetaThinkingBlockParam struct {\n\tSignature string `json:\"signature\" api:\"required\"`\n\tThinking  string `json:\"thinking\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"thinking\".\n\tType constant.Thinking `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaThinkingBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaThinkingBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaThinkingBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The property Type is required.\ntype BetaThinkingConfigAdaptiveParam struct {\n\t// Controls how thinking content appears in the response. When set to `summarized`,\n\t// thinking is returned normally. When set to `omitted`, thinking content is\n\t// redacted but a signature is returned for multi-turn continuity. Defaults to\n\t// `summarized`.\n\t//\n\t// Any of \"summarized\", \"omitted\".\n\tDisplay BetaThinkingConfigAdaptiveDisplay `json:\"display,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"adaptive\".\n\tType constant.Adaptive `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaThinkingConfigAdaptiveParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaThinkingConfigAdaptiveParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaThinkingConfigAdaptiveParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Controls how thinking content appears in the response. When set to `summarized`,\n// thinking is returned normally. When set to `omitted`, thinking content is\n// redacted but a signature is returned for multi-turn continuity. Defaults to\n// `summarized`.\ntype BetaThinkingConfigAdaptiveDisplay string\n\nconst (\n\tBetaThinkingConfigAdaptiveDisplaySummarized BetaThinkingConfigAdaptiveDisplay = \"summarized\"\n\tBetaThinkingConfigAdaptiveDisplayOmitted    BetaThinkingConfigAdaptiveDisplay = \"omitted\"\n)\n\nfunc NewBetaThinkingConfigDisabledParam() BetaThinkingConfigDisabledParam {\n\treturn BetaThinkingConfigDisabledParam{\n\t\tType: \"disabled\",\n\t}\n}\n\n// This struct has a constant value, construct it with\n// [NewBetaThinkingConfigDisabledParam].\ntype BetaThinkingConfigDisabledParam struct {\n\tType constant.Disabled `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaThinkingConfigDisabledParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaThinkingConfigDisabledParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaThinkingConfigDisabledParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties BudgetTokens, Type are required.\ntype BetaThinkingConfigEnabledParam struct {\n\t// Determines how many tokens Claude can use for its internal reasoning process.\n\t// Larger budgets can enable more thorough analysis for complex problems, improving\n\t// response quality.\n\t//\n\t// Must be ≥1024 and less than `max_tokens`.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tBudgetTokens int64 `json:\"budget_tokens\" api:\"required\"`\n\t// Controls how thinking content appears in the response. When set to `summarized`,\n\t// thinking is returned normally. When set to `omitted`, thinking content is\n\t// redacted but a signature is returned for multi-turn continuity. Defaults to\n\t// `summarized`.\n\t//\n\t// Any of \"summarized\", \"omitted\".\n\tDisplay BetaThinkingConfigEnabledDisplay `json:\"display,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"enabled\".\n\tType constant.Enabled `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaThinkingConfigEnabledParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaThinkingConfigEnabledParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaThinkingConfigEnabledParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Controls how thinking content appears in the response. When set to `summarized`,\n// thinking is returned normally. When set to `omitted`, thinking content is\n// redacted but a signature is returned for multi-turn continuity. Defaults to\n// `summarized`.\ntype BetaThinkingConfigEnabledDisplay string\n\nconst (\n\tBetaThinkingConfigEnabledDisplaySummarized BetaThinkingConfigEnabledDisplay = \"summarized\"\n\tBetaThinkingConfigEnabledDisplayOmitted    BetaThinkingConfigEnabledDisplay = \"omitted\"\n)\n\nfunc BetaThinkingConfigParamOfEnabled(budgetTokens int64) BetaThinkingConfigParamUnion {\n\tvar enabled BetaThinkingConfigEnabledParam\n\tenabled.BudgetTokens = budgetTokens\n\treturn BetaThinkingConfigParamUnion{OfEnabled: &enabled}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaThinkingConfigParamUnion struct {\n\tOfEnabled  *BetaThinkingConfigEnabledParam  `json:\",omitzero,inline\"`\n\tOfDisabled *BetaThinkingConfigDisabledParam `json:\",omitzero,inline\"`\n\tOfAdaptive *BetaThinkingConfigAdaptiveParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaThinkingConfigParamUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfEnabled, u.OfDisabled, u.OfAdaptive)\n}\nfunc (u *BetaThinkingConfigParamUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaThinkingConfigParamUnion) asAny() any {\n\tif !param.IsOmitted(u.OfEnabled) {\n\t\treturn u.OfEnabled\n\t} else if !param.IsOmitted(u.OfDisabled) {\n\t\treturn u.OfDisabled\n\t} else if !param.IsOmitted(u.OfAdaptive) {\n\t\treturn u.OfAdaptive\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaThinkingConfigParamUnion) GetBudgetTokens() *int64 {\n\tif vt := u.OfEnabled; vt != nil {\n\t\treturn &vt.BudgetTokens\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaThinkingConfigParamUnion) GetType() *string {\n\tif vt := u.OfEnabled; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfDisabled; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfAdaptive; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaThinkingConfigParamUnion) GetDisplay() *string {\n\tif vt := u.OfEnabled; vt != nil {\n\t\treturn (*string)(&vt.Display)\n\t} else if vt := u.OfAdaptive; vt != nil {\n\t\treturn (*string)(&vt.Display)\n\t}\n\treturn nil\n}\n\ntype BetaThinkingDelta struct {\n\tThinking string                 `json:\"thinking\" api:\"required\"`\n\tType     constant.ThinkingDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tThinking    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaThinkingDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaThinkingDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, Value are required.\ntype BetaThinkingTurnsParam struct {\n\tValue int64 `json:\"value\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"thinking_turns\".\n\tType constant.ThinkingTurns `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaThinkingTurnsParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaThinkingTurnsParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaThinkingTurnsParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties InputSchema, Name are required.\ntype BetaToolParam struct {\n\t// [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.\n\t//\n\t// This defines the shape of the `input` that your tool accepts and that the model\n\t// will produce.\n\tInputSchema BetaToolInputSchemaParam `json:\"input_schema,omitzero\" api:\"required\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\tName string `json:\"name\" api:\"required\"`\n\t// Enable eager input streaming for this tool. When true, tool input parameters\n\t// will be streamed incrementally as they are generated, and types will be inferred\n\t// on-the-fly rather than buffering the full JSON output. When false, streaming is\n\t// disabled for this tool even if the fine-grained-tool-streaming beta is active.\n\t// When null (default), uses the default behavior based on beta headers.\n\tEagerInputStreaming param.Opt[bool] `json:\"eager_input_streaming,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// Description of what this tool does.\n\t//\n\t// Tool descriptions should be as detailed as possible. The more information that\n\t// the model has about what the tool is and how to use it, the better it will\n\t// perform. You can use natural language descriptions to reinforce important\n\t// aspects of the tool input JSON schema.\n\tDescription param.Opt[string] `json:\"description,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"custom\".\n\tType BetaToolType `json:\"type,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaToolParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.\n//\n// This defines the shape of the `input` that your tool accepts and that the model\n// will produce.\n//\n// The property Type is required.\ntype BetaToolInputSchemaParam struct {\n\tProperties any      `json:\"properties,omitzero\"`\n\tRequired   []string `json:\"required,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"object\".\n\tType        constant.Object `json:\"type\" api:\"required\"`\n\tExtraFields map[string]any  `json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaToolInputSchemaParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolInputSchemaParam\n\treturn param.MarshalWithExtras(r, (*shadow)(&r), r.ExtraFields)\n}\nfunc (r *BetaToolInputSchemaParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaToolType string\n\nconst (\n\tBetaToolTypeCustom BetaToolType = \"custom\"\n)\n\n// The properties Name, Type are required.\ntype BetaToolBash20241022Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"bash\".\n\tName constant.Bash `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"bash_20241022\".\n\tType constant.Bash20241022 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolBash20241022Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolBash20241022Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolBash20241022Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaToolBash20250124Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"bash\".\n\tName constant.Bash `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"bash_20250124\".\n\tType constant.Bash20250124 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolBash20250124Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolBash20250124Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolBash20250124Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc BetaToolChoiceParamOfTool(name string) BetaToolChoiceUnionParam {\n\tvar tool BetaToolChoiceToolParam\n\ttool.Name = name\n\treturn BetaToolChoiceUnionParam{OfTool: &tool}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaToolChoiceUnionParam struct {\n\tOfAuto *BetaToolChoiceAutoParam `json:\",omitzero,inline\"`\n\tOfAny  *BetaToolChoiceAnyParam  `json:\",omitzero,inline\"`\n\tOfTool *BetaToolChoiceToolParam `json:\",omitzero,inline\"`\n\tOfNone *BetaToolChoiceNoneParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaToolChoiceUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfAuto, u.OfAny, u.OfTool, u.OfNone)\n}\nfunc (u *BetaToolChoiceUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaToolChoiceUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfAuto) {\n\t\treturn u.OfAuto\n\t} else if !param.IsOmitted(u.OfAny) {\n\t\treturn u.OfAny\n\t} else if !param.IsOmitted(u.OfTool) {\n\t\treturn u.OfTool\n\t} else if !param.IsOmitted(u.OfNone) {\n\t\treturn u.OfNone\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolChoiceUnionParam) GetName() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.Name\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolChoiceUnionParam) GetType() *string {\n\tif vt := u.OfAuto; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfAny; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfNone; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolChoiceUnionParam) GetDisableParallelToolUse() *bool {\n\tif vt := u.OfAuto; vt != nil && vt.DisableParallelToolUse.Valid() {\n\t\treturn &vt.DisableParallelToolUse.Value\n\t} else if vt := u.OfAny; vt != nil && vt.DisableParallelToolUse.Valid() {\n\t\treturn &vt.DisableParallelToolUse.Value\n\t} else if vt := u.OfTool; vt != nil && vt.DisableParallelToolUse.Valid() {\n\t\treturn &vt.DisableParallelToolUse.Value\n\t}\n\treturn nil\n}\n\n// The model will use any available tools.\n//\n// The property Type is required.\ntype BetaToolChoiceAnyParam struct {\n\t// Whether to disable parallel tool use.\n\t//\n\t// Defaults to `false`. If set to `true`, the model will output exactly one tool\n\t// use.\n\tDisableParallelToolUse param.Opt[bool] `json:\"disable_parallel_tool_use,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"any\".\n\tType constant.Any `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolChoiceAnyParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolChoiceAnyParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolChoiceAnyParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The model will automatically decide whether to use tools.\n//\n// The property Type is required.\ntype BetaToolChoiceAutoParam struct {\n\t// Whether to disable parallel tool use.\n\t//\n\t// Defaults to `false`. If set to `true`, the model will output at most one tool\n\t// use.\n\tDisableParallelToolUse param.Opt[bool] `json:\"disable_parallel_tool_use,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"auto\".\n\tType constant.Auto `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolChoiceAutoParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolChoiceAutoParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolChoiceAutoParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc NewBetaToolChoiceNoneParam() BetaToolChoiceNoneParam {\n\treturn BetaToolChoiceNoneParam{\n\t\tType: \"none\",\n\t}\n}\n\n// The model will not be allowed to use tools.\n//\n// This struct has a constant value, construct it with\n// [NewBetaToolChoiceNoneParam].\ntype BetaToolChoiceNoneParam struct {\n\tType constant.None `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolChoiceNoneParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolChoiceNoneParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolChoiceNoneParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The model will use the specified tool with `tool_choice.name`.\n//\n// The properties Name, Type are required.\ntype BetaToolChoiceToolParam struct {\n\t// The name of the tool to use.\n\tName string `json:\"name\" api:\"required\"`\n\t// Whether to disable parallel tool use.\n\t//\n\t// Defaults to `false`. If set to `true`, the model will output exactly one tool\n\t// use.\n\tDisableParallelToolUse param.Opt[bool] `json:\"disable_parallel_tool_use,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool\".\n\tType constant.Tool `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolChoiceToolParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolChoiceToolParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolChoiceToolParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties DisplayHeightPx, DisplayWidthPx, Name, Type are required.\ntype BetaToolComputerUse20241022Param struct {\n\t// The height of the display in pixels.\n\tDisplayHeightPx int64 `json:\"display_height_px\" api:\"required\"`\n\t// The width of the display in pixels.\n\tDisplayWidthPx int64 `json:\"display_width_px\" api:\"required\"`\n\t// The X11 display number (e.g. 0, 1) for the display.\n\tDisplayNumber param.Opt[int64] `json:\"display_number,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"computer\".\n\tName constant.Computer `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"computer_20241022\".\n\tType constant.Computer20241022 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolComputerUse20241022Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolComputerUse20241022Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolComputerUse20241022Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties DisplayHeightPx, DisplayWidthPx, Name, Type are required.\ntype BetaToolComputerUse20250124Param struct {\n\t// The height of the display in pixels.\n\tDisplayHeightPx int64 `json:\"display_height_px\" api:\"required\"`\n\t// The width of the display in pixels.\n\tDisplayWidthPx int64 `json:\"display_width_px\" api:\"required\"`\n\t// The X11 display number (e.g. 0, 1) for the display.\n\tDisplayNumber param.Opt[int64] `json:\"display_number,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"computer\".\n\tName constant.Computer `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"computer_20250124\".\n\tType constant.Computer20250124 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolComputerUse20250124Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolComputerUse20250124Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolComputerUse20250124Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties DisplayHeightPx, DisplayWidthPx, Name, Type are required.\ntype BetaToolComputerUse20251124Param struct {\n\t// The height of the display in pixels.\n\tDisplayHeightPx int64 `json:\"display_height_px\" api:\"required\"`\n\t// The width of the display in pixels.\n\tDisplayWidthPx int64 `json:\"display_width_px\" api:\"required\"`\n\t// The X11 display number (e.g. 0, 1) for the display.\n\tDisplayNumber param.Opt[int64] `json:\"display_number,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// Whether to enable an action to take a zoomed-in screenshot of the screen.\n\tEnableZoom param.Opt[bool] `json:\"enable_zoom,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"computer\".\n\tName constant.Computer `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"computer_20251124\".\n\tType constant.Computer20251124 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolComputerUse20251124Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolComputerUse20251124Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolComputerUse20251124Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaToolReferenceBlock struct {\n\tToolName string                 `json:\"tool_name\" api:\"required\"`\n\tType     constant.ToolReference `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolName    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaToolReferenceBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaToolReferenceBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Tool reference block that can be included in tool_result content.\n//\n// The properties ToolName, Type are required.\ntype BetaToolReferenceBlockParam struct {\n\tToolName string `json:\"tool_name\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_reference\".\n\tType constant.ToolReference `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolReferenceBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolReferenceBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolReferenceBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ToolUseID, Type are required.\ntype BetaToolResultBlockParam struct {\n\tToolUseID string          `json:\"tool_use_id\" api:\"required\"`\n\tIsError   param.Opt[bool] `json:\"is_error,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam         `json:\"cache_control,omitzero\"`\n\tContent      []BetaToolResultBlockParamContentUnion `json:\"content,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_result\".\n\tType constant.ToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc NewBetaToolResultTextBlockParam(toolUseID string, text string, isError bool) BetaToolResultBlockParam {\n\tvar p BetaToolResultBlockParam\n\tp.ToolUseID = toolUseID\n\tp.IsError = param.Opt[bool]{Value: isError}\n\tp.Content = []BetaToolResultBlockParamContentUnion{\n\t\t{OfText: &BetaTextBlockParam{Text: text}},\n\t}\n\treturn p\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaToolResultBlockParamContentUnion struct {\n\tOfText          *BetaTextBlockParam            `json:\",omitzero,inline\"`\n\tOfImage         *BetaImageBlockParam           `json:\",omitzero,inline\"`\n\tOfSearchResult  *BetaSearchResultBlockParam    `json:\",omitzero,inline\"`\n\tOfDocument      *BetaRequestDocumentBlockParam `json:\",omitzero,inline\"`\n\tOfToolReference *BetaToolReferenceBlockParam   `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfText,\n\t\tu.OfImage,\n\t\tu.OfSearchResult,\n\t\tu.OfDocument,\n\t\tu.OfToolReference)\n}\nfunc (u *BetaToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfImage) {\n\t\treturn u.OfImage\n\t} else if !param.IsOmitted(u.OfSearchResult) {\n\t\treturn u.OfSearchResult\n\t} else if !param.IsOmitted(u.OfDocument) {\n\t\treturn u.OfDocument\n\t} else if !param.IsOmitted(u.OfToolReference) {\n\t\treturn u.OfToolReference\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetText() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.Text\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetContent() []BetaTextBlockParam {\n\tif vt := u.OfSearchResult; vt != nil {\n\t\treturn vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetContext() *string {\n\tif vt := u.OfDocument; vt != nil && vt.Context.Valid() {\n\t\treturn &vt.Context.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetToolName() *string {\n\tif vt := u.OfToolReference; vt != nil {\n\t\treturn &vt.ToolName\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolReference; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetTitle() *string {\n\tif vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Title)\n\t} else if vt := u.OfDocument; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u BetaToolResultBlockParamContentUnion) GetCacheControl() *BetaCacheControlEphemeralParam {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolReference; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaToolResultBlockParamContentUnion) GetCitations() (res betaToolResultBlockParamContentUnionCitations) {\n\tif vt := u.OfText; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = &vt.Citations\n\t}\n\treturn\n}\n\n// Can have the runtime types [*[]BetaTextCitationParamUnion],\n// [*BetaCitationsConfigParam]\ntype betaToolResultBlockParamContentUnionCitations struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *[]anthropic.BetaTextCitationParamUnion:\n//\tcase *anthropic.BetaCitationsConfigParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaToolResultBlockParamContentUnionCitations) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionCitations) GetEnabled() *bool {\n\tswitch vt := u.any.(type) {\n\tcase *BetaCitationsConfigParam:\n\t\treturn paramutil.AddrIfPresent(vt.Enabled)\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u BetaToolResultBlockParamContentUnion) GetSource() (res betaToolResultBlockParamContentUnionSource) {\n\tif vt := u.OfImage; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Source\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t}\n\treturn\n}\n\n// Can have the runtime types [*BetaBase64ImageSourceParam],\n// [*BetaURLImageSourceParam], [*BetaFileImageSourceParam], [*string],\n// [*BetaBase64PDFSourceParam], [*BetaPlainTextSourceParam],\n// [*BetaContentBlockSourceParam], [*BetaURLPDFSourceParam],\n// [*BetaFileDocumentSourceParam]\ntype betaToolResultBlockParamContentUnionSource struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.BetaBase64ImageSourceParam:\n//\tcase *anthropic.BetaURLImageSourceParam:\n//\tcase *anthropic.BetaFileImageSourceParam:\n//\tcase *string:\n//\tcase *anthropic.BetaBase64PDFSourceParam:\n//\tcase *anthropic.BetaPlainTextSourceParam:\n//\tcase *anthropic.BetaContentBlockSourceParam:\n//\tcase *anthropic.BetaURLPDFSourceParam:\n//\tcase *anthropic.BetaFileDocumentSourceParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u betaToolResultBlockParamContentUnionSource) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionSource) GetContent() *BetaContentBlockSourceContentUnionParam {\n\tswitch vt := u.any.(type) {\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetContent()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionSource) GetData() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetData()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetData()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionSource) GetMediaType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetMediaType()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetMediaType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionSource) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetType()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionSource) GetURL() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetURL()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetURL()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u betaToolResultBlockParamContentUnionSource) GetFileID() *string {\n\tswitch vt := u.any.(type) {\n\tcase *BetaImageBlockParamSourceUnion:\n\t\treturn vt.GetFileID()\n\tcase *BetaRequestDocumentBlockSourceUnionParam:\n\t\treturn vt.GetFileID()\n\t}\n\treturn nil\n}\n\n// The properties Name, Type are required.\ntype BetaToolSearchToolBm25_20251119Param struct {\n\t// Any of \"tool_search_tool_bm25_20251119\", \"tool_search_tool_bm25\".\n\tType BetaToolSearchToolBm25_20251119Type `json:\"type,omitzero\" api:\"required\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_bm25\".\n\tName constant.ToolSearchToolBm25 `json:\"name\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolSearchToolBm25_20251119Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolSearchToolBm25_20251119Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolSearchToolBm25_20251119Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaToolSearchToolBm25_20251119Type string\n\nconst (\n\tBetaToolSearchToolBm25_20251119TypeToolSearchToolBm25_20251119 BetaToolSearchToolBm25_20251119Type = \"tool_search_tool_bm25_20251119\"\n\tBetaToolSearchToolBm25_20251119TypeToolSearchToolBm25          BetaToolSearchToolBm25_20251119Type = \"tool_search_tool_bm25\"\n)\n\n// The properties Name, Type are required.\ntype BetaToolSearchToolRegex20251119Param struct {\n\t// Any of \"tool_search_tool_regex_20251119\", \"tool_search_tool_regex\".\n\tType BetaToolSearchToolRegex20251119Type `json:\"type,omitzero\" api:\"required\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_regex\".\n\tName constant.ToolSearchToolRegex `json:\"name\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolSearchToolRegex20251119Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolSearchToolRegex20251119Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolSearchToolRegex20251119Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaToolSearchToolRegex20251119Type string\n\nconst (\n\tBetaToolSearchToolRegex20251119TypeToolSearchToolRegex20251119 BetaToolSearchToolRegex20251119Type = \"tool_search_tool_regex_20251119\"\n\tBetaToolSearchToolRegex20251119TypeToolSearchToolRegex         BetaToolSearchToolRegex20251119Type = \"tool_search_tool_regex\"\n)\n\ntype BetaToolSearchToolResultBlock struct {\n\tContent   BetaToolSearchToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                    `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.ToolSearchToolResult             `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaToolSearchToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaToolSearchToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaToolSearchToolResultBlockContentUnion contains all possible properties and\n// values from [BetaToolSearchToolResultError],\n// [BetaToolSearchToolSearchResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaToolSearchToolResultBlockContentUnion struct {\n\t// This field is from variant [BetaToolSearchToolResultError].\n\tErrorCode BetaToolSearchToolResultErrorErrorCode `json:\"error_code\"`\n\t// This field is from variant [BetaToolSearchToolResultError].\n\tErrorMessage string `json:\"error_message\"`\n\tType         string `json:\"type\"`\n\t// This field is from variant [BetaToolSearchToolSearchResultBlock].\n\tToolReferences []BetaToolReferenceBlock `json:\"tool_references\"`\n\tJSON           struct {\n\t\tErrorCode      respjson.Field\n\t\tErrorMessage   respjson.Field\n\t\tType           respjson.Field\n\t\tToolReferences respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError() (v BetaToolSearchToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock() (v BetaToolSearchToolSearchResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaToolSearchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaToolSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BetaToolSearchToolResultBlockParam struct {\n\tContent   BetaToolSearchToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                         `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_result\".\n\tType constant.ToolSearchToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolSearchToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolSearchToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolSearchToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaToolSearchToolResultBlockParamContentUnion struct {\n\tOfRequestToolSearchToolResultError       *BetaToolSearchToolResultErrorParam       `json:\",omitzero,inline\"`\n\tOfRequestToolSearchToolSearchResultBlock *BetaToolSearchToolSearchResultBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaToolSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestToolSearchToolResultError, u.OfRequestToolSearchToolSearchResultBlock)\n}\nfunc (u *BetaToolSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaToolSearchToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestToolSearchToolResultError) {\n\t\treturn u.OfRequestToolSearchToolResultError\n\t} else if !param.IsOmitted(u.OfRequestToolSearchToolSearchResultBlock) {\n\t\treturn u.OfRequestToolSearchToolSearchResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolSearchToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestToolSearchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolSearchToolResultBlockParamContentUnion) GetToolReferences() []BetaToolReferenceBlockParam {\n\tif vt := u.OfRequestToolSearchToolSearchResultBlock; vt != nil {\n\t\treturn vt.ToolReferences\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolSearchToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestToolSearchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestToolSearchToolSearchResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BetaToolSearchToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode    BetaToolSearchToolResultErrorErrorCode `json:\"error_code\" api:\"required\"`\n\tErrorMessage string                                 `json:\"error_message\" api:\"required\"`\n\tType         constant.ToolSearchToolResultError     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode    respjson.Field\n\t\tErrorMessage respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaToolSearchToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaToolSearchToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaToolSearchToolResultErrorErrorCode string\n\nconst (\n\tBetaToolSearchToolResultErrorErrorCodeInvalidToolInput      BetaToolSearchToolResultErrorErrorCode = \"invalid_tool_input\"\n\tBetaToolSearchToolResultErrorErrorCodeUnavailable           BetaToolSearchToolResultErrorErrorCode = \"unavailable\"\n\tBetaToolSearchToolResultErrorErrorCodeTooManyRequests       BetaToolSearchToolResultErrorErrorCode = \"too_many_requests\"\n\tBetaToolSearchToolResultErrorErrorCodeExecutionTimeExceeded BetaToolSearchToolResultErrorErrorCode = \"execution_time_exceeded\"\n)\n\n// The properties ErrorCode, Type are required.\ntype BetaToolSearchToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode BetaToolSearchToolResultErrorParamErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_result_error\".\n\tType constant.ToolSearchToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolSearchToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolSearchToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolSearchToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaToolSearchToolResultErrorParamErrorCode string\n\nconst (\n\tBetaToolSearchToolResultErrorParamErrorCodeInvalidToolInput      BetaToolSearchToolResultErrorParamErrorCode = \"invalid_tool_input\"\n\tBetaToolSearchToolResultErrorParamErrorCodeUnavailable           BetaToolSearchToolResultErrorParamErrorCode = \"unavailable\"\n\tBetaToolSearchToolResultErrorParamErrorCodeTooManyRequests       BetaToolSearchToolResultErrorParamErrorCode = \"too_many_requests\"\n\tBetaToolSearchToolResultErrorParamErrorCodeExecutionTimeExceeded BetaToolSearchToolResultErrorParamErrorCode = \"execution_time_exceeded\"\n)\n\ntype BetaToolSearchToolSearchResultBlock struct {\n\tToolReferences []BetaToolReferenceBlock            `json:\"tool_references\" api:\"required\"`\n\tType           constant.ToolSearchToolSearchResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolReferences respjson.Field\n\t\tType           respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaToolSearchToolSearchResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaToolSearchToolSearchResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ToolReferences, Type are required.\ntype BetaToolSearchToolSearchResultBlockParam struct {\n\tToolReferences []BetaToolReferenceBlockParam `json:\"tool_references,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_search_result\".\n\tType constant.ToolSearchToolSearchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolSearchToolSearchResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolSearchToolSearchResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolSearchToolSearchResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaToolTextEditor20241022Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_editor\".\n\tName constant.StrReplaceEditor `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20241022\".\n\tType constant.TextEditor20241022 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolTextEditor20241022Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolTextEditor20241022Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolTextEditor20241022Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaToolTextEditor20250124Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_editor\".\n\tName constant.StrReplaceEditor `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20250124\".\n\tType constant.TextEditor20250124 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolTextEditor20250124Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolTextEditor20250124Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolTextEditor20250124Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaToolTextEditor20250429Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_based_edit_tool\".\n\tName constant.StrReplaceBasedEditTool `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20250429\".\n\tType constant.TextEditor20250429 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolTextEditor20250429Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolTextEditor20250429Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolTextEditor20250429Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaToolTextEditor20250728Param struct {\n\t// Maximum number of characters to display when viewing a file. If not specified,\n\t// defaults to displaying the full file.\n\tMaxCharacters param.Opt[int64] `json:\"max_characters,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any               `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_based_edit_tool\".\n\tName constant.StrReplaceBasedEditTool `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20250728\".\n\tType constant.TextEditor20250728 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolTextEditor20250728Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolTextEditor20250728Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolTextEditor20250728Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc BetaToolUnionParamOfTool(inputSchema BetaToolInputSchemaParam, name string) BetaToolUnionParam {\n\tvar variant BetaToolParam\n\tvariant.InputSchema = inputSchema\n\tvariant.Name = name\n\treturn BetaToolUnionParam{OfTool: &variant}\n}\n\nfunc BetaToolUnionParamOfComputerUseTool20241022(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam {\n\tvar variant BetaToolComputerUse20241022Param\n\tvariant.DisplayHeightPx = displayHeightPx\n\tvariant.DisplayWidthPx = displayWidthPx\n\treturn BetaToolUnionParam{OfComputerUseTool20241022: &variant}\n}\n\nfunc BetaToolUnionParamOfComputerUseTool20250124(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam {\n\tvar variant BetaToolComputerUse20250124Param\n\tvariant.DisplayHeightPx = displayHeightPx\n\tvariant.DisplayWidthPx = displayWidthPx\n\treturn BetaToolUnionParam{OfComputerUseTool20250124: &variant}\n}\n\nfunc BetaToolUnionParamOfComputerUseTool20251124(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam {\n\tvar variant BetaToolComputerUse20251124Param\n\tvariant.DisplayHeightPx = displayHeightPx\n\tvariant.DisplayWidthPx = displayWidthPx\n\treturn BetaToolUnionParam{OfComputerUseTool20251124: &variant}\n}\n\nfunc BetaToolUnionParamOfToolSearchToolBm25_20251119(type_ BetaToolSearchToolBm25_20251119Type) BetaToolUnionParam {\n\tvar variant BetaToolSearchToolBm25_20251119Param\n\tvariant.Type = type_\n\treturn BetaToolUnionParam{OfToolSearchToolBm25_20251119: &variant}\n}\n\nfunc BetaToolUnionParamOfToolSearchToolRegex20251119(type_ BetaToolSearchToolRegex20251119Type) BetaToolUnionParam {\n\tvar variant BetaToolSearchToolRegex20251119Param\n\tvariant.Type = type_\n\treturn BetaToolUnionParam{OfToolSearchToolRegex20251119: &variant}\n}\n\nfunc BetaToolUnionParamOfMCPToolset(mcpServerName string) BetaToolUnionParam {\n\tvar variant BetaMCPToolsetParam\n\tvariant.MCPServerName = mcpServerName\n\treturn BetaToolUnionParam{OfMCPToolset: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaToolUnionParam struct {\n\tOfTool                        *BetaToolParam                        `json:\",omitzero,inline\"`\n\tOfBashTool20241022            *BetaToolBash20241022Param            `json:\",omitzero,inline\"`\n\tOfBashTool20250124            *BetaToolBash20250124Param            `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250522   *BetaCodeExecutionTool20250522Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250825   *BetaCodeExecutionTool20250825Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20260120   *BetaCodeExecutionTool20260120Param   `json:\",omitzero,inline\"`\n\tOfComputerUseTool20241022     *BetaToolComputerUse20241022Param     `json:\",omitzero,inline\"`\n\tOfMemoryTool20250818          *BetaMemoryTool20250818Param          `json:\",omitzero,inline\"`\n\tOfComputerUseTool20250124     *BetaToolComputerUse20250124Param     `json:\",omitzero,inline\"`\n\tOfTextEditor20241022          *BetaToolTextEditor20241022Param      `json:\",omitzero,inline\"`\n\tOfComputerUseTool20251124     *BetaToolComputerUse20251124Param     `json:\",omitzero,inline\"`\n\tOfTextEditor20250124          *BetaToolTextEditor20250124Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250429          *BetaToolTextEditor20250429Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250728          *BetaToolTextEditor20250728Param      `json:\",omitzero,inline\"`\n\tOfWebSearchTool20250305       *BetaWebSearchTool20250305Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20250910        *BetaWebFetchTool20250910Param        `json:\",omitzero,inline\"`\n\tOfWebSearchTool20260209       *BetaWebSearchTool20260209Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260209        *BetaWebFetchTool20260209Param        `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260309        *BetaWebFetchTool20260309Param        `json:\",omitzero,inline\"`\n\tOfToolSearchToolBm25_20251119 *BetaToolSearchToolBm25_20251119Param `json:\",omitzero,inline\"`\n\tOfToolSearchToolRegex20251119 *BetaToolSearchToolRegex20251119Param `json:\",omitzero,inline\"`\n\tOfMCPToolset                  *BetaMCPToolsetParam                  `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaToolUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfTool,\n\t\tu.OfBashTool20241022,\n\t\tu.OfBashTool20250124,\n\t\tu.OfCodeExecutionTool20250522,\n\t\tu.OfCodeExecutionTool20250825,\n\t\tu.OfCodeExecutionTool20260120,\n\t\tu.OfComputerUseTool20241022,\n\t\tu.OfMemoryTool20250818,\n\t\tu.OfComputerUseTool20250124,\n\t\tu.OfTextEditor20241022,\n\t\tu.OfComputerUseTool20251124,\n\t\tu.OfTextEditor20250124,\n\t\tu.OfTextEditor20250429,\n\t\tu.OfTextEditor20250728,\n\t\tu.OfWebSearchTool20250305,\n\t\tu.OfWebFetchTool20250910,\n\t\tu.OfWebSearchTool20260209,\n\t\tu.OfWebFetchTool20260209,\n\t\tu.OfWebFetchTool20260309,\n\t\tu.OfToolSearchToolBm25_20251119,\n\t\tu.OfToolSearchToolRegex20251119,\n\t\tu.OfMCPToolset)\n}\nfunc (u *BetaToolUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaToolUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfTool) {\n\t\treturn u.OfTool\n\t} else if !param.IsOmitted(u.OfBashTool20241022) {\n\t\treturn u.OfBashTool20241022\n\t} else if !param.IsOmitted(u.OfBashTool20250124) {\n\t\treturn u.OfBashTool20250124\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250522) {\n\t\treturn u.OfCodeExecutionTool20250522\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250825) {\n\t\treturn u.OfCodeExecutionTool20250825\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20260120) {\n\t\treturn u.OfCodeExecutionTool20260120\n\t} else if !param.IsOmitted(u.OfComputerUseTool20241022) {\n\t\treturn u.OfComputerUseTool20241022\n\t} else if !param.IsOmitted(u.OfMemoryTool20250818) {\n\t\treturn u.OfMemoryTool20250818\n\t} else if !param.IsOmitted(u.OfComputerUseTool20250124) {\n\t\treturn u.OfComputerUseTool20250124\n\t} else if !param.IsOmitted(u.OfTextEditor20241022) {\n\t\treturn u.OfTextEditor20241022\n\t} else if !param.IsOmitted(u.OfComputerUseTool20251124) {\n\t\treturn u.OfComputerUseTool20251124\n\t} else if !param.IsOmitted(u.OfTextEditor20250124) {\n\t\treturn u.OfTextEditor20250124\n\t} else if !param.IsOmitted(u.OfTextEditor20250429) {\n\t\treturn u.OfTextEditor20250429\n\t} else if !param.IsOmitted(u.OfTextEditor20250728) {\n\t\treturn u.OfTextEditor20250728\n\t} else if !param.IsOmitted(u.OfWebSearchTool20250305) {\n\t\treturn u.OfWebSearchTool20250305\n\t} else if !param.IsOmitted(u.OfWebFetchTool20250910) {\n\t\treturn u.OfWebFetchTool20250910\n\t} else if !param.IsOmitted(u.OfWebSearchTool20260209) {\n\t\treturn u.OfWebSearchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260209) {\n\t\treturn u.OfWebFetchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260309) {\n\t\treturn u.OfWebFetchTool20260309\n\t} else if !param.IsOmitted(u.OfToolSearchToolBm25_20251119) {\n\t\treturn u.OfToolSearchToolBm25_20251119\n\t} else if !param.IsOmitted(u.OfToolSearchToolRegex20251119) {\n\t\treturn u.OfToolSearchToolRegex20251119\n\t} else if !param.IsOmitted(u.OfMCPToolset) {\n\t\treturn u.OfMCPToolset\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetInputSchema() *BetaToolInputSchemaParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.InputSchema\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetDescription() *string {\n\tif vt := u.OfTool; vt != nil && vt.Description.Valid() {\n\t\treturn &vt.Description.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetEagerInputStreaming() *bool {\n\tif vt := u.OfTool; vt != nil && vt.EagerInputStreaming.Valid() {\n\t\treturn &vt.EagerInputStreaming.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetEnableZoom() *bool {\n\tif vt := u.OfComputerUseTool20251124; vt != nil && vt.EnableZoom.Valid() {\n\t\treturn &vt.EnableZoom.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetMaxCharacters() *int64 {\n\tif vt := u.OfTextEditor20250728; vt != nil && vt.MaxCharacters.Valid() {\n\t\treturn &vt.MaxCharacters.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetUseCache() *bool {\n\tif vt := u.OfWebFetchTool20260309; vt != nil && vt.UseCache.Valid() {\n\t\treturn &vt.UseCache.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetMCPServerName() *string {\n\tif vt := u.OfMCPToolset; vt != nil {\n\t\treturn &vt.MCPServerName\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetConfigs() map[string]BetaMCPToolConfigParam {\n\tif vt := u.OfMCPToolset; vt != nil {\n\t\treturn vt.Configs\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetDefaultConfig() *BetaMCPToolDefaultConfigParam {\n\tif vt := u.OfMCPToolset; vt != nil {\n\t\treturn &vt.DefaultConfig\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetName() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetDeferLoading() *bool {\n\tif vt := u.OfTool; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfBashTool20241022; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20241022; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetStrict() *bool {\n\tif vt := u.OfTool; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfBashTool20241022; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20241022; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetType() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMCPToolset; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetDisplayHeightPx() *int64 {\n\tif vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*int64)(&vt.DisplayHeightPx)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayHeightPx)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayHeightPx)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetDisplayWidthPx() *int64 {\n\tif vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*int64)(&vt.DisplayWidthPx)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayWidthPx)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayWidthPx)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetDisplayNumber() *int64 {\n\tif vt := u.OfComputerUseTool20241022; vt != nil && vt.DisplayNumber.Valid() {\n\t\treturn &vt.DisplayNumber.Value\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil && vt.DisplayNumber.Valid() {\n\t\treturn &vt.DisplayNumber.Value\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil && vt.DisplayNumber.Valid() {\n\t\treturn &vt.DisplayNumber.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetMaxUses() *int64 {\n\tif vt := u.OfWebSearchTool20250305; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUnionParam) GetMaxContentTokens() *int64 {\n\tif vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedCallers property, if\n// present.\nfunc (u BetaToolUnionParam) GetAllowedCallers() []string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u BetaToolUnionParam) GetCacheControl() *BetaCacheControlEphemeralParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMCPToolset; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's InputExamples property, if\n// present.\nfunc (u BetaToolUnionParam) GetInputExamples() []map[string]any {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.InputExamples\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedDomains property, if\n// present.\nfunc (u BetaToolUnionParam) GetAllowedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's BlockedDomains property, if\n// present.\nfunc (u BetaToolUnionParam) GetBlockedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.BlockedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's UserLocation property, if present.\nfunc (u BetaToolUnionParam) GetUserLocation() *BetaUserLocationParam {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.UserLocation\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.UserLocation\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's Citations property, if present.\nfunc (u BetaToolUnionParam) GetCitations() *BetaCitationsConfigParam {\n\tif vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.Citations\n\t}\n\treturn nil\n}\n\ntype BetaToolUseBlock struct {\n\tID    string           `json:\"id\" api:\"required\"`\n\tInput any              `json:\"input\" api:\"required\"`\n\tName  string           `json:\"name\" api:\"required\"`\n\tType  constant.ToolUse `json:\"type\" api:\"required\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaToolUseBlockCallerUnion `json:\"caller\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tInput       respjson.Field\n\t\tName        respjson.Field\n\t\tType        respjson.Field\n\t\tCaller      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaToolUseBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaToolUseBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaToolUseBlockCallerUnion contains all possible properties and values from\n// [BetaDirectCaller], [BetaServerToolCaller], [BetaServerToolCaller20260120].\n//\n// Use the [BetaToolUseBlockCallerUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaToolUseBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyBetaToolUseBlockCaller is implemented by each variant of\n// [BetaToolUseBlockCallerUnion] to add type safety for the return type of\n// [BetaToolUseBlockCallerUnion.AsAny]\ntype anyBetaToolUseBlockCaller interface {\n\timplBetaToolUseBlockCallerUnion()\n}\n\nfunc (BetaDirectCaller) implBetaToolUseBlockCallerUnion()             {}\nfunc (BetaServerToolCaller) implBetaToolUseBlockCallerUnion()         {}\nfunc (BetaServerToolCaller20260120) implBetaToolUseBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaToolUseBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.BetaDirectCaller:\n//\tcase anthropic.BetaServerToolCaller:\n//\tcase anthropic.BetaServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaToolUseBlockCallerUnion) AsAny() anyBetaToolUseBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u BetaToolUseBlockCallerUnion) AsDirect() (v BetaDirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaToolUseBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaToolUseBlockCallerUnion) AsCodeExecution20260120() (v BetaServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaToolUseBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaToolUseBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ID, Input, Name, Type are required.\ntype BetaToolUseBlockParam struct {\n\tID    string `json:\"id\" api:\"required\"`\n\tInput any    `json:\"input,omitzero\" api:\"required\"`\n\tName  string `json:\"name\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaToolUseBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_use\".\n\tType constant.ToolUse `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolUseBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolUseBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolUseBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaToolUseBlockParamCallerUnion struct {\n\tOfDirect                *BetaDirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *BetaServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *BetaServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaToolUseBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *BetaToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaToolUseBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUseBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaToolUseBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\n// The properties Type, Value are required.\ntype BetaToolUsesKeepParam struct {\n\tValue int64 `json:\"value\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_uses\".\n\tType constant.ToolUses `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolUsesKeepParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolUsesKeepParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolUsesKeepParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, Value are required.\ntype BetaToolUsesTriggerParam struct {\n\tValue int64 `json:\"value\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_uses\".\n\tType constant.ToolUses `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaToolUsesTriggerParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaToolUsesTriggerParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaToolUsesTriggerParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, URL are required.\ntype BetaURLImageSourceParam struct {\n\tURL string `json:\"url\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"url\".\n\tType constant.URL `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaURLImageSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaURLImageSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaURLImageSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, URL are required.\ntype BetaURLPDFSourceParam struct {\n\tURL string `json:\"url\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"url\".\n\tType constant.URL `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaURLPDFSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaURLPDFSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaURLPDFSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaUsage struct {\n\t// Breakdown of cached tokens by TTL\n\tCacheCreation BetaCacheCreation `json:\"cache_creation\" api:\"required\"`\n\t// The number of input tokens used to create the cache entry.\n\tCacheCreationInputTokens int64 `json:\"cache_creation_input_tokens\" api:\"required\"`\n\t// The number of input tokens read from the cache.\n\tCacheReadInputTokens int64 `json:\"cache_read_input_tokens\" api:\"required\"`\n\t// The geographic region where inference was performed for this request.\n\tInferenceGeo string `json:\"inference_geo\" api:\"required\"`\n\t// The number of input tokens which were used.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// Per-iteration token usage breakdown.\n\t//\n\t// Each entry represents one sampling iteration, with its own input/output token\n\t// counts and cache statistics. This allows you to:\n\t//\n\t// - Determine which iterations exceeded long context thresholds (>=200k tokens)\n\t// - Calculate the true context window size from the last iteration\n\t// - Understand token accumulation across server-side tool use loops\n\tIterations BetaIterationsUsage `json:\"iterations\" api:\"required\"`\n\t// The number of output tokens which were used.\n\tOutputTokens int64 `json:\"output_tokens\" api:\"required\"`\n\t// The number of server tool requests.\n\tServerToolUse BetaServerToolUsage `json:\"server_tool_use\" api:\"required\"`\n\t// If the request used the priority, standard, or batch tier.\n\t//\n\t// Any of \"standard\", \"priority\", \"batch\".\n\tServiceTier BetaUsageServiceTier `json:\"service_tier\" api:\"required\"`\n\t// The inference speed mode used for this request.\n\t//\n\t// Any of \"standard\", \"fast\".\n\tSpeed BetaUsageSpeed `json:\"speed\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCacheCreation            respjson.Field\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInferenceGeo             respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tIterations               respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tServerToolUse            respjson.Field\n\t\tServiceTier              respjson.Field\n\t\tSpeed                    respjson.Field\n\t\tExtraFields              map[string]respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// If the request used the priority, standard, or batch tier.\ntype BetaUsageServiceTier string\n\nconst (\n\tBetaUsageServiceTierStandard BetaUsageServiceTier = \"standard\"\n\tBetaUsageServiceTierPriority BetaUsageServiceTier = \"priority\"\n\tBetaUsageServiceTierBatch    BetaUsageServiceTier = \"batch\"\n)\n\n// The inference speed mode used for this request.\ntype BetaUsageSpeed string\n\nconst (\n\tBetaUsageSpeedStandard BetaUsageSpeed = \"standard\"\n\tBetaUsageSpeedFast     BetaUsageSpeed = \"fast\"\n)\n\n// The property Type is required.\ntype BetaUserLocationParam struct {\n\t// The city of the user.\n\tCity param.Opt[string] `json:\"city,omitzero\"`\n\t// The two letter\n\t// [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the\n\t// user.\n\tCountry param.Opt[string] `json:\"country,omitzero\"`\n\t// The region of the user.\n\tRegion param.Opt[string] `json:\"region,omitzero\"`\n\t// The [IANA timezone](https://nodatime.org/TimeZones) of the user.\n\tTimezone param.Opt[string] `json:\"timezone,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"approximate\".\n\tType constant.Approximate `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaUserLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaUserLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaUserLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaWebFetchBlock struct {\n\tContent BetaDocumentBlock `json:\"content\" api:\"required\"`\n\t// ISO 8601 timestamp when the content was retrieved\n\tRetrievedAt string                  `json:\"retrieved_at\" api:\"required\"`\n\tType        constant.WebFetchResult `json:\"type\" api:\"required\"`\n\t// Fetched content URL\n\tURL string `json:\"url\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tRetrievedAt respjson.Field\n\t\tType        respjson.Field\n\t\tURL         respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaWebFetchBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaWebFetchBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, Type, URL are required.\ntype BetaWebFetchBlockParam struct {\n\tContent BetaRequestDocumentBlockParam `json:\"content,omitzero\" api:\"required\"`\n\t// Fetched content URL\n\tURL string `json:\"url\" api:\"required\"`\n\t// ISO 8601 timestamp when the content was retrieved\n\tRetrievedAt param.Opt[string] `json:\"retrieved_at,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"web_fetch_result\".\n\tType constant.WebFetchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebFetchBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebFetchBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebFetchBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaWebFetchTool20250910Param struct {\n\t// Maximum number of tokens used by including web page text content in the context.\n\t// The limit is approximate and does not apply to binary content such as PDFs.\n\tMaxContentTokens param.Opt[int64] `json:\"max_content_tokens,omitzero\"`\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// List of domains to allow fetching from\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// List of domains to block fetching from\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Citations configuration for fetched documents. Citations are disabled by\n\t// default.\n\tCitations BetaCitationsConfigParam `json:\"citations,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_fetch\".\n\tName constant.WebFetch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_20250910\".\n\tType constant.WebFetch20250910 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebFetchTool20250910Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebFetchTool20250910Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebFetchTool20250910Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaWebFetchTool20260209Param struct {\n\t// Maximum number of tokens used by including web page text content in the context.\n\t// The limit is approximate and does not apply to binary content such as PDFs.\n\tMaxContentTokens param.Opt[int64] `json:\"max_content_tokens,omitzero\"`\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// List of domains to allow fetching from\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// List of domains to block fetching from\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Citations configuration for fetched documents. Citations are disabled by\n\t// default.\n\tCitations BetaCitationsConfigParam `json:\"citations,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_fetch\".\n\tName constant.WebFetch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_20260209\".\n\tType constant.WebFetch20260209 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebFetchTool20260209Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebFetchTool20260209Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebFetchTool20260209Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Web fetch tool with use_cache parameter for bypassing cached content.\n//\n// The properties Name, Type are required.\ntype BetaWebFetchTool20260309Param struct {\n\t// Maximum number of tokens used by including web page text content in the context.\n\t// The limit is approximate and does not apply to binary content such as PDFs.\n\tMaxContentTokens param.Opt[int64] `json:\"max_content_tokens,omitzero\"`\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Whether to use cached content. Set to false to bypass the cache and fetch fresh\n\t// content. Only set to false when the user explicitly requests fresh content or\n\t// when fetching rapidly-changing sources.\n\tUseCache param.Opt[bool] `json:\"use_cache,omitzero\"`\n\t// List of domains to allow fetching from\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// List of domains to block fetching from\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Citations configuration for fetched documents. Citations are disabled by\n\t// default.\n\tCitations BetaCitationsConfigParam `json:\"citations,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_fetch\".\n\tName constant.WebFetch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_20260309\".\n\tType constant.WebFetch20260309 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebFetchTool20260309Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebFetchTool20260309Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebFetchTool20260309Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaWebFetchToolResultBlock struct {\n\tContent   BetaWebFetchToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                  `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.WebFetchToolResult             `json:\"type\" api:\"required\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaWebFetchToolResultBlockCallerUnion `json:\"caller\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tCaller      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaWebFetchToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaWebFetchToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaWebFetchToolResultBlockContentUnion contains all possible properties and\n// values from [BetaWebFetchToolResultErrorBlock], [BetaWebFetchBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaWebFetchToolResultBlockContentUnion struct {\n\t// This field is from variant [BetaWebFetchToolResultErrorBlock].\n\tErrorCode BetaWebFetchToolResultErrorCode `json:\"error_code\"`\n\tType      string                          `json:\"type\"`\n\t// This field is from variant [BetaWebFetchBlock].\n\tContent BetaDocumentBlock `json:\"content\"`\n\t// This field is from variant [BetaWebFetchBlock].\n\tRetrievedAt string `json:\"retrieved_at\"`\n\t// This field is from variant [BetaWebFetchBlock].\n\tURL  string `json:\"url\"`\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tContent     respjson.Field\n\t\tRetrievedAt respjson.Field\n\t\tURL         respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaWebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError() (v BetaWebFetchToolResultErrorBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaWebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock() (v BetaWebFetchBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaWebFetchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaWebFetchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaWebFetchToolResultBlockCallerUnion contains all possible properties and\n// values from [BetaDirectCaller], [BetaServerToolCaller],\n// [BetaServerToolCaller20260120].\n//\n// Use the [BetaWebFetchToolResultBlockCallerUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaWebFetchToolResultBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyBetaWebFetchToolResultBlockCaller is implemented by each variant of\n// [BetaWebFetchToolResultBlockCallerUnion] to add type safety for the return type\n// of [BetaWebFetchToolResultBlockCallerUnion.AsAny]\ntype anyBetaWebFetchToolResultBlockCaller interface {\n\timplBetaWebFetchToolResultBlockCallerUnion()\n}\n\nfunc (BetaDirectCaller) implBetaWebFetchToolResultBlockCallerUnion()             {}\nfunc (BetaServerToolCaller) implBetaWebFetchToolResultBlockCallerUnion()         {}\nfunc (BetaServerToolCaller20260120) implBetaWebFetchToolResultBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaWebFetchToolResultBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.BetaDirectCaller:\n//\tcase anthropic.BetaServerToolCaller:\n//\tcase anthropic.BetaServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaWebFetchToolResultBlockCallerUnion) AsAny() anyBetaWebFetchToolResultBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u BetaWebFetchToolResultBlockCallerUnion) AsDirect() (v BetaDirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaWebFetchToolResultBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaWebFetchToolResultBlockCallerUnion) AsCodeExecution20260120() (v BetaServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaWebFetchToolResultBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaWebFetchToolResultBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BetaWebFetchToolResultBlockParam struct {\n\tContent   BetaWebFetchToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                       `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaWebFetchToolResultBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_tool_result\".\n\tType constant.WebFetchToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebFetchToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebFetchToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebFetchToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaWebFetchToolResultBlockParamContentUnion struct {\n\tOfRequestWebFetchToolResultError *BetaWebFetchToolResultErrorBlockParam `json:\",omitzero,inline\"`\n\tOfRequestWebFetchResultBlock     *BetaWebFetchBlockParam                `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaWebFetchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestWebFetchToolResultError, u.OfRequestWebFetchResultBlock)\n}\nfunc (u *BetaWebFetchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaWebFetchToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestWebFetchToolResultError) {\n\t\treturn u.OfRequestWebFetchToolResultError\n\t} else if !param.IsOmitted(u.OfRequestWebFetchResultBlock) {\n\t\treturn u.OfRequestWebFetchResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestWebFetchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamContentUnion) GetContent() *BetaRequestDocumentBlockParam {\n\tif vt := u.OfRequestWebFetchResultBlock; vt != nil {\n\t\treturn &vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamContentUnion) GetURL() *string {\n\tif vt := u.OfRequestWebFetchResultBlock; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamContentUnion) GetRetrievedAt() *string {\n\tif vt := u.OfRequestWebFetchResultBlock; vt != nil && vt.RetrievedAt.Valid() {\n\t\treturn &vt.RetrievedAt.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestWebFetchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestWebFetchResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaWebFetchToolResultBlockParamCallerUnion struct {\n\tOfDirect                *BetaDirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *BetaServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *BetaServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaWebFetchToolResultBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *BetaWebFetchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaWebFetchToolResultBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebFetchToolResultBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\ntype BetaWebFetchToolResultErrorBlock struct {\n\t// Any of \"invalid_tool_input\", \"url_too_long\", \"url_not_allowed\",\n\t// \"url_not_accessible\", \"unsupported_content_type\", \"too_many_requests\",\n\t// \"max_uses_exceeded\", \"unavailable\".\n\tErrorCode BetaWebFetchToolResultErrorCode  `json:\"error_code\" api:\"required\"`\n\tType      constant.WebFetchToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaWebFetchToolResultErrorBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaWebFetchToolResultErrorBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ErrorCode, Type are required.\ntype BetaWebFetchToolResultErrorBlockParam struct {\n\t// Any of \"invalid_tool_input\", \"url_too_long\", \"url_not_allowed\",\n\t// \"url_not_accessible\", \"unsupported_content_type\", \"too_many_requests\",\n\t// \"max_uses_exceeded\", \"unavailable\".\n\tErrorCode BetaWebFetchToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_tool_result_error\".\n\tType constant.WebFetchToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebFetchToolResultErrorBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebFetchToolResultErrorBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebFetchToolResultErrorBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaWebFetchToolResultErrorCode string\n\nconst (\n\tBetaWebFetchToolResultErrorCodeInvalidToolInput       BetaWebFetchToolResultErrorCode = \"invalid_tool_input\"\n\tBetaWebFetchToolResultErrorCodeURLTooLong             BetaWebFetchToolResultErrorCode = \"url_too_long\"\n\tBetaWebFetchToolResultErrorCodeURLNotAllowed          BetaWebFetchToolResultErrorCode = \"url_not_allowed\"\n\tBetaWebFetchToolResultErrorCodeURLNotAccessible       BetaWebFetchToolResultErrorCode = \"url_not_accessible\"\n\tBetaWebFetchToolResultErrorCodeUnsupportedContentType BetaWebFetchToolResultErrorCode = \"unsupported_content_type\"\n\tBetaWebFetchToolResultErrorCodeTooManyRequests        BetaWebFetchToolResultErrorCode = \"too_many_requests\"\n\tBetaWebFetchToolResultErrorCodeMaxUsesExceeded        BetaWebFetchToolResultErrorCode = \"max_uses_exceeded\"\n\tBetaWebFetchToolResultErrorCodeUnavailable            BetaWebFetchToolResultErrorCode = \"unavailable\"\n)\n\ntype BetaWebSearchResultBlock struct {\n\tEncryptedContent string                   `json:\"encrypted_content\" api:\"required\"`\n\tPageAge          string                   `json:\"page_age\" api:\"required\"`\n\tTitle            string                   `json:\"title\" api:\"required\"`\n\tType             constant.WebSearchResult `json:\"type\" api:\"required\"`\n\tURL              string                   `json:\"url\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tEncryptedContent respjson.Field\n\t\tPageAge          respjson.Field\n\t\tTitle            respjson.Field\n\t\tType             respjson.Field\n\t\tURL              respjson.Field\n\t\tExtraFields      map[string]respjson.Field\n\t\traw              string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaWebSearchResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaWebSearchResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties EncryptedContent, Title, Type, URL are required.\ntype BetaWebSearchResultBlockParam struct {\n\tEncryptedContent string            `json:\"encrypted_content\" api:\"required\"`\n\tTitle            string            `json:\"title\" api:\"required\"`\n\tURL              string            `json:\"url\" api:\"required\"`\n\tPageAge          param.Opt[string] `json:\"page_age,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_result\".\n\tType constant.WebSearchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebSearchResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebSearchResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebSearchResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaWebSearchTool20250305Param struct {\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// If provided, only these domains will be included in results. Cannot be used\n\t// alongside `blocked_domains`.\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// If provided, these domains will never appear in results. Cannot be used\n\t// alongside `allowed_domains`.\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Parameters for the user's location. Used to provide more relevant search\n\t// results.\n\tUserLocation BetaUserLocationParam `json:\"user_location,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_search\".\n\tName constant.WebSearch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_20250305\".\n\tType constant.WebSearch20250305 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebSearchTool20250305Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebSearchTool20250305Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebSearchTool20250305Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype BetaWebSearchTool20260209Param struct {\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// If provided, only these domains will be included in results. Cannot be used\n\t// alongside `blocked_domains`.\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// If provided, these domains will never appear in results. Cannot be used\n\t// alongside `allowed_domains`.\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Parameters for the user's location. Used to provide more relevant search\n\t// results.\n\tUserLocation BetaUserLocationParam `json:\"user_location,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_search\".\n\tName constant.WebSearch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_20260209\".\n\tType constant.WebSearch20260209 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebSearchTool20260209Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebSearchTool20260209Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebSearchTool20260209Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ErrorCode, Type are required.\ntype BetaWebSearchToolRequestErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"max_uses_exceeded\",\n\t// \"too_many_requests\", \"query_too_long\", \"request_too_large\".\n\tErrorCode BetaWebSearchToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_tool_result_error\".\n\tType constant.WebSearchToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebSearchToolRequestErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebSearchToolRequestErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebSearchToolRequestErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaWebSearchToolResultBlock struct {\n\tContent   BetaWebSearchToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                   `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.WebSearchToolResult             `json:\"type\" api:\"required\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaWebSearchToolResultBlockCallerUnion `json:\"caller\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tCaller      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaWebSearchToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaWebSearchToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaWebSearchToolResultBlockCallerUnion contains all possible properties and\n// values from [BetaDirectCaller], [BetaServerToolCaller],\n// [BetaServerToolCaller20260120].\n//\n// Use the [BetaWebSearchToolResultBlockCallerUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaWebSearchToolResultBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyBetaWebSearchToolResultBlockCaller is implemented by each variant of\n// [BetaWebSearchToolResultBlockCallerUnion] to add type safety for the return type\n// of [BetaWebSearchToolResultBlockCallerUnion.AsAny]\ntype anyBetaWebSearchToolResultBlockCaller interface {\n\timplBetaWebSearchToolResultBlockCallerUnion()\n}\n\nfunc (BetaDirectCaller) implBetaWebSearchToolResultBlockCallerUnion()             {}\nfunc (BetaServerToolCaller) implBetaWebSearchToolResultBlockCallerUnion()         {}\nfunc (BetaServerToolCaller20260120) implBetaWebSearchToolResultBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaWebSearchToolResultBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.BetaDirectCaller:\n//\tcase anthropic.BetaServerToolCaller:\n//\tcase anthropic.BetaServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaWebSearchToolResultBlockCallerUnion) AsAny() anyBetaWebSearchToolResultBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u BetaWebSearchToolResultBlockCallerUnion) AsDirect() (v BetaDirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaWebSearchToolResultBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaWebSearchToolResultBlockCallerUnion) AsCodeExecution20260120() (v BetaServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaWebSearchToolResultBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaWebSearchToolResultBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaWebSearchToolResultBlockContentUnion contains all possible properties and\n// values from [BetaWebSearchToolResultError], [[]BetaWebSearchResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfBetaWebSearchResultBlockArray]\ntype BetaWebSearchToolResultBlockContentUnion struct {\n\t// This field will be present if the value is a [[]BetaWebSearchResultBlock]\n\t// instead of an object.\n\tOfBetaWebSearchResultBlockArray []BetaWebSearchResultBlock `json:\",inline\"`\n\t// This field is from variant [BetaWebSearchToolResultError].\n\tErrorCode BetaWebSearchToolResultErrorCode `json:\"error_code\"`\n\t// This field is from variant [BetaWebSearchToolResultError].\n\tType constant.WebSearchToolResultError `json:\"type\"`\n\tJSON struct {\n\t\tOfBetaWebSearchResultBlockArray respjson.Field\n\t\tErrorCode                       respjson.Field\n\t\tType                            respjson.Field\n\t\traw                             string\n\t} `json:\"-\"`\n}\n\nfunc (u BetaWebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v BetaWebSearchToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaWebSearchToolResultBlockContentUnion) AsBetaWebSearchResultBlockArray() (v []BetaWebSearchResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaWebSearchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaWebSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BetaWebSearchToolResultBlockParam struct {\n\tContent   BetaWebSearchToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                        `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller BetaWebSearchToolResultBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_tool_result\".\n\tType constant.WebSearchToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaWebSearchToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaWebSearchToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaWebSearchToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaWebSearchToolResultBlockParamCallerUnion struct {\n\tOfDirect                *BetaDirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *BetaServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *BetaServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaWebSearchToolResultBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *BetaWebSearchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaWebSearchToolResultBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebSearchToolResultBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaWebSearchToolResultBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\nfunc BetaNewWebSearchToolRequestError(errorCode BetaWebSearchToolResultErrorCode) BetaWebSearchToolResultBlockParamContentUnion {\n\tvar variant BetaWebSearchToolRequestErrorParam\n\tvariant.ErrorCode = errorCode\n\treturn BetaWebSearchToolResultBlockParamContentUnion{OfError: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaWebSearchToolResultBlockParamContentUnion struct {\n\tOfResultBlock []BetaWebSearchResultBlockParam     `json:\",omitzero,inline\"`\n\tOfError       *BetaWebSearchToolRequestErrorParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaWebSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfResultBlock, u.OfError)\n}\nfunc (u *BetaWebSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaWebSearchToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfResultBlock) {\n\t\treturn &u.OfResultBlock\n\t} else if !param.IsOmitted(u.OfError) {\n\t\treturn u.OfError\n\t}\n\treturn nil\n}\n\ntype BetaWebSearchToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"max_uses_exceeded\",\n\t// \"too_many_requests\", \"query_too_long\", \"request_too_large\".\n\tErrorCode BetaWebSearchToolResultErrorCode  `json:\"error_code\" api:\"required\"`\n\tType      constant.WebSearchToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaWebSearchToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaWebSearchToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaWebSearchToolResultErrorCode string\n\nconst (\n\tBetaWebSearchToolResultErrorCodeInvalidToolInput BetaWebSearchToolResultErrorCode = \"invalid_tool_input\"\n\tBetaWebSearchToolResultErrorCodeUnavailable      BetaWebSearchToolResultErrorCode = \"unavailable\"\n\tBetaWebSearchToolResultErrorCodeMaxUsesExceeded  BetaWebSearchToolResultErrorCode = \"max_uses_exceeded\"\n\tBetaWebSearchToolResultErrorCodeTooManyRequests  BetaWebSearchToolResultErrorCode = \"too_many_requests\"\n\tBetaWebSearchToolResultErrorCodeQueryTooLong     BetaWebSearchToolResultErrorCode = \"query_too_long\"\n\tBetaWebSearchToolResultErrorCodeRequestTooLarge  BetaWebSearchToolResultErrorCode = \"request_too_large\"\n)\n\ntype BetaMessageNewParams struct {\n\t// The maximum number of tokens to generate before stopping.\n\t//\n\t// Note that our models may stop _before_ reaching this maximum. This parameter\n\t// only specifies the absolute maximum number of tokens to generate.\n\t//\n\t// Different models have different maximum values for this parameter. See\n\t// [models](https://docs.claude.com/en/docs/models-overview) for details.\n\tMaxTokens int64 `json:\"max_tokens\" api:\"required\"`\n\t// Input messages.\n\t//\n\t// Our models are trained to operate on alternating `user` and `assistant`\n\t// conversational turns. When creating a new `Message`, you specify the prior\n\t// conversational turns with the `messages` parameter, and the model then generates\n\t// the next `Message` in the conversation. Consecutive `user` or `assistant` turns\n\t// in your request will be combined into a single turn.\n\t//\n\t// Each input message must be an object with a `role` and `content`. You can\n\t// specify a single `user`-role message, or you can include multiple `user` and\n\t// `assistant` messages.\n\t//\n\t// If the final message uses the `assistant` role, the response content will\n\t// continue immediately from the content in that message. This can be used to\n\t// constrain part of the model's response.\n\t//\n\t// Example with a single `user` message:\n\t//\n\t// ```json\n\t// [{ \"role\": \"user\", \"content\": \"Hello, Claude\" }]\n\t// ```\n\t//\n\t// Example with multiple conversational turns:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{ \"role\": \"user\", \"content\": \"Hello there.\" },\n\t//\t{ \"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\" },\n\t//\t{ \"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Example with a partially-filled response from Claude:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Each input message `content` may be either a single `string` or an array of\n\t// content blocks, where each block has a specific `type`. Using a `string` for\n\t// `content` is shorthand for an array of one content block of type `\"text\"`. The\n\t// following input messages are equivalent:\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": \"Hello, Claude\" }\n\t// ```\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": [{ \"type\": \"text\", \"text\": \"Hello, Claude\" }] }\n\t// ```\n\t//\n\t// See [input examples](https://docs.claude.com/en/api/messages-examples).\n\t//\n\t// Note that if you want to include a\n\t// [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the\n\t// top-level `system` parameter — there is no `\"system\"` role for input messages in\n\t// the Messages API.\n\t//\n\t// There is a limit of 100,000 messages in a single request.\n\tMessages []BetaMessageParam `json:\"messages,omitzero\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// Specifies the geographic region for inference processing. If not specified, the\n\t// workspace's `default_inference_geo` is used.\n\tInferenceGeo param.Opt[string] `json:\"inference_geo,omitzero\"`\n\t// Amount of randomness injected into the response.\n\t//\n\t// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`\n\t// for analytical / multiple choice, and closer to `1.0` for creative and\n\t// generative tasks.\n\t//\n\t// Note that even with `temperature` of `0.0`, the results will not be fully\n\t// deterministic.\n\tTemperature param.Opt[float64] `json:\"temperature,omitzero\"`\n\t// Only sample from the top K options for each subsequent token.\n\t//\n\t// Used to remove \"long tail\" low probability responses.\n\t// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopK param.Opt[int64] `json:\"top_k,omitzero\"`\n\t// Use nucleus sampling.\n\t//\n\t// In nucleus sampling, we compute the cumulative distribution over all the options\n\t// for each subsequent token in decreasing probability order and cut it off once it\n\t// reaches a particular probability specified by `top_p`. You should either alter\n\t// `temperature` or `top_p`, but not both.\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopP param.Opt[float64] `json:\"top_p,omitzero\"`\n\t// Container identifier for reuse across requests.\n\tContainer BetaMessageNewParamsContainerUnion `json:\"container,omitzero\"`\n\t// The inference speed mode for this request. `\"fast\"` enables high\n\t// output-tokens-per-second inference.\n\t//\n\t// Any of \"standard\", \"fast\".\n\tSpeed BetaMessageNewParamsSpeed `json:\"speed,omitzero\"`\n\t// Top-level cache control automatically applies a cache_control marker to the last\n\t// cacheable block in the request.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Context management configuration.\n\t//\n\t// This allows you to control how Claude manages context across multiple requests,\n\t// such as whether to clear function results or not.\n\tContextManagement BetaContextManagementConfigParam `json:\"context_management,omitzero\"`\n\t// MCP servers to be utilized in this request\n\tMCPServers []BetaRequestMCPServerURLDefinitionParam `json:\"mcp_servers,omitzero\"`\n\t// An object describing metadata about the request.\n\tMetadata BetaMetadataParam `json:\"metadata,omitzero\"`\n\t// Configuration options for the model's output, such as the output format.\n\tOutputConfig BetaOutputConfigParam `json:\"output_config,omitzero\"`\n\t// Deprecated: Use `output_config.format` instead. See\n\t// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\t//\n\t// A schema to specify Claude's output format in responses. This parameter will be\n\t// removed in a future release.\n\tOutputFormat BetaJSONOutputFormatParam `json:\"output_format,omitzero\"`\n\t// Determines whether to use priority capacity (if available) or standard capacity\n\t// for this request.\n\t//\n\t// Anthropic offers different levels of service for your API requests. See\n\t// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.\n\t//\n\t// Any of \"auto\", \"standard_only\".\n\tServiceTier BetaMessageNewParamsServiceTier `json:\"service_tier,omitzero\"`\n\t// Custom text sequences that will cause the model to stop generating.\n\t//\n\t// Our models will normally stop when they have naturally completed their turn,\n\t// which will result in a response `stop_reason` of `\"end_turn\"`.\n\t//\n\t// If you want the model to stop generating when it encounters custom strings of\n\t// text, you can use the `stop_sequences` parameter. If the model encounters one of\n\t// the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"`\n\t// and the response `stop_sequence` value will contain the matched stop sequence.\n\tStopSequences []string `json:\"stop_sequences,omitzero\"`\n\t// System prompt.\n\t//\n\t// A system prompt is a way of providing context and instructions to Claude, such\n\t// as specifying a particular goal or role. See our\n\t// [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).\n\tSystem []BetaTextBlockParam `json:\"system,omitzero\"`\n\t// Configuration for enabling Claude's extended thinking.\n\t//\n\t// When enabled, responses include `thinking` content blocks showing Claude's\n\t// thinking process before the final answer. Requires a minimum budget of 1,024\n\t// tokens and counts towards your `max_tokens` limit.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tThinking BetaThinkingConfigParamUnion `json:\"thinking,omitzero\"`\n\t// How the model should use the provided tools. The model can use a specific tool,\n\t// any available tool, decide by itself, or not use tools at all.\n\tToolChoice BetaToolChoiceUnionParam `json:\"tool_choice,omitzero\"`\n\t// Definitions of tools that the model may use.\n\t//\n\t// If you include `tools` in your API request, the model may return `tool_use`\n\t// content blocks that represent the model's use of those tools. You can then run\n\t// those tools using the tool input generated by the model and then optionally\n\t// return results back to the model using `tool_result` content blocks.\n\t//\n\t// There are two types of tools: **client tools** and **server tools**. The\n\t// behavior described below applies to client tools. For\n\t// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),\n\t// see their individual documentation as each has its own behavior (e.g., the\n\t// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\t//\n\t// Each tool definition includes:\n\t//\n\t//   - `name`: Name of the tool.\n\t//   - `description`: Optional, but strongly-recommended description of the tool.\n\t//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the\n\t//     tool `input` shape that the model will produce in `tool_use` output content\n\t//     blocks.\n\t//\n\t// For example, if you defined `tools` as:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"description\": \"Get the current stock price for a given ticker symbol.\",\n\t//\t  \"input_schema\": {\n\t//\t    \"type\": \"object\",\n\t//\t    \"properties\": {\n\t//\t      \"ticker\": {\n\t//\t        \"type\": \"string\",\n\t//\t        \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n\t//\t      }\n\t//\t    },\n\t//\t    \"required\": [\"ticker\"]\n\t//\t  }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// And then asked the model \"What's the S&P 500 at today?\", the model might produce\n\t// `tool_use` content blocks in the response like this:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_use\",\n\t//\t  \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"input\": { \"ticker\": \"^GSPC\" }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// You might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an\n\t// input, and return the following back to the model in a subsequent `user`\n\t// message:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_result\",\n\t//\t  \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"content\": \"259.75 USD\"\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Tools can be used for workflows that include running client-side tools and\n\t// functions, or more generally whenever you want the model to produce a particular\n\t// JSON structure of output.\n\t//\n\t// See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.\n\tTools []BetaToolUnionParam `json:\"tools,omitzero\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaMessageNewParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMessageNewParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMessageNewParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaMessageNewParamsContainerUnion struct {\n\tOfContainers *BetaContainerParams `json:\",omitzero,inline\"`\n\tOfString     param.Opt[string]    `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaMessageNewParamsContainerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfContainers, u.OfString)\n}\nfunc (u *BetaMessageNewParamsContainerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaMessageNewParamsContainerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfContainers) {\n\t\treturn u.OfContainers\n\t} else if !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t}\n\treturn nil\n}\n\n// Determines whether to use priority capacity (if available) or standard capacity\n// for this request.\n//\n// Anthropic offers different levels of service for your API requests. See\n// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.\ntype BetaMessageNewParamsServiceTier string\n\nconst (\n\tBetaMessageNewParamsServiceTierAuto         BetaMessageNewParamsServiceTier = \"auto\"\n\tBetaMessageNewParamsServiceTierStandardOnly BetaMessageNewParamsServiceTier = \"standard_only\"\n)\n\n// The inference speed mode for this request. `\"fast\"` enables high\n// output-tokens-per-second inference.\ntype BetaMessageNewParamsSpeed string\n\nconst (\n\tBetaMessageNewParamsSpeedStandard BetaMessageNewParamsSpeed = \"standard\"\n\tBetaMessageNewParamsSpeedFast     BetaMessageNewParamsSpeed = \"fast\"\n)\n\ntype BetaMessageCountTokensParams struct {\n\t// Input messages.\n\t//\n\t// Our models are trained to operate on alternating `user` and `assistant`\n\t// conversational turns. When creating a new `Message`, you specify the prior\n\t// conversational turns with the `messages` parameter, and the model then generates\n\t// the next `Message` in the conversation. Consecutive `user` or `assistant` turns\n\t// in your request will be combined into a single turn.\n\t//\n\t// Each input message must be an object with a `role` and `content`. You can\n\t// specify a single `user`-role message, or you can include multiple `user` and\n\t// `assistant` messages.\n\t//\n\t// If the final message uses the `assistant` role, the response content will\n\t// continue immediately from the content in that message. This can be used to\n\t// constrain part of the model's response.\n\t//\n\t// Example with a single `user` message:\n\t//\n\t// ```json\n\t// [{ \"role\": \"user\", \"content\": \"Hello, Claude\" }]\n\t// ```\n\t//\n\t// Example with multiple conversational turns:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{ \"role\": \"user\", \"content\": \"Hello there.\" },\n\t//\t{ \"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\" },\n\t//\t{ \"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Example with a partially-filled response from Claude:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Each input message `content` may be either a single `string` or an array of\n\t// content blocks, where each block has a specific `type`. Using a `string` for\n\t// `content` is shorthand for an array of one content block of type `\"text\"`. The\n\t// following input messages are equivalent:\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": \"Hello, Claude\" }\n\t// ```\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": [{ \"type\": \"text\", \"text\": \"Hello, Claude\" }] }\n\t// ```\n\t//\n\t// See [input examples](https://docs.claude.com/en/api/messages-examples).\n\t//\n\t// Note that if you want to include a\n\t// [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the\n\t// top-level `system` parameter — there is no `\"system\"` role for input messages in\n\t// the Messages API.\n\t//\n\t// There is a limit of 100,000 messages in a single request.\n\tMessages []BetaMessageParam `json:\"messages,omitzero\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// The inference speed mode for this request. `\"fast\"` enables high\n\t// output-tokens-per-second inference.\n\t//\n\t// Any of \"standard\", \"fast\".\n\tSpeed BetaMessageCountTokensParamsSpeed `json:\"speed,omitzero\"`\n\t// Top-level cache control automatically applies a cache_control marker to the last\n\t// cacheable block in the request.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Context management configuration.\n\t//\n\t// This allows you to control how Claude manages context across multiple requests,\n\t// such as whether to clear function results or not.\n\tContextManagement BetaContextManagementConfigParam `json:\"context_management,omitzero\"`\n\t// MCP servers to be utilized in this request\n\tMCPServers []BetaRequestMCPServerURLDefinitionParam `json:\"mcp_servers,omitzero\"`\n\t// Configuration options for the model's output, such as the output format.\n\tOutputConfig BetaOutputConfigParam `json:\"output_config,omitzero\"`\n\t// Deprecated: Use `output_config.format` instead. See\n\t// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\t//\n\t// A schema to specify Claude's output format in responses. This parameter will be\n\t// removed in a future release.\n\tOutputFormat BetaJSONOutputFormatParam `json:\"output_format,omitzero\"`\n\t// System prompt.\n\t//\n\t// A system prompt is a way of providing context and instructions to Claude, such\n\t// as specifying a particular goal or role. See our\n\t// [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).\n\tSystem BetaMessageCountTokensParamsSystemUnion `json:\"system,omitzero\"`\n\t// Configuration for enabling Claude's extended thinking.\n\t//\n\t// When enabled, responses include `thinking` content blocks showing Claude's\n\t// thinking process before the final answer. Requires a minimum budget of 1,024\n\t// tokens and counts towards your `max_tokens` limit.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tThinking BetaThinkingConfigParamUnion `json:\"thinking,omitzero\"`\n\t// How the model should use the provided tools. The model can use a specific tool,\n\t// any available tool, decide by itself, or not use tools at all.\n\tToolChoice BetaToolChoiceUnionParam `json:\"tool_choice,omitzero\"`\n\t// Definitions of tools that the model may use.\n\t//\n\t// If you include `tools` in your API request, the model may return `tool_use`\n\t// content blocks that represent the model's use of those tools. You can then run\n\t// those tools using the tool input generated by the model and then optionally\n\t// return results back to the model using `tool_result` content blocks.\n\t//\n\t// There are two types of tools: **client tools** and **server tools**. The\n\t// behavior described below applies to client tools. For\n\t// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),\n\t// see their individual documentation as each has its own behavior (e.g., the\n\t// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\t//\n\t// Each tool definition includes:\n\t//\n\t//   - `name`: Name of the tool.\n\t//   - `description`: Optional, but strongly-recommended description of the tool.\n\t//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the\n\t//     tool `input` shape that the model will produce in `tool_use` output content\n\t//     blocks.\n\t//\n\t// For example, if you defined `tools` as:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"description\": \"Get the current stock price for a given ticker symbol.\",\n\t//\t  \"input_schema\": {\n\t//\t    \"type\": \"object\",\n\t//\t    \"properties\": {\n\t//\t      \"ticker\": {\n\t//\t        \"type\": \"string\",\n\t//\t        \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n\t//\t      }\n\t//\t    },\n\t//\t    \"required\": [\"ticker\"]\n\t//\t  }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// And then asked the model \"What's the S&P 500 at today?\", the model might produce\n\t// `tool_use` content blocks in the response like this:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_use\",\n\t//\t  \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"input\": { \"ticker\": \"^GSPC\" }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// You might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an\n\t// input, and return the following back to the model in a subsequent `user`\n\t// message:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_result\",\n\t//\t  \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"content\": \"259.75 USD\"\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Tools can be used for workflows that include running client-side tools and\n\t// functions, or more generally whenever you want the model to produce a particular\n\t// JSON structure of output.\n\t//\n\t// See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.\n\tTools []BetaMessageCountTokensParamsToolUnion `json:\"tools,omitzero\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaMessageCountTokensParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMessageCountTokensParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMessageCountTokensParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The inference speed mode for this request. `\"fast\"` enables high\n// output-tokens-per-second inference.\ntype BetaMessageCountTokensParamsSpeed string\n\nconst (\n\tBetaMessageCountTokensParamsSpeedStandard BetaMessageCountTokensParamsSpeed = \"standard\"\n\tBetaMessageCountTokensParamsSpeedFast     BetaMessageCountTokensParamsSpeed = \"fast\"\n)\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaMessageCountTokensParamsSystemUnion struct {\n\tOfString             param.Opt[string]    `json:\",omitzero,inline\"`\n\tOfBetaTextBlockArray []BetaTextBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaMessageCountTokensParamsSystemUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfString, u.OfBetaTextBlockArray)\n}\nfunc (u *BetaMessageCountTokensParamsSystemUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaMessageCountTokensParamsSystemUnion) asAny() any {\n\tif !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t} else if !param.IsOmitted(u.OfBetaTextBlockArray) {\n\t\treturn &u.OfBetaTextBlockArray\n\t}\n\treturn nil\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaMessageCountTokensParamsToolUnion struct {\n\tOfTool                        *BetaToolParam                        `json:\",omitzero,inline\"`\n\tOfBashTool20241022            *BetaToolBash20241022Param            `json:\",omitzero,inline\"`\n\tOfBashTool20250124            *BetaToolBash20250124Param            `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250522   *BetaCodeExecutionTool20250522Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250825   *BetaCodeExecutionTool20250825Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20260120   *BetaCodeExecutionTool20260120Param   `json:\",omitzero,inline\"`\n\tOfComputerUseTool20241022     *BetaToolComputerUse20241022Param     `json:\",omitzero,inline\"`\n\tOfMemoryTool20250818          *BetaMemoryTool20250818Param          `json:\",omitzero,inline\"`\n\tOfComputerUseTool20250124     *BetaToolComputerUse20250124Param     `json:\",omitzero,inline\"`\n\tOfTextEditor20241022          *BetaToolTextEditor20241022Param      `json:\",omitzero,inline\"`\n\tOfComputerUseTool20251124     *BetaToolComputerUse20251124Param     `json:\",omitzero,inline\"`\n\tOfTextEditor20250124          *BetaToolTextEditor20250124Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250429          *BetaToolTextEditor20250429Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250728          *BetaToolTextEditor20250728Param      `json:\",omitzero,inline\"`\n\tOfWebSearchTool20250305       *BetaWebSearchTool20250305Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20250910        *BetaWebFetchTool20250910Param        `json:\",omitzero,inline\"`\n\tOfWebSearchTool20260209       *BetaWebSearchTool20260209Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260209        *BetaWebFetchTool20260209Param        `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260309        *BetaWebFetchTool20260309Param        `json:\",omitzero,inline\"`\n\tOfToolSearchToolBm25_20251119 *BetaToolSearchToolBm25_20251119Param `json:\",omitzero,inline\"`\n\tOfToolSearchToolRegex20251119 *BetaToolSearchToolRegex20251119Param `json:\",omitzero,inline\"`\n\tOfMCPToolset                  *BetaMCPToolsetParam                  `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaMessageCountTokensParamsToolUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfTool,\n\t\tu.OfBashTool20241022,\n\t\tu.OfBashTool20250124,\n\t\tu.OfCodeExecutionTool20250522,\n\t\tu.OfCodeExecutionTool20250825,\n\t\tu.OfCodeExecutionTool20260120,\n\t\tu.OfComputerUseTool20241022,\n\t\tu.OfMemoryTool20250818,\n\t\tu.OfComputerUseTool20250124,\n\t\tu.OfTextEditor20241022,\n\t\tu.OfComputerUseTool20251124,\n\t\tu.OfTextEditor20250124,\n\t\tu.OfTextEditor20250429,\n\t\tu.OfTextEditor20250728,\n\t\tu.OfWebSearchTool20250305,\n\t\tu.OfWebFetchTool20250910,\n\t\tu.OfWebSearchTool20260209,\n\t\tu.OfWebFetchTool20260209,\n\t\tu.OfWebFetchTool20260309,\n\t\tu.OfToolSearchToolBm25_20251119,\n\t\tu.OfToolSearchToolRegex20251119,\n\t\tu.OfMCPToolset)\n}\nfunc (u *BetaMessageCountTokensParamsToolUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaMessageCountTokensParamsToolUnion) asAny() any {\n\tif !param.IsOmitted(u.OfTool) {\n\t\treturn u.OfTool\n\t} else if !param.IsOmitted(u.OfBashTool20241022) {\n\t\treturn u.OfBashTool20241022\n\t} else if !param.IsOmitted(u.OfBashTool20250124) {\n\t\treturn u.OfBashTool20250124\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250522) {\n\t\treturn u.OfCodeExecutionTool20250522\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250825) {\n\t\treturn u.OfCodeExecutionTool20250825\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20260120) {\n\t\treturn u.OfCodeExecutionTool20260120\n\t} else if !param.IsOmitted(u.OfComputerUseTool20241022) {\n\t\treturn u.OfComputerUseTool20241022\n\t} else if !param.IsOmitted(u.OfMemoryTool20250818) {\n\t\treturn u.OfMemoryTool20250818\n\t} else if !param.IsOmitted(u.OfComputerUseTool20250124) {\n\t\treturn u.OfComputerUseTool20250124\n\t} else if !param.IsOmitted(u.OfTextEditor20241022) {\n\t\treturn u.OfTextEditor20241022\n\t} else if !param.IsOmitted(u.OfComputerUseTool20251124) {\n\t\treturn u.OfComputerUseTool20251124\n\t} else if !param.IsOmitted(u.OfTextEditor20250124) {\n\t\treturn u.OfTextEditor20250124\n\t} else if !param.IsOmitted(u.OfTextEditor20250429) {\n\t\treturn u.OfTextEditor20250429\n\t} else if !param.IsOmitted(u.OfTextEditor20250728) {\n\t\treturn u.OfTextEditor20250728\n\t} else if !param.IsOmitted(u.OfWebSearchTool20250305) {\n\t\treturn u.OfWebSearchTool20250305\n\t} else if !param.IsOmitted(u.OfWebFetchTool20250910) {\n\t\treturn u.OfWebFetchTool20250910\n\t} else if !param.IsOmitted(u.OfWebSearchTool20260209) {\n\t\treturn u.OfWebSearchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260209) {\n\t\treturn u.OfWebFetchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260309) {\n\t\treturn u.OfWebFetchTool20260309\n\t} else if !param.IsOmitted(u.OfToolSearchToolBm25_20251119) {\n\t\treturn u.OfToolSearchToolBm25_20251119\n\t} else if !param.IsOmitted(u.OfToolSearchToolRegex20251119) {\n\t\treturn u.OfToolSearchToolRegex20251119\n\t} else if !param.IsOmitted(u.OfMCPToolset) {\n\t\treturn u.OfMCPToolset\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetInputSchema() *BetaToolInputSchemaParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.InputSchema\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetDescription() *string {\n\tif vt := u.OfTool; vt != nil && vt.Description.Valid() {\n\t\treturn &vt.Description.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetEagerInputStreaming() *bool {\n\tif vt := u.OfTool; vt != nil && vt.EagerInputStreaming.Valid() {\n\t\treturn &vt.EagerInputStreaming.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetEnableZoom() *bool {\n\tif vt := u.OfComputerUseTool20251124; vt != nil && vt.EnableZoom.Valid() {\n\t\treturn &vt.EnableZoom.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetMaxCharacters() *int64 {\n\tif vt := u.OfTextEditor20250728; vt != nil && vt.MaxCharacters.Valid() {\n\t\treturn &vt.MaxCharacters.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetUseCache() *bool {\n\tif vt := u.OfWebFetchTool20260309; vt != nil && vt.UseCache.Valid() {\n\t\treturn &vt.UseCache.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetMCPServerName() *string {\n\tif vt := u.OfMCPToolset; vt != nil {\n\t\treturn &vt.MCPServerName\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetConfigs() map[string]BetaMCPToolConfigParam {\n\tif vt := u.OfMCPToolset; vt != nil {\n\t\treturn vt.Configs\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetDefaultConfig() *BetaMCPToolDefaultConfigParam {\n\tif vt := u.OfMCPToolset; vt != nil {\n\t\treturn &vt.DefaultConfig\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetName() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetDeferLoading() *bool {\n\tif vt := u.OfTool; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfBashTool20241022; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20241022; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetStrict() *bool {\n\tif vt := u.OfTool; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfBashTool20241022; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20241022; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetType() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMCPToolset; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetDisplayHeightPx() *int64 {\n\tif vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*int64)(&vt.DisplayHeightPx)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayHeightPx)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayHeightPx)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetDisplayWidthPx() *int64 {\n\tif vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn (*int64)(&vt.DisplayWidthPx)\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayWidthPx)\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn (*int64)(&vt.DisplayWidthPx)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetDisplayNumber() *int64 {\n\tif vt := u.OfComputerUseTool20241022; vt != nil && vt.DisplayNumber.Valid() {\n\t\treturn &vt.DisplayNumber.Value\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil && vt.DisplayNumber.Valid() {\n\t\treturn &vt.DisplayNumber.Value\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil && vt.DisplayNumber.Valid() {\n\t\treturn &vt.DisplayNumber.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetMaxUses() *int64 {\n\tif vt := u.OfWebSearchTool20250305; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetMaxContentTokens() *int64 {\n\tif vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedCallers property, if\n// present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetAllowedCallers() []string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetCacheControl() *BetaCacheControlEphemeralParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMCPToolset; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's InputExamples property, if\n// present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetInputExamples() []map[string]any {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfBashTool20241022; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfComputerUseTool20241022; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfComputerUseTool20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20241022; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfComputerUseTool20251124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.InputExamples\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedDomains property, if\n// present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetAllowedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's BlockedDomains property, if\n// present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetBlockedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.BlockedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's UserLocation property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetUserLocation() *BetaUserLocationParam {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.UserLocation\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.UserLocation\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's Citations property, if present.\nfunc (u BetaMessageCountTokensParamsToolUnion) GetCitations() *BetaCitationsConfigParam {\n\tif vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.Citations\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "betamessage_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestBetaMessageNewWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.BetaMessageParam{{\n\t\t\tContent: []anthropic.BetaContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.BetaTextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t},\n\t\t\t\t\tCitations: []anthropic.BetaTextCitationParamUnion{{\n\t\t\t\t\t\tOfCharLocation: &anthropic.BetaCitationCharLocationParam{\n\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.BetaMessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t},\n\t\tContainer: anthropic.BetaMessageNewParamsContainerUnion{\n\t\t\tOfContainers: &anthropic.BetaContainerParams{\n\t\t\t\tID: anthropic.String(\"id\"),\n\t\t\t\tSkills: []anthropic.BetaSkillParams{{\n\t\t\t\t\tSkillID: \"pdf\",\n\t\t\t\t\tType:    anthropic.BetaSkillParamsTypeAnthropic,\n\t\t\t\t\tVersion: anthropic.String(\"latest\"),\n\t\t\t\t}},\n\t\t\t},\n\t\t},\n\t\tContextManagement: anthropic.BetaContextManagementConfigParam{\n\t\t\tEdits: []anthropic.BetaContextManagementConfigEditUnionParam{{\n\t\t\t\tOfClearToolUses20250919: &anthropic.BetaClearToolUses20250919EditParam{\n\t\t\t\t\tClearAtLeast: anthropic.BetaInputTokensClearAtLeastParam{\n\t\t\t\t\t\tValue: 0,\n\t\t\t\t\t},\n\t\t\t\t\tClearToolInputs: anthropic.BetaClearToolUses20250919EditClearToolInputsUnionParam{\n\t\t\t\t\t\tOfBool: anthropic.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t\tExcludeTools: []string{\"string\"},\n\t\t\t\t\tKeep: anthropic.BetaToolUsesKeepParam{\n\t\t\t\t\t\tValue: 0,\n\t\t\t\t\t},\n\t\t\t\t\tTrigger: anthropic.BetaClearToolUses20250919EditTriggerUnionParam{\n\t\t\t\t\t\tOfInputTokens: &anthropic.BetaInputTokensTriggerParam{\n\t\t\t\t\t\t\tValue: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}},\n\t\t},\n\t\tInferenceGeo: anthropic.String(\"inference_geo\"),\n\t\tMCPServers: []anthropic.BetaRequestMCPServerURLDefinitionParam{{\n\t\t\tName:               \"name\",\n\t\t\tURL:                \"url\",\n\t\t\tAuthorizationToken: anthropic.String(\"authorization_token\"),\n\t\t\tToolConfiguration: anthropic.BetaRequestMCPServerToolConfigurationParam{\n\t\t\t\tAllowedTools: []string{\"string\"},\n\t\t\t\tEnabled:      anthropic.Bool(true),\n\t\t\t},\n\t\t}},\n\t\tMetadata: anthropic.BetaMetadataParam{\n\t\t\tUserID: anthropic.String(\"13803d75-b4b5-4c3e-b2a2-6f21399b021b\"),\n\t\t},\n\t\tOutputConfig: anthropic.BetaOutputConfigParam{\n\t\t\tEffort: anthropic.BetaOutputConfigEffortLow,\n\t\t\tFormat: anthropic.BetaJSONOutputFormatParam{\n\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tOutputFormat: anthropic.BetaJSONOutputFormatParam{\n\t\t\tSchema: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t\tServiceTier:   anthropic.BetaMessageNewParamsServiceTierAuto,\n\t\tSpeed:         anthropic.BetaMessageNewParamsSpeedStandard,\n\t\tStopSequences: []string{\"string\"},\n\t\tSystem: []anthropic.BetaTextBlockParam{{\n\t\t\tText: \"Today's date is 2024-06-01.\",\n\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t},\n\t\t\tCitations: []anthropic.BetaTextCitationParamUnion{{\n\t\t\t\tOfCharLocation: &anthropic.BetaCitationCharLocationParam{\n\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t},\n\t\t\t}},\n\t\t}},\n\t\tTemperature: anthropic.Float(1),\n\t\tThinking: anthropic.BetaThinkingConfigParamUnion{\n\t\t\tOfAdaptive: &anthropic.BetaThinkingConfigAdaptiveParam{\n\t\t\t\tDisplay: anthropic.BetaThinkingConfigAdaptiveDisplaySummarized,\n\t\t\t},\n\t\t},\n\t\tToolChoice: anthropic.BetaToolChoiceUnionParam{\n\t\t\tOfAuto: &anthropic.BetaToolChoiceAutoParam{\n\t\t\t\tDisableParallelToolUse: anthropic.Bool(true),\n\t\t\t},\n\t\t},\n\t\tTools: []anthropic.BetaToolUnionParam{{\n\t\t\tOfTool: &anthropic.BetaToolParam{\n\t\t\t\tInputSchema: anthropic.BetaToolInputSchemaParam{\n\t\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\t\"location\": \"bar\",\n\t\t\t\t\t\t\"unit\":     \"bar\",\n\t\t\t\t\t},\n\t\t\t\t\tRequired: []string{\"location\"},\n\t\t\t\t},\n\t\t\t\tName:           \"name\",\n\t\t\t\tAllowedCallers: []string{\"direct\"},\n\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tDeferLoading:        anthropic.Bool(true),\n\t\t\t\tDescription:         anthropic.String(\"Get the current weather in a given location\"),\n\t\t\t\tEagerInputStreaming: anthropic.Bool(true),\n\t\t\t\tInputExamples: []map[string]any{{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t}},\n\t\t\t\tStrict: anthropic.Bool(true),\n\t\t\t\tType:   anthropic.BetaToolTypeCustom,\n\t\t\t},\n\t\t}},\n\t\tTopK:  anthropic.Int(5),\n\t\tTopP:  anthropic.Float(0.7),\n\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaMessageCountTokensWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.CountTokens(context.TODO(), anthropic.BetaMessageCountTokensParams{\n\t\tMessages: []anthropic.BetaMessageParam{{\n\t\t\tContent: []anthropic.BetaContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.BetaTextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t},\n\t\t\t\t\tCitations: []anthropic.BetaTextCitationParamUnion{{\n\t\t\t\t\t\tOfCharLocation: &anthropic.BetaCitationCharLocationParam{\n\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.BetaMessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t},\n\t\tContextManagement: anthropic.BetaContextManagementConfigParam{\n\t\t\tEdits: []anthropic.BetaContextManagementConfigEditUnionParam{{\n\t\t\t\tOfClearToolUses20250919: &anthropic.BetaClearToolUses20250919EditParam{\n\t\t\t\t\tClearAtLeast: anthropic.BetaInputTokensClearAtLeastParam{\n\t\t\t\t\t\tValue: 0,\n\t\t\t\t\t},\n\t\t\t\t\tClearToolInputs: anthropic.BetaClearToolUses20250919EditClearToolInputsUnionParam{\n\t\t\t\t\t\tOfBool: anthropic.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t\tExcludeTools: []string{\"string\"},\n\t\t\t\t\tKeep: anthropic.BetaToolUsesKeepParam{\n\t\t\t\t\t\tValue: 0,\n\t\t\t\t\t},\n\t\t\t\t\tTrigger: anthropic.BetaClearToolUses20250919EditTriggerUnionParam{\n\t\t\t\t\t\tOfInputTokens: &anthropic.BetaInputTokensTriggerParam{\n\t\t\t\t\t\t\tValue: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}},\n\t\t},\n\t\tMCPServers: []anthropic.BetaRequestMCPServerURLDefinitionParam{{\n\t\t\tName:               \"name\",\n\t\t\tURL:                \"url\",\n\t\t\tAuthorizationToken: anthropic.String(\"authorization_token\"),\n\t\t\tToolConfiguration: anthropic.BetaRequestMCPServerToolConfigurationParam{\n\t\t\t\tAllowedTools: []string{\"string\"},\n\t\t\t\tEnabled:      anthropic.Bool(true),\n\t\t\t},\n\t\t}},\n\t\tOutputConfig: anthropic.BetaOutputConfigParam{\n\t\t\tEffort: anthropic.BetaOutputConfigEffortLow,\n\t\t\tFormat: anthropic.BetaJSONOutputFormatParam{\n\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tOutputFormat: anthropic.BetaJSONOutputFormatParam{\n\t\t\tSchema: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t\tSpeed: anthropic.BetaMessageCountTokensParamsSpeedStandard,\n\t\tSystem: anthropic.BetaMessageCountTokensParamsSystemUnion{\n\t\t\tOfBetaTextBlockArray: []anthropic.BetaTextBlockParam{{\n\t\t\t\tText: \"Today's date is 2024-06-01.\",\n\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tCitations: []anthropic.BetaTextCitationParamUnion{{\n\t\t\t\t\tOfCharLocation: &anthropic.BetaCitationCharLocationParam{\n\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\tThinking: anthropic.BetaThinkingConfigParamUnion{\n\t\t\tOfAdaptive: &anthropic.BetaThinkingConfigAdaptiveParam{\n\t\t\t\tDisplay: anthropic.BetaThinkingConfigAdaptiveDisplaySummarized,\n\t\t\t},\n\t\t},\n\t\tToolChoice: anthropic.BetaToolChoiceUnionParam{\n\t\t\tOfAuto: &anthropic.BetaToolChoiceAutoParam{\n\t\t\t\tDisableParallelToolUse: anthropic.Bool(true),\n\t\t\t},\n\t\t},\n\t\tTools: []anthropic.BetaMessageCountTokensParamsToolUnion{{\n\t\t\tOfTool: &anthropic.BetaToolParam{\n\t\t\t\tInputSchema: anthropic.BetaToolInputSchemaParam{\n\t\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\t\"location\": \"bar\",\n\t\t\t\t\t\t\"unit\":     \"bar\",\n\t\t\t\t\t},\n\t\t\t\t\tRequired: []string{\"location\"},\n\t\t\t\t},\n\t\t\t\tName:           \"name\",\n\t\t\t\tAllowedCallers: []string{\"direct\"},\n\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tDeferLoading:        anthropic.Bool(true),\n\t\t\t\tDescription:         anthropic.String(\"Get the current weather in a given location\"),\n\t\t\t\tEagerInputStreaming: anthropic.Bool(true),\n\t\t\t\tInputExamples: []map[string]any{{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t}},\n\t\t\t\tStrict: anthropic.Bool(true),\n\t\t\t\tType:   anthropic.BetaToolTypeCustom,\n\t\t\t},\n\t\t}},\n\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaAccumulate(t *testing.T) {\n\tfor name, testCase := range map[string]struct {\n\t\texpected anthropic.BetaMessage\n\t\tevents   []string\n\t}{\n\t\t\"empty message\": {\n\t\t\texpected: anthropic.BetaMessage{Usage: anthropic.BetaUsage{}},\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type: \"message_stop\"}`,\n\t\t\t},\n\t\t},\n\t\t\"text content block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"text\", \"text\": \"This \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\", \"text\": \"is a \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\": \"text\": \"text block!\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"text\", Text: \"This is a text block!\"},\n\t\t\t}},\n\t\t},\n\t\t\"text content block with citations\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"text\", \"text\": \"1 + 1\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\", \"text\": \" = 2\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"citations_delta\", \"citation\": {\"type\": \"char_location\", \"cited_text\": \"1 + 1 = 2\", \"document_index\": 0, \"document_title\": \"Math Facts\", \"start_char_index\": 300, \"end_char_index\": 310 }}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"text\", Text: \"1 + 1 = 2\", Citations: []anthropic.BetaTextCitationUnion{{\n\t\t\t\t\tType:           \"char_location\",\n\t\t\t\t\tCitedText:      \"1 + 1 = 2\",\n\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\tDocumentTitle:  \"Math Facts\",\n\t\t\t\t\tStartCharIndex: 300,\n\t\t\t\t\tEndCharIndex:   310,\n\t\t\t\t}}},\n\t\t\t}},\n\t\t},\n\t\t\"tool use block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"tool_use\", \"id\": \"toolu_id\", \"name\": \"tool_name\", \"input\": {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"{\\\"argument\\\":\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \" \\\"value\\\"}\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"tool_use\", ID: \"toolu_id\", Name: \"tool_name\", Input: []byte(`{\"argument\": \"value\"}`)},\n\t\t\t}},\n\t\t},\n\t\t\"tool use block with no params\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\": \"index\": 0, \"content_block\": {\"type\": \"tool_use\", \"id\": \"toolu_id\", \"name\": \"tool_name\", input: {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"tool_use\", ID: \"toolu_id\", Name: \"tool_name\"},\n\t\t\t}},\n\t\t},\n\t\t\"server tool use block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\": \"index\": 0, \"content_block\": {\"type\": \"server_tool_use\", \"id\": \"srvtoolu_id\", \"name\": \"web_search\", input: {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"{\\\"query\\\": \\\"weat\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"her\\\"}\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"server_tool_use\", ID: \"srvtoolu_id\", Name: \"web_search\", Input: []byte(`{\"query\": \"weather\"}`)},\n\t\t\t}},\n\t\t},\n\t\t\"thinking block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"thinking\", \"thinking\": \"Let me think...\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"\nFirst, let's try this...\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"\nTherefore, the answer is...\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"signature_delta\", \"signature\": \"ThinkingSignature\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"thinking\", Thinking: \"Let me think...\\nFirst, let's try this...\\nTherefore, the answer is...\", Signature: \"ThinkingSignature\"},\n\t\t\t}},\n\t\t},\n\t\t\"redacted thinking block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"redacted_thinking\", \"data\": \"Redacted\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"redacted_thinking\", Data: \"Redacted\"},\n\t\t\t}},\n\t\t},\n\t\t\"compaction block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"compaction\", \"content\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"compaction_delta\", \"content\": \"Summary of the conversation so far.\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"compaction\", Content: anthropic.BetaContentBlockUnionContent{OfString: \"Summary of the conversation so far.\"}},\n\t\t\t}},\n\t\t},\n\t\t\"multiple content blocks\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"text\", \"text\": \"Let me look up \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\", \"text\": \"the weather for \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\": \"text\": \"you.\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 1, \"content_block\": {\"type\": \"thinking\", \"thinking\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 1, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"I can look this \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 1, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"up using a tool.\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 1}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 2, \"content_block\": {\"type\": \"tool_use\", \"id\": \"toolu_id\", \"name\": \"get_weather\", \"input\": {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 2, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"{\\\"city\\\": \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 2, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"\\\"Los Angeles\\\"}\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 2}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 3, \"content_block\": {\"type\": \"text\", \"text\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 3, \"delta\": {\"type\": \"text_delta\", \"text\": \"The weather in Los Angeles\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 3, \"delta\": {\"type\": \"text_delta\", \"text\": \" is 85 degrees Fahrenheit!\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 3\"}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.BetaMessage{Content: []anthropic.BetaContentBlockUnion{\n\t\t\t\t{Type: \"text\", Text: \"Let me look up the weather for you.\"},\n\t\t\t\t{Type: \"thinking\", Thinking: \"I can look this up using a tool.\"},\n\t\t\t\t{Type: \"tool_use\", ID: \"toolu_id\", Name: \"get_weather\", Input: []byte(`{\"city\": \"Los Angeles\"}`)},\n\t\t\t\t{Type: \"text\", Text: \"The weather in Los Angeles is 85 degrees Fahrenheit!\"},\n\t\t\t}},\n\t\t},\n\t} {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tmessage := anthropic.BetaMessage{}\n\t\t\tfor _, eventStr := range testCase.events {\n\t\t\t\tevent := anthropic.BetaRawMessageStreamEventUnion{}\n\t\t\t\terr := (&event).UnmarshalJSON([]byte(eventStr))\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t\t(&message).Accumulate(event)\n\t\t\t}\n\t\t\tmarshaledMessage, err := json.Marshal(message)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tmarshaledExpectedMessage, err := json.Marshal(testCase.expected)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tif string(marshaledMessage) != string(marshaledExpectedMessage) {\n\t\t\t\tt.Fatalf(\"Mismatched message: expected %s but got %s\", marshaledExpectedMessage, marshaledMessage)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "betamessagebatch.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/jsonl\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// BetaMessageBatchService contains methods and other services that help with\n// interacting with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaMessageBatchService] method instead.\ntype BetaMessageBatchService struct {\n\tOptions []option.RequestOption\n}\n\n// NewBetaMessageBatchService generates a new service that applies the given\n// options to each request. These options are applied after the parent client's\n// options (if there is one), and before any request-specific options.\nfunc NewBetaMessageBatchService(opts ...option.RequestOption) (r BetaMessageBatchService) {\n\tr = BetaMessageBatchService{}\n\tr.Options = opts\n\treturn\n}\n\n// Send a batch of Message creation requests.\n//\n// The Message Batches API can be used to process multiple Messages API requests at\n// once. Once a Message Batch is created, it begins processing immediately. Batches\n// can take up to 24 hours to complete.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) New(ctx context.Context, params BetaMessageBatchNewParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"message-batches-2024-09-24\")}, opts...)\n\tpath := \"v1/messages/batches?beta=true\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\n// This endpoint is idempotent and can be used to poll for Message Batch\n// completion. To access the results of a Message Batch, make a request to the\n// `results_url` field in the response.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) Get(ctx context.Context, messageBatchID string, query BetaMessageBatchGetParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error) {\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"message-batches-2024-09-24\")}, opts...)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s?beta=true\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// List all Message Batches within a Workspace. Most recently created batches are\n// returned first.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) List(ctx context.Context, params BetaMessageBatchListParams, opts ...option.RequestOption) (res *pagination.Page[BetaMessageBatch], err error) {\n\tvar raw *http.Response\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"message-batches-2024-09-24\"), option.WithResponseInto(&raw)}, opts...)\n\tpath := \"v1/messages/batches?beta=true\"\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List all Message Batches within a Workspace. Most recently created batches are\n// returned first.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) ListAutoPaging(ctx context.Context, params BetaMessageBatchListParams, opts ...option.RequestOption) *pagination.PageAutoPager[BetaMessageBatch] {\n\treturn pagination.NewPageAutoPager(r.List(ctx, params, opts...))\n}\n\n// Delete a Message Batch.\n//\n// Message Batches can only be deleted once they've finished processing. If you'd\n// like to delete an in-progress batch, you must first cancel it.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) Delete(ctx context.Context, messageBatchID string, body BetaMessageBatchDeleteParams, opts ...option.RequestOption) (res *BetaDeletedMessageBatch, err error) {\n\tfor _, v := range body.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"message-batches-2024-09-24\")}, opts...)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s?beta=true\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Batches may be canceled any time before processing ends. Once cancellation is\n// initiated, the batch enters a `canceling` state, at which time the system may\n// complete any in-progress, non-interruptible requests before finalizing\n// cancellation.\n//\n// The number of canceled requests is specified in `request_counts`. To determine\n// which requests were canceled, check the individual results within the batch.\n// Note that cancellation may not result in any canceled requests if they were\n// non-interruptible.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) Cancel(ctx context.Context, messageBatchID string, body BetaMessageBatchCancelParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error) {\n\tfor _, v := range body.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"message-batches-2024-09-24\")}, opts...)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s/cancel?beta=true\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Streams the results of a Message Batch as a `.jsonl` file.\n//\n// Each line in the file is a JSON object containing the result of a single request\n// in the Message Batch. Results are not guaranteed to be in the same order as\n// requests. Use the `custom_id` field to match results to requests.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *BetaMessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, query BetaMessageBatchResultsParams, opts ...option.RequestOption) (stream *jsonl.Stream[BetaMessageBatchIndividualResponse]) {\n\tvar (\n\t\traw *http.Response\n\t\terr error\n\t)\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"message-batches-2024-09-24\"), option.WithHeader(\"Accept\", \"application/x-jsonl\")}, opts...)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn jsonl.NewStream[BetaMessageBatchIndividualResponse](nil, err)\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s/results?beta=true\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &raw, opts...)\n\treturn jsonl.NewStream[BetaMessageBatchIndividualResponse](raw, err)\n}\n\ntype BetaDeletedMessageBatch struct {\n\t// ID of the Message Batch.\n\tID string `json:\"id\" api:\"required\"`\n\t// Deleted object type.\n\t//\n\t// For Message Batches, this is always `\"message_batch_deleted\"`.\n\tType constant.MessageBatchDeleted `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaDeletedMessageBatch) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaDeletedMessageBatch) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageBatch struct {\n\t// Unique object identifier.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// RFC 3339 datetime string representing the time at which the Message Batch was\n\t// archived and its results became unavailable.\n\tArchivedAt time.Time `json:\"archived_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which cancellation was\n\t// initiated for the Message Batch. Specified only if cancellation was initiated.\n\tCancelInitiatedAt time.Time `json:\"cancel_initiated_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which the Message Batch was\n\t// created.\n\tCreatedAt time.Time `json:\"created_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which processing for the\n\t// Message Batch ended. Specified only once processing ends.\n\t//\n\t// Processing ends when every request in a Message Batch has either succeeded,\n\t// errored, canceled, or expired.\n\tEndedAt time.Time `json:\"ended_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which the Message Batch will\n\t// expire and end processing, which is 24 hours after creation.\n\tExpiresAt time.Time `json:\"expires_at\" api:\"required\" format:\"date-time\"`\n\t// Processing status of the Message Batch.\n\t//\n\t// Any of \"in_progress\", \"canceling\", \"ended\".\n\tProcessingStatus BetaMessageBatchProcessingStatus `json:\"processing_status\" api:\"required\"`\n\t// Tallies requests within the Message Batch, categorized by their status.\n\t//\n\t// Requests start as `processing` and move to one of the other statuses only once\n\t// processing of the entire batch ends. The sum of all values always matches the\n\t// total number of requests in the batch.\n\tRequestCounts BetaMessageBatchRequestCounts `json:\"request_counts\" api:\"required\"`\n\t// URL to a `.jsonl` file containing the results of the Message Batch requests.\n\t// Specified only once processing ends.\n\t//\n\t// Results in the file are not guaranteed to be in the same order as requests. Use\n\t// the `custom_id` field to match results to requests.\n\tResultsURL string `json:\"results_url\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Message Batches, this is always `\"message_batch\"`.\n\tType constant.MessageBatch `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID                respjson.Field\n\t\tArchivedAt        respjson.Field\n\t\tCancelInitiatedAt respjson.Field\n\t\tCreatedAt         respjson.Field\n\t\tEndedAt           respjson.Field\n\t\tExpiresAt         respjson.Field\n\t\tProcessingStatus  respjson.Field\n\t\tRequestCounts     respjson.Field\n\t\tResultsURL        respjson.Field\n\t\tType              respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatch) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatch) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Processing status of the Message Batch.\ntype BetaMessageBatchProcessingStatus string\n\nconst (\n\tBetaMessageBatchProcessingStatusInProgress BetaMessageBatchProcessingStatus = \"in_progress\"\n\tBetaMessageBatchProcessingStatusCanceling  BetaMessageBatchProcessingStatus = \"canceling\"\n\tBetaMessageBatchProcessingStatusEnded      BetaMessageBatchProcessingStatus = \"ended\"\n)\n\ntype BetaMessageBatchCanceledResult struct {\n\tType constant.Canceled `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatchCanceledResult) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatchCanceledResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageBatchErroredResult struct {\n\tError BetaErrorResponse `json:\"error\" api:\"required\"`\n\tType  constant.Errored  `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tError       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatchErroredResult) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatchErroredResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageBatchExpiredResult struct {\n\tType constant.Expired `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatchExpiredResult) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatchExpiredResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// This is a single line in the response `.jsonl` file and does not represent the\n// response as a whole.\ntype BetaMessageBatchIndividualResponse struct {\n\t// Developer-provided ID created for each request in a Message Batch. Useful for\n\t// matching results to requests, as results may be given out of request order.\n\t//\n\t// Must be unique for each request within the Message Batch.\n\tCustomID string `json:\"custom_id\" api:\"required\"`\n\t// Processing result for this request.\n\t//\n\t// Contains a Message output if processing was successful, an error response if\n\t// processing failed, or the reason why processing was not attempted, such as\n\t// cancellation or expiration.\n\tResult BetaMessageBatchResultUnion `json:\"result\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCustomID    respjson.Field\n\t\tResult      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatchIndividualResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatchIndividualResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageBatchRequestCounts struct {\n\t// Number of requests in the Message Batch that have been canceled.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tCanceled int64 `json:\"canceled\" api:\"required\"`\n\t// Number of requests in the Message Batch that encountered an error.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tErrored int64 `json:\"errored\" api:\"required\"`\n\t// Number of requests in the Message Batch that have expired.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tExpired int64 `json:\"expired\" api:\"required\"`\n\t// Number of requests in the Message Batch that are processing.\n\tProcessing int64 `json:\"processing\" api:\"required\"`\n\t// Number of requests in the Message Batch that have completed successfully.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tSucceeded int64 `json:\"succeeded\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCanceled    respjson.Field\n\t\tErrored     respjson.Field\n\t\tExpired     respjson.Field\n\t\tProcessing  respjson.Field\n\t\tSucceeded   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatchRequestCounts) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatchRequestCounts) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BetaMessageBatchResultUnion contains all possible properties and values from\n// [BetaMessageBatchSucceededResult], [BetaMessageBatchErroredResult],\n// [BetaMessageBatchCanceledResult], [BetaMessageBatchExpiredResult].\n//\n// Use the [BetaMessageBatchResultUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BetaMessageBatchResultUnion struct {\n\t// This field is from variant [BetaMessageBatchSucceededResult].\n\tMessage BetaMessage `json:\"message\"`\n\t// Any of \"succeeded\", \"errored\", \"canceled\", \"expired\".\n\tType string `json:\"type\"`\n\t// This field is from variant [BetaMessageBatchErroredResult].\n\tError BetaErrorResponse `json:\"error\"`\n\tJSON  struct {\n\t\tMessage respjson.Field\n\t\tType    respjson.Field\n\t\tError   respjson.Field\n\t\traw     string\n\t} `json:\"-\"`\n}\n\n// anyBetaMessageBatchResult is implemented by each variant of\n// [BetaMessageBatchResultUnion] to add type safety for the return type of\n// [BetaMessageBatchResultUnion.AsAny]\ntype anyBetaMessageBatchResult interface {\n\timplBetaMessageBatchResultUnion()\n}\n\nfunc (BetaMessageBatchSucceededResult) implBetaMessageBatchResultUnion() {}\nfunc (BetaMessageBatchErroredResult) implBetaMessageBatchResultUnion()   {}\nfunc (BetaMessageBatchCanceledResult) implBetaMessageBatchResultUnion()  {}\nfunc (BetaMessageBatchExpiredResult) implBetaMessageBatchResultUnion()   {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := BetaMessageBatchResultUnion.AsAny().(type) {\n//\tcase anthropic.BetaMessageBatchSucceededResult:\n//\tcase anthropic.BetaMessageBatchErroredResult:\n//\tcase anthropic.BetaMessageBatchCanceledResult:\n//\tcase anthropic.BetaMessageBatchExpiredResult:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u BetaMessageBatchResultUnion) AsAny() anyBetaMessageBatchResult {\n\tswitch u.Type {\n\tcase \"succeeded\":\n\t\treturn u.AsSucceeded()\n\tcase \"errored\":\n\t\treturn u.AsErrored()\n\tcase \"canceled\":\n\t\treturn u.AsCanceled()\n\tcase \"expired\":\n\t\treturn u.AsExpired()\n\t}\n\treturn nil\n}\n\nfunc (u BetaMessageBatchResultUnion) AsSucceeded() (v BetaMessageBatchSucceededResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMessageBatchResultUnion) AsErrored() (v BetaMessageBatchErroredResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMessageBatchResultUnion) AsCanceled() (v BetaMessageBatchCanceledResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BetaMessageBatchResultUnion) AsExpired() (v BetaMessageBatchExpiredResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BetaMessageBatchResultUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BetaMessageBatchResultUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageBatchSucceededResult struct {\n\tMessage BetaMessage        `json:\"message\" api:\"required\"`\n\tType    constant.Succeeded `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaMessageBatchSucceededResult) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaMessageBatchSucceededResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaMessageBatchNewParams struct {\n\t// List of requests for prompt completion. Each is an individual request to create\n\t// a Message.\n\tRequests []BetaMessageBatchNewParamsRequest `json:\"requests,omitzero\" api:\"required\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaMessageBatchNewParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMessageBatchNewParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMessageBatchNewParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CustomID, Params are required.\ntype BetaMessageBatchNewParamsRequest struct {\n\t// Developer-provided ID created for each request in a Message Batch. Useful for\n\t// matching results to requests, as results may be given out of request order.\n\t//\n\t// Must be unique for each request within the Message Batch.\n\tCustomID string `json:\"custom_id\" api:\"required\"`\n\t// Messages API creation parameters for the individual request.\n\t//\n\t// See the [Messages API reference](https://docs.claude.com/en/api/messages) for\n\t// full documentation on available parameters.\n\tParams BetaMessageBatchNewParamsRequestParams `json:\"params,omitzero\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BetaMessageBatchNewParamsRequest) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMessageBatchNewParamsRequest\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMessageBatchNewParamsRequest) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Messages API creation parameters for the individual request.\n//\n// See the [Messages API reference](https://docs.claude.com/en/api/messages) for\n// full documentation on available parameters.\n//\n// The properties MaxTokens, Messages, Model are required.\ntype BetaMessageBatchNewParamsRequestParams struct {\n\t// The maximum number of tokens to generate before stopping.\n\t//\n\t// Note that our models may stop _before_ reaching this maximum. This parameter\n\t// only specifies the absolute maximum number of tokens to generate.\n\t//\n\t// Different models have different maximum values for this parameter. See\n\t// [models](https://docs.claude.com/en/docs/models-overview) for details.\n\tMaxTokens int64 `json:\"max_tokens\" api:\"required\"`\n\t// Input messages.\n\t//\n\t// Our models are trained to operate on alternating `user` and `assistant`\n\t// conversational turns. When creating a new `Message`, you specify the prior\n\t// conversational turns with the `messages` parameter, and the model then generates\n\t// the next `Message` in the conversation. Consecutive `user` or `assistant` turns\n\t// in your request will be combined into a single turn.\n\t//\n\t// Each input message must be an object with a `role` and `content`. You can\n\t// specify a single `user`-role message, or you can include multiple `user` and\n\t// `assistant` messages.\n\t//\n\t// If the final message uses the `assistant` role, the response content will\n\t// continue immediately from the content in that message. This can be used to\n\t// constrain part of the model's response.\n\t//\n\t// Example with a single `user` message:\n\t//\n\t// ```json\n\t// [{ \"role\": \"user\", \"content\": \"Hello, Claude\" }]\n\t// ```\n\t//\n\t// Example with multiple conversational turns:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{ \"role\": \"user\", \"content\": \"Hello there.\" },\n\t//\t{ \"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\" },\n\t//\t{ \"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Example with a partially-filled response from Claude:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Each input message `content` may be either a single `string` or an array of\n\t// content blocks, where each block has a specific `type`. Using a `string` for\n\t// `content` is shorthand for an array of one content block of type `\"text\"`. The\n\t// following input messages are equivalent:\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": \"Hello, Claude\" }\n\t// ```\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": [{ \"type\": \"text\", \"text\": \"Hello, Claude\" }] }\n\t// ```\n\t//\n\t// See [input examples](https://docs.claude.com/en/api/messages-examples).\n\t//\n\t// Note that if you want to include a\n\t// [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the\n\t// top-level `system` parameter — there is no `\"system\"` role for input messages in\n\t// the Messages API.\n\t//\n\t// There is a limit of 100,000 messages in a single request.\n\tMessages []BetaMessageParam `json:\"messages,omitzero\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// Specifies the geographic region for inference processing. If not specified, the\n\t// workspace's `default_inference_geo` is used.\n\tInferenceGeo param.Opt[string] `json:\"inference_geo,omitzero\"`\n\t// Whether to incrementally stream the response using server-sent events.\n\t//\n\t// See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.\n\tStream param.Opt[bool] `json:\"stream,omitzero\"`\n\t// Amount of randomness injected into the response.\n\t//\n\t// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`\n\t// for analytical / multiple choice, and closer to `1.0` for creative and\n\t// generative tasks.\n\t//\n\t// Note that even with `temperature` of `0.0`, the results will not be fully\n\t// deterministic.\n\tTemperature param.Opt[float64] `json:\"temperature,omitzero\"`\n\t// Only sample from the top K options for each subsequent token.\n\t//\n\t// Used to remove \"long tail\" low probability responses.\n\t// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopK param.Opt[int64] `json:\"top_k,omitzero\"`\n\t// Use nucleus sampling.\n\t//\n\t// In nucleus sampling, we compute the cumulative distribution over all the options\n\t// for each subsequent token in decreasing probability order and cut it off once it\n\t// reaches a particular probability specified by `top_p`. You should either alter\n\t// `temperature` or `top_p`, but not both.\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopP param.Opt[float64] `json:\"top_p,omitzero\"`\n\t// Container identifier for reuse across requests.\n\tContainer BetaMessageBatchNewParamsRequestParamsContainerUnion `json:\"container,omitzero\"`\n\t// The inference speed mode for this request. `\"fast\"` enables high\n\t// output-tokens-per-second inference.\n\t//\n\t// Any of \"standard\", \"fast\".\n\tSpeed string `json:\"speed,omitzero\"`\n\t// Top-level cache control automatically applies a cache_control marker to the last\n\t// cacheable block in the request.\n\tCacheControl BetaCacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Context management configuration.\n\t//\n\t// This allows you to control how Claude manages context across multiple requests,\n\t// such as whether to clear function results or not.\n\tContextManagement BetaContextManagementConfigParam `json:\"context_management,omitzero\"`\n\t// MCP servers to be utilized in this request\n\tMCPServers []BetaRequestMCPServerURLDefinitionParam `json:\"mcp_servers,omitzero\"`\n\t// An object describing metadata about the request.\n\tMetadata BetaMetadataParam `json:\"metadata,omitzero\"`\n\t// Configuration options for the model's output, such as the output format.\n\tOutputConfig BetaOutputConfigParam `json:\"output_config,omitzero\"`\n\t// Deprecated: Use `output_config.format` instead. See\n\t// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\t//\n\t// A schema to specify Claude's output format in responses. This parameter will be\n\t// removed in a future release.\n\t//\n\t// Deprecated: deprecated\n\tOutputFormat BetaJSONOutputFormatParam `json:\"output_format,omitzero\"`\n\t// Determines whether to use priority capacity (if available) or standard capacity\n\t// for this request.\n\t//\n\t// Anthropic offers different levels of service for your API requests. See\n\t// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.\n\t//\n\t// Any of \"auto\", \"standard_only\".\n\tServiceTier string `json:\"service_tier,omitzero\"`\n\t// Custom text sequences that will cause the model to stop generating.\n\t//\n\t// Our models will normally stop when they have naturally completed their turn,\n\t// which will result in a response `stop_reason` of `\"end_turn\"`.\n\t//\n\t// If you want the model to stop generating when it encounters custom strings of\n\t// text, you can use the `stop_sequences` parameter. If the model encounters one of\n\t// the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"`\n\t// and the response `stop_sequence` value will contain the matched stop sequence.\n\tStopSequences []string `json:\"stop_sequences,omitzero\"`\n\t// System prompt.\n\t//\n\t// A system prompt is a way of providing context and instructions to Claude, such\n\t// as specifying a particular goal or role. See our\n\t// [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).\n\tSystem []BetaTextBlockParam `json:\"system,omitzero\"`\n\t// Configuration for enabling Claude's extended thinking.\n\t//\n\t// When enabled, responses include `thinking` content blocks showing Claude's\n\t// thinking process before the final answer. Requires a minimum budget of 1,024\n\t// tokens and counts towards your `max_tokens` limit.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tThinking BetaThinkingConfigParamUnion `json:\"thinking,omitzero\"`\n\t// How the model should use the provided tools. The model can use a specific tool,\n\t// any available tool, decide by itself, or not use tools at all.\n\tToolChoice BetaToolChoiceUnionParam `json:\"tool_choice,omitzero\"`\n\t// Definitions of tools that the model may use.\n\t//\n\t// If you include `tools` in your API request, the model may return `tool_use`\n\t// content blocks that represent the model's use of those tools. You can then run\n\t// those tools using the tool input generated by the model and then optionally\n\t// return results back to the model using `tool_result` content blocks.\n\t//\n\t// There are two types of tools: **client tools** and **server tools**. The\n\t// behavior described below applies to client tools. For\n\t// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),\n\t// see their individual documentation as each has its own behavior (e.g., the\n\t// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\t//\n\t// Each tool definition includes:\n\t//\n\t//   - `name`: Name of the tool.\n\t//   - `description`: Optional, but strongly-recommended description of the tool.\n\t//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the\n\t//     tool `input` shape that the model will produce in `tool_use` output content\n\t//     blocks.\n\t//\n\t// For example, if you defined `tools` as:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"description\": \"Get the current stock price for a given ticker symbol.\",\n\t//\t  \"input_schema\": {\n\t//\t    \"type\": \"object\",\n\t//\t    \"properties\": {\n\t//\t      \"ticker\": {\n\t//\t        \"type\": \"string\",\n\t//\t        \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n\t//\t      }\n\t//\t    },\n\t//\t    \"required\": [\"ticker\"]\n\t//\t  }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// And then asked the model \"What's the S&P 500 at today?\", the model might produce\n\t// `tool_use` content blocks in the response like this:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_use\",\n\t//\t  \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"input\": { \"ticker\": \"^GSPC\" }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// You might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an\n\t// input, and return the following back to the model in a subsequent `user`\n\t// message:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_result\",\n\t//\t  \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"content\": \"259.75 USD\"\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Tools can be used for workflows that include running client-side tools and\n\t// functions, or more generally whenever you want the model to produce a particular\n\t// JSON structure of output.\n\t//\n\t// See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.\n\tTools []BetaToolUnionParam `json:\"tools,omitzero\"`\n\tparamObj\n}\n\nfunc (r BetaMessageBatchNewParamsRequestParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow BetaMessageBatchNewParamsRequestParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BetaMessageBatchNewParamsRequestParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc init() {\n\tapijson.RegisterFieldValidator[BetaMessageBatchNewParamsRequestParams](\n\t\t\"service_tier\", \"auto\", \"standard_only\",\n\t)\n\tapijson.RegisterFieldValidator[BetaMessageBatchNewParamsRequestParams](\n\t\t\"speed\", \"standard\", \"fast\",\n\t)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BetaMessageBatchNewParamsRequestParamsContainerUnion struct {\n\tOfContainers *BetaContainerParams `json:\",omitzero,inline\"`\n\tOfString     param.Opt[string]    `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BetaMessageBatchNewParamsRequestParamsContainerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfContainers, u.OfString)\n}\nfunc (u *BetaMessageBatchNewParamsRequestParamsContainerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BetaMessageBatchNewParamsRequestParamsContainerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfContainers) {\n\t\treturn u.OfContainers\n\t} else if !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t}\n\treturn nil\n}\n\ntype BetaMessageBatchGetParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaMessageBatchListParams struct {\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately after this object.\n\tAfterID param.Opt[string] `query:\"after_id,omitzero\" json:\"-\"`\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately before this object.\n\tBeforeID param.Opt[string] `query:\"before_id,omitzero\" json:\"-\"`\n\t// Number of items to return per page.\n\t//\n\t// Defaults to `20`. Ranges from `1` to `1000`.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [BetaMessageBatchListParams]'s query parameters as\n// `url.Values`.\nfunc (r BetaMessageBatchListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n\ntype BetaMessageBatchDeleteParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaMessageBatchCancelParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaMessageBatchResultsParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n"
  },
  {
    "path": "betamessagebatch_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestBetaMessageBatchNewWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.Batches.New(context.TODO(), anthropic.BetaMessageBatchNewParams{\n\t\tRequests: []anthropic.BetaMessageBatchNewParamsRequest{{\n\t\t\tCustomID: \"my-custom-id-1\",\n\t\t\tParams: anthropic.BetaMessageBatchNewParamsRequestParams{\n\t\t\t\tMaxTokens: 1024,\n\t\t\t\tMessages: []anthropic.BetaMessageParam{{\n\t\t\t\t\tContent: []anthropic.BetaContentBlockParamUnion{{\n\t\t\t\t\t\tOfText: &anthropic.BetaTextBlockParam{\n\t\t\t\t\t\t\tText: \"x\",\n\t\t\t\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tCitations: []anthropic.BetaTextCitationParamUnion{{\n\t\t\t\t\t\t\t\tOfCharLocation: &anthropic.BetaCitationCharLocationParam{\n\t\t\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t\tRole: anthropic.BetaMessageParamRoleUser,\n\t\t\t\t}},\n\t\t\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tContainer: anthropic.BetaMessageBatchNewParamsRequestParamsContainerUnion{\n\t\t\t\t\tOfContainers: &anthropic.BetaContainerParams{\n\t\t\t\t\t\tID: anthropic.String(\"id\"),\n\t\t\t\t\t\tSkills: []anthropic.BetaSkillParams{{\n\t\t\t\t\t\t\tSkillID: \"pdf\",\n\t\t\t\t\t\t\tType:    anthropic.BetaSkillParamsTypeAnthropic,\n\t\t\t\t\t\t\tVersion: anthropic.String(\"latest\"),\n\t\t\t\t\t\t}},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tContextManagement: anthropic.BetaContextManagementConfigParam{\n\t\t\t\t\tEdits: []anthropic.BetaContextManagementConfigEditUnionParam{{\n\t\t\t\t\t\tOfClearToolUses20250919: &anthropic.BetaClearToolUses20250919EditParam{\n\t\t\t\t\t\t\tClearAtLeast: anthropic.BetaInputTokensClearAtLeastParam{\n\t\t\t\t\t\t\t\tValue: 0,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tClearToolInputs: anthropic.BetaClearToolUses20250919EditClearToolInputsUnionParam{\n\t\t\t\t\t\t\t\tOfBool: anthropic.Bool(true),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tExcludeTools: []string{\"string\"},\n\t\t\t\t\t\t\tKeep: anthropic.BetaToolUsesKeepParam{\n\t\t\t\t\t\t\t\tValue: 0,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tTrigger: anthropic.BetaClearToolUses20250919EditTriggerUnionParam{\n\t\t\t\t\t\t\t\tOfInputTokens: &anthropic.BetaInputTokensTriggerParam{\n\t\t\t\t\t\t\t\t\tValue: 1,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t\tInferenceGeo: anthropic.String(\"inference_geo\"),\n\t\t\t\tMCPServers: []anthropic.BetaRequestMCPServerURLDefinitionParam{{\n\t\t\t\t\tName:               \"name\",\n\t\t\t\t\tURL:                \"url\",\n\t\t\t\t\tAuthorizationToken: anthropic.String(\"authorization_token\"),\n\t\t\t\t\tToolConfiguration: anthropic.BetaRequestMCPServerToolConfigurationParam{\n\t\t\t\t\t\tAllowedTools: []string{\"string\"},\n\t\t\t\t\t\tEnabled:      anthropic.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t\tMetadata: anthropic.BetaMetadataParam{\n\t\t\t\t\tUserID: anthropic.String(\"13803d75-b4b5-4c3e-b2a2-6f21399b021b\"),\n\t\t\t\t},\n\t\t\t\tOutputConfig: anthropic.BetaOutputConfigParam{\n\t\t\t\t\tEffort: anthropic.BetaOutputConfigEffortLow,\n\t\t\t\t\tFormat: anthropic.BetaJSONOutputFormatParam{\n\t\t\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tOutputFormat: anthropic.BetaJSONOutputFormatParam{\n\t\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tServiceTier:   \"auto\",\n\t\t\t\tSpeed:         \"standard\",\n\t\t\t\tStopSequences: []string{\"string\"},\n\t\t\t\tStream:        anthropic.Bool(true),\n\t\t\t\tSystem: []anthropic.BetaTextBlockParam{{\n\t\t\t\t\tText: \"Today's date is 2024-06-01.\",\n\t\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t},\n\t\t\t\t\tCitations: []anthropic.BetaTextCitationParamUnion{{\n\t\t\t\t\t\tOfCharLocation: &anthropic.BetaCitationCharLocationParam{\n\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t}},\n\t\t\t\tTemperature: anthropic.Float(1),\n\t\t\t\tThinking: anthropic.BetaThinkingConfigParamUnion{\n\t\t\t\t\tOfAdaptive: &anthropic.BetaThinkingConfigAdaptiveParam{\n\t\t\t\t\t\tDisplay: anthropic.BetaThinkingConfigAdaptiveDisplaySummarized,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tToolChoice: anthropic.BetaToolChoiceUnionParam{\n\t\t\t\t\tOfAuto: &anthropic.BetaToolChoiceAutoParam{\n\t\t\t\t\t\tDisableParallelToolUse: anthropic.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tTools: []anthropic.BetaToolUnionParam{{\n\t\t\t\t\tOfTool: &anthropic.BetaToolParam{\n\t\t\t\t\t\tInputSchema: anthropic.BetaToolInputSchemaParam{\n\t\t\t\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\t\t\t\"location\": \"bar\",\n\t\t\t\t\t\t\t\t\"unit\":     \"bar\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tRequired: []string{\"location\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tName:           \"name\",\n\t\t\t\t\t\tAllowedCallers: []string{\"direct\"},\n\t\t\t\t\t\tCacheControl: anthropic.BetaCacheControlEphemeralParam{\n\t\t\t\t\t\t\tTTL: anthropic.BetaCacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tDeferLoading:        anthropic.Bool(true),\n\t\t\t\t\t\tDescription:         anthropic.String(\"Get the current weather in a given location\"),\n\t\t\t\t\t\tEagerInputStreaming: anthropic.Bool(true),\n\t\t\t\t\t\tInputExamples: []map[string]any{{\n\t\t\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t\t\t}},\n\t\t\t\t\t\tStrict: anthropic.Bool(true),\n\t\t\t\t\t\tType:   anthropic.BetaToolTypeCustom,\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t\tTopK: anthropic.Int(5),\n\t\t\t\tTopP: anthropic.Float(0.7),\n\t\t\t},\n\t\t}},\n\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaMessageBatchGetWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.Batches.Get(\n\t\tcontext.TODO(),\n\t\t\"message_batch_id\",\n\t\tanthropic.BetaMessageBatchGetParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaMessageBatchListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.Batches.List(context.TODO(), anthropic.BetaMessageBatchListParams{\n\t\tAfterID:  anthropic.String(\"after_id\"),\n\t\tBeforeID: anthropic.String(\"before_id\"),\n\t\tLimit:    anthropic.Int(1),\n\t\tBetas:    []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaMessageBatchDeleteWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.Batches.Delete(\n\t\tcontext.TODO(),\n\t\t\"message_batch_id\",\n\t\tanthropic.BetaMessageBatchDeleteParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaMessageBatchCancelWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Messages.Batches.Cancel(\n\t\tcontext.TODO(),\n\t\t\"message_batch_id\",\n\t\tanthropic.BetaMessageBatchCancelParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "betamessageutil.go",
    "content": "package anthropic\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/paramutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n)\n\n// Accumulate builds up the Message incrementally from a MessageStreamEvent. The Message then can be used as\n// any other Message, except with the caveat that the Message.JSON field which normally can be used to inspect\n// the JSON sent over the network may not be populated fully.\n//\n//\tmessage := anthropic.Message{}\n//\tfor stream.Next() {\n//\t\tevent := stream.Current()\n//\t\tmessage.Accumulate(event)\n//\t}\nfunc (acc *BetaMessage) Accumulate(event BetaRawMessageStreamEventUnion) error {\n\tif acc == nil {\n\t\treturn fmt.Errorf(\"accumulate: cannot accumulate into nil Message\")\n\t}\n\n\tswitch event := event.AsAny().(type) {\n\tcase BetaRawMessageStartEvent:\n\t\t*acc = event.Message\n\tcase BetaRawMessageDeltaEvent:\n\t\tacc.StopReason = event.Delta.StopReason\n\t\tacc.StopSequence = event.Delta.StopSequence\n\t\tacc.Usage.OutputTokens = event.Usage.OutputTokens\n\t\tacc.Usage.Iterations = event.Usage.Iterations\n\t\tacc.ContextManagement = event.ContextManagement\n\tcase BetaRawContentBlockStartEvent:\n\t\tacc.Content = append(acc.Content, BetaContentBlockUnion{})\n\t\terr := acc.Content[len(acc.Content)-1].UnmarshalJSON([]byte(event.ContentBlock.RawJSON()))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tcase BetaRawContentBlockDeltaEvent:\n\t\tif len(acc.Content) == 0 {\n\t\t\treturn fmt.Errorf(\"received event of type %s but there was no content block\", event.Type)\n\t\t}\n\t\tcb := &acc.Content[len(acc.Content)-1]\n\t\tswitch delta := event.Delta.AsAny().(type) {\n\t\tcase BetaTextDelta:\n\t\t\tcb.Text += delta.Text\n\t\tcase BetaInputJSONDelta:\n\t\t\tif len(delta.PartialJSON) != 0 {\n\t\t\t\tif string(cb.Input) == \"{}\" {\n\t\t\t\t\tcb.Input = []byte(delta.PartialJSON)\n\t\t\t\t} else {\n\t\t\t\t\tcb.Input = append(cb.Input, []byte(delta.PartialJSON)...)\n\t\t\t\t}\n\t\t\t}\n\t\tcase BetaThinkingDelta:\n\t\t\tcb.Thinking += delta.Thinking\n\t\tcase BetaSignatureDelta:\n\t\t\tcb.Signature += delta.Signature\n\t\tcase BetaCitationsDelta:\n\t\t\tcitation := BetaTextCitationUnion{}\n\t\t\terr := citation.UnmarshalJSON([]byte(delta.Citation.RawJSON()))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not unmarshal citation delta into citation type: %w\", err)\n\t\t\t}\n\t\t\tcb.Citations = append(cb.Citations, citation)\n\t\tcase BetaCompactionContentBlockDelta:\n\t\t\tcb.Content.OfString = delta.Content\n\t\t}\n\tcase BetaRawMessageStopEvent:\n\t\t// Re-marshal the accumulated message to update JSON.raw so that AsAny()\n\t\t// returns the accumulated data rather than the original stream data\n\t\taccJSON, err := json.Marshal(acc)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error converting accumulated message to JSON: %w\", err)\n\t\t}\n\t\tacc.JSON.raw = string(accJSON)\n\tcase BetaRawContentBlockStopEvent:\n\t\t// Re-marshal the content block to update JSON.raw so that AsAny()\n\t\t// returns the accumulated data rather than the original stream data\n\t\tif len(acc.Content) == 0 {\n\t\t\treturn fmt.Errorf(\"received event of type %s but there was no content block\", event.Type)\n\t\t}\n\t\tcontentBlock := &acc.Content[len(acc.Content)-1]\n\t\tcbJSON, err := json.Marshal(contentBlock)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error converting content block to JSON: %w\", err)\n\t\t}\n\t\tcontentBlock.JSON.raw = string(cbJSON)\n\t}\n\n\treturn nil\n}\n\n// Param converters\n\nfunc (r BetaContentBlockUnion) ToParam() BetaContentBlockParamUnion {\n\treturn r.AsAny().toParamUnion()\n}\n\nfunc (variant BetaTextBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfText: &p}\n}\n\nfunc (variant BetaToolUseBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfToolUse: &p}\n}\n\nfunc (variant BetaThinkingBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfThinking: &p}\n}\n\nfunc (variant BetaRedactedThinkingBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfRedactedThinking: &p}\n}\n\nfunc (variant BetaWebSearchToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfWebSearchToolResult: &p}\n}\n\nfunc (variant BetaBashCodeExecutionToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfBashCodeExecutionToolResult: &p}\n}\n\nfunc (variant BetaCodeExecutionToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfCodeExecutionToolResult: &p}\n}\n\nfunc (variant BetaContainerUploadBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfContainerUpload: &p}\n}\n\nfunc (variant BetaMCPToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfMCPToolResult: &p}\n}\n\nfunc (variant BetaMCPToolUseBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfMCPToolUse: &p}\n}\n\nfunc (variant BetaServerToolUseBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfServerToolUse: &p}\n}\n\nfunc (variant BetaTextEditorCodeExecutionToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfTextEditorCodeExecutionToolResult: &p}\n}\n\nfunc (variant BetaWebFetchToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfWebFetchToolResult: &p}\n}\n\nfunc (variant BetaToolSearchToolResultBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfToolSearchToolResult: &p}\n}\n\nfunc (variant BetaCompactionBlock) toParamUnion() BetaContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn BetaContentBlockParamUnion{OfCompaction: &p}\n}\n\nfunc (r BetaMessage) ToParam() BetaMessageParam {\n\tvar p BetaMessageParam\n\tp.Role = BetaMessageParamRole(r.Role)\n\tp.Content = make([]BetaContentBlockParamUnion, len(r.Content))\n\tfor i, c := range r.Content {\n\t\tcontentParams := c.ToParam()\n\t\tp.Content[i] = contentParams\n\t}\n\treturn p\n}\n\nfunc (r BetaRedactedThinkingBlock) ToParam() BetaRedactedThinkingBlockParam {\n\tvar p BetaRedactedThinkingBlockParam\n\tp.Type = r.Type\n\tp.Data = r.Data\n\treturn p\n}\n\nfunc (r BetaTextBlock) ToParam() BetaTextBlockParam {\n\tvar p BetaTextBlockParam\n\tp.Type = r.Type\n\tp.Text = r.Text\n\n\t// Distinguish between a nil and zero length slice, since some compatible\n\t// APIs may not require citations.\n\tif r.Citations != nil {\n\t\tp.Citations = make([]BetaTextCitationParamUnion, 0, len(r.Citations))\n\t}\n\tfor _, citation := range r.Citations {\n\t\tp.Citations = append(p.Citations, citation.AsAny().toParamUnion())\n\t}\n\treturn p\n}\n\nfunc (r BetaCitationCharLocation) toParamUnion() BetaTextCitationParamUnion {\n\tvar citationParam BetaCitationCharLocationParam\n\tcitationParam.Type = r.Type\n\tcitationParam.DocumentTitle = paramutil.ToOpt(r.DocumentTitle, r.JSON.DocumentTitle)\n\tcitationParam.CitedText = r.CitedText\n\tcitationParam.DocumentIndex = r.DocumentIndex\n\tcitationParam.EndCharIndex = r.EndCharIndex\n\tcitationParam.StartCharIndex = r.StartCharIndex\n\treturn BetaTextCitationParamUnion{OfCharLocation: &citationParam}\n}\n\nfunc (citationVariant BetaCitationPageLocation) toParamUnion() BetaTextCitationParamUnion {\n\tvar citationParam BetaCitationPageLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.DocumentTitle = paramutil.ToOpt(citationVariant.DocumentTitle, citationVariant.JSON.DocumentTitle)\n\tcitationParam.DocumentIndex = citationVariant.DocumentIndex\n\tcitationParam.EndPageNumber = citationVariant.EndPageNumber\n\tcitationParam.StartPageNumber = citationVariant.StartPageNumber\n\treturn BetaTextCitationParamUnion{OfPageLocation: &citationParam}\n}\n\nfunc (citationVariant BetaCitationContentBlockLocation) toParamUnion() BetaTextCitationParamUnion {\n\tvar citationParam BetaCitationContentBlockLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.DocumentTitle = paramutil.ToOpt(citationVariant.DocumentTitle, citationVariant.JSON.DocumentTitle)\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.DocumentIndex = citationVariant.DocumentIndex\n\tcitationParam.EndBlockIndex = citationVariant.EndBlockIndex\n\tcitationParam.StartBlockIndex = citationVariant.StartBlockIndex\n\treturn BetaTextCitationParamUnion{OfContentBlockLocation: &citationParam}\n}\n\nfunc (citationVariant BetaCitationsWebSearchResultLocation) toParamUnion() BetaTextCitationParamUnion {\n\tvar citationParam BetaCitationWebSearchResultLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.Title = paramutil.ToOpt(citationVariant.Title, citationVariant.JSON.Title)\n\treturn BetaTextCitationParamUnion{OfWebSearchResultLocation: &citationParam}\n}\n\nfunc (citationVariant BetaCitationSearchResultLocation) toParamUnion() BetaTextCitationParamUnion {\n\tvar citationParam BetaCitationSearchResultLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.Title = paramutil.ToOpt(citationVariant.Title, citationVariant.JSON.Title)\n\tcitationParam.EndBlockIndex = citationVariant.EndBlockIndex\n\tcitationParam.StartBlockIndex = citationVariant.StartBlockIndex\n\tcitationParam.Source = citationVariant.Source\n\treturn BetaTextCitationParamUnion{OfSearchResultLocation: &citationParam}\n}\n\nfunc (r BetaThinkingBlock) ToParam() BetaThinkingBlockParam {\n\tvar p BetaThinkingBlockParam\n\tp.Type = r.Type\n\tp.Signature = r.Signature\n\tp.Thinking = r.Thinking\n\treturn p\n}\n\nfunc (r BetaToolUseBlock) ToParam() BetaToolUseBlockParam {\n\tvar p BetaToolUseBlockParam\n\tp.Type = r.Type\n\tp.ID = r.ID\n\tp.Input = r.Input\n\tp.Name = r.Name\n\treturn p\n}\n\nfunc (r BetaWebSearchResultBlock) ToParam() BetaWebSearchResultBlockParam {\n\tvar p BetaWebSearchResultBlockParam\n\tp.Type = r.Type\n\tp.EncryptedContent = r.EncryptedContent\n\tp.Title = r.Title\n\tp.URL = r.URL\n\tp.PageAge = paramutil.ToOpt(r.PageAge, r.JSON.PageAge)\n\treturn p\n}\n\nfunc (r BetaWebSearchToolResultBlock) ToParam() BetaWebSearchToolResultBlockParam {\n\tvar p BetaWebSearchToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\n\tif len(r.Content.OfBetaWebSearchResultBlockArray) > 0 {\n\t\tfor _, block := range r.Content.OfBetaWebSearchResultBlockArray {\n\t\t\tp.Content.OfResultBlock = append(p.Content.OfResultBlock, block.ToParam())\n\t\t}\n\t} else {\n\t\tp.Content.OfError = &BetaWebSearchToolRequestErrorParam{\n\t\t\tType:      r.Content.Type,\n\t\t\tErrorCode: r.Content.ErrorCode,\n\t\t}\n\t}\n\treturn p\n}\n\nfunc (r BetaWebFetchToolResultBlock) ToParam() BetaWebFetchToolResultBlockParam {\n\tvar p BetaWebFetchToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\treturn p\n}\n\nfunc (r BetaMCPToolUseBlock) ToParam() BetaMCPToolUseBlockParam {\n\tvar p BetaMCPToolUseBlockParam\n\tp.Type = r.Type\n\tp.ID = r.ID\n\tp.Input = r.Input\n\tp.Name = r.Name\n\tp.ServerName = r.ServerName\n\treturn p\n}\n\nfunc (r BetaContainerUploadBlock) ToParam() BetaContainerUploadBlockParam {\n\tvar p BetaContainerUploadBlockParam\n\tp.Type = r.Type\n\tp.FileID = r.FileID\n\treturn p\n}\n\nfunc (r BetaServerToolUseBlock) ToParam() BetaServerToolUseBlockParam {\n\tvar p BetaServerToolUseBlockParam\n\tp.Type = r.Type\n\tp.ID = r.ID\n\tp.Input = r.Input\n\tp.Name = BetaServerToolUseBlockParamName(r.Name)\n\treturn p\n}\n\nfunc (r BetaTextEditorCodeExecutionToolResultBlock) ToParam() BetaTextEditorCodeExecutionToolResultBlockParam {\n\tvar p BetaTextEditorCodeExecutionToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestTextEditorCodeExecutionToolResultError = &BetaTextEditorCodeExecutionToolResultErrorParam{\n\t\t\tErrorCode:    BetaTextEditorCodeExecutionToolResultErrorParamErrorCode(r.Content.ErrorCode),\n\t\t\tErrorMessage: paramutil.ToOpt(r.Content.ErrorMessage, r.Content.JSON.ErrorMessage),\n\t\t}\n\t} else {\n\t\tp.Content = param.Override[BetaTextEditorCodeExecutionToolResultBlockParamContentUnion](r.Content.RawJSON())\n\t}\n\treturn p\n}\n\nfunc (r BetaMCPToolResultBlock) ToParam() BetaRequestMCPToolResultBlockParam {\n\tvar p BetaRequestMCPToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.OfString.Valid() {\n\t\tp.Content.OfString = paramutil.ToOpt(r.Content.OfString, r.Content.JSON.OfString)\n\t} else {\n\t\tfor _, block := range r.Content.OfBetaMCPToolResultBlockContent {\n\t\t\tp.Content.OfBetaMCPToolResultBlockContent = append(p.Content.OfBetaMCPToolResultBlockContent, block.ToParam())\n\t\t}\n\t}\n\treturn p\n}\n\nfunc (r BetaBashCodeExecutionToolResultBlock) ToParam() BetaBashCodeExecutionToolResultBlockParam {\n\tvar p BetaBashCodeExecutionToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestBashCodeExecutionToolResultError = &BetaBashCodeExecutionToolResultErrorParam{\n\t\t\tErrorCode: BetaBashCodeExecutionToolResultErrorParamErrorCode(r.Content.ErrorCode),\n\t\t}\n\t} else {\n\t\trequestBashContentResult := &BetaBashCodeExecutionResultBlockParam{\n\t\t\tReturnCode: r.Content.ReturnCode,\n\t\t\tStderr:     r.Content.Stderr,\n\t\t\tStdout:     r.Content.Stdout,\n\t\t}\n\t\tfor _, block := range r.Content.Content {\n\t\t\trequestBashContentResult.Content = append(requestBashContentResult.Content, block.ToParam())\n\t\t}\n\t\tp.Content.OfRequestBashCodeExecutionResultBlock = requestBashContentResult\n\t}\n\n\treturn p\n}\n\nfunc (r BetaBashCodeExecutionOutputBlock) ToParam() BetaBashCodeExecutionOutputBlockParam {\n\tvar p BetaBashCodeExecutionOutputBlockParam\n\tp.Type = r.Type\n\tp.FileID = r.FileID\n\treturn p\n}\n\nfunc (r BetaCodeExecutionToolResultBlock) ToParam() BetaCodeExecutionToolResultBlockParam {\n\tvar p BetaCodeExecutionToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfError = &BetaCodeExecutionToolResultErrorParam{\n\t\t\tErrorCode: r.Content.ErrorCode,\n\t\t}\n\t} else {\n\t\tp.Content.OfResultBlock = &BetaCodeExecutionResultBlockParam{\n\t\t\tReturnCode: r.Content.ReturnCode,\n\t\t\tStderr:     r.Content.Stderr,\n\t\t\tStdout:     r.Content.Stdout,\n\t\t}\n\t\tfor _, block := range r.Content.Content {\n\t\t\tp.Content.OfResultBlock.Content = append(p.Content.OfResultBlock.Content, block.ToParam())\n\t\t}\n\t}\n\treturn p\n}\n\nfunc (r BetaCodeExecutionOutputBlock) ToParam() BetaCodeExecutionOutputBlockParam {\n\tvar p BetaCodeExecutionOutputBlockParam\n\tp.Type = r.Type\n\tp.FileID = r.FileID\n\treturn p\n}\n\nfunc (r BetaToolSearchToolResultBlock) ToParam() BetaToolSearchToolResultBlockParam {\n\tvar p BetaToolSearchToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestToolSearchToolResultError = &BetaToolSearchToolResultErrorParam{\n\t\t\tErrorCode: BetaToolSearchToolResultErrorParamErrorCode(r.Content.ErrorCode),\n\t\t}\n\t} else {\n\t\tp.Content.OfRequestToolSearchToolSearchResultBlock = &BetaToolSearchToolSearchResultBlockParam{}\n\t\tfor _, block := range r.Content.ToolReferences {\n\t\t\tp.Content.OfRequestToolSearchToolSearchResultBlock.ToolReferences = append(\n\t\t\t\tp.Content.OfRequestToolSearchToolSearchResultBlock.ToolReferences,\n\t\t\t\tblock.ToParam(),\n\t\t\t)\n\t\t}\n\t}\n\treturn p\n}\n\nfunc (r BetaToolReferenceBlock) ToParam() BetaToolReferenceBlockParam {\n\tvar p BetaToolReferenceBlockParam\n\tp.Type = r.Type\n\tp.ToolName = r.ToolName\n\treturn p\n}\n\nfunc (r BetaCompactionBlock) ToParam() BetaCompactionBlockParam {\n\tvar p BetaCompactionBlockParam\n\tp.Type = r.Type\n\tp.Content = param.NewOpt(r.Content)\n\treturn p\n}\n"
  },
  {
    "path": "betamodel.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// BetaModelService contains methods and other services that help with interacting\n// with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaModelService] method instead.\ntype BetaModelService struct {\n\tOptions []option.RequestOption\n}\n\n// NewBetaModelService generates a new service that applies the given options to\n// each request. These options are applied after the parent client's options (if\n// there is one), and before any request-specific options.\nfunc NewBetaModelService(opts ...option.RequestOption) (r BetaModelService) {\n\tr = BetaModelService{}\n\tr.Options = opts\n\treturn\n}\n\n// Get a specific model.\n//\n// The Models API response can be used to determine information about a specific\n// model or resolve a model alias to a model ID.\nfunc (r *BetaModelService) Get(ctx context.Context, modelID string, query BetaModelGetParams, opts ...option.RequestOption) (res *BetaModelInfo, err error) {\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\tif modelID == \"\" {\n\t\terr = errors.New(\"missing required model_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/models/%s?beta=true\", modelID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// List available models.\n//\n// The Models API response can be used to determine which models are available for\n// use in the API. More recently released models are listed first.\nfunc (r *BetaModelService) List(ctx context.Context, params BetaModelListParams, opts ...option.RequestOption) (res *pagination.Page[BetaModelInfo], err error) {\n\tvar raw *http.Response\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)\n\tpath := \"v1/models?beta=true\"\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List available models.\n//\n// The Models API response can be used to determine which models are available for\n// use in the API. More recently released models are listed first.\nfunc (r *BetaModelService) ListAutoPaging(ctx context.Context, params BetaModelListParams, opts ...option.RequestOption) *pagination.PageAutoPager[BetaModelInfo] {\n\treturn pagination.NewPageAutoPager(r.List(ctx, params, opts...))\n}\n\n// Indicates whether a capability is supported.\ntype BetaCapabilitySupport struct {\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSupported   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaCapabilitySupport) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaCapabilitySupport) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Context management capability details.\ntype BetaContextManagementCapability struct {\n\t// Indicates whether a capability is supported.\n\tClearThinking20251015 BetaCapabilitySupport `json:\"clear_thinking_20251015\" api:\"required\"`\n\t// Indicates whether a capability is supported.\n\tClearToolUses20250919 BetaCapabilitySupport `json:\"clear_tool_uses_20250919\" api:\"required\"`\n\t// Indicates whether a capability is supported.\n\tCompact20260112 BetaCapabilitySupport `json:\"compact_20260112\" api:\"required\"`\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tClearThinking20251015 respjson.Field\n\t\tClearToolUses20250919 respjson.Field\n\t\tCompact20260112       respjson.Field\n\t\tSupported             respjson.Field\n\t\tExtraFields           map[string]respjson.Field\n\t\traw                   string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaContextManagementCapability) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaContextManagementCapability) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Effort (reasoning_effort) capability details.\ntype BetaEffortCapability struct {\n\t// Whether the model supports high effort level.\n\tHigh BetaCapabilitySupport `json:\"high\" api:\"required\"`\n\t// Whether the model supports low effort level.\n\tLow BetaCapabilitySupport `json:\"low\" api:\"required\"`\n\t// Whether the model supports max effort level.\n\tMax BetaCapabilitySupport `json:\"max\" api:\"required\"`\n\t// Whether the model supports medium effort level.\n\tMedium BetaCapabilitySupport `json:\"medium\" api:\"required\"`\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tHigh        respjson.Field\n\t\tLow         respjson.Field\n\t\tMax         respjson.Field\n\t\tMedium      respjson.Field\n\t\tSupported   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaEffortCapability) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaEffortCapability) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Model capability information.\ntype BetaModelCapabilities struct {\n\t// Whether the model supports the Batch API.\n\tBatch BetaCapabilitySupport `json:\"batch\" api:\"required\"`\n\t// Whether the model supports citation generation.\n\tCitations BetaCapabilitySupport `json:\"citations\" api:\"required\"`\n\t// Whether the model supports code execution tools.\n\tCodeExecution BetaCapabilitySupport `json:\"code_execution\" api:\"required\"`\n\t// Context management support and available strategies.\n\tContextManagement BetaContextManagementCapability `json:\"context_management\" api:\"required\"`\n\t// Effort (reasoning_effort) support and available levels.\n\tEffort BetaEffortCapability `json:\"effort\" api:\"required\"`\n\t// Whether the model accepts image content blocks.\n\tImageInput BetaCapabilitySupport `json:\"image_input\" api:\"required\"`\n\t// Whether the model accepts PDF content blocks.\n\tPDFInput BetaCapabilitySupport `json:\"pdf_input\" api:\"required\"`\n\t// Whether the model supports structured output / JSON mode / strict tool schemas.\n\tStructuredOutputs BetaCapabilitySupport `json:\"structured_outputs\" api:\"required\"`\n\t// Thinking capability and supported type configurations.\n\tThinking BetaThinkingCapability `json:\"thinking\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tBatch             respjson.Field\n\t\tCitations         respjson.Field\n\t\tCodeExecution     respjson.Field\n\t\tContextManagement respjson.Field\n\t\tEffort            respjson.Field\n\t\tImageInput        respjson.Field\n\t\tPDFInput          respjson.Field\n\t\tStructuredOutputs respjson.Field\n\t\tThinking          respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaModelCapabilities) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaModelCapabilities) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaModelInfo struct {\n\t// Unique model identifier.\n\tID string `json:\"id\" api:\"required\"`\n\t// Model capability information.\n\tCapabilities BetaModelCapabilities `json:\"capabilities\" api:\"required\"`\n\t// RFC 3339 datetime string representing the time at which the model was released.\n\t// May be set to an epoch value if the release date is unknown.\n\tCreatedAt time.Time `json:\"created_at\" api:\"required\" format:\"date-time\"`\n\t// A human-readable name for the model.\n\tDisplayName string `json:\"display_name\" api:\"required\"`\n\t// Maximum input context window size in tokens for this model.\n\tMaxInputTokens int64 `json:\"max_input_tokens\" api:\"required\"`\n\t// Maximum value for the `max_tokens` parameter when using this model.\n\tMaxTokens int64 `json:\"max_tokens\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Models, this is always `\"model\"`.\n\tType constant.Model `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID             respjson.Field\n\t\tCapabilities   respjson.Field\n\t\tCreatedAt      respjson.Field\n\t\tDisplayName    respjson.Field\n\t\tMaxInputTokens respjson.Field\n\t\tMaxTokens      respjson.Field\n\t\tType           respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaModelInfo) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaModelInfo) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Thinking capability details.\ntype BetaThinkingCapability struct {\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// Supported thinking type configurations.\n\tTypes BetaThinkingTypes `json:\"types\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSupported   respjson.Field\n\t\tTypes       respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaThinkingCapability) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaThinkingCapability) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Supported thinking type configurations.\ntype BetaThinkingTypes struct {\n\t// Whether the model supports thinking with type 'adaptive' (auto).\n\tAdaptive BetaCapabilitySupport `json:\"adaptive\" api:\"required\"`\n\t// Whether the model supports thinking with type 'enabled'.\n\tEnabled BetaCapabilitySupport `json:\"enabled\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tAdaptive    respjson.Field\n\t\tEnabled     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaThinkingTypes) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaThinkingTypes) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaModelGetParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaModelListParams struct {\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately after this object.\n\tAfterID param.Opt[string] `query:\"after_id,omitzero\" json:\"-\"`\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately before this object.\n\tBeforeID param.Opt[string] `query:\"before_id,omitzero\" json:\"-\"`\n\t// Number of items to return per page.\n\t//\n\t// Defaults to `20`. Ranges from `1` to `1000`.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [BetaModelListParams]'s query parameters as `url.Values`.\nfunc (r BetaModelListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n"
  },
  {
    "path": "betamodel_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestBetaModelGetWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Models.Get(\n\t\tcontext.TODO(),\n\t\t\"model_id\",\n\t\tanthropic.BetaModelGetParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaModelListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Models.List(context.TODO(), anthropic.BetaModelListParams{\n\t\tAfterID:  anthropic.String(\"after_id\"),\n\t\tBeforeID: anthropic.String(\"before_id\"),\n\t\tLimit:    anthropic.Int(1),\n\t\tBetas:    []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "betaskill.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiform\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n)\n\n// BetaSkillService contains methods and other services that help with interacting\n// with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaSkillService] method instead.\ntype BetaSkillService struct {\n\tOptions  []option.RequestOption\n\tVersions BetaSkillVersionService\n}\n\n// NewBetaSkillService generates a new service that applies the given options to\n// each request. These options are applied after the parent client's options (if\n// there is one), and before any request-specific options.\nfunc NewBetaSkillService(opts ...option.RequestOption) (r BetaSkillService) {\n\tr = BetaSkillService{}\n\tr.Options = opts\n\tr.Versions = NewBetaSkillVersionService(opts...)\n\treturn\n}\n\n// Create Skill\nfunc (r *BetaSkillService) New(ctx context.Context, params BetaSkillNewParams, opts ...option.RequestOption) (res *BetaSkillNewResponse, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\")}, opts...)\n\tpath := \"v1/skills?beta=true\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\n// Get Skill\nfunc (r *BetaSkillService) Get(ctx context.Context, skillID string, query BetaSkillGetParams, opts ...option.RequestOption) (res *BetaSkillGetResponse, err error) {\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\")}, opts...)\n\tif skillID == \"\" {\n\t\terr = errors.New(\"missing required skill_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/skills/%s?beta=true\", skillID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// List Skills\nfunc (r *BetaSkillService) List(ctx context.Context, params BetaSkillListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaSkillListResponse], err error) {\n\tvar raw *http.Response\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\"), option.WithResponseInto(&raw)}, opts...)\n\tpath := \"v1/skills?beta=true\"\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List Skills\nfunc (r *BetaSkillService) ListAutoPaging(ctx context.Context, params BetaSkillListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaSkillListResponse] {\n\treturn pagination.NewPageCursorAutoPager(r.List(ctx, params, opts...))\n}\n\n// Delete Skill\nfunc (r *BetaSkillService) Delete(ctx context.Context, skillID string, body BetaSkillDeleteParams, opts ...option.RequestOption) (res *BetaSkillDeleteResponse, err error) {\n\tfor _, v := range body.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\")}, opts...)\n\tif skillID == \"\" {\n\t\terr = errors.New(\"missing required skill_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/skills/%s?beta=true\", skillID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n\treturn res, err\n}\n\ntype BetaSkillNewResponse struct {\n\t// Unique identifier for the skill.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill was created.\n\tCreatedAt string `json:\"created_at\" api:\"required\"`\n\t// Display title for the skill.\n\t//\n\t// This is a human-readable label that is not included in the prompt sent to the\n\t// model.\n\tDisplayTitle string `json:\"display_title\" api:\"required\"`\n\t// The latest version identifier for the skill.\n\t//\n\t// This represents the most recent version of the skill that has been created.\n\tLatestVersion string `json:\"latest_version\" api:\"required\"`\n\t// Source of the skill.\n\t//\n\t// This may be one of the following values:\n\t//\n\t// - `\"custom\"`: the skill was created by a user\n\t// - `\"anthropic\"`: the skill was created by Anthropic\n\tSource string `json:\"source\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Skills, this is always `\"skill\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill was last updated.\n\tUpdatedAt string `json:\"updated_at\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID            respjson.Field\n\t\tCreatedAt     respjson.Field\n\t\tDisplayTitle  respjson.Field\n\t\tLatestVersion respjson.Field\n\t\tSource        respjson.Field\n\t\tType          respjson.Field\n\t\tUpdatedAt     respjson.Field\n\t\tExtraFields   map[string]respjson.Field\n\t\traw           string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillNewResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillNewResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillGetResponse struct {\n\t// Unique identifier for the skill.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill was created.\n\tCreatedAt string `json:\"created_at\" api:\"required\"`\n\t// Display title for the skill.\n\t//\n\t// This is a human-readable label that is not included in the prompt sent to the\n\t// model.\n\tDisplayTitle string `json:\"display_title\" api:\"required\"`\n\t// The latest version identifier for the skill.\n\t//\n\t// This represents the most recent version of the skill that has been created.\n\tLatestVersion string `json:\"latest_version\" api:\"required\"`\n\t// Source of the skill.\n\t//\n\t// This may be one of the following values:\n\t//\n\t// - `\"custom\"`: the skill was created by a user\n\t// - `\"anthropic\"`: the skill was created by Anthropic\n\tSource string `json:\"source\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Skills, this is always `\"skill\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill was last updated.\n\tUpdatedAt string `json:\"updated_at\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID            respjson.Field\n\t\tCreatedAt     respjson.Field\n\t\tDisplayTitle  respjson.Field\n\t\tLatestVersion respjson.Field\n\t\tSource        respjson.Field\n\t\tType          respjson.Field\n\t\tUpdatedAt     respjson.Field\n\t\tExtraFields   map[string]respjson.Field\n\t\traw           string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillGetResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillGetResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillListResponse struct {\n\t// Unique identifier for the skill.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill was created.\n\tCreatedAt string `json:\"created_at\" api:\"required\"`\n\t// Display title for the skill.\n\t//\n\t// This is a human-readable label that is not included in the prompt sent to the\n\t// model.\n\tDisplayTitle string `json:\"display_title\" api:\"required\"`\n\t// The latest version identifier for the skill.\n\t//\n\t// This represents the most recent version of the skill that has been created.\n\tLatestVersion string `json:\"latest_version\" api:\"required\"`\n\t// Source of the skill.\n\t//\n\t// This may be one of the following values:\n\t//\n\t// - `\"custom\"`: the skill was created by a user\n\t// - `\"anthropic\"`: the skill was created by Anthropic\n\tSource string `json:\"source\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Skills, this is always `\"skill\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill was last updated.\n\tUpdatedAt string `json:\"updated_at\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID            respjson.Field\n\t\tCreatedAt     respjson.Field\n\t\tDisplayTitle  respjson.Field\n\t\tLatestVersion respjson.Field\n\t\tSource        respjson.Field\n\t\tType          respjson.Field\n\t\tUpdatedAt     respjson.Field\n\t\tExtraFields   map[string]respjson.Field\n\t\traw           string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillListResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillListResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillDeleteResponse struct {\n\t// Unique identifier for the skill.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// Deleted object type.\n\t//\n\t// For Skills, this is always `\"skill_deleted\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillDeleteResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillDeleteResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillNewParams struct {\n\t// Display title for the skill.\n\t//\n\t// This is a human-readable label that is not included in the prompt sent to the\n\t// model.\n\tDisplayTitle param.Opt[string] `json:\"display_title,omitzero\"`\n\t// Files to upload for the skill.\n\t//\n\t// All files must be in the same top-level directory and must include a SKILL.md\n\t// file at the root of that directory.\n\tFiles []io.Reader `json:\"files,omitzero\" format:\"binary\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaSkillNewParams) MarshalMultipart() (data []byte, contentType string, err error) {\n\tbuf := bytes.NewBuffer(nil)\n\twriter := multipart.NewWriter(buf)\n\terr = apiform.MarshalRoot(r, writer)\n\tif err == nil {\n\t\terr = apiform.WriteExtras(writer, r.ExtraFields())\n\t}\n\tif err != nil {\n\t\twriter.Close()\n\t\treturn nil, \"\", err\n\t}\n\terr = writer.Close()\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\treturn buf.Bytes(), writer.FormDataContentType(), nil\n}\n\ntype BetaSkillGetParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaSkillListParams struct {\n\t// Pagination token for fetching a specific page of results.\n\t//\n\t// Pass the value from a previous response's `next_page` field to get the next page\n\t// of results.\n\tPage param.Opt[string] `query:\"page,omitzero\" json:\"-\"`\n\t// Filter skills by source.\n\t//\n\t// If provided, only skills from the specified source will be returned:\n\t//\n\t// - `\"custom\"`: only return user-created skills\n\t// - `\"anthropic\"`: only return Anthropic-created skills\n\tSource param.Opt[string] `query:\"source,omitzero\" json:\"-\"`\n\t// Number of results to return per page.\n\t//\n\t// Maximum value is 100. Defaults to 20.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [BetaSkillListParams]'s query parameters as `url.Values`.\nfunc (r BetaSkillListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n\ntype BetaSkillDeleteParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n"
  },
  {
    "path": "betaskill_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"io\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestBetaSkillNewWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.New(context.TODO(), anthropic.BetaSkillNewParams{\n\t\tDisplayTitle: anthropic.String(\"display_title\"),\n\t\tFiles:        []io.Reader{io.Reader(bytes.NewBuffer([]byte(\"Example data\")))},\n\t\tBetas:        []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaSkillGetWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.Get(\n\t\tcontext.TODO(),\n\t\t\"skill_id\",\n\t\tanthropic.BetaSkillGetParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaSkillListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.List(context.TODO(), anthropic.BetaSkillListParams{\n\t\tLimit:  anthropic.Int(0),\n\t\tPage:   anthropic.String(\"page\"),\n\t\tSource: anthropic.String(\"source\"),\n\t\tBetas:  []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaSkillDeleteWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.Delete(\n\t\tcontext.TODO(),\n\t\t\"skill_id\",\n\t\tanthropic.BetaSkillDeleteParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "betaskillversion.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiform\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n)\n\n// BetaSkillVersionService contains methods and other services that help with\n// interacting with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewBetaSkillVersionService] method instead.\ntype BetaSkillVersionService struct {\n\tOptions []option.RequestOption\n}\n\n// NewBetaSkillVersionService generates a new service that applies the given\n// options to each request. These options are applied after the parent client's\n// options (if there is one), and before any request-specific options.\nfunc NewBetaSkillVersionService(opts ...option.RequestOption) (r BetaSkillVersionService) {\n\tr = BetaSkillVersionService{}\n\tr.Options = opts\n\treturn\n}\n\n// Create Skill Version\nfunc (r *BetaSkillVersionService) New(ctx context.Context, skillID string, params BetaSkillVersionNewParams, opts ...option.RequestOption) (res *BetaSkillVersionNewResponse, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\")}, opts...)\n\tif skillID == \"\" {\n\t\terr = errors.New(\"missing required skill_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/skills/%s/versions?beta=true\", skillID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\n// Get Skill Version\nfunc (r *BetaSkillVersionService) Get(ctx context.Context, version string, params BetaSkillVersionGetParams, opts ...option.RequestOption) (res *BetaSkillVersionGetResponse, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\")}, opts...)\n\tif params.SkillID == \"\" {\n\t\terr = errors.New(\"missing required skill_id parameter\")\n\t\treturn nil, err\n\t}\n\tif version == \"\" {\n\t\terr = errors.New(\"missing required version parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/skills/%s/versions/%s?beta=true\", params.SkillID, version)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// List Skill Versions\nfunc (r *BetaSkillVersionService) List(ctx context.Context, skillID string, params BetaSkillVersionListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaSkillVersionListResponse], err error) {\n\tvar raw *http.Response\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\"), option.WithResponseInto(&raw)}, opts...)\n\tif skillID == \"\" {\n\t\terr = errors.New(\"missing required skill_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/skills/%s/versions?beta=true\", skillID)\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List Skill Versions\nfunc (r *BetaSkillVersionService) ListAutoPaging(ctx context.Context, skillID string, params BetaSkillVersionListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaSkillVersionListResponse] {\n\treturn pagination.NewPageCursorAutoPager(r.List(ctx, skillID, params, opts...))\n}\n\n// Delete Skill Version\nfunc (r *BetaSkillVersionService) Delete(ctx context.Context, version string, params BetaSkillVersionDeleteParams, opts ...option.RequestOption) (res *BetaSkillVersionDeleteResponse, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"anthropic-beta\", \"skills-2025-10-02\")}, opts...)\n\tif params.SkillID == \"\" {\n\t\terr = errors.New(\"missing required skill_id parameter\")\n\t\treturn nil, err\n\t}\n\tif version == \"\" {\n\t\terr = errors.New(\"missing required version parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/skills/%s/versions/%s?beta=true\", params.SkillID, version)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n\treturn res, err\n}\n\ntype BetaSkillVersionNewResponse struct {\n\t// Unique identifier for the skill version.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill version was created.\n\tCreatedAt string `json:\"created_at\" api:\"required\"`\n\t// Description of the skill version.\n\t//\n\t// This is extracted from the SKILL.md file in the skill upload.\n\tDescription string `json:\"description\" api:\"required\"`\n\t// Directory name of the skill version.\n\t//\n\t// This is the top-level directory name that was extracted from the uploaded files.\n\tDirectory string `json:\"directory\" api:\"required\"`\n\t// Human-readable name of the skill version.\n\t//\n\t// This is extracted from the SKILL.md file in the skill upload.\n\tName string `json:\"name\" api:\"required\"`\n\t// Identifier for the skill that this version belongs to.\n\tSkillID string `json:\"skill_id\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Skill Versions, this is always `\"skill_version\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// Version identifier for the skill.\n\t//\n\t// Each version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\").\n\tVersion string `json:\"version\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tCreatedAt   respjson.Field\n\t\tDescription respjson.Field\n\t\tDirectory   respjson.Field\n\t\tName        respjson.Field\n\t\tSkillID     respjson.Field\n\t\tType        respjson.Field\n\t\tVersion     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillVersionNewResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillVersionNewResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillVersionGetResponse struct {\n\t// Unique identifier for the skill version.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill version was created.\n\tCreatedAt string `json:\"created_at\" api:\"required\"`\n\t// Description of the skill version.\n\t//\n\t// This is extracted from the SKILL.md file in the skill upload.\n\tDescription string `json:\"description\" api:\"required\"`\n\t// Directory name of the skill version.\n\t//\n\t// This is the top-level directory name that was extracted from the uploaded files.\n\tDirectory string `json:\"directory\" api:\"required\"`\n\t// Human-readable name of the skill version.\n\t//\n\t// This is extracted from the SKILL.md file in the skill upload.\n\tName string `json:\"name\" api:\"required\"`\n\t// Identifier for the skill that this version belongs to.\n\tSkillID string `json:\"skill_id\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Skill Versions, this is always `\"skill_version\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// Version identifier for the skill.\n\t//\n\t// Each version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\").\n\tVersion string `json:\"version\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tCreatedAt   respjson.Field\n\t\tDescription respjson.Field\n\t\tDirectory   respjson.Field\n\t\tName        respjson.Field\n\t\tSkillID     respjson.Field\n\t\tType        respjson.Field\n\t\tVersion     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillVersionGetResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillVersionGetResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillVersionListResponse struct {\n\t// Unique identifier for the skill version.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// ISO 8601 timestamp of when the skill version was created.\n\tCreatedAt string `json:\"created_at\" api:\"required\"`\n\t// Description of the skill version.\n\t//\n\t// This is extracted from the SKILL.md file in the skill upload.\n\tDescription string `json:\"description\" api:\"required\"`\n\t// Directory name of the skill version.\n\t//\n\t// This is the top-level directory name that was extracted from the uploaded files.\n\tDirectory string `json:\"directory\" api:\"required\"`\n\t// Human-readable name of the skill version.\n\t//\n\t// This is extracted from the SKILL.md file in the skill upload.\n\tName string `json:\"name\" api:\"required\"`\n\t// Identifier for the skill that this version belongs to.\n\tSkillID string `json:\"skill_id\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Skill Versions, this is always `\"skill_version\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// Version identifier for the skill.\n\t//\n\t// Each version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\").\n\tVersion string `json:\"version\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tCreatedAt   respjson.Field\n\t\tDescription respjson.Field\n\t\tDirectory   respjson.Field\n\t\tName        respjson.Field\n\t\tSkillID     respjson.Field\n\t\tType        respjson.Field\n\t\tVersion     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillVersionListResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillVersionListResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillVersionDeleteResponse struct {\n\t// Version identifier for the skill.\n\t//\n\t// Each version is identified by a Unix epoch timestamp (e.g., \"1759178010641129\").\n\tID string `json:\"id\" api:\"required\"`\n\t// Deleted object type.\n\t//\n\t// For Skill Versions, this is always `\"skill_version_deleted\"`.\n\tType string `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BetaSkillVersionDeleteResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *BetaSkillVersionDeleteResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BetaSkillVersionNewParams struct {\n\t// Files to upload for the skill.\n\t//\n\t// All files must be in the same top-level directory and must include a SKILL.md\n\t// file at the root of that directory.\n\tFiles []io.Reader `json:\"files,omitzero\" format:\"binary\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r BetaSkillVersionNewParams) MarshalMultipart() (data []byte, contentType string, err error) {\n\tbuf := bytes.NewBuffer(nil)\n\twriter := multipart.NewWriter(buf)\n\terr = apiform.MarshalRoot(r, writer)\n\tif err == nil {\n\t\terr = apiform.WriteExtras(writer, r.ExtraFields())\n\t}\n\tif err != nil {\n\t\twriter.Close()\n\t\treturn nil, \"\", err\n\t}\n\terr = writer.Close()\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\treturn buf.Bytes(), writer.FormDataContentType(), nil\n}\n\ntype BetaSkillVersionGetParams struct {\n\t// Unique identifier for the skill.\n\t//\n\t// The format and length of IDs may change over time.\n\tSkillID string `path:\"skill_id\" api:\"required\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype BetaSkillVersionListParams struct {\n\t// Number of items to return per page.\n\t//\n\t// Defaults to `20`. Ranges from `1` to `1000`.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\t// Optionally set to the `next_page` token from the previous response.\n\tPage param.Opt[string] `query:\"page,omitzero\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [BetaSkillVersionListParams]'s query parameters as\n// `url.Values`.\nfunc (r BetaSkillVersionListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n\ntype BetaSkillVersionDeleteParams struct {\n\t// Unique identifier for the skill.\n\t//\n\t// The format and length of IDs may change over time.\n\tSkillID string `path:\"skill_id\" api:\"required\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n"
  },
  {
    "path": "betaskillversion_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"io\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestBetaSkillVersionNewWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.Versions.New(\n\t\tcontext.TODO(),\n\t\t\"skill_id\",\n\t\tanthropic.BetaSkillVersionNewParams{\n\t\t\tFiles: []io.Reader{io.Reader(bytes.NewBuffer([]byte(\"Example data\")))},\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaSkillVersionGetWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.Versions.Get(\n\t\tcontext.TODO(),\n\t\t\"version\",\n\t\tanthropic.BetaSkillVersionGetParams{\n\t\t\tSkillID: \"skill_id\",\n\t\t\tBetas:   []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaSkillVersionListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.Versions.List(\n\t\tcontext.TODO(),\n\t\t\"skill_id\",\n\t\tanthropic.BetaSkillVersionListParams{\n\t\t\tLimit: anthropic.Int(0),\n\t\t\tPage:  anthropic.String(\"page\"),\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestBetaSkillVersionDeleteWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Beta.Skills.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t\"version\",\n\t\tanthropic.BetaSkillVersionDeleteParams{\n\t\t\tSkillID: \"skill_id\",\n\t\t\tBetas:   []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "betatoolrunner.go",
    "content": "package anthropic\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"iter\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"golang.org/x/sync/errgroup\"\n)\n\n// BetaTool represents a tool that can be executed by the BetaToolRunner.\ntype BetaTool interface {\n\t// Name returns the tool's name\n\tName() string\n\t// Description returns the tool's description\n\tDescription() string\n\t// InputSchema returns the JSON schema for the tool's input\n\tInputSchema() BetaToolInputSchemaParam\n\t// Execute runs the tool with raw JSON input and returns the result\n\tExecute(ctx context.Context, input json.RawMessage) (BetaToolResultBlockParamContentUnion, error)\n}\n\n// BetaToolRunnerParams contains parameters for creating a BetaToolRunner or BetaToolRunnerStreaming.\ntype BetaToolRunnerParams struct {\n\tBetaMessageNewParams\n\t// MaxIterations limits the number of API calls. When set to 0 (the default),\n\t// there is no limit and the runner continues until the model stops using tools.\n\tMaxIterations int\n}\n\n// betaToolRunnerBase holds state and logic shared by BetaToolRunner and BetaToolRunnerStreaming.\ntype betaToolRunnerBase struct {\n\tmessageService *BetaMessageService\n\t// Params contains the configuration for the tool runner.\n\t// This field is exported so users can modify parameters directly.\n\tParams         BetaToolRunnerParams\n\ttoolMap        map[string]BetaTool\n\titerationCount int\n\tlastMessage    *BetaMessage\n\tcompleted      bool\n\topts           []option.RequestOption\n\terr            error\n}\n\nfunc newBetaToolRunnerBase(messageService *BetaMessageService, tools []BetaTool, params BetaToolRunnerParams, opts []option.RequestOption) betaToolRunnerBase {\n\ttoolMap := make(map[string]BetaTool)\n\tapiTools := make([]BetaToolUnionParam, len(tools))\n\n\tfor i, tool := range tools {\n\t\ttoolMap[tool.Name()] = tool\n\t\tapiTools[i] = BetaToolUnionParam{\n\t\t\tOfTool: &BetaToolParam{\n\t\t\t\tName:        tool.Name(),\n\t\t\t\tDescription: String(tool.Description()),\n\t\t\t\tInputSchema: tool.InputSchema(),\n\t\t\t},\n\t\t}\n\t}\n\n\t// Add tools to the API params\n\tparams.BetaMessageNewParams.Tools = apiTools\n\tparams.Messages = append([]BetaMessageParam{}, params.Messages...)\n\n\treturn betaToolRunnerBase{\n\t\tmessageService: messageService,\n\t\tParams:         params,\n\t\ttoolMap:        toolMap,\n\t\topts:           opts,\n\t}\n}\n\n// LastMessage returns the most recent assistant message, or nil if no messages have been received yet.\nfunc (b *betaToolRunnerBase) LastMessage() *BetaMessage {\n\treturn b.lastMessage\n}\n\n// AppendMessages adds messages to the conversation history.\n// This is a convenience method equivalent to:\n//\n//\trunner.Params.Messages = append(runner.Params.Messages, messages...)\nfunc (b *betaToolRunnerBase) AppendMessages(messages ...BetaMessageParam) {\n\tb.Params.Messages = append(b.Params.Messages, messages...)\n}\n\n// Messages returns a copy of the current conversation history.\n// The returned slice can be safely modified without affecting the runner's state.\nfunc (b *betaToolRunnerBase) Messages() []BetaMessageParam {\n\tresult := make([]BetaMessageParam, len(b.Params.Messages))\n\tcopy(result, b.Params.Messages)\n\treturn result\n}\n\n// IterationCount returns the number of API calls made so far.\n// This is incremented each time a turn makes an API call.\nfunc (b *betaToolRunnerBase) IterationCount() int {\n\treturn b.iterationCount\n}\n\n// IsCompleted returns true if the conversation has finished, either because\n// the model stopped using tools or the maximum iteration limit was reached.\nfunc (b *betaToolRunnerBase) IsCompleted() bool {\n\treturn b.completed\n}\n\n// Err returns the last error that occurred during iteration, if any.\n// This is useful when using All() or AllStreaming() to check for errors\n// after the iteration completes.\nfunc (b *betaToolRunnerBase) Err() error {\n\treturn b.err\n}\n\n// executeTools processes any tool use blocks in the given message and returns a tool result message.\n// Returns:\n//   - (result, nil) if tools executed successfully\n//   - (nil, nil) if no tools to execute\n//   - (nil, ctx.Err()) if context was cancelled\nfunc (b *betaToolRunnerBase) executeTools(ctx context.Context, message *BetaMessage) (*BetaMessageParam, error) {\n\tvar toolUseBlocks []BetaToolUseBlock\n\n\t// Find all tool use blocks in the message\n\tfor _, block := range message.Content {\n\t\tif block.Type == \"tool_use\" {\n\t\t\ttoolUseBlocks = append(toolUseBlocks, block.AsToolUse())\n\t\t}\n\t}\n\n\tif len(toolUseBlocks) == 0 {\n\t\treturn nil, nil\n\t}\n\n\t// Execute all tools in parallel using errgroup for proper cancellation handling\n\tresults := make([]BetaContentBlockParamUnion, len(toolUseBlocks))\n\n\tg, gctx := errgroup.WithContext(ctx)\n\tfor i, toolUse := range toolUseBlocks {\n\t\tg.Go(func() error {\n\t\t\t// Check for cancellation before executing tool\n\t\t\tselect {\n\t\t\tcase <-gctx.Done():\n\t\t\t\treturn gctx.Err()\n\t\t\tdefault:\n\t\t\t}\n\t\t\tresult := b.executeToolUse(gctx, toolUse)\n\t\t\tresults[i] = BetaContentBlockParamUnion{OfToolResult: &result}\n\t\t\treturn nil // tool errors become result content, not Go errors\n\t\t})\n\t}\n\n\tif err := g.Wait(); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create user message with tool results\n\tuserMessage := NewBetaUserMessage(results...)\n\treturn &userMessage, nil\n}\n\nfunc newBetaToolResultErrorBlockParam(toolUseID string, errorText string) BetaToolResultBlockParam {\n\treturn NewBetaToolResultTextBlockParam(toolUseID, errorText, true)\n}\n\n// executeToolUse executes a single tool use block and returns the result.\nfunc (b *betaToolRunnerBase) executeToolUse(ctx context.Context, toolUse BetaToolUseBlock) BetaToolResultBlockParam {\n\ttool, exists := b.toolMap[toolUse.Name]\n\tif !exists {\n\t\treturn newBetaToolResultErrorBlockParam(\n\t\t\ttoolUse.ID,\n\t\t\tfmt.Sprintf(\"Error: Tool '%s' not found\", toolUse.Name),\n\t\t)\n\t}\n\n\t// Parse and execute the tool\n\tinputBytes, err := json.Marshal(toolUse.Input)\n\tif err != nil {\n\t\treturn newBetaToolResultErrorBlockParam(\n\t\t\ttoolUse.ID,\n\t\t\tfmt.Sprintf(\"Error: Failed to marshal tool input: %v\", err),\n\t\t)\n\t}\n\n\tresult, err := tool.Execute(ctx, inputBytes)\n\tif err != nil {\n\t\treturn newBetaToolResultErrorBlockParam(\n\t\t\ttoolUse.ID,\n\t\t\tfmt.Sprintf(\"Error: %v\", err),\n\t\t)\n\t}\n\n\treturn BetaToolResultBlockParam{\n\t\tToolUseID: toolUse.ID,\n\t\tContent:   []BetaToolResultBlockParamContentUnion{result},\n\t}\n}\n\n// BetaToolRunner manages the automatic conversation loop between the assistant and tools\n// using non-streaming API calls. It implements an iterator pattern for processing\n// conversation turns.\n//\n// A BetaToolRunner is NOT safe for concurrent use. All methods must be called\n// from a single goroutine. However, tool handlers ARE called concurrently\n// when multiple tools are invoked in a single turn - ensure your handlers\n// are thread-safe.\ntype BetaToolRunner struct {\n\tbetaToolRunnerBase\n}\n\n// NewToolRunner creates a BetaToolRunner that automatically handles the loop between\n// the model generating tool calls, executing those tool calls, and sending the\n// results back to the model until a final answer is produced or the maximum\n// number of iterations is reached.\nfunc (r *BetaMessageService) NewToolRunner(tools []BetaTool, params BetaToolRunnerParams, opts ...option.RequestOption) *BetaToolRunner {\n\treturn &BetaToolRunner{\n\t\tbetaToolRunnerBase: newBetaToolRunnerBase(r, tools, params, opts),\n\t}\n}\n\n// NextMessage advances the conversation by one turn. It executes any pending tool calls\n// from the previous message, then makes an API call to get the model's next response.\n//\n// Returns:\n//   - (message, nil) on success with the assistant's response\n//   - (nil, nil) when the conversation is complete (no more tool calls or max iterations reached)\n//   - (nil, error) if an error occurred during tool execution or API call\nfunc (r *BetaToolRunner) NextMessage(ctx context.Context) (*BetaMessage, error) {\n\tif r.completed {\n\t\treturn nil, nil\n\t}\n\n\t// Check iteration limit\n\tif r.Params.MaxIterations > 0 && r.iterationCount >= r.Params.MaxIterations {\n\t\tr.completed = true\n\t\treturn r.lastMessage, nil\n\t}\n\n\t// Execute any pending tool calls from the last message\n\tif r.lastMessage != nil {\n\t\ttoolMessage, err := r.executeTools(ctx, r.lastMessage)\n\t\tif err != nil {\n\t\t\tr.err = err\n\t\t\treturn nil, err\n\t\t}\n\t\tif toolMessage == nil {\n\t\t\t// No tools to execute, conversation is complete\n\t\t\tr.completed = true\n\t\t\treturn r.lastMessage, nil\n\t\t}\n\t\tr.Params.Messages = append(r.Params.Messages, *toolMessage)\n\t}\n\n\t// Make API call\n\tr.iterationCount++\n\tmessageParams := r.Params.BetaMessageNewParams\n\tmessageParams.Messages = r.Params.Messages\n\n\tmessage, err := r.messageService.New(ctx, messageParams, r.opts...)\n\tif err != nil {\n\t\tr.err = err\n\t\treturn nil, fmt.Errorf(\"failed to get next message: %w\", err)\n\t}\n\n\tr.lastMessage = message\n\tr.Params.Messages = append(r.Params.Messages, message.ToParam())\n\n\treturn message, nil\n}\n\n// RunToCompletion repeatedly calls NextMessage until the conversation is complete,\n// either because the model stopped using tools or the maximum iteration limit was reached.\n//\n// Returns the final assistant message and any error that occurred.\nfunc (r *BetaToolRunner) RunToCompletion(ctx context.Context) (*BetaMessage, error) {\n\tfor {\n\t\tmessage, err := r.NextMessage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif message == nil {\n\t\t\treturn r.lastMessage, nil\n\t\t}\n\t}\n}\n\n// All returns an iterator that yields all messages until the conversation completes.\n// This is a convenience method for iterating over the entire conversation.\n//\n// Example usage:\n//\n//\tfor message, err := range runner.All(ctx) {\n//\t    if err != nil {\n//\t        return err\n//\t    }\n//\t    // process message\n//\t}\nfunc (r *BetaToolRunner) All(ctx context.Context) iter.Seq2[*BetaMessage, error] {\n\treturn func(yield func(*BetaMessage, error) bool) {\n\t\tfor {\n\t\t\tmessage, err := r.NextMessage(ctx)\n\t\t\tr.err = err\n\t\t\tif message == nil {\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif !yield(message, err) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n\n// BetaToolRunnerStreaming manages the automatic conversation loop between the assistant\n// and tools using streaming API calls. It implements an iterator pattern for processing\n// streaming events across conversation turns.\n//\n// A BetaToolRunnerStreaming is NOT safe for concurrent use. All methods must be called\n// from a single goroutine. However, tool handlers ARE called concurrently\n// when multiple tools are invoked in a single turn - ensure your handlers\n// are thread-safe.\ntype BetaToolRunnerStreaming struct {\n\tbetaToolRunnerBase\n}\n\n// NewToolRunnerStreaming creates a BetaToolRunnerStreaming that automatically handles\n// the loop between the model generating tool calls, executing those tool calls, and\n// sending the results back to the model using streaming API calls until a final answer\n// is produced or the maximum number of iterations is reached.\nfunc (r *BetaMessageService) NewToolRunnerStreaming(tools []BetaTool, params BetaToolRunnerParams, opts ...option.RequestOption) *BetaToolRunnerStreaming {\n\treturn &BetaToolRunnerStreaming{\n\t\tbetaToolRunnerBase: newBetaToolRunnerBase(r, tools, params, opts),\n\t}\n}\n\n// NextStreaming advances the conversation by one turn with streaming. It executes any\n// pending tool calls from the previous message, then makes a streaming API call.\n//\n// Returns an iterator that yields streaming events as they arrive. The iterator should\n// be fully consumed to ensure the message is properly accumulated for subsequent turns.\n//\n// If an error occurs, it will be yielded as the second value in the iterator pair.\n// Check IsCompleted() after consuming the iterator to determine if the conversation\n// has finished.\nfunc (r *BetaToolRunnerStreaming) NextStreaming(ctx context.Context) iter.Seq2[BetaRawMessageStreamEventUnion, error] {\n\treturn func(yield func(BetaRawMessageStreamEventUnion, error) bool) {\n\t\tif r.completed {\n\t\t\treturn\n\t\t}\n\n\t\t// Check iteration limit\n\t\tif r.Params.MaxIterations > 0 && r.iterationCount >= r.Params.MaxIterations {\n\t\t\tr.completed = true\n\t\t\treturn\n\t\t}\n\n\t\t// Execute any pending tool calls from the last message\n\t\tif r.lastMessage != nil {\n\t\t\ttoolMessage, err := r.executeTools(ctx, r.lastMessage)\n\t\t\tif err != nil {\n\t\t\t\tr.err = err\n\t\t\t\tyield(BetaRawMessageStreamEventUnion{}, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif toolMessage == nil {\n\t\t\t\t// No tools to execute, conversation is complete\n\t\t\t\tr.completed = true\n\t\t\t\treturn\n\t\t\t}\n\t\t\tr.Params.Messages = append(r.Params.Messages, *toolMessage)\n\t\t}\n\n\t\t// Make streaming API call\n\t\tr.iterationCount++\n\t\tstreamParams := r.Params.BetaMessageNewParams\n\t\tstreamParams.Messages = r.Params.Messages\n\n\t\tstream := r.messageService.NewStreaming(ctx, streamParams, r.opts...)\n\t\tdefer stream.Close()\n\n\t\t// We need to collect the final message from the stream for the next iteration\n\t\tfinalMessage := &BetaMessage{}\n\t\tfor stream.Next() {\n\t\t\tevent := stream.Current()\n\t\t\terr := finalMessage.Accumulate(event)\n\t\t\tif err != nil {\n\t\t\t\tr.err = fmt.Errorf(\"failed to accumulate streaming event: %w\", err)\n\t\t\t\tyield(BetaRawMessageStreamEventUnion{}, r.err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif !yield(event, nil) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Check for stream errors after the loop exits\n\t\tif stream.Err() != nil {\n\t\t\tr.err = stream.Err()\n\t\t\tyield(BetaRawMessageStreamEventUnion{}, r.err)\n\t\t\treturn\n\t\t}\n\n\t\tr.lastMessage = finalMessage\n\t\tr.Params.Messages = append(r.Params.Messages, finalMessage.ToParam())\n\t}\n}\n\n// AllStreaming returns an iterator of iterators, where each inner iterator yields\n// streaming events for a single turn of the conversation. The outer iterator continues\n// until the conversation completes.\n//\n// Example usage:\n//\n//\tfor events, err := range runner.AllStreaming(ctx) {\n//\t    if err != nil {\n//\t        return err\n//\t    }\n//\t    for event, err := range events {\n//\t        if err != nil {\n//\t            return err\n//\t        }\n//\t        // process streaming event\n//\t    }\n//\t}\nfunc (r *BetaToolRunnerStreaming) AllStreaming(ctx context.Context) iter.Seq2[iter.Seq2[BetaRawMessageStreamEventUnion, error], error] {\n\treturn func(yield func(iter.Seq2[BetaRawMessageStreamEventUnion, error], error) bool) {\n\t\tfor !r.completed {\n\t\t\teventSeq := r.NextStreaming(ctx)\n\t\t\tif !yield(eventSeq, nil) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "client.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// Client creates a struct with services and top level methods that help with\n// interacting with the anthropic API. You should not instantiate this client\n// directly, and instead use the [NewClient] method instead.\ntype Client struct {\n\tOptions     []option.RequestOption\n\tCompletions CompletionService\n\tMessages    MessageService\n\tModels      ModelService\n\tBeta        BetaService\n}\n\n// DefaultClientOptions read from the environment (ANTHROPIC_API_KEY,\n// ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL). This should be used to initialize new\n// clients.\nfunc DefaultClientOptions() []option.RequestOption {\n\tdefaults := []option.RequestOption{option.WithEnvironmentProduction()}\n\tif o, ok := os.LookupEnv(\"ANTHROPIC_BASE_URL\"); ok {\n\t\tdefaults = append(defaults, option.WithBaseURL(o))\n\t}\n\tif o, ok := os.LookupEnv(\"ANTHROPIC_API_KEY\"); ok {\n\t\tdefaults = append(defaults, option.WithAPIKey(o))\n\t}\n\tif o, ok := os.LookupEnv(\"ANTHROPIC_AUTH_TOKEN\"); ok {\n\t\tdefaults = append(defaults, option.WithAuthToken(o))\n\t}\n\treturn defaults\n}\n\n// NewClient generates a new client with the default option read from the\n// environment (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL). The\n// option passed in as arguments are applied after these default arguments, and all\n// option will be passed down to the services and requests that this client makes.\nfunc NewClient(opts ...option.RequestOption) (r Client) {\n\topts = append(DefaultClientOptions(), opts...)\n\n\tr = Client{Options: opts}\n\n\tr.Completions = NewCompletionService(opts...)\n\tr.Messages = NewMessageService(opts...)\n\tr.Models = NewModelService(opts...)\n\tr.Beta = NewBetaService(opts...)\n\n\treturn\n}\n\n// Execute makes a request with the given context, method, URL, request params,\n// response, and request options. This is useful for hitting undocumented endpoints\n// while retaining the base URL, auth, retries, and other options from the client.\n//\n// If a byte slice or an [io.Reader] is supplied to params, it will be used as-is\n// for the request body.\n//\n// The params is by default serialized into the body using [encoding/json]. If your\n// type implements a MarshalJSON function, it will be used instead to serialize the\n// request. If a URLQuery method is implemented, the returned [url.Values] will be\n// used as query strings to the url.\n//\n// If your params struct uses [param.Field], you must provide either [MarshalJSON],\n// [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a\n// struct uses [param.Field] without specifying how it is serialized.\n//\n// Any \"…Params\" object defined in this library can be used as the request\n// argument. Note that 'path' arguments will not be forwarded into the url.\n//\n// The response body will be deserialized into the res variable, depending on its\n// type:\n//\n//   - A pointer to a [*http.Response] is populated by the raw response.\n//   - A pointer to a byte array will be populated with the contents of the request\n//     body.\n//   - A pointer to any other type uses this library's default JSON decoding, which\n//     respects UnmarshalJSON if it is defined on the type.\n//   - A nil value will not read the response body.\n//\n// For even greater flexibility, see [option.WithResponseInto] and\n// [option.WithResponseBodyInto].\nfunc (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error {\n\topts = slices.Concat(r.Options, opts)\n\treturn requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...)\n}\n\n// Get makes a GET request with the given URL, params, and optionally deserializes\n// to a response. See [Execute] documentation on the params and response.\nfunc (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error {\n\treturn r.Execute(ctx, http.MethodGet, path, params, res, opts...)\n}\n\n// Post makes a POST request with the given URL, params, and optionally\n// deserializes to a response. See [Execute] documentation on the params and\n// response.\nfunc (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error {\n\treturn r.Execute(ctx, http.MethodPost, path, params, res, opts...)\n}\n\n// Put makes a PUT request with the given URL, params, and optionally deserializes\n// to a response. See [Execute] documentation on the params and response.\nfunc (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error {\n\treturn r.Execute(ctx, http.MethodPut, path, params, res, opts...)\n}\n\n// Patch makes a PATCH request with the given URL, params, and optionally\n// deserializes to a response. See [Execute] documentation on the params and\n// response.\nfunc (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error {\n\treturn r.Execute(ctx, http.MethodPatch, path, params, res, opts...)\n}\n\n// Delete makes a DELETE request with the given URL, params, and optionally\n// deserializes to a response. See [Execute] documentation on the params and\n// response.\nfunc (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error {\n\treturn r.Execute(ctx, http.MethodDelete, path, params, res, opts...)\n}\n\n// CalculateNonStreamingTimeout calculates the appropriate timeout for a non-streaming request\n// based on the maximum number of tokens and the model's non-streaming token limit\nfunc CalculateNonStreamingTimeout(maxTokens int, model Model, opts []option.RequestOption) (time.Duration, error) {\n\tpreCfg, err := requestconfig.PreRequestOptions(opts...)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"error applying request options: %w\", err)\n\t}\n\t// if the user has set a specific request timeout, use that\n\tif preCfg.RequestTimeout != 0 {\n\t\treturn preCfg.RequestTimeout, nil\n\t}\n\n\tmaximumTime := time.Hour // 1 hour\n\tdefaultTime := 10 * time.Minute\n\n\texpectedTime := time.Duration(float64(maximumTime) * float64(maxTokens) / 128000.0)\n\n\t// If the model has a non-streaming token limit and max_tokens exceeds it,\n\t// or if the expected time exceeds default time, require streaming\n\tmaxNonStreamingTokens, hasLimit := constant.ModelNonStreamingTokens[string(model)]\n\tif expectedTime > defaultTime || (hasLimit && maxTokens > maxNonStreamingTokens) {\n\t\treturn 0, fmt.Errorf(\"streaming is required for operations that may take longer than 10 minutes\")\n\t}\n\n\treturn defaultTime, nil\n}\n"
  },
  {
    "path": "client_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"reflect\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\ntype closureTransport struct {\n\tfn func(req *http.Request) (*http.Response, error)\n}\n\nfunc (t *closureTransport) RoundTrip(req *http.Request) (*http.Response, error) {\n\treturn t.fn(req)\n}\n\nfunc TestUserAgentHeader(t *testing.T) {\n\tvar userAgent string\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\tuserAgent = req.Header.Get(\"User-Agent\")\n\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\tStatusCode: http.StatusOK,\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t)\n\t_, _ = client.Messages.New(context.Background(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif userAgent != fmt.Sprintf(\"Anthropic/Go %s\", internal.PackageVersion) {\n\t\tt.Errorf(\"Expected User-Agent to be correct, but got: %#v\", userAgent)\n\t}\n}\n\nfunc TestRetryAfter(t *testing.T) {\n\tretryCountHeaders := make([]string, 0)\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\tretryCountHeaders = append(retryCountHeaders, req.Header.Get(\"X-Stainless-Retry-Count\"))\n\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\tStatusCode: http.StatusTooManyRequests,\n\t\t\t\t\t\tHeader: http.Header{\n\t\t\t\t\t\t\thttp.CanonicalHeaderKey(\"Retry-After\"): []string{\"0.1\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t)\n\t_, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err == nil {\n\t\tt.Error(\"Expected there to be a cancel error\")\n\t}\n\n\tattempts := len(retryCountHeaders)\n\tif attempts != 3 {\n\t\tt.Errorf(\"Expected %d attempts, got %d\", 3, attempts)\n\t}\n\n\texpectedRetryCountHeaders := []string{\"0\", \"1\", \"2\"}\n\tif !reflect.DeepEqual(retryCountHeaders, expectedRetryCountHeaders) {\n\t\tt.Errorf(\"Expected %v retry count headers, got %v\", expectedRetryCountHeaders, retryCountHeaders)\n\t}\n}\n\nfunc TestDeleteRetryCountHeader(t *testing.T) {\n\tretryCountHeaders := make([]string, 0)\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\tretryCountHeaders = append(retryCountHeaders, req.Header.Get(\"X-Stainless-Retry-Count\"))\n\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\tStatusCode: http.StatusTooManyRequests,\n\t\t\t\t\t\tHeader: http.Header{\n\t\t\t\t\t\t\thttp.CanonicalHeaderKey(\"Retry-After\"): []string{\"0.1\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t\toption.WithHeaderDel(\"X-Stainless-Retry-Count\"),\n\t)\n\t_, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err == nil {\n\t\tt.Error(\"Expected there to be a cancel error\")\n\t}\n\n\texpectedRetryCountHeaders := []string{\"\", \"\", \"\"}\n\tif !reflect.DeepEqual(retryCountHeaders, expectedRetryCountHeaders) {\n\t\tt.Errorf(\"Expected %v retry count headers, got %v\", expectedRetryCountHeaders, retryCountHeaders)\n\t}\n}\n\nfunc TestOverwriteRetryCountHeader(t *testing.T) {\n\tretryCountHeaders := make([]string, 0)\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\tretryCountHeaders = append(retryCountHeaders, req.Header.Get(\"X-Stainless-Retry-Count\"))\n\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\tStatusCode: http.StatusTooManyRequests,\n\t\t\t\t\t\tHeader: http.Header{\n\t\t\t\t\t\t\thttp.CanonicalHeaderKey(\"Retry-After\"): []string{\"0.1\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t\toption.WithHeader(\"X-Stainless-Retry-Count\", \"42\"),\n\t)\n\t_, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err == nil {\n\t\tt.Error(\"Expected there to be a cancel error\")\n\t}\n\n\texpectedRetryCountHeaders := []string{\"42\", \"42\", \"42\"}\n\tif !reflect.DeepEqual(retryCountHeaders, expectedRetryCountHeaders) {\n\t\tt.Errorf(\"Expected %v retry count headers, got %v\", expectedRetryCountHeaders, retryCountHeaders)\n\t}\n}\n\nfunc TestRetryAfterMs(t *testing.T) {\n\tattempts := 0\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\tattempts++\n\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\tStatusCode: http.StatusTooManyRequests,\n\t\t\t\t\t\tHeader: http.Header{\n\t\t\t\t\t\t\thttp.CanonicalHeaderKey(\"Retry-After-Ms\"): []string{\"100\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t}, nil\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t)\n\t_, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err == nil {\n\t\tt.Error(\"Expected there to be a cancel error\")\n\t}\n\tif want := 3; attempts != want {\n\t\tt.Errorf(\"Expected %d attempts, got %d\", want, attempts)\n\t}\n}\n\nfunc TestContextCancel(t *testing.T) {\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\t<-req.Context().Done()\n\t\t\t\t\treturn nil, req.Context().Err()\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t)\n\tcancelCtx, cancel := context.WithCancel(context.Background())\n\tcancel()\n\t_, err := client.Messages.New(cancelCtx, anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err == nil {\n\t\tt.Error(\"Expected there to be a cancel error\")\n\t}\n}\n\nfunc TestContextCancelDelay(t *testing.T) {\n\tclient := anthropic.NewClient(\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\toption.WithHTTPClient(&http.Client{\n\t\t\tTransport: &closureTransport{\n\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\t<-req.Context().Done()\n\t\t\t\t\treturn nil, req.Context().Err()\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t)\n\tcancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)\n\tdefer cancel()\n\t_, err := client.Messages.New(cancelCtx, anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err == nil {\n\t\tt.Error(\"expected there to be a cancel error\")\n\t}\n}\n\nfunc TestContextDeadline(t *testing.T) {\n\ttestTimeout := time.After(3 * time.Second)\n\ttestDone := make(chan struct{})\n\n\tdeadline := time.Now().Add(100 * time.Millisecond)\n\tdeadlineCtx, cancel := context.WithDeadline(context.Background(), deadline)\n\tdefer cancel()\n\n\tgo func() {\n\t\tclient := anthropic.NewClient(\n\t\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\t\toption.WithHTTPClient(&http.Client{\n\t\t\t\tTransport: &closureTransport{\n\t\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\t\t<-req.Context().Done()\n\t\t\t\t\t\treturn nil, req.Context().Err()\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t)\n\t\t_, err := client.Messages.New(deadlineCtx, anthropic.MessageNewParams{\n\t\t\tMaxTokens: 1024,\n\t\t\tMessages: []anthropic.MessageParam{{\n\t\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\t\tText: \"x\",\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t\t}},\n\t\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t\t})\n\t\tif err == nil {\n\t\t\tt.Error(\"expected there to be a deadline error\")\n\t\t}\n\t\tclose(testDone)\n\t}()\n\n\tselect {\n\tcase <-testTimeout:\n\t\tt.Fatal(\"client didn't finish in time\")\n\tcase <-testDone:\n\t\tif diff := time.Since(deadline); diff < -30*time.Millisecond || 30*time.Millisecond < diff {\n\t\t\tt.Fatalf(\"client did not return within 30ms of context deadline, got %s\", diff)\n\t\t}\n\t}\n}\n\nfunc TestContextDeadlineStreaming(t *testing.T) {\n\ttestTimeout := time.After(3 * time.Second)\n\ttestDone := make(chan struct{})\n\n\tdeadline := time.Now().Add(100 * time.Millisecond)\n\tdeadlineCtx, cancel := context.WithDeadline(context.Background(), deadline)\n\tdefer cancel()\n\n\tgo func() {\n\t\tclient := anthropic.NewClient(\n\t\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\t\toption.WithHTTPClient(&http.Client{\n\t\t\t\tTransport: &closureTransport{\n\t\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\t\tStatusCode: 200,\n\t\t\t\t\t\t\tStatus:     \"200 OK\",\n\t\t\t\t\t\t\tBody: io.NopCloser(\n\t\t\t\t\t\t\t\tio.Reader(readerFunc(func([]byte) (int, error) {\n\t\t\t\t\t\t\t\t\t<-req.Context().Done()\n\t\t\t\t\t\t\t\t\treturn 0, req.Context().Err()\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}, nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t)\n\t\tstream := client.Messages.NewStreaming(deadlineCtx, anthropic.MessageNewParams{\n\t\t\tMaxTokens: 1024,\n\t\t\tMessages: []anthropic.MessageParam{{\n\t\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\t\tText: \"x\",\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t\t}},\n\t\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\t})\n\t\tfor stream.Next() {\n\t\t\t_ = stream.Current()\n\t\t}\n\t\tif stream.Err() == nil {\n\t\t\tt.Error(\"expected there to be a deadline error\")\n\t\t}\n\t\tclose(testDone)\n\t}()\n\n\tselect {\n\tcase <-testTimeout:\n\t\tt.Fatal(\"client didn't finish in time\")\n\tcase <-testDone:\n\t\tif diff := time.Since(deadline); diff < -30*time.Millisecond || 30*time.Millisecond < diff {\n\t\t\tt.Fatalf(\"client did not return within 30ms of context deadline, got %s\", diff)\n\t\t}\n\t}\n}\n\nfunc TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {\n\ttestTimeout := time.After(3 * time.Second)\n\ttestDone := make(chan struct{})\n\tdeadline := time.Now().Add(100 * time.Millisecond)\n\n\tgo func() {\n\t\tclient := anthropic.NewClient(\n\t\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t\t\toption.WithHTTPClient(&http.Client{\n\t\t\t\tTransport: &closureTransport{\n\t\t\t\t\tfn: func(req *http.Request) (*http.Response, error) {\n\t\t\t\t\t\treturn &http.Response{\n\t\t\t\t\t\t\tStatusCode: 200,\n\t\t\t\t\t\t\tStatus:     \"200 OK\",\n\t\t\t\t\t\t\tBody: io.NopCloser(\n\t\t\t\t\t\t\t\tio.Reader(readerFunc(func([]byte) (int, error) {\n\t\t\t\t\t\t\t\t\t<-req.Context().Done()\n\t\t\t\t\t\t\t\t\treturn 0, req.Context().Err()\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}, nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t)\n\t\tstream := client.Messages.NewStreaming(\n\t\t\tcontext.Background(),\n\t\t\tanthropic.MessageNewParams{\n\t\t\t\tMaxTokens: 1024,\n\t\t\t\tMessages: []anthropic.MessageParam{{\n\t\t\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\t\t\tText: \"x\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t\t\t}},\n\t\t\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\t\t},\n\t\t\toption.WithRequestTimeout((100 * time.Millisecond)),\n\t\t)\n\t\tfor stream.Next() {\n\t\t\t_ = stream.Current()\n\t\t}\n\t\tif stream.Err() == nil {\n\t\t\tt.Error(\"expected there to be a deadline error\")\n\t\t}\n\t\tclose(testDone)\n\t}()\n\n\tselect {\n\tcase <-testTimeout:\n\t\tt.Fatal(\"client didn't finish in time\")\n\tcase <-testDone:\n\t\tif diff := time.Since(deadline); diff < -30*time.Millisecond || 30*time.Millisecond < diff {\n\t\t\tt.Fatalf(\"client did not return within 30ms of context deadline, got %s\", diff)\n\t\t}\n\t}\n}\n\ntype readerFunc func([]byte) (int, error)\n\nfunc (f readerFunc) Read(p []byte) (int, error) { return f(p) }\nfunc (f readerFunc) Close() error               { return nil }\n"
  },
  {
    "path": "completion.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"slices\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/ssestream\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// CompletionService contains methods and other services that help with interacting\n// with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewCompletionService] method instead.\ntype CompletionService struct {\n\tOptions []option.RequestOption\n}\n\n// NewCompletionService generates a new service that applies the given options to\n// each request. These options are applied after the parent client's options (if\n// there is one), and before any request-specific options.\nfunc NewCompletionService(opts ...option.RequestOption) (r CompletionService) {\n\tr = CompletionService{}\n\tr.Options = opts\n\treturn\n}\n\n// [Legacy] Create a Text Completion.\n//\n// The Text Completions API is a legacy API. We recommend using the\n// [Messages API](https://docs.claude.com/en/api/messages) going forward.\n//\n// Future models and features will not be compatible with Text Completions. See our\n// [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)\n// for guidance in migrating from Text Completions to Messages.\n//\n// Note: If you choose to set a timeout for this request, we recommend 10 minutes.\nfunc (r *CompletionService) New(ctx context.Context, params CompletionNewParams, opts ...option.RequestOption) (res *Completion, err error) {\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\tpath := \"v1/complete\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)\n\treturn res, err\n}\n\n// [Legacy] Create a Text Completion.\n//\n// The Text Completions API is a legacy API. We recommend using the\n// [Messages API](https://docs.claude.com/en/api/messages) going forward.\n//\n// Future models and features will not be compatible with Text Completions. See our\n// [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)\n// for guidance in migrating from Text Completions to Messages.\n//\n// Note: If you choose to set a timeout for this request, we recommend 10 minutes.\nfunc (r *CompletionService) NewStreaming(ctx context.Context, params CompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[Completion]) {\n\tvar (\n\t\traw *http.Response\n\t\terr error\n\t)\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append(opts, option.WithJSONSet(\"stream\", true))\n\tpath := \"v1/complete\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...)\n\treturn ssestream.NewStream[Completion](ssestream.NewDecoder(raw), err)\n}\n\ntype Completion struct {\n\t// Unique object identifier.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// The resulting completion up to and excluding the stop sequences.\n\tCompletion string `json:\"completion\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model\" api:\"required\"`\n\t// The reason that we stopped.\n\t//\n\t// This may be one the following values:\n\t//\n\t//   - `\"stop_sequence\"`: we reached a stop sequence — either provided by you via the\n\t//     `stop_sequences` parameter, or a stop sequence built into the model\n\t//   - `\"max_tokens\"`: we exceeded `max_tokens_to_sample` or the model's maximum\n\tStopReason string `json:\"stop_reason\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Text Completions, this is always `\"completion\"`.\n\tType constant.Completion `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tCompletion  respjson.Field\n\t\tModel       respjson.Field\n\t\tStopReason  respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Completion) RawJSON() string { return r.JSON.raw }\nfunc (r *Completion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CompletionNewParams struct {\n\t// The maximum number of tokens to generate before stopping.\n\t//\n\t// Note that our models may stop _before_ reaching this maximum. This parameter\n\t// only specifies the absolute maximum number of tokens to generate.\n\tMaxTokensToSample int64 `json:\"max_tokens_to_sample\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// The prompt that you want Claude to complete.\n\t//\n\t// For proper response generation you will need to format your prompt using\n\t// alternating `\\n\\nHuman:` and `\\n\\nAssistant:` conversational turns. For example:\n\t//\n\t// ```\n\t// \"\\n\\nHuman: {userQuestion}\\n\\nAssistant:\"\n\t// ```\n\t//\n\t// See [prompt validation](https://docs.claude.com/en/api/prompt-validation) and\n\t// our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting)\n\t// for more details.\n\tPrompt string `json:\"prompt\" api:\"required\"`\n\t// Amount of randomness injected into the response.\n\t//\n\t// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`\n\t// for analytical / multiple choice, and closer to `1.0` for creative and\n\t// generative tasks.\n\t//\n\t// Note that even with `temperature` of `0.0`, the results will not be fully\n\t// deterministic.\n\tTemperature param.Opt[float64] `json:\"temperature,omitzero\"`\n\t// Only sample from the top K options for each subsequent token.\n\t//\n\t// Used to remove \"long tail\" low probability responses.\n\t// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopK param.Opt[int64] `json:\"top_k,omitzero\"`\n\t// Use nucleus sampling.\n\t//\n\t// In nucleus sampling, we compute the cumulative distribution over all the options\n\t// for each subsequent token in decreasing probability order and cut it off once it\n\t// reaches a particular probability specified by `top_p`. You should either alter\n\t// `temperature` or `top_p`, but not both.\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopP param.Opt[float64] `json:\"top_p,omitzero\"`\n\t// An object describing metadata about the request.\n\tMetadata MetadataParam `json:\"metadata,omitzero\"`\n\t// Sequences that will cause the model to stop generating.\n\t//\n\t// Our models stop on `\"\\n\\nHuman:\"`, and may include additional built-in stop\n\t// sequences in the future. By providing the stop_sequences parameter, you may\n\t// include additional strings that will cause the model to stop generating.\n\tStopSequences []string `json:\"stop_sequences,omitzero\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\nfunc (r CompletionNewParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow CompletionNewParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CompletionNewParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n"
  },
  {
    "path": "completion_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestCompletionNewWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Completions.New(context.TODO(), anthropic.CompletionNewParams{\n\t\tMaxTokensToSample: 256,\n\t\tModel:             anthropic.ModelClaudeOpus4_6,\n\t\tPrompt:            \"\\n\\nHuman: Hello, world!\\n\\nAssistant:\",\n\t\tMetadata: anthropic.MetadataParam{\n\t\t\tUserID: anthropic.String(\"13803d75-b4b5-4c3e-b2a2-6f21399b021b\"),\n\t\t},\n\t\tStopSequences: []string{\"string\"},\n\t\tTemperature:   anthropic.Float(1),\n\t\tTopK:          anthropic.Int(5),\n\t\tTopP:          anthropic.Float(0.7),\n\t\tBetas:         []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "examples/.keep",
    "content": "File generated from our OpenAPI spec by Stainless.\n\nThis directory can be used to store example files demonstrating usage of this SDK.\nIt is ignored by Stainless code generation and its content (other than this keep file) won't be touched."
  },
  {
    "path": "examples/bedrock/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/bedrock\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient(\n\t\tbedrock.WithLoadDefaultConfig(context.Background()),\n\t)\n\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         \"us.anthropic.claude-sonnet-4-5-20250929-v1:0\",\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tprintln(\"[assistant]: \" + message.Content[0].Text + message.StopSequence)\n}\n"
  },
  {
    "path": "examples/bedrock-bearer-token/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/bedrock\"\n)\n\nfunc main() {\n\t// bedrock.WithLoadDefaultConfig automatically configures using the AWS_BEARER_TOKEN_BEDROCK\n\t// environment variable. Region defaults to us-east-1 or uses AWS_REGION if set.\n\t//\n\t// To provide a token programmatically:\n\t//\n\t//\tcfg := aws.Config{\n\t//\t\tRegion:                  \"us-west-2\",\n\t//\t\tBearerAuthTokenProvider: bedrock.NewStaticBearerTokenProvider(\"my-bearer-token\"),\n\t//\t}\n\t//\tclient := anthropic.NewClient(\n\t//\t\tbedrock.WithConfig(cfg),\n\t//\t)\n\tclient := anthropic.NewClient(\n\t\tbedrock.WithLoadDefaultConfig(context.TODO()),\n\t)\n\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         \"us.anthropic.claude-sonnet-4-20250514-v1:0\",\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tprintln(\"[assistant]: \" + message.Content[0].Text + message.StopSequence)\n}\n"
  },
  {
    "path": "examples/bedrock-streaming/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/bedrock\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient(\n\t\tbedrock.WithLoadDefaultConfig(context.Background()),\n\t)\n\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tstream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         \"us.anthropic.claude-sonnet-4-5-20250929-v1:0\",\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\n\tprint(\"[assistant]: \")\n\n\tfor stream.Next() {\n\t\tevent := stream.Current()\n\n\t\tswitch eventVariant := event.AsAny().(type) {\n\t\tcase anthropic.MessageDeltaEvent:\n\t\t\tprint(eventVariant.Delta.StopSequence)\n\t\tcase anthropic.ContentBlockDeltaEvent:\n\t\t\tswitch deltaVariant := eventVariant.Delta.AsAny().(type) {\n\t\t\tcase anthropic.TextDelta:\n\t\t\t\tprint(deltaVariant.Text)\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln()\n\n\tif stream.Err() != nil {\n\t\tpanic(stream.Err())\n\t}\n}\n"
  },
  {
    "path": "examples/file-upload/file.txt",
    "content": "My top 5 favorite types of birds are, in no particular order:\n\n- Flycatchers (especially the Eastern Phoebe)\n- Hummingbirds\n- Swallows\n- Wrens\n- Sandpipers"
  },
  {
    "path": "examples/file-upload/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient := anthropic.NewClient()\n\n\tmyFile, err := os.Open(\"examples/file-upload/file.txt\")\n\tif err != nil {\n\t\tfmt.Printf(\"Error opening file: %v\\n\", err)\n\t\treturn\n\t}\n\n\tfileUploadResult, err := client.Beta.Files.Upload(ctx, anthropic.BetaFileUploadParams{\n\t\tFile:  anthropic.File(myFile, \"file.txt\", \"text/plain\"),\n\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},\n\t})\n\tif err != nil {\n\t\tfmt.Printf(\"Error uploading file: %v\\n\", err)\n\t\treturn\n\t}\n\tcontent := \"Write me a summary of my file.txt file in the style of a Shakespearean sonnet.\\n\\n\"\n\tprintln(\"[user]: \" + content)\n\n\tmessage, err := client.Beta.Messages.New(ctx, anthropic.BetaMessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\tanthropic.NewBetaUserMessage(\n\t\t\t\tanthropic.NewBetaTextBlock(content),\n\t\t\t\tanthropic.NewBetaDocumentBlock(anthropic.BetaFileDocumentSourceParam{\n\t\t\t\t\tFileID: fileUploadResult.ID,\n\t\t\t\t}),\n\t\t\t),\n\t\t},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},\n\t})\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating message: %v\\n\", err)\n\t\treturn\n\t}\n\n\tprintln(\"[assistant]: \" + message.Content[0].Text + message.StopSequence)\n}\n"
  },
  {
    "path": "examples/go.mod",
    "content": "module github.com/anthropic/anthropic-sdk-go/examples\n\nreplace github.com/anthropics/anthropic-sdk-go => ../\n\ngo 1.23.0\n\ntoolchain go1.24.3\n\nrequire (\n\tgithub.com/anthropics/anthropic-sdk-go v0.0.0-00010101000000-000000000000\n\tgithub.com/invopop/jsonschema v0.13.0\n)\n\nrequire (\n\tcloud.google.com/go/auth v0.7.2 // indirect\n\tcloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect\n\tcloud.google.com/go/compute/metadata v0.5.0 // indirect\n\tgithub.com/bahlo/generic-list-go v0.2.0 // indirect\n\tgithub.com/buger/jsonparser v1.1.1 // indirect\n\tgithub.com/felixge/httpsnoop v1.0.4 // indirect\n\tgithub.com/go-logr/logr v1.4.2 // indirect\n\tgithub.com/go-logr/stdr v1.2.2 // indirect\n\tgithub.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect\n\tgithub.com/golang/protobuf v1.5.4 // indirect\n\tgithub.com/google/s2a-go v0.1.7 // indirect\n\tgithub.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect\n\tgithub.com/mailru/easyjson v0.7.7 // indirect\n\tgithub.com/tidwall/gjson v1.18.0 // indirect\n\tgithub.com/tidwall/match v1.1.1 // indirect\n\tgithub.com/tidwall/pretty v1.2.1 // indirect\n\tgithub.com/tidwall/sjson v1.2.5 // indirect\n\tgithub.com/wk8/go-ordered-map/v2 v2.1.8 // indirect\n\tgo.opencensus.io v0.24.0 // indirect\n\tgo.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect\n\tgo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect\n\tgo.opentelemetry.io/otel v1.24.0 // indirect\n\tgo.opentelemetry.io/otel/metric v1.24.0 // indirect\n\tgo.opentelemetry.io/otel/trace v1.24.0 // indirect\n\tgolang.org/x/crypto v0.40.0 // indirect\n\tgolang.org/x/net v0.41.0 // indirect\n\tgolang.org/x/oauth2 v0.30.0 // indirect\n\tgolang.org/x/sync v0.16.0 // indirect\n\tgolang.org/x/sys v0.34.0 // indirect\n\tgolang.org/x/text v0.27.0 // indirect\n\tgolang.org/x/time v0.5.0 // indirect\n\tgoogle.golang.org/api v0.189.0 // indirect\n\tgoogle.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect\n\tgoogle.golang.org/grpc v1.64.1 // indirect\n\tgoogle.golang.org/protobuf v1.34.2 // indirect\n\tgopkg.in/yaml.v3 v3.0.1 // indirect\n)\n\nrequire (\n\t// for the bedrock package\n\tgithub.com/aws/aws-sdk-go-v2 v1.30.3 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/config v1.27.27 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/credentials v1.17.27 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/sso v1.22.4 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect\n\tgithub.com/aws/smithy-go v1.20.3 // indirect\n)\n"
  },
  {
    "path": "examples/go.sum",
    "content": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go/auth v0.7.2 h1:uiha352VrCDMXg+yoBtaD0tUF4Kv9vrtrWPYXwutnDE=\ncloud.google.com/go/auth v0.7.2/go.mod h1:VEc4p5NNxycWQTMQEDQF0bd6aTMb6VgYDXEwiJJQAbs=\ncloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI=\ncloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I=\ncloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=\ncloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=\ngithub.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=\ngithub.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=\ngithub.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=\ngithub.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 h1:tW1/Rkad38LA15X4UQtjXZXNKsCgkshC3EbmcUmghTg=\ngithub.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3/go.mod h1:UbnqO+zjqk3uIt9yCACHJ9IVNhyhOCnYk8yA19SAWrM=\ngithub.com/aws/aws-sdk-go-v2/config v1.27.27 h1:HdqgGt1OAP0HkEDDShEl0oSYa9ZZBSOmKpdpsDMdO90=\ngithub.com/aws/aws-sdk-go-v2/config v1.27.27/go.mod h1:MVYamCg76dFNINkZFu4n4RjDixhVr51HLj4ErWzrVwg=\ngithub.com/aws/aws-sdk-go-v2/credentials v1.17.27 h1:2raNba6gr2IfA0eqqiP2XiQ0UVOpGPgDSi0I9iAP+UI=\ngithub.com/aws/aws-sdk-go-v2/credentials v1.17.27/go.mod h1:gniiwbGahQByxan6YjQUMcW4Aov6bLC3m+evgcoN4r4=\ngithub.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 h1:KreluoV8FZDEtI6Co2xuNk/UqI9iwMrOx/87PBNIKqw=\ngithub.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11/go.mod h1:SeSUYBLsMYFoRvHE0Tjvn7kbxaUhl75CJi1sbfhMxkU=\ngithub.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 h1:SoNJ4RlFEQEbtDcCEt+QG56MY4fm4W8rYirAmq+/DdU=\ngithub.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15/go.mod h1:U9ke74k1n2bf+RIgoX1SXFed1HLs51OgUSs+Ph0KJP8=\ngithub.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 h1:C6WHdGnTDIYETAm5iErQUiVNsclNx9qbJVPIt03B6bI=\ngithub.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15/go.mod h1:ZQLZqhcu+JhSrA9/NXRm8SkDvsycE+JkV3WGY41e+IM=\ngithub.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU=\ngithub.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY=\ngithub.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 h1:dT3MqvGhSoaIhRseqw2I0yH81l7wiR2vjs57O51EAm8=\ngithub.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3/go.mod h1:GlAeCkHwugxdHaueRr4nhPuY+WW+gR8UjlcqzPr1SPI=\ngithub.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 h1:HGErhhrxZlQ044RiM+WdoZxp0p+EGM62y3L6pwA4olE=\ngithub.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17/go.mod h1:RkZEx4l0EHYDJpWppMJ3nD9wZJAa8/0lq9aVC+r2UII=\ngithub.com/aws/aws-sdk-go-v2/service/sso v1.22.4 h1:BXx0ZIxvrJdSgSvKTZ+yRBeSqqgPM89VPlulEcl37tM=\ngithub.com/aws/aws-sdk-go-v2/service/sso v1.22.4/go.mod h1:ooyCOXjvJEsUw7x+ZDHeISPMhtwI3ZCB7ggFMcFfWLU=\ngithub.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 h1:yiwVzJW2ZxZTurVbYWA7QOrAaCYQR72t0wrSBfoesUE=\ngithub.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4/go.mod h1:0oxfLkpz3rQ/CHlx5hB7H69YUpFiI1tql6Q6Ne+1bCw=\ngithub.com/aws/aws-sdk-go-v2/service/sts v1.30.3 h1:ZsDKRLXGWHk8WdtyYMoGNO7bTudrvuKpDKgMVRlepGE=\ngithub.com/aws/aws-sdk-go-v2/service/sts v1.30.3/go.mod h1:zwySh8fpFyXp9yOr/KVzxOl8SRqgf/IDw5aUt9UKFcQ=\ngithub.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=\ngithub.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=\ngithub.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=\ngithub.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=\ngithub.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=\ngithub.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=\ngithub.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=\ngithub.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=\ngithub.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=\ngithub.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=\ngithub.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=\ngithub.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=\ngithub.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=\ngithub.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=\ngithub.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=\ngithub.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=\ngithub.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=\ngithub.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=\ngithub.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=\ngithub.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=\ngithub.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=\ngithub.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=\ngithub.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=\ngithub.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=\ngithub.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=\ngithub.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=\ngithub.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=\ngithub.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=\ngithub.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=\ngithub.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=\ngithub.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=\ngithub.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=\ngithub.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=\ngithub.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=\ngithub.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=\ngithub.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=\ngithub.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=\ngithub.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=\ngithub.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=\ngithub.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=\ngithub.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=\ngithub.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=\ngithub.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=\ngithub.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=\ngithub.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=\ngithub.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=\ngithub.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=\ngithub.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=\ngithub.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=\ngithub.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=\ngithub.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=\ngithub.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=\ngithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=\ngithub.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=\ngithub.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=\ngithub.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=\ngithub.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=\ngithub.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=\ngithub.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=\ngithub.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=\ngithub.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=\ngithub.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=\ngithub.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=\ngithub.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=\ngithub.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=\ngithub.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=\ngithub.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=\ngithub.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=\ngithub.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=\ngithub.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=\ngithub.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=\ngithub.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=\ngithub.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=\ngithub.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=\ngo.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=\ngo.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=\ngo.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=\ngo.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=\ngo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=\ngo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=\ngo.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=\ngo.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=\ngo.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=\ngo.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=\ngo.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=\ngo.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=\ngolang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=\ngolang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=\ngolang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=\ngolang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=\ngolang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=\ngolang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=\ngolang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=\ngolang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=\ngolang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=\ngolang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=\ngolang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=\ngolang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=\ngolang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=\ngolang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=\ngolang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=\ngolang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=\ngolang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=\ngolang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=\ngolang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=\ngolang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=\ngolang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=\ngolang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=\ngolang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=\ngolang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=\ngolang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=\ngolang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=\ngolang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=\ngolang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=\ngolang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=\ngolang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=\ngolang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=\ngolang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=\ngolang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=\ngolang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=\ngolang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=\ngolang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=\ngolang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=\ngoogle.golang.org/api v0.189.0 h1:equMo30LypAkdkLMBqfeIqtyAnlyig1JSZArl4XPwdI=\ngoogle.golang.org/api v0.189.0/go.mod h1:FLWGJKb0hb+pU2j+rJqwbnsF+ym+fQs73rbJ+KAUgy8=\ngoogle.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=\ngoogle.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=\ngoogle.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=\ngoogle.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=\ngoogle.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=\ngoogle.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade h1:oCRSWfwGXQsqlVdErcyTt4A93Y8fo0/9D4b1gnI++qo=\ngoogle.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=\ngoogle.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=\ngoogle.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=\ngoogle.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=\ngoogle.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=\ngoogle.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=\ngoogle.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=\ngoogle.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=\ngoogle.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=\ngoogle.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=\ngoogle.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=\ngoogle.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=\ngoogle.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=\ngoogle.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=\ngoogle.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=\ngoogle.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=\ngoogle.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=\ngoogle.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=\ngoogle.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=\ngopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\ngopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=\ngopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\nhonnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=\nhonnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=\n"
  },
  {
    "path": "examples/message/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         anthropic.ModelClaudeSonnet4_5_20250929,\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tprintln(\"[assistant]: \" + message.Content[0].Text + message.StopSequence)\n}\n"
  },
  {
    "path": "examples/message-mcp-streaming/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient(option.WithHeader(\"anthropic-beta\", anthropic.AnthropicBetaMCPClient2025_04_04))\n\n\tmcpServers := []anthropic.BetaRequestMCPServerURLDefinitionParam{\n\t\t{\n\t\t\tURL:                \"http://example-server.modelcontextprotocol.io/sse\",\n\t\t\tName:               \"example\",\n\t\t\tAuthorizationToken: param.NewOpt(\"YOUR_TOKEN\"),\n\t\t\tToolConfiguration: anthropic.BetaRequestMCPServerToolConfigurationParam{\n\t\t\t\tEnabled:      anthropic.Bool(true),\n\t\t\t\tAllowedTools: []string{\"echo\", \"add\"},\n\t\t\t},\n\t\t},\n\t}\n\n\tstream := client.Beta.Messages.NewStreaming(context.TODO(), anthropic.BetaMessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"what is 1+1?\")),\n\t\t},\n\t\tMCPServers:    mcpServers,\n\t\tModel:         anthropic.ModelClaudeSonnet4_5_20250929,\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\n\tmessage := anthropic.BetaMessage{}\n\tfor stream.Next() {\n\t\tevent := stream.Current()\n\t\terr := message.Accumulate(event)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"error accumulating event: %v\\n\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch eventVariant := event.AsAny().(type) {\n\t\tcase anthropic.BetaRawMessageDeltaEvent:\n\t\t\tprint(eventVariant.Delta.StopSequence)\n\t\tcase anthropic.BetaRawContentBlockDeltaEvent:\n\t\t\tswitch deltaVariant := eventVariant.Delta.AsAny().(type) {\n\t\t\tcase anthropic.BetaTextDelta:\n\t\t\t\tprint(deltaVariant.Text)\n\t\t\t}\n\t\tdefault:\n\t\t\tfmt.Printf(\"%+v\\n\", eventVariant)\n\t\t}\n\t}\n\n\tprintln()\n\n\tif stream.Err() != nil {\n\t\tpanic(stream.Err())\n\t}\n\n}\n"
  },
  {
    "path": "examples/message-streaming/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tstream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         anthropic.ModelClaudeSonnet4_5_20250929,\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\n\tprint(\"[assistant]: \")\n\n\tfor stream.Next() {\n\t\tevent := stream.Current()\n\n\t\tswitch eventVariant := event.AsAny().(type) {\n\t\tcase anthropic.MessageDeltaEvent:\n\t\t\tprint(eventVariant.Delta.StopSequence)\n\t\tcase anthropic.ContentBlockDeltaEvent:\n\t\t\tswitch deltaVariant := eventVariant.Delta.AsAny().(type) {\n\t\t\tcase anthropic.TextDelta:\n\t\t\t\tprint(deltaVariant.Text)\n\t\t\t}\n\t\t}\n\t}\n\n\tprintln()\n\n\tif stream.Err() != nil {\n\t\tpanic(stream.Err())\n\t}\n}\n"
  },
  {
    "path": "examples/multimodal/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\n\tcontent := \"How many dogs are in this picture?\"\n\n\tprintln(\"[user]: \" + content)\n\n\tfile, err := os.Open(\"./multimodal/nine_dogs.png\")\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"failed to open file: you should run this example from the root of the anthropic-go/examples directory: %w\", err))\n\t}\n\tfileBytes, err := io.ReadAll(file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfileEncoded := base64.StdEncoding.EncodeToString(fileBytes)\n\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(\n\t\t\t\tanthropic.NewTextBlock(content),\n\t\t\t\tanthropic.NewImageBlockBase64(\"image/png\", fileEncoded),\n\t\t\t),\n\t\t},\n\t\tModel:         anthropic.ModelClaudeSonnet4_5_20250929,\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tprintln(\"[assistant]: \" + message.Content[0].Text + message.StopSequence)\n}\n"
  },
  {
    "path": "examples/structured-outputs/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/invopop/jsonschema\"\n)\n\n// Example struct with various field types and constraints\ntype WeatherQuery struct {\n\tLocation    string   `json:\"location\" jsonschema:\"title=Location,description=The city and state e.g. San Francisco CA\"`\n\tUnits       string   `json:\"units,omitempty\" jsonschema:\"enum=celsius,enum=fahrenheit,default=fahrenheit\"`\n\tDays        int      `json:\"days\" jsonschema:\"minimum=1,maximum=7,description=Number of days to forecast\"`\n\tIncludeWind bool     `json:\"include_wind,omitempty\"`\n\tDetails     []string `json:\"details,omitempty\" jsonschema:\"minItems=1,maxItems=5\"`\n}\n\nfunc main() {\n\tschemaMap := generateJSONSchema(&WeatherQuery{})\n\n\tfmt.Println(\"schema generated by invopop/jsonschema:\")\n\tprintJSON(schemaMap)\n\n\tclient := anthropic.NewClient()\n\n\tmessages := []anthropic.BetaMessageParam{\n\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather like in San Francisco for the next 3 days? Include wind information.\")),\n\t}\n\n\tmsg, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{\n\t\tModel:        anthropic.Model(\"claude-sonnet-4-5\"),\n\t\tMaxTokens:    1024,\n\t\tMessages:     messages,\n\t\tOutputFormat: anthropic.BetaJSONSchemaOutputFormat(schemaMap),\n\t\tBetas:        []anthropic.AnthropicBeta{\"structured-outputs-2025-11-13\"},\n\t})\n\n\tif err != nil {\n\t\tfmt.Printf(\"Error calling API: %v\\n\", err)\n\t\treturn\n\t}\n\n\tfmt.Println(\"\\nAPI Response:\")\n\tfor _, block := range msg.Content {\n\t\tswitch v := block.AsAny().(type) {\n\t\tcase anthropic.BetaTextBlock:\n\t\t\tfmt.Printf(\"Text: %s\\n\", v.Text)\n\t\tcase anthropic.BetaToolUseBlock:\n\t\t\tfmt.Printf(\"Tool use: %s\\n\", v.Name)\n\t\t\tfmt.Printf(\"Input: %s\\n\", v.JSON.Input.Raw())\n\t\t}\n\t}\n\n}\n\nfunc generateJSONSchema(t any) map[string]any {\n\treflector := jsonschema.Reflector{\n\t\tAllowAdditionalProperties: false,\n\t\tDoNotReference:            true,\n\t}\n\tschema := reflector.Reflect(t)\n\tschemaBytes, err := json.Marshal(schema)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tvar schemaMap map[string]any\n\tif err := json.Unmarshal(schemaBytes, &schemaMap); err != nil {\n\t\tpanic(err)\n\t}\n\treturn schemaMap\n\n}\n\nfunc printJSON(v any) {\n\tb, err := json.MarshalIndent(v, \"\", \"  \")\n\tif err != nil {\n\t\tfmt.Printf(\"Error: %v\\n\", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n}\n"
  },
  {
    "path": "examples/tool-runner/main.go",
    "content": "// Example demonstrating the Tool Runner framework\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strconv\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/toolrunner\"\n)\n\ntype CalculatorInput struct {\n\tOperation string  `json:\"operation\" jsonschema:\"required,description=The arithmetic operation to perform,enum=add,subtract,multiply,divide\"`\n\tA         float64 `json:\"a\" jsonschema:\"required,description=The first number\"`\n\tB         float64 `json:\"b\" jsonschema:\"required,description=The second number\"`\n}\n\nfunc calculate(ctx context.Context, calc CalculatorInput) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\tvar floatResult float64\n\tfmt.Printf(\"🔧 Calculator tool called with: %+v\\n\", calc)\n\tswitch calc.Operation {\n\tcase \"add\":\n\t\tfloatResult = calc.A + calc.B\n\tcase \"subtract\":\n\t\tfloatResult = calc.A - calc.B\n\tcase \"multiply\":\n\t\tfloatResult = calc.A * calc.B\n\tcase \"divide\":\n\t\tif calc.B == 0 {\n\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{}, fmt.Errorf(\"division by zero\")\n\t\t}\n\t\tfloatResult = calc.A / calc.B\n\tdefault:\n\t\treturn anthropic.BetaToolResultBlockParamContentUnion{}, fmt.Errorf(\"unknown operation: %s\", calc.Operation)\n\t}\n\n\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\tOfText: &anthropic.BetaTextBlockParam{Text: strconv.FormatFloat(floatResult, 'g', -1, 64)},\n\t}, nil\n}\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\tctx := context.Background()\n\n\tcalculatorTool, err := toolrunner.NewBetaToolFromJSONSchema(\"calculator\", \"Perform basic arithmetic operations\", calculate)\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating calculator tool: %v\\n\", err)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"Starting tool runner with calculator tool: %+v\\n\", calculatorTool)\n\n\ttools := []anthropic.BetaTool{calculatorTool}\n\n\trunner := client.Beta.Messages.NewToolRunner(tools, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_20250514,\n\t\t\tMaxTokens: 1000,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(\n\t\t\t\t\tanthropic.NewBetaTextBlock(\"Calculate 15 * 23, then add 10 to the result\"),\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tfinalMessage, err := runner.RunToCompletion(ctx)\n\tif err != nil {\n\t\tfmt.Printf(\"Error running tools: %v\\n\", err)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"Final message content:\\n\")\n\tfmt.Printf(\"%+v\\n\", finalMessage)\n}\n"
  },
  {
    "path": "examples/tool-runner-streaming/main.go",
    "content": "// Example demonstrating the Tool Runner framework with streaming\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/toolrunner\"\n)\n\ntype WeatherRequest struct {\n\tCity    string `json:\"city\" jsonschema:\"required,description=The city to get weather for\"`\n\tUnits   string `json:\"units,omitempty\" jsonschema:\"description=Temperature units,enum=celsius,fahrenheit\"`\n\tInclude string `json:\"include,omitempty\" jsonschema:\"description=Additional data to include,enum=forecast,historical\"`\n}\n\nfunc colorWith(code string, s string) string { return fmt.Sprintf(\"\\033[1;%sm%s\\033[0m\", code, s) }\nfunc colorUser(s string) string              { return colorWith(\"36\", s) } // cyan\nfunc colorAssistant(s string) string         { return colorWith(\"32\", s) } // green\nfunc colorTool(s string) string              { return colorWith(\"33\", s) } // yellow\nfunc colorThinking(s string) string          { return colorWith(\"90\", s) } // grey\n\nfunc getWeather(ctx context.Context, req WeatherRequest) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\tfmt.Printf(\"%s%s %+v\\n\", colorTool(\"[tool get_weather]: \"), \"called with\", req)\n\n\ttemp := 22\n\tif req.Units == \"fahrenheit\" {\n\t\ttemp = 72\n\t}\n\n\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\tOfText: &anthropic.BetaTextBlockParam{\n\t\t\tText: fmt.Sprintf(\"The current weather in %s is %d degrees %s. Tomorrow's weather will be cloudy and colder.\", req.City, temp, req.Units),\n\t\t},\n\t}, nil\n}\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\tctx := context.Background()\n\n\tweatherTool, err := toolrunner.NewBetaToolFromJSONSchema(\"get_weather\", \"Get current weather information for a city\", getWeather)\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating weather tool: %v\\n\", err)\n\t\treturn\n\t}\n\n\tuserQuestion := \"What's the weather like in San Francisco? Please use Fahrenheit and include the forecast.\"\n\tfmt.Println(colorUser(\"[user]: \") + userQuestion)\n\n\ttools := []anthropic.BetaTool{weatherTool}\n\n\trunner := client.Beta.Messages.NewToolRunnerStreaming(tools, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_20250514,\n\t\t\tMaxTokens: 1000,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(\n\t\t\t\t\tanthropic.NewBetaTextBlock(userQuestion),\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tfor eventsIterator := range runner.AllStreaming(ctx) {\n\t\t_ = runner.IterationCount()\n\t\tfor event, err := range eventsIterator {\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%s %+v\\n\", colorWith(\"31\", \"[error]: \"+err.Error()), event)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tswitch eventVariant := event.AsAny().(type) {\n\t\t\tcase anthropic.BetaRawMessageStartEvent:\n\t\t\t\tfmt.Print(colorAssistant(\"[assistant]: \"))\n\t\t\tcase anthropic.BetaRawContentBlockStartEvent:\n\t\t\t\tswitch cb := eventVariant.ContentBlock.AsAny().(type) {\n\t\t\t\tcase anthropic.BetaToolUseBlock:\n\t\t\t\t\t// Assistant is initiating a tool call; stream its JSON input deltas next\n\t\t\t\t\tlabel := fmt.Sprintf(\"[tool call %s]: \", cb.Name)\n\t\t\t\t\tfmt.Print(colorTool(label))\n\t\t\t\tcase anthropic.BetaTextBlock:\n\t\t\t\t\t// nothing, normal assistant text will follow via deltas\n\t\t\t\tcase anthropic.BetaThinkingBlock:\n\t\t\t\t\tfmt.Print(colorThinking(\"[assistant thinking]: \"))\n\t\t\t\t}\n\t\t\tcase anthropic.BetaRawContentBlockDeltaEvent:\n\t\t\t\tswitch deltaVariant := eventVariant.Delta.AsAny().(type) {\n\t\t\t\tcase anthropic.BetaTextDelta:\n\t\t\t\t\tfmt.Print(colorAssistant(deltaVariant.Text))\n\t\t\t\tcase anthropic.BetaInputJSONDelta:\n\t\t\t\t\tif deltaVariant.PartialJSON != \"\" {\n\t\t\t\t\t\tfmt.Print(colorTool(deltaVariant.PartialJSON))\n\t\t\t\t\t}\n\t\t\t\tcase anthropic.BetaThinkingDelta:\n\t\t\t\t\tfmt.Print(colorThinking(deltaVariant.Thinking))\n\t\t\t\t}\n\t\t\tcase anthropic.BetaRawContentBlockStopEvent:\n\t\t\t\tfmt.Println()\n\t\t\tcase anthropic.BetaRawMessageDeltaEvent:\n\t\t\t\t// No visible text here; keep for completeness\n\t\t\tcase anthropic.BetaRawMessageStopEvent:\n\t\t\t\tfmt.Println()\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "examples/tools/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\n\tcontent := \"What is the weather in San Francisco, CA?\"\n\n\tprintln(color(\"[user]: \") + content)\n\n\tmessages := []anthropic.MessageParam{\n\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t}\n\n\ttoolParams := []anthropic.ToolParam{\n\t\t{\n\t\t\tName:        \"get_coordinates\",\n\t\t\tDescription: anthropic.String(\"Accepts a place as an address, then returns the latitude and longitude coordinates.\"),\n\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\"location\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\"description\": \"The location to look up.\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"get_temperature_unit\",\n\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\"country\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\"description\": \"The country\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:        \"get_weather\",\n\t\t\tDescription: anthropic.String(\"Get the weather at a specific location\"),\n\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\"lat\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"number\",\n\t\t\t\t\t\t\"description\": \"The lattitude of the location to check weather.\",\n\t\t\t\t\t},\n\t\t\t\t\t\"long\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"number\",\n\t\t\t\t\t\t\"description\": \"The longitude of the location to check weather.\",\n\t\t\t\t\t},\n\t\t\t\t\t\"unit\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\"enum\":        []string{\"celsius\", \"fahrenheit\"},\n\t\t\t\t\t\t\"description\": \"Unit for the output\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\ttools := make([]anthropic.ToolUnionParam, len(toolParams))\n\tfor i, toolParam := range toolParams {\n\t\ttools[i] = anthropic.ToolUnionParam{OfTool: &toolParam}\n\t}\n\n\tfor {\n\t\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5_20250929,\n\t\t\tMaxTokens: 1024,\n\t\t\tMessages:  messages,\n\t\t\tTools:     tools,\n\t\t})\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tprint(color(\"[assistant]: \"))\n\n\t\tfor _, block := range message.Content {\n\t\t\tswitch block := block.AsAny().(type) {\n\t\t\tcase anthropic.TextBlock:\n\t\t\t\tprintln(block.Text)\n\t\t\t\tprintln()\n\t\t\tcase anthropic.ToolUseBlock:\n\t\t\t\tinputJSON, _ := json.Marshal(block.Input)\n\t\t\t\tprintln(block.Name + \": \" + string(inputJSON))\n\t\t\t\tprintln()\n\t\t\t}\n\t\t}\n\t\tprintln()\n\n\t\tmessages = append(messages, message.ToParam())\n\t\ttoolResults := []anthropic.ContentBlockParamUnion{}\n\n\t\tfor _, block := range message.Content {\n\t\t\tswitch variant := block.AsAny().(type) {\n\t\t\tcase anthropic.ToolUseBlock:\n\t\t\t\tprint(color(\"[user (\" + block.Name + \")]: \"))\n\n\t\t\t\tvar response any\n\t\t\t\tswitch block.Name {\n\t\t\t\tcase \"get_coordinates\":\n\t\t\t\t\tvar input struct {\n\t\t\t\t\t\tLocation string `json:\"location\"`\n\t\t\t\t\t}\n\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\n\t\t\t\t\tresponse = GetCoordinates(input.Location)\n\t\t\t\tcase \"get_temperature_unit\":\n\t\t\t\t\tvar input struct {\n\t\t\t\t\t\tCountry string `json:\"country\"`\n\t\t\t\t\t}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetTemperatureUnit(input.Country)\n\t\t\t\tcase \"get_weather\":\n\t\t\t\t\tvar input struct {\n\t\t\t\t\t\tLat  float64 `json:\"lat\"`\n\t\t\t\t\t\tLong float64 `json:\"long\"`\n\t\t\t\t\t\tUnit string  `json:\"unit\"`\n\t\t\t\t\t}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetWeather(input.Lat, input.Long, input.Unit)\n\t\t\t\t}\n\n\t\t\t\tb, err := json.Marshal(response)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\n\t\t\t\tprintln(string(b))\n\n\t\t\t\ttoolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, string(b), false))\n\t\t\t}\n\t\t}\n\n\t\tif len(toolResults) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tmessages = append(messages, anthropic.NewUserMessage(toolResults...))\n\t}\n}\n\ntype CoordinateResponse struct {\n\tLong float64 `json:\"long\"`\n\tLat  float64 `json:\"lat\"`\n}\n\nfunc GetCoordinates(location string) CoordinateResponse {\n\treturn CoordinateResponse{\n\t\tLong: -122.4194,\n\t\tLat:  37.7749,\n\t}\n}\n\nfunc GetTemperatureUnit(country string) string {\n\treturn \"farenheit\"\n}\n\ntype WeatherResponse struct {\n\tUnit        string  `json:\"unit\"`\n\tTemperature float64 `json:\"temperature\"`\n}\n\nfunc GetWeather(lat, long float64, unit string) WeatherResponse {\n\treturn WeatherResponse{\n\t\tUnit:        \"farenheit\",\n\t\tTemperature: 122,\n\t}\n}\n\nfunc color(s string) string {\n\treturn fmt.Sprintf(\"\\033[1;%sm%s\\033[0m\", \"33\", s)\n}\n"
  },
  {
    "path": "examples/tools-streaming/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\n\tcontent := \"What is the weather in San Francisco, CA?\"\n\n\tprintln(color(\"[user]: \") + content)\n\n\tmessages := []anthropic.MessageParam{\n\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t}\n\n\ttoolParams := []anthropic.ToolParam{\n\t\t{\n\t\t\tName:        \"get_coordinates\",\n\t\t\tDescription: anthropic.String(\"Accepts a place as an address, then returns the latitude and longitude coordinates.\"),\n\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\"location\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\"description\": \"The location to look up.\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"get_temperature_unit\",\n\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\"country\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\"description\": \"The country\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:        \"get_weather\",\n\t\t\tDescription: anthropic.String(\"Get the weather at a specific location\"),\n\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\"lat\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"number\",\n\t\t\t\t\t\t\"description\": \"The lattitude of the location to check weather.\",\n\t\t\t\t\t},\n\t\t\t\t\t\"long\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"number\",\n\t\t\t\t\t\t\"description\": \"The longitude of the location to check weather.\",\n\t\t\t\t\t},\n\t\t\t\t\t\"unit\": map[string]any{\n\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\"enum\":        []string{\"celsius\", \"fahrenheit\"},\n\t\t\t\t\t\t\"description\": \"Unit for the output\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\ttools := make([]anthropic.ToolUnionParam, len(toolParams))\n\tfor i, toolParam := range toolParams {\n\t\ttools[i] = anthropic.ToolUnionParam{OfTool: &toolParam}\n\t}\n\n\tfor {\n\t\tstream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5_20250929,\n\t\t\tMaxTokens: 1024,\n\t\t\tMessages:  messages,\n\t\t\tTools:     tools,\n\t\t})\n\n\t\tprint(color(\"[assistant]: \"))\n\n\t\tmessage := anthropic.Message{}\n\t\tfor stream.Next() {\n\t\t\tevent := stream.Current()\n\t\t\terr := message.Accumulate(event)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tswitch event := event.AsAny().(type) {\n\t\t\tcase anthropic.ContentBlockStartEvent:\n\t\t\t\tif event.ContentBlock.Name != \"\" {\n\t\t\t\t\tprint(event.ContentBlock.Name + \": \")\n\t\t\t\t}\n\t\t\tcase anthropic.ContentBlockDeltaEvent:\n\t\t\t\tprint(event.Delta.Text)\n\t\t\t\tprint(event.Delta.PartialJSON)\n\t\t\tcase anthropic.ContentBlockStopEvent:\n\t\t\t\tprintln()\n\t\t\t\tprintln()\n\t\t\tcase anthropic.MessageStopEvent:\n\t\t\t\tprintln()\n\t\t\t}\n\t\t}\n\n\t\tif stream.Err() != nil {\n\t\t\tpanic(stream.Err())\n\t\t}\n\n\t\tmessages = append(messages, message.ToParam())\n\t\ttoolResults := []anthropic.ContentBlockParamUnion{}\n\n\t\tfor _, block := range message.Content {\n\t\t\tswitch variant := block.AsAny().(type) {\n\t\t\tcase anthropic.ToolUseBlock:\n\t\t\t\tprint(color(\"[user (\" + block.Name + \")]: \"))\n\n\t\t\t\tvar response any\n\t\t\t\tswitch block.Name {\n\t\t\t\tcase \"get_coordinates\":\n\t\t\t\t\tvar input struct {\n\t\t\t\t\t\tLocation string `json:\"location\"`\n\t\t\t\t\t}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetCoordinates(input.Location)\n\t\t\t\tcase \"get_temperature_unit\":\n\t\t\t\t\tvar input struct {\n\t\t\t\t\t\tCountry string `json:\"country\"`\n\t\t\t\t\t}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetTemperatureUnit(input.Country)\n\t\t\t\tcase \"get_weather\":\n\t\t\t\t\tvar input struct {\n\t\t\t\t\t\tLat  float64 `json:\"lat\"`\n\t\t\t\t\t\tLong float64 `json:\"long\"`\n\t\t\t\t\t\tUnit string  `json:\"unit\"`\n\t\t\t\t\t}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetWeather(input.Lat, input.Long, input.Unit)\n\t\t\t\t}\n\n\t\t\t\tb, err := json.Marshal(response)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\n\t\t\t\tprintln(string(b))\n\n\t\t\t\ttoolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, string(b), false))\n\t\t\t}\n\t\t}\n\n\t\tif len(toolResults) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tmessages = append(messages, anthropic.NewUserMessage(toolResults...))\n\t}\n}\n\ntype CoordinateResponse struct {\n\tLong float64 `json:\"long\"`\n\tLat  float64 `json:\"lat\"`\n}\n\nfunc GetCoordinates(location string) CoordinateResponse {\n\treturn CoordinateResponse{\n\t\tLong: -122.4194,\n\t\tLat:  37.7749,\n\t}\n}\n\nfunc GetTemperatureUnit(country string) string {\n\treturn \"farenheit\"\n}\n\ntype WeatherResponse struct {\n\tUnit        string  `json:\"unit\"`\n\tTemperature float64 `json:\"temperature\"`\n}\n\nfunc GetWeather(lat, long float64, unit string) WeatherResponse {\n\treturn WeatherResponse{\n\t\tUnit:        \"farenheit\",\n\t\tTemperature: 122,\n\t}\n}\n\nfunc color(s string) string {\n\treturn fmt.Sprintf(\"\\033[1;%sm%s\\033[0m\", \"33\", s)\n}\n"
  },
  {
    "path": "examples/tools-streaming-jsonschema/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/invopop/jsonschema\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient()\n\n\tcontent := \"What is the weather in San Francisco, CA?\"\n\n\tprintln(color(\"[user]: \") + content)\n\n\tmessages := []anthropic.MessageParam{\n\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t}\n\n\ttoolParams := []anthropic.ToolParam{\n\t\t{\n\t\t\tName:        \"get_coordinates\",\n\t\t\tDescription: anthropic.String(\"Accepts a place as an address, then returns the latitude and longitude coordinates.\"),\n\t\t\tInputSchema: GetCoordinatesInputSchema,\n\t\t},\n\t\t{\n\t\t\tName:        \"get_temperature_unit\",\n\t\t\tInputSchema: GetTemperatureUnitInputSchema,\n\t\t},\n\t\t{\n\t\t\tName:        \"get_weather\",\n\t\t\tDescription: anthropic.String(\"Get the weather at a specific location\"),\n\t\t\tInputSchema: GetWeatherInputSchema,\n\t\t},\n\t}\n\ttools := make([]anthropic.ToolUnionParam, len(toolParams))\n\tfor i, toolParam := range toolParams {\n\t\ttools[i] = anthropic.ToolUnionParam{OfTool: &toolParam}\n\t}\n\n\tfor {\n\t\tstream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5_20250929,\n\t\t\tMaxTokens: 1024,\n\t\t\tMessages:  messages,\n\t\t\tTools:     tools,\n\t\t})\n\n\t\tprint(color(\"[assistant]: \"))\n\n\t\tmessage := anthropic.Message{}\n\t\tfor stream.Next() {\n\t\t\tevent := stream.Current()\n\t\t\terr := message.Accumulate(event)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tswitch event := event.AsAny().(type) {\n\t\t\tcase anthropic.ContentBlockStartEvent:\n\t\t\t\tif event.ContentBlock.Name != \"\" {\n\t\t\t\t\tprint(event.ContentBlock.Name + \": \")\n\t\t\t\t}\n\t\t\tcase anthropic.ContentBlockDeltaEvent:\n\t\t\t\tprint(event.Delta.Text)\n\t\t\t\tprint(event.Delta.PartialJSON)\n\t\t\tcase anthropic.ContentBlockStopEvent:\n\t\t\t\tprintln()\n\t\t\t\tprintln()\n\t\t\tcase anthropic.MessageStopEvent:\n\t\t\t\tprintln()\n\t\t\t}\n\t\t}\n\n\t\tif stream.Err() != nil {\n\t\t\tpanic(stream.Err())\n\t\t}\n\n\t\tmessages = append(messages, message.ToParam())\n\t\ttoolResults := []anthropic.ContentBlockParamUnion{}\n\n\t\tfor _, block := range message.Content {\n\t\t\tswitch variant := block.AsAny().(type) {\n\t\t\tcase anthropic.ToolUseBlock:\n\t\t\t\tprint(color(\"[user (\" + block.Name + \")]: \"))\n\n\t\t\t\tvar response any\n\t\t\t\tswitch block.Name {\n\t\t\t\tcase \"get_coordinates\":\n\t\t\t\t\tinput := GetCoordinatesInput{}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetCoordinates(input.Location)\n\t\t\t\tcase \"get_temperature_unit\":\n\t\t\t\t\tinput := GetTemperatureUnitInput{}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetTemperatureUnit(input.Country)\n\t\t\t\tcase \"get_weather\":\n\t\t\t\t\tinput := GetWeatherInput{}\n\t\t\t\t\terr := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t\tresponse = GetWeather(input.Lat, input.Long, input.Unit)\n\t\t\t\t}\n\n\t\t\t\tb, err := json.Marshal(response)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\n\t\t\t\tprintln(string(b))\n\n\t\t\t\ttoolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, string(b), false))\n\t\t\t}\n\t\t}\n\n\t\tif len(toolResults) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tmessages = append(messages, anthropic.NewUserMessage(toolResults...))\n\t}\n}\n\n// Get Coordinates\n\ntype GetCoordinatesInput struct {\n\tLocation string `json:\"location\" jsonschema_description:\"The location to look up.\"`\n}\n\nvar GetCoordinatesInputSchema = GenerateSchema[GetCoordinatesInput]()\n\ntype GetCoordinateResponse struct {\n\tLong float64 `json:\"long\"`\n\tLat  float64 `json:\"lat\"`\n}\n\nfunc GetCoordinates(location string) GetCoordinateResponse {\n\treturn GetCoordinateResponse{\n\t\tLong: -122.4194,\n\t\tLat:  37.7749,\n\t}\n}\n\n// Get Temperature Unit\n\ntype GetTemperatureUnitInput struct {\n\tCountry string `json:\"country\" jsonschema_description:\"The country\"`\n}\n\nvar GetTemperatureUnitInputSchema = GenerateSchema[GetTemperatureUnitInput]()\n\nfunc GetTemperatureUnit(country string) string {\n\treturn \"farenheit\"\n}\n\n// Get Weather\n\ntype GetWeatherInput struct {\n\tLat  float64 `json:\"lat\" jsonschema_description:\"The latitude of the location to check weather.\"`\n\tLong float64 `json:\"long\" jsonschema_description:\"The longitude of the location to check weather.\"`\n\tUnit string  `json:\"unit\" jsonschema_description:\"Unit for the output\"`\n}\n\nvar GetWeatherInputSchema = GenerateSchema[GetWeatherInput]()\n\ntype GetWeatherResponse struct {\n\tUnit        string  `json:\"unit\"`\n\tTemperature float64 `json:\"temperature\"`\n}\n\nfunc GetWeather(lat, long float64, unit string) GetWeatherResponse {\n\treturn GetWeatherResponse{\n\t\tUnit:        \"farenheit\",\n\t\tTemperature: 122,\n\t}\n}\n\nfunc GenerateSchema[T any]() anthropic.ToolInputSchemaParam {\n\treflector := jsonschema.Reflector{\n\t\tAllowAdditionalProperties: false,\n\t\tDoNotReference:            true,\n\t}\n\tvar v T\n\n\tschema := reflector.Reflect(v)\n\n\treturn anthropic.ToolInputSchemaParam{\n\t\tProperties: schema.Properties,\n\t}\n}\n\nfunc color(s string) string {\n\treturn fmt.Sprintf(\"\\033[1;%sm%s\\033[0m\", \"33\", s)\n}\n"
  },
  {
    "path": "examples/vertex/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"github.com/anthropics/anthropic-sdk-go/vertex\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient(\n\t\tvertex.WithGoogleAuth(context.Background(), \"us-central1\", \"id-xxx\"),\n\t)\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         \"claude-sonnet-4-v1@20250514\",\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tprintln(\"[assistant]: \" + message.Content[0].Text + message.StopSequence)\n}\n"
  },
  {
    "path": "examples/vertex-streaming/main.go",
    "content": "package main\n\nimport (\n\t\"context\"\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/vertex\"\n)\n\nfunc main() {\n\tclient := anthropic.NewClient(\n\t\tvertex.WithGoogleAuth(context.Background(), \"us-central1\", \"id-xxx\"),\n\t)\n\n\tcontent := \"Write me a function to call the Anthropic message API in Node.js using the Anthropic Typescript SDK.\"\n\n\tprintln(\"[user]: \" + content)\n\n\tstream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{\n\t\t\tanthropic.NewUserMessage(anthropic.NewTextBlock(content)),\n\t\t},\n\t\tModel:         \"claude-sonnet-4-v1@20250514\",\n\t\tStopSequences: []string{\"```\\n\"},\n\t})\n\n\tprint(\"[assistant]: \")\n\n\tfor stream.Next() {\n\t\tevent := stream.Current()\n\n\t\tswitch variant := event.AsAny().(type) {\n\t\tcase anthropic.ContentBlockDeltaEvent:\n\t\t\tif variant.Delta.Text != \"\" {\n\t\t\t\tprint(variant.Delta.Text)\n\t\t\t}\n\t\tcase anthropic.MessageDeltaEvent:\n\t\t\tif variant.Delta.StopSequence != \"\" {\n\t\t\t\tprint(variant.Delta.StopSequence)\n\t\t\t}\n\t\t}\n\n\t}\n\n\tprintln()\n\n\tif stream.Err() != nil {\n\t\tpanic(stream.Err())\n\t}\n}\n"
  },
  {
    "path": "field.go",
    "content": "package anthropic\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"io\"\n\t\"time\"\n)\n\nfunc String(s string) param.Opt[string]     { return param.NewOpt(s) }\nfunc Int(i int64) param.Opt[int64]          { return param.NewOpt(i) }\nfunc Bool(b bool) param.Opt[bool]           { return param.NewOpt(b) }\nfunc Float(f float64) param.Opt[float64]    { return param.NewOpt(f) }\nfunc Time(t time.Time) param.Opt[time.Time] { return param.NewOpt(t) }\n\nfunc Opt[T comparable](v T) param.Opt[T] { return param.NewOpt(v) }\nfunc Ptr[T any](v T) *T                  { return &v }\n\nfunc IntPtr(v int64) *int64          { return &v }\nfunc BoolPtr(v bool) *bool           { return &v }\nfunc FloatPtr(v float64) *float64    { return &v }\nfunc StringPtr(v string) *string     { return &v }\nfunc TimePtr(v time.Time) *time.Time { return &v }\n\nfunc File(rdr io.Reader, filename string, contentType string) file {\n\treturn file{rdr, filename, contentType}\n}\n\ntype file struct {\n\tio.Reader\n\tname        string\n\tcontentType string\n}\n\nfunc (f file) Filename() string {\n\tif f.name != \"\" {\n\t\treturn f.name\n\t} else if named, ok := f.Reader.(interface{ Name() string }); ok {\n\t\treturn named.Name()\n\t}\n\treturn \"\"\n}\n\nfunc (f file) ContentType() string {\n\treturn f.contentType\n}\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/anthropics/anthropic-sdk-go\n\ngo 1.23.0\n\ntoolchain go1.24.3\n\nrequire (\n\tgithub.com/aws/aws-sdk-go-v2 v1.30.3\n\tgithub.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3\n\tgithub.com/aws/aws-sdk-go-v2/config v1.27.27\n\tgithub.com/aws/aws-sdk-go-v2/credentials v1.17.27\n\tgithub.com/aws/smithy-go v1.20.3\n\tgithub.com/dnaeon/go-vcr v1.2.0\n\tgithub.com/invopop/jsonschema v0.13.0\n\tgithub.com/stretchr/testify v1.8.4\n\tgithub.com/tidwall/gjson v1.18.0\n\tgithub.com/tidwall/sjson v1.2.5\n\tgolang.org/x/oauth2 v0.30.0\n\tgolang.org/x/sync v0.16.0\n\tgoogle.golang.org/api v0.189.0\n)\n\nrequire (\n\tcloud.google.com/go/auth v0.7.2 // indirect\n\tcloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect\n\tcloud.google.com/go/compute/metadata v0.5.0 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/sso v1.22.4 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect\n\tgithub.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect\n\tgithub.com/bahlo/generic-list-go v0.2.0 // indirect\n\tgithub.com/buger/jsonparser v1.1.1 // indirect\n\tgithub.com/davecgh/go-spew v1.1.1 // indirect\n\tgithub.com/felixge/httpsnoop v1.0.4 // indirect\n\tgithub.com/go-logr/logr v1.4.2 // indirect\n\tgithub.com/go-logr/stdr v1.2.2 // indirect\n\tgithub.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect\n\tgithub.com/golang/protobuf v1.5.4 // indirect\n\tgithub.com/google/s2a-go v0.1.7 // indirect\n\tgithub.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect\n\tgithub.com/mailru/easyjson v0.7.7 // indirect\n\tgithub.com/pmezard/go-difflib v1.0.0 // indirect\n\tgithub.com/tidwall/match v1.1.1 // indirect\n\tgithub.com/tidwall/pretty v1.2.1 // indirect\n\tgithub.com/wk8/go-ordered-map/v2 v2.1.8 // indirect\n\tgo.opencensus.io v0.24.0 // indirect\n\tgo.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect\n\tgo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect\n\tgo.opentelemetry.io/otel v1.24.0 // indirect\n\tgo.opentelemetry.io/otel/metric v1.24.0 // indirect\n\tgo.opentelemetry.io/otel/trace v1.24.0 // indirect\n\tgolang.org/x/crypto v0.40.0 // indirect\n\tgolang.org/x/net v0.41.0 // indirect\n\tgolang.org/x/sys v0.34.0 // indirect\n\tgolang.org/x/text v0.27.0 // indirect\n\tgolang.org/x/time v0.5.0 // indirect\n\tgoogle.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect\n\tgoogle.golang.org/grpc v1.64.1 // indirect\n\tgoogle.golang.org/protobuf v1.34.2 // indirect\n\tgopkg.in/yaml.v2 v2.2.8 // indirect\n\tgopkg.in/yaml.v3 v3.0.1 // indirect\n)\n"
  },
  {
    "path": "go.sum",
    "content": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go/auth v0.7.2 h1:uiha352VrCDMXg+yoBtaD0tUF4Kv9vrtrWPYXwutnDE=\ncloud.google.com/go/auth v0.7.2/go.mod h1:VEc4p5NNxycWQTMQEDQF0bd6aTMb6VgYDXEwiJJQAbs=\ncloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI=\ncloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I=\ncloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=\ncloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=\ngithub.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=\ngithub.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=\ngithub.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=\ngithub.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 h1:tW1/Rkad38LA15X4UQtjXZXNKsCgkshC3EbmcUmghTg=\ngithub.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3/go.mod h1:UbnqO+zjqk3uIt9yCACHJ9IVNhyhOCnYk8yA19SAWrM=\ngithub.com/aws/aws-sdk-go-v2/config v1.27.27 h1:HdqgGt1OAP0HkEDDShEl0oSYa9ZZBSOmKpdpsDMdO90=\ngithub.com/aws/aws-sdk-go-v2/config v1.27.27/go.mod h1:MVYamCg76dFNINkZFu4n4RjDixhVr51HLj4ErWzrVwg=\ngithub.com/aws/aws-sdk-go-v2/credentials v1.17.27 h1:2raNba6gr2IfA0eqqiP2XiQ0UVOpGPgDSi0I9iAP+UI=\ngithub.com/aws/aws-sdk-go-v2/credentials v1.17.27/go.mod h1:gniiwbGahQByxan6YjQUMcW4Aov6bLC3m+evgcoN4r4=\ngithub.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 h1:KreluoV8FZDEtI6Co2xuNk/UqI9iwMrOx/87PBNIKqw=\ngithub.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11/go.mod h1:SeSUYBLsMYFoRvHE0Tjvn7kbxaUhl75CJi1sbfhMxkU=\ngithub.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 h1:SoNJ4RlFEQEbtDcCEt+QG56MY4fm4W8rYirAmq+/DdU=\ngithub.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15/go.mod h1:U9ke74k1n2bf+RIgoX1SXFed1HLs51OgUSs+Ph0KJP8=\ngithub.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 h1:C6WHdGnTDIYETAm5iErQUiVNsclNx9qbJVPIt03B6bI=\ngithub.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15/go.mod h1:ZQLZqhcu+JhSrA9/NXRm8SkDvsycE+JkV3WGY41e+IM=\ngithub.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU=\ngithub.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY=\ngithub.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 h1:dT3MqvGhSoaIhRseqw2I0yH81l7wiR2vjs57O51EAm8=\ngithub.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3/go.mod h1:GlAeCkHwugxdHaueRr4nhPuY+WW+gR8UjlcqzPr1SPI=\ngithub.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 h1:HGErhhrxZlQ044RiM+WdoZxp0p+EGM62y3L6pwA4olE=\ngithub.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17/go.mod h1:RkZEx4l0EHYDJpWppMJ3nD9wZJAa8/0lq9aVC+r2UII=\ngithub.com/aws/aws-sdk-go-v2/service/sso v1.22.4 h1:BXx0ZIxvrJdSgSvKTZ+yRBeSqqgPM89VPlulEcl37tM=\ngithub.com/aws/aws-sdk-go-v2/service/sso v1.22.4/go.mod h1:ooyCOXjvJEsUw7x+ZDHeISPMhtwI3ZCB7ggFMcFfWLU=\ngithub.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 h1:yiwVzJW2ZxZTurVbYWA7QOrAaCYQR72t0wrSBfoesUE=\ngithub.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4/go.mod h1:0oxfLkpz3rQ/CHlx5hB7H69YUpFiI1tql6Q6Ne+1bCw=\ngithub.com/aws/aws-sdk-go-v2/service/sts v1.30.3 h1:ZsDKRLXGWHk8WdtyYMoGNO7bTudrvuKpDKgMVRlepGE=\ngithub.com/aws/aws-sdk-go-v2/service/sts v1.30.3/go.mod h1:zwySh8fpFyXp9yOr/KVzxOl8SRqgf/IDw5aUt9UKFcQ=\ngithub.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=\ngithub.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=\ngithub.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=\ngithub.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=\ngithub.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=\ngithub.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=\ngithub.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=\ngithub.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=\ngithub.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=\ngithub.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=\ngithub.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=\ngithub.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=\ngithub.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=\ngithub.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=\ngithub.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=\ngithub.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=\ngithub.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=\ngithub.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=\ngithub.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=\ngithub.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=\ngithub.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=\ngithub.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=\ngithub.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=\ngithub.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=\ngithub.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=\ngithub.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=\ngithub.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=\ngithub.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=\ngithub.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=\ngithub.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=\ngithub.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=\ngithub.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=\ngithub.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=\ngithub.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=\ngithub.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=\ngithub.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=\ngithub.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=\ngithub.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=\ngithub.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=\ngithub.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=\ngithub.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=\ngithub.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=\ngithub.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=\ngithub.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=\ngithub.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=\ngithub.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=\ngithub.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=\ngithub.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=\ngithub.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=\ngithub.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=\ngithub.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=\ngithub.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=\ngithub.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=\ngithub.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=\ngithub.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=\ngithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=\ngithub.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=\ngithub.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=\ngithub.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=\ngithub.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=\ngithub.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=\ngithub.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=\ngithub.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=\ngithub.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=\ngithub.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=\ngithub.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=\ngithub.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=\ngithub.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=\ngithub.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=\ngithub.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=\ngithub.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=\ngithub.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=\ngithub.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=\ngithub.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=\ngithub.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=\ngithub.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=\ngithub.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=\ngo.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=\ngo.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=\ngo.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=\ngo.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=\ngo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=\ngo.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=\ngo.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=\ngo.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=\ngo.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=\ngo.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=\ngo.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=\ngo.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=\ngolang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=\ngolang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=\ngolang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=\ngolang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=\ngolang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=\ngolang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=\ngolang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=\ngolang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=\ngolang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=\ngolang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=\ngolang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=\ngolang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=\ngolang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=\ngolang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=\ngolang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=\ngolang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=\ngolang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=\ngolang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=\ngolang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=\ngolang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=\ngolang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=\ngolang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=\ngolang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=\ngolang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=\ngolang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=\ngolang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=\ngolang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=\ngolang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=\ngolang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=\ngolang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=\ngolang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=\ngolang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=\ngolang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=\ngolang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=\ngolang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=\ngolang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=\ngolang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=\ngoogle.golang.org/api v0.189.0 h1:equMo30LypAkdkLMBqfeIqtyAnlyig1JSZArl4XPwdI=\ngoogle.golang.org/api v0.189.0/go.mod h1:FLWGJKb0hb+pU2j+rJqwbnsF+ym+fQs73rbJ+KAUgy8=\ngoogle.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=\ngoogle.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=\ngoogle.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=\ngoogle.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=\ngoogle.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=\ngoogle.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade h1:oCRSWfwGXQsqlVdErcyTt4A93Y8fo0/9D4b1gnI++qo=\ngoogle.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=\ngoogle.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=\ngoogle.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=\ngoogle.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=\ngoogle.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=\ngoogle.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=\ngoogle.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=\ngoogle.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=\ngoogle.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=\ngoogle.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=\ngoogle.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=\ngoogle.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=\ngoogle.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=\ngoogle.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=\ngoogle.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=\ngoogle.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=\ngoogle.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=\ngoogle.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=\ngoogle.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=\ngopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=\ngopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=\ngopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\ngopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=\ngopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\nhonnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=\nhonnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=\n"
  },
  {
    "path": "internal/apierror/apierror.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage apierror\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/http/httputil\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n)\n\n// Error represents an error that originates from the API, i.e. when a request is\n// made and the API returns a response with a HTTP status code. Other errors are\n// not wrapped by this SDK.\ntype Error struct {\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n\tStatusCode int\n\tRequest    *http.Request\n\tResponse   *http.Response\n\tRequestID  string\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Error) RawJSON() string { return r.JSON.raw }\nfunc (r *Error) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (r *Error) Error() string {\n\t// Attempt to re-populate the response body\n\tstatusInfo := fmt.Sprintf(\"%s %q: %d %s\", r.Request.Method, r.Request.URL, r.Response.StatusCode, http.StatusText(r.Response.StatusCode))\n\n\tif r.RequestID != \"\" {\n\t\tstatusInfo += fmt.Sprintf(\" (Request-ID: %s)\", r.RequestID)\n\t}\n\n\treturn fmt.Sprintf(\"%s %s\", statusInfo, r.JSON.raw)\n}\n\nfunc (r *Error) DumpRequest(body bool) []byte {\n\tif r.Request.GetBody != nil {\n\t\tr.Request.Body, _ = r.Request.GetBody()\n\t}\n\tout, _ := httputil.DumpRequestOut(r.Request, body)\n\treturn out\n}\n\nfunc (r *Error) DumpResponse(body bool) []byte {\n\tout, _ := httputil.DumpResponse(r.Response, body)\n\treturn out\n}\n"
  },
  {
    "path": "internal/apiform/encoder.go",
    "content": "package apiform\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/textproto\"\n\t\"path\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n)\n\nvar encoders sync.Map // map[encoderEntry]encoderFunc\n\nfunc Marshal(value any, writer *multipart.Writer) error {\n\te := &encoder{\n\t\tdateFormat: time.RFC3339,\n\t\tarrayFmt:   \"comma\",\n\t}\n\treturn e.marshal(value, writer)\n}\n\nfunc MarshalRoot(value any, writer *multipart.Writer) error {\n\te := &encoder{\n\t\troot:       true,\n\t\tdateFormat: time.RFC3339,\n\t\tarrayFmt:   \"comma\",\n\t}\n\treturn e.marshal(value, writer)\n}\n\nfunc MarshalWithSettings(value any, writer *multipart.Writer, arrayFormat string) error {\n\te := &encoder{\n\t\tarrayFmt:   arrayFormat,\n\t\tdateFormat: time.RFC3339,\n\t}\n\treturn e.marshal(value, writer)\n}\n\ntype encoder struct {\n\tarrayFmt   string\n\tdateFormat string\n\troot       bool\n}\n\ntype encoderFunc func(key string, value reflect.Value, writer *multipart.Writer) error\n\ntype encoderField struct {\n\ttag parsedStructTag\n\tfn  encoderFunc\n\tidx []int\n}\n\ntype encoderEntry struct {\n\treflect.Type\n\tdateFormat string\n\tarrayFmt   string\n\troot       bool\n}\n\nfunc (e *encoder) marshal(value any, writer *multipart.Writer) error {\n\tval := reflect.ValueOf(value)\n\tif !val.IsValid() {\n\t\treturn nil\n\t}\n\ttyp := val.Type()\n\tenc := e.typeEncoder(typ)\n\treturn enc(\"\", val, writer)\n}\n\nfunc (e *encoder) typeEncoder(t reflect.Type) encoderFunc {\n\tentry := encoderEntry{\n\t\tType:       t,\n\t\tdateFormat: e.dateFormat,\n\t\tarrayFmt:   e.arrayFmt,\n\t\troot:       e.root,\n\t}\n\n\tif fi, ok := encoders.Load(entry); ok {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// To deal with recursive types, populate the map with an\n\t// indirect func before we build it. This type waits on the\n\t// real func (f) to be ready and then calls it. This indirect\n\t// func is only used for recursive types.\n\tvar (\n\t\twg sync.WaitGroup\n\t\tf  encoderFunc\n\t)\n\twg.Add(1)\n\tfi, loaded := encoders.LoadOrStore(entry, encoderFunc(func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\twg.Wait()\n\t\treturn f(key, v, writer)\n\t}))\n\tif loaded {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// Compute the real encoder and replace the indirect func with it.\n\tf = e.newTypeEncoder(t)\n\twg.Done()\n\tencoders.Store(entry, f)\n\treturn f\n}\n\nfunc (e *encoder) newTypeEncoder(t reflect.Type) encoderFunc {\n\tif t.ConvertibleTo(reflect.TypeOf(time.Time{})) {\n\t\treturn e.newTimeTypeEncoder()\n\t}\n\tif t.Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()) {\n\t\treturn e.newReaderTypeEncoder()\n\t}\n\te.root = false\n\tswitch t.Kind() {\n\tcase reflect.Pointer:\n\t\tinner := t.Elem()\n\n\t\tinnerEncoder := e.typeEncoder(inner)\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\tif !v.IsValid() || v.IsNil() {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn innerEncoder(key, v.Elem(), writer)\n\t\t}\n\tcase reflect.Struct:\n\t\treturn e.newStructTypeEncoder(t)\n\tcase reflect.Slice, reflect.Array:\n\t\treturn e.newArrayTypeEncoder(t)\n\tcase reflect.Map:\n\t\treturn e.newMapEncoder(t)\n\tcase reflect.Interface:\n\t\treturn e.newInterfaceEncoder()\n\tdefault:\n\t\treturn e.newPrimitiveTypeEncoder(t)\n\t}\n}\n\nfunc (e *encoder) newPrimitiveTypeEncoder(t reflect.Type) encoderFunc {\n\tswitch t.Kind() {\n\t// Note that we could use `gjson` to encode these types but it would complicate our\n\t// code more and this current code shouldn't cause any issues\n\tcase reflect.String:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\treturn writer.WriteField(key, v.String())\n\t\t}\n\tcase reflect.Bool:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\tif v.Bool() {\n\t\t\t\treturn writer.WriteField(key, \"true\")\n\t\t\t}\n\t\t\treturn writer.WriteField(key, \"false\")\n\t\t}\n\tcase reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\treturn writer.WriteField(key, strconv.FormatInt(v.Int(), 10))\n\t\t}\n\tcase reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\treturn writer.WriteField(key, strconv.FormatUint(v.Uint(), 10))\n\t\t}\n\tcase reflect.Float32:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\treturn writer.WriteField(key, strconv.FormatFloat(v.Float(), 'f', -1, 32))\n\t\t}\n\tcase reflect.Float64:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\treturn writer.WriteField(key, strconv.FormatFloat(v.Float(), 'f', -1, 64))\n\t\t}\n\tdefault:\n\t\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\t\treturn fmt.Errorf(\"unknown type received at primitive encoder: %s\", t.String())\n\t\t}\n\t}\n}\n\nfunc (e *encoder) newArrayTypeEncoder(t reflect.Type) encoderFunc {\n\titemEncoder := e.typeEncoder(t.Elem())\n\tkeyFn := e.arrayKeyEncoder()\n\treturn func(key string, v reflect.Value, writer *multipart.Writer) error {\n\t\tif keyFn == nil {\n\t\t\treturn fmt.Errorf(\"apiform: unsupported array format\")\n\t\t}\n\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\terr := itemEncoder(keyFn(key, i), v.Index(i), writer)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n}\n\nfunc (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc {\n\tif t.Implements(reflect.TypeOf((*param.Optional)(nil)).Elem()) {\n\t\treturn e.newRichFieldTypeEncoder(t)\n\t}\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tif t.Field(i).Type == paramUnionType && t.Field(i).Anonymous {\n\t\t\treturn e.newStructUnionTypeEncoder(t)\n\t\t}\n\t}\n\n\tencoderFields := []encoderField{}\n\textraEncoder := (*encoderField)(nil)\n\n\t// This helper allows us to recursively collect field encoders into a flat\n\t// array. The parameter `index` keeps track of the access patterns necessary\n\t// to get to some field.\n\tvar collectEncoderFields func(r reflect.Type, index []int)\n\tcollectEncoderFields = func(r reflect.Type, index []int) {\n\t\tfor i := 0; i < r.NumField(); i++ {\n\t\t\tidx := append(index, i)\n\t\t\tfield := t.FieldByIndex(idx)\n\t\t\tif !field.IsExported() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If this is an embedded struct, traverse one level deeper to extract\n\t\t\t// the field and get their encoders as well.\n\t\t\tif field.Anonymous {\n\t\t\t\tcollectEncoderFields(field.Type, idx)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If json tag is not present, then we skip, which is intentionally\n\t\t\t// different behavior from the stdlib.\n\t\t\tptag, ok := parseFormStructTag(field)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// We only want to support unexported field if they're tagged with\n\t\t\t// `extras` because that field shouldn't be part of the public API. We\n\t\t\t// also want to only keep the top level extras\n\t\t\tif ptag.extras && len(index) == 0 {\n\t\t\t\textraEncoder = &encoderField{ptag, e.typeEncoder(field.Type.Elem()), idx}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ptag.name == \"-\" || ptag.name == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdateFormat, ok := parseFormatStructTag(field)\n\t\t\toldFormat := e.dateFormat\n\t\t\tif ok {\n\t\t\t\tswitch dateFormat {\n\t\t\t\tcase \"date-time\":\n\t\t\t\t\te.dateFormat = time.RFC3339\n\t\t\t\tcase \"date\":\n\t\t\t\t\te.dateFormat = \"2006-01-02\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar encoderFn encoderFunc\n\t\t\tif ptag.omitzero {\n\t\t\t\ttypeEncoderFn := e.typeEncoder(field.Type)\n\t\t\t\tencoderFn = func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\t\t\t\tif value.IsZero() {\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t\treturn typeEncoderFn(key, value, writer)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tencoderFn = e.typeEncoder(field.Type)\n\t\t\t}\n\t\t\tencoderFields = append(encoderFields, encoderField{ptag, encoderFn, idx})\n\t\t\te.dateFormat = oldFormat\n\t\t}\n\t}\n\tcollectEncoderFields(t, []int{})\n\n\t// Ensure deterministic output by sorting by lexicographic order\n\tsort.Slice(encoderFields, func(i, j int) bool {\n\t\treturn encoderFields[i].tag.name < encoderFields[j].tag.name\n\t})\n\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\tkeyFn := e.objKeyEncoder(key)\n\t\tfor _, ef := range encoderFields {\n\t\t\tfield := value.FieldByIndex(ef.idx)\n\t\t\terr := ef.fn(keyFn(ef.tag.name), field, writer)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif extraEncoder != nil {\n\t\t\terr := e.encodeMapEntries(key, value.FieldByIndex(extraEncoder.idx), writer)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n}\n\nvar paramUnionType = reflect.TypeOf((*param.APIUnion)(nil)).Elem()\n\nfunc (e *encoder) newStructUnionTypeEncoder(t reflect.Type) encoderFunc {\n\tvar fieldEncoders []encoderFunc\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\tif field.Type == paramUnionType && field.Anonymous {\n\t\t\tfieldEncoders = append(fieldEncoders, nil)\n\t\t\tcontinue\n\t\t}\n\t\tfieldEncoders = append(fieldEncoders, e.typeEncoder(field.Type))\n\t}\n\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\tfor i := 0; i < t.NumField(); i++ {\n\t\t\tif value.Field(i).Type() == paramUnionType {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !value.Field(i).IsZero() {\n\t\t\t\treturn fieldEncoders[i](key, value.Field(i), writer)\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"apiform: union %s has no field set\", t.String())\n\t}\n}\n\nfunc (e *encoder) newTimeTypeEncoder() encoderFunc {\n\tformat := e.dateFormat\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\treturn writer.WriteField(key, value.Convert(reflect.TypeOf(time.Time{})).Interface().(time.Time).Format(format))\n\t}\n}\n\nfunc (e encoder) newInterfaceEncoder() encoderFunc {\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\tvalue = value.Elem()\n\t\tif !value.IsValid() {\n\t\t\treturn nil\n\t\t}\n\t\treturn e.typeEncoder(value.Type())(key, value, writer)\n\t}\n}\n\nvar quoteEscaper = strings.NewReplacer(\"\\\\\", \"\\\\\\\\\", `\"`, \"\\\\\\\"\")\n\nfunc escapeQuotes(s string) string {\n\treturn quoteEscaper.Replace(s)\n}\n\nfunc (e *encoder) newReaderTypeEncoder() encoderFunc {\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\treader, ok := value.Convert(reflect.TypeOf((*io.Reader)(nil)).Elem()).Interface().(io.Reader)\n\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\t\tfilename := \"anonymous_file\"\n\t\tcontentType := \"application/octet-stream\"\n\t\tif named, ok := reader.(interface{ Filename() string }); ok {\n\t\t\tfilename = named.Filename()\n\t\t} else if named, ok := reader.(interface{ Name() string }); ok {\n\t\t\tfilename = path.Base(named.Name())\n\t\t}\n\t\tif typed, ok := reader.(interface{ ContentType() string }); ok {\n\t\t\tcontentType = typed.ContentType()\n\t\t}\n\n\t\t// Below is taken almost 1-for-1 from [multipart.CreateFormFile]\n\t\th := make(textproto.MIMEHeader)\n\t\th.Set(\"Content-Disposition\", fmt.Sprintf(`form-data; name=\"%s\"; filename=\"%s\"`, escapeQuotes(key), escapeQuotes(filename)))\n\t\th.Set(\"Content-Type\", contentType)\n\t\tfilewriter, err := writer.CreatePart(h)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = io.Copy(filewriter, reader)\n\t\treturn err\n\t}\n}\n\nfunc (e encoder) arrayKeyEncoder() func(string, int) string {\n\tvar keyFn func(string, int) string\n\tswitch e.arrayFmt {\n\tcase \"comma\", \"repeat\":\n\t\tkeyFn = func(k string, _ int) string { return k }\n\tcase \"brackets\":\n\t\tkeyFn = func(key string, _ int) string { return key + \"[]\" }\n\tcase \"indices:dots\":\n\t\tkeyFn = func(k string, i int) string {\n\t\t\tif k == \"\" {\n\t\t\t\treturn strconv.Itoa(i)\n\t\t\t}\n\t\t\treturn k + \".\" + strconv.Itoa(i)\n\t\t}\n\tcase \"indices:brackets\":\n\t\tkeyFn = func(k string, i int) string {\n\t\t\tif k == \"\" {\n\t\t\t\treturn strconv.Itoa(i)\n\t\t\t}\n\t\t\treturn k + \"[\" + strconv.Itoa(i) + \"]\"\n\t\t}\n\t}\n\treturn keyFn\n}\n\nfunc (e encoder) objKeyEncoder(parent string) func(string) string {\n\tif parent == \"\" {\n\t\treturn func(child string) string { return child }\n\t}\n\tswitch e.arrayFmt {\n\tcase \"brackets\":\n\t\treturn func(child string) string { return parent + \"[\" + child + \"]\" }\n\tdefault:\n\t\treturn func(child string) string { return parent + \".\" + child }\n\t}\n}\n\n// Given a []byte of json (may either be an empty object or an object that already contains entries)\n// encode all of the entries in the map to the json byte array.\nfunc (e *encoder) encodeMapEntries(key string, v reflect.Value, writer *multipart.Writer) error {\n\ttype mapPair struct {\n\t\tkey   string\n\t\tvalue reflect.Value\n\t}\n\n\tpairs := []mapPair{}\n\n\titer := v.MapRange()\n\tfor iter.Next() {\n\t\tif iter.Key().Type().Kind() == reflect.String {\n\t\t\tpairs = append(pairs, mapPair{key: iter.Key().String(), value: iter.Value()})\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"cannot encode a map with a non string key\")\n\t\t}\n\t}\n\n\t// Ensure deterministic output\n\tsort.Slice(pairs, func(i, j int) bool {\n\t\treturn pairs[i].key < pairs[j].key\n\t})\n\n\telementEncoder := e.typeEncoder(v.Type().Elem())\n\tkeyFn := e.objKeyEncoder(key)\n\tfor _, p := range pairs {\n\t\terr := elementEncoder(keyFn(p.key), p.value, writer)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (e *encoder) newMapEncoder(_ reflect.Type) encoderFunc {\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\treturn e.encodeMapEntries(key, value, writer)\n\t}\n}\n\nfunc WriteExtras(writer *multipart.Writer, extras map[string]any) (err error) {\n\tfor k, v := range extras {\n\t\tstr, ok := v.(string)\n\t\tif !ok {\n\t\t\tbreak\n\t\t}\n\t\terr = writer.WriteField(k, str)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn err\n}\n"
  },
  {
    "path": "internal/apiform/form.go",
    "content": "package apiform\n\ntype Marshaler interface {\n\tMarshalMultipart() ([]byte, string, error)\n}\n"
  },
  {
    "path": "internal/apiform/form_test.go",
    "content": "package apiform\n\nimport (\n\t\"bytes\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc P[T any](v T) *T { return &v }\n\ntype Primitives struct {\n\tA bool    `form:\"a\"`\n\tB int     `form:\"b\"`\n\tC uint    `form:\"c\"`\n\tD float64 `form:\"d\"`\n\tE float32 `form:\"e\"`\n\tF []int   `form:\"f\"`\n}\n\n// These aliases are necessary to bypass the cache.\n// This only relevant during testing.\ntype int_ int\ntype PrimitivesBrackets struct {\n\tF []int_ `form:\"f\"`\n}\n\ntype PrimitivePointers struct {\n\tA *bool    `form:\"a\"`\n\tB *int     `form:\"b\"`\n\tC *uint    `form:\"c\"`\n\tD *float64 `form:\"d\"`\n\tE *float32 `form:\"e\"`\n\tF *[]int   `form:\"f\"`\n}\n\ntype Slices struct {\n\tSlice []Primitives `form:\"slices\"`\n}\n\ntype DateTime struct {\n\tDate     time.Time `form:\"date\" format:\"date\"`\n\tDateTime time.Time `form:\"date-time\" format:\"date-time\"`\n}\n\ntype AdditionalProperties struct {\n\tA      bool           `form:\"a\"`\n\tExtras map[string]any `form:\"-\" api:\"extrafields\"`\n}\n\ntype TypedAdditionalProperties struct {\n\tA      bool           `form:\"a\"`\n\tExtras map[string]int `form:\"-\" api:\"extrafields\"`\n}\n\ntype EmbeddedStructs struct {\n\tAdditionalProperties\n\tA      *int           `form:\"number2\"`\n\tExtras map[string]any `form:\"-\" api:\"extrafields\"`\n}\n\ntype Recursive struct {\n\tName  string     `form:\"name\"`\n\tChild *Recursive `form:\"child\"`\n}\n\ntype UnknownStruct struct {\n\tUnknown any `form:\"unknown\"`\n}\n\ntype UnionStruct struct {\n\tUnion Union `form:\"union\" format:\"date\"`\n}\n\ntype Union interface {\n\tunion()\n}\n\ntype UnionInteger int64\n\nfunc (UnionInteger) union() {}\n\ntype UnionStructA struct {\n\tType string `form:\"type\"`\n\tA    string `form:\"a\"`\n\tB    string `form:\"b\"`\n}\n\nfunc (UnionStructA) union() {}\n\ntype UnionStructB struct {\n\tType string `form:\"type\"`\n\tA    string `form:\"a\"`\n}\n\nfunc (UnionStructB) union() {}\n\ntype UnionTime time.Time\n\nfunc (UnionTime) union() {}\n\ntype ReaderStruct struct {\n\tFile io.Reader `form:\"file\"`\n}\n\ntype NamedEnum string\n\nconst NamedEnumFoo NamedEnum = \"foo\"\n\ntype StructUnionWrapper struct {\n\tUnion StructUnion `form:\"union\"`\n}\n\ntype StructUnion struct {\n\tOfInt    param.Opt[int64]     `form:\",omitzero,inline\"`\n\tOfString param.Opt[string]    `form:\",omitzero,inline\"`\n\tOfEnum   param.Opt[NamedEnum] `form:\",omitzero,inline\"`\n\tOfA      UnionStructA         `form:\",omitzero,inline\"`\n\tOfB      UnionStructB         `form:\",omitzero,inline\"`\n\tparam.APIUnion\n}\n\ntype MultipartMarshalerParent struct {\n\tMiddle MultipartMarshalerMiddleNext `form:\"middle\"`\n}\n\ntype MultipartMarshalerMiddleNext struct {\n\tMiddleNext MultipartMarshalerMiddle `form:\"middleNext\"`\n}\n\ntype MultipartMarshalerMiddle struct {\n\tChild int `form:\"child\"`\n}\n\nvar tests = map[string]struct {\n\tbuf string\n\tval any\n}{\n\t\"file\": {\n\t\tbuf: `--xxx\nContent-Disposition: form-data; name=\"file\"; filename=\"anonymous_file\"\nContent-Type: application/octet-stream\n\nsome file contents...\n--xxx--\n`,\n\t\tval: ReaderStruct{\n\t\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"some file contents...\"))),\n\t\t},\n\t},\n\t\"map_string\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"foo\"\n\nbar\n--xxx--\n`,\n\t\tmap[string]string{\"foo\": \"bar\"},\n\t},\n\n\t\"map_interface\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"a\"\n\n1\n--xxx\nContent-Disposition: form-data; name=\"b\"\n\nstr\n--xxx\nContent-Disposition: form-data; name=\"c\"\n\nfalse\n--xxx--\n`,\n\t\tmap[string]any{\"a\": float64(1), \"b\": \"str\", \"c\": false},\n\t},\n\n\t\"primitive_struct\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"a\"\n\nfalse\n--xxx\nContent-Disposition: form-data; name=\"b\"\n\n237628372683\n--xxx\nContent-Disposition: form-data; name=\"c\"\n\n654\n--xxx\nContent-Disposition: form-data; name=\"d\"\n\n9999.43\n--xxx\nContent-Disposition: form-data; name=\"e\"\n\n43.76\n--xxx\nContent-Disposition: form-data; name=\"f.0\"\n\n1\n--xxx\nContent-Disposition: form-data; name=\"f.1\"\n\n2\n--xxx\nContent-Disposition: form-data; name=\"f.2\"\n\n3\n--xxx\nContent-Disposition: form-data; name=\"f.3\"\n\n4\n--xxx--\n`,\n\t\tPrimitives{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t},\n\t\"primitive_struct,brackets\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"f[]\"\n\n1\n--xxx\nContent-Disposition: form-data; name=\"f[]\"\n\n2\n--xxx\nContent-Disposition: form-data; name=\"f[]\"\n\n3\n--xxx\nContent-Disposition: form-data; name=\"f[]\"\n\n4\n--xxx--\n`,\n\t\tPrimitivesBrackets{F: []int_{1, 2, 3, 4}},\n\t},\n\n\t\"slices\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"slices.0.a\"\n\nfalse\n--xxx\nContent-Disposition: form-data; name=\"slices.0.b\"\n\n237628372683\n--xxx\nContent-Disposition: form-data; name=\"slices.0.c\"\n\n654\n--xxx\nContent-Disposition: form-data; name=\"slices.0.d\"\n\n9999.43\n--xxx\nContent-Disposition: form-data; name=\"slices.0.e\"\n\n43.76\n--xxx\nContent-Disposition: form-data; name=\"slices.0.f.0\"\n\n1\n--xxx\nContent-Disposition: form-data; name=\"slices.0.f.1\"\n\n2\n--xxx\nContent-Disposition: form-data; name=\"slices.0.f.2\"\n\n3\n--xxx\nContent-Disposition: form-data; name=\"slices.0.f.3\"\n\n4\n--xxx--\n`,\n\t\tSlices{\n\t\t\tSlice: []Primitives{{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}}},\n\t\t},\n\t},\n\t\"primitive_pointer_struct\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"a\"\n\nfalse\n--xxx\nContent-Disposition: form-data; name=\"b\"\n\n237628372683\n--xxx\nContent-Disposition: form-data; name=\"c\"\n\n654\n--xxx\nContent-Disposition: form-data; name=\"d\"\n\n9999.43\n--xxx\nContent-Disposition: form-data; name=\"e\"\n\n43.76\n--xxx\nContent-Disposition: form-data; name=\"f.0\"\n\n1\n--xxx\nContent-Disposition: form-data; name=\"f.1\"\n\n2\n--xxx\nContent-Disposition: form-data; name=\"f.2\"\n\n3\n--xxx\nContent-Disposition: form-data; name=\"f.3\"\n\n4\n--xxx\nContent-Disposition: form-data; name=\"f.4\"\n\n5\n--xxx--\n`,\n\t\tPrimitivePointers{\n\t\t\tA: P(false),\n\t\t\tB: P(237628372683),\n\t\t\tC: P(uint(654)),\n\t\t\tD: P(9999.43),\n\t\t\tE: P(float32(43.76)),\n\t\t\tF: &[]int{1, 2, 3, 4, 5},\n\t\t},\n\t},\n\n\t\"datetime_struct\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"date\"\n\n2006-01-02\n--xxx\nContent-Disposition: form-data; name=\"date-time\"\n\n2006-01-02T15:04:05Z\n--xxx--\n`,\n\t\tDateTime{\n\t\t\tDate:     time.Date(2006, time.January, 2, 0, 0, 0, 0, time.UTC),\n\t\t\tDateTime: time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC),\n\t\t},\n\t},\n\n\t\"additional_properties\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"a\"\n\ntrue\n--xxx\nContent-Disposition: form-data; name=\"bar\"\n\nvalue\n--xxx\nContent-Disposition: form-data; name=\"foo\"\n\ntrue\n--xxx--\n`,\n\t\tAdditionalProperties{\n\t\t\tA: true,\n\t\t\tExtras: map[string]any{\n\t\t\t\t\"bar\": \"value\",\n\t\t\t\t\"foo\": true,\n\t\t\t},\n\t\t},\n\t},\n\t\"recursive_struct,brackets\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"child[name]\"\n\nAlex\n--xxx\nContent-Disposition: form-data; name=\"name\"\n\nRobert\n--xxx--\n`,\n\t\tRecursive{Name: \"Robert\", Child: &Recursive{Name: \"Alex\"}},\n\t},\n\n\t\"recursive_struct\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"child.name\"\n\nAlex\n--xxx\nContent-Disposition: form-data; name=\"name\"\n\nRobert\n--xxx--\n`,\n\t\tRecursive{Name: \"Robert\", Child: &Recursive{Name: \"Alex\"}},\n\t},\n\n\t\"unknown_struct_number\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"unknown\"\n\n12\n--xxx--\n`,\n\t\tUnknownStruct{\n\t\t\tUnknown: 12.,\n\t\t},\n\t},\n\n\t\"unknown_struct_map\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"unknown.foo\"\n\nbar\n--xxx--\n`,\n\t\tUnknownStruct{\n\t\t\tUnknown: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"struct_union_integer\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union\"\n\n12\n--xxx--\n`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfInt: param.NewOpt[int64](12)},\n\t\t},\n\t},\n\n\t\"union_integer\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union\"\n\n12\n--xxx--\n`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionInteger(12),\n\t\t},\n\t},\n\n\t\"struct_union_struct_discriminated_a\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union.a\"\n\nfoo\n--xxx\nContent-Disposition: form-data; name=\"union.b\"\n\nbar\n--xxx\nContent-Disposition: form-data; name=\"union.type\"\n\ntypeA\n--xxx--\n`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfA: UnionStructA{\n\t\t\t\tType: \"typeA\",\n\t\t\t\tA:    \"foo\",\n\t\t\t\tB:    \"bar\",\n\t\t\t}},\n\t\t},\n\t},\n\n\t\"union_struct_discriminated_a\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union.a\"\n\nfoo\n--xxx\nContent-Disposition: form-data; name=\"union.b\"\n\nbar\n--xxx\nContent-Disposition: form-data; name=\"union.type\"\n\ntypeA\n--xxx--\n`,\n\n\t\tUnionStruct{\n\t\t\tUnion: UnionStructA{\n\t\t\t\tType: \"typeA\",\n\t\t\t\tA:    \"foo\",\n\t\t\t\tB:    \"bar\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"struct_union_struct_discriminated_b\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union.a\"\n\nfoo\n--xxx\nContent-Disposition: form-data; name=\"union.type\"\n\ntypeB\n--xxx--\n`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfB: UnionStructB{\n\t\t\t\tType: \"typeB\",\n\t\t\t\tA:    \"foo\",\n\t\t\t}},\n\t\t},\n\t},\n\n\t\"union_struct_discriminated_b\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union.a\"\n\nfoo\n--xxx\nContent-Disposition: form-data; name=\"union.type\"\n\ntypeB\n--xxx--\n`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionStructB{\n\t\t\t\tType: \"typeB\",\n\t\t\t\tA:    \"foo\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"union_struct_time\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"union\"\n\n2010-05-23\n--xxx--\n`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionTime(time.Date(2010, 05, 23, 0, 0, 0, 0, time.UTC)),\n\t\t},\n\t},\n\t\"deeply-nested-struct,brackets\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"middle[middleNext][child]\"\n\n10\n--xxx--\n`,\n\t\tMultipartMarshalerParent{\n\t\t\tMiddle: MultipartMarshalerMiddleNext{\n\t\t\t\tMiddleNext: MultipartMarshalerMiddle{\n\t\t\t\t\tChild: 10,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t\"deeply-nested-map,brackets\": {\n\t\t`--xxx\nContent-Disposition: form-data; name=\"middle[middleNext][child]\"\n\n10\n--xxx--\n`,\n\t\tmap[string]any{\"middle\": map[string]any{\"middleNext\": map[string]any{\"child\": 10}}},\n\t},\n}\n\nfunc TestEncode(t *testing.T) {\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tbuf := bytes.NewBuffer(nil)\n\t\t\twriter := multipart.NewWriter(buf)\n\t\t\terr := writer.SetBoundary(\"xxx\")\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"setting boundary for %v failed with error %v\", test.val, err)\n\t\t\t}\n\n\t\t\tarrayFmt := \"indices:dots\"\n\t\t\tif tags := strings.Split(name, \",\"); len(tags) > 1 {\n\t\t\t\tarrayFmt = tags[1]\n\t\t\t}\n\n\t\t\terr = MarshalWithSettings(test.val, writer, arrayFmt)\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"serialization of %v failed with error %v\", test.val, err)\n\t\t\t}\n\t\t\terr = writer.Close()\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"serialization of %v failed with error %v\", test.val, err)\n\t\t\t}\n\t\t\traw := buf.Bytes()\n\t\t\tif string(raw) != strings.ReplaceAll(test.buf, \"\\n\", \"\\r\\n\") {\n\t\t\t\tt.Errorf(\"expected %+#v to serialize to '%s' but got '%s' (with format %s)\", test.val, test.buf, string(raw), arrayFmt)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "internal/apiform/richparam.go",
    "content": "package apiform\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"mime/multipart\"\n\t\"reflect\"\n)\n\nfunc (e *encoder) newRichFieldTypeEncoder(t reflect.Type) encoderFunc {\n\tf, _ := t.FieldByName(\"Value\")\n\tenc := e.newPrimitiveTypeEncoder(f.Type)\n\treturn func(key string, value reflect.Value, writer *multipart.Writer) error {\n\t\tif opt, ok := value.Interface().(param.Optional); ok && opt.Valid() {\n\t\t\treturn enc(key, value.FieldByIndex(f.Index), writer)\n\t\t} else if ok && param.IsNull(opt) {\n\t\t\treturn writer.WriteField(key, \"null\")\n\t\t}\n\t\treturn nil\n\t}\n}\n"
  },
  {
    "path": "internal/apiform/tag.go",
    "content": "package apiform\n\nimport (\n\t\"reflect\"\n\t\"strings\"\n)\n\nconst apiStructTag = \"api\"\nconst jsonStructTag = \"json\"\nconst formStructTag = \"form\"\nconst formatStructTag = \"format\"\n\ntype parsedStructTag struct {\n\tname     string\n\trequired bool\n\textras   bool\n\tmetadata bool\n\tomitzero bool\n}\n\nfunc parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {\n\traw, ok := field.Tag.Lookup(formStructTag)\n\tif !ok {\n\t\traw, ok = field.Tag.Lookup(jsonStructTag)\n\t}\n\tif !ok {\n\t\treturn tag, ok\n\t}\n\tparts := strings.Split(raw, \",\")\n\tif len(parts) == 0 {\n\t\treturn tag, false\n\t}\n\ttag.name = parts[0]\n\tfor _, part := range parts[1:] {\n\t\tswitch part {\n\t\tcase \"required\":\n\t\t\ttag.required = true\n\t\tcase \"extras\":\n\t\t\ttag.extras = true\n\t\tcase \"metadata\":\n\t\t\ttag.metadata = true\n\t\tcase \"omitzero\":\n\t\t\ttag.omitzero = true\n\t\t}\n\t}\n\n\tparseApiStructTag(field, &tag)\n\treturn tag, ok\n}\n\nfunc parseApiStructTag(field reflect.StructField, tag *parsedStructTag) {\n\traw, ok := field.Tag.Lookup(apiStructTag)\n\tif !ok {\n\t\treturn\n\t}\n\tparts := strings.Split(raw, \",\")\n\tfor _, part := range parts {\n\t\tswitch part {\n\t\tcase \"extrafields\":\n\t\t\ttag.extras = true\n\t\tcase \"required\":\n\t\t\ttag.required = true\n\t\tcase \"metadata\":\n\t\t\ttag.metadata = true\n\t\t}\n\t}\n}\n\nfunc parseFormatStructTag(field reflect.StructField) (format string, ok bool) {\n\tformat, ok = field.Tag.Lookup(formatStructTag)\n\treturn format, ok\n}\n"
  },
  {
    "path": "internal/apijson/decodeparam_test.go",
    "content": "package apijson_test\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc TestOptionalDecoders(t *testing.T) {\n\tcases := map[string]struct {\n\t\tbuf string\n\t\tval any\n\t}{\n\n\t\t\"opt_string_present\": {\n\t\t\t`\"hello\"`,\n\t\t\tparam.NewOpt(\"hello\"),\n\t\t},\n\t\t\"opt_string_empty_present\": {\n\t\t\t`\"\"`,\n\t\t\tparam.NewOpt(\"\"),\n\t\t},\n\t\t\"opt_string_null\": {\n\t\t\t`null`,\n\t\t\tparam.Null[string](),\n\t\t},\n\t\t\"opt_string_null_with_whitespace\": {\n\t\t\t`  null  `,\n\t\t\tparam.Null[string](),\n\t\t},\n\t}\n\n\tfor name, test := range cases {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tresult := reflect.New(reflect.TypeOf(test.val))\n\t\t\tif err := json.Unmarshal([]byte(test.buf), result.Interface()); err != nil {\n\t\t\t\tt.Fatalf(\"deserialization of %v failed with error %v\", result, err)\n\t\t\t}\n\n\t\t\tif !reflect.DeepEqual(result.Elem().Interface(), test.val) {\n\t\t\t\tt.Fatalf(\"expected '%s' to deserialize to \\n%#v\\nbut got\\n%#v\", test.buf, test.val, result.Elem().Interface())\n\t\t\t}\n\t\t})\n\t}\n}\n\ntype paramObject = param.APIObject\n\ntype BasicObject struct {\n\tReqInt    int64   `json:\"req_int\" api:\"required\"`\n\tReqFloat  float64 `json:\"req_float\" api:\"required\"`\n\tReqString string  `json:\"req_string\" api:\"required\"`\n\tReqBool   bool    `json:\"req_bool\" api:\"required\"`\n\n\tOptInt    param.Opt[int64]   `json:\"opt_int\"`\n\tOptFloat  param.Opt[float64] `json:\"opt_float\"`\n\tOptString param.Opt[string]  `json:\"opt_string\"`\n\tOptBool   param.Opt[bool]    `json:\"opt_bool\"`\n\n\tparamObject\n}\n\nfunc (o *BasicObject) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, o) }\n\nfunc TestBasicObjectWithNull(t *testing.T) {\n\traw := `{\"opt_int\":null,\"opt_string\":null,\"opt_bool\":null}`\n\tvar dst BasicObject\n\ttarget := BasicObject{\n\t\tOptInt: param.Null[int64](),\n\t\t// OptFloat:  param.Opt[float64]{},\n\t\tOptString: param.Null[string](),\n\t\tOptBool:   param.Null[bool](),\n\t}\n\n\terr := json.Unmarshal([]byte(raw), &dst)\n\tif err != nil {\n\t\tt.Fatalf(\"failed unmarshal\")\n\t}\n\n\tif !reflect.DeepEqual(dst, target) {\n\t\tt.Fatalf(\"failed equality check %#v\", dst)\n\t}\n}\n\nfunc TestBasicObject(t *testing.T) {\n\traw := `{\"req_int\":1,\"req_float\":1.3,\"req_string\":\"test\",\"req_bool\":true,\"opt_int\":2,\"opt_float\":2.0,\"opt_string\":\"test\",\"opt_bool\":false}`\n\tvar dst BasicObject\n\ttarget := BasicObject{\n\t\tReqInt:    1,\n\t\tReqFloat:  1.3,\n\t\tReqString: \"test\",\n\t\tReqBool:   true,\n\t\tOptInt:    param.NewOpt[int64](2),\n\t\tOptFloat:  param.NewOpt(2.0),\n\t\tOptString: param.NewOpt(\"test\"),\n\t\tOptBool:   param.NewOpt(false),\n\t}\n\n\terr := json.Unmarshal([]byte(raw), &dst)\n\tif err != nil {\n\t\tt.Fatalf(\"failed unmarshal\")\n\t}\n\n\tif !reflect.DeepEqual(dst, target) {\n\t\tt.Fatalf(\"failed equality check %#v\", dst)\n\t}\n}\n\ntype ComplexObject struct {\n\tBasic BasicObject `json:\"basic\" api:\"required\"`\n\tEnum  string      `json:\"enum\"`\n\tparamObject\n}\n\nfunc (o *ComplexObject) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, o) }\n\nfunc init() {\n\tapijson.RegisterFieldValidator[ComplexObject](\"enum\", \"a\", \"b\", \"c\")\n}\n\nfunc TestComplexObject(t *testing.T) {\n\traw := `{\"basic\":{\"req_int\":1,\"req_float\":1.3,\"req_string\":\"test\",\"req_bool\":true,\"opt_int\":2,\"opt_float\":2.0,\"opt_string\":\"test\",\"opt_bool\":false},\"enum\":\"a\"}`\n\tvar dst ComplexObject\n\n\ttarget := ComplexObject{\n\t\tBasic: BasicObject{\n\t\t\tReqInt:    1,\n\t\t\tReqFloat:  1.3,\n\t\t\tReqString: \"test\",\n\t\t\tReqBool:   true,\n\t\t\tOptInt:    param.NewOpt[int64](2),\n\t\t\tOptFloat:  param.NewOpt(2.0),\n\t\t\tOptString: param.NewOpt(\"test\"),\n\t\t\tOptBool:   param.NewOpt(false),\n\t\t},\n\t\tEnum: \"a\",\n\t}\n\n\terr := json.Unmarshal([]byte(raw), &dst)\n\tif err != nil {\n\t\tt.Fatalf(\"failed unmarshal\")\n\t}\n\n\tif !reflect.DeepEqual(dst, target) {\n\t\tt.Fatalf(\"failed equality check %#v\", dst)\n\t}\n}\n\ntype paramUnion = param.APIUnion\n\ntype MemberA struct {\n\tName string `json:\"name\" api:\"required\"`\n\tAge  int    `json:\"age\" api:\"required\"`\n}\n\ntype MemberB struct {\n\tName string `json:\"name\" api:\"required\"`\n\tAge  string `json:\"age\" api:\"required\"`\n}\n\ntype MemberC struct {\n\tName   string `json:\"name\" api:\"required\"`\n\tAge    int    `json:\"age\" api:\"required\"`\n\tStatus string `json:\"status\"`\n}\n\ntype MemberD struct {\n\tCost   int    `json:\"cost\" api:\"required\"`\n\tStatus string `json:\"status\" api:\"required\"`\n}\n\ntype MemberE struct {\n\tCost   int    `json:\"cost\" api:\"required\"`\n\tStatus string `json:\"status\" api:\"required\"`\n}\n\ntype MemberF struct {\n\tD int            `json:\"d\"`\n\tE string         `json:\"e\"`\n\tF float64        `json:\"f\"`\n\tG param.Opt[int] `json:\"g\"`\n}\n\ntype MemberG struct {\n\tD int             `json:\"d\"`\n\tE string          `json:\"e\"`\n\tF float64         `json:\"f\"`\n\tG param.Opt[bool] `json:\"g\"`\n}\n\nfunc init() {\n\tapijson.RegisterFieldValidator[MemberD](\"status\", \"good\", \"ok\", \"bad\")\n\tapijson.RegisterFieldValidator[MemberE](\"status\", \"GOOD\", \"OK\", \"BAD\")\n}\n\ntype UnionStruct struct {\n\tOfMemberA *MemberA          `json:\",inline\"`\n\tOfMemberB *MemberB          `json:\",inline\"`\n\tOfMemberC *MemberC          `json:\",inline\"`\n\tOfMemberD *MemberD          `json:\",inline\"`\n\tOfMemberE *MemberE          `json:\",inline\"`\n\tOfMemberF *MemberF          `json:\",inline\"`\n\tOfMemberG *MemberG          `json:\",inline\"`\n\tOfString  param.Opt[string] `json:\",inline\"`\n\n\tparamUnion\n}\n\nfunc (union *UnionStruct) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, union)\n}\n\nfunc TestUnionStruct(t *testing.T) {\n\ttests := map[string]struct {\n\t\traw        string\n\t\ttarget     UnionStruct\n\t\tshouldFail bool\n\t}{\n\t\t\"fail\": {\n\t\t\traw:        `1200`,\n\t\t\ttarget:     UnionStruct{},\n\t\t\tshouldFail: true,\n\t\t},\n\t\t\"easy\": {\n\t\t\traw:    `{\"age\":30}`,\n\t\t\ttarget: UnionStruct{OfMemberA: &MemberA{Age: 30}},\n\t\t},\n\t\t\"less-easy\": {\n\t\t\traw:    `{\"age\":\"thirty\"}`,\n\t\t\ttarget: UnionStruct{OfMemberB: &MemberB{Age: \"thirty\"}},\n\t\t},\n\t\t\"even-less-easy\": {\n\t\t\traw:    `{\"age\":\"30\"}`,\n\t\t\ttarget: UnionStruct{OfMemberB: &MemberB{Age: \"30\"}},\n\t\t},\n\t\t\"medium\": {\n\t\t\traw: `{\"name\":\"jacob\",\"age\":30}`,\n\t\t\ttarget: UnionStruct{OfMemberA: &MemberA{\n\t\t\t\tAge:  30,\n\t\t\t\tName: \"jacob\",\n\t\t\t}},\n\t\t},\n\t\t\"less-medium\": {\n\t\t\traw: `{\"name\":\"jacob\",\"age\":\"thirty\"}`,\n\t\t\ttarget: UnionStruct{OfMemberB: &MemberB{\n\t\t\t\tAge:  \"thirty\",\n\t\t\t\tName: \"jacob\",\n\t\t\t}},\n\t\t},\n\t\t\"even-less-medium\": {\n\t\t\traw: `{\"name\":\"jacob\",\"age\":\"30\"}`,\n\t\t\ttarget: UnionStruct{OfMemberB: &MemberB{\n\t\t\t\tName: \"jacob\",\n\t\t\t\tAge:  \"30\",\n\t\t\t}},\n\t\t},\n\t\t\"hard\": {\n\t\t\traw: `{\"name\":\"jacob\",\"age\":30,\"status\":\"active\"}`,\n\t\t\ttarget: UnionStruct{OfMemberC: &MemberC{\n\t\t\t\tName:   \"jacob\",\n\t\t\t\tAge:    30,\n\t\t\t\tStatus: \"active\",\n\t\t\t}},\n\t\t},\n\t\t\"inline-string\": {\n\t\t\traw:    `\"hello there\"`,\n\t\t\ttarget: UnionStruct{OfString: param.NewOpt(\"hello there\")},\n\t\t},\n\t\t\"enum-field\": {\n\t\t\traw:    `{\"cost\":100,\"status\":\"ok\"}`,\n\t\t\ttarget: UnionStruct{OfMemberD: &MemberD{Cost: 100, Status: \"ok\"}},\n\t\t},\n\t\t\"other-enum-field\": {\n\t\t\traw:    `{\"cost\":100,\"status\":\"GOOD\"}`,\n\t\t\ttarget: UnionStruct{OfMemberE: &MemberE{Cost: 100, Status: \"GOOD\"}},\n\t\t},\n\t\t\"tricky-extra-fields\": {\n\t\t\traw:    `{\"d\":12,\"e\":\"hello\",\"f\":1.00}`,\n\t\t\ttarget: UnionStruct{OfMemberF: &MemberF{D: 12, E: \"hello\", F: 1.00}},\n\t\t},\n\t\t\"optional-fields\": {\n\t\t\traw:    `{\"d\":12,\"e\":\"hello\",\"f\":1.00,\"g\":12}`,\n\t\t\ttarget: UnionStruct{OfMemberF: &MemberF{D: 12, E: \"hello\", F: 1.00, G: param.NewOpt(12)}},\n\t\t},\n\t\t\"optional-fields-2\": {\n\t\t\traw:    `{\"d\":12,\"e\":\"hello\",\"f\":1.00,\"g\":false}`,\n\t\t\ttarget: UnionStruct{OfMemberG: &MemberG{D: 12, E: \"hello\", F: 1.00, G: param.NewOpt(false)}},\n\t\t},\n\t}\n\n\tfor name, test := range tests {\n\t\tvar dst UnionStruct\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\terr := json.Unmarshal([]byte(test.raw), &dst)\n\t\t\tif err != nil && !test.shouldFail {\n\t\t\t\tt.Fatalf(\"failed unmarshal with err: %v %#v\", err, dst)\n\t\t\t}\n\n\t\t\tif !reflect.DeepEqual(dst, test.target) {\n\t\t\t\tif dst.OfMemberA != nil {\n\t\t\t\t\tfmt.Printf(\"%#v\", dst.OfMemberA)\n\t\t\t\t}\n\t\t\t\tt.Fatalf(\"failed equality, got %#v but expected %#v\", dst, test.target)\n\t\t\t}\n\t\t})\n\t}\n}\n\ntype ConstantA string\ntype ConstantB string\ntype ConstantC string\n\nfunc (c ConstantA) Default() string { return \"A\" }\nfunc (c ConstantB) Default() string { return \"B\" }\nfunc (c ConstantC) Default() string { return \"C\" }\n\ntype DiscVariantA struct {\n\tName string    `json:\"name\" api:\"required\"`\n\tAge  int       `json:\"age\" api:\"required\"`\n\tType ConstantA `json:\"type\" api:\"required\"`\n}\n\ntype DiscVariantB struct {\n\tName string    `json:\"name\" api:\"required\"`\n\tAge  int       `json:\"age\" api:\"required\"`\n\tType ConstantB `json:\"type\" api:\"required\"`\n}\n\ntype DiscVariantC struct {\n\tName string    `json:\"name\" api:\"required\"`\n\tAge  float64   `json:\"age\" api:\"required\"`\n\tType ConstantC `json:\"type\" api:\"required\"`\n}\n\ntype DiscriminatedUnion struct {\n\tOfA *DiscVariantA `json:\",inline\"`\n\tOfB *DiscVariantB `json:\",inline\"`\n\tOfC *DiscVariantC `json:\",inline\"`\n\n\tparamUnion\n}\n\nfunc init() {\n\tapijson.RegisterDiscriminatedUnion[DiscriminatedUnion](\"type\", map[string]reflect.Type{\n\t\t\"A\": reflect.TypeOf(DiscVariantA{}),\n\t\t\"B\": reflect.TypeOf(DiscVariantB{}),\n\t\t\"C\": reflect.TypeOf(DiscVariantC{}),\n\t})\n}\n\ntype FooVariant struct {\n\tType  string `json:\"type\" api:\"required\"`\n\tValue string `json:\"value\" api:\"required\"`\n}\n\ntype BarVariant struct {\n\tType   string `json:\"type\" api:\"required\"`\n\tEnable bool   `json:\"enable\" api:\"required\"`\n}\n\ntype MultiDiscriminatorUnion struct {\n\tOfFoo *FooVariant `json:\",inline\"`\n\tOfBar *BarVariant `json:\",inline\"`\n\n\tparamUnion\n}\n\nfunc init() {\n\tapijson.RegisterDiscriminatedUnion[MultiDiscriminatorUnion](\"type\", map[string]reflect.Type{\n\t\t\"foo\":        reflect.TypeOf(FooVariant{}),\n\t\t\"foo_v2\":     reflect.TypeOf(FooVariant{}),\n\t\t\"bar\":        reflect.TypeOf(BarVariant{}),\n\t\t\"bar_legacy\": reflect.TypeOf(BarVariant{}),\n\t})\n}\n\nfunc (m *MultiDiscriminatorUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, m)\n}\n\nfunc (d *DiscriminatedUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, d)\n}\n\nfunc TestDiscriminatedUnion(t *testing.T) {\n\ttests := map[string]struct {\n\t\traw        string\n\t\ttarget     DiscriminatedUnion\n\t\tshouldFail bool\n\t}{\n\t\t\"variant_a\": {\n\t\t\traw: `{\"name\":\"Alice\",\"age\":25,\"type\":\"A\"}`,\n\t\t\ttarget: DiscriminatedUnion{OfA: &DiscVariantA{\n\t\t\t\tName: \"Alice\",\n\t\t\t\tAge:  25,\n\t\t\t\tType: \"A\",\n\t\t\t}},\n\t\t},\n\t\t\"variant_b\": {\n\t\t\traw: `{\"name\":\"Bob\",\"age\":30,\"type\":\"B\"}`,\n\t\t\ttarget: DiscriminatedUnion{OfB: &DiscVariantB{\n\t\t\t\tName: \"Bob\",\n\t\t\t\tAge:  30,\n\t\t\t\tType: \"B\",\n\t\t\t}},\n\t\t},\n\t\t\"variant_c\": {\n\t\t\traw: `{\"name\":\"Charlie\",\"age\":35.5,\"type\":\"C\"}`,\n\t\t\ttarget: DiscriminatedUnion{OfC: &DiscVariantC{\n\t\t\t\tName: \"Charlie\",\n\t\t\t\tAge:  35.5,\n\t\t\t\tType: \"C\",\n\t\t\t}},\n\t\t},\n\t\t\"invalid_type\": {\n\t\t\traw:        `{\"name\":\"Unknown\",\"age\":40,\"type\":\"D\"}`,\n\t\t\ttarget:     DiscriminatedUnion{},\n\t\t\tshouldFail: true,\n\t\t},\n\t}\n\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tvar dst DiscriminatedUnion\n\t\t\terr := json.Unmarshal([]byte(test.raw), &dst)\n\t\t\tif err != nil && !test.shouldFail {\n\t\t\t\tt.Fatalf(\"failed unmarshal with err: %v\", err)\n\t\t\t}\n\t\t\tif err == nil && test.shouldFail {\n\t\t\t\tt.Fatalf(\"expected unmarshal to fail but it succeeded\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(dst, test.target) {\n\t\t\t\tt.Fatalf(\"failed equality, got %#v but expected %#v\", dst, test.target)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestMultiDiscriminatorUnion(t *testing.T) {\n\ttests := map[string]struct {\n\t\traw        string\n\t\ttarget     MultiDiscriminatorUnion\n\t\tshouldFail bool\n\t}{\n\t\t\"foo_variant\": {\n\t\t\traw: `{\"type\":\"foo\",\"value\":\"test\"}`,\n\t\t\ttarget: MultiDiscriminatorUnion{OfFoo: &FooVariant{\n\t\t\t\tType:  \"foo\",\n\t\t\t\tValue: \"test\",\n\t\t\t}},\n\t\t},\n\t\t\"foo_v2_variant\": {\n\t\t\traw: `{\"type\":\"foo_v2\",\"value\":\"test_v2\"}`,\n\t\t\ttarget: MultiDiscriminatorUnion{OfFoo: &FooVariant{\n\t\t\t\tType:  \"foo_v2\",\n\t\t\t\tValue: \"test_v2\",\n\t\t\t}},\n\t\t},\n\t\t\"bar_variant\": {\n\t\t\traw: `{\"type\":\"bar\",\"enable\":true}`,\n\t\t\ttarget: MultiDiscriminatorUnion{OfBar: &BarVariant{\n\t\t\t\tType:   \"bar\",\n\t\t\t\tEnable: true,\n\t\t\t}},\n\t\t},\n\t\t\"bar_legacy_variant\": {\n\t\t\traw: `{\"type\":\"bar_legacy\",\"enable\":false}`,\n\t\t\ttarget: MultiDiscriminatorUnion{OfBar: &BarVariant{\n\t\t\t\tType:   \"bar_legacy\",\n\t\t\t\tEnable: false,\n\t\t\t}},\n\t\t},\n\t\t\"invalid_type\": {\n\t\t\traw:        `{\"type\":\"unknown\",\"value\":\"test\"}`,\n\t\t\ttarget:     MultiDiscriminatorUnion{},\n\t\t\tshouldFail: true,\n\t\t},\n\t}\n\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tvar dst MultiDiscriminatorUnion\n\t\t\terr := json.Unmarshal([]byte(test.raw), &dst)\n\t\t\tif err != nil && !test.shouldFail {\n\t\t\t\tt.Fatalf(\"failed unmarshal with err: %v\", err)\n\t\t\t}\n\t\t\tif err == nil && test.shouldFail {\n\t\t\t\tt.Fatalf(\"expected unmarshal to fail but it succeeded\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(dst, test.target) {\n\t\t\t\tt.Fatalf(\"failed equality, got %#v but expected %#v\", dst, test.target)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/decoder.go",
    "content": "// The deserialization algorithm from apijson may be subject to improvements\n// between minor versions, particularly with respect to calling [json.Unmarshal]\n// into param unions.\n\npackage apijson\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"sync\"\n\t\"time\"\n\t\"unsafe\"\n\n\t\"github.com/tidwall/gjson\"\n)\n\n// decoders is a synchronized map with roughly the following type:\n// map[reflect.Type]decoderFunc\nvar decoders sync.Map\n\n// Unmarshal is similar to [encoding/json.Unmarshal] and parses the JSON-encoded\n// data and stores it in the given pointer.\nfunc Unmarshal(raw []byte, to any) error {\n\td := &decoderBuilder{dateFormat: time.RFC3339}\n\treturn d.unmarshal(raw, to)\n}\n\n// UnmarshalRoot is like Unmarshal, but doesn't try to call MarshalJSON on the\n// root element. Useful if a struct's UnmarshalJSON is overrode to use the\n// behavior of this encoder versus the standard library.\nfunc UnmarshalRoot(raw []byte, to any) error {\n\td := &decoderBuilder{dateFormat: time.RFC3339, root: true}\n\treturn d.unmarshal(raw, to)\n}\n\n// decoderBuilder contains the 'compile-time' state of the decoder.\ntype decoderBuilder struct {\n\t// Whether or not this is the first element and called by [UnmarshalRoot], see\n\t// the documentation there to see why this is necessary.\n\troot bool\n\t// The dateFormat (a format string for [time.Format]) which is chosen by the\n\t// last struct tag that was seen.\n\tdateFormat string\n}\n\n// decoderState contains the 'run-time' state of the decoder.\ntype decoderState struct {\n\tstrict    bool\n\texactness exactness\n\tvalidator *validationEntry\n}\n\n// Exactness refers to how close to the type the result was if deserialization\n// was successful. This is useful in deserializing unions, where you want to try\n// each entry, first with strict, then with looser validation, without actually\n// having to do a lot of redundant work by marshalling twice (or maybe even more\n// times).\ntype exactness int8\n\nconst (\n\t// Some values had to fudged a bit, for example by converting a string to an\n\t// int, or an enum with extra values.\n\tloose exactness = iota\n\t// There are some extra arguments, but other wise it matches the union.\n\textras\n\t// Exactly right.\n\texact\n)\n\ntype decoderFunc func(node gjson.Result, value reflect.Value, state *decoderState) error\n\ntype decoderField struct {\n\ttag    parsedStructTag\n\tfn     decoderFunc\n\tidx    []int\n\tgoname string\n}\n\ntype decoderEntry struct {\n\treflect.Type\n\tdateFormat string\n\troot       bool\n}\n\nfunc (d *decoderBuilder) unmarshal(raw []byte, to any) error {\n\tvalue := reflect.ValueOf(to).Elem()\n\tresult := gjson.ParseBytes(raw)\n\tif !value.IsValid() {\n\t\treturn fmt.Errorf(\"apijson: cannot marshal into invalid value\")\n\t}\n\treturn d.typeDecoder(value.Type())(result, value, &decoderState{strict: false, exactness: exact})\n}\n\n// unmarshalWithExactness is used for internal testing purposes.\nfunc (d *decoderBuilder) unmarshalWithExactness(raw []byte, to any) (exactness, error) {\n\tvalue := reflect.ValueOf(to).Elem()\n\tresult := gjson.ParseBytes(raw)\n\tif !value.IsValid() {\n\t\treturn 0, fmt.Errorf(\"apijson: cannot marshal into invalid value\")\n\t}\n\tstate := decoderState{strict: false, exactness: exact}\n\terr := d.typeDecoder(value.Type())(result, value, &state)\n\treturn state.exactness, err\n}\n\nfunc (d *decoderBuilder) typeDecoder(t reflect.Type) decoderFunc {\n\tentry := decoderEntry{\n\t\tType:       t,\n\t\tdateFormat: d.dateFormat,\n\t\troot:       d.root,\n\t}\n\n\tif fi, ok := decoders.Load(entry); ok {\n\t\treturn fi.(decoderFunc)\n\t}\n\n\t// To deal with recursive types, populate the map with an\n\t// indirect func before we build it. This type waits on the\n\t// real func (f) to be ready and then calls it. This indirect\n\t// func is only used for recursive types.\n\tvar (\n\t\twg sync.WaitGroup\n\t\tf  decoderFunc\n\t)\n\twg.Add(1)\n\tfi, loaded := decoders.LoadOrStore(entry, decoderFunc(func(node gjson.Result, v reflect.Value, state *decoderState) error {\n\t\twg.Wait()\n\t\treturn f(node, v, state)\n\t}))\n\tif loaded {\n\t\treturn fi.(decoderFunc)\n\t}\n\n\t// Compute the real decoder and replace the indirect func with it.\n\tf = d.newTypeDecoder(t)\n\twg.Done()\n\tdecoders.Store(entry, f)\n\treturn f\n}\n\n// validatedTypeDecoder wraps the type decoder with a validator. This is helpful\n// for ensuring that enum fields are correct.\nfunc (d *decoderBuilder) validatedTypeDecoder(t reflect.Type, entry *validationEntry) decoderFunc {\n\tdec := d.typeDecoder(t)\n\tif entry == nil {\n\t\treturn dec\n\t}\n\n\t// Thread the current validation entry through the decoder,\n\t// but clean up in time for the next field.\n\treturn func(node gjson.Result, v reflect.Value, state *decoderState) error {\n\t\tstate.validator = entry\n\t\terr := dec(node, v, state)\n\t\tstate.validator = nil\n\t\treturn err\n\t}\n}\n\nfunc indirectUnmarshalerDecoder(n gjson.Result, v reflect.Value, state *decoderState) error {\n\treturn v.Addr().Interface().(json.Unmarshaler).UnmarshalJSON([]byte(n.Raw))\n}\n\nfunc unmarshalerDecoder(n gjson.Result, v reflect.Value, state *decoderState) error {\n\tif v.Kind() == reflect.Pointer && v.CanSet() {\n\t\tv.Set(reflect.New(v.Type().Elem()))\n\t}\n\treturn v.Interface().(json.Unmarshaler).UnmarshalJSON([]byte(n.Raw))\n}\n\nfunc (d *decoderBuilder) newTypeDecoder(t reflect.Type) decoderFunc {\n\t// Check for custom decoders first\n\tif customDecoder, ok := customDecoderRegistry[t]; ok {\n\t\t// Create the default decoder for this type (without the custom decoder)\n\t\tdefaultDecoder := d.newDefaultTypeDecoder(t)\n\t\treturn func(node gjson.Result, value reflect.Value, state *decoderState) error {\n\t\t\t// Provide a wrapper that removes the state parameter for the custom decoder\n\t\t\tdefaultWrapper := func(node gjson.Result, value reflect.Value) error {\n\t\t\t\treturn defaultDecoder(node, value, state)\n\t\t\t}\n\t\t\treturn customDecoder(node, value, defaultWrapper)\n\t\t}\n\t}\n\n\treturn d.newDefaultTypeDecoder(t)\n}\n\nfunc (d *decoderBuilder) newDefaultTypeDecoder(t reflect.Type) decoderFunc {\n\tif t.ConvertibleTo(reflect.TypeOf(time.Time{})) {\n\t\treturn d.newTimeTypeDecoder(t)\n\t}\n\n\tif t.Implements(reflect.TypeOf((*param.Optional)(nil)).Elem()) {\n\t\treturn d.newOptTypeDecoder(t)\n\t}\n\n\tif !d.root && t.Implements(reflect.TypeOf((*json.Unmarshaler)(nil)).Elem()) {\n\t\treturn unmarshalerDecoder\n\t}\n\tif !d.root && reflect.PointerTo(t).Implements(reflect.TypeOf((*json.Unmarshaler)(nil)).Elem()) {\n\t\tif _, ok := unionVariants[t]; !ok {\n\t\t\treturn indirectUnmarshalerDecoder\n\t\t}\n\t}\n\td.root = false\n\n\tif _, ok := unionRegistry[t]; ok {\n\t\tif isStructUnion(t) {\n\t\t\treturn d.newStructUnionDecoder(t)\n\t\t}\n\t\treturn d.newUnionDecoder(t)\n\t}\n\n\tswitch t.Kind() {\n\tcase reflect.Pointer:\n\t\tinner := t.Elem()\n\t\tinnerDecoder := d.typeDecoder(inner)\n\n\t\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\tif !v.IsValid() {\n\t\t\t\treturn fmt.Errorf(\"apijson: unexpected invalid reflection value %+#v\", v)\n\t\t\t}\n\n\t\t\tnewValue := reflect.New(inner).Elem()\n\t\t\terr := innerDecoder(n, newValue, state)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tv.Set(newValue.Addr())\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Struct:\n\t\tif isStructUnion(t) {\n\t\t\treturn d.newStructUnionDecoder(t)\n\t\t}\n\t\treturn d.newStructTypeDecoder(t)\n\tcase reflect.Array:\n\t\tfallthrough\n\tcase reflect.Slice:\n\t\treturn d.newArrayTypeDecoder(t)\n\tcase reflect.Map:\n\t\treturn d.newMapDecoder(t)\n\tcase reflect.Interface:\n\t\treturn func(node gjson.Result, value reflect.Value, state *decoderState) error {\n\t\t\tif !value.IsValid() {\n\t\t\t\treturn fmt.Errorf(\"apijson: unexpected invalid value %+#v\", value)\n\t\t\t}\n\t\t\tif node.Value() != nil && value.CanSet() {\n\t\t\t\tvalue.Set(reflect.ValueOf(node.Value()))\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\tdefault:\n\t\treturn d.newPrimitiveTypeDecoder(t)\n\t}\n}\n\nfunc (d *decoderBuilder) newMapDecoder(t reflect.Type) decoderFunc {\n\tkeyType := t.Key()\n\titemType := t.Elem()\n\titemDecoder := d.typeDecoder(itemType)\n\n\treturn func(node gjson.Result, value reflect.Value, state *decoderState) (err error) {\n\t\tmapValue := reflect.MakeMapWithSize(t, len(node.Map()))\n\n\t\tnode.ForEach(func(key, value gjson.Result) bool {\n\t\t\t// It's fine for us to just use `ValueOf` here because the key types will\n\t\t\t// always be primitive types so we don't need to decode it using the standard pattern\n\t\t\tkeyValue := reflect.ValueOf(key.Value())\n\t\t\tif !keyValue.IsValid() {\n\t\t\t\tif err == nil {\n\t\t\t\t\terr = fmt.Errorf(\"apijson: received invalid key type %v\", keyValue.String())\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif keyValue.Type() != keyType {\n\t\t\t\tif err == nil {\n\t\t\t\t\terr = fmt.Errorf(\"apijson: expected key type %v but got %v\", keyType, keyValue.Type())\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\titemValue := reflect.New(itemType).Elem()\n\t\t\titemerr := itemDecoder(value, itemValue, state)\n\t\t\tif itemerr != nil {\n\t\t\t\tif err == nil {\n\t\t\t\t\terr = itemerr\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tmapValue.SetMapIndex(keyValue, itemValue)\n\t\t\treturn true\n\t\t})\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.Set(mapValue)\n\t\treturn nil\n\t}\n}\n\nfunc (d *decoderBuilder) newArrayTypeDecoder(t reflect.Type) decoderFunc {\n\titemDecoder := d.typeDecoder(t.Elem())\n\n\treturn func(node gjson.Result, value reflect.Value, state *decoderState) (err error) {\n\t\tif !node.IsArray() {\n\t\t\treturn fmt.Errorf(\"apijson: could not deserialize to an array\")\n\t\t}\n\n\t\tarrayNode := node.Array()\n\n\t\tarrayValue := reflect.MakeSlice(reflect.SliceOf(t.Elem()), len(arrayNode), len(arrayNode))\n\t\tfor i, itemNode := range arrayNode {\n\t\t\terr = itemDecoder(itemNode, arrayValue.Index(i), state)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tvalue.Set(arrayValue)\n\t\treturn nil\n\t}\n}\n\nfunc (d *decoderBuilder) newStructTypeDecoder(t reflect.Type) decoderFunc {\n\t// map of json field name to struct field decoders\n\tdecoderFields := map[string]decoderField{}\n\tanonymousDecoders := []decoderField{}\n\textraDecoder := (*decoderField)(nil)\n\tvar inlineDecoders []decoderField\n\n\tvalidationEntries := validationRegistry[t]\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tidx := []int{i}\n\t\tfield := t.FieldByIndex(idx)\n\t\tif !field.IsExported() {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar validator *validationEntry\n\t\tfor _, entry := range validationEntries {\n\t\t\tif entry.field.Offset == field.Offset {\n\t\t\t\tvalidator = &entry\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// If this is an embedded struct, traverse one level deeper to extract\n\t\t// the fields and get their encoders as well.\n\t\tif field.Anonymous {\n\t\t\tanonymousDecoders = append(anonymousDecoders, decoderField{\n\t\t\t\tfn:  d.typeDecoder(field.Type),\n\t\t\t\tidx: idx[:],\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\t\t// If json tag is not present, then we skip, which is intentionally\n\t\t// different behavior from the stdlib.\n\t\tptag, ok := parseJSONStructTag(field)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\t// We only want to support unexported fields if they're tagged with\n\t\t// `extras` because that field shouldn't be part of the public API.\n\t\tif ptag.extras {\n\t\t\textraDecoder = &decoderField{ptag, d.typeDecoder(field.Type.Elem()), idx, field.Name}\n\t\t\tcontinue\n\t\t}\n\t\tif ptag.inline {\n\t\t\tdf := decoderField{ptag, d.typeDecoder(field.Type), idx, field.Name}\n\t\t\tinlineDecoders = append(inlineDecoders, df)\n\t\t\tcontinue\n\t\t}\n\t\tif ptag.metadata {\n\t\t\tcontinue\n\t\t}\n\n\t\toldFormat := d.dateFormat\n\t\tdateFormat, ok := parseFormatStructTag(field)\n\t\tif ok {\n\t\t\tswitch dateFormat {\n\t\t\tcase \"date-time\":\n\t\t\t\td.dateFormat = time.RFC3339\n\t\t\tcase \"date\":\n\t\t\t\td.dateFormat = \"2006-01-02\"\n\t\t\t}\n\t\t}\n\n\t\tdecoderFields[ptag.name] = decoderField{\n\t\t\tptag,\n\t\t\td.validatedTypeDecoder(field.Type, validator),\n\t\t\tidx, field.Name,\n\t\t}\n\n\t\td.dateFormat = oldFormat\n\t}\n\n\treturn func(node gjson.Result, value reflect.Value, state *decoderState) (err error) {\n\t\tif field := value.FieldByName(\"JSON\"); field.IsValid() {\n\t\t\tif raw := field.FieldByName(\"raw\"); raw.IsValid() {\n\t\t\t\tsetUnexportedField(raw, node.Raw)\n\t\t\t}\n\t\t}\n\n\t\tfor _, decoder := range anonymousDecoders {\n\t\t\t// ignore errors\n\t\t\t_ = decoder.fn(node, value.FieldByIndex(decoder.idx), state)\n\t\t}\n\n\t\tfor _, inlineDecoder := range inlineDecoders {\n\t\t\tvar meta Field\n\t\t\tdest := value.FieldByIndex(inlineDecoder.idx)\n\t\t\tisValid := false\n\t\t\tif dest.IsValid() && node.Type != gjson.Null {\n\t\t\t\tinlineState := decoderState{exactness: state.exactness, strict: true}\n\t\t\t\terr = inlineDecoder.fn(node, dest, &inlineState)\n\t\t\t\tif err == nil {\n\t\t\t\t\tisValid = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif node.Type == gjson.Null {\n\t\t\t\tmeta = Field{\n\t\t\t\t\traw:    node.Raw,\n\t\t\t\t\tstatus: null,\n\t\t\t\t}\n\t\t\t} else if !isValid {\n\t\t\t\t// If an inline decoder fails, unset the field and move on.\n\t\t\t\tif dest.IsValid() {\n\t\t\t\t\tdest.SetZero()\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t} else if isValid {\n\t\t\t\tmeta = Field{\n\t\t\t\t\traw:    node.Raw,\n\t\t\t\t\tstatus: valid,\n\t\t\t\t}\n\t\t\t}\n\t\t\tsetMetadataSubField(value, inlineDecoder.idx, inlineDecoder.goname, meta)\n\t\t}\n\n\t\ttypedExtraType := reflect.Type(nil)\n\t\ttypedExtraFields := reflect.Value{}\n\t\tif extraDecoder != nil {\n\t\t\ttypedExtraType = value.FieldByIndex(extraDecoder.idx).Type()\n\t\t\ttypedExtraFields = reflect.MakeMap(typedExtraType)\n\t\t}\n\t\tuntypedExtraFields := map[string]Field{}\n\n\t\tfor fieldName, itemNode := range node.Map() {\n\t\t\tdf, explicit := decoderFields[fieldName]\n\t\t\tvar (\n\t\t\t\tdest reflect.Value\n\t\t\t\tfn   decoderFunc\n\t\t\t\tmeta Field\n\t\t\t)\n\t\t\tif explicit {\n\t\t\t\tfn = df.fn\n\t\t\t\tdest = value.FieldByIndex(df.idx)\n\t\t\t}\n\t\t\tif !explicit && extraDecoder != nil {\n\t\t\t\tdest = reflect.New(typedExtraType.Elem()).Elem()\n\t\t\t\tfn = extraDecoder.fn\n\t\t\t}\n\n\t\t\tisValid := false\n\t\t\tif dest.IsValid() && itemNode.Type != gjson.Null {\n\t\t\t\terr = fn(itemNode, dest, state)\n\t\t\t\tif err == nil {\n\t\t\t\t\tisValid = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle null [param.Opt]\n\t\t\tif itemNode.Type == gjson.Null && dest.IsValid() && dest.Type().Implements(reflect.TypeOf((*param.Optional)(nil)).Elem()) {\n\t\t\t\t_ = dest.Addr().Interface().(json.Unmarshaler).UnmarshalJSON([]byte(itemNode.Raw))\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif itemNode.Type == gjson.Null {\n\t\t\t\tmeta = Field{\n\t\t\t\t\traw:    itemNode.Raw,\n\t\t\t\t\tstatus: null,\n\t\t\t\t}\n\t\t\t} else if !isValid {\n\t\t\t\tmeta = Field{\n\t\t\t\t\traw:    itemNode.Raw,\n\t\t\t\t\tstatus: invalid,\n\t\t\t\t}\n\t\t\t} else if isValid {\n\t\t\t\tmeta = Field{\n\t\t\t\t\traw:    itemNode.Raw,\n\t\t\t\t\tstatus: valid,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif explicit {\n\t\t\t\tsetMetadataSubField(value, df.idx, df.goname, meta)\n\t\t\t}\n\t\t\tif !explicit {\n\t\t\t\tuntypedExtraFields[fieldName] = meta\n\t\t\t}\n\t\t\tif !explicit && extraDecoder != nil {\n\t\t\t\ttypedExtraFields.SetMapIndex(reflect.ValueOf(fieldName), dest)\n\t\t\t}\n\t\t}\n\n\t\tif extraDecoder != nil && typedExtraFields.Len() > 0 {\n\t\t\tvalue.FieldByIndex(extraDecoder.idx).Set(typedExtraFields)\n\t\t}\n\n\t\t// Set exactness to 'extras' if there are untyped, extra fields.\n\t\tif len(untypedExtraFields) > 0 && state.exactness > extras {\n\t\t\tstate.exactness = extras\n\t\t}\n\n\t\tif len(untypedExtraFields) > 0 {\n\t\t\tsetMetadataExtraFields(value, []int{-1}, \"ExtraFields\", untypedExtraFields)\n\t\t}\n\t\treturn nil\n\t}\n}\n\nfunc (d *decoderBuilder) newPrimitiveTypeDecoder(t reflect.Type) decoderFunc {\n\tswitch t.Kind() {\n\tcase reflect.String:\n\t\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\tv.SetString(n.String())\n\t\t\tif guardStrict(state, n.Type != gjson.String) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse string strictly\")\n\t\t\t}\n\t\t\t// Everything that is not an object can be loosely stringified.\n\t\t\tif n.Type == gjson.JSON {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse string\")\n\t\t\t}\n\n\t\t\tstate.validateString(v)\n\n\t\t\tif guardUnknown(state, v) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed string enum validation\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Bool:\n\t\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\tv.SetBool(n.Bool())\n\t\t\tif guardStrict(state, n.Type != gjson.True && n.Type != gjson.False) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse bool strictly\")\n\t\t\t}\n\t\t\t// Numbers and strings that are either 'true' or 'false' can be loosely\n\t\t\t// deserialized as bool.\n\t\t\tif n.Type == gjson.String && (n.Raw != \"true\" && n.Raw != \"false\") || n.Type == gjson.JSON {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse bool\")\n\t\t\t}\n\n\t\t\tstate.validateBool(v)\n\n\t\t\tif guardUnknown(state, v) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed bool enum validation\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\tv.SetInt(n.Int())\n\t\t\tif guardStrict(state, n.Type != gjson.Number || n.Num != float64(int(n.Num))) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse int strictly\")\n\t\t\t}\n\t\t\t// Numbers, booleans, and strings that maybe look like numbers can be\n\t\t\t// loosely deserialized as numbers.\n\t\t\tif n.Type == gjson.JSON || (n.Type == gjson.String && !canParseAsNumber(n.Str)) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse int\")\n\t\t\t}\n\n\t\t\tstate.validateInt(v)\n\n\t\t\tif guardUnknown(state, v) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed int enum validation\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\tv.SetUint(n.Uint())\n\t\t\tif guardStrict(state, n.Type != gjson.Number || n.Num != float64(int(n.Num)) || n.Num < 0) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse uint strictly\")\n\t\t\t}\n\t\t\t// Numbers, booleans, and strings that maybe look like numbers can be\n\t\t\t// loosely deserialized as uint.\n\t\t\tif n.Type == gjson.JSON || (n.Type == gjson.String && !canParseAsNumber(n.Str)) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse uint\")\n\t\t\t}\n\t\t\tif guardUnknown(state, v) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed uint enum validation\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\tv.SetFloat(n.Float())\n\t\t\tif guardStrict(state, n.Type != gjson.Number) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse float strictly\")\n\t\t\t}\n\t\t\t// Numbers, booleans, and strings that maybe look like numbers can be\n\t\t\t// loosely deserialized as floats.\n\t\t\tif n.Type == gjson.JSON || (n.Type == gjson.String && !canParseAsNumber(n.Str)) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed to parse float\")\n\t\t\t}\n\t\t\tif guardUnknown(state, v) {\n\t\t\t\treturn fmt.Errorf(\"apijson: failed float enum validation\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\tdefault:\n\t\treturn func(node gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t\treturn fmt.Errorf(\"unknown type received at primitive decoder: %s\", t.String())\n\t\t}\n\t}\n}\n\nfunc (d *decoderBuilder) newOptTypeDecoder(t reflect.Type) decoderFunc {\n\tfor t.Kind() == reflect.Pointer {\n\t\tt = t.Elem()\n\t}\n\tvalueField, _ := t.FieldByName(\"Value\")\n\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\tstate.validateOptKind(n, valueField.Type)\n\t\treturn v.Addr().Interface().(json.Unmarshaler).UnmarshalJSON([]byte(n.Raw))\n\t}\n}\n\nfunc (d *decoderBuilder) newTimeTypeDecoder(t reflect.Type) decoderFunc {\n\tformat := d.dateFormat\n\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\tparsed, err := time.Parse(format, n.Str)\n\t\tif err == nil {\n\t\t\tv.Set(reflect.ValueOf(parsed).Convert(t))\n\t\t\treturn nil\n\t\t}\n\n\t\tif guardStrict(state, true) {\n\t\t\treturn err\n\t\t}\n\n\t\tlayouts := []string{\n\t\t\t\"2006-01-02\",\n\t\t\t\"2006-01-02T15:04:05Z07:00\",\n\t\t\t\"2006-01-02T15:04:05Z0700\",\n\t\t\t\"2006-01-02T15:04:05\",\n\t\t\t\"2006-01-02 15:04:05Z07:00\",\n\t\t\t\"2006-01-02 15:04:05Z0700\",\n\t\t\t\"2006-01-02 15:04:05\",\n\t\t}\n\n\t\tfor _, layout := range layouts {\n\t\t\tparsed, err := time.Parse(layout, n.Str)\n\t\t\tif err == nil {\n\t\t\t\tv.Set(reflect.ValueOf(parsed).Convert(t))\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\treturn fmt.Errorf(\"unable to leniently parse date-time string: %s\", n.Str)\n\t}\n}\n\nfunc setUnexportedField(field reflect.Value, value any) {\n\treflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Set(reflect.ValueOf(value))\n}\n\nfunc guardStrict(state *decoderState, cond bool) bool {\n\tif !cond {\n\t\treturn false\n\t}\n\n\tif state.strict {\n\t\treturn true\n\t}\n\n\tstate.exactness = loose\n\treturn false\n}\n\nfunc canParseAsNumber(str string) bool {\n\t_, err := strconv.ParseFloat(str, 64)\n\treturn err == nil\n}\n\nvar stringType = reflect.TypeOf(string(\"\"))\n\nfunc guardUnknown(state *decoderState, v reflect.Value) bool {\n\tif have, ok := v.Interface().(interface{ IsKnown() bool }); guardStrict(state, ok && !have.IsKnown()) {\n\t\treturn true\n\t}\n\n\tconstantString, ok := v.Interface().(interface{ Default() string })\n\tnamed := v.Type() != stringType\n\treturn guardStrict(state, ok && named && v.Equal(reflect.ValueOf(constantString.Default())))\n}\n"
  },
  {
    "path": "internal/apijson/decoderesp_test.go",
    "content": "package apijson_test\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"testing\"\n)\n\ntype StructWithNullExtraField struct {\n\tResults []string `json:\"results\" api:\"required\"`\n\tJSON    struct {\n\t\tResults     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\nfunc (r *StructWithNullExtraField) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc TestDecodeWithNullExtraField(t *testing.T) {\n\traw := `{\"something_else\":null}`\n\tvar dst *StructWithNullExtraField\n\terr := json.Unmarshal([]byte(raw), &dst)\n\tif err != nil {\n\t\tt.Fatalf(\"error: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/encoder.go",
    "content": "package apijson\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/tidwall/sjson\"\n)\n\nvar encoders sync.Map // map[encoderEntry]encoderFunc\n\n// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have\n// special characters that sjson interprets as a path.\nvar EscapeSJSONKey = strings.NewReplacer(\"\\\\\", \"\\\\\\\\\", \"|\", \"\\\\|\", \"#\", \"\\\\#\", \"@\", \"\\\\@\", \"*\", \"\\\\*\", \".\", \"\\\\.\", \":\", \"\\\\:\", \"?\", \"\\\\?\").Replace\n\nfunc Marshal(value any) ([]byte, error) {\n\te := &encoder{dateFormat: time.RFC3339}\n\treturn e.marshal(value)\n}\n\nfunc MarshalRoot(value any) ([]byte, error) {\n\te := &encoder{root: true, dateFormat: time.RFC3339}\n\treturn e.marshal(value)\n}\n\ntype encoder struct {\n\tdateFormat string\n\troot       bool\n}\n\ntype encoderFunc func(value reflect.Value) ([]byte, error)\n\ntype encoderField struct {\n\ttag parsedStructTag\n\tfn  encoderFunc\n\tidx []int\n}\n\ntype encoderEntry struct {\n\treflect.Type\n\tdateFormat string\n\troot       bool\n}\n\nfunc (e *encoder) marshal(value any) ([]byte, error) {\n\tval := reflect.ValueOf(value)\n\tif !val.IsValid() {\n\t\treturn nil, nil\n\t}\n\ttyp := val.Type()\n\tenc := e.typeEncoder(typ)\n\treturn enc(val)\n}\n\nfunc (e *encoder) typeEncoder(t reflect.Type) encoderFunc {\n\tentry := encoderEntry{\n\t\tType:       t,\n\t\tdateFormat: e.dateFormat,\n\t\troot:       e.root,\n\t}\n\n\tif fi, ok := encoders.Load(entry); ok {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// To deal with recursive types, populate the map with an\n\t// indirect func before we build it. This type waits on the\n\t// real func (f) to be ready and then calls it. This indirect\n\t// func is only used for recursive types.\n\tvar (\n\t\twg sync.WaitGroup\n\t\tf  encoderFunc\n\t)\n\twg.Add(1)\n\tfi, loaded := encoders.LoadOrStore(entry, encoderFunc(func(v reflect.Value) ([]byte, error) {\n\t\twg.Wait()\n\t\treturn f(v)\n\t}))\n\tif loaded {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// Compute the real encoder and replace the indirect func with it.\n\tf = e.newTypeEncoder(t)\n\twg.Done()\n\tencoders.Store(entry, f)\n\treturn f\n}\n\nfunc marshalerEncoder(v reflect.Value) ([]byte, error) {\n\treturn v.Interface().(json.Marshaler).MarshalJSON()\n}\n\nfunc indirectMarshalerEncoder(v reflect.Value) ([]byte, error) {\n\treturn v.Addr().Interface().(json.Marshaler).MarshalJSON()\n}\n\nfunc (e *encoder) newTypeEncoder(t reflect.Type) encoderFunc {\n\tif t.ConvertibleTo(reflect.TypeOf(time.Time{})) {\n\t\treturn e.newTimeTypeEncoder()\n\t}\n\tif !e.root && t.Implements(reflect.TypeOf((*json.Marshaler)(nil)).Elem()) {\n\t\treturn marshalerEncoder\n\t}\n\tif !e.root && reflect.PointerTo(t).Implements(reflect.TypeOf((*json.Marshaler)(nil)).Elem()) {\n\t\treturn indirectMarshalerEncoder\n\t}\n\te.root = false\n\tswitch t.Kind() {\n\tcase reflect.Pointer:\n\t\tinner := t.Elem()\n\n\t\tinnerEncoder := e.typeEncoder(inner)\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\tif !v.IsValid() || v.IsNil() {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\treturn innerEncoder(v.Elem())\n\t\t}\n\tcase reflect.Struct:\n\t\treturn e.newStructTypeEncoder(t)\n\tcase reflect.Array:\n\t\tfallthrough\n\tcase reflect.Slice:\n\t\treturn e.newArrayTypeEncoder(t)\n\tcase reflect.Map:\n\t\treturn e.newMapEncoder(t)\n\tcase reflect.Interface:\n\t\treturn e.newInterfaceEncoder()\n\tdefault:\n\t\treturn e.newPrimitiveTypeEncoder(t)\n\t}\n}\n\nfunc (e *encoder) newPrimitiveTypeEncoder(t reflect.Type) encoderFunc {\n\tswitch t.Kind() {\n\t// Note that we could use `gjson` to encode these types but it would complicate our\n\t// code more and this current code shouldn't cause any issues\n\tcase reflect.String:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\treturn json.Marshal(v.Interface())\n\t\t}\n\tcase reflect.Bool:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\tif v.Bool() {\n\t\t\t\treturn []byte(\"true\"), nil\n\t\t\t}\n\t\t\treturn []byte(\"false\"), nil\n\t\t}\n\tcase reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\treturn []byte(strconv.FormatInt(v.Int(), 10)), nil\n\t\t}\n\tcase reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\treturn []byte(strconv.FormatUint(v.Uint(), 10)), nil\n\t\t}\n\tcase reflect.Float32:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\treturn []byte(strconv.FormatFloat(v.Float(), 'f', -1, 32)), nil\n\t\t}\n\tcase reflect.Float64:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\treturn []byte(strconv.FormatFloat(v.Float(), 'f', -1, 64)), nil\n\t\t}\n\tdefault:\n\t\treturn func(v reflect.Value) ([]byte, error) {\n\t\t\treturn nil, fmt.Errorf(\"unknown type received at primitive encoder: %s\", t.String())\n\t\t}\n\t}\n}\n\nfunc (e *encoder) newArrayTypeEncoder(t reflect.Type) encoderFunc {\n\titemEncoder := e.typeEncoder(t.Elem())\n\n\treturn func(value reflect.Value) ([]byte, error) {\n\t\tjson := []byte(\"[]\")\n\t\tfor i := 0; i < value.Len(); i++ {\n\t\t\tvar value, err = itemEncoder(value.Index(i))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif value == nil {\n\t\t\t\t// Assume that empty items should be inserted as `null` so that the output array\n\t\t\t\t// will be the same length as the input array\n\t\t\t\tvalue = []byte(\"null\")\n\t\t\t}\n\n\t\t\tjson, err = sjson.SetRawBytes(json, \"-1\", value)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\treturn json, nil\n\t}\n}\n\nfunc (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc {\n\tencoderFields := []encoderField{}\n\textraEncoder := (*encoderField)(nil)\n\n\t// This helper allows us to recursively collect field encoders into a flat\n\t// array. The parameter `index` keeps track of the access patterns necessary\n\t// to get to some field.\n\tvar collectEncoderFields func(r reflect.Type, index []int)\n\tcollectEncoderFields = func(r reflect.Type, index []int) {\n\t\tfor i := 0; i < r.NumField(); i++ {\n\t\t\tidx := append(index, i)\n\t\t\tfield := t.FieldByIndex(idx)\n\t\t\tif !field.IsExported() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If this is an embedded struct, traverse one level deeper to extract\n\t\t\t// the field and get their encoders as well.\n\t\t\tif field.Anonymous {\n\t\t\t\tcollectEncoderFields(field.Type, idx)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If json tag is not present, then we skip, which is intentionally\n\t\t\t// different behavior from the stdlib.\n\t\t\tptag, ok := parseJSONStructTag(field)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// We only want to support unexported field if they're tagged with\n\t\t\t// `extras` because that field shouldn't be part of the public API. We\n\t\t\t// also want to only keep the top level extras\n\t\t\tif ptag.extras && len(index) == 0 {\n\t\t\t\textraEncoder = &encoderField{ptag, e.typeEncoder(field.Type.Elem()), idx}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ptag.name == \"-\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdateFormat, ok := parseFormatStructTag(field)\n\t\t\toldFormat := e.dateFormat\n\t\t\tif ok {\n\t\t\t\tswitch dateFormat {\n\t\t\t\tcase \"date-time\":\n\t\t\t\t\te.dateFormat = time.RFC3339\n\t\t\t\tcase \"date\":\n\t\t\t\t\te.dateFormat = \"2006-01-02\"\n\t\t\t\t}\n\t\t\t}\n\t\t\tencoderFields = append(encoderFields, encoderField{ptag, e.typeEncoder(field.Type), idx})\n\t\t\te.dateFormat = oldFormat\n\t\t}\n\t}\n\tcollectEncoderFields(t, []int{})\n\n\t// Ensure deterministic output by sorting by lexicographic order\n\tsort.Slice(encoderFields, func(i, j int) bool {\n\t\treturn encoderFields[i].tag.name < encoderFields[j].tag.name\n\t})\n\n\treturn func(value reflect.Value) (json []byte, err error) {\n\t\tjson = []byte(\"{}\")\n\n\t\tfor _, ef := range encoderFields {\n\t\t\tfield := value.FieldByIndex(ef.idx)\n\t\t\tencoded, err := ef.fn(field)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif encoded == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tjson, err = sjson.SetRawBytes(json, EscapeSJSONKey(ef.tag.name), encoded)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\tif extraEncoder != nil {\n\t\t\tjson, err = e.encodeMapEntries(json, value.FieldByIndex(extraEncoder.idx))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn json, err\n\t}\n}\n\nfunc (e *encoder) newTimeTypeEncoder() encoderFunc {\n\tformat := e.dateFormat\n\treturn func(value reflect.Value) (json []byte, err error) {\n\t\treturn []byte(`\"` + value.Convert(reflect.TypeOf(time.Time{})).Interface().(time.Time).Format(format) + `\"`), nil\n\t}\n}\n\nfunc (e encoder) newInterfaceEncoder() encoderFunc {\n\treturn func(value reflect.Value) ([]byte, error) {\n\t\tvalue = value.Elem()\n\t\tif !value.IsValid() {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn e.typeEncoder(value.Type())(value)\n\t}\n}\n\n// Given a []byte of json (may either be an empty object or an object that already contains entries)\n// encode all of the entries in the map to the json byte array.\nfunc (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error) {\n\ttype mapPair struct {\n\t\tkey   []byte\n\t\tvalue reflect.Value\n\t}\n\n\tpairs := []mapPair{}\n\tkeyEncoder := e.typeEncoder(v.Type().Key())\n\n\titer := v.MapRange()\n\tfor iter.Next() {\n\t\tvar encodedKeyString string\n\t\tif iter.Key().Type().Kind() == reflect.String {\n\t\t\tencodedKeyString = iter.Key().String()\n\t\t} else {\n\t\t\tvar err error\n\t\t\tencodedKeyBytes, err := keyEncoder(iter.Key())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tencodedKeyString = string(encodedKeyBytes)\n\t\t}\n\t\tencodedKey := []byte(encodedKeyString)\n\t\tpairs = append(pairs, mapPair{key: encodedKey, value: iter.Value()})\n\t}\n\n\t// Ensure deterministic output\n\tsort.Slice(pairs, func(i, j int) bool {\n\t\treturn bytes.Compare(pairs[i].key, pairs[j].key) < 0\n\t})\n\n\telementEncoder := e.typeEncoder(v.Type().Elem())\n\tfor _, p := range pairs {\n\t\tencodedValue, err := elementEncoder(p.value)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif len(encodedValue) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tjson, err = sjson.SetRawBytes(json, EscapeSJSONKey(string(p.key)), encodedValue)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn json, nil\n}\n\nfunc (e *encoder) newMapEncoder(_ reflect.Type) encoderFunc {\n\treturn func(value reflect.Value) ([]byte, error) {\n\t\tjson := []byte(\"{}\")\n\t\tvar err error\n\t\tjson, err = e.encodeMapEntries(json, value)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn json, nil\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/enum.go",
    "content": "package apijson\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\t\"slices\"\n\n\t\"github.com/tidwall/gjson\"\n)\n\n/********************/\n/* Validating Enums */\n/********************/\n\ntype validationEntry struct {\n\tfield       reflect.StructField\n\tlegalValues struct {\n\t\tstrings []string\n\t\t// 1 represents true, 0 represents false, -1 represents either\n\t\tbools int\n\t\tints  []int64\n\t}\n}\n\nvar validationRegistry = map[reflect.Type][]validationEntry{}\n\nfunc RegisterFieldValidator[T any, V string | bool | int | float64](fieldName string, values ...V) {\n\tvar t T\n\tparentType := reflect.TypeOf(t)\n\n\tif _, ok := validationRegistry[parentType]; !ok {\n\t\tvalidationRegistry[parentType] = []validationEntry{}\n\t}\n\n\t// The following checks run at initialization time,\n\t// it is impossible for them to panic if any tests pass.\n\tif parentType.Kind() != reflect.Struct {\n\t\tpanic(fmt.Sprintf(\"apijson: cannot initialize validator for non-struct %s\", parentType.String()))\n\t}\n\n\tvar field reflect.StructField\n\tfound := false\n\tfor i := 0; i < parentType.NumField(); i++ {\n\t\tptag, ok := parseJSONStructTag(parentType.Field(i))\n\t\tif ok && ptag.name == fieldName {\n\t\t\tfield = parentType.Field(i)\n\t\t\tfound = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !found {\n\t\tpanic(fmt.Sprintf(\"apijson: cannot find field %s in struct %s\", fieldName, parentType.String()))\n\t}\n\n\tnewEntry := validationEntry{field: field}\n\tnewEntry.legalValues.bools = -1 // default to either\n\n\tswitch values := any(values).(type) {\n\tcase []string:\n\t\tnewEntry.legalValues.strings = values\n\tcase []int:\n\t\tnewEntry.legalValues.ints = make([]int64, len(values))\n\t\tfor i, value := range values {\n\t\t\tnewEntry.legalValues.ints[i] = int64(value)\n\t\t}\n\tcase []bool:\n\t\tfor i, value := range values {\n\t\t\tvar next int\n\t\t\tif value {\n\t\t\t\tnext = 1\n\t\t\t}\n\t\t\tif i > 0 && newEntry.legalValues.bools != next {\n\t\t\t\tnewEntry.legalValues.bools = -1 // accept either\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tnewEntry.legalValues.bools = next\n\t\t}\n\t}\n\n\t// Store the information necessary to create a validator, so that we can use it\n\t// lazily create the validator function when did.\n\tvalidationRegistry[parentType] = append(validationRegistry[parentType], newEntry)\n}\n\nfunc (state *decoderState) validateString(v reflect.Value) {\n\tif state.validator == nil {\n\t\treturn\n\t}\n\tif !slices.Contains(state.validator.legalValues.strings, v.String()) {\n\t\tstate.exactness = loose\n\t}\n}\n\nfunc (state *decoderState) validateInt(v reflect.Value) {\n\tif state.validator == nil {\n\t\treturn\n\t}\n\tif !slices.Contains(state.validator.legalValues.ints, v.Int()) {\n\t\tstate.exactness = loose\n\t}\n}\n\nfunc (state *decoderState) validateBool(v reflect.Value) {\n\tif state.validator == nil {\n\t\treturn\n\t}\n\tb := v.Bool()\n\tif state.validator.legalValues.bools == 1 && !b {\n\t\tstate.exactness = loose\n\t} else if state.validator.legalValues.bools == 0 && b {\n\t\tstate.exactness = loose\n\t}\n}\n\nfunc (state *decoderState) validateOptKind(node gjson.Result, t reflect.Type) {\n\tswitch node.Type {\n\tcase gjson.JSON:\n\t\tstate.exactness = loose\n\tcase gjson.Null:\n\t\treturn\n\tcase gjson.False, gjson.True:\n\t\tif t.Kind() != reflect.Bool {\n\t\t\tstate.exactness = loose\n\t\t}\n\tcase gjson.Number:\n\t\tswitch t.Kind() {\n\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,\n\t\t\treflect.Float32, reflect.Float64:\n\t\t\treturn\n\t\tdefault:\n\t\t\tstate.exactness = loose\n\t\t}\n\tcase gjson.String:\n\t\tif t.Kind() != reflect.String {\n\t\t\tstate.exactness = loose\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/enum_test.go",
    "content": "package apijson\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\ntype EnumStruct struct {\n\tNormalString string        `json:\"normal_string\"`\n\tStringEnum   string        `json:\"string_enum\"`\n\tNamedEnum    NamedEnumType `json:\"named_enum\"`\n\n\tIntEnum  int  `json:\"int_enum\"`\n\tBoolEnum bool `json:\"bool_enum\"`\n\n\tWeirdBoolEnum bool `json:\"weird_bool_enum\"`\n}\n\nfunc (o *EnumStruct) UnmarshalJSON(data []byte) error {\n\treturn UnmarshalRoot(data, o)\n}\n\nfunc init() {\n\tRegisterFieldValidator[EnumStruct](\"string_enum\", \"one\", \"two\", \"three\")\n\tRegisterFieldValidator[EnumStruct](\"int_enum\", 200, 404)\n\tRegisterFieldValidator[EnumStruct](\"bool_enum\", false)\n\tRegisterFieldValidator[EnumStruct](\"weird_bool_enum\", true, false)\n}\n\ntype NamedEnumType string\n\nconst (\n\tNamedEnumOne   NamedEnumType = \"one\"\n\tNamedEnumTwo   NamedEnumType = \"two\"\n\tNamedEnumThree NamedEnumType = \"three\"\n)\n\nfunc (e NamedEnumType) IsKnown() bool {\n\treturn e == NamedEnumOne || e == NamedEnumTwo || e == NamedEnumThree\n}\n\nfunc TestEnumStructStringValidator(t *testing.T) {\n\tcases := map[string]struct {\n\t\texactness\n\t\tEnumStruct\n\t}{\n\t\t`{\"string_enum\":\"one\"}`:     {exact, EnumStruct{StringEnum: \"one\"}},\n\t\t`{\"string_enum\":\"two\"}`:     {exact, EnumStruct{StringEnum: \"two\"}},\n\t\t`{\"string_enum\":\"three\"}`:   {exact, EnumStruct{StringEnum: \"three\"}},\n\t\t`{\"string_enum\":\"none\"}`:    {loose, EnumStruct{StringEnum: \"none\"}},\n\t\t`{\"int_enum\":200}`:          {exact, EnumStruct{IntEnum: 200}},\n\t\t`{\"int_enum\":404}`:          {exact, EnumStruct{IntEnum: 404}},\n\t\t`{\"int_enum\":500}`:          {loose, EnumStruct{IntEnum: 500}},\n\t\t`{\"bool_enum\":false}`:       {exact, EnumStruct{BoolEnum: false}},\n\t\t`{\"bool_enum\":true}`:        {loose, EnumStruct{BoolEnum: true}},\n\t\t`{\"weird_bool_enum\":true}`:  {exact, EnumStruct{WeirdBoolEnum: true}},\n\t\t`{\"weird_bool_enum\":false}`: {exact, EnumStruct{WeirdBoolEnum: false}},\n\n\t\t`{\"named_enum\":\"one\"}`:  {exact, EnumStruct{NamedEnum: NamedEnumOne}},\n\t\t`{\"named_enum\":\"none\"}`: {loose, EnumStruct{NamedEnum: \"none\"}},\n\n\t\t`{\"string_enum\":\"one\",\"named_enum\":\"one\"}`: {exact, EnumStruct{NamedEnum: \"one\", StringEnum: \"one\"}},\n\t\t`{\"string_enum\":\"four\",\"named_enum\":\"one\"}`: {\n\t\t\tloose,\n\t\t\tEnumStruct{NamedEnum: \"one\", StringEnum: \"four\"},\n\t\t},\n\t\t`{\"string_enum\":\"one\",\"named_enum\":\"four\"}`: {\n\t\t\tloose, EnumStruct{NamedEnum: \"four\", StringEnum: \"one\"},\n\t\t},\n\t\t`{\"wrong_key\":\"one\"}`: {extras, EnumStruct{StringEnum: \"\"}},\n\t}\n\n\tfor raw, expected := range cases {\n\t\tvar dst EnumStruct\n\n\t\tdec := decoderBuilder{root: true}\n\t\texactness, _ := dec.unmarshalWithExactness([]byte(raw), &dst)\n\n\t\tif !reflect.DeepEqual(dst, expected.EnumStruct) {\n\t\t\tt.Fatalf(\"failed equality check %#v\", dst)\n\t\t}\n\n\t\tif exactness != expected.exactness {\n\t\t\tt.Fatalf(\"exactness got %d expected %d %s\", exactness, expected.exactness, raw)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/field.go",
    "content": "package apijson\n\ntype status uint8\n\nconst (\n\tmissing status = iota\n\tnull\n\tinvalid\n\tvalid\n)\n\ntype Field struct {\n\traw    string\n\tstatus status\n}\n\n// Returns true if the field is explicitly `null` _or_ if it is not present at all (ie, missing).\n// To check if the field's key is present in the JSON with an explicit null value,\n// you must check `f.IsNull() && !f.IsMissing()`.\nfunc (j Field) IsNull() bool    { return j.status <= null }\nfunc (j Field) IsMissing() bool { return j.status == missing }\nfunc (j Field) IsInvalid() bool { return j.status == invalid }\nfunc (j Field) Raw() string     { return j.raw }\n"
  },
  {
    "path": "internal/apijson/json_test.go",
    "content": "package apijson\n\nimport (\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/tidwall/gjson\"\n)\n\nfunc P[T any](v T) *T { return &v }\n\ntype Primitives struct {\n\tA bool    `json:\"a\"`\n\tB int     `json:\"b\"`\n\tC uint    `json:\"c\"`\n\tD float64 `json:\"d\"`\n\tE float32 `json:\"e\"`\n\tF []int   `json:\"f\"`\n}\n\ntype PrimitivePointers struct {\n\tA *bool    `json:\"a\"`\n\tB *int     `json:\"b\"`\n\tC *uint    `json:\"c\"`\n\tD *float64 `json:\"d\"`\n\tE *float32 `json:\"e\"`\n\tF *[]int   `json:\"f\"`\n}\n\ntype Slices struct {\n\tSlice []Primitives `json:\"slices\"`\n}\n\ntype DateTime struct {\n\tDate     time.Time `json:\"date\" format:\"date\"`\n\tDateTime time.Time `json:\"date-time\" format:\"date-time\"`\n}\n\ntype AdditionalProperties struct {\n\tA           bool           `json:\"a\"`\n\tExtraFields map[string]any `json:\"-\" api:\"extrafields\"`\n}\n\ntype TypedAdditionalProperties struct {\n\tA           bool           `json:\"a\"`\n\tExtraFields map[string]int `json:\"-\" api:\"extrafields\"`\n}\n\ntype EmbeddedStruct struct {\n\tA bool   `json:\"a\"`\n\tB string `json:\"b\"`\n\n\tJSON EmbeddedStructJSON\n}\n\ntype EmbeddedStructJSON struct {\n\tA           Field\n\tB           Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\ntype EmbeddedStructs struct {\n\tEmbeddedStruct\n\tA           *int           `json:\"a\"`\n\tExtraFields map[string]any `json:\"-\" api:\"extrafields\"`\n\n\tJSON EmbeddedStructsJSON\n}\n\ntype EmbeddedStructsJSON struct {\n\tA           Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\ntype Recursive struct {\n\tName  string     `json:\"name\"`\n\tChild *Recursive `json:\"child\"`\n}\n\ntype JSONFieldStruct struct {\n\tA           bool                `json:\"a\"`\n\tB           int64               `json:\"b\"`\n\tC           string              `json:\"c\"`\n\tD           string              `json:\"d\"`\n\tExtraFields map[string]int64    `json:\"\" api:\"extrafields\"`\n\tJSON        JSONFieldStructJSON `json:\"-\" api:\"metadata\"`\n}\n\ntype JSONFieldStructJSON struct {\n\tA           Field\n\tB           Field\n\tC           Field\n\tD           Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\ntype UnknownStruct struct {\n\tUnknown any `json:\"unknown\"`\n}\n\ntype UnionStruct struct {\n\tUnion Union `json:\"union\" format:\"date\"`\n}\n\ntype Union interface {\n\tunion()\n}\n\ntype Inline struct {\n\tInlineField Primitives `json:\",inline\"`\n\tJSON        InlineJSON `json:\"-\" api:\"metadata\"`\n}\n\ntype InlineArray struct {\n\tInlineField []string   `json:\",inline\"`\n\tJSON        InlineJSON `json:\"-\" api:\"metadata\"`\n}\n\ntype InlineJSON struct {\n\tInlineField Field\n\traw         string\n}\n\ntype UnionInteger int64\n\nfunc (UnionInteger) union() {}\n\ntype UnionStructA struct {\n\tType string `json:\"type\"`\n\tA    string `json:\"a\"`\n\tB    string `json:\"b\"`\n}\n\nfunc (UnionStructA) union() {}\n\ntype UnionStructB struct {\n\tType string `json:\"type\"`\n\tA    string `json:\"a\"`\n}\n\nfunc (UnionStructB) union() {}\n\ntype UnionTime time.Time\n\nfunc (UnionTime) union() {}\n\nfunc init() {\n\tRegisterUnion[Union](\"type\",\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.String,\n\t\t\tType:       reflect.TypeOf(UnionTime{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.Number,\n\t\t\tType:       reflect.TypeOf(UnionInteger(0)),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter:         gjson.JSON,\n\t\t\tDiscriminatorValue: \"typeA\",\n\t\t\tType:               reflect.TypeOf(UnionStructA{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter:         gjson.JSON,\n\t\t\tDiscriminatorValue: \"typeB\",\n\t\t\tType:               reflect.TypeOf(UnionStructB{}),\n\t\t},\n\t)\n}\n\ntype ComplexUnionStruct struct {\n\tUnion ComplexUnion `json:\"union\"`\n}\n\ntype ComplexUnion interface {\n\tcomplexUnion()\n}\n\ntype ComplexUnionA struct {\n\tBoo string `json:\"boo\"`\n\tFoo bool   `json:\"foo\"`\n}\n\nfunc (ComplexUnionA) complexUnion() {}\n\ntype ComplexUnionB struct {\n\tBoo bool   `json:\"boo\"`\n\tFoo string `json:\"foo\"`\n}\n\nfunc (ComplexUnionB) complexUnion() {}\n\ntype ComplexUnionC struct {\n\tBoo int64 `json:\"boo\"`\n}\n\nfunc (ComplexUnionC) complexUnion() {}\n\ntype ComplexUnionTypeA struct {\n\tBaz  int64 `json:\"baz\"`\n\tType TypeA `json:\"type\"`\n}\n\nfunc (ComplexUnionTypeA) complexUnion() {}\n\ntype TypeA string\n\nfunc (t TypeA) IsKnown() bool {\n\treturn t == \"a\"\n}\n\ntype ComplexUnionTypeB struct {\n\tBaz  int64 `json:\"baz\"`\n\tType TypeB `json:\"type\"`\n}\n\ntype TypeB string\n\nfunc (t TypeB) IsKnown() bool {\n\treturn t == \"b\"\n}\n\ntype UnmarshalStruct struct {\n\tFoo  string `json:\"foo\"`\n\tprop bool   `json:\"-\"`\n}\n\nfunc (r *UnmarshalStruct) UnmarshalJSON(json []byte) error {\n\tr.prop = true\n\treturn UnmarshalRoot(json, r)\n}\n\nfunc (ComplexUnionTypeB) complexUnion() {}\n\nfunc init() {\n\tRegisterUnion[ComplexUnion](\"\",\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(ComplexUnionA{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(ComplexUnionB{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(ComplexUnionC{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(ComplexUnionTypeA{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(ComplexUnionTypeB{}),\n\t\t},\n\t)\n}\n\ntype MarshallingUnionStruct struct {\n\tUnion MarshallingUnion\n}\n\nfunc (r *MarshallingUnionStruct) UnmarshalJSON(data []byte) (err error) {\n\t*r = MarshallingUnionStruct{}\n\terr = UnmarshalRoot(data, &r.Union)\n\treturn err\n}\n\nfunc (r MarshallingUnionStruct) MarshalJSON() (data []byte, err error) {\n\treturn MarshalRoot(r.Union)\n}\n\ntype MarshallingUnion interface {\n\tmarshallingUnion()\n}\n\ntype MarshallingUnionA struct {\n\tBoo string `json:\"boo\"`\n}\n\nfunc (MarshallingUnionA) marshallingUnion() {}\n\nfunc (r *MarshallingUnionA) UnmarshalJSON(data []byte) (err error) {\n\treturn UnmarshalRoot(data, r)\n}\n\ntype MarshallingUnionB struct {\n\tFoo string `json:\"foo\"`\n}\n\nfunc (MarshallingUnionB) marshallingUnion() {}\n\nfunc (r *MarshallingUnionB) UnmarshalJSON(data []byte) (err error) {\n\treturn UnmarshalRoot(data, r)\n}\n\nfunc init() {\n\tRegisterUnion[MarshallingUnion](\n\t\t\"\",\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(MarshallingUnionA{}),\n\t\t},\n\t\tUnionVariant{\n\t\t\tTypeFilter: gjson.JSON,\n\t\t\tType:       reflect.TypeOf(MarshallingUnionB{}),\n\t\t},\n\t)\n}\n\nvar tests = map[string]struct {\n\tbuf string\n\tval any\n}{\n\t\"true\":               {\"true\", true},\n\t\"false\":              {\"false\", false},\n\t\"int\":                {\"1\", 1},\n\t\"int_bigger\":         {\"12324\", 12324},\n\t\"int_string_coerce\":  {`\"65\"`, 65},\n\t\"int_boolean_coerce\": {\"true\", 1},\n\t\"int64\":              {\"1\", int64(1)},\n\t\"int64_huge\":         {\"123456789123456789\", int64(123456789123456789)},\n\t\"uint\":               {\"1\", uint(1)},\n\t\"uint_bigger\":        {\"12324\", uint(12324)},\n\t\"uint_coerce\":        {`\"65\"`, uint(65)},\n\t\"float_1.54\":         {\"1.54\", float32(1.54)},\n\t\"float_1.89\":         {\"1.89\", float64(1.89)},\n\t\"string\":             {`\"str\"`, \"str\"},\n\t\"string_int_coerce\":  {`12`, \"12\"},\n\t\"array_string\":       {`[\"foo\",\"bar\"]`, []string{\"foo\", \"bar\"}},\n\t\"array_int\":          {`[1,2]`, []int{1, 2}},\n\t\"array_int_coerce\":   {`[\"1\",2]`, []int{1, 2}},\n\n\t\"ptr_true\":               {\"true\", P(true)},\n\t\"ptr_false\":              {\"false\", P(false)},\n\t\"ptr_int\":                {\"1\", P(1)},\n\t\"ptr_int_bigger\":         {\"12324\", P(12324)},\n\t\"ptr_int_string_coerce\":  {`\"65\"`, P(65)},\n\t\"ptr_int_boolean_coerce\": {\"true\", P(1)},\n\t\"ptr_int64\":              {\"1\", P(int64(1))},\n\t\"ptr_int64_huge\":         {\"123456789123456789\", P(int64(123456789123456789))},\n\t\"ptr_uint\":               {\"1\", P(uint(1))},\n\t\"ptr_uint_bigger\":        {\"12324\", P(uint(12324))},\n\t\"ptr_uint_coerce\":        {`\"65\"`, P(uint(65))},\n\t\"ptr_float_1.54\":         {\"1.54\", P(float32(1.54))},\n\t\"ptr_float_1.89\":         {\"1.89\", P(float64(1.89))},\n\n\t\"date_time\":             {`\"2007-03-01T13:00:00Z\"`, time.Date(2007, time.March, 1, 13, 0, 0, 0, time.UTC)},\n\t\"date_time_nano_coerce\": {`\"2007-03-01T13:03:05.123456789Z\"`, time.Date(2007, time.March, 1, 13, 3, 5, 123456789, time.UTC)},\n\n\t\"date_time_missing_t_coerce\":        {`\"2007-03-01 13:03:05Z\"`, time.Date(2007, time.March, 1, 13, 3, 5, 0, time.UTC)},\n\t\"date_time_missing_timezone_coerce\": {`\"2007-03-01T13:03:05\"`, time.Date(2007, time.March, 1, 13, 3, 5, 0, time.UTC)},\n\t// note: using -1200 to minimize probability of conflicting with the local timezone of the test runner\n\t// see https://en.wikipedia.org/wiki/UTC%E2%88%9212:00\n\t\"date_time_missing_timezone_colon_coerce\": {`\"2007-03-01T13:03:05-1200\"`, time.Date(2007, time.March, 1, 13, 3, 5, 0, time.FixedZone(\"\", -12*60*60))},\n\t\"date_time_nano_missing_t_coerce\":         {`\"2007-03-01 13:03:05.123456789Z\"`, time.Date(2007, time.March, 1, 13, 3, 5, 123456789, time.UTC)},\n\n\t\"map_string\":                       {`{\"foo\":\"bar\"}`, map[string]string{\"foo\": \"bar\"}},\n\t\"map_string_with_sjson_path_chars\": {`{\":a.b.c*:d*-1e.f\":\"bar\"}`, map[string]string{\":a.b.c*:d*-1e.f\": \"bar\"}},\n\t\"map_interface\":                    {`{\"a\":1,\"b\":\"str\",\"c\":false}`, map[string]any{\"a\": float64(1), \"b\": \"str\", \"c\": false}},\n\n\t\"primitive_struct\": {\n\t\t`{\"a\":false,\"b\":237628372683,\"c\":654,\"d\":9999.43,\"e\":43.76,\"f\":[1,2,3,4]}`,\n\t\tPrimitives{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t},\n\n\t\"slices\": {\n\t\t`{\"slices\":[{\"a\":false,\"b\":237628372683,\"c\":654,\"d\":9999.43,\"e\":43.76,\"f\":[1,2,3,4]}]}`,\n\t\tSlices{\n\t\t\tSlice: []Primitives{{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}}},\n\t\t},\n\t},\n\n\t\"primitive_pointer_struct\": {\n\t\t`{\"a\":false,\"b\":237628372683,\"c\":654,\"d\":9999.43,\"e\":43.76,\"f\":[1,2,3,4,5]}`,\n\t\tPrimitivePointers{\n\t\t\tA: P(false),\n\t\t\tB: P(237628372683),\n\t\t\tC: P(uint(654)),\n\t\t\tD: P(9999.43),\n\t\t\tE: P(float32(43.76)),\n\t\t\tF: &[]int{1, 2, 3, 4, 5},\n\t\t},\n\t},\n\n\t\"datetime_struct\": {\n\t\t`{\"date\":\"2006-01-02\",\"date-time\":\"2006-01-02T15:04:05Z\"}`,\n\t\tDateTime{\n\t\t\tDate:     time.Date(2006, time.January, 2, 0, 0, 0, 0, time.UTC),\n\t\t\tDateTime: time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC),\n\t\t},\n\t},\n\n\t\"additional_properties\": {\n\t\t`{\"a\":true,\"bar\":\"value\",\"foo\":true}`,\n\t\tAdditionalProperties{\n\t\t\tA: true,\n\t\t\tExtraFields: map[string]any{\n\t\t\t\t\"bar\": \"value\",\n\t\t\t\t\"foo\": true,\n\t\t\t},\n\t\t},\n\t},\n\n\t\"embedded_struct\": {\n\t\t`{\"a\":1,\"b\":\"bar\"}`,\n\t\tEmbeddedStructs{\n\t\t\tEmbeddedStruct: EmbeddedStruct{\n\t\t\t\tA: true,\n\t\t\t\tB: \"bar\",\n\t\t\t\tJSON: EmbeddedStructJSON{\n\t\t\t\t\tA:   Field{raw: `1`, status: valid},\n\t\t\t\t\tB:   Field{raw: `\"bar\"`, status: valid},\n\t\t\t\t\traw: `{\"a\":1,\"b\":\"bar\"}`,\n\t\t\t\t},\n\t\t\t},\n\t\t\tA:           P(1),\n\t\t\tExtraFields: map[string]any{\"b\": \"bar\"},\n\t\t\tJSON: EmbeddedStructsJSON{\n\t\t\t\tA: Field{raw: `1`, status: valid},\n\t\t\t\tExtraFields: map[string]Field{\n\t\t\t\t\t\"b\": {raw: `\"bar\"`, status: valid},\n\t\t\t\t},\n\t\t\t\traw: `{\"a\":1,\"b\":\"bar\"}`,\n\t\t\t},\n\t\t},\n\t},\n\n\t\"recursive_struct\": {\n\t\t`{\"child\":{\"name\":\"Alex\"},\"name\":\"Robert\"}`,\n\t\tRecursive{Name: \"Robert\", Child: &Recursive{Name: \"Alex\"}},\n\t},\n\n\t\"metadata_coerce\": {\n\t\t`{\"a\":\"12\",\"b\":\"12\",\"c\":null,\"extra_typed\":12,\"extra_untyped\":{\"foo\":\"bar\"}}`,\n\t\tJSONFieldStruct{\n\t\t\tA: false,\n\t\t\tB: 12,\n\t\t\tC: \"\",\n\t\t\tJSON: JSONFieldStructJSON{\n\t\t\t\traw: `{\"a\":\"12\",\"b\":\"12\",\"c\":null,\"extra_typed\":12,\"extra_untyped\":{\"foo\":\"bar\"}}`,\n\t\t\t\tA:   Field{raw: `\"12\"`, status: invalid},\n\t\t\t\tB:   Field{raw: `\"12\"`, status: valid},\n\t\t\t\tC:   Field{raw: \"null\", status: null},\n\t\t\t\tD:   Field{raw: \"\", status: missing},\n\t\t\t\tExtraFields: map[string]Field{\n\t\t\t\t\t\"extra_typed\": {\n\t\t\t\t\t\traw:    \"12\",\n\t\t\t\t\t\tstatus: valid,\n\t\t\t\t\t},\n\t\t\t\t\t\"extra_untyped\": {\n\t\t\t\t\t\traw:    `{\"foo\":\"bar\"}`,\n\t\t\t\t\t\tstatus: invalid,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tExtraFields: map[string]int64{\n\t\t\t\t\"extra_typed\":   12,\n\t\t\t\t\"extra_untyped\": 0,\n\t\t\t},\n\t\t},\n\t},\n\n\t\"unknown_struct_number\": {\n\t\t`{\"unknown\":12}`,\n\t\tUnknownStruct{\n\t\t\tUnknown: 12.,\n\t\t},\n\t},\n\n\t\"unknown_struct_map\": {\n\t\t`{\"unknown\":{\"foo\":\"bar\"}}`,\n\t\tUnknownStruct{\n\t\t\tUnknown: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"union_integer\": {\n\t\t`{\"union\":12}`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionInteger(12),\n\t\t},\n\t},\n\n\t\"union_struct_discriminated_a\": {\n\t\t`{\"union\":{\"a\":\"foo\",\"b\":\"bar\",\"type\":\"typeA\"}}`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionStructA{\n\t\t\t\tType: \"typeA\",\n\t\t\t\tA:    \"foo\",\n\t\t\t\tB:    \"bar\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"union_struct_discriminated_b\": {\n\t\t`{\"union\":{\"a\":\"foo\",\"type\":\"typeB\"}}`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionStructB{\n\t\t\t\tType: \"typeB\",\n\t\t\t\tA:    \"foo\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"union_struct_time\": {\n\t\t`{\"union\":\"2010-05-23\"}`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionTime(time.Date(2010, 05, 23, 0, 0, 0, 0, time.UTC)),\n\t\t},\n\t},\n\n\t\"complex_union_a\": {\n\t\t`{\"union\":{\"boo\":\"12\",\"foo\":true}}`,\n\t\tComplexUnionStruct{Union: ComplexUnionA{Boo: \"12\", Foo: true}},\n\t},\n\n\t\"complex_union_b\": {\n\t\t`{\"union\":{\"boo\":true,\"foo\":\"12\"}}`,\n\t\tComplexUnionStruct{Union: ComplexUnionB{Boo: true, Foo: \"12\"}},\n\t},\n\n\t\"complex_union_c\": {\n\t\t`{\"union\":{\"boo\":12}}`,\n\t\tComplexUnionStruct{Union: ComplexUnionC{Boo: 12}},\n\t},\n\n\t\"complex_union_type_a\": {\n\t\t`{\"union\":{\"baz\":12,\"type\":\"a\"}}`,\n\t\tComplexUnionStruct{Union: ComplexUnionTypeA{Baz: 12, Type: TypeA(\"a\")}},\n\t},\n\n\t\"complex_union_type_b\": {\n\t\t`{\"union\":{\"baz\":12,\"type\":\"b\"}}`,\n\t\tComplexUnionStruct{Union: ComplexUnionTypeB{Baz: 12, Type: TypeB(\"b\")}},\n\t},\n\n\t\"marshalling_union_a\": {\n\t\t`{\"boo\":\"hello\"}`,\n\t\tMarshallingUnionStruct{Union: MarshallingUnionA{Boo: \"hello\"}},\n\t},\n\t\"marshalling_union_b\": {\n\t\t`{\"foo\":\"hi\"}`,\n\t\tMarshallingUnionStruct{Union: MarshallingUnionB{Foo: \"hi\"}},\n\t},\n\n\t\"unmarshal\": {\n\t\t`{\"foo\":\"hello\"}`,\n\t\t&UnmarshalStruct{Foo: \"hello\", prop: true},\n\t},\n\n\t\"array_of_unmarshal\": {\n\t\t`[{\"foo\":\"hello\"}]`,\n\t\t[]UnmarshalStruct{{Foo: \"hello\", prop: true}},\n\t},\n\n\t\"inline_coerce\": {\n\t\t`{\"a\":false,\"b\":237628372683,\"c\":654,\"d\":9999.43,\"e\":43.76,\"f\":[1,2,3,4]}`,\n\t\tInline{\n\t\t\tInlineField: Primitives{A: false, B: 237628372683, C: 0x28e, D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t\t\tJSON: InlineJSON{\n\t\t\t\tInlineField: Field{raw: \"{\\\"a\\\":false,\\\"b\\\":237628372683,\\\"c\\\":654,\\\"d\\\":9999.43,\\\"e\\\":43.76,\\\"f\\\":[1,2,3,4]}\", status: 3},\n\t\t\t\traw:         \"{\\\"a\\\":false,\\\"b\\\":237628372683,\\\"c\\\":654,\\\"d\\\":9999.43,\\\"e\\\":43.76,\\\"f\\\":[1,2,3,4]}\",\n\t\t\t},\n\t\t},\n\t},\n\n\t\"inline_array_coerce\": {\n\t\t`[\"Hello\",\"foo\",\"bar\"]`,\n\t\tInlineArray{\n\t\t\tInlineField: []string{\"Hello\", \"foo\", \"bar\"},\n\t\t\tJSON: InlineJSON{\n\t\t\t\tInlineField: Field{raw: `[\"Hello\",\"foo\",\"bar\"]`, status: 3},\n\t\t\t\traw:         `[\"Hello\",\"foo\",\"bar\"]`,\n\t\t\t},\n\t\t},\n\t},\n}\n\nfunc TestDecode(t *testing.T) {\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tresult := reflect.New(reflect.TypeOf(test.val))\n\t\t\tif err := Unmarshal([]byte(test.buf), result.Interface()); err != nil {\n\t\t\t\tt.Fatalf(\"deserialization of %v failed with error %v\", result, err)\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(result.Elem().Interface(), test.val) {\n\t\t\t\tt.Fatalf(\"expected '%s' to deserialize to \\n%#v\\nbut got\\n%#v\", test.buf, test.val, result.Elem().Interface())\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestEncode(t *testing.T) {\n\tfor name, test := range tests {\n\t\tif strings.HasSuffix(name, \"_coerce\") {\n\t\t\tcontinue\n\t\t}\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\traw, err := Marshal(test.val)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"serialization of %v failed with error %v\", test.val, err)\n\t\t\t}\n\t\t\tif string(raw) != test.buf {\n\t\t\t\tt.Fatalf(\"expected %+#v to serialize to %s but got %s\", test.val, test.buf, string(raw))\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/port.go",
    "content": "package apijson\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n)\n\n// Port copies over values from one struct to another struct.\nfunc Port(from any, to any) error {\n\ttoVal := reflect.ValueOf(to)\n\tfromVal := reflect.ValueOf(from)\n\n\tif toVal.Kind() != reflect.Ptr || toVal.IsNil() {\n\t\treturn fmt.Errorf(\"destination must be a non-nil pointer\")\n\t}\n\n\tfor toVal.Kind() == reflect.Ptr {\n\t\ttoVal = toVal.Elem()\n\t}\n\ttoType := toVal.Type()\n\n\tfor fromVal.Kind() == reflect.Ptr {\n\t\tfromVal = fromVal.Elem()\n\t}\n\tfromType := fromVal.Type()\n\n\tif toType.Kind() != reflect.Struct {\n\t\treturn fmt.Errorf(\"destination must be a non-nil pointer to a struct (%v %v)\", toType, toType.Kind())\n\t}\n\n\tvalues := map[string]reflect.Value{}\n\tfields := map[string]reflect.Value{}\n\n\tfromJSON := fromVal.FieldByName(\"JSON\")\n\ttoJSON := toVal.FieldByName(\"JSON\")\n\n\t// Iterate through the fields of v and load all the \"normal\" fields in the struct to the map of\n\t// string to reflect.Value, as well as their raw .JSON.Foo counterpart indicated by j.\n\tvar getFields func(t reflect.Type, v reflect.Value)\n\tgetFields = func(t reflect.Type, v reflect.Value) {\n\t\tj := v.FieldByName(\"JSON\")\n\n\t\t// Recurse into anonymous fields first, since the fields on the object should win over the fields in the\n\t\t// embedded object.\n\t\tfor i := 0; i < t.NumField(); i++ {\n\t\t\tfield := t.Field(i)\n\t\t\tif field.Anonymous {\n\t\t\t\tgetFields(field.Type, v.Field(i))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < t.NumField(); i++ {\n\t\t\tfield := t.Field(i)\n\t\t\tptag, ok := parseJSONStructTag(field)\n\t\t\tif !ok || ptag.name == \"-\" || ptag.name == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvalues[ptag.name] = v.Field(i)\n\t\t\tif j.IsValid() {\n\t\t\t\tfields[ptag.name] = j.FieldByName(field.Name)\n\t\t\t}\n\t\t}\n\t}\n\tgetFields(fromType, fromVal)\n\n\t// Use the values from the previous step to populate the 'to' struct.\n\tfor i := 0; i < toType.NumField(); i++ {\n\t\tfield := toType.Field(i)\n\t\tptag, ok := parseJSONStructTag(field)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tif ptag.name == \"-\" {\n\t\t\tcontinue\n\t\t}\n\t\tif value, ok := values[ptag.name]; ok {\n\t\t\tdelete(values, ptag.name)\n\t\t\tif field.Type.Kind() == reflect.Interface {\n\t\t\t\ttoVal.Field(i).Set(value)\n\t\t\t} else {\n\t\t\t\tswitch value.Kind() {\n\t\t\t\tcase reflect.String:\n\t\t\t\t\ttoVal.Field(i).SetString(value.String())\n\t\t\t\tcase reflect.Bool:\n\t\t\t\t\ttoVal.Field(i).SetBool(value.Bool())\n\t\t\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\t\t\ttoVal.Field(i).SetInt(value.Int())\n\t\t\t\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\t\t\t\ttoVal.Field(i).SetUint(value.Uint())\n\t\t\t\tcase reflect.Float32, reflect.Float64:\n\t\t\t\t\ttoVal.Field(i).SetFloat(value.Float())\n\t\t\t\tdefault:\n\t\t\t\t\ttoVal.Field(i).Set(value)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif fromJSONField, ok := fields[ptag.name]; ok {\n\t\t\tif toJSONField := toJSON.FieldByName(field.Name); toJSONField.IsValid() {\n\t\t\t\ttoJSONField.Set(fromJSONField)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Finally, copy over the .JSON.raw and .JSON.ExtraFields\n\tif toJSON.IsValid() {\n\t\tif raw := toJSON.FieldByName(\"raw\"); raw.IsValid() {\n\t\t\tsetUnexportedField(raw, fromJSON.Interface().(interface{ RawJSON() string }).RawJSON())\n\t\t}\n\n\t\tif toExtraFields := toJSON.FieldByName(\"ExtraFields\"); toExtraFields.IsValid() {\n\t\t\tif fromExtraFields := fromJSON.FieldByName(\"ExtraFields\"); fromExtraFields.IsValid() {\n\t\t\t\tsetUnexportedField(toExtraFields, fromExtraFields.Interface())\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n"
  },
  {
    "path": "internal/apijson/port_test.go",
    "content": "package apijson\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\ntype Metadata struct {\n\tCreatedAt string `json:\"created_at\"`\n}\n\n// Card is the \"combined\" type of CardVisa and CardMastercard\ntype Card struct {\n\tProcessor CardProcessor `json:\"processor\"`\n\tData      any           `json:\"data\"`\n\tIsFoo     bool          `json:\"is_foo\"`\n\tIsBar     bool          `json:\"is_bar\"`\n\tMetadata  Metadata      `json:\"metadata\"`\n\tValue     any           `json:\"value\"`\n\n\tJSON cardJSON\n}\n\ntype cardJSON struct {\n\tProcessor   Field\n\tData        Field\n\tIsFoo       Field\n\tIsBar       Field\n\tMetadata    Field\n\tValue       Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\nfunc (r cardJSON) RawJSON() string { return r.raw }\n\ntype CardProcessor string\n\n// CardVisa\ntype CardVisa struct {\n\tProcessor CardVisaProcessor `json:\"processor\"`\n\tData      CardVisaData      `json:\"data\"`\n\tIsFoo     bool              `json:\"is_foo\"`\n\tMetadata  Metadata          `json:\"metadata\"`\n\tValue     string            `json:\"value\"`\n\n\tJSON cardVisaJSON\n}\n\ntype cardVisaJSON struct {\n\tProcessor   Field\n\tData        Field\n\tIsFoo       Field\n\tMetadata    Field\n\tValue       Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\nfunc (r cardVisaJSON) RawJSON() string { return r.raw }\n\ntype CardVisaProcessor string\n\ntype CardVisaData struct {\n\tFoo string `json:\"foo\"`\n}\n\n// CardMastercard\ntype CardMastercard struct {\n\tProcessor CardMastercardProcessor `json:\"processor\"`\n\tData      CardMastercardData      `json:\"data\"`\n\tIsBar     bool                    `json:\"is_bar\"`\n\tMetadata  Metadata                `json:\"metadata\"`\n\tValue     bool                    `json:\"value\"`\n\n\tJSON cardMastercardJSON\n}\n\ntype cardMastercardJSON struct {\n\tProcessor   Field\n\tData        Field\n\tIsBar       Field\n\tMetadata    Field\n\tValue       Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\nfunc (r cardMastercardJSON) RawJSON() string { return r.raw }\n\ntype CardMastercardProcessor string\n\ntype CardMastercardData struct {\n\tBar int64 `json:\"bar\"`\n}\n\ntype CommonFields struct {\n\tMetadata Metadata `json:\"metadata\"`\n\tValue    string   `json:\"value\"`\n\n\tJSON commonFieldsJSON\n}\n\ntype commonFieldsJSON struct {\n\tMetadata    Field\n\tValue       Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\ntype CardEmbedded struct {\n\tCommonFields\n\tProcessor CardVisaProcessor `json:\"processor\"`\n\tData      CardVisaData      `json:\"data\"`\n\tIsFoo     bool              `json:\"is_foo\"`\n\n\tJSON cardEmbeddedJSON\n}\n\ntype cardEmbeddedJSON struct {\n\tProcessor   Field\n\tData        Field\n\tIsFoo       Field\n\tExtraFields map[string]Field\n\traw         string\n}\n\nfunc (r cardEmbeddedJSON) RawJSON() string { return r.raw }\n\nvar portTests = map[string]struct {\n\tfrom any\n\tto   any\n}{\n\t\"visa to card\": {\n\t\tCardVisa{\n\t\t\tProcessor: \"visa\",\n\t\t\tIsFoo:     true,\n\t\t\tData: CardVisaData{\n\t\t\t\tFoo: \"foo\",\n\t\t\t},\n\t\t\tMetadata: Metadata{\n\t\t\t\tCreatedAt: \"Mar 29 2024\",\n\t\t\t},\n\t\t\tValue: \"value\",\n\t\t\tJSON: cardVisaJSON{\n\t\t\t\traw:         `{\"processor\":\"visa\",\"is_foo\":true,\"data\":{\"foo\":\"foo\"}}`,\n\t\t\t\tProcessor:   Field{raw: `\"visa\"`, status: valid},\n\t\t\t\tIsFoo:       Field{raw: `true`, status: valid},\n\t\t\t\tData:        Field{raw: `{\"foo\":\"foo\"}`, status: valid},\n\t\t\t\tValue:       Field{raw: `\"value\"`, status: valid},\n\t\t\t\tExtraFields: map[string]Field{\"extra\": {raw: `\"yo\"`, status: valid}},\n\t\t\t},\n\t\t},\n\t\tCard{\n\t\t\tProcessor: \"visa\",\n\t\t\tIsFoo:     true,\n\t\t\tIsBar:     false,\n\t\t\tData: CardVisaData{\n\t\t\t\tFoo: \"foo\",\n\t\t\t},\n\t\t\tMetadata: Metadata{\n\t\t\t\tCreatedAt: \"Mar 29 2024\",\n\t\t\t},\n\t\t\tValue: \"value\",\n\t\t\tJSON: cardJSON{\n\t\t\t\traw:         `{\"processor\":\"visa\",\"is_foo\":true,\"data\":{\"foo\":\"foo\"}}`,\n\t\t\t\tProcessor:   Field{raw: `\"visa\"`, status: valid},\n\t\t\t\tIsFoo:       Field{raw: `true`, status: valid},\n\t\t\t\tData:        Field{raw: `{\"foo\":\"foo\"}`, status: valid},\n\t\t\t\tValue:       Field{raw: `\"value\"`, status: valid},\n\t\t\t\tExtraFields: map[string]Field{\"extra\": {raw: `\"yo\"`, status: valid}},\n\t\t\t},\n\t\t},\n\t},\n\t\"mastercard to card\": {\n\t\tCardMastercard{\n\t\t\tProcessor: \"mastercard\",\n\t\t\tIsBar:     true,\n\t\t\tData: CardMastercardData{\n\t\t\t\tBar: 13,\n\t\t\t},\n\t\t\tValue: false,\n\t\t},\n\t\tCard{\n\t\t\tProcessor: \"mastercard\",\n\t\t\tIsFoo:     false,\n\t\t\tIsBar:     true,\n\t\t\tData: CardMastercardData{\n\t\t\t\tBar: 13,\n\t\t\t},\n\t\t\tValue: false,\n\t\t},\n\t},\n\t\"embedded to card\": {\n\t\tCardEmbedded{\n\t\t\tCommonFields: CommonFields{\n\t\t\t\tMetadata: Metadata{\n\t\t\t\t\tCreatedAt: \"Mar 29 2024\",\n\t\t\t\t},\n\t\t\t\tValue: \"embedded_value\",\n\t\t\t\tJSON: commonFieldsJSON{\n\t\t\t\t\tMetadata: Field{raw: `{\"created_at\":\"Mar 29 2024\"}`, status: valid},\n\t\t\t\t\tValue:    Field{raw: `\"embedded_value\"`, status: valid},\n\t\t\t\t\traw:      `should not matter`,\n\t\t\t\t},\n\t\t\t},\n\t\t\tProcessor: \"visa\",\n\t\t\tIsFoo:     true,\n\t\t\tData: CardVisaData{\n\t\t\t\tFoo: \"embedded_foo\",\n\t\t\t},\n\t\t\tJSON: cardEmbeddedJSON{\n\t\t\t\traw:       `{\"processor\":\"visa\",\"is_foo\":true,\"data\":{\"foo\":\"embedded_foo\"},\"metadata\":{\"created_at\":\"Mar 29 2024\"},\"value\":\"embedded_value\"}`,\n\t\t\t\tProcessor: Field{raw: `\"visa\"`, status: valid},\n\t\t\t\tIsFoo:     Field{raw: `true`, status: valid},\n\t\t\t\tData:      Field{raw: `{\"foo\":\"embedded_foo\"}`, status: valid},\n\t\t\t},\n\t\t},\n\t\tCard{\n\t\t\tProcessor: \"visa\",\n\t\t\tIsFoo:     true,\n\t\t\tIsBar:     false,\n\t\t\tData: CardVisaData{\n\t\t\t\tFoo: \"embedded_foo\",\n\t\t\t},\n\t\t\tMetadata: Metadata{\n\t\t\t\tCreatedAt: \"Mar 29 2024\",\n\t\t\t},\n\t\t\tValue: \"embedded_value\",\n\t\t\tJSON: cardJSON{\n\t\t\t\traw:       `{\"processor\":\"visa\",\"is_foo\":true,\"data\":{\"foo\":\"embedded_foo\"},\"metadata\":{\"created_at\":\"Mar 29 2024\"},\"value\":\"embedded_value\"}`,\n\t\t\t\tProcessor: Field{raw: `\"visa\"`, status: 0x3},\n\t\t\t\tIsFoo:     Field{raw: \"true\", status: 0x3},\n\t\t\t\tData:      Field{raw: `{\"foo\":\"embedded_foo\"}`, status: 0x3},\n\t\t\t\tMetadata:  Field{raw: `{\"created_at\":\"Mar 29 2024\"}`, status: 0x3},\n\t\t\t\tValue:     Field{raw: `\"embedded_value\"`, status: 0x3},\n\t\t\t},\n\t\t},\n\t},\n}\n\nfunc TestPort(t *testing.T) {\n\tfor name, test := range portTests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\ttoVal := reflect.New(reflect.TypeOf(test.to))\n\n\t\t\terr := Port(test.from, toVal.Interface())\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"port of %v failed with error %v\", test.from, err)\n\t\t\t}\n\n\t\t\tif !reflect.DeepEqual(toVal.Elem().Interface(), test.to) {\n\t\t\t\tt.Fatalf(\"expected:\\n%+#v\\n\\nto port to:\\n%+#v\\n\\nbut got:\\n%+#v\", test.from, test.to, toVal.Elem().Interface())\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/registry.go",
    "content": "package apijson\n\nimport (\n\t\"reflect\"\n\n\t\"github.com/tidwall/gjson\"\n)\n\ntype UnionVariant struct {\n\tTypeFilter         gjson.Type\n\tDiscriminatorValue any\n\tType               reflect.Type\n}\n\nvar unionRegistry = map[reflect.Type]unionEntry{}\nvar unionVariants = map[reflect.Type]any{}\nvar customDecoderRegistry = map[reflect.Type]CustomDecoderFunc{}\n\ntype unionEntry struct {\n\tdiscriminatorKey string\n\tvariants         []UnionVariant\n}\n\nfunc Discriminator[T any](value any) UnionVariant {\n\tvar zero T\n\treturn UnionVariant{\n\t\tTypeFilter:         gjson.JSON,\n\t\tDiscriminatorValue: value,\n\t\tType:               reflect.TypeOf(zero),\n\t}\n}\n\nfunc RegisterUnion[T any](discriminator string, variants ...UnionVariant) {\n\ttyp := reflect.TypeOf((*T)(nil)).Elem()\n\tunionRegistry[typ] = unionEntry{\n\t\tdiscriminatorKey: discriminator,\n\t\tvariants:         variants,\n\t}\n\tfor _, variant := range variants {\n\t\tunionVariants[variant.Type] = typ\n\t}\n}\n\n// Useful to wrap a union type to force it to use [apijson.UnmarshalJSON] since you cannot define an\n// UnmarshalJSON function on the interface itself.\ntype UnionUnmarshaler[T any] struct {\n\tValue T\n}\n\nfunc (c *UnionUnmarshaler[T]) UnmarshalJSON(buf []byte) error {\n\treturn UnmarshalRoot(buf, &c.Value)\n}\n\ntype CustomDecoderFunc func(node gjson.Result, value reflect.Value, defaultDecoder func(gjson.Result, reflect.Value) error) error\n\nfunc RegisterCustomDecoder[T any](decoder CustomDecoderFunc) {\n\ttyp := reflect.TypeOf((*T)(nil)).Elem()\n\tcustomDecoderRegistry[typ] = decoder\n}\n"
  },
  {
    "path": "internal/apijson/subfield.go",
    "content": "package apijson\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"reflect\"\n)\n\nfunc getSubField(root reflect.Value, index []int, name string) reflect.Value {\n\tstrct := root.FieldByIndex(index[:len(index)-1])\n\tif !strct.IsValid() {\n\t\tpanic(\"couldn't find encapsulating struct for field \" + name)\n\t}\n\tmeta := strct.FieldByName(\"JSON\")\n\tif !meta.IsValid() {\n\t\treturn reflect.Value{}\n\t}\n\tfield := meta.FieldByName(name)\n\tif !field.IsValid() {\n\t\treturn reflect.Value{}\n\t}\n\treturn field\n}\n\nfunc setMetadataSubField(root reflect.Value, index []int, name string, meta Field) {\n\ttarget := getSubField(root, index, name)\n\tif !target.IsValid() {\n\t\treturn\n\t}\n\n\tif target.Type() == reflect.TypeOf(meta) {\n\t\ttarget.Set(reflect.ValueOf(meta))\n\t} else if respMeta := meta.toRespField(); target.Type() == reflect.TypeOf(respMeta) {\n\t\ttarget.Set(reflect.ValueOf(respMeta))\n\t}\n}\n\nfunc setMetadataExtraFields(root reflect.Value, index []int, name string, metaExtras map[string]Field) {\n\ttarget := getSubField(root, index, name)\n\tif !target.IsValid() {\n\t\treturn\n\t}\n\n\tif target.Type() == reflect.TypeOf(metaExtras) {\n\t\ttarget.Set(reflect.ValueOf(metaExtras))\n\t\treturn\n\t}\n\n\tnewMap := make(map[string]respjson.Field, len(metaExtras))\n\tif target.Type() == reflect.TypeOf(newMap) {\n\t\tfor k, v := range metaExtras {\n\t\t\tnewMap[k] = v.toRespField()\n\t\t}\n\t\ttarget.Set(reflect.ValueOf(newMap))\n\t}\n}\n\nfunc (f Field) toRespField() respjson.Field {\n\tif f.IsMissing() {\n\t\treturn respjson.Field{}\n\t} else if f.IsNull() {\n\t\treturn respjson.NewField(\"null\")\n\t} else if f.IsInvalid() {\n\t\treturn respjson.NewInvalidField(f.raw)\n\t} else {\n\t\treturn respjson.NewField(f.raw)\n\t}\n}\n"
  },
  {
    "path": "internal/apijson/tag.go",
    "content": "package apijson\n\nimport (\n\t\"reflect\"\n\t\"strings\"\n)\n\nconst apiStructTag = \"api\"\nconst jsonStructTag = \"json\"\nconst formatStructTag = \"format\"\n\ntype parsedStructTag struct {\n\tname     string\n\trequired bool\n\textras   bool\n\tmetadata bool\n\tinline   bool\n}\n\nfunc parseJSONStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {\n\traw, ok := field.Tag.Lookup(jsonStructTag)\n\tif !ok {\n\t\treturn tag, ok\n\t}\n\tparts := strings.Split(raw, \",\")\n\tif len(parts) == 0 {\n\t\treturn tag, false\n\t}\n\ttag.name = parts[0]\n\tfor _, part := range parts[1:] {\n\t\tswitch part {\n\t\tcase \"required\":\n\t\t\ttag.required = true\n\t\tcase \"extras\":\n\t\t\ttag.extras = true\n\t\tcase \"metadata\":\n\t\t\ttag.metadata = true\n\t\tcase \"inline\":\n\t\t\ttag.inline = true\n\t\t}\n\t}\n\n\t// the `api` struct tag is only used alongside `json` for custom behaviour\n\tparseApiStructTag(field, &tag)\n\treturn tag, ok\n}\n\nfunc parseApiStructTag(field reflect.StructField, tag *parsedStructTag) {\n\traw, ok := field.Tag.Lookup(apiStructTag)\n\tif !ok {\n\t\treturn\n\t}\n\tparts := strings.Split(raw, \",\")\n\tfor _, part := range parts {\n\t\tswitch part {\n\t\tcase \"extrafields\":\n\t\t\ttag.extras = true\n\t\tcase \"required\":\n\t\t\ttag.required = true\n\t\tcase \"metadata\":\n\t\t\ttag.metadata = true\n\t\t}\n\t}\n}\n\nfunc parseFormatStructTag(field reflect.StructField) (format string, ok bool) {\n\tformat, ok = field.Tag.Lookup(formatStructTag)\n\treturn format, ok\n}\n"
  },
  {
    "path": "internal/apijson/union.go",
    "content": "package apijson\n\nimport (\n\t\"errors\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"reflect\"\n\n\t\"github.com/tidwall/gjson\"\n)\n\nvar apiUnionType = reflect.TypeOf(param.APIUnion{})\n\nfunc isStructUnion(t reflect.Type) bool {\n\tif t.Kind() != reflect.Struct {\n\t\treturn false\n\t}\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tif t.Field(i).Type == apiUnionType && t.Field(i).Anonymous {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc RegisterDiscriminatedUnion[T any](key string, mappings map[string]reflect.Type) {\n\tvar t T\n\tentry := unionEntry{\n\t\tdiscriminatorKey: key,\n\t\tvariants:         []UnionVariant{},\n\t}\n\tfor k, typ := range mappings {\n\t\tentry.variants = append(entry.variants, UnionVariant{\n\t\t\tDiscriminatorValue: k,\n\t\t\tType:               typ,\n\t\t})\n\t}\n\tunionRegistry[reflect.TypeOf(t)] = entry\n}\n\nfunc (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc {\n\ttype variantDecoder struct {\n\t\tdecoder decoderFunc\n\t\tfield   reflect.StructField\n\t}\n\tdecoders := []variantDecoder{}\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\n\t\tif field.Anonymous && field.Type == apiUnionType {\n\t\t\tcontinue\n\t\t}\n\n\t\tdecoder := d.typeDecoder(field.Type)\n\t\tdecoders = append(decoders, variantDecoder{\n\t\t\tdecoder: decoder,\n\t\t\tfield:   field,\n\t\t})\n\t}\n\n\ttype discriminatedDecoder struct {\n\t\tvariantDecoder\n\t\tdiscriminator any\n\t}\n\tdiscriminatedDecoders := []discriminatedDecoder{}\n\tunionEntry, discriminated := unionRegistry[t]\n\tfor _, variant := range unionEntry.variants {\n\t\t// For each union variant, find a matching decoder and save it\n\t\tfor _, decoder := range decoders {\n\t\t\tif decoder.field.Type.Elem() == variant.Type {\n\t\t\t\tdiscriminatedDecoders = append(discriminatedDecoders, discriminatedDecoder{\n\t\t\t\t\tdecoder,\n\t\t\t\t\tvariant.DiscriminatorValue,\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\tif discriminated && n.Type == gjson.JSON && len(unionEntry.discriminatorKey) != 0 {\n\t\t\tdiscriminator := n.Get(EscapeSJSONKey(unionEntry.discriminatorKey)).Value()\n\t\t\tfor _, decoder := range discriminatedDecoders {\n\t\t\t\tif discriminator == decoder.discriminator {\n\t\t\t\t\tinner := v.FieldByIndex(decoder.field.Index)\n\t\t\t\t\treturn decoder.decoder(n, inner, state)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn errors.New(\"apijson: was not able to find discriminated union variant\")\n\t\t}\n\n\t\t// Set bestExactness to worse than loose\n\t\tbestExactness := loose - 1\n\t\tbestVariant := -1\n\t\tfor i, decoder := range decoders {\n\t\t\t// Pointers are used to discern JSON object variants from value variants\n\t\t\tif n.Type != gjson.JSON && decoder.field.Type.Kind() == reflect.Ptr {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tsub := decoderState{strict: state.strict, exactness: exact}\n\t\t\tinner := v.FieldByIndex(decoder.field.Index)\n\t\t\terr := decoder.decoder(n, inner, &sub)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif sub.exactness == exact {\n\t\t\t\tbestExactness = exact\n\t\t\t\tbestVariant = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif sub.exactness > bestExactness {\n\t\t\t\tbestExactness = sub.exactness\n\t\t\t\tbestVariant = i\n\t\t\t}\n\t\t}\n\n\t\tif bestExactness < loose {\n\t\t\treturn errors.New(\"apijson: was not able to coerce type as union\")\n\t\t}\n\n\t\tif guardStrict(state, bestExactness != exact) {\n\t\t\treturn errors.New(\"apijson: was not able to coerce type as union strictly\")\n\t\t}\n\n\t\tfor i := 0; i < len(decoders); i++ {\n\t\t\tif i == bestVariant {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tv.FieldByIndex(decoders[i].field.Index).SetZero()\n\t\t}\n\n\t\treturn nil\n\t}\n}\n\n// newUnionDecoder returns a decoderFunc that deserializes into a union using an\n// algorithm roughly similar to Pydantic's [smart algorithm].\n//\n// Conceptually this is equivalent to choosing the best schema based on how 'exact'\n// the deserialization is for each of the schemas.\n//\n// If there is a tie in the level of exactness, then the tie is broken\n// left-to-right.\n//\n// [smart algorithm]: https://docs.pydantic.dev/latest/concepts/unions/#smart-mode\nfunc (d *decoderBuilder) newUnionDecoder(t reflect.Type) decoderFunc {\n\tunionEntry, ok := unionRegistry[t]\n\tif !ok {\n\t\tpanic(\"apijson: couldn't find union of type \" + t.String() + \" in union registry\")\n\t}\n\tdecoders := []decoderFunc{}\n\tfor _, variant := range unionEntry.variants {\n\t\tdecoder := d.typeDecoder(variant.Type)\n\t\tdecoders = append(decoders, decoder)\n\t}\n\treturn func(n gjson.Result, v reflect.Value, state *decoderState) error {\n\t\t// If there is a discriminator match, circumvent the exactness logic entirely\n\t\tfor idx, variant := range unionEntry.variants {\n\t\t\tdecoder := decoders[idx]\n\t\t\tif variant.TypeFilter != n.Type {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(unionEntry.discriminatorKey) != 0 {\n\t\t\t\tdiscriminatorValue := n.Get(EscapeSJSONKey(unionEntry.discriminatorKey)).Value()\n\t\t\t\tif discriminatorValue == variant.DiscriminatorValue {\n\t\t\t\t\tinner := reflect.New(variant.Type).Elem()\n\t\t\t\t\terr := decoder(n, inner, state)\n\t\t\t\t\tv.Set(inner)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Set bestExactness to worse than loose\n\t\tbestExactness := loose - 1\n\t\tfor idx, variant := range unionEntry.variants {\n\t\t\tdecoder := decoders[idx]\n\t\t\tif variant.TypeFilter != n.Type {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsub := decoderState{strict: state.strict, exactness: exact}\n\t\t\tinner := reflect.New(variant.Type).Elem()\n\t\t\terr := decoder(n, inner, &sub)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif sub.exactness == exact {\n\t\t\t\tv.Set(inner)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif sub.exactness > bestExactness {\n\t\t\t\tv.Set(inner)\n\t\t\t\tbestExactness = sub.exactness\n\t\t\t}\n\t\t}\n\n\t\tif bestExactness < loose {\n\t\t\treturn errors.New(\"apijson: was not able to coerce type as union\")\n\t\t}\n\n\t\tif guardStrict(state, bestExactness != exact) {\n\t\t\treturn errors.New(\"apijson: was not able to coerce type as union strictly\")\n\t\t}\n\n\t\treturn nil\n\t}\n}\n"
  },
  {
    "path": "internal/apiquery/encoder.go",
    "content": "package apiquery\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n)\n\nvar encoders sync.Map // map[reflect.Type]encoderFunc\n\ntype encoder struct {\n\tdateFormat string\n\troot       bool\n\tsettings   QuerySettings\n}\n\ntype encoderFunc func(key string, value reflect.Value) ([]Pair, error)\n\ntype encoderField struct {\n\ttag parsedStructTag\n\tfn  encoderFunc\n\tidx []int\n}\n\ntype encoderEntry struct {\n\treflect.Type\n\tdateFormat string\n\troot       bool\n\tsettings   QuerySettings\n}\n\ntype Pair struct {\n\tkey   string\n\tvalue string\n}\n\nfunc (e *encoder) typeEncoder(t reflect.Type) encoderFunc {\n\tentry := encoderEntry{\n\t\tType:       t,\n\t\tdateFormat: e.dateFormat,\n\t\troot:       e.root,\n\t\tsettings:   e.settings,\n\t}\n\n\tif fi, ok := encoders.Load(entry); ok {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// To deal with recursive types, populate the map with an\n\t// indirect func before we build it. This type waits on the\n\t// real func (f) to be ready and then calls it. This indirect\n\t// func is only used for recursive types.\n\tvar (\n\t\twg sync.WaitGroup\n\t\tf  encoderFunc\n\t)\n\twg.Add(1)\n\tfi, loaded := encoders.LoadOrStore(entry, encoderFunc(func(key string, v reflect.Value) ([]Pair, error) {\n\t\twg.Wait()\n\t\treturn f(key, v)\n\t}))\n\tif loaded {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// Compute the real encoder and replace the indirect func with it.\n\tf = e.newTypeEncoder(t)\n\twg.Done()\n\tencoders.Store(entry, f)\n\treturn f\n}\n\nfunc marshalerEncoder(key string, value reflect.Value) ([]Pair, error) {\n\ts, err := value.Interface().(json.Marshaler).MarshalJSON()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"apiquery: json fallback marshal error %s\", err)\n\t}\n\treturn []Pair{{key, string(s)}}, nil\n}\n\nfunc (e *encoder) newTypeEncoder(t reflect.Type) encoderFunc {\n\tif t.ConvertibleTo(reflect.TypeOf(time.Time{})) {\n\t\treturn e.newTimeTypeEncoder(t)\n\t}\n\n\tif t.Implements(reflect.TypeOf((*param.Optional)(nil)).Elem()) {\n\t\treturn e.newRichFieldTypeEncoder(t)\n\t}\n\n\tif !e.root && t.Implements(reflect.TypeOf((*json.Marshaler)(nil)).Elem()) {\n\t\treturn marshalerEncoder\n\t}\n\n\te.root = false\n\tswitch t.Kind() {\n\tcase reflect.Pointer:\n\t\tencoder := e.typeEncoder(t.Elem())\n\t\treturn func(key string, value reflect.Value) (pairs []Pair, err error) {\n\t\t\tif !value.IsValid() || value.IsNil() {\n\t\t\t\treturn pairs, err\n\t\t\t}\n\t\t\treturn encoder(key, value.Elem())\n\t\t}\n\tcase reflect.Struct:\n\t\treturn e.newStructTypeEncoder(t)\n\tcase reflect.Array:\n\t\tfallthrough\n\tcase reflect.Slice:\n\t\treturn e.newArrayTypeEncoder(t)\n\tcase reflect.Map:\n\t\treturn e.newMapEncoder(t)\n\tcase reflect.Interface:\n\t\treturn e.newInterfaceEncoder()\n\tdefault:\n\t\treturn e.newPrimitiveTypeEncoder(t)\n\t}\n}\n\nfunc (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc {\n\tif t.Implements(reflect.TypeOf((*param.Optional)(nil)).Elem()) {\n\t\treturn e.newRichFieldTypeEncoder(t)\n\t}\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tif t.Field(i).Type == paramUnionType && t.Field(i).Anonymous {\n\t\t\treturn e.newStructUnionTypeEncoder(t)\n\t\t}\n\t}\n\n\tencoderFields := []encoderField{}\n\n\t// This helper allows us to recursively collect field encoders into a flat\n\t// array. The parameter `index` keeps track of the access patterns necessary\n\t// to get to some field.\n\tvar collectEncoderFields func(r reflect.Type, index []int)\n\tcollectEncoderFields = func(r reflect.Type, index []int) {\n\t\tfor i := 0; i < r.NumField(); i++ {\n\t\t\tidx := append(index, i)\n\t\t\tfield := t.FieldByIndex(idx)\n\t\t\tif !field.IsExported() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If this is an embedded struct, traverse one level deeper to extract\n\t\t\t// the field and get their encoders as well.\n\t\t\tif field.Anonymous {\n\t\t\t\tcollectEncoderFields(field.Type, idx)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If query tag is not present, then we skip, which is intentionally\n\t\t\t// different behavior from the stdlib.\n\t\t\tptag, ok := parseQueryStructTag(field)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (ptag.name == \"-\" || ptag.name == \"\") && !ptag.inline {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdateFormat, ok := parseFormatStructTag(field)\n\t\t\toldFormat := e.dateFormat\n\t\t\tif ok {\n\t\t\t\tswitch dateFormat {\n\t\t\t\tcase \"date-time\":\n\t\t\t\t\te.dateFormat = time.RFC3339\n\t\t\t\tcase \"date\":\n\t\t\t\t\te.dateFormat = \"2006-01-02\"\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar encoderFn encoderFunc\n\t\t\tif ptag.omitzero {\n\t\t\t\ttypeEncoderFn := e.typeEncoder(field.Type)\n\t\t\t\tencoderFn = func(key string, value reflect.Value) ([]Pair, error) {\n\t\t\t\t\tif value.IsZero() {\n\t\t\t\t\t\treturn nil, nil\n\t\t\t\t\t}\n\t\t\t\t\treturn typeEncoderFn(key, value)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tencoderFn = e.typeEncoder(field.Type)\n\t\t\t}\n\t\t\tencoderFields = append(encoderFields, encoderField{ptag, encoderFn, idx})\n\t\t\te.dateFormat = oldFormat\n\t\t}\n\t}\n\tcollectEncoderFields(t, []int{})\n\n\treturn func(key string, value reflect.Value) (pairs []Pair, err error) {\n\t\tfor _, ef := range encoderFields {\n\t\t\tsubkey := e.renderKeyPath(key, ef.tag.name)\n\t\t\tif ef.tag.inline {\n\t\t\t\tsubkey = key\n\t\t\t}\n\n\t\t\tfield := value.FieldByIndex(ef.idx)\n\t\t\tsubpairs, suberr := ef.fn(subkey, field)\n\t\t\tif suberr != nil {\n\t\t\t\terr = suberr\n\t\t\t}\n\t\t\tpairs = append(pairs, subpairs...)\n\t\t}\n\t\treturn pairs, err\n\t}\n}\n\nvar paramUnionType = reflect.TypeOf((*param.APIUnion)(nil)).Elem()\n\nfunc (e *encoder) newStructUnionTypeEncoder(t reflect.Type) encoderFunc {\n\tvar fieldEncoders []encoderFunc\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\tif field.Type == paramUnionType && field.Anonymous {\n\t\t\tfieldEncoders = append(fieldEncoders, nil)\n\t\t\tcontinue\n\t\t}\n\t\tfieldEncoders = append(fieldEncoders, e.typeEncoder(field.Type))\n\t}\n\n\treturn func(key string, value reflect.Value) (pairs []Pair, err error) {\n\t\tfor i := 0; i < t.NumField(); i++ {\n\t\t\tif value.Field(i).Type() == paramUnionType {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !value.Field(i).IsZero() {\n\t\t\t\treturn fieldEncoders[i](key, value.Field(i))\n\t\t\t}\n\t\t}\n\t\treturn nil, fmt.Errorf(\"apiquery: union %s has no field set\", t.String())\n\t}\n}\n\nfunc (e *encoder) newMapEncoder(t reflect.Type) encoderFunc {\n\tkeyEncoder := e.typeEncoder(t.Key())\n\telementEncoder := e.typeEncoder(t.Elem())\n\treturn func(key string, value reflect.Value) (pairs []Pair, err error) {\n\t\titer := value.MapRange()\n\t\tfor iter.Next() {\n\t\t\tencodedKey, err := keyEncoder(\"\", iter.Key())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif len(encodedKey) != 1 {\n\t\t\t\treturn nil, fmt.Errorf(\"apiquery: unexpected number of parts for encoded map key, map may contain non-primitive\")\n\t\t\t}\n\t\t\tsubkey := encodedKey[0].value\n\t\t\tkeyPath := e.renderKeyPath(key, subkey)\n\t\t\tsubpairs, suberr := elementEncoder(keyPath, iter.Value())\n\t\t\tif suberr != nil {\n\t\t\t\terr = suberr\n\t\t\t}\n\t\t\tpairs = append(pairs, subpairs...)\n\t\t}\n\t\treturn pairs, err\n\t}\n}\n\nfunc (e *encoder) renderKeyPath(key string, subkey string) string {\n\tif len(key) == 0 {\n\t\treturn subkey\n\t}\n\tif e.settings.NestedFormat == NestedQueryFormatDots {\n\t\treturn fmt.Sprintf(\"%s.%s\", key, subkey)\n\t}\n\treturn fmt.Sprintf(\"%s[%s]\", key, subkey)\n}\n\nfunc (e *encoder) newArrayTypeEncoder(t reflect.Type) encoderFunc {\n\tswitch e.settings.ArrayFormat {\n\tcase ArrayQueryFormatComma:\n\t\tinnerEncoder := e.typeEncoder(t.Elem())\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\telements := []string{}\n\t\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\t\tinnerPairs, err := innerEncoder(\"\", v.Index(i))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tfor _, pair := range innerPairs {\n\t\t\t\t\telements = append(elements, pair.value)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(elements) == 0 {\n\t\t\t\treturn []Pair{}, nil\n\t\t\t}\n\t\t\treturn []Pair{{key, strings.Join(elements, \",\")}}, nil\n\t\t}\n\tcase ArrayQueryFormatRepeat:\n\t\tinnerEncoder := e.typeEncoder(t.Elem())\n\t\treturn func(key string, value reflect.Value) (pairs []Pair, err error) {\n\t\t\tfor i := 0; i < value.Len(); i++ {\n\t\t\t\tsubpairs, suberr := innerEncoder(key, value.Index(i))\n\t\t\t\tif suberr != nil {\n\t\t\t\t\terr = suberr\n\t\t\t\t}\n\t\t\t\tpairs = append(pairs, subpairs...)\n\t\t\t}\n\t\t\treturn pairs, err\n\t\t}\n\tcase ArrayQueryFormatIndices:\n\t\tpanic(\"The array indices format is not supported yet\")\n\tcase ArrayQueryFormatBrackets:\n\t\tinnerEncoder := e.typeEncoder(t.Elem())\n\t\treturn func(key string, value reflect.Value) (pairs []Pair, err error) {\n\t\t\tpairs = []Pair{}\n\t\t\tfor i := 0; i < value.Len(); i++ {\n\t\t\t\tsubpairs, suberr := innerEncoder(key+\"[]\", value.Index(i))\n\t\t\t\tif suberr != nil {\n\t\t\t\t\terr = suberr\n\t\t\t\t}\n\t\t\t\tpairs = append(pairs, subpairs...)\n\t\t\t}\n\t\t\treturn pairs, err\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unknown ArrayFormat value: %d\", e.settings.ArrayFormat))\n\t}\n}\n\nfunc (e *encoder) newPrimitiveTypeEncoder(t reflect.Type) encoderFunc {\n\tswitch t.Kind() {\n\tcase reflect.Pointer:\n\t\tinner := t.Elem()\n\n\t\tinnerEncoder := e.newPrimitiveTypeEncoder(inner)\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\tif !v.IsValid() || v.IsNil() {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\treturn innerEncoder(key, v.Elem())\n\t\t}\n\tcase reflect.String:\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\treturn []Pair{{key, v.String()}}, nil\n\t\t}\n\tcase reflect.Bool:\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\tif v.Bool() {\n\t\t\t\treturn []Pair{{key, \"true\"}}, nil\n\t\t\t}\n\t\t\treturn []Pair{{key, \"false\"}}, nil\n\t\t}\n\tcase reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\treturn []Pair{{key, strconv.FormatInt(v.Int(), 10)}}, nil\n\t\t}\n\tcase reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\treturn []Pair{{key, strconv.FormatUint(v.Uint(), 10)}}, nil\n\t\t}\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\treturn []Pair{{key, strconv.FormatFloat(v.Float(), 'f', -1, 64)}}, nil\n\t\t}\n\tcase reflect.Complex64, reflect.Complex128:\n\t\tbitSize := 64\n\t\tif t.Kind() == reflect.Complex128 {\n\t\t\tbitSize = 128\n\t\t}\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\treturn []Pair{{key, strconv.FormatComplex(v.Complex(), 'f', -1, bitSize)}}, nil\n\t\t}\n\tdefault:\n\t\treturn func(key string, v reflect.Value) ([]Pair, error) {\n\t\t\treturn nil, nil\n\t\t}\n\t}\n}\n\nfunc (e *encoder) newTimeTypeEncoder(_ reflect.Type) encoderFunc {\n\tformat := e.dateFormat\n\treturn func(key string, value reflect.Value) ([]Pair, error) {\n\t\treturn []Pair{{\n\t\t\tkey,\n\t\t\tvalue.Convert(reflect.TypeOf(time.Time{})).Interface().(time.Time).Format(format),\n\t\t}}, nil\n\t}\n}\n\nfunc (e encoder) newInterfaceEncoder() encoderFunc {\n\treturn func(key string, value reflect.Value) ([]Pair, error) {\n\t\tvalue = value.Elem()\n\t\tif !value.IsValid() {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn e.typeEncoder(value.Type())(key, value)\n\t}\n\n}\n"
  },
  {
    "path": "internal/apiquery/query.go",
    "content": "package apiquery\n\nimport (\n\t\"net/url\"\n\t\"reflect\"\n\t\"time\"\n)\n\nfunc MarshalWithSettings(value any, settings QuerySettings) (url.Values, error) {\n\te := encoder{time.RFC3339, true, settings}\n\tkv := url.Values{}\n\tval := reflect.ValueOf(value)\n\tif !val.IsValid() {\n\t\treturn nil, nil\n\t}\n\ttyp := val.Type()\n\n\tpairs, err := e.typeEncoder(typ)(\"\", val)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, pair := range pairs {\n\t\tkv.Add(pair.key, pair.value)\n\t}\n\treturn kv, nil\n}\n\nfunc Marshal(value any) (url.Values, error) {\n\treturn MarshalWithSettings(value, QuerySettings{})\n}\n\ntype Queryer interface {\n\tURLQuery() (url.Values, error)\n}\n\ntype QuerySettings struct {\n\tNestedFormat NestedQueryFormat\n\tArrayFormat  ArrayQueryFormat\n}\n\ntype NestedQueryFormat int\n\nconst (\n\tNestedQueryFormatBrackets NestedQueryFormat = iota\n\tNestedQueryFormatDots\n)\n\ntype ArrayQueryFormat int\n\nconst (\n\tArrayQueryFormatComma ArrayQueryFormat = iota\n\tArrayQueryFormatRepeat\n\tArrayQueryFormatIndices\n\tArrayQueryFormatBrackets\n)\n"
  },
  {
    "path": "internal/apiquery/query_test.go",
    "content": "package apiquery\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"net/url\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc P[T any](v T) *T { return &v }\n\ntype Primitives struct {\n\tA bool    `query:\"a\"`\n\tB int     `query:\"b\"`\n\tC uint    `query:\"c\"`\n\tD float64 `query:\"d\"`\n\tE float32 `query:\"e\"`\n\tF []int   `query:\"f\"`\n}\n\ntype PrimitivePointers struct {\n\tA *bool    `query:\"a\"`\n\tB *int     `query:\"b\"`\n\tC *uint    `query:\"c\"`\n\tD *float64 `query:\"d\"`\n\tE *float32 `query:\"e\"`\n\tF *[]int   `query:\"f\"`\n}\n\ntype Slices struct {\n\tSlice []Primitives `query:\"slices\"`\n\tMixed []any        `query:\"mixed\"`\n}\n\ntype DateTime struct {\n\tDate     time.Time `query:\"date\" format:\"date\"`\n\tDateTime time.Time `query:\"date-time\" format:\"date-time\"`\n}\n\ntype AdditionalProperties struct {\n\tA      bool           `query:\"a\"`\n\tExtras map[string]any `query:\"-,inline\"`\n}\n\ntype Recursive struct {\n\tName  string     `query:\"name\"`\n\tChild *Recursive `query:\"child\"`\n}\n\ntype UnknownStruct struct {\n\tUnknown any `query:\"unknown\"`\n}\n\ntype UnionStruct struct {\n\tUnion Union `query:\"union\" format:\"date\"`\n}\n\ntype Union interface {\n\tunion()\n}\n\ntype UnionInteger int64\n\nfunc (UnionInteger) union() {}\n\ntype UnionString string\n\nfunc (UnionString) union() {}\n\ntype UnionStructA struct {\n\tType string `query:\"type\"`\n\tA    string `query:\"a\"`\n\tB    string `query:\"b\"`\n}\n\nfunc (UnionStructA) union() {}\n\ntype UnionStructB struct {\n\tType string `query:\"type\"`\n\tA    string `query:\"a\"`\n}\n\nfunc (UnionStructB) union() {}\n\ntype UnionTime time.Time\n\nfunc (UnionTime) union() {}\n\ntype DeeplyNested struct {\n\tA DeeplyNested1 `query:\"a\"`\n}\n\ntype DeeplyNested1 struct {\n\tB DeeplyNested2 `query:\"b\"`\n}\n\ntype DeeplyNested2 struct {\n\tC DeeplyNested3 `query:\"c\"`\n}\n\ntype DeeplyNested3 struct {\n\tD *string `query:\"d\"`\n}\n\ntype RichPrimitives struct {\n\tA param.Opt[string] `query:\"a\"`\n}\n\ntype QueryOmitTest struct {\n\tA param.Opt[string] `query:\"a,omitzero\"`\n\tB string            `query:\"b,omitzero\"`\n}\n\ntype NamedEnum string\n\nconst NamedEnumFoo NamedEnum = \"foo\"\n\ntype StructUnionWrapper struct {\n\tUnion StructUnion `query:\"union\"`\n}\n\ntype StructUnion struct {\n\tOfInt    param.Opt[int64]     `query:\",omitzero,inline\"`\n\tOfString param.Opt[string]    `query:\",omitzero,inline\"`\n\tOfEnum   param.Opt[NamedEnum] `query:\",omitzero,inline\"`\n\tOfA      UnionStructA         `query:\",omitzero,inline\"`\n\tOfB      UnionStructB         `query:\",omitzero,inline\"`\n\tparam.APIUnion\n}\n\nvar tests = map[string]struct {\n\tenc      string\n\tval      any\n\tsettings QuerySettings\n}{\n\t\"primitives\": {\n\t\t\"a=false&b=237628372683&c=654&d=9999.43&e=43.7599983215332&f=1,2,3,4\",\n\t\tPrimitives{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t\tQuerySettings{},\n\t},\n\n\t\"slices_brackets\": {\n\t\t`mixed[]=1&mixed[]=2.3&mixed[]=hello&slices[][a]=false&slices[][a]=false&slices[][b]=237628372683&slices[][b]=237628372683&slices[][c]=654&slices[][c]=654&slices[][d]=9999.43&slices[][d]=9999.43&slices[][e]=43.7599983215332&slices[][e]=43.7599983215332&slices[][f][]=1&slices[][f][]=2&slices[][f][]=3&slices[][f][]=4&slices[][f][]=1&slices[][f][]=2&slices[][f][]=3&slices[][f][]=4`,\n\t\tSlices{\n\t\t\tSlice: []Primitives{\n\t\t\t\t{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t\t\t\t{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t\t\t},\n\t\t\tMixed: []any{1, 2.3, \"hello\"},\n\t\t},\n\t\tQuerySettings{ArrayFormat: ArrayQueryFormatBrackets},\n\t},\n\n\t\"slices_comma\": {\n\t\t`mixed=1,2.3,hello`,\n\t\tSlices{\n\t\t\tMixed: []any{1, 2.3, \"hello\"},\n\t\t},\n\t\tQuerySettings{ArrayFormat: ArrayQueryFormatComma},\n\t},\n\n\t\"slices_repeat\": {\n\t\t`mixed=1&mixed=2.3&mixed=hello&slices[a]=false&slices[a]=false&slices[b]=237628372683&slices[b]=237628372683&slices[c]=654&slices[c]=654&slices[d]=9999.43&slices[d]=9999.43&slices[e]=43.7599983215332&slices[e]=43.7599983215332&slices[f]=1&slices[f]=2&slices[f]=3&slices[f]=4&slices[f]=1&slices[f]=2&slices[f]=3&slices[f]=4`,\n\t\tSlices{\n\t\t\tSlice: []Primitives{\n\t\t\t\t{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t\t\t\t{A: false, B: 237628372683, C: uint(654), D: 9999.43, E: 43.76, F: []int{1, 2, 3, 4}},\n\t\t\t},\n\t\t\tMixed: []any{1, 2.3, \"hello\"},\n\t\t},\n\t\tQuerySettings{ArrayFormat: ArrayQueryFormatRepeat},\n\t},\n\n\t\"primitive_pointer_struct\": {\n\t\t\"a=false&b=237628372683&c=654&d=9999.43&e=43.7599983215332&f=1,2,3,4,5\",\n\t\tPrimitivePointers{\n\t\t\tA: P(false),\n\t\t\tB: P(237628372683),\n\t\t\tC: P(uint(654)),\n\t\t\tD: P(9999.43),\n\t\t\tE: P(float32(43.76)),\n\t\t\tF: &[]int{1, 2, 3, 4, 5},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"datetime_struct\": {\n\t\t`date=2006-01-02&date-time=2006-01-02T15:04:05Z`,\n\t\tDateTime{\n\t\t\tDate:     time.Date(2006, time.January, 2, 0, 0, 0, 0, time.UTC),\n\t\t\tDateTime: time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC),\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"additional_properties\": {\n\t\t`a=true&bar=value&foo=true`,\n\t\tAdditionalProperties{\n\t\t\tA: true,\n\t\t\tExtras: map[string]any{\n\t\t\t\t\"bar\": \"value\",\n\t\t\t\t\"foo\": true,\n\t\t\t},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"recursive_struct_brackets\": {\n\t\t`child[name]=Alex&name=Robert`,\n\t\tRecursive{Name: \"Robert\", Child: &Recursive{Name: \"Alex\"}},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatBrackets},\n\t},\n\n\t\"recursive_struct_dots\": {\n\t\t`child.name=Alex&name=Robert`,\n\t\tRecursive{Name: \"Robert\", Child: &Recursive{Name: \"Alex\"}},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatDots},\n\t},\n\n\t\"unknown_struct_number\": {\n\t\t`unknown=12`,\n\t\tUnknownStruct{\n\t\t\tUnknown: 12.,\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"unknown_struct_map_brackets\": {\n\t\t`unknown[foo]=bar`,\n\t\tUnknownStruct{\n\t\t\tUnknown: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatBrackets},\n\t},\n\n\t\"unknown_struct_map_dots\": {\n\t\t`unknown.foo=bar`,\n\t\tUnknownStruct{\n\t\t\tUnknown: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatDots},\n\t},\n\n\t\"struct_union_string\": {\n\t\t`union=hello`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfString: param.NewOpt(\"hello\")},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"union_string\": {\n\t\t`union=hello`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionString(\"hello\"),\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"struct_union_integer\": {\n\t\t`union=12`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfInt: param.NewOpt[int64](12)},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"union_integer\": {\n\t\t`union=12`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionInteger(12),\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"struct_union_enum\": {\n\t\t`union=foo`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfEnum: param.NewOpt[NamedEnum](NamedEnumFoo)},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"struct_union_struct_discriminated_a\": {\n\t\t`union[a]=foo&union[b]=bar&union[type]=typeA`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfA: UnionStructA{\n\t\t\t\tType: \"typeA\",\n\t\t\t\tA:    \"foo\",\n\t\t\t\tB:    \"bar\",\n\t\t\t}},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"union_struct_discriminated_a\": {\n\t\t`union[a]=foo&union[b]=bar&union[type]=typeA`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionStructA{\n\t\t\t\tType: \"typeA\",\n\t\t\t\tA:    \"foo\",\n\t\t\t\tB:    \"bar\",\n\t\t\t},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"struct_union_struct_discriminated_b\": {\n\t\t`union[a]=foo&union[type]=typeB`,\n\t\tStructUnionWrapper{\n\t\t\tUnion: StructUnion{OfB: UnionStructB{\n\t\t\t\tType: \"typeB\",\n\t\t\t\tA:    \"foo\",\n\t\t\t}},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"union_struct_discriminated_b\": {\n\t\t`union[a]=foo&union[type]=typeB`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionStructB{\n\t\t\t\tType: \"typeB\",\n\t\t\t\tA:    \"foo\",\n\t\t\t},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"union_struct_time\": {\n\t\t`union=2010-05-23`,\n\t\tUnionStruct{\n\t\t\tUnion: UnionTime(time.Date(2010, 05, 23, 0, 0, 0, 0, time.UTC)),\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"deeply_nested_brackets\": {\n\t\t`a[b][c][d]=hello`,\n\t\tDeeplyNested{\n\t\t\tA: DeeplyNested1{\n\t\t\t\tB: DeeplyNested2{\n\t\t\t\t\tC: DeeplyNested3{\n\t\t\t\t\t\tD: P(\"hello\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatBrackets},\n\t},\n\n\t\"deeply_nested_dots\": {\n\t\t`a.b.c.d=hello`,\n\t\tDeeplyNested{\n\t\t\tA: DeeplyNested1{\n\t\t\t\tB: DeeplyNested2{\n\t\t\t\t\tC: DeeplyNested3{\n\t\t\t\t\t\tD: P(\"hello\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatDots},\n\t},\n\n\t\"deeply_nested_brackets_empty\": {\n\t\t``,\n\t\tDeeplyNested{\n\t\t\tA: DeeplyNested1{\n\t\t\t\tB: DeeplyNested2{\n\t\t\t\t\tC: DeeplyNested3{\n\t\t\t\t\t\tD: nil,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatBrackets},\n\t},\n\n\t\"deeply_nested_dots_empty\": {\n\t\t``,\n\t\tDeeplyNested{\n\t\t\tA: DeeplyNested1{\n\t\t\t\tB: DeeplyNested2{\n\t\t\t\t\tC: DeeplyNested3{\n\t\t\t\t\t\tD: nil,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tQuerySettings{NestedFormat: NestedQueryFormatDots},\n\t},\n\n\t\"rich_primitives\": {\n\t\t`a=hello`,\n\t\tRichPrimitives{\n\t\t\tA: param.Opt[string]{Value: \"hello\"},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\n\t\"rich_primitives_omit\": {\n\t\t``,\n\t\tQueryOmitTest{\n\t\t\tA: param.Opt[string]{},\n\t\t},\n\t\tQuerySettings{},\n\t},\n\t\"query_omit\": {\n\t\t`a=hello`,\n\t\tQueryOmitTest{\n\t\t\tA: param.Opt[string]{Value: \"hello\"},\n\t\t},\n\t\tQuerySettings{},\n\t},\n}\n\nfunc TestEncode(t *testing.T) {\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tvalues, err := MarshalWithSettings(test.val, test.settings)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"failed to marshal url %s\", err)\n\t\t\t}\n\t\t\tstr, _ := url.QueryUnescape(values.Encode())\n\t\t\tif str != test.enc {\n\t\t\t\tt.Fatalf(\"expected %+#v to serialize to %s but got %s\", test.val, test.enc, str)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "internal/apiquery/richparam.go",
    "content": "package apiquery\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"reflect\"\n)\n\nfunc (e *encoder) newRichFieldTypeEncoder(t reflect.Type) encoderFunc {\n\tf, _ := t.FieldByName(\"Value\")\n\tenc := e.typeEncoder(f.Type)\n\treturn func(key string, value reflect.Value) ([]Pair, error) {\n\t\tif opt, ok := value.Interface().(param.Optional); ok && opt.Valid() {\n\t\t\treturn enc(key, value.FieldByIndex(f.Index))\n\t\t} else if ok && param.IsNull(opt) {\n\t\t\treturn []Pair{{key, \"null\"}}, nil\n\t\t}\n\t\treturn nil, nil\n\t}\n}\n"
  },
  {
    "path": "internal/apiquery/tag.go",
    "content": "package apiquery\n\nimport (\n\t\"reflect\"\n\t\"strings\"\n)\n\nconst queryStructTag = \"query\"\nconst formatStructTag = \"format\"\n\ntype parsedStructTag struct {\n\tname      string\n\tomitempty bool\n\tomitzero  bool\n\tinline    bool\n}\n\nfunc parseQueryStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {\n\traw, ok := field.Tag.Lookup(queryStructTag)\n\tif !ok {\n\t\treturn tag, ok\n\t}\n\tparts := strings.Split(raw, \",\")\n\tif len(parts) == 0 {\n\t\treturn tag, false\n\t}\n\ttag.name = parts[0]\n\tfor _, part := range parts[1:] {\n\t\tswitch part {\n\t\tcase \"omitzero\":\n\t\t\ttag.omitzero = true\n\t\tcase \"omitempty\":\n\t\t\ttag.omitempty = true\n\t\tcase \"inline\":\n\t\t\ttag.inline = true\n\t\t}\n\t}\n\treturn tag, ok\n}\n\nfunc parseFormatStructTag(field reflect.StructField) (format string, ok bool) {\n\tformat, ok = field.Tag.Lookup(formatStructTag)\n\treturn format, ok\n}\n"
  },
  {
    "path": "internal/encoding/json/decode.go",
    "content": "// Vendored from Go 1.24.0-pre-release\n// To find alterations, check package shims, and comments beginning in SHIM().\n//\n// Copyright 2010 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Represents JSON data structure using native Go types: booleans, floats,\n// strings, arrays, and maps.\n\npackage json\n\nimport (\n\t\"encoding\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/shims\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n\t\"unicode/utf16\"\n\t\"unicode/utf8\"\n\t_ \"unsafe\" // for linkname\n)\n\n// Unmarshal parses the JSON-encoded data and stores the result\n// in the value pointed to by v. If v is nil or not a pointer,\n// Unmarshal returns an [InvalidUnmarshalError].\n//\n// Unmarshal uses the inverse of the encodings that\n// [Marshal] uses, allocating maps, slices, and pointers as necessary,\n// with the following additional rules:\n//\n// To unmarshal JSON into a pointer, Unmarshal first handles the case of\n// the JSON being the JSON literal null. In that case, Unmarshal sets\n// the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into\n// the value pointed at by the pointer. If the pointer is nil, Unmarshal\n// allocates a new value for it to point to.\n//\n// To unmarshal JSON into a value implementing [Unmarshaler],\n// Unmarshal calls that value's [Unmarshaler.UnmarshalJSON] method, including\n// when the input is a JSON null.\n// Otherwise, if the value implements [encoding.TextUnmarshaler]\n// and the input is a JSON quoted string, Unmarshal calls\n// [encoding.TextUnmarshaler.UnmarshalText] with the unquoted form of the string.\n//\n// To unmarshal JSON into a struct, Unmarshal matches incoming object\n// keys to the keys used by [Marshal] (either the struct field name or its tag),\n// preferring an exact match but also accepting a case-insensitive match. By\n// default, object keys which don't have a corresponding struct field are\n// ignored (see [Decoder.DisallowUnknownFields] for an alternative).\n//\n// To unmarshal JSON into an interface value,\n// Unmarshal stores one of these in the interface value:\n//\n//   - bool, for JSON booleans\n//   - float64, for JSON numbers\n//   - string, for JSON strings\n//   - []any, for JSON arrays\n//   - map[string]any, for JSON objects\n//   - nil for JSON null\n//\n// To unmarshal a JSON array into a slice, Unmarshal resets the slice length\n// to zero and then appends each element to the slice.\n// As a special case, to unmarshal an empty JSON array into a slice,\n// Unmarshal replaces the slice with a new empty slice.\n//\n// To unmarshal a JSON array into a Go array, Unmarshal decodes\n// JSON array elements into corresponding Go array elements.\n// If the Go array is smaller than the JSON array,\n// the additional JSON array elements are discarded.\n// If the JSON array is smaller than the Go array,\n// the additional Go array elements are set to zero values.\n//\n// To unmarshal a JSON object into a map, Unmarshal first establishes a map to\n// use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal\n// reuses the existing map, keeping existing entries. Unmarshal then stores\n// key-value pairs from the JSON object into the map. The map's key type must\n// either be any string type, an integer, or implement [encoding.TextUnmarshaler].\n//\n// If the JSON-encoded data contain a syntax error, Unmarshal returns a [SyntaxError].\n//\n// If a JSON value is not appropriate for a given target type,\n// or if a JSON number overflows the target type, Unmarshal\n// skips that field and completes the unmarshaling as best it can.\n// If no more serious errors are encountered, Unmarshal returns\n// an [UnmarshalTypeError] describing the earliest such error. In any\n// case, it's not guaranteed that all the remaining fields following\n// the problematic one will be unmarshaled into the target object.\n//\n// The JSON null value unmarshals into an interface, map, pointer, or slice\n// by setting that Go value to nil. Because null is often used in JSON to mean\n// “not present,” unmarshaling a JSON null into any other Go type has no effect\n// on the value and produces no error.\n//\n// When unmarshaling quoted strings, invalid UTF-8 or\n// invalid UTF-16 surrogate pairs are not treated as an error.\n// Instead, they are replaced by the Unicode replacement\n// character U+FFFD.\nfunc Unmarshal(data []byte, v any) error {\n\t// Check for well-formedness.\n\t// Avoids filling out half a data structure\n\t// before discovering a JSON syntax error.\n\tvar d decodeState\n\terr := checkValid(data, &d.scan)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.init(data)\n\treturn d.unmarshal(v)\n}\n\n// Unmarshaler is the interface implemented by types\n// that can unmarshal a JSON description of themselves.\n// The input can be assumed to be a valid encoding of\n// a JSON value. UnmarshalJSON must copy the JSON data\n// if it wishes to retain the data after returning.\n//\n// By convention, to approximate the behavior of [Unmarshal] itself,\n// Unmarshalers implement UnmarshalJSON([]byte(\"null\")) as a no-op.\ntype Unmarshaler interface {\n\tUnmarshalJSON([]byte) error\n}\n\n// An UnmarshalTypeError describes a JSON value that was\n// not appropriate for a value of a specific Go type.\ntype UnmarshalTypeError struct {\n\tValue  string       // description of JSON value - \"bool\", \"array\", \"number -5\"\n\tType   reflect.Type // type of Go value it could not be assigned to\n\tOffset int64        // error occurred after reading Offset bytes\n\tStruct string       // name of the struct type containing the field\n\tField  string       // the full path from root node to the field, include embedded struct\n}\n\nfunc (e *UnmarshalTypeError) Error() string {\n\tif e.Struct != \"\" || e.Field != \"\" {\n\t\treturn \"json: cannot unmarshal \" + e.Value + \" into Go struct field \" + e.Struct + \".\" + e.Field + \" of type \" + e.Type.String()\n\t}\n\treturn \"json: cannot unmarshal \" + e.Value + \" into Go value of type \" + e.Type.String()\n}\n\n// An UnmarshalFieldError describes a JSON object key that\n// led to an unexported (and therefore unwritable) struct field.\n//\n// Deprecated: No longer used; kept for compatibility.\ntype UnmarshalFieldError struct {\n\tKey   string\n\tType  reflect.Type\n\tField reflect.StructField\n}\n\nfunc (e *UnmarshalFieldError) Error() string {\n\treturn \"json: cannot unmarshal object key \" + strconv.Quote(e.Key) + \" into unexported field \" + e.Field.Name + \" of type \" + e.Type.String()\n}\n\n// An InvalidUnmarshalError describes an invalid argument passed to [Unmarshal].\n// (The argument to [Unmarshal] must be a non-nil pointer.)\ntype InvalidUnmarshalError struct {\n\tType reflect.Type\n}\n\nfunc (e *InvalidUnmarshalError) Error() string {\n\tif e.Type == nil {\n\t\treturn \"json: Unmarshal(nil)\"\n\t}\n\n\tif e.Type.Kind() != reflect.Pointer {\n\t\treturn \"json: Unmarshal(non-pointer \" + e.Type.String() + \")\"\n\t}\n\treturn \"json: Unmarshal(nil \" + e.Type.String() + \")\"\n}\n\nfunc (d *decodeState) unmarshal(v any) error {\n\trv := reflect.ValueOf(v)\n\tif rv.Kind() != reflect.Pointer || rv.IsNil() {\n\t\treturn &InvalidUnmarshalError{reflect.TypeOf(v)}\n\t}\n\n\td.scan.reset()\n\td.scanWhile(scanSkipSpace)\n\t// We decode rv not rv.Elem because the Unmarshaler interface\n\t// test must be applied at the top level of the value.\n\terr := d.value(rv)\n\tif err != nil {\n\t\treturn d.addErrorContext(err)\n\t}\n\treturn d.savedError\n}\n\n// A Number represents a JSON number literal.\ntype Number string\n\n// String returns the literal text of the number.\nfunc (n Number) String() string { return string(n) }\n\n// Float64 returns the number as a float64.\nfunc (n Number) Float64() (float64, error) {\n\treturn strconv.ParseFloat(string(n), 64)\n}\n\n// Int64 returns the number as an int64.\nfunc (n Number) Int64() (int64, error) {\n\treturn strconv.ParseInt(string(n), 10, 64)\n}\n\n// An errorContext provides context for type errors during decoding.\ntype errorContext struct {\n\tStruct     reflect.Type\n\tFieldStack []string\n}\n\n// decodeState represents the state while decoding a JSON value.\ntype decodeState struct {\n\tdata                  []byte\n\toff                   int // next read offset in data\n\topcode                int // last read result\n\tscan                  scanner\n\terrorContext          *errorContext\n\tsavedError            error\n\tuseNumber             bool\n\tdisallowUnknownFields bool\n}\n\n// readIndex returns the position of the last byte read.\nfunc (d *decodeState) readIndex() int {\n\treturn d.off - 1\n}\n\n// phasePanicMsg is used as a panic message when we end up with something that\n// shouldn't happen. It can indicate a bug in the JSON decoder, or that\n// something is editing the data slice while the decoder executes.\nconst phasePanicMsg = \"JSON decoder out of sync - data changing underfoot?\"\n\nfunc (d *decodeState) init(data []byte) *decodeState {\n\td.data = data\n\td.off = 0\n\td.savedError = nil\n\tif d.errorContext != nil {\n\t\td.errorContext.Struct = nil\n\t\t// Reuse the allocated space for the FieldStack slice.\n\t\td.errorContext.FieldStack = d.errorContext.FieldStack[:0]\n\t}\n\treturn d\n}\n\n// saveError saves the first err it is called with,\n// for reporting at the end of the unmarshal.\nfunc (d *decodeState) saveError(err error) {\n\tif d.savedError == nil {\n\t\td.savedError = d.addErrorContext(err)\n\t}\n}\n\n// addErrorContext returns a new error enhanced with information from d.errorContext\nfunc (d *decodeState) addErrorContext(err error) error {\n\tif d.errorContext != nil && (d.errorContext.Struct != nil || len(d.errorContext.FieldStack) > 0) {\n\t\tswitch err := err.(type) {\n\t\tcase *UnmarshalTypeError:\n\t\t\terr.Struct = d.errorContext.Struct.Name()\n\t\t\tfieldStack := d.errorContext.FieldStack\n\t\t\tif err.Field != \"\" {\n\t\t\t\tfieldStack = append(fieldStack, err.Field)\n\t\t\t}\n\t\t\terr.Field = strings.Join(fieldStack, \".\")\n\t\t}\n\t}\n\treturn err\n}\n\n// skip scans to the end of what was started.\nfunc (d *decodeState) skip() {\n\ts, data, i := &d.scan, d.data, d.off\n\tdepth := len(s.parseState)\n\tfor {\n\t\top := s.step(s, data[i])\n\t\ti++\n\t\tif len(s.parseState) < depth {\n\t\t\td.off = i\n\t\t\td.opcode = op\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// scanNext processes the byte at d.data[d.off].\nfunc (d *decodeState) scanNext() {\n\tif d.off < len(d.data) {\n\t\td.opcode = d.scan.step(&d.scan, d.data[d.off])\n\t\td.off++\n\t} else {\n\t\td.opcode = d.scan.eof()\n\t\td.off = len(d.data) + 1 // mark processed EOF with len+1\n\t}\n}\n\n// scanWhile processes bytes in d.data[d.off:] until it\n// receives a scan code not equal to op.\nfunc (d *decodeState) scanWhile(op int) {\n\ts, data, i := &d.scan, d.data, d.off\n\tfor i < len(data) {\n\t\tnewOp := s.step(s, data[i])\n\t\ti++\n\t\tif newOp != op {\n\t\t\td.opcode = newOp\n\t\t\td.off = i\n\t\t\treturn\n\t\t}\n\t}\n\n\td.off = len(data) + 1 // mark processed EOF with len+1\n\td.opcode = d.scan.eof()\n}\n\n// rescanLiteral is similar to scanWhile(scanContinue), but it specialises the\n// common case where we're decoding a literal. The decoder scans the input\n// twice, once for syntax errors and to check the length of the value, and the\n// second to perform the decoding.\n//\n// Only in the second step do we use decodeState to tokenize literals, so we\n// know there aren't any syntax errors. We can take advantage of that knowledge,\n// and scan a literal's bytes much more quickly.\nfunc (d *decodeState) rescanLiteral() {\n\tdata, i := d.data, d.off\nSwitch:\n\tswitch data[i-1] {\n\tcase '\"': // string\n\t\tfor ; i < len(data); i++ {\n\t\t\tswitch data[i] {\n\t\t\tcase '\\\\':\n\t\t\t\ti++ // escaped char\n\t\t\tcase '\"':\n\t\t\t\ti++ // tokenize the closing quote too\n\t\t\t\tbreak Switch\n\t\t\t}\n\t\t}\n\tcase '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-': // number\n\t\tfor ; i < len(data); i++ {\n\t\t\tswitch data[i] {\n\t\t\tcase '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n\t\t\t\t'.', 'e', 'E', '+', '-':\n\t\t\tdefault:\n\t\t\t\tbreak Switch\n\t\t\t}\n\t\t}\n\tcase 't': // true\n\t\ti += len(\"rue\")\n\tcase 'f': // false\n\t\ti += len(\"alse\")\n\tcase 'n': // null\n\t\ti += len(\"ull\")\n\t}\n\tif i < len(data) {\n\t\td.opcode = stateEndValue(&d.scan, data[i])\n\t} else {\n\t\td.opcode = scanEnd\n\t}\n\td.off = i + 1\n}\n\n// value consumes a JSON value from d.data[d.off-1:], decoding into v, and\n// reads the following byte ahead. If v is invalid, the value is discarded.\n// The first byte of the value has been read already.\nfunc (d *decodeState) value(v reflect.Value) error {\n\tswitch d.opcode {\n\tdefault:\n\t\tpanic(phasePanicMsg)\n\n\tcase scanBeginArray:\n\t\tif v.IsValid() {\n\t\t\tif err := d.array(v); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\td.skip()\n\t\t}\n\t\td.scanNext()\n\n\tcase scanBeginObject:\n\t\tif v.IsValid() {\n\t\t\tif err := d.object(v); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\td.skip()\n\t\t}\n\t\td.scanNext()\n\n\tcase scanBeginLiteral:\n\t\t// All bytes inside literal return scanContinue op code.\n\t\tstart := d.readIndex()\n\t\td.rescanLiteral()\n\n\t\tif v.IsValid() {\n\t\t\tif err := d.literalStore(d.data[start:d.readIndex()], v, false); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\ntype unquotedValue struct{}\n\n// valueQuoted is like value but decodes a\n// quoted string literal or literal null into an interface value.\n// If it finds anything other than a quoted string literal or null,\n// valueQuoted returns unquotedValue{}.\nfunc (d *decodeState) valueQuoted() any {\n\tswitch d.opcode {\n\tdefault:\n\t\tpanic(phasePanicMsg)\n\n\tcase scanBeginArray, scanBeginObject:\n\t\td.skip()\n\t\td.scanNext()\n\n\tcase scanBeginLiteral:\n\t\tv := d.literalInterface()\n\t\tswitch v.(type) {\n\t\tcase nil, string:\n\t\t\treturn v\n\t\t}\n\t}\n\treturn unquotedValue{}\n}\n\n// indirect walks down v allocating pointers as needed,\n// until it gets to a non-pointer.\n// If it encounters an Unmarshaler, indirect stops and returns that.\n// If decodingNull is true, indirect stops at the first settable pointer so it\n// can be set to nil.\nfunc indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnmarshaler, reflect.Value) {\n\t// Issue #24153 indicates that it is generally not a guaranteed property\n\t// that you may round-trip a reflect.Value by calling Value.Addr().Elem()\n\t// and expect the value to still be settable for values derived from\n\t// unexported embedded struct fields.\n\t//\n\t// The logic below effectively does this when it first addresses the value\n\t// (to satisfy possible pointer methods) and continues to dereference\n\t// subsequent pointers as necessary.\n\t//\n\t// After the first round-trip, we set v back to the original value to\n\t// preserve the original RW flags contained in reflect.Value.\n\tv0 := v\n\thaveAddr := false\n\n\t// If v is a named type and is addressable,\n\t// start with its address, so that if the type has pointer methods,\n\t// we find them.\n\tif v.Kind() != reflect.Pointer && v.Type().Name() != \"\" && v.CanAddr() {\n\t\thaveAddr = true\n\t\tv = v.Addr()\n\t}\n\tfor {\n\t\t// Load value from interface, but only if the result will be\n\t\t// usefully addressable.\n\t\tif v.Kind() == reflect.Interface && !v.IsNil() {\n\t\t\te := v.Elem()\n\t\t\tif e.Kind() == reflect.Pointer && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Pointer) {\n\t\t\t\thaveAddr = false\n\t\t\t\tv = e\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif v.Kind() != reflect.Pointer {\n\t\t\tbreak\n\t\t}\n\n\t\tif decodingNull && v.CanSet() {\n\t\t\tbreak\n\t\t}\n\n\t\t// Prevent infinite loop if v is an interface pointing to its own address:\n\t\t//     var v any\n\t\t//     v = &v\n\t\tif v.Elem().Kind() == reflect.Interface && v.Elem().Elem().Equal(v) {\n\t\t\tv = v.Elem()\n\t\t\tbreak\n\t\t}\n\t\tif v.IsNil() {\n\t\t\tv.Set(reflect.New(v.Type().Elem()))\n\t\t}\n\t\tif v.Type().NumMethod() > 0 && v.CanInterface() {\n\t\t\tif u, ok := v.Interface().(Unmarshaler); ok {\n\t\t\t\treturn u, nil, reflect.Value{}\n\t\t\t}\n\t\t\tif !decodingNull {\n\t\t\t\tif u, ok := v.Interface().(encoding.TextUnmarshaler); ok {\n\t\t\t\t\treturn nil, u, reflect.Value{}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif haveAddr {\n\t\t\tv = v0 // restore original value after round-trip Value.Addr().Elem()\n\t\t\thaveAddr = false\n\t\t} else {\n\t\t\tv = v.Elem()\n\t\t}\n\t}\n\treturn nil, nil, v\n}\n\n// array consumes an array from d.data[d.off-1:], decoding into v.\n// The first byte of the array ('[') has been read already.\nfunc (d *decodeState) array(v reflect.Value) error {\n\t// Check for unmarshaler.\n\tu, ut, pv := indirect(v, false)\n\tif u != nil {\n\t\tstart := d.readIndex()\n\t\td.skip()\n\t\treturn u.UnmarshalJSON(d.data[start:d.off])\n\t}\n\tif ut != nil {\n\t\td.saveError(&UnmarshalTypeError{Value: \"array\", Type: v.Type(), Offset: int64(d.off)})\n\t\td.skip()\n\t\treturn nil\n\t}\n\tv = pv\n\n\t// Check type of target.\n\tswitch v.Kind() {\n\tcase reflect.Interface:\n\t\tif v.NumMethod() == 0 {\n\t\t\t// Decoding into nil interface? Switch to non-reflect code.\n\t\t\tai := d.arrayInterface()\n\t\t\tv.Set(reflect.ValueOf(ai))\n\t\t\treturn nil\n\t\t}\n\t\t// Otherwise it's invalid.\n\t\tfallthrough\n\tdefault:\n\t\td.saveError(&UnmarshalTypeError{Value: \"array\", Type: v.Type(), Offset: int64(d.off)})\n\t\td.skip()\n\t\treturn nil\n\tcase reflect.Array, reflect.Slice:\n\t\tbreak\n\t}\n\n\ti := 0\n\tfor {\n\t\t// Look ahead for ] - can only happen on first iteration.\n\t\td.scanWhile(scanSkipSpace)\n\t\tif d.opcode == scanEndArray {\n\t\t\tbreak\n\t\t}\n\n\t\t// Expand slice length, growing the slice if necessary.\n\t\tif v.Kind() == reflect.Slice {\n\t\t\tif i >= v.Cap() {\n\t\t\t\tv.Grow(1)\n\t\t\t}\n\t\t\tif i >= v.Len() {\n\t\t\t\tv.SetLen(i + 1)\n\t\t\t}\n\t\t}\n\n\t\tif i < v.Len() {\n\t\t\t// Decode into element.\n\t\t\tif err := d.value(v.Index(i)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\t// Ran out of fixed array: skip.\n\t\t\tif err := d.value(reflect.Value{}); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\ti++\n\n\t\t// Next token must be , or ].\n\t\tif d.opcode == scanSkipSpace {\n\t\t\td.scanWhile(scanSkipSpace)\n\t\t}\n\t\tif d.opcode == scanEndArray {\n\t\t\tbreak\n\t\t}\n\t\tif d.opcode != scanArrayValue {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t}\n\n\tif i < v.Len() {\n\t\tif v.Kind() == reflect.Array {\n\t\t\tfor ; i < v.Len(); i++ {\n\t\t\t\tv.Index(i).SetZero() // zero remainder of array\n\t\t\t}\n\t\t} else {\n\t\t\tv.SetLen(i) // truncate the slice\n\t\t}\n\t}\n\tif i == 0 && v.Kind() == reflect.Slice {\n\t\tv.Set(reflect.MakeSlice(v.Type(), 0, 0))\n\t}\n\treturn nil\n}\n\nvar nullLiteral = []byte(\"null\")\n\n// SHIM(reflect): reflect.TypeFor[T]() reflect.T\nvar textUnmarshalerType = shims.TypeFor[encoding.TextUnmarshaler]()\n\n// object consumes an object from d.data[d.off-1:], decoding into v.\n// The first byte ('{') of the object has been read already.\nfunc (d *decodeState) object(v reflect.Value) error {\n\t// Check for unmarshaler.\n\tu, ut, pv := indirect(v, false)\n\tif u != nil {\n\t\tstart := d.readIndex()\n\t\td.skip()\n\t\treturn u.UnmarshalJSON(d.data[start:d.off])\n\t}\n\tif ut != nil {\n\t\td.saveError(&UnmarshalTypeError{Value: \"object\", Type: v.Type(), Offset: int64(d.off)})\n\t\td.skip()\n\t\treturn nil\n\t}\n\tv = pv\n\tt := v.Type()\n\n\t// Decoding into nil interface? Switch to non-reflect code.\n\tif v.Kind() == reflect.Interface && v.NumMethod() == 0 {\n\t\toi := d.objectInterface()\n\t\tv.Set(reflect.ValueOf(oi))\n\t\treturn nil\n\t}\n\n\tvar fields structFields\n\n\t// Check type of target:\n\t//   struct or\n\t//   map[T1]T2 where T1 is string, an integer type,\n\t//             or an encoding.TextUnmarshaler\n\tswitch v.Kind() {\n\tcase reflect.Map:\n\t\t// Map key must either have string kind, have an integer kind,\n\t\t// or be an encoding.TextUnmarshaler.\n\t\tswitch t.Key().Kind() {\n\t\tcase reflect.String,\n\t\t\treflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\tdefault:\n\t\t\tif !reflect.PointerTo(t.Key()).Implements(textUnmarshalerType) {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"object\", Type: t, Offset: int64(d.off)})\n\t\t\t\td.skip()\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\tif v.IsNil() {\n\t\t\tv.Set(reflect.MakeMap(t))\n\t\t}\n\tcase reflect.Struct:\n\t\tfields = cachedTypeFields(t)\n\t\t// ok\n\tdefault:\n\t\td.saveError(&UnmarshalTypeError{Value: \"object\", Type: t, Offset: int64(d.off)})\n\t\td.skip()\n\t\treturn nil\n\t}\n\n\tvar mapElem reflect.Value\n\tvar origErrorContext errorContext\n\tif d.errorContext != nil {\n\t\torigErrorContext = *d.errorContext\n\t}\n\n\tfor {\n\t\t// Read opening \" of string key or closing }.\n\t\td.scanWhile(scanSkipSpace)\n\t\tif d.opcode == scanEndObject {\n\t\t\t// closing } - can only happen on first iteration.\n\t\t\tbreak\n\t\t}\n\t\tif d.opcode != scanBeginLiteral {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\n\t\t// Read key.\n\t\tstart := d.readIndex()\n\t\td.rescanLiteral()\n\t\titem := d.data[start:d.readIndex()]\n\t\tkey, ok := unquoteBytes(item)\n\t\tif !ok {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\n\t\t// Figure out field corresponding to key.\n\t\tvar subv reflect.Value\n\t\tdestring := false // whether the value is wrapped in a string to be decoded first\n\n\t\tif v.Kind() == reflect.Map {\n\t\t\telemType := t.Elem()\n\t\t\tif !mapElem.IsValid() {\n\t\t\t\tmapElem = reflect.New(elemType).Elem()\n\t\t\t} else {\n\t\t\t\tmapElem.SetZero()\n\t\t\t}\n\t\t\tsubv = mapElem\n\t\t} else {\n\t\t\tf := fields.byExactName[string(key)]\n\t\t\tif f == nil {\n\t\t\t\tf = fields.byFoldedName[string(foldName(key))]\n\t\t\t}\n\t\t\tif f != nil {\n\t\t\t\tsubv = v\n\t\t\t\tdestring = f.quoted\n\t\t\t\tif d.errorContext == nil {\n\t\t\t\t\td.errorContext = new(errorContext)\n\t\t\t\t}\n\t\t\t\tfor i, ind := range f.index {\n\t\t\t\t\tif subv.Kind() == reflect.Pointer {\n\t\t\t\t\t\tif subv.IsNil() {\n\t\t\t\t\t\t\t// If a struct embeds a pointer to an unexported type,\n\t\t\t\t\t\t\t// it is not possible to set a newly allocated value\n\t\t\t\t\t\t\t// since the field is unexported.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// See https://golang.org/issue/21357\n\t\t\t\t\t\t\tif !subv.CanSet() {\n\t\t\t\t\t\t\t\td.saveError(fmt.Errorf(\"json: cannot set embedded pointer to unexported struct: %v\", subv.Type().Elem()))\n\t\t\t\t\t\t\t\t// Invalidate subv to ensure d.value(subv) skips over\n\t\t\t\t\t\t\t\t// the JSON value without assigning it to subv.\n\t\t\t\t\t\t\t\tsubv = reflect.Value{}\n\t\t\t\t\t\t\t\tdestring = false\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubv.Set(reflect.New(subv.Type().Elem()))\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsubv = subv.Elem()\n\t\t\t\t\t}\n\t\t\t\t\tif i < len(f.index)-1 {\n\t\t\t\t\t\td.errorContext.FieldStack = append(\n\t\t\t\t\t\t\td.errorContext.FieldStack,\n\t\t\t\t\t\t\tsubv.Type().Field(ind).Name,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tsubv = subv.Field(ind)\n\t\t\t\t}\n\t\t\t\td.errorContext.Struct = t\n\t\t\t\td.errorContext.FieldStack = append(d.errorContext.FieldStack, f.name)\n\t\t\t} else if d.disallowUnknownFields {\n\t\t\t\td.saveError(fmt.Errorf(\"json: unknown field %q\", key))\n\t\t\t}\n\t\t}\n\n\t\t// Read : before value.\n\t\tif d.opcode == scanSkipSpace {\n\t\t\td.scanWhile(scanSkipSpace)\n\t\t}\n\t\tif d.opcode != scanObjectKey {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\td.scanWhile(scanSkipSpace)\n\n\t\tif destring {\n\t\t\tswitch qv := d.valueQuoted().(type) {\n\t\t\tcase nil:\n\t\t\t\tif err := d.literalStore(nullLiteral, subv, false); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\tcase string:\n\t\t\t\tif err := d.literalStore([]byte(qv), subv, true); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\td.saveError(fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v\", subv.Type()))\n\t\t\t}\n\t\t} else {\n\t\t\tif err := d.value(subv); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// Write value back to map;\n\t\t// if using struct, subv points into struct already.\n\t\tif v.Kind() == reflect.Map {\n\t\t\tkt := t.Key()\n\t\t\tvar kv reflect.Value\n\t\t\tif reflect.PointerTo(kt).Implements(textUnmarshalerType) {\n\t\t\t\tkv = reflect.New(kt)\n\t\t\t\tif err := d.literalStore(item, kv, true); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tkv = kv.Elem()\n\t\t\t} else {\n\t\t\t\tswitch kt.Kind() {\n\t\t\t\tcase reflect.String:\n\t\t\t\t\tkv = reflect.New(kt).Elem()\n\t\t\t\t\tkv.SetString(string(key))\n\t\t\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\t\t\ts := string(key)\n\t\t\t\t\tn, err := strconv.ParseInt(s, 10, 64)\n\t\t\t\t\t// SHIM(reflect): reflect.Type.OverflowInt(int64) bool\n\t\t\t\t\tokt := shims.OverflowableType{Type: kt}\n\t\t\t\t\tif err != nil || okt.OverflowInt(n) {\n\t\t\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"number \" + s, Type: kt, Offset: int64(start + 1)})\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tkv = reflect.New(kt).Elem()\n\t\t\t\t\tkv.SetInt(n)\n\t\t\t\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\t\t\t\ts := string(key)\n\t\t\t\t\tn, err := strconv.ParseUint(s, 10, 64)\n\t\t\t\t\t// SHIM(reflect): reflect.Type.OverflowUint(uint64) bool\n\t\t\t\t\tokt := shims.OverflowableType{Type: kt}\n\t\t\t\t\tif err != nil || okt.OverflowUint(n) {\n\t\t\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"number \" + s, Type: kt, Offset: int64(start + 1)})\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tkv = reflect.New(kt).Elem()\n\t\t\t\t\tkv.SetUint(n)\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(\"json: Unexpected key type\") // should never occur\n\t\t\t\t}\n\t\t\t}\n\t\t\tif kv.IsValid() {\n\t\t\t\tv.SetMapIndex(kv, subv)\n\t\t\t}\n\t\t}\n\n\t\t// Next token must be , or }.\n\t\tif d.opcode == scanSkipSpace {\n\t\t\td.scanWhile(scanSkipSpace)\n\t\t}\n\t\tif d.errorContext != nil {\n\t\t\t// Reset errorContext to its original state.\n\t\t\t// Keep the same underlying array for FieldStack, to reuse the\n\t\t\t// space and avoid unnecessary allocs.\n\t\t\td.errorContext.FieldStack = d.errorContext.FieldStack[:len(origErrorContext.FieldStack)]\n\t\t\td.errorContext.Struct = origErrorContext.Struct\n\t\t}\n\t\tif d.opcode == scanEndObject {\n\t\t\tbreak\n\t\t}\n\t\tif d.opcode != scanObjectValue {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t}\n\treturn nil\n}\n\n// convertNumber converts the number literal s to a float64 or a Number\n// depending on the setting of d.useNumber.\nfunc (d *decodeState) convertNumber(s string) (any, error) {\n\tif d.useNumber {\n\t\treturn Number(s), nil\n\t}\n\tf, err := strconv.ParseFloat(s, 64)\n\tif err != nil {\n\t\t// SHIM(reflect): reflect.TypeFor[T]() reflect.Type\n\t\treturn nil, &UnmarshalTypeError{Value: \"number \" + s, Type: shims.TypeFor[float64](), Offset: int64(d.off)}\n\t}\n\treturn f, nil\n}\n\n// SHIM(reflect): TypeFor[T]() reflect.Type\nvar numberType = shims.TypeFor[Number]()\n\n// literalStore decodes a literal stored in item into v.\n//\n// fromQuoted indicates whether this literal came from unwrapping a\n// string from the \",string\" struct tag option. this is used only to\n// produce more helpful error messages.\nfunc (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool) error {\n\t// Check for unmarshaler.\n\tif len(item) == 0 {\n\t\t// Empty string given.\n\t\td.saveError(fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type()))\n\t\treturn nil\n\t}\n\tisNull := item[0] == 'n' // null\n\tu, ut, pv := indirect(v, isNull)\n\tif u != nil {\n\t\treturn u.UnmarshalJSON(item)\n\t}\n\tif ut != nil {\n\t\tif item[0] != '\"' {\n\t\t\tif fromQuoted {\n\t\t\t\td.saveError(fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type()))\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tval := \"number\"\n\t\t\tswitch item[0] {\n\t\t\tcase 'n':\n\t\t\t\tval = \"null\"\n\t\t\tcase 't', 'f':\n\t\t\t\tval = \"bool\"\n\t\t\t}\n\t\t\td.saveError(&UnmarshalTypeError{Value: val, Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\treturn nil\n\t\t}\n\t\ts, ok := unquoteBytes(item)\n\t\tif !ok {\n\t\t\tif fromQuoted {\n\t\t\t\treturn fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type())\n\t\t\t}\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\treturn ut.UnmarshalText(s)\n\t}\n\n\tv = pv\n\n\tswitch c := item[0]; c {\n\tcase 'n': // null\n\t\t// The main parser checks that only true and false can reach here,\n\t\t// but if this was a quoted string input, it could be anything.\n\t\tif fromQuoted && string(item) != \"null\" {\n\t\t\td.saveError(fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type()))\n\t\t\tbreak\n\t\t}\n\t\tswitch v.Kind() {\n\t\tcase reflect.Interface, reflect.Pointer, reflect.Map, reflect.Slice:\n\t\t\tv.SetZero()\n\t\t\t// otherwise, ignore null for primitives/string\n\t\t}\n\tcase 't', 'f': // true, false\n\t\tvalue := item[0] == 't'\n\t\t// The main parser checks that only true and false can reach here,\n\t\t// but if this was a quoted string input, it could be anything.\n\t\tif fromQuoted && string(item) != \"true\" && string(item) != \"false\" {\n\t\t\td.saveError(fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type()))\n\t\t\tbreak\n\t\t}\n\t\tswitch v.Kind() {\n\t\tdefault:\n\t\t\tif fromQuoted {\n\t\t\t\td.saveError(fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type()))\n\t\t\t} else {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"bool\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t}\n\t\tcase reflect.Bool:\n\t\t\tv.SetBool(value)\n\t\tcase reflect.Interface:\n\t\t\tif v.NumMethod() == 0 {\n\t\t\t\tv.Set(reflect.ValueOf(value))\n\t\t\t} else {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"bool\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t}\n\t\t}\n\n\tcase '\"': // string\n\t\ts, ok := unquoteBytes(item)\n\t\tif !ok {\n\t\t\tif fromQuoted {\n\t\t\t\treturn fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type())\n\t\t\t}\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\tswitch v.Kind() {\n\t\tdefault:\n\t\t\td.saveError(&UnmarshalTypeError{Value: \"string\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\tcase reflect.Slice:\n\t\t\tif v.Type().Elem().Kind() != reflect.Uint8 {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"string\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tb := make([]byte, base64.StdEncoding.DecodedLen(len(s)))\n\t\t\tn, err := base64.StdEncoding.Decode(b, s)\n\t\t\tif err != nil {\n\t\t\t\td.saveError(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tv.SetBytes(b[:n])\n\t\tcase reflect.String:\n\t\t\tt := string(s)\n\t\t\tif v.Type() == numberType && !isValidNumber(t) {\n\t\t\t\treturn fmt.Errorf(\"json: invalid number literal, trying to unmarshal %q into Number\", item)\n\t\t\t}\n\t\t\tv.SetString(t)\n\t\tcase reflect.Interface:\n\t\t\tif v.NumMethod() == 0 {\n\t\t\t\tv.Set(reflect.ValueOf(string(s)))\n\t\t\t} else {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"string\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t}\n\t\t}\n\n\tdefault: // number\n\t\tif c != '-' && (c < '0' || c > '9') {\n\t\t\tif fromQuoted {\n\t\t\t\treturn fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type())\n\t\t\t}\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\tswitch v.Kind() {\n\t\tdefault:\n\t\t\tif v.Kind() == reflect.String && v.Type() == numberType {\n\t\t\t\t// s must be a valid number, because it's\n\t\t\t\t// already been tokenized.\n\t\t\t\tv.SetString(string(item))\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif fromQuoted {\n\t\t\t\treturn fmt.Errorf(\"json: invalid use of ,string struct tag, trying to unmarshal %q into %v\", item, v.Type())\n\t\t\t}\n\t\t\td.saveError(&UnmarshalTypeError{Value: \"number\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\tcase reflect.Interface:\n\t\t\tn, err := d.convertNumber(string(item))\n\t\t\tif err != nil {\n\t\t\t\td.saveError(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif v.NumMethod() != 0 {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"number\", Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tv.Set(reflect.ValueOf(n))\n\n\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\tn, err := strconv.ParseInt(string(item), 10, 64)\n\t\t\tif err != nil || v.OverflowInt(n) {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"number \" + string(item), Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tv.SetInt(n)\n\n\t\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\t\tn, err := strconv.ParseUint(string(item), 10, 64)\n\t\t\tif err != nil || v.OverflowUint(n) {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"number \" + string(item), Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tv.SetUint(n)\n\n\t\tcase reflect.Float32, reflect.Float64:\n\t\t\tn, err := strconv.ParseFloat(string(item), v.Type().Bits())\n\t\t\tif err != nil || v.OverflowFloat(n) {\n\t\t\t\td.saveError(&UnmarshalTypeError{Value: \"number \" + string(item), Type: v.Type(), Offset: int64(d.readIndex())})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tv.SetFloat(n)\n\t\t}\n\t}\n\treturn nil\n}\n\n// The xxxInterface routines build up a value to be stored\n// in an empty interface. They are not strictly necessary,\n// but they avoid the weight of reflection in this common case.\n\n// valueInterface is like value but returns any.\nfunc (d *decodeState) valueInterface() (val any) {\n\tswitch d.opcode {\n\tdefault:\n\t\tpanic(phasePanicMsg)\n\tcase scanBeginArray:\n\t\tval = d.arrayInterface()\n\t\td.scanNext()\n\tcase scanBeginObject:\n\t\tval = d.objectInterface()\n\t\td.scanNext()\n\tcase scanBeginLiteral:\n\t\tval = d.literalInterface()\n\t}\n\treturn\n}\n\n// arrayInterface is like array but returns []any.\nfunc (d *decodeState) arrayInterface() []any {\n\tvar v = make([]any, 0)\n\tfor {\n\t\t// Look ahead for ] - can only happen on first iteration.\n\t\td.scanWhile(scanSkipSpace)\n\t\tif d.opcode == scanEndArray {\n\t\t\tbreak\n\t\t}\n\n\t\tv = append(v, d.valueInterface())\n\n\t\t// Next token must be , or ].\n\t\tif d.opcode == scanSkipSpace {\n\t\t\td.scanWhile(scanSkipSpace)\n\t\t}\n\t\tif d.opcode == scanEndArray {\n\t\t\tbreak\n\t\t}\n\t\tif d.opcode != scanArrayValue {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t}\n\treturn v\n}\n\n// objectInterface is like object but returns map[string]any.\nfunc (d *decodeState) objectInterface() map[string]any {\n\tm := make(map[string]any)\n\tfor {\n\t\t// Read opening \" of string key or closing }.\n\t\td.scanWhile(scanSkipSpace)\n\t\tif d.opcode == scanEndObject {\n\t\t\t// closing } - can only happen on first iteration.\n\t\t\tbreak\n\t\t}\n\t\tif d.opcode != scanBeginLiteral {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\n\t\t// Read string key.\n\t\tstart := d.readIndex()\n\t\td.rescanLiteral()\n\t\titem := d.data[start:d.readIndex()]\n\t\tkey, ok := unquote(item)\n\t\tif !ok {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\n\t\t// Read : before value.\n\t\tif d.opcode == scanSkipSpace {\n\t\t\td.scanWhile(scanSkipSpace)\n\t\t}\n\t\tif d.opcode != scanObjectKey {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\td.scanWhile(scanSkipSpace)\n\n\t\t// Read value.\n\t\tm[key] = d.valueInterface()\n\n\t\t// Next token must be , or }.\n\t\tif d.opcode == scanSkipSpace {\n\t\t\td.scanWhile(scanSkipSpace)\n\t\t}\n\t\tif d.opcode == scanEndObject {\n\t\t\tbreak\n\t\t}\n\t\tif d.opcode != scanObjectValue {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t}\n\treturn m\n}\n\n// literalInterface consumes and returns a literal from d.data[d.off-1:] and\n// it reads the following byte ahead. The first byte of the literal has been\n// read already (that's how the caller knows it's a literal).\nfunc (d *decodeState) literalInterface() any {\n\t// All bytes inside literal return scanContinue op code.\n\tstart := d.readIndex()\n\td.rescanLiteral()\n\n\titem := d.data[start:d.readIndex()]\n\n\tswitch c := item[0]; c {\n\tcase 'n': // null\n\t\treturn nil\n\n\tcase 't', 'f': // true, false\n\t\treturn c == 't'\n\n\tcase '\"': // string\n\t\ts, ok := unquote(item)\n\t\tif !ok {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\treturn s\n\n\tdefault: // number\n\t\tif c != '-' && (c < '0' || c > '9') {\n\t\t\tpanic(phasePanicMsg)\n\t\t}\n\t\tn, err := d.convertNumber(string(item))\n\t\tif err != nil {\n\t\t\td.saveError(err)\n\t\t}\n\t\treturn n\n\t}\n}\n\n// getu4 decodes \\uXXXX from the beginning of s, returning the hex value,\n// or it returns -1.\nfunc getu4(s []byte) rune {\n\tif len(s) < 6 || s[0] != '\\\\' || s[1] != 'u' {\n\t\treturn -1\n\t}\n\tvar r rune\n\tfor _, c := range s[2:6] {\n\t\tswitch {\n\t\tcase '0' <= c && c <= '9':\n\t\t\tc = c - '0'\n\t\tcase 'a' <= c && c <= 'f':\n\t\t\tc = c - 'a' + 10\n\t\tcase 'A' <= c && c <= 'F':\n\t\t\tc = c - 'A' + 10\n\t\tdefault:\n\t\t\treturn -1\n\t\t}\n\t\tr = r*16 + rune(c)\n\t}\n\treturn r\n}\n\n// unquote converts a quoted JSON string literal s into an actual string t.\n// The rules are different than for Go, so cannot use strconv.Unquote.\nfunc unquote(s []byte) (t string, ok bool) {\n\ts, ok = unquoteBytes(s)\n\tt = string(s)\n\treturn\n}\n\n// unquoteBytes should be an internal detail,\n// but widely used packages access it using linkname.\n// Notable members of the hall of shame include:\n//   - github.com/bytedance/sonic\n//\n// Do not remove or change the type signature.\n// See go.dev/issue/67401.\n//\n//go:linkname unquoteBytes\nfunc unquoteBytes(s []byte) (t []byte, ok bool) {\n\tif len(s) < 2 || s[0] != '\"' || s[len(s)-1] != '\"' {\n\t\treturn\n\t}\n\ts = s[1 : len(s)-1]\n\n\t// Check for unusual characters. If there are none,\n\t// then no unquoting is needed, so return a slice of the\n\t// original bytes.\n\tr := 0\n\tfor r < len(s) {\n\t\tc := s[r]\n\t\tif c == '\\\\' || c == '\"' || c < ' ' {\n\t\t\tbreak\n\t\t}\n\t\tif c < utf8.RuneSelf {\n\t\t\tr++\n\t\t\tcontinue\n\t\t}\n\t\trr, size := utf8.DecodeRune(s[r:])\n\t\tif rr == utf8.RuneError && size == 1 {\n\t\t\tbreak\n\t\t}\n\t\tr += size\n\t}\n\tif r == len(s) {\n\t\treturn s, true\n\t}\n\n\tb := make([]byte, len(s)+2*utf8.UTFMax)\n\tw := copy(b, s[0:r])\n\tfor r < len(s) {\n\t\t// Out of room? Can only happen if s is full of\n\t\t// malformed UTF-8 and we're replacing each\n\t\t// byte with RuneError.\n\t\tif w >= len(b)-2*utf8.UTFMax {\n\t\t\tnb := make([]byte, (len(b)+utf8.UTFMax)*2)\n\t\t\tcopy(nb, b[0:w])\n\t\t\tb = nb\n\t\t}\n\t\tswitch c := s[r]; {\n\t\tcase c == '\\\\':\n\t\t\tr++\n\t\t\tif r >= len(s) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tswitch s[r] {\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t\tcase '\"', '\\\\', '/', '\\'':\n\t\t\t\tb[w] = s[r]\n\t\t\t\tr++\n\t\t\t\tw++\n\t\t\tcase 'b':\n\t\t\t\tb[w] = '\\b'\n\t\t\t\tr++\n\t\t\t\tw++\n\t\t\tcase 'f':\n\t\t\t\tb[w] = '\\f'\n\t\t\t\tr++\n\t\t\t\tw++\n\t\t\tcase 'n':\n\t\t\t\tb[w] = '\\n'\n\t\t\t\tr++\n\t\t\t\tw++\n\t\t\tcase 'r':\n\t\t\t\tb[w] = '\\r'\n\t\t\t\tr++\n\t\t\t\tw++\n\t\t\tcase 't':\n\t\t\t\tb[w] = '\\t'\n\t\t\t\tr++\n\t\t\t\tw++\n\t\t\tcase 'u':\n\t\t\t\tr--\n\t\t\t\trr := getu4(s[r:])\n\t\t\t\tif rr < 0 {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tr += 6\n\t\t\t\tif utf16.IsSurrogate(rr) {\n\t\t\t\t\trr1 := getu4(s[r:])\n\t\t\t\t\tif dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar {\n\t\t\t\t\t\t// A valid pair; consume.\n\t\t\t\t\t\tr += 6\n\t\t\t\t\t\tw += utf8.EncodeRune(b[w:], dec)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\t// Invalid surrogate; fall back to replacement rune.\n\t\t\t\t\trr = unicode.ReplacementChar\n\t\t\t\t}\n\t\t\t\tw += utf8.EncodeRune(b[w:], rr)\n\t\t\t}\n\n\t\t// Quote, control characters are invalid.\n\t\tcase c == '\"', c < ' ':\n\t\t\treturn\n\n\t\t// ASCII\n\t\tcase c < utf8.RuneSelf:\n\t\t\tb[w] = c\n\t\t\tr++\n\t\t\tw++\n\n\t\t// Coerce to well-formed UTF-8.\n\t\tdefault:\n\t\t\trr, size := utf8.DecodeRune(s[r:])\n\t\t\tr += size\n\t\t\tw += utf8.EncodeRune(b[w:], rr)\n\t\t}\n\t}\n\treturn b[0:w], true\n}\n"
  },
  {
    "path": "internal/encoding/json/encode.go",
    "content": "// Vendored from Go 1.24.0-pre-release\n// To find alterations, check package shims, and comments beginning in SHIM().\n//\n// Copyright 2010 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package json implements encoding and decoding of JSON as defined in\n// RFC 7159. The mapping between JSON and Go values is described\n// in the documentation for the Marshal and Unmarshal functions.\n//\n// See \"JSON and Go\" for an introduction to this package:\n// https://golang.org/doc/articles/json_and_go.html\npackage json\n\nimport (\n\t\"bytes\"\n\t\"cmp\"\n\t\"encoding\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/sentinel\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/shims\"\n\t\"math\"\n\t\"reflect\"\n\t\"slices\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n\t\"unicode\"\n\t\"unicode/utf8\"\n\t_ \"unsafe\" // for linkname\n)\n\n// Marshal returns the JSON encoding of v.\n//\n// Marshal traverses the value v recursively.\n// If an encountered value implements [Marshaler]\n// and is not a nil pointer, Marshal calls [Marshaler.MarshalJSON]\n// to produce JSON. If no [Marshaler.MarshalJSON] method is present but the\n// value implements [encoding.TextMarshaler] instead, Marshal calls\n// [encoding.TextMarshaler.MarshalText] and encodes the result as a JSON string.\n// The nil pointer exception is not strictly necessary\n// but mimics a similar, necessary exception in the behavior of\n// [Unmarshaler.UnmarshalJSON].\n//\n// Otherwise, Marshal uses the following type-dependent default encodings:\n//\n// Boolean values encode as JSON booleans.\n//\n// Floating point, integer, and [Number] values encode as JSON numbers.\n// NaN and +/-Inf values will return an [UnsupportedValueError].\n//\n// String values encode as JSON strings coerced to valid UTF-8,\n// replacing invalid bytes with the Unicode replacement rune.\n// So that the JSON will be safe to embed inside HTML <script> tags,\n// the string is encoded using [HTMLEscape],\n// which replaces \"<\", \">\", \"&\", U+2028, and U+2029 are escaped\n// to \"\\u003c\",\"\\u003e\", \"\\u0026\", \"\\u2028\", and \"\\u2029\".\n// This replacement can be disabled when using an [Encoder],\n// by calling [Encoder.SetEscapeHTML](false).\n//\n// Array and slice values encode as JSON arrays, except that\n// []byte encodes as a base64-encoded string, and a nil slice\n// encodes as the null JSON value.\n//\n// Struct values encode as JSON objects.\n// Each exported struct field becomes a member of the object, using the\n// field name as the object key, unless the field is omitted for one of the\n// reasons given below.\n//\n// The encoding of each struct field can be customized by the format string\n// stored under the \"json\" key in the struct field's tag.\n// The format string gives the name of the field, possibly followed by a\n// comma-separated list of options. The name may be empty in order to\n// specify options without overriding the default field name.\n//\n// The \"omitempty\" option specifies that the field should be omitted\n// from the encoding if the field has an empty value, defined as\n// false, 0, a nil pointer, a nil interface value, and any array,\n// slice, map, or string of length zero.\n//\n// As a special case, if the field tag is \"-\", the field is always omitted.\n// Note that a field with name \"-\" can still be generated using the tag \"-,\".\n//\n// Examples of struct field tags and their meanings:\n//\n//\t// Field appears in JSON as key \"myName\".\n//\tField int `json:\"myName\"`\n//\n//\t// Field appears in JSON as key \"myName\" and\n//\t// the field is omitted from the object if its value is empty,\n//\t// as defined above.\n//\tField int `json:\"myName,omitempty\"`\n//\n//\t// Field appears in JSON as key \"Field\" (the default), but\n//\t// the field is skipped if empty.\n//\t// Note the leading comma.\n//\tField int `json:\",omitempty\"`\n//\n//\t// Field is ignored by this package.\n//\tField int `json:\"-\"`\n//\n//\t// Field appears in JSON as key \"-\".\n//\tField int `json:\"-,\"`\n//\n// The \"omitzero\" option specifies that the field should be omitted\n// from the encoding if the field has a zero value, according to rules:\n//\n// 1) If the field type has an \"IsZero() bool\" method, that will be used to\n// determine whether the value is zero.\n//\n// 2) Otherwise, the value is zero if it is the zero value for its type.\n//\n// If both \"omitempty\" and \"omitzero\" are specified, the field will be omitted\n// if the value is either empty or zero (or both).\n//\n// The \"string\" option signals that a field is stored as JSON inside a\n// JSON-encoded string. It applies only to fields of string, floating point,\n// integer, or boolean types. This extra level of encoding is sometimes used\n// when communicating with JavaScript programs:\n//\n//\tInt64String int64 `json:\",string\"`\n//\n// The key name will be used if it's a non-empty string consisting of\n// only Unicode letters, digits, and ASCII punctuation except quotation\n// marks, backslash, and comma.\n//\n// Embedded struct fields are usually marshaled as if their inner exported fields\n// were fields in the outer struct, subject to the usual Go visibility rules amended\n// as described in the next paragraph.\n// An anonymous struct field with a name given in its JSON tag is treated as\n// having that name, rather than being anonymous.\n// An anonymous struct field of interface type is treated the same as having\n// that type as its name, rather than being anonymous.\n//\n// The Go visibility rules for struct fields are amended for JSON when\n// deciding which field to marshal or unmarshal. If there are\n// multiple fields at the same level, and that level is the least\n// nested (and would therefore be the nesting level selected by the\n// usual Go rules), the following extra rules apply:\n//\n// 1) Of those fields, if any are JSON-tagged, only tagged fields are considered,\n// even if there are multiple untagged fields that would otherwise conflict.\n//\n// 2) If there is exactly one field (tagged or not according to the first rule), that is selected.\n//\n// 3) Otherwise there are multiple fields, and all are ignored; no error occurs.\n//\n// Handling of anonymous struct fields is new in Go 1.1.\n// Prior to Go 1.1, anonymous struct fields were ignored. To force ignoring of\n// an anonymous struct field in both current and earlier versions, give the field\n// a JSON tag of \"-\".\n//\n// Map values encode as JSON objects. The map's key type must either be a\n// string, an integer type, or implement [encoding.TextMarshaler]. The map keys\n// are sorted and used as JSON object keys by applying the following rules,\n// subject to the UTF-8 coercion described for string values above:\n//   - keys of any string type are used directly\n//   - keys that implement [encoding.TextMarshaler] are marshaled\n//   - integer keys are converted to strings\n//\n// Pointer values encode as the value pointed to.\n// A nil pointer encodes as the null JSON value.\n//\n// Interface values encode as the value contained in the interface.\n// A nil interface value encodes as the null JSON value.\n//\n// Channel, complex, and function values cannot be encoded in JSON.\n// Attempting to encode such a value causes Marshal to return\n// an [UnsupportedTypeError].\n//\n// JSON cannot represent cyclic data structures and Marshal does not\n// handle them. Passing cyclic structures to Marshal will result in\n// an error.\nfunc Marshal(v any) ([]byte, error) {\n\te := newEncodeState()\n\tdefer encodeStatePool.Put(e)\n\n\t// SHIM(begin): don't escape HTML by default\n\terr := e.marshal(v, encOpts{escapeHTML: shims.EscapeHTMLByDefault})\n\t// ORIGINAL:\n\t//  err := e.marshal(v, encOpts{escapeHTML: true})\n\t// SHIM(end)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbuf := append([]byte(nil), e.Bytes()...)\n\n\treturn buf, nil\n}\n\n// MarshalIndent is like [Marshal] but applies [Indent] to format the output.\n// Each JSON element in the output will begin on a new line beginning with prefix\n// followed by one or more copies of indent according to the indentation nesting.\nfunc MarshalIndent(v any, prefix, indent string) ([]byte, error) {\n\tb, err := Marshal(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb2 := make([]byte, 0, indentGrowthFactor*len(b))\n\tb2, err = appendIndent(b2, b, prefix, indent)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn b2, nil\n}\n\n// Marshaler is the interface implemented by types that\n// can marshal themselves into valid JSON.\ntype Marshaler interface {\n\tMarshalJSON() ([]byte, error)\n}\n\n// An UnsupportedTypeError is returned by [Marshal] when attempting\n// to encode an unsupported value type.\ntype UnsupportedTypeError struct {\n\tType reflect.Type\n}\n\nfunc (e *UnsupportedTypeError) Error() string {\n\treturn \"json: unsupported type: \" + e.Type.String()\n}\n\n// An UnsupportedValueError is returned by [Marshal] when attempting\n// to encode an unsupported value.\ntype UnsupportedValueError struct {\n\tValue reflect.Value\n\tStr   string\n}\n\nfunc (e *UnsupportedValueError) Error() string {\n\treturn \"json: unsupported value: \" + e.Str\n}\n\n// Before Go 1.2, an InvalidUTF8Error was returned by [Marshal] when\n// attempting to encode a string value with invalid UTF-8 sequences.\n// As of Go 1.2, [Marshal] instead coerces the string to valid UTF-8 by\n// replacing invalid bytes with the Unicode replacement rune U+FFFD.\n//\n// Deprecated: No longer used; kept for compatibility.\ntype InvalidUTF8Error struct {\n\tS string // the whole string value that caused the error\n}\n\nfunc (e *InvalidUTF8Error) Error() string {\n\treturn \"json: invalid UTF-8 in string: \" + strconv.Quote(e.S)\n}\n\n// A MarshalerError represents an error from calling a\n// [Marshaler.MarshalJSON] or [encoding.TextMarshaler.MarshalText] method.\ntype MarshalerError struct {\n\tType       reflect.Type\n\tErr        error\n\tsourceFunc string\n}\n\nfunc (e *MarshalerError) Error() string {\n\tsrcFunc := e.sourceFunc\n\tif srcFunc == \"\" {\n\t\tsrcFunc = \"MarshalJSON\"\n\t}\n\treturn \"json: error calling \" + srcFunc +\n\t\t\" for type \" + e.Type.String() +\n\t\t\": \" + e.Err.Error()\n}\n\n// Unwrap returns the underlying error.\nfunc (e *MarshalerError) Unwrap() error { return e.Err }\n\nconst hex = \"0123456789abcdef\"\n\n// An encodeState encodes JSON into a bytes.Buffer.\ntype encodeState struct {\n\tbytes.Buffer // accumulated output\n\n\t// Keep track of what pointers we've seen in the current recursive call\n\t// path, to avoid cycles that could lead to a stack overflow. Only do\n\t// the relatively expensive map operations if ptrLevel is larger than\n\t// startDetectingCyclesAfter, so that we skip the work if we're within a\n\t// reasonable amount of nested pointers deep.\n\tptrLevel uint\n\tptrSeen  map[any]struct{}\n}\n\nconst startDetectingCyclesAfter = 1000\n\nvar encodeStatePool sync.Pool\n\nfunc newEncodeState() *encodeState {\n\tif v := encodeStatePool.Get(); v != nil {\n\t\te := v.(*encodeState)\n\t\te.Reset()\n\t\tif len(e.ptrSeen) > 0 {\n\t\t\tpanic(\"ptrEncoder.encode should have emptied ptrSeen via defers\")\n\t\t}\n\t\te.ptrLevel = 0\n\t\treturn e\n\t}\n\treturn &encodeState{ptrSeen: make(map[any]struct{})}\n}\n\n// jsonError is an error wrapper type for internal use only.\n// Panics with errors are wrapped in jsonError so that the top-level recover\n// can distinguish intentional panics from this package.\ntype jsonError struct{ error }\n\nfunc (e *encodeState) marshal(v any, opts encOpts) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tif je, ok := r.(jsonError); ok {\n\t\t\t\terr = je.error\n\t\t\t} else {\n\t\t\t\tpanic(r)\n\t\t\t}\n\t\t}\n\t}()\n\te.reflectValue(reflect.ValueOf(v), opts)\n\treturn nil\n}\n\n// error aborts the encoding by panicking with err wrapped in jsonError.\nfunc (e *encodeState) error(err error) {\n\tpanic(jsonError{err})\n}\n\nfunc isEmptyValue(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.String:\n\t\treturn v.Len() == 0\n\tcase reflect.Array, reflect.Map, reflect.Slice:\n\t\treturn v.Len() == 0\n\tcase reflect.Bool,\n\t\treflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,\n\t\treflect.Float32, reflect.Float64,\n\t\treflect.Interface, reflect.Pointer:\n\t\treturn v.IsZero()\n\t}\n\treturn false\n}\n\nfunc (e *encodeState) reflectValue(v reflect.Value, opts encOpts) {\n\tvalueEncoder(v)(e, v, opts)\n}\n\ntype encOpts struct {\n\t// quoted causes primitive fields to be encoded inside JSON strings.\n\tquoted bool\n\t// escapeHTML causes '<', '>', and '&' to be escaped in JSON strings.\n\tescapeHTML bool\n\t// EDIT(begin): save the timefmt\n\ttimefmt string\n\t// EDIT(end)\n}\n\ntype encoderFunc func(e *encodeState, v reflect.Value, opts encOpts)\n\nvar encoderCache sync.Map // map[reflect.Type]encoderFunc\n\nfunc valueEncoder(v reflect.Value) encoderFunc {\n\tif !v.IsValid() {\n\t\treturn invalidValueEncoder\n\t}\n\treturn typeEncoder(v.Type())\n}\n\nfunc typeEncoder(t reflect.Type) encoderFunc {\n\tif fi, ok := encoderCache.Load(t); ok {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// To deal with recursive types, populate the map with an\n\t// indirect func before we build it. This type waits on the\n\t// real func (f) to be ready and then calls it. This indirect\n\t// func is only used for recursive types.\n\tvar (\n\t\twg sync.WaitGroup\n\t\tf  encoderFunc\n\t)\n\twg.Add(1)\n\tfi, loaded := encoderCache.LoadOrStore(t, encoderFunc(func(e *encodeState, v reflect.Value, opts encOpts) {\n\t\twg.Wait()\n\t\tf(e, v, opts)\n\t}))\n\tif loaded {\n\t\treturn fi.(encoderFunc)\n\t}\n\n\t// Compute the real encoder and replace the indirect func with it.\n\tf = newTypeEncoder(t, true)\n\twg.Done()\n\tencoderCache.Store(t, f)\n\treturn f\n}\n\nvar (\n\t// SHIM(begin): TypeFor[T]() reflect.Type\n\tmarshalerType     = shims.TypeFor[Marshaler]()\n\ttextMarshalerType = shims.TypeFor[encoding.TextMarshaler]()\n\t// SHIM(end)\n)\n\n// newTypeEncoder constructs an encoderFunc for a type.\n// The returned encoder only checks CanAddr when allowAddr is true.\nfunc newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc {\n\t// EDIT(begin): add custom time encoder\n\tif t == timeType {\n\t\treturn newTimeEncoder()\n\t}\n\t// EDIT(end)\n\n\t// If we have a non-pointer value whose type implements\n\t// Marshaler with a value receiver, then we're better off taking\n\t// the address of the value - otherwise we end up with an\n\t// allocation as we cast the value to an interface.\n\tif t.Kind() != reflect.Pointer && allowAddr && reflect.PointerTo(t).Implements(marshalerType) {\n\t\treturn newCondAddrEncoder(addrMarshalerEncoder, newTypeEncoder(t, false))\n\t}\n\n\tif t.Implements(marshalerType) {\n\t\treturn marshalerEncoder\n\t}\n\tif t.Kind() != reflect.Pointer && allowAddr && reflect.PointerTo(t).Implements(textMarshalerType) {\n\t\treturn newCondAddrEncoder(addrTextMarshalerEncoder, newTypeEncoder(t, false))\n\t}\n\tif t.Implements(textMarshalerType) {\n\t\treturn textMarshalerEncoder\n\t}\n\n\tswitch t.Kind() {\n\tcase reflect.Bool:\n\t\treturn boolEncoder\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn intEncoder\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn uintEncoder\n\tcase reflect.Float32:\n\t\treturn float32Encoder\n\tcase reflect.Float64:\n\t\treturn float64Encoder\n\tcase reflect.String:\n\t\treturn stringEncoder\n\tcase reflect.Interface:\n\t\treturn interfaceEncoder\n\tcase reflect.Struct:\n\t\treturn newStructEncoder(t)\n\tcase reflect.Map:\n\t\treturn newMapEncoder(t)\n\tcase reflect.Slice:\n\t\treturn newSliceEncoder(t)\n\tcase reflect.Array:\n\t\treturn newArrayEncoder(t)\n\tcase reflect.Pointer:\n\t\treturn newPtrEncoder(t)\n\tdefault:\n\t\treturn unsupportedTypeEncoder\n\t}\n}\n\nfunc invalidValueEncoder(e *encodeState, v reflect.Value, _ encOpts) {\n\te.WriteString(\"null\")\n}\n\nfunc marshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.Kind() == reflect.Pointer && v.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\tm, ok := v.Interface().(Marshaler)\n\tif !ok {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\n\t// EDIT(begin): use custom time encoder\n\tif timeMarshalEncoder(e, v, opts) {\n\t\treturn\n\t}\n\t// EDIT(end)\n\n\tb, err := m.MarshalJSON()\n\tif err == nil {\n\t\te.Grow(len(b))\n\t\tout := e.AvailableBuffer()\n\t\tout, err = appendCompact(out, b, opts.escapeHTML)\n\t\te.Buffer.Write(out)\n\t}\n\tif err != nil {\n\t\te.error(&MarshalerError{v.Type(), err, \"MarshalJSON\"})\n\t}\n}\n\nfunc addrMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tva := v.Addr()\n\tif va.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\n\t// EDIT(begin): use custom time encoder\n\tif timeMarshalEncoder(e, v, opts) {\n\t\treturn\n\t}\n\t// EDIT(end)\n\n\tm := va.Interface().(Marshaler)\n\tb, err := m.MarshalJSON()\n\tif err == nil {\n\t\te.Grow(len(b))\n\t\tout := e.AvailableBuffer()\n\t\tout, err = appendCompact(out, b, opts.escapeHTML)\n\t\te.Buffer.Write(out)\n\t}\n\tif err != nil {\n\t\te.error(&MarshalerError{v.Type(), err, \"MarshalJSON\"})\n\t}\n}\n\nfunc textMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.Kind() == reflect.Pointer && v.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\tm, ok := v.Interface().(encoding.TextMarshaler)\n\tif !ok {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\tb, err := m.MarshalText()\n\tif err != nil {\n\t\te.error(&MarshalerError{v.Type(), err, \"MarshalText\"})\n\t}\n\te.Write(appendString(e.AvailableBuffer(), b, opts.escapeHTML))\n}\n\nfunc addrTextMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tva := v.Addr()\n\tif va.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\tm := va.Interface().(encoding.TextMarshaler)\n\tb, err := m.MarshalText()\n\tif err != nil {\n\t\te.error(&MarshalerError{v.Type(), err, \"MarshalText\"})\n\t}\n\te.Write(appendString(e.AvailableBuffer(), b, opts.escapeHTML))\n}\n\nfunc boolEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tb := e.AvailableBuffer()\n\tb = mayAppendQuote(b, opts.quoted)\n\tb = strconv.AppendBool(b, v.Bool())\n\tb = mayAppendQuote(b, opts.quoted)\n\te.Write(b)\n}\n\nfunc intEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tb := e.AvailableBuffer()\n\tb = mayAppendQuote(b, opts.quoted)\n\tb = strconv.AppendInt(b, v.Int(), 10)\n\tb = mayAppendQuote(b, opts.quoted)\n\te.Write(b)\n}\n\nfunc uintEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tb := e.AvailableBuffer()\n\tb = mayAppendQuote(b, opts.quoted)\n\tb = strconv.AppendUint(b, v.Uint(), 10)\n\tb = mayAppendQuote(b, opts.quoted)\n\te.Write(b)\n}\n\ntype floatEncoder int // number of bits\n\nfunc (bits floatEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\tf := v.Float()\n\tif math.IsInf(f, 0) || math.IsNaN(f) {\n\t\te.error(&UnsupportedValueError{v, strconv.FormatFloat(f, 'g', -1, int(bits))})\n\t}\n\n\t// Convert as if by ES6 number to string conversion.\n\t// This matches most other JSON generators.\n\t// See golang.org/issue/6384 and golang.org/issue/14135.\n\t// Like fmt %g, but the exponent cutoffs are different\n\t// and exponents themselves are not padded to two digits.\n\tb := e.AvailableBuffer()\n\tb = mayAppendQuote(b, opts.quoted)\n\tabs := math.Abs(f)\n\tfmt := byte('f')\n\t// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.\n\tif abs != 0 {\n\t\tif bits == 64 && (abs < 1e-6 || abs >= 1e21) || bits == 32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) {\n\t\t\tfmt = 'e'\n\t\t}\n\t}\n\tb = strconv.AppendFloat(b, f, fmt, -1, int(bits))\n\tif fmt == 'e' {\n\t\t// clean up e-09 to e-9\n\t\tn := len(b)\n\t\tif n >= 4 && b[n-4] == 'e' && b[n-3] == '-' && b[n-2] == '0' {\n\t\t\tb[n-2] = b[n-1]\n\t\t\tb = b[:n-1]\n\t\t}\n\t}\n\tb = mayAppendQuote(b, opts.quoted)\n\te.Write(b)\n}\n\nvar (\n\tfloat32Encoder = (floatEncoder(32)).encode\n\tfloat64Encoder = (floatEncoder(64)).encode\n)\n\nfunc stringEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.Type() == numberType {\n\t\tnumStr := v.String()\n\t\t// In Go1.5 the empty string encodes to \"0\", while this is not a valid number literal\n\t\t// we keep compatibility so check validity after this.\n\t\tif numStr == \"\" {\n\t\t\tnumStr = \"0\" // Number's zero-val\n\t\t}\n\t\tif !isValidNumber(numStr) {\n\t\t\te.error(fmt.Errorf(\"json: invalid number literal %q\", numStr))\n\t\t}\n\t\tb := e.AvailableBuffer()\n\t\tb = mayAppendQuote(b, opts.quoted)\n\t\tb = append(b, numStr...)\n\t\tb = mayAppendQuote(b, opts.quoted)\n\t\te.Write(b)\n\t\treturn\n\t}\n\tif opts.quoted {\n\t\tb := appendString(nil, v.String(), opts.escapeHTML)\n\t\te.Write(appendString(e.AvailableBuffer(), b, false)) // no need to escape again since it is already escaped\n\t} else {\n\t\te.Write(appendString(e.AvailableBuffer(), v.String(), opts.escapeHTML))\n\t}\n}\n\n// isValidNumber reports whether s is a valid JSON number literal.\n//\n// isValidNumber should be an internal detail,\n// but widely used packages access it using linkname.\n// Notable members of the hall of shame include:\n//   - github.com/bytedance/sonic\n//\n// Do not remove or change the type signature.\n// See go.dev/issue/67401.\n//\n//go:linkname isValidNumber\nfunc isValidNumber(s string) bool {\n\t// This function implements the JSON numbers grammar.\n\t// See https://tools.ietf.org/html/rfc7159#section-6\n\t// and https://www.json.org/img/number.png\n\n\tif s == \"\" {\n\t\treturn false\n\t}\n\n\t// Optional -\n\tif s[0] == '-' {\n\t\ts = s[1:]\n\t\tif s == \"\" {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Digits\n\tswitch {\n\tdefault:\n\t\treturn false\n\n\tcase s[0] == '0':\n\t\ts = s[1:]\n\n\tcase '1' <= s[0] && s[0] <= '9':\n\t\ts = s[1:]\n\t\tfor len(s) > 0 && '0' <= s[0] && s[0] <= '9' {\n\t\t\ts = s[1:]\n\t\t}\n\t}\n\n\t// . followed by 1 or more digits.\n\tif len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' {\n\t\ts = s[2:]\n\t\tfor len(s) > 0 && '0' <= s[0] && s[0] <= '9' {\n\t\t\ts = s[1:]\n\t\t}\n\t}\n\n\t// e or E followed by an optional - or + and\n\t// 1 or more digits.\n\tif len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') {\n\t\ts = s[1:]\n\t\tif s[0] == '+' || s[0] == '-' {\n\t\t\ts = s[1:]\n\t\t\tif s == \"\" {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tfor len(s) > 0 && '0' <= s[0] && s[0] <= '9' {\n\t\t\ts = s[1:]\n\t\t}\n\t}\n\n\t// Make sure we are at the end.\n\treturn s == \"\"\n}\n\nfunc interfaceEncoder(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\te.reflectValue(v.Elem(), opts)\n}\n\nfunc unsupportedTypeEncoder(e *encodeState, v reflect.Value, _ encOpts) {\n\te.error(&UnsupportedTypeError{v.Type()})\n}\n\ntype structEncoder struct {\n\tfields structFields\n}\n\ntype structFields struct {\n\tlist         []field\n\tbyExactName  map[string]*field\n\tbyFoldedName map[string]*field\n}\n\nfunc (se structEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\tnext := byte('{')\nFieldLoop:\n\tfor i := range se.fields.list {\n\t\tf := &se.fields.list[i]\n\n\t\t// Find the nested struct field by following f.index.\n\t\tfv := v\n\t\tfor _, i := range f.index {\n\t\t\tif fv.Kind() == reflect.Pointer {\n\t\t\t\tif fv.IsNil() {\n\t\t\t\t\tcontinue FieldLoop\n\t\t\t\t}\n\t\t\t\tfv = fv.Elem()\n\t\t\t}\n\t\t\tfv = fv.Field(i)\n\t\t}\n\n\t\tif (f.omitEmpty && isEmptyValue(fv)) ||\n\t\t\t(f.omitZero && (f.isZero == nil && fv.IsZero() || (f.isZero != nil && f.isZero(fv)))) {\n\t\t\tcontinue\n\t\t}\n\t\te.WriteByte(next)\n\t\tnext = ','\n\t\tif opts.escapeHTML {\n\t\t\te.WriteString(f.nameEscHTML)\n\t\t} else {\n\t\t\te.WriteString(f.nameNonEsc)\n\t\t}\n\t\topts.quoted = f.quoted\n\t\tf.encoder(e, fv, opts)\n\t}\n\tif next == '{' {\n\t\te.WriteString(\"{}\")\n\t} else {\n\t\te.WriteByte('}')\n\t}\n}\n\nfunc newStructEncoder(t reflect.Type) encoderFunc {\n\tse := structEncoder{fields: cachedTypeFields(t)}\n\treturn se.encode\n}\n\ntype mapEncoder struct {\n\telemEnc encoderFunc\n}\n\nfunc (me mapEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.IsNil() /* EDIT(begin) */ || sentinel.IsValueNull(v) /* EDIT(end) */ {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\tif e.ptrLevel++; e.ptrLevel > startDetectingCyclesAfter {\n\t\t// We're a large number of nested ptrEncoder.encode calls deep;\n\t\t// start checking if we've run into a pointer cycle.\n\t\tptr := v.UnsafePointer()\n\t\tif _, ok := e.ptrSeen[ptr]; ok {\n\t\t\te.error(&UnsupportedValueError{v, fmt.Sprintf(\"encountered a cycle via %s\", v.Type())})\n\t\t}\n\t\te.ptrSeen[ptr] = struct{}{}\n\t\tdefer delete(e.ptrSeen, ptr)\n\t}\n\te.WriteByte('{')\n\n\t// Extract and sort the keys.\n\tvar (\n\t\tsv  = make([]reflectWithString, v.Len())\n\t\tmi  = v.MapRange()\n\t\terr error\n\t)\n\tfor i := 0; mi.Next(); i++ {\n\t\tif sv[i].ks, err = resolveKeyName(mi.Key()); err != nil {\n\t\t\te.error(fmt.Errorf(\"json: encoding error for type %q: %q\", v.Type().String(), err.Error()))\n\t\t}\n\t\tsv[i].v = mi.Value()\n\t}\n\tslices.SortFunc(sv, func(i, j reflectWithString) int {\n\t\treturn strings.Compare(i.ks, j.ks)\n\t})\n\n\tfor i, kv := range sv {\n\t\tif i > 0 {\n\t\t\te.WriteByte(',')\n\t\t}\n\t\te.Write(appendString(e.AvailableBuffer(), kv.ks, opts.escapeHTML))\n\t\te.WriteByte(':')\n\t\tme.elemEnc(e, kv.v, opts)\n\t}\n\te.WriteByte('}')\n\te.ptrLevel--\n}\n\nfunc newMapEncoder(t reflect.Type) encoderFunc {\n\tswitch t.Key().Kind() {\n\tcase reflect.String,\n\t\treflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\tdefault:\n\t\tif !t.Key().Implements(textMarshalerType) {\n\t\t\treturn unsupportedTypeEncoder\n\t\t}\n\t}\n\tme := mapEncoder{typeEncoder(t.Elem())}\n\treturn me.encode\n}\n\nfunc encodeByteSlice(e *encodeState, v reflect.Value, _ encOpts) {\n\tif v.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\n\ts := v.Bytes()\n\tb := e.AvailableBuffer()\n\tb = append(b, '\"')\n\t// SHIM(base64): base64.StdEncoding.AppendEncode([]byte, []byte) []byte\n\tb = (shims.AppendableStdEncoding{Encoding: base64.StdEncoding}).AppendEncode(b, s)\n\tb = append(b, '\"')\n\te.Write(b)\n}\n\n// sliceEncoder just wraps an arrayEncoder, checking to make sure the value isn't nil.\ntype sliceEncoder struct {\n\tarrayEnc encoderFunc\n}\n\nfunc (se sliceEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.IsNil() /* EDIT(begin) */ || sentinel.IsValueNull(v) /* EDIT(end) */ {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\tif e.ptrLevel++; e.ptrLevel > startDetectingCyclesAfter {\n\t\t// We're a large number of nested ptrEncoder.encode calls deep;\n\t\t// start checking if we've run into a pointer cycle.\n\t\t// Here we use a struct to memorize the pointer to the first element of the slice\n\t\t// and its length.\n\t\tptr := struct {\n\t\t\tptr any // always an unsafe.Pointer, but avoids a dependency on package unsafe\n\t\t\tlen int\n\t\t}{v.UnsafePointer(), v.Len()}\n\t\tif _, ok := e.ptrSeen[ptr]; ok {\n\t\t\te.error(&UnsupportedValueError{v, fmt.Sprintf(\"encountered a cycle via %s\", v.Type())})\n\t\t}\n\t\te.ptrSeen[ptr] = struct{}{}\n\t\tdefer delete(e.ptrSeen, ptr)\n\t}\n\tse.arrayEnc(e, v, opts)\n\te.ptrLevel--\n}\n\nfunc newSliceEncoder(t reflect.Type) encoderFunc {\n\t// Byte slices get special treatment; arrays don't.\n\tif t.Elem().Kind() == reflect.Uint8 {\n\t\tp := reflect.PointerTo(t.Elem())\n\t\tif !p.Implements(marshalerType) && !p.Implements(textMarshalerType) {\n\t\t\treturn encodeByteSlice\n\t\t}\n\t}\n\tenc := sliceEncoder{newArrayEncoder(t)}\n\treturn enc.encode\n}\n\ntype arrayEncoder struct {\n\telemEnc encoderFunc\n}\n\nfunc (ae arrayEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\te.WriteByte('[')\n\tn := v.Len()\n\tfor i := 0; i < n; i++ {\n\t\tif i > 0 {\n\t\t\te.WriteByte(',')\n\t\t}\n\t\tae.elemEnc(e, v.Index(i), opts)\n\t}\n\te.WriteByte(']')\n}\n\nfunc newArrayEncoder(t reflect.Type) encoderFunc {\n\tenc := arrayEncoder{typeEncoder(t.Elem())}\n\treturn enc.encode\n}\n\ntype ptrEncoder struct {\n\telemEnc encoderFunc\n}\n\nfunc (pe ptrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.IsNil() {\n\t\te.WriteString(\"null\")\n\t\treturn\n\t}\n\n\t// EDIT(end)\n\tif e.ptrLevel++; e.ptrLevel > startDetectingCyclesAfter {\n\t\t// We're a large number of nested ptrEncoder.encode calls deep;\n\t\t// start checking if we've run into a pointer cycle.\n\t\tptr := v.Interface()\n\t\tif _, ok := e.ptrSeen[ptr]; ok {\n\t\t\te.error(&UnsupportedValueError{v, fmt.Sprintf(\"encountered a cycle via %s\", v.Type())})\n\t\t}\n\t\te.ptrSeen[ptr] = struct{}{}\n\t\tdefer delete(e.ptrSeen, ptr)\n\t}\n\tpe.elemEnc(e, v.Elem(), opts)\n\te.ptrLevel--\n}\n\nfunc newPtrEncoder(t reflect.Type) encoderFunc {\n\tenc := ptrEncoder{typeEncoder(t.Elem())}\n\treturn enc.encode\n}\n\ntype condAddrEncoder struct {\n\tcanAddrEnc, elseEnc encoderFunc\n}\n\nfunc (ce condAddrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) {\n\tif v.CanAddr() {\n\t\tce.canAddrEnc(e, v, opts)\n\t} else {\n\t\tce.elseEnc(e, v, opts)\n\t}\n}\n\n// newCondAddrEncoder returns an encoder that checks whether its value\n// CanAddr and delegates to canAddrEnc if so, else to elseEnc.\nfunc newCondAddrEncoder(canAddrEnc, elseEnc encoderFunc) encoderFunc {\n\tenc := condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc}\n\treturn enc.encode\n}\n\nfunc isValidTag(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\tfor _, c := range s {\n\t\tswitch {\n\t\tcase strings.ContainsRune(\"!#$%&()*+-./:;<=>?@[]^_{|}~ \", c):\n\t\t\t// Backslash and quote chars are reserved, but\n\t\t\t// otherwise any punctuation chars are allowed\n\t\t\t// in a tag name.\n\t\tcase !unicode.IsLetter(c) && !unicode.IsDigit(c):\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc typeByIndex(t reflect.Type, index []int) reflect.Type {\n\tfor _, i := range index {\n\t\tif t.Kind() == reflect.Pointer {\n\t\t\tt = t.Elem()\n\t\t}\n\t\tt = t.Field(i).Type\n\t}\n\treturn t\n}\n\ntype reflectWithString struct {\n\tv  reflect.Value\n\tks string\n}\n\nfunc resolveKeyName(k reflect.Value) (string, error) {\n\tif k.Kind() == reflect.String {\n\t\treturn k.String(), nil\n\t}\n\tif tm, ok := k.Interface().(encoding.TextMarshaler); ok {\n\t\tif k.Kind() == reflect.Pointer && k.IsNil() {\n\t\t\treturn \"\", nil\n\t\t}\n\t\tbuf, err := tm.MarshalText()\n\t\treturn string(buf), err\n\t}\n\tswitch k.Kind() {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn strconv.FormatInt(k.Int(), 10), nil\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn strconv.FormatUint(k.Uint(), 10), nil\n\t}\n\tpanic(\"unexpected map key type\")\n}\n\nfunc appendString[Bytes []byte | string](dst []byte, src Bytes, escapeHTML bool) []byte {\n\tdst = append(dst, '\"')\n\tstart := 0\n\tfor i := 0; i < len(src); {\n\t\tif b := src[i]; b < utf8.RuneSelf {\n\t\t\tif htmlSafeSet[b] || (!escapeHTML && safeSet[b]) {\n\t\t\t\ti++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdst = append(dst, src[start:i]...)\n\t\t\tswitch b {\n\t\t\tcase '\\\\', '\"':\n\t\t\t\tdst = append(dst, '\\\\', b)\n\t\t\tcase '\\b':\n\t\t\t\tdst = append(dst, '\\\\', 'b')\n\t\t\tcase '\\f':\n\t\t\t\tdst = append(dst, '\\\\', 'f')\n\t\t\tcase '\\n':\n\t\t\t\tdst = append(dst, '\\\\', 'n')\n\t\t\tcase '\\r':\n\t\t\t\tdst = append(dst, '\\\\', 'r')\n\t\t\tcase '\\t':\n\t\t\t\tdst = append(dst, '\\\\', 't')\n\t\t\tdefault:\n\t\t\t\t// This encodes bytes < 0x20 except for \\b, \\f, \\n, \\r and \\t.\n\t\t\t\t// If escapeHTML is set, it also escapes <, >, and &\n\t\t\t\t// because they can lead to security holes when\n\t\t\t\t// user-controlled strings are rendered into JSON\n\t\t\t\t// and served to some browsers.\n\t\t\t\tdst = append(dst, '\\\\', 'u', '0', '0', hex[b>>4], hex[b&0xF])\n\t\t\t}\n\t\t\ti++\n\t\t\tstart = i\n\t\t\tcontinue\n\t\t}\n\t\t// TODO(https://go.dev/issue/56948): Use generic utf8 functionality.\n\t\t// For now, cast only a small portion of byte slices to a string\n\t\t// so that it can be stack allocated. This slows down []byte slightly\n\t\t// due to the extra copy, but keeps string performance roughly the same.\n\t\tn := len(src) - i\n\t\tif n > utf8.UTFMax {\n\t\t\tn = utf8.UTFMax\n\t\t}\n\t\tc, size := utf8.DecodeRuneInString(string(src[i : i+n]))\n\t\tif c == utf8.RuneError && size == 1 {\n\t\t\tdst = append(dst, src[start:i]...)\n\t\t\tdst = append(dst, `\\ufffd`...)\n\t\t\ti += size\n\t\t\tstart = i\n\t\t\tcontinue\n\t\t}\n\t\t// U+2028 is LINE SEPARATOR.\n\t\t// U+2029 is PARAGRAPH SEPARATOR.\n\t\t// They are both technically valid characters in JSON strings,\n\t\t// but don't work in JSONP, which has to be evaluated as JavaScript,\n\t\t// and can lead to security holes there. It is valid JSON to\n\t\t// escape them, so we do so unconditionally.\n\t\t// See https://en.wikipedia.org/wiki/JSON#Safety.\n\t\tif c == '\\u2028' || c == '\\u2029' {\n\t\t\tdst = append(dst, src[start:i]...)\n\t\t\tdst = append(dst, '\\\\', 'u', '2', '0', '2', hex[c&0xF])\n\t\t\ti += size\n\t\t\tstart = i\n\t\t\tcontinue\n\t\t}\n\t\ti += size\n\t}\n\tdst = append(dst, src[start:]...)\n\tdst = append(dst, '\"')\n\treturn dst\n}\n\n// A field represents a single field found in a struct.\ntype field struct {\n\tname      string\n\tnameBytes []byte // []byte(name)\n\n\tnameNonEsc  string // `\"` + name + `\":`\n\tnameEscHTML string // `\"` + HTMLEscape(name) + `\":`\n\n\ttag       bool\n\tindex     []int\n\ttyp       reflect.Type\n\tomitEmpty bool\n\tomitZero  bool\n\tisZero    func(reflect.Value) bool\n\tquoted    bool\n\n\tencoder encoderFunc\n\n\t// EDIT(begin): save the timefmt if present\n\ttimefmt string\n\t// EDIT(end)\n}\n\ntype isZeroer interface {\n\tIsZero() bool\n}\n\n// SHIM(reflect): TypeFor[T]() reflect.Type\nvar isZeroerType = shims.TypeFor[isZeroer]()\n\n// typeFields returns a list of fields that JSON should recognize for the given type.\n// The algorithm is breadth-first search over the set of structs to include - the top struct\n// and then any reachable anonymous structs.\n//\n// typeFields should be an internal detail,\n// but widely used packages access it using linkname.\n// Notable members of the hall of shame include:\n//   - github.com/bytedance/sonic\n//\n// Do not remove or change the type signature.\n// See go.dev/issue/67401.\n//\n//go:linkname typeFields\nfunc typeFields(t reflect.Type) structFields {\n\t// Anonymous fields to explore at the current level and the next.\n\tcurrent := []field{}\n\tnext := []field{{typ: t}}\n\n\t// Count of queued names for current level and the next.\n\tvar count, nextCount map[reflect.Type]int\n\n\t// Types already visited at an earlier level.\n\tvisited := map[reflect.Type]bool{}\n\n\t// Fields found.\n\tvar fields []field\n\n\t// Buffer to run appendHTMLEscape on field names.\n\tvar nameEscBuf []byte\n\n\tfor len(next) > 0 {\n\t\tcurrent, next = next, current[:0]\n\t\tcount, nextCount = nextCount, map[reflect.Type]int{}\n\n\t\tfor _, f := range current {\n\t\t\tif visited[f.typ] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvisited[f.typ] = true\n\n\t\t\t// Scan f.typ for fields to include.\n\t\t\tfor i := 0; i < f.typ.NumField(); i++ {\n\t\t\t\tsf := f.typ.Field(i)\n\t\t\t\tif sf.Anonymous {\n\t\t\t\t\tt := sf.Type\n\t\t\t\t\tif t.Kind() == reflect.Pointer {\n\t\t\t\t\t\tt = t.Elem()\n\t\t\t\t\t}\n\t\t\t\t\tif !sf.IsExported() && t.Kind() != reflect.Struct {\n\t\t\t\t\t\t// Ignore embedded fields of unexported non-struct types.\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\t// Do not ignore embedded fields of unexported struct types\n\t\t\t\t\t// since they may have exported fields.\n\t\t\t\t} else if !sf.IsExported() {\n\t\t\t\t\t// Ignore unexported non-embedded fields.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttag := sf.Tag.Get(\"json\")\n\t\t\t\tif tag == \"-\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tname, opts := parseTag(tag)\n\t\t\t\tif !isValidTag(name) {\n\t\t\t\t\tname = \"\"\n\t\t\t\t}\n\t\t\t\tindex := make([]int, len(f.index)+1)\n\t\t\t\tcopy(index, f.index)\n\t\t\t\tindex[len(f.index)] = i\n\n\t\t\t\tft := sf.Type\n\t\t\t\tif ft.Name() == \"\" && ft.Kind() == reflect.Pointer {\n\t\t\t\t\t// Follow pointer.\n\t\t\t\t\tft = ft.Elem()\n\t\t\t\t}\n\n\t\t\t\t// Only strings, floats, integers, and booleans can be quoted.\n\t\t\t\tquoted := false\n\t\t\t\tif opts.Contains(\"string\") {\n\t\t\t\t\tswitch ft.Kind() {\n\t\t\t\t\tcase reflect.Bool,\n\t\t\t\t\t\treflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\t\t\t\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,\n\t\t\t\t\t\treflect.Float32, reflect.Float64,\n\t\t\t\t\t\treflect.String:\n\t\t\t\t\t\tquoted = true\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Record found field and index sequence.\n\t\t\t\tif name != \"\" || !sf.Anonymous || ft.Kind() != reflect.Struct {\n\t\t\t\t\ttagged := name != \"\"\n\t\t\t\t\tif name == \"\" {\n\t\t\t\t\t\tname = sf.Name\n\t\t\t\t\t}\n\t\t\t\t\tfield := field{\n\t\t\t\t\t\tname:      name,\n\t\t\t\t\t\ttag:       tagged,\n\t\t\t\t\t\tindex:     index,\n\t\t\t\t\t\ttyp:       ft,\n\t\t\t\t\t\tomitEmpty: opts.Contains(\"omitempty\"),\n\t\t\t\t\t\tomitZero:  opts.Contains(\"omitzero\"),\n\t\t\t\t\t\tquoted:    quoted,\n\t\t\t\t\t\t// EDIT(begin): save the timefmt\n\t\t\t\t\t\ttimefmt: sf.Tag.Get(\"format\"),\n\t\t\t\t\t\t// EDIT(end)\n\t\t\t\t\t}\n\t\t\t\t\tfield.nameBytes = []byte(field.name)\n\n\t\t\t\t\t// Build nameEscHTML and nameNonEsc ahead of time.\n\t\t\t\t\tnameEscBuf = appendHTMLEscape(nameEscBuf[:0], field.nameBytes)\n\t\t\t\t\tfield.nameEscHTML = `\"` + string(nameEscBuf) + `\":`\n\t\t\t\t\tfield.nameNonEsc = `\"` + field.name + `\":`\n\n\t\t\t\t\tif field.omitZero {\n\t\t\t\t\t\tt := sf.Type\n\t\t\t\t\t\t// Provide a function that uses a type's IsZero method.\n\t\t\t\t\t\tswitch {\n\t\t\t\t\t\tcase t.Kind() == reflect.Interface && t.Implements(isZeroerType):\n\t\t\t\t\t\t\tfield.isZero = func(v reflect.Value) bool {\n\t\t\t\t\t\t\t\t// Avoid panics calling IsZero on a nil interface or\n\t\t\t\t\t\t\t\t// non-nil interface with nil pointer.\n\t\t\t\t\t\t\t\treturn v.IsNil() ||\n\t\t\t\t\t\t\t\t\t(v.Elem().Kind() == reflect.Pointer && v.Elem().IsNil()) ||\n\t\t\t\t\t\t\t\t\tv.Interface().(isZeroer).IsZero()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase t.Kind() == reflect.Pointer && t.Implements(isZeroerType):\n\t\t\t\t\t\t\tfield.isZero = func(v reflect.Value) bool {\n\t\t\t\t\t\t\t\t// Avoid panics calling IsZero on nil pointer.\n\t\t\t\t\t\t\t\treturn v.IsNil() || v.Interface().(isZeroer).IsZero()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase t.Implements(isZeroerType):\n\t\t\t\t\t\t\tfield.isZero = func(v reflect.Value) bool {\n\t\t\t\t\t\t\t\treturn v.Interface().(isZeroer).IsZero()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase reflect.PointerTo(t).Implements(isZeroerType):\n\t\t\t\t\t\t\tfield.isZero = func(v reflect.Value) bool {\n\t\t\t\t\t\t\t\tif !v.CanAddr() {\n\t\t\t\t\t\t\t\t\t// Temporarily box v so we can take the address.\n\t\t\t\t\t\t\t\t\tv2 := reflect.New(v.Type()).Elem()\n\t\t\t\t\t\t\t\t\tv2.Set(v)\n\t\t\t\t\t\t\t\t\tv = v2\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn v.Addr().Interface().(isZeroer).IsZero()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfields = append(fields, field)\n\t\t\t\t\tif count[f.typ] > 1 {\n\t\t\t\t\t\t// If there were multiple instances, add a second,\n\t\t\t\t\t\t// so that the annihilation code will see a duplicate.\n\t\t\t\t\t\t// It only cares about the distinction between 1 and 2,\n\t\t\t\t\t\t// so don't bother generating any more copies.\n\t\t\t\t\t\tfields = append(fields, fields[len(fields)-1])\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// Record new anonymous struct to explore in next round.\n\t\t\t\tnextCount[ft]++\n\t\t\t\tif nextCount[ft] == 1 {\n\t\t\t\t\tnext = append(next, field{name: ft.Name(), index: index, typ: ft})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tslices.SortFunc(fields, func(a, b field) int {\n\t\t// sort field by name, breaking ties with depth, then\n\t\t// breaking ties with \"name came from json tag\", then\n\t\t// breaking ties with index sequence.\n\t\tif c := strings.Compare(a.name, b.name); c != 0 {\n\t\t\treturn c\n\t\t}\n\t\tif c := cmp.Compare(len(a.index), len(b.index)); c != 0 {\n\t\t\treturn c\n\t\t}\n\t\tif a.tag != b.tag {\n\t\t\tif a.tag {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t\treturn +1\n\t\t}\n\t\treturn slices.Compare(a.index, b.index)\n\t})\n\n\t// Delete all fields that are hidden by the Go rules for embedded fields,\n\t// except that fields with JSON tags are promoted.\n\n\t// The fields are sorted in primary order of name, secondary order\n\t// of field index length. Loop over names; for each name, delete\n\t// hidden fields by choosing the one dominant field that survives.\n\tout := fields[:0]\n\tfor advance, i := 0, 0; i < len(fields); i += advance {\n\t\t// One iteration per name.\n\t\t// Find the sequence of fields with the name of this first field.\n\t\tfi := fields[i]\n\t\tname := fi.name\n\t\tfor advance = 1; i+advance < len(fields); advance++ {\n\t\t\tfj := fields[i+advance]\n\t\t\tif fj.name != name {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif advance == 1 { // Only one field with this name\n\t\t\tout = append(out, fi)\n\t\t\tcontinue\n\t\t}\n\t\tdominant, ok := dominantField(fields[i : i+advance])\n\t\tif ok {\n\t\t\tout = append(out, dominant)\n\t\t}\n\t}\n\n\tfields = out\n\tslices.SortFunc(fields, func(i, j field) int {\n\t\treturn slices.Compare(i.index, j.index)\n\t})\n\n\tfor i := range fields {\n\t\tf := &fields[i]\n\t\tf.encoder = typeEncoder(typeByIndex(t, f.index))\n\n\t\t// EDIT(begin): add custom timefmt if necessary\n\t\tif f.timefmt != \"\" {\n\t\t\tf.encoder = continueWithTimeFmt(f.timefmt, f.encoder)\n\t\t}\n\t\t// EDIT(end)\n\t}\n\texactNameIndex := make(map[string]*field, len(fields))\n\tfoldedNameIndex := make(map[string]*field, len(fields))\n\tfor i, field := range fields {\n\t\texactNameIndex[field.name] = &fields[i]\n\t\t// For historical reasons, first folded match takes precedence.\n\t\tif _, ok := foldedNameIndex[string(foldName(field.nameBytes))]; !ok {\n\t\t\tfoldedNameIndex[string(foldName(field.nameBytes))] = &fields[i]\n\t\t}\n\t}\n\treturn structFields{fields, exactNameIndex, foldedNameIndex}\n}\n\n// dominantField looks through the fields, all of which are known to\n// have the same name, to find the single field that dominates the\n// others using Go's embedding rules, modified by the presence of\n// JSON tags. If there are multiple top-level fields, the boolean\n// will be false: This condition is an error in Go and we skip all\n// the fields.\nfunc dominantField(fields []field) (field, bool) {\n\t// The fields are sorted in increasing index-length order, then by presence of tag.\n\t// That means that the first field is the dominant one. We need only check\n\t// for error cases: two fields at top level, either both tagged or neither tagged.\n\tif len(fields) > 1 && len(fields[0].index) == len(fields[1].index) && fields[0].tag == fields[1].tag {\n\t\treturn field{}, false\n\t}\n\treturn fields[0], true\n}\n\nvar fieldCache sync.Map // map[reflect.Type]structFields\n\n// cachedTypeFields is like typeFields but uses a cache to avoid repeated work.\nfunc cachedTypeFields(t reflect.Type) structFields {\n\tif f, ok := fieldCache.Load(t); ok {\n\t\treturn f.(structFields)\n\t}\n\tf, _ := fieldCache.LoadOrStore(t, typeFields(t))\n\treturn f.(structFields)\n}\n\nfunc mayAppendQuote(b []byte, quoted bool) []byte {\n\tif quoted {\n\t\tb = append(b, '\"')\n\t}\n\treturn b\n}\n"
  },
  {
    "path": "internal/encoding/json/fold.go",
    "content": "// Copyright 2013 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage json\n\nimport (\n\t\"unicode\"\n\t\"unicode/utf8\"\n)\n\n// foldName returns a folded string such that foldName(x) == foldName(y)\n// is identical to bytes.EqualFold(x, y).\nfunc foldName(in []byte) []byte {\n\t// This is inlinable to take advantage of \"function outlining\".\n\tvar arr [32]byte // large enough for most JSON names\n\treturn appendFoldedName(arr[:0], in)\n}\n\nfunc appendFoldedName(out, in []byte) []byte {\n\tfor i := 0; i < len(in); {\n\t\t// Handle single-byte ASCII.\n\t\tif c := in[i]; c < utf8.RuneSelf {\n\t\t\tif 'a' <= c && c <= 'z' {\n\t\t\t\tc -= 'a' - 'A'\n\t\t\t}\n\t\t\tout = append(out, c)\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\t// Handle multi-byte Unicode.\n\t\tr, n := utf8.DecodeRune(in[i:])\n\t\tout = utf8.AppendRune(out, foldRune(r))\n\t\ti += n\n\t}\n\treturn out\n}\n\n// foldRune is returns the smallest rune for all runes in the same fold set.\nfunc foldRune(r rune) rune {\n\tfor {\n\t\tr2 := unicode.SimpleFold(r)\n\t\tif r2 <= r {\n\t\t\treturn r2\n\t\t}\n\t\tr = r2\n\t}\n}\n"
  },
  {
    "path": "internal/encoding/json/indent.go",
    "content": "// Copyright 2010 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage json\n\nimport \"bytes\"\n\n// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029\n// characters inside string literals changed to \\u003c, \\u003e, \\u0026, \\u2028, \\u2029\n// so that the JSON will be safe to embed inside HTML <script> tags.\n// For historical reasons, web browsers don't honor standard HTML\n// escaping within <script> tags, so an alternative JSON encoding must be used.\nfunc HTMLEscape(dst *bytes.Buffer, src []byte) {\n\tdst.Grow(len(src))\n\tdst.Write(appendHTMLEscape(dst.AvailableBuffer(), src))\n}\n\nfunc appendHTMLEscape(dst, src []byte) []byte {\n\t// The characters can only appear in string literals,\n\t// so just scan the string one byte at a time.\n\tstart := 0\n\tfor i, c := range src {\n\t\tif c == '<' || c == '>' || c == '&' {\n\t\t\tdst = append(dst, src[start:i]...)\n\t\t\tdst = append(dst, '\\\\', 'u', '0', '0', hex[c>>4], hex[c&0xF])\n\t\t\tstart = i + 1\n\t\t}\n\t\t// Convert U+2028 and U+2029 (E2 80 A8 and E2 80 A9).\n\t\tif c == 0xE2 && i+2 < len(src) && src[i+1] == 0x80 && src[i+2]&^1 == 0xA8 {\n\t\t\tdst = append(dst, src[start:i]...)\n\t\t\tdst = append(dst, '\\\\', 'u', '2', '0', '2', hex[src[i+2]&0xF])\n\t\t\tstart = i + len(\"\\u2029\")\n\t\t}\n\t}\n\treturn append(dst, src[start:]...)\n}\n\n// Compact appends to dst the JSON-encoded src with\n// insignificant space characters elided.\nfunc Compact(dst *bytes.Buffer, src []byte) error {\n\tdst.Grow(len(src))\n\tb := dst.AvailableBuffer()\n\tb, err := appendCompact(b, src, false)\n\tdst.Write(b)\n\treturn err\n}\n\nfunc appendCompact(dst, src []byte, escape bool) ([]byte, error) {\n\torigLen := len(dst)\n\tscan := newScanner()\n\tdefer freeScanner(scan)\n\tstart := 0\n\tfor i, c := range src {\n\t\tif escape && (c == '<' || c == '>' || c == '&') {\n\t\t\tif start < i {\n\t\t\t\tdst = append(dst, src[start:i]...)\n\t\t\t}\n\t\t\tdst = append(dst, '\\\\', 'u', '0', '0', hex[c>>4], hex[c&0xF])\n\t\t\tstart = i + 1\n\t\t}\n\t\t// Convert U+2028 and U+2029 (E2 80 A8 and E2 80 A9).\n\t\tif escape && c == 0xE2 && i+2 < len(src) && src[i+1] == 0x80 && src[i+2]&^1 == 0xA8 {\n\t\t\tif start < i {\n\t\t\t\tdst = append(dst, src[start:i]...)\n\t\t\t}\n\t\t\tdst = append(dst, '\\\\', 'u', '2', '0', '2', hex[src[i+2]&0xF])\n\t\t\tstart = i + 3\n\t\t}\n\t\tv := scan.step(scan, c)\n\t\tif v >= scanSkipSpace {\n\t\t\tif v == scanError {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif start < i {\n\t\t\t\tdst = append(dst, src[start:i]...)\n\t\t\t}\n\t\t\tstart = i + 1\n\t\t}\n\t}\n\tif scan.eof() == scanError {\n\t\treturn dst[:origLen], scan.err\n\t}\n\tif start < len(src) {\n\t\tdst = append(dst, src[start:]...)\n\t}\n\treturn dst, nil\n}\n\nfunc appendNewline(dst []byte, prefix, indent string, depth int) []byte {\n\tdst = append(dst, '\\n')\n\tdst = append(dst, prefix...)\n\tfor i := 0; i < depth; i++ {\n\t\tdst = append(dst, indent...)\n\t}\n\treturn dst\n}\n\n// indentGrowthFactor specifies the growth factor of indenting JSON input.\n// Empirically, the growth factor was measured to be between 1.4x to 1.8x\n// for some set of compacted JSON with the indent being a single tab.\n// Specify a growth factor slightly larger than what is observed\n// to reduce probability of allocation in appendIndent.\n// A factor no higher than 2 ensures that wasted space never exceeds 50%.\nconst indentGrowthFactor = 2\n\n// Indent appends to dst an indented form of the JSON-encoded src.\n// Each element in a JSON object or array begins on a new,\n// indented line beginning with prefix followed by one or more\n// copies of indent according to the indentation nesting.\n// The data appended to dst does not begin with the prefix nor\n// any indentation, to make it easier to embed inside other formatted JSON data.\n// Although leading space characters (space, tab, carriage return, newline)\n// at the beginning of src are dropped, trailing space characters\n// at the end of src are preserved and copied to dst.\n// For example, if src has no trailing spaces, neither will dst;\n// if src ends in a trailing newline, so will dst.\nfunc Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {\n\tdst.Grow(indentGrowthFactor * len(src))\n\tb := dst.AvailableBuffer()\n\tb, err := appendIndent(b, src, prefix, indent)\n\tdst.Write(b)\n\treturn err\n}\n\nfunc appendIndent(dst, src []byte, prefix, indent string) ([]byte, error) {\n\torigLen := len(dst)\n\tscan := newScanner()\n\tdefer freeScanner(scan)\n\tneedIndent := false\n\tdepth := 0\n\tfor _, c := range src {\n\t\tscan.bytes++\n\t\tv := scan.step(scan, c)\n\t\tif v == scanSkipSpace {\n\t\t\tcontinue\n\t\t}\n\t\tif v == scanError {\n\t\t\tbreak\n\t\t}\n\t\tif needIndent && v != scanEndObject && v != scanEndArray {\n\t\t\tneedIndent = false\n\t\t\tdepth++\n\t\t\tdst = appendNewline(dst, prefix, indent, depth)\n\t\t}\n\n\t\t// Emit semantically uninteresting bytes\n\t\t// (in particular, punctuation in strings) unmodified.\n\t\tif v == scanContinue {\n\t\t\tdst = append(dst, c)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Add spacing around real punctuation.\n\t\tswitch c {\n\t\tcase '{', '[':\n\t\t\t// delay indent so that empty object and array are formatted as {} and [].\n\t\t\tneedIndent = true\n\t\t\tdst = append(dst, c)\n\t\tcase ',':\n\t\t\tdst = append(dst, c)\n\t\t\tdst = appendNewline(dst, prefix, indent, depth)\n\t\tcase ':':\n\t\t\tdst = append(dst, c, ' ')\n\t\tcase '}', ']':\n\t\t\tif needIndent {\n\t\t\t\t// suppress indent in empty object/array\n\t\t\t\tneedIndent = false\n\t\t\t} else {\n\t\t\t\tdepth--\n\t\t\t\tdst = appendNewline(dst, prefix, indent, depth)\n\t\t\t}\n\t\t\tdst = append(dst, c)\n\t\tdefault:\n\t\t\tdst = append(dst, c)\n\t\t}\n\t}\n\tif scan.eof() == scanError {\n\t\treturn dst[:origLen], scan.err\n\t}\n\treturn dst, nil\n}\n"
  },
  {
    "path": "internal/encoding/json/scanner.go",
    "content": "// Copyright 2010 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage json\n\n// JSON value parser state machine.\n// Just about at the limit of what is reasonable to write by hand.\n// Some parts are a bit tedious, but overall it nicely factors out the\n// otherwise common code from the multiple scanning functions\n// in this package (Compact, Indent, checkValid, etc).\n//\n// This file starts with two simple examples using the scanner\n// before diving into the scanner itself.\n\nimport (\n\t\"strconv\"\n\t\"sync\"\n)\n\n// Valid reports whether data is a valid JSON encoding.\nfunc Valid(data []byte) bool {\n\tscan := newScanner()\n\tdefer freeScanner(scan)\n\treturn checkValid(data, scan) == nil\n}\n\n// checkValid verifies that data is valid JSON-encoded data.\n// scan is passed in for use by checkValid to avoid an allocation.\n// checkValid returns nil or a SyntaxError.\nfunc checkValid(data []byte, scan *scanner) error {\n\tscan.reset()\n\tfor _, c := range data {\n\t\tscan.bytes++\n\t\tif scan.step(scan, c) == scanError {\n\t\t\treturn scan.err\n\t\t}\n\t}\n\tif scan.eof() == scanError {\n\t\treturn scan.err\n\t}\n\treturn nil\n}\n\n// A SyntaxError is a description of a JSON syntax error.\n// [Unmarshal] will return a SyntaxError if the JSON can't be parsed.\ntype SyntaxError struct {\n\tmsg    string // description of error\n\tOffset int64  // error occurred after reading Offset bytes\n}\n\nfunc (e *SyntaxError) Error() string { return e.msg }\n\n// A scanner is a JSON scanning state machine.\n// Callers call scan.reset and then pass bytes in one at a time\n// by calling scan.step(&scan, c) for each byte.\n// The return value, referred to as an opcode, tells the\n// caller about significant parsing events like beginning\n// and ending literals, objects, and arrays, so that the\n// caller can follow along if it wishes.\n// The return value scanEnd indicates that a single top-level\n// JSON value has been completed, *before* the byte that\n// just got passed in.  (The indication must be delayed in order\n// to recognize the end of numbers: is 123 a whole value or\n// the beginning of 12345e+6?).\ntype scanner struct {\n\t// The step is a func to be called to execute the next transition.\n\t// Also tried using an integer constant and a single func\n\t// with a switch, but using the func directly was 10% faster\n\t// on a 64-bit Mac Mini, and it's nicer to read.\n\tstep func(*scanner, byte) int\n\n\t// Reached end of top-level value.\n\tendTop bool\n\n\t// Stack of what we're in the middle of - array values, object keys, object values.\n\tparseState []int\n\n\t// Error that happened, if any.\n\terr error\n\n\t// total bytes consumed, updated by decoder.Decode (and deliberately\n\t// not set to zero by scan.reset)\n\tbytes int64\n}\n\nvar scannerPool = sync.Pool{\n\tNew: func() any {\n\t\treturn &scanner{}\n\t},\n}\n\nfunc newScanner() *scanner {\n\tscan := scannerPool.Get().(*scanner)\n\t// scan.reset by design doesn't set bytes to zero\n\tscan.bytes = 0\n\tscan.reset()\n\treturn scan\n}\n\nfunc freeScanner(scan *scanner) {\n\t// Avoid hanging on to too much memory in extreme cases.\n\tif len(scan.parseState) > 1024 {\n\t\tscan.parseState = nil\n\t}\n\tscannerPool.Put(scan)\n}\n\n// These values are returned by the state transition functions\n// assigned to scanner.state and the method scanner.eof.\n// They give details about the current state of the scan that\n// callers might be interested to know about.\n// It is okay to ignore the return value of any particular\n// call to scanner.state: if one call returns scanError,\n// every subsequent call will return scanError too.\nconst (\n\t// Continue.\n\tscanContinue     = iota // uninteresting byte\n\tscanBeginLiteral        // end implied by next result != scanContinue\n\tscanBeginObject         // begin object\n\tscanObjectKey           // just finished object key (string)\n\tscanObjectValue         // just finished non-last object value\n\tscanEndObject           // end object (implies scanObjectValue if possible)\n\tscanBeginArray          // begin array\n\tscanArrayValue          // just finished array value\n\tscanEndArray            // end array (implies scanArrayValue if possible)\n\tscanSkipSpace           // space byte; can skip; known to be last \"continue\" result\n\n\t// Stop.\n\tscanEnd   // top-level value ended *before* this byte; known to be first \"stop\" result\n\tscanError // hit an error, scanner.err.\n)\n\n// These values are stored in the parseState stack.\n// They give the current state of a composite value\n// being scanned. If the parser is inside a nested value\n// the parseState describes the nested state, outermost at entry 0.\nconst (\n\tparseObjectKey   = iota // parsing object key (before colon)\n\tparseObjectValue        // parsing object value (after colon)\n\tparseArrayValue         // parsing array value\n)\n\n// This limits the max nesting depth to prevent stack overflow.\n// This is permitted by https://tools.ietf.org/html/rfc7159#section-9\nconst maxNestingDepth = 10000\n\n// reset prepares the scanner for use.\n// It must be called before calling s.step.\nfunc (s *scanner) reset() {\n\ts.step = stateBeginValue\n\ts.parseState = s.parseState[0:0]\n\ts.err = nil\n\ts.endTop = false\n}\n\n// eof tells the scanner that the end of input has been reached.\n// It returns a scan status just as s.step does.\nfunc (s *scanner) eof() int {\n\tif s.err != nil {\n\t\treturn scanError\n\t}\n\tif s.endTop {\n\t\treturn scanEnd\n\t}\n\ts.step(s, ' ')\n\tif s.endTop {\n\t\treturn scanEnd\n\t}\n\tif s.err == nil {\n\t\ts.err = &SyntaxError{\"unexpected end of JSON input\", s.bytes}\n\t}\n\treturn scanError\n}\n\n// pushParseState pushes a new parse state p onto the parse stack.\n// an error state is returned if maxNestingDepth was exceeded, otherwise successState is returned.\nfunc (s *scanner) pushParseState(c byte, newParseState int, successState int) int {\n\ts.parseState = append(s.parseState, newParseState)\n\tif len(s.parseState) <= maxNestingDepth {\n\t\treturn successState\n\t}\n\treturn s.error(c, \"exceeded max depth\")\n}\n\n// popParseState pops a parse state (already obtained) off the stack\n// and updates s.step accordingly.\nfunc (s *scanner) popParseState() {\n\tn := len(s.parseState) - 1\n\ts.parseState = s.parseState[0:n]\n\tif n == 0 {\n\t\ts.step = stateEndTop\n\t\ts.endTop = true\n\t} else {\n\t\ts.step = stateEndValue\n\t}\n}\n\nfunc isSpace(c byte) bool {\n\treturn c <= ' ' && (c == ' ' || c == '\\t' || c == '\\r' || c == '\\n')\n}\n\n// stateBeginValueOrEmpty is the state after reading `[`.\nfunc stateBeginValueOrEmpty(s *scanner, c byte) int {\n\tif isSpace(c) {\n\t\treturn scanSkipSpace\n\t}\n\tif c == ']' {\n\t\treturn stateEndValue(s, c)\n\t}\n\treturn stateBeginValue(s, c)\n}\n\n// stateBeginValue is the state at the beginning of the input.\nfunc stateBeginValue(s *scanner, c byte) int {\n\tif isSpace(c) {\n\t\treturn scanSkipSpace\n\t}\n\tswitch c {\n\tcase '{':\n\t\ts.step = stateBeginStringOrEmpty\n\t\treturn s.pushParseState(c, parseObjectKey, scanBeginObject)\n\tcase '[':\n\t\ts.step = stateBeginValueOrEmpty\n\t\treturn s.pushParseState(c, parseArrayValue, scanBeginArray)\n\tcase '\"':\n\t\ts.step = stateInString\n\t\treturn scanBeginLiteral\n\tcase '-':\n\t\ts.step = stateNeg\n\t\treturn scanBeginLiteral\n\tcase '0': // beginning of 0.123\n\t\ts.step = state0\n\t\treturn scanBeginLiteral\n\tcase 't': // beginning of true\n\t\ts.step = stateT\n\t\treturn scanBeginLiteral\n\tcase 'f': // beginning of false\n\t\ts.step = stateF\n\t\treturn scanBeginLiteral\n\tcase 'n': // beginning of null\n\t\ts.step = stateN\n\t\treturn scanBeginLiteral\n\t}\n\tif '1' <= c && c <= '9' { // beginning of 1234.5\n\t\ts.step = state1\n\t\treturn scanBeginLiteral\n\t}\n\treturn s.error(c, \"looking for beginning of value\")\n}\n\n// stateBeginStringOrEmpty is the state after reading `{`.\nfunc stateBeginStringOrEmpty(s *scanner, c byte) int {\n\tif isSpace(c) {\n\t\treturn scanSkipSpace\n\t}\n\tif c == '}' {\n\t\tn := len(s.parseState)\n\t\ts.parseState[n-1] = parseObjectValue\n\t\treturn stateEndValue(s, c)\n\t}\n\treturn stateBeginString(s, c)\n}\n\n// stateBeginString is the state after reading `{\"key\": value,`.\nfunc stateBeginString(s *scanner, c byte) int {\n\tif isSpace(c) {\n\t\treturn scanSkipSpace\n\t}\n\tif c == '\"' {\n\t\ts.step = stateInString\n\t\treturn scanBeginLiteral\n\t}\n\treturn s.error(c, \"looking for beginning of object key string\")\n}\n\n// stateEndValue is the state after completing a value,\n// such as after reading `{}` or `true` or `[\"x\"`.\nfunc stateEndValue(s *scanner, c byte) int {\n\tn := len(s.parseState)\n\tif n == 0 {\n\t\t// Completed top-level before the current byte.\n\t\ts.step = stateEndTop\n\t\ts.endTop = true\n\t\treturn stateEndTop(s, c)\n\t}\n\tif isSpace(c) {\n\t\ts.step = stateEndValue\n\t\treturn scanSkipSpace\n\t}\n\tps := s.parseState[n-1]\n\tswitch ps {\n\tcase parseObjectKey:\n\t\tif c == ':' {\n\t\t\ts.parseState[n-1] = parseObjectValue\n\t\t\ts.step = stateBeginValue\n\t\t\treturn scanObjectKey\n\t\t}\n\t\treturn s.error(c, \"after object key\")\n\tcase parseObjectValue:\n\t\tif c == ',' {\n\t\t\ts.parseState[n-1] = parseObjectKey\n\t\t\ts.step = stateBeginString\n\t\t\treturn scanObjectValue\n\t\t}\n\t\tif c == '}' {\n\t\t\ts.popParseState()\n\t\t\treturn scanEndObject\n\t\t}\n\t\treturn s.error(c, \"after object key:value pair\")\n\tcase parseArrayValue:\n\t\tif c == ',' {\n\t\t\ts.step = stateBeginValue\n\t\t\treturn scanArrayValue\n\t\t}\n\t\tif c == ']' {\n\t\t\ts.popParseState()\n\t\t\treturn scanEndArray\n\t\t}\n\t\treturn s.error(c, \"after array element\")\n\t}\n\treturn s.error(c, \"\")\n}\n\n// stateEndTop is the state after finishing the top-level value,\n// such as after reading `{}` or `[1,2,3]`.\n// Only space characters should be seen now.\nfunc stateEndTop(s *scanner, c byte) int {\n\tif !isSpace(c) {\n\t\t// Complain about non-space byte on next call.\n\t\ts.error(c, \"after top-level value\")\n\t}\n\treturn scanEnd\n}\n\n// stateInString is the state after reading `\"`.\nfunc stateInString(s *scanner, c byte) int {\n\tif c == '\"' {\n\t\ts.step = stateEndValue\n\t\treturn scanContinue\n\t}\n\tif c == '\\\\' {\n\t\ts.step = stateInStringEsc\n\t\treturn scanContinue\n\t}\n\tif c < 0x20 {\n\t\treturn s.error(c, \"in string literal\")\n\t}\n\treturn scanContinue\n}\n\n// stateInStringEsc is the state after reading `\"\\` during a quoted string.\nfunc stateInStringEsc(s *scanner, c byte) int {\n\tswitch c {\n\tcase 'b', 'f', 'n', 'r', 't', '\\\\', '/', '\"':\n\t\ts.step = stateInString\n\t\treturn scanContinue\n\tcase 'u':\n\t\ts.step = stateInStringEscU\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in string escape code\")\n}\n\n// stateInStringEscU is the state after reading `\"\\u` during a quoted string.\nfunc stateInStringEscU(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' {\n\t\ts.step = stateInStringEscU1\n\t\treturn scanContinue\n\t}\n\t// numbers\n\treturn s.error(c, \"in \\\\u hexadecimal character escape\")\n}\n\n// stateInStringEscU1 is the state after reading `\"\\u1` during a quoted string.\nfunc stateInStringEscU1(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' {\n\t\ts.step = stateInStringEscU12\n\t\treturn scanContinue\n\t}\n\t// numbers\n\treturn s.error(c, \"in \\\\u hexadecimal character escape\")\n}\n\n// stateInStringEscU12 is the state after reading `\"\\u12` during a quoted string.\nfunc stateInStringEscU12(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' {\n\t\ts.step = stateInStringEscU123\n\t\treturn scanContinue\n\t}\n\t// numbers\n\treturn s.error(c, \"in \\\\u hexadecimal character escape\")\n}\n\n// stateInStringEscU123 is the state after reading `\"\\u123` during a quoted string.\nfunc stateInStringEscU123(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' {\n\t\ts.step = stateInString\n\t\treturn scanContinue\n\t}\n\t// numbers\n\treturn s.error(c, \"in \\\\u hexadecimal character escape\")\n}\n\n// stateNeg is the state after reading `-` during a number.\nfunc stateNeg(s *scanner, c byte) int {\n\tif c == '0' {\n\t\ts.step = state0\n\t\treturn scanContinue\n\t}\n\tif '1' <= c && c <= '9' {\n\t\ts.step = state1\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in numeric literal\")\n}\n\n// state1 is the state after reading a non-zero integer during a number,\n// such as after reading `1` or `100` but not `0`.\nfunc state1(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' {\n\t\ts.step = state1\n\t\treturn scanContinue\n\t}\n\treturn state0(s, c)\n}\n\n// state0 is the state after reading `0` during a number.\nfunc state0(s *scanner, c byte) int {\n\tif c == '.' {\n\t\ts.step = stateDot\n\t\treturn scanContinue\n\t}\n\tif c == 'e' || c == 'E' {\n\t\ts.step = stateE\n\t\treturn scanContinue\n\t}\n\treturn stateEndValue(s, c)\n}\n\n// stateDot is the state after reading the integer and decimal point in a number,\n// such as after reading `1.`.\nfunc stateDot(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' {\n\t\ts.step = stateDot0\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"after decimal point in numeric literal\")\n}\n\n// stateDot0 is the state after reading the integer, decimal point, and subsequent\n// digits of a number, such as after reading `3.14`.\nfunc stateDot0(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' {\n\t\treturn scanContinue\n\t}\n\tif c == 'e' || c == 'E' {\n\t\ts.step = stateE\n\t\treturn scanContinue\n\t}\n\treturn stateEndValue(s, c)\n}\n\n// stateE is the state after reading the mantissa and e in a number,\n// such as after reading `314e` or `0.314e`.\nfunc stateE(s *scanner, c byte) int {\n\tif c == '+' || c == '-' {\n\t\ts.step = stateESign\n\t\treturn scanContinue\n\t}\n\treturn stateESign(s, c)\n}\n\n// stateESign is the state after reading the mantissa, e, and sign in a number,\n// such as after reading `314e-` or `0.314e+`.\nfunc stateESign(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' {\n\t\ts.step = stateE0\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in exponent of numeric literal\")\n}\n\n// stateE0 is the state after reading the mantissa, e, optional sign,\n// and at least one digit of the exponent in a number,\n// such as after reading `314e-2` or `0.314e+1` or `3.14e0`.\nfunc stateE0(s *scanner, c byte) int {\n\tif '0' <= c && c <= '9' {\n\t\treturn scanContinue\n\t}\n\treturn stateEndValue(s, c)\n}\n\n// stateT is the state after reading `t`.\nfunc stateT(s *scanner, c byte) int {\n\tif c == 'r' {\n\t\ts.step = stateTr\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal true (expecting 'r')\")\n}\n\n// stateTr is the state after reading `tr`.\nfunc stateTr(s *scanner, c byte) int {\n\tif c == 'u' {\n\t\ts.step = stateTru\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal true (expecting 'u')\")\n}\n\n// stateTru is the state after reading `tru`.\nfunc stateTru(s *scanner, c byte) int {\n\tif c == 'e' {\n\t\ts.step = stateEndValue\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal true (expecting 'e')\")\n}\n\n// stateF is the state after reading `f`.\nfunc stateF(s *scanner, c byte) int {\n\tif c == 'a' {\n\t\ts.step = stateFa\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal false (expecting 'a')\")\n}\n\n// stateFa is the state after reading `fa`.\nfunc stateFa(s *scanner, c byte) int {\n\tif c == 'l' {\n\t\ts.step = stateFal\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal false (expecting 'l')\")\n}\n\n// stateFal is the state after reading `fal`.\nfunc stateFal(s *scanner, c byte) int {\n\tif c == 's' {\n\t\ts.step = stateFals\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal false (expecting 's')\")\n}\n\n// stateFals is the state after reading `fals`.\nfunc stateFals(s *scanner, c byte) int {\n\tif c == 'e' {\n\t\ts.step = stateEndValue\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal false (expecting 'e')\")\n}\n\n// stateN is the state after reading `n`.\nfunc stateN(s *scanner, c byte) int {\n\tif c == 'u' {\n\t\ts.step = stateNu\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal null (expecting 'u')\")\n}\n\n// stateNu is the state after reading `nu`.\nfunc stateNu(s *scanner, c byte) int {\n\tif c == 'l' {\n\t\ts.step = stateNul\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal null (expecting 'l')\")\n}\n\n// stateNul is the state after reading `nul`.\nfunc stateNul(s *scanner, c byte) int {\n\tif c == 'l' {\n\t\ts.step = stateEndValue\n\t\treturn scanContinue\n\t}\n\treturn s.error(c, \"in literal null (expecting 'l')\")\n}\n\n// stateError is the state after reaching a syntax error,\n// such as after reading `[1}` or `5.1.2`.\nfunc stateError(s *scanner, c byte) int {\n\treturn scanError\n}\n\n// error records an error and switches to the error state.\nfunc (s *scanner) error(c byte, context string) int {\n\ts.step = stateError\n\ts.err = &SyntaxError{\"invalid character \" + quoteChar(c) + \" \" + context, s.bytes}\n\treturn scanError\n}\n\n// quoteChar formats c as a quoted character literal.\nfunc quoteChar(c byte) string {\n\t// special cases - different from quoted strings\n\tif c == '\\'' {\n\t\treturn `'\\''`\n\t}\n\tif c == '\"' {\n\t\treturn `'\"'`\n\t}\n\n\t// use quoted string with different quotation marks\n\ts := strconv.Quote(string(c))\n\treturn \"'\" + s[1:len(s)-1] + \"'\"\n}\n"
  },
  {
    "path": "internal/encoding/json/sentinel/null.go",
    "content": "package sentinel\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/shims\"\n\t\"reflect\"\n\t\"sync\"\n)\n\ntype cacheEntry struct {\n\tx    any\n\tptr  uintptr\n\tkind reflect.Kind\n}\n\nvar nullCache sync.Map // map[reflect.Type]cacheEntry\n\nfunc NewNullSentinel[T any](mk func() T) T {\n\tt := shims.TypeFor[T]()\n\tentry, loaded := nullCache.Load(t) // avoid premature allocation\n\tif !loaded {\n\t\tx := mk()\n\t\tptr := reflect.ValueOf(x).Pointer()\n\t\tentry, _ = nullCache.LoadOrStore(t, cacheEntry{x, ptr, t.Kind()})\n\t}\n\treturn entry.(cacheEntry).x.(T)\n}\n\n// for internal use only\nfunc IsValueNull(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.Map, reflect.Slice:\n\t\tnull, ok := nullCache.Load(v.Type())\n\t\treturn ok && v.Pointer() == null.(cacheEntry).ptr\n\t}\n\treturn false\n}\n\nfunc IsNull[T any](v T) bool {\n\tt := shims.TypeFor[T]()\n\tswitch t.Kind() {\n\tcase reflect.Map, reflect.Slice:\n\t\tnull, ok := nullCache.Load(t)\n\t\treturn ok && reflect.ValueOf(v).Pointer() == null.(cacheEntry).ptr\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "internal/encoding/json/sentinel/sentinel_test.go",
    "content": "package sentinel_test\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/sentinel\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"reflect\"\n\t\"slices\"\n\t\"testing\"\n)\n\ntype Pair struct {\n\tgot  bool\n\twant bool\n}\n\nfunc TestNullSlice(t *testing.T) {\n\tvar nilSlice []int = nil\n\tvar nonNilSlice []int = []int{1, 2, 3}\n\tvar nullSlice []int = param.NullSlice[[]int]()\n\n\tcases := map[string]Pair{\n\t\t\"nilSlice\":            {sentinel.IsNull(nilSlice), false},\n\t\t\"nullSlice\":           {sentinel.IsNull(nullSlice), true},\n\t\t\"newNullSlice\":        {sentinel.IsNull(param.NullSlice[[]int]()), true},\n\t\t\"lenNullSlice\":        {len(nullSlice) == 0, true},\n\t\t\"nilSliceValue\":       {sentinel.IsValueNull(reflect.ValueOf(nilSlice)), false},\n\t\t\"nullSliceValue\":      {sentinel.IsValueNull(reflect.ValueOf(nullSlice)), true},\n\t\t\"compareSlices\":       {slices.Compare(nilSlice, nullSlice) == 0, true},\n\t\t\"compareNonNilSlices\": {slices.Compare(nonNilSlice, nullSlice) == 0, false},\n\t}\n\n\tfor name, c := range cases {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tgot, want := c.got, c.want\n\t\t\tif got != want {\n\t\t\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestNullMap(t *testing.T) {\n\tvar nilMap map[string]int = nil\n\tvar nonNilMap map[string]int = map[string]int{\"a\": 1, \"b\": 2}\n\tvar nullMap map[string]int = param.NullMap[map[string]int]()\n\n\tcases := map[string]Pair{\n\t\t\"nilMap\":            {sentinel.IsNull(nilMap), false},\n\t\t\"nullMap\":           {sentinel.IsNull(nullMap), true},\n\t\t\"newNullMap\":        {sentinel.IsNull(param.NullMap[map[string]int]()), true},\n\t\t\"lenNullMap\":        {len(nullMap) == 0, true},\n\t\t\"nilMapValue\":       {sentinel.IsValueNull(reflect.ValueOf(nilMap)), false},\n\t\t\"nullMapValue\":      {sentinel.IsValueNull(reflect.ValueOf(nullMap)), true},\n\t\t\"compareMaps\":       {reflect.DeepEqual(nilMap, nullMap), false},\n\t\t\"compareNonNilMaps\": {reflect.DeepEqual(nonNilMap, nullMap), false},\n\t}\n\n\tfor name, test := range cases {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tgot, want := test.got, test.want\n\t\t\tif got != want {\n\t\t\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestIsNullRepeated(t *testing.T) {\n\t// Test for slices\n\tnullSlice1 := param.NullSlice[[]int]()\n\tnullSlice2 := param.NullSlice[[]int]()\n\tif !sentinel.IsNull(nullSlice1) {\n\t\tt.Errorf(\"IsNull(nullSlice1) = false, want true\")\n\t}\n\tif !sentinel.IsNull(nullSlice2) {\n\t\tt.Errorf(\"IsNull(nullSlice2) = false, want true\")\n\t}\n\tif !sentinel.IsNull(nullSlice1) || !sentinel.IsNull(nullSlice2) {\n\t\tt.Errorf(\"IsNull should return true for all NullSlice instances\")\n\t}\n\n\t// Test for maps\n\tnullMap1 := param.NullMap[map[string]int]()\n\tnullMap2 := param.NullMap[map[string]int]()\n\tif !sentinel.IsNull(nullMap1) {\n\t\tt.Errorf(\"IsNull(nullMap1) = false, want true\")\n\t}\n\tif !sentinel.IsNull(nullMap2) {\n\t\tt.Errorf(\"IsNull(nullMap2) = false, want true\")\n\t}\n}\n"
  },
  {
    "path": "internal/encoding/json/shims/shims.go",
    "content": "// This package provides shims over Go 1.2{2,3} APIs\n// which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.\n//\n// Inside the vendored package, all shim code has comments that begin look like\n// // SHIM(...): ...\npackage shims\n\nimport (\n\t\"encoding/base64\"\n\t\"reflect\"\n\t\"slices\"\n)\n\nconst EscapeHTMLByDefault = true\n\ntype OverflowableType struct{ reflect.Type }\n\nfunc (t OverflowableType) OverflowInt(x int64) bool {\n\tk := t.Kind()\n\tswitch k {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tbitSize := t.Size() * 8\n\t\ttrunc := (x << (64 - bitSize)) >> (64 - bitSize)\n\t\treturn x != trunc\n\t}\n\tpanic(\"reflect: OverflowInt of non-int type \" + t.String())\n}\n\nfunc (t OverflowableType) OverflowUint(x uint64) bool {\n\tk := t.Kind()\n\tswitch k {\n\tcase reflect.Uint, reflect.Uintptr, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\tbitSize := t.Size() * 8\n\t\ttrunc := (x << (64 - bitSize)) >> (64 - bitSize)\n\t\treturn x != trunc\n\t}\n\tpanic(\"reflect: OverflowUint of non-uint type \" + t.String())\n}\n\n// Original src code from Go 1.23 go/src/reflect/type.go (taken 1/9/25)\n/*\n\nfunc (t *rtype) OverflowInt(x int64) bool {\n\tk := t.Kind()\n\tswitch k {\n\tcase Int, Int8, Int16, Int32, Int64:\n\t\tbitSize := t.Size() * 8\n\t\ttrunc := (x << (64 - bitSize)) >> (64 - bitSize)\n\t\treturn x != trunc\n\t}\n\tpanic(\"reflect: OverflowInt of non-int type \" + t.String())\n}\n\nfunc (t *rtype) OverflowUint(x uint64) bool {\n\tk := t.Kind()\n\tswitch k {\n\tcase Uint, Uintptr, Uint8, Uint16, Uint32, Uint64:\n\t\tbitSize := t.Size() * 8\n\t\ttrunc := (x << (64 - bitSize)) >> (64 - bitSize)\n\t\treturn x != trunc\n\t}\n\tpanic(\"reflect: OverflowUint of non-uint type \" + t.String())\n}\n\n*/\n\n// TypeFor returns the [Type] that represents the type argument T.\nfunc TypeFor[T any]() reflect.Type {\n\tvar v T\n\tif t := reflect.TypeOf(v); t != nil {\n\t\treturn t // optimize for T being a non-interface kind\n\t}\n\treturn reflect.TypeOf((*T)(nil)).Elem() // only for an interface kind\n}\n\n// Original src code from Go 1.23 go/src/reflect/type.go (taken 1/9/25)\n/*\n\n// TypeFor returns the [Type] that represents the type argument T.\nfunc TypeFor[T any]() Type {\n\tvar v T\n\tif t := TypeOf(v); t != nil {\n\t\treturn t // optimize for T being a non-interface kind\n\t}\n\treturn TypeOf((*T)(nil)).Elem() // only for an interface kind\n}\n\n*/\n\ntype AppendableStdEncoding struct{ *base64.Encoding }\n\n// AppendEncode appends the base64 encoded src to dst\n// and returns the extended buffer.\nfunc (enc AppendableStdEncoding) AppendEncode(dst, src []byte) []byte {\n\tn := enc.EncodedLen(len(src))\n\tdst = slices.Grow(dst, n)\n\tenc.Encode(dst[len(dst):][:n], src)\n\treturn dst[:len(dst)+n]\n}\n\n// Original src code from Go 1.23.4 go/src/encoding/base64/base64.go (taken 1/9/25)\n/*\n\n// AppendEncode appends the base64 encoded src to dst\n// and returns the extended buffer.\nfunc (enc *Encoding) AppendEncode(dst, src []byte) []byte {\n\tn := enc.EncodedLen(len(src))\n\tdst = slices.Grow(dst, n)\n\tenc.Encode(dst[len(dst):][:n], src)\n\treturn dst[:len(dst)+n]\n}\n\n*/\n"
  },
  {
    "path": "internal/encoding/json/stream.go",
    "content": "// Copyright 2010 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage json\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"io\"\n)\n\n// A Decoder reads and decodes JSON values from an input stream.\ntype Decoder struct {\n\tr       io.Reader\n\tbuf     []byte\n\td       decodeState\n\tscanp   int   // start of unread data in buf\n\tscanned int64 // amount of data already scanned\n\tscan    scanner\n\terr     error\n\n\ttokenState int\n\ttokenStack []int\n}\n\n// NewDecoder returns a new decoder that reads from r.\n//\n// The decoder introduces its own buffering and may\n// read data from r beyond the JSON values requested.\nfunc NewDecoder(r io.Reader) *Decoder {\n\treturn &Decoder{r: r}\n}\n\n// UseNumber causes the Decoder to unmarshal a number into an\n// interface value as a [Number] instead of as a float64.\nfunc (dec *Decoder) UseNumber() { dec.d.useNumber = true }\n\n// DisallowUnknownFields causes the Decoder to return an error when the destination\n// is a struct and the input contains object keys which do not match any\n// non-ignored, exported fields in the destination.\nfunc (dec *Decoder) DisallowUnknownFields() { dec.d.disallowUnknownFields = true }\n\n// Decode reads the next JSON-encoded value from its\n// input and stores it in the value pointed to by v.\n//\n// See the documentation for [Unmarshal] for details about\n// the conversion of JSON into a Go value.\nfunc (dec *Decoder) Decode(v any) error {\n\tif dec.err != nil {\n\t\treturn dec.err\n\t}\n\n\tif err := dec.tokenPrepareForDecode(); err != nil {\n\t\treturn err\n\t}\n\n\tif !dec.tokenValueAllowed() {\n\t\treturn &SyntaxError{msg: \"not at beginning of value\", Offset: dec.InputOffset()}\n\t}\n\n\t// Read whole value into buffer.\n\tn, err := dec.readValue()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdec.d.init(dec.buf[dec.scanp : dec.scanp+n])\n\tdec.scanp += n\n\n\t// Don't save err from unmarshal into dec.err:\n\t// the connection is still usable since we read a complete JSON\n\t// object from it before the error happened.\n\terr = dec.d.unmarshal(v)\n\n\t// fixup token streaming state\n\tdec.tokenValueEnd()\n\n\treturn err\n}\n\n// Buffered returns a reader of the data remaining in the Decoder's\n// buffer. The reader is valid until the next call to [Decoder.Decode].\nfunc (dec *Decoder) Buffered() io.Reader {\n\treturn bytes.NewReader(dec.buf[dec.scanp:])\n}\n\n// readValue reads a JSON value into dec.buf.\n// It returns the length of the encoding.\nfunc (dec *Decoder) readValue() (int, error) {\n\tdec.scan.reset()\n\n\tscanp := dec.scanp\n\tvar err error\nInput:\n\t// help the compiler see that scanp is never negative, so it can remove\n\t// some bounds checks below.\n\tfor scanp >= 0 {\n\n\t\t// Look in the buffer for a new value.\n\t\tfor ; scanp < len(dec.buf); scanp++ {\n\t\t\tc := dec.buf[scanp]\n\t\t\tdec.scan.bytes++\n\t\t\tswitch dec.scan.step(&dec.scan, c) {\n\t\t\tcase scanEnd:\n\t\t\t\t// scanEnd is delayed one byte so we decrement\n\t\t\t\t// the scanner bytes count by 1 to ensure that\n\t\t\t\t// this value is correct in the next call of Decode.\n\t\t\t\tdec.scan.bytes--\n\t\t\t\tbreak Input\n\t\t\tcase scanEndObject, scanEndArray:\n\t\t\t\t// scanEnd is delayed one byte.\n\t\t\t\t// We might block trying to get that byte from src,\n\t\t\t\t// so instead invent a space byte.\n\t\t\t\tif stateEndValue(&dec.scan, ' ') == scanEnd {\n\t\t\t\t\tscanp++\n\t\t\t\t\tbreak Input\n\t\t\t\t}\n\t\t\tcase scanError:\n\t\t\t\tdec.err = dec.scan.err\n\t\t\t\treturn 0, dec.scan.err\n\t\t\t}\n\t\t}\n\n\t\t// Did the last read have an error?\n\t\t// Delayed until now to allow buffer scan.\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tif dec.scan.step(&dec.scan, ' ') == scanEnd {\n\t\t\t\t\tbreak Input\n\t\t\t\t}\n\t\t\t\tif nonSpace(dec.buf) {\n\t\t\t\t\terr = io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t}\n\t\t\tdec.err = err\n\t\t\treturn 0, err\n\t\t}\n\n\t\tn := scanp - dec.scanp\n\t\terr = dec.refill()\n\t\tscanp = dec.scanp + n\n\t}\n\treturn scanp - dec.scanp, nil\n}\n\nfunc (dec *Decoder) refill() error {\n\t// Make room to read more into the buffer.\n\t// First slide down data already consumed.\n\tif dec.scanp > 0 {\n\t\tdec.scanned += int64(dec.scanp)\n\t\tn := copy(dec.buf, dec.buf[dec.scanp:])\n\t\tdec.buf = dec.buf[:n]\n\t\tdec.scanp = 0\n\t}\n\n\t// Grow buffer if not large enough.\n\tconst minRead = 512\n\tif cap(dec.buf)-len(dec.buf) < minRead {\n\t\tnewBuf := make([]byte, len(dec.buf), 2*cap(dec.buf)+minRead)\n\t\tcopy(newBuf, dec.buf)\n\t\tdec.buf = newBuf\n\t}\n\n\t// Read. Delay error for next iteration (after scan).\n\tn, err := dec.r.Read(dec.buf[len(dec.buf):cap(dec.buf)])\n\tdec.buf = dec.buf[0 : len(dec.buf)+n]\n\n\treturn err\n}\n\nfunc nonSpace(b []byte) bool {\n\tfor _, c := range b {\n\t\tif !isSpace(c) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// An Encoder writes JSON values to an output stream.\ntype Encoder struct {\n\tw          io.Writer\n\terr        error\n\tescapeHTML bool\n\n\tindentBuf    []byte\n\tindentPrefix string\n\tindentValue  string\n}\n\n// NewEncoder returns a new encoder that writes to w.\nfunc NewEncoder(w io.Writer) *Encoder {\n\treturn &Encoder{w: w, escapeHTML: true}\n}\n\n// Encode writes the JSON encoding of v to the stream,\n// with insignificant space characters elided,\n// followed by a newline character.\n//\n// See the documentation for [Marshal] for details about the\n// conversion of Go values to JSON.\nfunc (enc *Encoder) Encode(v any) error {\n\tif enc.err != nil {\n\t\treturn enc.err\n\t}\n\n\te := newEncodeState()\n\tdefer encodeStatePool.Put(e)\n\n\terr := e.marshal(v, encOpts{escapeHTML: enc.escapeHTML})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Terminate each value with a newline.\n\t// This makes the output look a little nicer\n\t// when debugging, and some kind of space\n\t// is required if the encoded value was a number,\n\t// so that the reader knows there aren't more\n\t// digits coming.\n\te.WriteByte('\\n')\n\n\tb := e.Bytes()\n\tif enc.indentPrefix != \"\" || enc.indentValue != \"\" {\n\t\tenc.indentBuf, err = appendIndent(enc.indentBuf[:0], b, enc.indentPrefix, enc.indentValue)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb = enc.indentBuf\n\t}\n\tif _, err = enc.w.Write(b); err != nil {\n\t\tenc.err = err\n\t}\n\treturn err\n}\n\n// SetIndent instructs the encoder to format each subsequent encoded\n// value as if indented by the package-level function Indent(dst, src, prefix, indent).\n// Calling SetIndent(\"\", \"\") disables indentation.\nfunc (enc *Encoder) SetIndent(prefix, indent string) {\n\tenc.indentPrefix = prefix\n\tenc.indentValue = indent\n}\n\n// SetEscapeHTML specifies whether problematic HTML characters\n// should be escaped inside JSON quoted strings.\n// The default behavior is to escape &, <, and > to \\u0026, \\u003c, and \\u003e\n// to avoid certain safety problems that can arise when embedding JSON in HTML.\n//\n// In non-HTML settings where the escaping interferes with the readability\n// of the output, SetEscapeHTML(false) disables this behavior.\nfunc (enc *Encoder) SetEscapeHTML(on bool) {\n\tenc.escapeHTML = on\n}\n\n// RawMessage is a raw encoded JSON value.\n// It implements [Marshaler] and [Unmarshaler] and can\n// be used to delay JSON decoding or precompute a JSON encoding.\ntype RawMessage []byte\n\n// MarshalJSON returns m as the JSON encoding of m.\nfunc (m RawMessage) MarshalJSON() ([]byte, error) {\n\tif m == nil {\n\t\treturn []byte(\"null\"), nil\n\t}\n\treturn m, nil\n}\n\n// UnmarshalJSON sets *m to a copy of data.\nfunc (m *RawMessage) UnmarshalJSON(data []byte) error {\n\tif m == nil {\n\t\treturn errors.New(\"json.RawMessage: UnmarshalJSON on nil pointer\")\n\t}\n\t*m = append((*m)[0:0], data...)\n\treturn nil\n}\n\nvar _ Marshaler = (*RawMessage)(nil)\nvar _ Unmarshaler = (*RawMessage)(nil)\n\n// A Token holds a value of one of these types:\n//\n//   - [Delim], for the four JSON delimiters [ ] { }\n//   - bool, for JSON booleans\n//   - float64, for JSON numbers\n//   - [Number], for JSON numbers\n//   - string, for JSON string literals\n//   - nil, for JSON null\ntype Token any\n\nconst (\n\ttokenTopValue = iota\n\ttokenArrayStart\n\ttokenArrayValue\n\ttokenArrayComma\n\ttokenObjectStart\n\ttokenObjectKey\n\ttokenObjectColon\n\ttokenObjectValue\n\ttokenObjectComma\n)\n\n// advance tokenstate from a separator state to a value state\nfunc (dec *Decoder) tokenPrepareForDecode() error {\n\t// Note: Not calling peek before switch, to avoid\n\t// putting peek into the standard Decode path.\n\t// peek is only called when using the Token API.\n\tswitch dec.tokenState {\n\tcase tokenArrayComma:\n\t\tc, err := dec.peek()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif c != ',' {\n\t\t\treturn &SyntaxError{\"expected comma after array element\", dec.InputOffset()}\n\t\t}\n\t\tdec.scanp++\n\t\tdec.tokenState = tokenArrayValue\n\tcase tokenObjectColon:\n\t\tc, err := dec.peek()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif c != ':' {\n\t\t\treturn &SyntaxError{\"expected colon after object key\", dec.InputOffset()}\n\t\t}\n\t\tdec.scanp++\n\t\tdec.tokenState = tokenObjectValue\n\t}\n\treturn nil\n}\n\nfunc (dec *Decoder) tokenValueAllowed() bool {\n\tswitch dec.tokenState {\n\tcase tokenTopValue, tokenArrayStart, tokenArrayValue, tokenObjectValue:\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (dec *Decoder) tokenValueEnd() {\n\tswitch dec.tokenState {\n\tcase tokenArrayStart, tokenArrayValue:\n\t\tdec.tokenState = tokenArrayComma\n\tcase tokenObjectValue:\n\t\tdec.tokenState = tokenObjectComma\n\t}\n}\n\n// A Delim is a JSON array or object delimiter, one of [ ] { or }.\ntype Delim rune\n\nfunc (d Delim) String() string {\n\treturn string(d)\n}\n\n// Token returns the next JSON token in the input stream.\n// At the end of the input stream, Token returns nil, [io.EOF].\n//\n// Token guarantees that the delimiters [ ] { } it returns are\n// properly nested and matched: if Token encounters an unexpected\n// delimiter in the input, it will return an error.\n//\n// The input stream consists of basic JSON values—bool, string,\n// number, and null—along with delimiters [ ] { } of type [Delim]\n// to mark the start and end of arrays and objects.\n// Commas and colons are elided.\nfunc (dec *Decoder) Token() (Token, error) {\n\tfor {\n\t\tc, err := dec.peek()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tswitch c {\n\t\tcase '[':\n\t\t\tif !dec.tokenValueAllowed() {\n\t\t\t\treturn dec.tokenError(c)\n\t\t\t}\n\t\t\tdec.scanp++\n\t\t\tdec.tokenStack = append(dec.tokenStack, dec.tokenState)\n\t\t\tdec.tokenState = tokenArrayStart\n\t\t\treturn Delim('['), nil\n\n\t\tcase ']':\n\t\t\tif dec.tokenState != tokenArrayStart && dec.tokenState != tokenArrayComma {\n\t\t\t\treturn dec.tokenError(c)\n\t\t\t}\n\t\t\tdec.scanp++\n\t\t\tdec.tokenState = dec.tokenStack[len(dec.tokenStack)-1]\n\t\t\tdec.tokenStack = dec.tokenStack[:len(dec.tokenStack)-1]\n\t\t\tdec.tokenValueEnd()\n\t\t\treturn Delim(']'), nil\n\n\t\tcase '{':\n\t\t\tif !dec.tokenValueAllowed() {\n\t\t\t\treturn dec.tokenError(c)\n\t\t\t}\n\t\t\tdec.scanp++\n\t\t\tdec.tokenStack = append(dec.tokenStack, dec.tokenState)\n\t\t\tdec.tokenState = tokenObjectStart\n\t\t\treturn Delim('{'), nil\n\n\t\tcase '}':\n\t\t\tif dec.tokenState != tokenObjectStart && dec.tokenState != tokenObjectComma {\n\t\t\t\treturn dec.tokenError(c)\n\t\t\t}\n\t\t\tdec.scanp++\n\t\t\tdec.tokenState = dec.tokenStack[len(dec.tokenStack)-1]\n\t\t\tdec.tokenStack = dec.tokenStack[:len(dec.tokenStack)-1]\n\t\t\tdec.tokenValueEnd()\n\t\t\treturn Delim('}'), nil\n\n\t\tcase ':':\n\t\t\tif dec.tokenState != tokenObjectColon {\n\t\t\t\treturn dec.tokenError(c)\n\t\t\t}\n\t\t\tdec.scanp++\n\t\t\tdec.tokenState = tokenObjectValue\n\t\t\tcontinue\n\n\t\tcase ',':\n\t\t\tif dec.tokenState == tokenArrayComma {\n\t\t\t\tdec.scanp++\n\t\t\t\tdec.tokenState = tokenArrayValue\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif dec.tokenState == tokenObjectComma {\n\t\t\t\tdec.scanp++\n\t\t\t\tdec.tokenState = tokenObjectKey\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn dec.tokenError(c)\n\n\t\tcase '\"':\n\t\t\tif dec.tokenState == tokenObjectStart || dec.tokenState == tokenObjectKey {\n\t\t\t\tvar x string\n\t\t\t\told := dec.tokenState\n\t\t\t\tdec.tokenState = tokenTopValue\n\t\t\t\terr := dec.Decode(&x)\n\t\t\t\tdec.tokenState = old\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tdec.tokenState = tokenObjectColon\n\t\t\t\treturn x, nil\n\t\t\t}\n\t\t\tfallthrough\n\n\t\tdefault:\n\t\t\tif !dec.tokenValueAllowed() {\n\t\t\t\treturn dec.tokenError(c)\n\t\t\t}\n\t\t\tvar x any\n\t\t\tif err := dec.Decode(&x); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn x, nil\n\t\t}\n\t}\n}\n\nfunc (dec *Decoder) tokenError(c byte) (Token, error) {\n\tvar context string\n\tswitch dec.tokenState {\n\tcase tokenTopValue:\n\t\tcontext = \" looking for beginning of value\"\n\tcase tokenArrayStart, tokenArrayValue, tokenObjectValue:\n\t\tcontext = \" looking for beginning of value\"\n\tcase tokenArrayComma:\n\t\tcontext = \" after array element\"\n\tcase tokenObjectKey:\n\t\tcontext = \" looking for beginning of object key string\"\n\tcase tokenObjectColon:\n\t\tcontext = \" after object key\"\n\tcase tokenObjectComma:\n\t\tcontext = \" after object key:value pair\"\n\t}\n\treturn nil, &SyntaxError{\"invalid character \" + quoteChar(c) + context, dec.InputOffset()}\n}\n\n// More reports whether there is another element in the\n// current array or object being parsed.\nfunc (dec *Decoder) More() bool {\n\tc, err := dec.peek()\n\treturn err == nil && c != ']' && c != '}'\n}\n\nfunc (dec *Decoder) peek() (byte, error) {\n\tvar err error\n\tfor {\n\t\tfor i := dec.scanp; i < len(dec.buf); i++ {\n\t\t\tc := dec.buf[i]\n\t\t\tif isSpace(c) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdec.scanp = i\n\t\t\treturn c, nil\n\t\t}\n\t\t// buffer has been scanned, now report any error\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\terr = dec.refill()\n\t}\n}\n\n// InputOffset returns the input stream byte offset of the current decoder position.\n// The offset gives the location of the end of the most recently returned token\n// and the beginning of the next token.\nfunc (dec *Decoder) InputOffset() int64 {\n\treturn dec.scanned + int64(dec.scanp)\n}\n"
  },
  {
    "path": "internal/encoding/json/tables.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage json\n\nimport \"unicode/utf8\"\n\n// safeSet holds the value true if the ASCII character with the given array\n// position can be represented inside a JSON string without any further\n// escaping.\n//\n// All values are true except for the ASCII control characters (0-31), the\n// double quote (\"), and the backslash character (\"\\\").\nvar safeSet = [utf8.RuneSelf]bool{\n\t' ':      true,\n\t'!':      true,\n\t'\"':      false,\n\t'#':      true,\n\t'$':      true,\n\t'%':      true,\n\t'&':      true,\n\t'\\'':     true,\n\t'(':      true,\n\t')':      true,\n\t'*':      true,\n\t'+':      true,\n\t',':      true,\n\t'-':      true,\n\t'.':      true,\n\t'/':      true,\n\t'0':      true,\n\t'1':      true,\n\t'2':      true,\n\t'3':      true,\n\t'4':      true,\n\t'5':      true,\n\t'6':      true,\n\t'7':      true,\n\t'8':      true,\n\t'9':      true,\n\t':':      true,\n\t';':      true,\n\t'<':      true,\n\t'=':      true,\n\t'>':      true,\n\t'?':      true,\n\t'@':      true,\n\t'A':      true,\n\t'B':      true,\n\t'C':      true,\n\t'D':      true,\n\t'E':      true,\n\t'F':      true,\n\t'G':      true,\n\t'H':      true,\n\t'I':      true,\n\t'J':      true,\n\t'K':      true,\n\t'L':      true,\n\t'M':      true,\n\t'N':      true,\n\t'O':      true,\n\t'P':      true,\n\t'Q':      true,\n\t'R':      true,\n\t'S':      true,\n\t'T':      true,\n\t'U':      true,\n\t'V':      true,\n\t'W':      true,\n\t'X':      true,\n\t'Y':      true,\n\t'Z':      true,\n\t'[':      true,\n\t'\\\\':     false,\n\t']':      true,\n\t'^':      true,\n\t'_':      true,\n\t'`':      true,\n\t'a':      true,\n\t'b':      true,\n\t'c':      true,\n\t'd':      true,\n\t'e':      true,\n\t'f':      true,\n\t'g':      true,\n\t'h':      true,\n\t'i':      true,\n\t'j':      true,\n\t'k':      true,\n\t'l':      true,\n\t'm':      true,\n\t'n':      true,\n\t'o':      true,\n\t'p':      true,\n\t'q':      true,\n\t'r':      true,\n\t's':      true,\n\t't':      true,\n\t'u':      true,\n\t'v':      true,\n\t'w':      true,\n\t'x':      true,\n\t'y':      true,\n\t'z':      true,\n\t'{':      true,\n\t'|':      true,\n\t'}':      true,\n\t'~':      true,\n\t'\\u007f': true,\n}\n\n// htmlSafeSet holds the value true if the ASCII character with the given\n// array position can be safely represented inside a JSON string, embedded\n// inside of HTML <script> tags, without any additional escaping.\n//\n// All values are true except for the ASCII control characters (0-31), the\n// double quote (\"), the backslash character (\"\\\"), HTML opening and closing\n// tags (\"<\" and \">\"), and the ampersand (\"&\").\nvar htmlSafeSet = [utf8.RuneSelf]bool{\n\t' ':      true,\n\t'!':      true,\n\t'\"':      false,\n\t'#':      true,\n\t'$':      true,\n\t'%':      true,\n\t'&':      false,\n\t'\\'':     true,\n\t'(':      true,\n\t')':      true,\n\t'*':      true,\n\t'+':      true,\n\t',':      true,\n\t'-':      true,\n\t'.':      true,\n\t'/':      true,\n\t'0':      true,\n\t'1':      true,\n\t'2':      true,\n\t'3':      true,\n\t'4':      true,\n\t'5':      true,\n\t'6':      true,\n\t'7':      true,\n\t'8':      true,\n\t'9':      true,\n\t':':      true,\n\t';':      true,\n\t'<':      false,\n\t'=':      true,\n\t'>':      false,\n\t'?':      true,\n\t'@':      true,\n\t'A':      true,\n\t'B':      true,\n\t'C':      true,\n\t'D':      true,\n\t'E':      true,\n\t'F':      true,\n\t'G':      true,\n\t'H':      true,\n\t'I':      true,\n\t'J':      true,\n\t'K':      true,\n\t'L':      true,\n\t'M':      true,\n\t'N':      true,\n\t'O':      true,\n\t'P':      true,\n\t'Q':      true,\n\t'R':      true,\n\t'S':      true,\n\t'T':      true,\n\t'U':      true,\n\t'V':      true,\n\t'W':      true,\n\t'X':      true,\n\t'Y':      true,\n\t'Z':      true,\n\t'[':      true,\n\t'\\\\':     false,\n\t']':      true,\n\t'^':      true,\n\t'_':      true,\n\t'`':      true,\n\t'a':      true,\n\t'b':      true,\n\t'c':      true,\n\t'd':      true,\n\t'e':      true,\n\t'f':      true,\n\t'g':      true,\n\t'h':      true,\n\t'i':      true,\n\t'j':      true,\n\t'k':      true,\n\t'l':      true,\n\t'm':      true,\n\t'n':      true,\n\t'o':      true,\n\t'p':      true,\n\t'q':      true,\n\t'r':      true,\n\t's':      true,\n\t't':      true,\n\t'u':      true,\n\t'v':      true,\n\t'w':      true,\n\t'x':      true,\n\t'y':      true,\n\t'z':      true,\n\t'{':      true,\n\t'|':      true,\n\t'}':      true,\n\t'~':      true,\n\t'\\u007f': true,\n}\n"
  },
  {
    "path": "internal/encoding/json/tags.go",
    "content": "// Copyright 2011 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage json\n\nimport (\n\t\"strings\"\n)\n\n// tagOptions is the string following a comma in a struct field's \"json\"\n// tag, or the empty string. It does not include the leading comma.\ntype tagOptions string\n\n// parseTag splits a struct field's json tag into its name and\n// comma-separated options.\nfunc parseTag(tag string) (string, tagOptions) {\n\ttag, opt, _ := strings.Cut(tag, \",\")\n\treturn tag, tagOptions(opt)\n}\n\n// Contains reports whether a comma-separated list of options\n// contains a particular substr flag. substr must be surrounded by a\n// string boundary or commas.\nfunc (o tagOptions) Contains(optionName string) bool {\n\tif len(o) == 0 {\n\t\treturn false\n\t}\n\ts := string(o)\n\tfor s != \"\" {\n\t\tvar name string\n\t\tname, s, _ = strings.Cut(s, \",\")\n\t\tif name == optionName {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "internal/encoding/json/time.go",
    "content": "// EDIT(begin): custom time marshaler\npackage json\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/shims\"\n\t\"reflect\"\n\t\"time\"\n)\n\ntype TimeMarshaler interface {\n\tMarshalJSONWithTimeLayout(string) []byte\n}\n\nfunc TimeLayout(fmt string) string {\n\tswitch fmt {\n\tcase \"\", \"date-time\":\n\t\treturn time.RFC3339\n\tcase \"date\":\n\t\treturn time.DateOnly\n\tdefault:\n\t\treturn fmt\n\t}\n}\n\nvar timeType = shims.TypeFor[time.Time]()\n\nfunc newTimeEncoder() encoderFunc {\n\treturn func(e *encodeState, v reflect.Value, opts encOpts) {\n\t\tt := v.Interface().(time.Time)\n\t\tfmtted := t.Format(TimeLayout(opts.timefmt))\n\t\tstringEncoder(e, reflect.ValueOf(fmtted), opts)\n\t}\n}\n\n// Uses continuation passing style, to add the timefmt option to k\nfunc continueWithTimeFmt(timefmt string, k encoderFunc) encoderFunc {\n\treturn func(e *encodeState, v reflect.Value, opts encOpts) {\n\t\topts.timefmt = timefmt\n\t\tk(e, v, opts)\n\t}\n}\n\nfunc timeMarshalEncoder(e *encodeState, v reflect.Value, opts encOpts) bool {\n\ttm, ok := v.Interface().(TimeMarshaler)\n\tif !ok {\n\t\treturn false\n\t}\n\n\tb := tm.MarshalJSONWithTimeLayout(opts.timefmt)\n\tif b != nil {\n\t\te.Grow(len(b))\n\t\tout := e.AvailableBuffer()\n\t\tout, _ = appendCompact(out, b, opts.escapeHTML)\n\t\te.Buffer.Write(out)\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// EDIT(end)\n"
  },
  {
    "path": "internal/paramutil/field.go",
    "content": "package paramutil\n\nimport (\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n)\n\nfunc AddrIfPresent[T comparable](v param.Opt[T]) *T {\n\tif v.Valid() {\n\t\treturn &v.Value\n\t}\n\treturn nil\n}\n\nfunc ToOpt[T comparable](v T, meta respjson.Field) param.Opt[T] {\n\tif meta.Valid() {\n\t\treturn param.NewOpt(v)\n\t} else if meta.Raw() == respjson.Null {\n\t\treturn param.Null[T]()\n\t}\n\treturn param.Opt[T]{}\n}\n\n// Checks if the value is not omitted and not null\nfunc Valid(v param.ParamStruct) bool {\n\tif ovr, ok := v.Overrides(); ok {\n\t\treturn ovr != nil\n\t}\n\treturn !param.IsNull(v) && !param.IsOmitted(v)\n}\n"
  },
  {
    "path": "internal/paramutil/union.go",
    "content": "package paramutil\n\nimport (\n\t\"fmt\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"reflect\"\n)\n\nvar paramUnionType = reflect.TypeOf(param.APIUnion{})\n\n// VariantFromUnion can be used to extract the present variant from a param union type.\n// A param union type is a struct with an embedded field of [APIUnion].\nfunc VariantFromUnion(u reflect.Value) (any, error) {\n\tif u.Kind() == reflect.Ptr {\n\t\tu = u.Elem()\n\t}\n\n\tif u.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"param: cannot extract variant from non-struct union\")\n\t}\n\n\tisUnion := false\n\tnVariants := 0\n\tvariantIdx := -1\n\tfor i := 0; i < u.NumField(); i++ {\n\t\tif !u.Field(i).IsZero() {\n\t\t\tnVariants++\n\t\t\tvariantIdx = i\n\t\t}\n\t\tif u.Field(i).Type() == paramUnionType {\n\t\t\tisUnion = u.Type().Field(i).Anonymous\n\t\t}\n\t}\n\n\tif !isUnion {\n\t\treturn nil, fmt.Errorf(\"param: cannot extract variant from non-union\")\n\t}\n\n\tif nVariants > 1 {\n\t\treturn nil, fmt.Errorf(\"param: cannot extract variant from union with multiple variants\")\n\t}\n\n\tif nVariants == 0 {\n\t\treturn nil, fmt.Errorf(\"param: cannot extract variant from union with no variants\")\n\t}\n\n\treturn u.Field(variantIdx).Interface(), nil\n}\n"
  },
  {
    "path": "internal/requestconfig/requestconfig.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage requestconfig\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"math/rand\"\n\t\"mime\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apierror\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiform\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n)\n\nfunc getDefaultHeaders() map[string]string {\n\treturn map[string]string{\n\t\t\"User-Agent\": fmt.Sprintf(\"Anthropic/Go %s\", internal.PackageVersion),\n\t}\n}\n\nfunc getNormalizedOS() string {\n\tswitch runtime.GOOS {\n\tcase \"ios\":\n\t\treturn \"iOS\"\n\tcase \"android\":\n\t\treturn \"Android\"\n\tcase \"darwin\":\n\t\treturn \"MacOS\"\n\tcase \"window\":\n\t\treturn \"Windows\"\n\tcase \"freebsd\":\n\t\treturn \"FreeBSD\"\n\tcase \"openbsd\":\n\t\treturn \"OpenBSD\"\n\tcase \"linux\":\n\t\treturn \"Linux\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"Other:%s\", runtime.GOOS)\n\t}\n}\n\nfunc getNormalizedArchitecture() string {\n\tswitch runtime.GOARCH {\n\tcase \"386\":\n\t\treturn \"x32\"\n\tcase \"amd64\":\n\t\treturn \"x64\"\n\tcase \"arm\":\n\t\treturn \"arm\"\n\tcase \"arm64\":\n\t\treturn \"arm64\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"other:%s\", runtime.GOARCH)\n\t}\n}\n\nfunc getPlatformProperties() map[string]string {\n\treturn map[string]string{\n\t\t\"X-Stainless-Lang\":            \"go\",\n\t\t\"X-Stainless-Package-Version\": internal.PackageVersion,\n\t\t\"X-Stainless-OS\":              getNormalizedOS(),\n\t\t\"X-Stainless-Arch\":            getNormalizedArchitecture(),\n\t\t\"X-Stainless-Runtime\":         \"go\",\n\t\t\"X-Stainless-Runtime-Version\": runtime.Version(),\n\t}\n}\n\ntype RequestOption interface {\n\tApply(*RequestConfig) error\n}\n\ntype RequestOptionFunc func(*RequestConfig) error\ntype PreRequestOptionFunc func(*RequestConfig) error\n\nfunc (s RequestOptionFunc) Apply(r *RequestConfig) error    { return s(r) }\nfunc (s PreRequestOptionFunc) Apply(r *RequestConfig) error { return s(r) }\n\nfunc NewRequestConfig(ctx context.Context, method string, u string, body any, dst any, opts ...RequestOption) (*RequestConfig, error) {\n\tvar reader io.Reader\n\n\tcontentType := \"application/json\"\n\thasSerializationFunc := false\n\n\tif body, ok := body.(json.Marshaler); ok {\n\t\tcontent, err := body.MarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treader = bytes.NewBuffer(content)\n\t\thasSerializationFunc = true\n\t}\n\tif body, ok := body.(apiform.Marshaler); ok {\n\t\tvar (\n\t\t\tcontent []byte\n\t\t\terr     error\n\t\t)\n\t\tcontent, contentType, err = body.MarshalMultipart()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treader = bytes.NewBuffer(content)\n\t\thasSerializationFunc = true\n\t}\n\tif body, ok := body.(apiquery.Queryer); ok {\n\t\thasSerializationFunc = true\n\t\tq, err := body.URLQuery()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tparams := q.Encode()\n\t\tif params != \"\" {\n\t\t\tu = u + \"?\" + params\n\t\t}\n\t}\n\tif body, ok := body.([]byte); ok {\n\t\treader = bytes.NewBuffer(body)\n\t\thasSerializationFunc = true\n\t}\n\tif body, ok := body.(io.Reader); ok {\n\t\treader = body\n\t\thasSerializationFunc = true\n\t}\n\n\t// Fallback to json serialization if none of the serialization functions that we expect\n\t// to see is present.\n\tif body != nil && !hasSerializationFunc {\n\t\tbuf := new(bytes.Buffer)\n\t\tenc := json.NewEncoder(buf)\n\t\tenc.SetEscapeHTML(true)\n\t\tif err := enc.Encode(body); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treader = buf\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, method, u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif reader != nil {\n\t\treq.Header.Set(\"Content-Type\", contentType)\n\t}\n\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"X-Stainless-Retry-Count\", \"0\")\n\treq.Header.Set(\"X-Stainless-Timeout\", \"0\")\n\tfor k, v := range getDefaultHeaders() {\n\t\treq.Header.Add(k, v)\n\t}\n\treq.Header.Set(\"anthropic-version\", \"2023-06-01\")\n\tfor k, v := range getPlatformProperties() {\n\t\treq.Header.Add(k, v)\n\t}\n\tcfg := RequestConfig{\n\t\tMaxRetries: 2,\n\t\tContext:    ctx,\n\t\tRequest:    req,\n\t\tHTTPClient: http.DefaultClient,\n\t\tBody:       reader,\n\t}\n\tcfg.ResponseBodyInto = dst\n\terr = cfg.Apply(opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// This must run after `cfg.Apply(...)` above in case the request timeout gets modified. We also only\n\t// apply our own logic for it if it's still \"0\" from above. If it's not, then it was deleted or modified\n\t// by the user and we should respect that.\n\tif req.Header.Get(\"X-Stainless-Timeout\") == \"0\" {\n\t\tif cfg.RequestTimeout == time.Duration(0) {\n\t\t\treq.Header.Del(\"X-Stainless-Timeout\")\n\t\t} else {\n\t\t\treq.Header.Set(\"X-Stainless-Timeout\", strconv.Itoa(int(cfg.RequestTimeout.Seconds())))\n\t\t}\n\t}\n\n\treturn &cfg, nil\n}\n\n// This interface is primarily used to describe an [*http.Client], but also\n// supports custom HTTP implementations.\ntype HTTPDoer interface {\n\tDo(req *http.Request) (*http.Response, error)\n}\n\n// RequestConfig represents all the state related to one request.\n//\n// Editing the variables inside RequestConfig directly is unstable api. Prefer\n// composing the RequestOption instead if possible.\ntype RequestConfig struct {\n\tMaxRetries     int\n\tRequestTimeout time.Duration\n\tContext        context.Context\n\tRequest        *http.Request\n\tBaseURL        *url.URL\n\t// DefaultBaseURL will be used if BaseURL is not explicitly overridden using\n\t// WithBaseURL.\n\tDefaultBaseURL *url.URL\n\tCustomHTTPDoer HTTPDoer\n\tHTTPClient     *http.Client\n\tMiddlewares    []middleware\n\tAPIKey         string\n\tAuthToken      string\n\t// If ResponseBodyInto not nil, then we will attempt to deserialize into\n\t// ResponseBodyInto. If Destination is a []byte, then it will return the body as\n\t// is.\n\tResponseBodyInto any\n\t// ResponseInto copies the \\*http.Response of the corresponding request into the\n\t// given address\n\tResponseInto **http.Response\n\tBody         io.Reader\n}\n\n// middleware is exactly the same type as the Middleware type found in the [option] package,\n// but it is redeclared here for circular dependency issues.\ntype middleware = func(*http.Request, middlewareNext) (*http.Response, error)\n\n// middlewareNext is exactly the same type as the MiddlewareNext type found in the [option] package,\n// but it is redeclared here for circular dependency issues.\ntype middlewareNext = func(*http.Request) (*http.Response, error)\n\nfunc applyMiddleware(middleware middleware, next middlewareNext) middlewareNext {\n\treturn func(req *http.Request) (res *http.Response, err error) {\n\t\treturn middleware(req, next)\n\t}\n}\n\nfunc shouldRetry(req *http.Request, res *http.Response) bool {\n\t// If there is no way to recover the Body, then we shouldn't retry.\n\tif req.Body != nil && req.GetBody == nil {\n\t\treturn false\n\t}\n\n\t// If there is no response, that indicates that there is a connection error\n\t// so we retry the request.\n\tif res == nil {\n\t\treturn true\n\t}\n\n\t// If the header explicitly wants a retry behavior, respect that over the\n\t// http status code.\n\tif res.Header.Get(\"x-should-retry\") == \"true\" {\n\t\treturn true\n\t}\n\tif res.Header.Get(\"x-should-retry\") == \"false\" {\n\t\treturn false\n\t}\n\n\treturn res.StatusCode == http.StatusRequestTimeout ||\n\t\tres.StatusCode == http.StatusConflict ||\n\t\tres.StatusCode == http.StatusTooManyRequests ||\n\t\tres.StatusCode >= http.StatusInternalServerError\n}\n\nfunc parseRetryAfterHeader(resp *http.Response) (time.Duration, bool) {\n\tif resp == nil {\n\t\treturn 0, false\n\t}\n\n\ttype retryData struct {\n\t\theader string\n\t\tunits  time.Duration\n\n\t\t// custom is used when the regular algorithm failed and is optional.\n\t\t// the returned duration is used verbatim (units is not applied).\n\t\tcustom func(string) (time.Duration, bool)\n\t}\n\n\tnop := func(string) (time.Duration, bool) { return 0, false }\n\n\t// the headers are listed in order of preference\n\tretries := []retryData{\n\t\t{\n\t\t\theader: \"Retry-After-Ms\",\n\t\t\tunits:  time.Millisecond,\n\t\t\tcustom: nop,\n\t\t},\n\t\t{\n\t\t\theader: \"Retry-After\",\n\t\t\tunits:  time.Second,\n\n\t\t\t// retry-after values are expressed in either number of\n\t\t\t// seconds or an HTTP-date indicating when to try again\n\t\t\tcustom: func(ra string) (time.Duration, bool) {\n\t\t\t\tt, err := time.Parse(time.RFC1123, ra)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn 0, false\n\t\t\t\t}\n\t\t\t\treturn time.Until(t), true\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, retry := range retries {\n\t\tv := resp.Header.Get(retry.header)\n\t\tif v == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif retryAfter, err := strconv.ParseFloat(v, 64); err == nil {\n\t\t\treturn time.Duration(retryAfter * float64(retry.units)), true\n\t\t}\n\t\tif d, ok := retry.custom(v); ok {\n\t\t\treturn d, true\n\t\t}\n\t}\n\n\treturn 0, false\n}\n\n// isBeforeContextDeadline reports whether the non-zero Time t is\n// before ctx's deadline. If ctx does not have a deadline, it\n// always reports true (the deadline is considered infinite).\nfunc isBeforeContextDeadline(t time.Time, ctx context.Context) bool {\n\td, ok := ctx.Deadline()\n\tif !ok {\n\t\treturn true\n\t}\n\treturn t.Before(d)\n}\n\n// bodyWithTimeout is an io.ReadCloser which can observe a context's cancel func\n// to handle timeouts etc. It wraps an existing io.ReadCloser.\ntype bodyWithTimeout struct {\n\tstop func() // stops the time.Timer waiting to cancel the request\n\trc   io.ReadCloser\n}\n\nfunc (b *bodyWithTimeout) Read(p []byte) (n int, err error) {\n\tn, err = b.rc.Read(p)\n\tif err == nil {\n\t\treturn n, nil\n\t}\n\tif err == io.EOF {\n\t\treturn n, err\n\t}\n\treturn n, err\n}\n\nfunc (b *bodyWithTimeout) Close() error {\n\terr := b.rc.Close()\n\tb.stop()\n\treturn err\n}\n\nfunc retryDelay(res *http.Response, retryCount int) time.Duration {\n\t// If the backend tells us to wait a certain amount of time, use that value\n\tif retryAfterDelay, ok := parseRetryAfterHeader(res); ok {\n\t\treturn max(0, retryAfterDelay)\n\t}\n\n\tmaxDelay := 8 * time.Second\n\tdelay := time.Duration(0.5 * float64(time.Second) * math.Pow(2, float64(retryCount)))\n\tif delay > maxDelay {\n\t\tdelay = maxDelay\n\t}\n\n\tjitter := rand.Int63n(int64(delay / 4))\n\tdelay -= time.Duration(jitter)\n\treturn delay\n}\n\nfunc (cfg *RequestConfig) Execute() (err error) {\n\tif cfg.BaseURL == nil {\n\t\tif cfg.DefaultBaseURL != nil {\n\t\t\tcfg.BaseURL = cfg.DefaultBaseURL\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"requestconfig: base url is not set\")\n\t\t}\n\t}\n\n\tcfg.Request.URL, err = cfg.BaseURL.Parse(strings.TrimLeft(cfg.Request.URL.String(), \"/\"))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif cfg.Body != nil && cfg.Request.Body == nil {\n\t\tswitch body := cfg.Body.(type) {\n\t\tcase *bytes.Buffer:\n\t\t\tb := body.Bytes()\n\t\t\tcfg.Request.ContentLength = int64(body.Len())\n\t\t\tcfg.Request.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(b)), nil }\n\t\t\tcfg.Request.Body, _ = cfg.Request.GetBody()\n\t\tcase *bytes.Reader:\n\t\t\tcfg.Request.ContentLength = int64(body.Len())\n\t\t\tcfg.Request.GetBody = func() (io.ReadCloser, error) {\n\t\t\t\t_, err := body.Seek(0, 0)\n\t\t\t\treturn io.NopCloser(body), err\n\t\t\t}\n\t\t\tcfg.Request.Body, _ = cfg.Request.GetBody()\n\t\tdefault:\n\t\t\tif rc, ok := body.(io.ReadCloser); ok {\n\t\t\t\tcfg.Request.Body = rc\n\t\t\t} else {\n\t\t\t\tcfg.Request.Body = io.NopCloser(body)\n\t\t\t}\n\t\t}\n\t}\n\n\thandler := cfg.HTTPClient.Do\n\tif cfg.CustomHTTPDoer != nil {\n\t\thandler = cfg.CustomHTTPDoer.Do\n\t}\n\tfor i := len(cfg.Middlewares) - 1; i >= 0; i -= 1 {\n\t\thandler = applyMiddleware(cfg.Middlewares[i], handler)\n\t}\n\n\t// Don't send the current retry count in the headers if the caller modified the header defaults.\n\tshouldSendRetryCount := cfg.Request.Header.Get(\"X-Stainless-Retry-Count\") == \"0\"\n\n\tvar res *http.Response\n\tvar cancel context.CancelFunc\n\tfor retryCount := 0; retryCount <= cfg.MaxRetries; retryCount += 1 {\n\t\tctx := cfg.Request.Context()\n\t\tif cfg.RequestTimeout != time.Duration(0) && isBeforeContextDeadline(time.Now().Add(cfg.RequestTimeout), ctx) {\n\t\t\tctx, cancel = context.WithTimeout(ctx, cfg.RequestTimeout)\n\t\t\tdefer func() {\n\t\t\t\t// The cancel function is nil if it was handed off to be handled in a different scope.\n\t\t\t\tif cancel != nil {\n\t\t\t\t\tcancel()\n\t\t\t\t}\n\t\t\t}()\n\t\t}\n\n\t\treq := cfg.Request.Clone(ctx)\n\t\tif shouldSendRetryCount {\n\t\t\treq.Header.Set(\"X-Stainless-Retry-Count\", strconv.Itoa(retryCount))\n\t\t}\n\n\t\tres, err = handler(req)\n\t\tif ctx != nil && ctx.Err() != nil {\n\t\t\treturn ctx.Err()\n\t\t}\n\t\tif !shouldRetry(cfg.Request, res) || retryCount >= cfg.MaxRetries {\n\t\t\tbreak\n\t\t}\n\n\t\t// Prepare next request and wait for the retry delay\n\t\tif cfg.Request.GetBody != nil {\n\t\t\tcfg.Request.Body, err = cfg.Request.GetBody()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// Can't actually refresh the body, so we don't attempt to retry here\n\t\tif cfg.Request.GetBody == nil && cfg.Request.Body != nil {\n\t\t\tbreak\n\t\t}\n\n\t\t// Close the response body before retrying to prevent connection leaks\n\t\tif res != nil && res.Body != nil {\n\t\t\t_ = res.Body.Close()\n\t\t}\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tcase <-time.After(retryDelay(res, retryCount)):\n\t\t}\n\t}\n\n\t// Save *http.Response if it is requested to, even if there was an error making the request. This is\n\t// useful in cases where you might want to debug by inspecting the response. Note that if err != nil,\n\t// the response should be generally be empty, but there are edge cases.\n\tif cfg.ResponseInto != nil {\n\t\t*cfg.ResponseInto = res\n\t}\n\tif responseBodyInto, ok := cfg.ResponseBodyInto.(**http.Response); ok {\n\t\t*responseBodyInto = res\n\t}\n\n\t// If there was a connection error in the final request or any other transport error,\n\t// return that early without trying to coerce into an APIError.\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode >= 400 {\n\t\tcontents, err := io.ReadAll(res.Body)\n\t\t_ = res.Body.Close()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// If there is an APIError, re-populate the response body so that debugging\n\t\t// utilities can conveniently dump the response without issue.\n\t\tres.Body = io.NopCloser(bytes.NewBuffer(contents))\n\n\t\t// Load the contents into the error format if it is provided.\n\t\taerr := apierror.Error{Request: cfg.Request, Response: res, StatusCode: res.StatusCode, RequestID: res.Header.Get(\"request-id\")}\n\t\terr = aerr.UnmarshalJSON(contents)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn &aerr\n\t}\n\n\t_, intoCustomResponseBody := cfg.ResponseBodyInto.(**http.Response)\n\tif cfg.ResponseBodyInto == nil || intoCustomResponseBody {\n\t\t// We aren't reading the response body in this scope, but whoever is will need the\n\t\t// cancel func from the context to observe request timeouts.\n\t\t// Put the cancel function in the response body so it can be handled elsewhere.\n\t\tif cancel != nil {\n\t\t\tres.Body = &bodyWithTimeout{rc: res.Body, stop: cancel}\n\t\t\tcancel = nil\n\t\t}\n\t\treturn nil\n\t}\n\n\tcontents, err := io.ReadAll(res.Body)\n\t_ = res.Body.Close()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading response body: %w\", err)\n\t}\n\n\t// If we are not json, return plaintext\n\tcontentType := res.Header.Get(\"content-type\")\n\tmediaType, _, _ := mime.ParseMediaType(contentType)\n\tisJSON := strings.Contains(mediaType, \"application/json\") || strings.HasSuffix(mediaType, \"+json\")\n\tif !isJSON {\n\t\tswitch dst := cfg.ResponseBodyInto.(type) {\n\t\tcase *string:\n\t\t\t*dst = string(contents)\n\t\tcase **string:\n\t\t\ttmp := string(contents)\n\t\t\t*dst = &tmp\n\t\tcase *[]byte:\n\t\t\t*dst = contents\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"expected destination type of 'string' or '[]byte' for responses with content-type '%s' that is not 'application/json'\", contentType)\n\t\t}\n\t\treturn nil\n\t}\n\n\tswitch dst := cfg.ResponseBodyInto.(type) {\n\t// If the response happens to be a byte array, deserialize the body as-is.\n\tcase *[]byte:\n\t\t*dst = contents\n\tdefault:\n\t\terr = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error parsing response json: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc ExecuteNewRequest(ctx context.Context, method string, u string, body any, dst any, opts ...RequestOption) error {\n\tcfg, err := NewRequestConfig(ctx, method, u, body, dst, opts...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn cfg.Execute()\n}\n\nfunc (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig {\n\tif cfg == nil {\n\t\treturn nil\n\t}\n\treq := cfg.Request.Clone(ctx)\n\tvar err error\n\tif req.Body != nil {\n\t\treq.Body, err = req.GetBody()\n\t}\n\tif err != nil {\n\t\treturn nil\n\t}\n\tnew := &RequestConfig{\n\t\tMaxRetries:     cfg.MaxRetries,\n\t\tRequestTimeout: cfg.RequestTimeout,\n\t\tContext:        ctx,\n\t\tRequest:        req,\n\t\tBaseURL:        cfg.BaseURL,\n\t\tHTTPClient:     cfg.HTTPClient,\n\t\tMiddlewares:    cfg.Middlewares,\n\t\tAPIKey:         cfg.APIKey,\n\t\tAuthToken:      cfg.AuthToken,\n\t}\n\n\treturn new\n}\n\nfunc (cfg *RequestConfig) Apply(opts ...RequestOption) error {\n\tfor _, opt := range opts {\n\t\terr := opt.Apply(cfg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\n// PreRequestOptions is used to collect all the options which need to be known before\n// a call to [RequestConfig.ExecuteNewRequest], such as path parameters\n// or global defaults.\n// PreRequestOptions will return a [RequestConfig] with the options applied.\n//\n// Only request option functions of type [PreRequestOptionFunc] are applied.\nfunc PreRequestOptions(opts ...RequestOption) (RequestConfig, error) {\n\tcfg := RequestConfig{}\n\tfor _, opt := range opts {\n\t\tif opt, ok := opt.(PreRequestOptionFunc); ok {\n\t\t\terr := opt.Apply(&cfg)\n\t\t\tif err != nil {\n\t\t\t\treturn cfg, err\n\t\t\t}\n\t\t}\n\t}\n\treturn cfg, nil\n}\n\n// WithDefaultBaseURL returns a RequestOption that sets the client's default Base URL.\n// This is always overridden by setting a base URL with WithBaseURL.\n// WithBaseURL should be used instead of WithDefaultBaseURL except in internal code.\nfunc WithDefaultBaseURL(baseURL string) RequestOption {\n\tu, err := url.Parse(baseURL)\n\treturn RequestOptionFunc(func(r *RequestConfig) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tr.DefaultBaseURL = u\n\t\treturn nil\n\t})\n}\n"
  },
  {
    "path": "internal/requestconfig/requestconfig_test.go",
    "content": "package requestconfig\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"net/url\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apierror\"\n\t\"github.com/stretchr/testify/assert\"\n\t\"github.com/stretchr/testify/require\"\n)\n\n// mockBaseURL is a helper function to create a URL for testing\nfunc mockBaseURL(server *httptest.Server) *url.URL {\n\tu, _ := url.Parse(server.URL)\n\treturn u\n}\n\n// TestErrorWithRequestID tests that RequestID is properly extracted from response headers\n// and included in the Error struct when API errors occur\nfunc TestErrorWithRequestID(t *testing.T) {\n\t// Create a test server that simulates an API returning an error with request-id\n\tserver := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// Set the request-id header - using the same header name as in the code\n\t\tw.Header().Set(\"request-id\", \"req_123456789\")\n\t\t// Return a 400 error with error JSON\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(`{\"error\":{\"type\":\"invalid_request_error\",\"message\":\"Invalid request\"}}`))\n\t}))\n\tdefer server.Close()\n\n\t// Create a request to the test server\n\treq, err := http.NewRequest(\"GET\", \"/test\", nil)\n\trequire.NoError(t, err, \"Failed to create request\")\n\n\t// Create a RequestConfig with proper BaseURL\n\tcfg := &RequestConfig{\n\t\tContext:    context.Background(),\n\t\tRequest:    req,\n\t\tBaseURL:    mockBaseURL(server),\n\t\tHTTPClient: http.DefaultClient,\n\t}\n\n\t// Execute the request, which should return an error\n\terr = cfg.Execute()\n\trequire.Error(t, err, \"Expected an error, but got nil\")\n\n\t// The error should be of type *apierror.Error\n\tapiErr, ok := err.(*apierror.Error)\n\trequire.True(t, ok, \"Expected error of type *apierror.Error, got %T\", err)\n\n\t// Verify that RequestID field was properly set from the header\n\texpectedRequestID := \"req_123456789\"\n\tassert.Equal(t, expectedRequestID, apiErr.RequestID, \"Expected RequestID to be %s, got %s\", expectedRequestID, apiErr.RequestID)\n\n\t// Verify that the error message includes the RequestID\n\terrorMsg := apiErr.Error()\n\tassert.Contains(t, errorMsg, \"Request-ID: req_123456789\", \"Error message should contain request ID\")\n}\n"
  },
  {
    "path": "internal/testutil/golden.go",
    "content": "package testutil\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\t\"testing\"\n)\n\n// CompareGolden compares the given string with the golden file at path.\n// If UPDATE_GOLDEN=1, it overwrites the file with the provided contents.\nfunc CompareGolden(t *testing.T, goldenRelPath string, got []byte) {\n\tt.Helper()\n\tgoldenPath := filepath.FromSlash(goldenRelPath)\n\n\tif os.Getenv(\"UPDATE_GOLDEN\") == \"1\" {\n\t\tif err := os.MkdirAll(filepath.Dir(goldenPath), 0o755); err != nil {\n\t\t\tt.Fatalf(\"creating golden dir: %v\", err)\n\t\t}\n\t\tif err := os.WriteFile(goldenPath, got, 0o644); err != nil {\n\t\t\tt.Fatalf(\"writing golden: %v\", err)\n\t\t}\n\t\treturn\n\t}\n\n\twant, err := os.ReadFile(goldenPath)\n\tif err != nil {\n\t\tt.Fatalf(\"reading golden: %v\", err)\n\t}\n\tif string(want) != string(got) {\n\t\tt.Fatalf(\"golden mismatch for %s\\nwant:\\n%s\\n----\\ngot:\\n%s\", goldenRelPath, string(want), string(got))\n\t}\n}\n"
  },
  {
    "path": "internal/testutil/testutil.go",
    "content": "package testutil\n\nimport (\n\t\"net/http\"\n\t\"os\"\n\t\"strconv\"\n\t\"testing\"\n)\n\nfunc CheckTestServer(t *testing.T, url string) bool {\n\tif _, err := http.Get(url); err != nil {\n\t\tconst SKIP_MOCK_TESTS = \"SKIP_MOCK_TESTS\"\n\t\tif str, ok := os.LookupEnv(SKIP_MOCK_TESTS); ok {\n\t\t\tskip, err := strconv.ParseBool(str)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"strconv.ParseBool(os.LookupEnv(%s)) failed: %s\", SKIP_MOCK_TESTS, err)\n\t\t\t}\n\t\t\tif skip {\n\t\t\t\tt.Skip(\"The test will not run without a mock server running against your OpenAPI spec\")\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tt.Errorf(\"The test will not run without a mock server running against your OpenAPI spec. You can set the environment variable %s to true to skip running any tests that require the mock server\", SKIP_MOCK_TESTS)\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"
  },
  {
    "path": "internal/testutil/vcr.go",
    "content": "package testutil\n\nimport (\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"testing\"\n\n\t\"github.com/dnaeon/go-vcr/recorder\"\n)\n\n// NewVCRHTTPClient creates an *http.Client wired to a go-vcr recorder.\n// Cassette files are stored under testdata/cassettes.\n// If ANTHROPIC_LIVE=1, the recorder runs in recording mode; otherwise replay-only.\nfunc NewVCRHTTPClient(t *testing.T, cassetteName string) (*http.Client, *recorder.Recorder) {\n\tt.Helper()\n\n\tmode := recorder.ModeReplaying\n\tif os.Getenv(\"ANTHROPIC_LIVE\") == \"1\" {\n\t\tmode = recorder.ModeRecording\n\t}\n\n\t// Let go-vcr handle the .yaml extension to avoid accidental double suffixes\n\tcassettePath := filepath.Join(\"testdata\", \"cassettes\", cassetteName)\n\tr, err := recorder.NewAsMode(cassettePath, mode, nil)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create recorder: %v\", err)\n\t}\n\n\tt.Cleanup(func() {\n\t\t_ = r.Stop()\n\t})\n\n\thttpClient := &http.Client{Transport: r}\n\treturn httpClient, r\n}\n"
  },
  {
    "path": "internal/version.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage internal\n\nconst PackageVersion = \"1.27.1\" // x-release-please-version\n"
  },
  {
    "path": "lib/.keep",
    "content": "File generated from our OpenAPI spec by Stainless.\n\nThis directory can be used to store custom files to expand the SDK.\nIt is ignored by Stainless code generation and its content (other than this keep file) won't be touched."
  },
  {
    "path": "message.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"net/http\"\n\t\"reflect\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/paramutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/ssestream\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n\t\"github.com/tidwall/gjson\"\n)\n\n// MessageService contains methods and other services that help with interacting\n// with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewMessageService] method instead.\ntype MessageService struct {\n\tOptions []option.RequestOption\n\tBatches MessageBatchService\n}\n\n// NewMessageService generates a new service that applies the given options to each\n// request. These options are applied after the parent client's options (if there\n// is one), and before any request-specific options.\nfunc NewMessageService(opts ...option.RequestOption) (r MessageService) {\n\tr = MessageService{}\n\tr.Options = opts\n\tr.Batches = NewMessageBatchService(opts...)\n\treturn\n}\n\n// Send a structured list of input messages with text and/or image content, and the\n// model will generate the next message in the conversation.\n//\n// The Messages API can be used for either single queries or stateless multi-turn\n// conversations.\n//\n// Learn more about the Messages API in our\n// [user guide](https://docs.claude.com/en/docs/initial-setup)\n//\n// Note: If you choose to set a timeout for this request, we recommend 10 minutes.\nfunc (r *MessageService) New(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (res *Message, err error) {\n\topts = slices.Concat(r.Options, opts)\n\n\t// For non-streaming requests, calculate the appropriate timeout based on maxTokens\n\t// and check against model-specific limits\n\ttimeout, timeoutErr := CalculateNonStreamingTimeout(int(body.MaxTokens), body.Model, opts)\n\tif timeoutErr != nil {\n\t\treturn nil, timeoutErr\n\t}\n\topts = append(opts, option.WithRequestTimeout(timeout))\n\n\tpath := \"v1/messages\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)\n\treturn res, err\n}\n\n// Send a structured list of input messages with text and/or image content, and the\n// model will generate the next message in the conversation.\n//\n// The Messages API can be used for either single queries or stateless multi-turn\n// conversations.\n//\n// Learn more about the Messages API in our\n// [user guide](https://docs.claude.com/en/docs/initial-setup)\n//\n// Note: If you choose to set a timeout for this request, we recommend 10 minutes.\nfunc (r *MessageService) NewStreaming(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[MessageStreamEventUnion]) {\n\tvar (\n\t\traw *http.Response\n\t\terr error\n\t)\n\topts = slices.Concat(r.Options, opts)\n\topts = append(opts, option.WithJSONSet(\"stream\", true))\n\tpath := \"v1/messages\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)\n\treturn ssestream.NewStream[MessageStreamEventUnion](ssestream.NewDecoder(raw), err)\n}\n\n// Count the number of tokens in a Message.\n//\n// The Token Count API can be used to count the number of tokens in a Message,\n// including tools, images, and documents, without creating it.\n//\n// Learn more about token counting in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)\nfunc (r *MessageService) CountTokens(ctx context.Context, body MessageCountTokensParams, opts ...option.RequestOption) (res *MessageTokensCount, err error) {\n\topts = slices.Concat(r.Options, opts)\n\tpath := \"v1/messages/count_tokens\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)\n\treturn res, err\n}\n\n// The properties Data, MediaType, Type are required.\ntype Base64ImageSourceParam struct {\n\tData string `json:\"data\" api:\"required\" format:\"byte\"`\n\t// Any of \"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\".\n\tMediaType Base64ImageSourceMediaType `json:\"media_type,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"base64\".\n\tType constant.Base64 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r Base64ImageSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow Base64ImageSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *Base64ImageSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype Base64ImageSourceMediaType string\n\nconst (\n\tBase64ImageSourceMediaTypeImageJPEG Base64ImageSourceMediaType = \"image/jpeg\"\n\tBase64ImageSourceMediaTypeImagePNG  Base64ImageSourceMediaType = \"image/png\"\n\tBase64ImageSourceMediaTypeImageGIF  Base64ImageSourceMediaType = \"image/gif\"\n\tBase64ImageSourceMediaTypeImageWebP Base64ImageSourceMediaType = \"image/webp\"\n)\n\ntype Base64PDFSource struct {\n\tData      string                  `json:\"data\" api:\"required\" format:\"byte\"`\n\tMediaType constant.ApplicationPDF `json:\"media_type\" api:\"required\"`\n\tType      constant.Base64         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tMediaType   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Base64PDFSource) RawJSON() string { return r.JSON.raw }\nfunc (r *Base64PDFSource) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this Base64PDFSource to a Base64PDFSourceParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// Base64PDFSourceParam.Overrides()\nfunc (r Base64PDFSource) ToParam() Base64PDFSourceParam {\n\treturn param.Override[Base64PDFSourceParam](json.RawMessage(r.RawJSON()))\n}\n\n// The properties Data, MediaType, Type are required.\ntype Base64PDFSourceParam struct {\n\tData string `json:\"data\" api:\"required\" format:\"byte\"`\n\t// This field can be elided, and will marshal its zero value as \"application/pdf\".\n\tMediaType constant.ApplicationPDF `json:\"media_type\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"base64\".\n\tType constant.Base64 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r Base64PDFSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow Base64PDFSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *Base64PDFSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BashCodeExecutionOutputBlock struct {\n\tFileID string                           `json:\"file_id\" api:\"required\"`\n\tType   constant.BashCodeExecutionOutput `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tFileID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BashCodeExecutionOutputBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BashCodeExecutionOutputBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties FileID, Type are required.\ntype BashCodeExecutionOutputBlockParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_output\".\n\tType constant.BashCodeExecutionOutput `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BashCodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BashCodeExecutionOutputBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BashCodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BashCodeExecutionResultBlock struct {\n\tContent    []BashCodeExecutionOutputBlock   `json:\"content\" api:\"required\"`\n\tReturnCode int64                            `json:\"return_code\" api:\"required\"`\n\tStderr     string                           `json:\"stderr\" api:\"required\"`\n\tStdout     string                           `json:\"stdout\" api:\"required\"`\n\tType       constant.BashCodeExecutionResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tReturnCode  respjson.Field\n\t\tStderr      respjson.Field\n\t\tStdout      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BashCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BashCodeExecutionResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ReturnCode, Stderr, Stdout, Type are required.\ntype BashCodeExecutionResultBlockParam struct {\n\tContent    []BashCodeExecutionOutputBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tReturnCode int64                               `json:\"return_code\" api:\"required\"`\n\tStderr     string                              `json:\"stderr\" api:\"required\"`\n\tStdout     string                              `json:\"stdout\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_result\".\n\tType constant.BashCodeExecutionResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BashCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BashCodeExecutionResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BashCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BashCodeExecutionToolResultBlock struct {\n\tContent   BashCodeExecutionToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                       `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.BashCodeExecutionToolResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BashCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *BashCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// BashCodeExecutionToolResultBlockContentUnion contains all possible properties\n// and values from [BashCodeExecutionToolResultError],\n// [BashCodeExecutionResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype BashCodeExecutionToolResultBlockContentUnion struct {\n\t// This field is from variant [BashCodeExecutionToolResultError].\n\tErrorCode BashCodeExecutionToolResultErrorCode `json:\"error_code\"`\n\tType      string                               `json:\"type\"`\n\t// This field is from variant [BashCodeExecutionResultBlock].\n\tContent []BashCodeExecutionOutputBlock `json:\"content\"`\n\t// This field is from variant [BashCodeExecutionResultBlock].\n\tReturnCode int64 `json:\"return_code\"`\n\t// This field is from variant [BashCodeExecutionResultBlock].\n\tStderr string `json:\"stderr\"`\n\t// This field is from variant [BashCodeExecutionResultBlock].\n\tStdout string `json:\"stdout\"`\n\tJSON   struct {\n\t\tErrorCode  respjson.Field\n\t\tType       respjson.Field\n\t\tContent    respjson.Field\n\t\tReturnCode respjson.Field\n\t\tStderr     respjson.Field\n\t\tStdout     respjson.Field\n\t\traw        string\n\t} `json:\"-\"`\n}\n\nfunc (u BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError() (v BashCodeExecutionToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock() (v BashCodeExecutionResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u BashCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *BashCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype BashCodeExecutionToolResultBlockParam struct {\n\tContent   BashCodeExecutionToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                            `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_tool_result\".\n\tType constant.BashCodeExecutionToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BashCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BashCodeExecutionToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BashCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype BashCodeExecutionToolResultBlockParamContentUnion struct {\n\tOfRequestBashCodeExecutionToolResultError *BashCodeExecutionToolResultErrorParam `json:\",omitzero,inline\"`\n\tOfRequestBashCodeExecutionResultBlock     *BashCodeExecutionResultBlockParam     `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestBashCodeExecutionToolResultError, u.OfRequestBashCodeExecutionResultBlock)\n}\nfunc (u *BashCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *BashCodeExecutionToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestBashCodeExecutionToolResultError) {\n\t\treturn u.OfRequestBashCodeExecutionToolResultError\n\t} else if !param.IsOmitted(u.OfRequestBashCodeExecutionResultBlock) {\n\t\treturn u.OfRequestBashCodeExecutionResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestBashCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) GetContent() []BashCodeExecutionOutputBlockParam {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64 {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.ReturnCode\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) GetStderr() *string {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.Stderr\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) GetStdout() *string {\n\tif vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.Stdout\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u BashCodeExecutionToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestBashCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestBashCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype BashCodeExecutionToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"output_file_too_large\".\n\tErrorCode BashCodeExecutionToolResultErrorCode      `json:\"error_code\" api:\"required\"`\n\tType      constant.BashCodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BashCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *BashCodeExecutionToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype BashCodeExecutionToolResultErrorCode string\n\nconst (\n\tBashCodeExecutionToolResultErrorCodeInvalidToolInput      BashCodeExecutionToolResultErrorCode = \"invalid_tool_input\"\n\tBashCodeExecutionToolResultErrorCodeUnavailable           BashCodeExecutionToolResultErrorCode = \"unavailable\"\n\tBashCodeExecutionToolResultErrorCodeTooManyRequests       BashCodeExecutionToolResultErrorCode = \"too_many_requests\"\n\tBashCodeExecutionToolResultErrorCodeExecutionTimeExceeded BashCodeExecutionToolResultErrorCode = \"execution_time_exceeded\"\n\tBashCodeExecutionToolResultErrorCodeOutputFileTooLarge    BashCodeExecutionToolResultErrorCode = \"output_file_too_large\"\n)\n\n// The properties ErrorCode, Type are required.\ntype BashCodeExecutionToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"output_file_too_large\".\n\tErrorCode BashCodeExecutionToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"bash_code_execution_tool_result_error\".\n\tType constant.BashCodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r BashCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow BashCodeExecutionToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *BashCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc NewCacheControlEphemeralParam() CacheControlEphemeralParam {\n\treturn CacheControlEphemeralParam{\n\t\tType: \"ephemeral\",\n\t}\n}\n\n// This struct has a constant value, construct it with\n// [NewCacheControlEphemeralParam].\ntype CacheControlEphemeralParam struct {\n\t// The time-to-live for the cache control breakpoint.\n\t//\n\t// This may be one the following values:\n\t//\n\t// - `5m`: 5 minutes\n\t// - `1h`: 1 hour\n\t//\n\t// Defaults to `5m`.\n\t//\n\t// Any of \"5m\", \"1h\".\n\tTTL  CacheControlEphemeralTTL `json:\"ttl,omitzero\"`\n\tType constant.Ephemeral       `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CacheControlEphemeralParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CacheControlEphemeralParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CacheControlEphemeralParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The time-to-live for the cache control breakpoint.\n//\n// This may be one the following values:\n//\n// - `5m`: 5 minutes\n// - `1h`: 1 hour\n//\n// Defaults to `5m`.\ntype CacheControlEphemeralTTL string\n\nconst (\n\tCacheControlEphemeralTTLTTL5m CacheControlEphemeralTTL = \"5m\"\n\tCacheControlEphemeralTTLTTL1h CacheControlEphemeralTTL = \"1h\"\n)\n\ntype CacheCreation struct {\n\t// The number of input tokens used to create the 1 hour cache entry.\n\tEphemeral1hInputTokens int64 `json:\"ephemeral_1h_input_tokens\" api:\"required\"`\n\t// The number of input tokens used to create the 5 minute cache entry.\n\tEphemeral5mInputTokens int64 `json:\"ephemeral_5m_input_tokens\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tEphemeral1hInputTokens respjson.Field\n\t\tEphemeral5mInputTokens respjson.Field\n\t\tExtraFields            map[string]respjson.Field\n\t\traw                    string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CacheCreation) RawJSON() string { return r.JSON.raw }\nfunc (r *CacheCreation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationCharLocation struct {\n\tCitedText      string                `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex  int64                 `json:\"document_index\" api:\"required\"`\n\tDocumentTitle  string                `json:\"document_title\" api:\"required\"`\n\tEndCharIndex   int64                 `json:\"end_char_index\" api:\"required\"`\n\tFileID         string                `json:\"file_id\" api:\"required\"`\n\tStartCharIndex int64                 `json:\"start_char_index\" api:\"required\"`\n\tType           constant.CharLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText      respjson.Field\n\t\tDocumentIndex  respjson.Field\n\t\tDocumentTitle  respjson.Field\n\t\tEndCharIndex   respjson.Field\n\t\tFileID         respjson.Field\n\t\tStartCharIndex respjson.Field\n\t\tType           respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationCharLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationCharLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, DocumentIndex, DocumentTitle, EndCharIndex,\n// StartCharIndex, Type are required.\ntype CitationCharLocationParam struct {\n\tDocumentTitle  param.Opt[string] `json:\"document_title,omitzero\" api:\"required\"`\n\tCitedText      string            `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex  int64             `json:\"document_index\" api:\"required\"`\n\tEndCharIndex   int64             `json:\"end_char_index\" api:\"required\"`\n\tStartCharIndex int64             `json:\"start_char_index\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"char_location\".\n\tType constant.CharLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CitationCharLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CitationCharLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CitationCharLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationContentBlockLocation struct {\n\tCitedText       string                        `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64                         `json:\"document_index\" api:\"required\"`\n\tDocumentTitle   string                        `json:\"document_title\" api:\"required\"`\n\tEndBlockIndex   int64                         `json:\"end_block_index\" api:\"required\"`\n\tFileID          string                        `json:\"file_id\" api:\"required\"`\n\tStartBlockIndex int64                         `json:\"start_block_index\" api:\"required\"`\n\tType            constant.ContentBlockLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText       respjson.Field\n\t\tDocumentIndex   respjson.Field\n\t\tDocumentTitle   respjson.Field\n\t\tEndBlockIndex   respjson.Field\n\t\tFileID          respjson.Field\n\t\tStartBlockIndex respjson.Field\n\t\tType            respjson.Field\n\t\tExtraFields     map[string]respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationContentBlockLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationContentBlockLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, DocumentIndex, DocumentTitle, EndBlockIndex,\n// StartBlockIndex, Type are required.\ntype CitationContentBlockLocationParam struct {\n\tDocumentTitle   param.Opt[string] `json:\"document_title,omitzero\" api:\"required\"`\n\tCitedText       string            `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64             `json:\"document_index\" api:\"required\"`\n\tEndBlockIndex   int64             `json:\"end_block_index\" api:\"required\"`\n\tStartBlockIndex int64             `json:\"start_block_index\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"content_block_location\".\n\tType constant.ContentBlockLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CitationContentBlockLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CitationContentBlockLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CitationContentBlockLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationPageLocation struct {\n\tCitedText       string                `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64                 `json:\"document_index\" api:\"required\"`\n\tDocumentTitle   string                `json:\"document_title\" api:\"required\"`\n\tEndPageNumber   int64                 `json:\"end_page_number\" api:\"required\"`\n\tFileID          string                `json:\"file_id\" api:\"required\"`\n\tStartPageNumber int64                 `json:\"start_page_number\" api:\"required\"`\n\tType            constant.PageLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText       respjson.Field\n\t\tDocumentIndex   respjson.Field\n\t\tDocumentTitle   respjson.Field\n\t\tEndPageNumber   respjson.Field\n\t\tFileID          respjson.Field\n\t\tStartPageNumber respjson.Field\n\t\tType            respjson.Field\n\t\tExtraFields     map[string]respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationPageLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationPageLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, DocumentIndex, DocumentTitle, EndPageNumber,\n// StartPageNumber, Type are required.\ntype CitationPageLocationParam struct {\n\tDocumentTitle   param.Opt[string] `json:\"document_title,omitzero\" api:\"required\"`\n\tCitedText       string            `json:\"cited_text\" api:\"required\"`\n\tDocumentIndex   int64             `json:\"document_index\" api:\"required\"`\n\tEndPageNumber   int64             `json:\"end_page_number\" api:\"required\"`\n\tStartPageNumber int64             `json:\"start_page_number\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"page_location\".\n\tType constant.PageLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CitationPageLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CitationPageLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CitationPageLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, EndBlockIndex, SearchResultIndex, Source,\n// StartBlockIndex, Title, Type are required.\ntype CitationSearchResultLocationParam struct {\n\tTitle             param.Opt[string] `json:\"title,omitzero\" api:\"required\"`\n\tCitedText         string            `json:\"cited_text\" api:\"required\"`\n\tEndBlockIndex     int64             `json:\"end_block_index\" api:\"required\"`\n\tSearchResultIndex int64             `json:\"search_result_index\" api:\"required\"`\n\tSource            string            `json:\"source\" api:\"required\"`\n\tStartBlockIndex   int64             `json:\"start_block_index\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"search_result_location\".\n\tType constant.SearchResultLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CitationSearchResultLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CitationSearchResultLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CitationSearchResultLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CitedText, EncryptedIndex, Title, Type, URL are required.\ntype CitationWebSearchResultLocationParam struct {\n\tTitle          param.Opt[string] `json:\"title,omitzero\" api:\"required\"`\n\tCitedText      string            `json:\"cited_text\" api:\"required\"`\n\tEncryptedIndex string            `json:\"encrypted_index\" api:\"required\"`\n\tURL            string            `json:\"url\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_result_location\".\n\tType constant.WebSearchResultLocation `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CitationWebSearchResultLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CitationWebSearchResultLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CitationWebSearchResultLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationsConfig struct {\n\tEnabled bool `json:\"enabled\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tEnabled     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationsConfig) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationsConfig) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationsConfigParam struct {\n\tEnabled param.Opt[bool] `json:\"enabled,omitzero\"`\n\tparamObj\n}\n\nfunc (r CitationsConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CitationsConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CitationsConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationsDelta struct {\n\tCitation CitationsDeltaCitationUnion `json:\"citation\" api:\"required\"`\n\tType     constant.CitationsDelta     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitation    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationsDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationsDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// CitationsDeltaCitationUnion contains all possible properties and values from\n// [CitationCharLocation], [CitationPageLocation], [CitationContentBlockLocation],\n// [CitationsWebSearchResultLocation], [CitationsSearchResultLocation].\n//\n// Use the [CitationsDeltaCitationUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype CitationsDeltaCitationUnion struct {\n\tCitedText     string `json:\"cited_text\"`\n\tDocumentIndex int64  `json:\"document_index\"`\n\tDocumentTitle string `json:\"document_title\"`\n\t// This field is from variant [CitationCharLocation].\n\tEndCharIndex int64  `json:\"end_char_index\"`\n\tFileID       string `json:\"file_id\"`\n\t// This field is from variant [CitationCharLocation].\n\tStartCharIndex int64 `json:\"start_char_index\"`\n\t// Any of \"char_location\", \"page_location\", \"content_block_location\",\n\t// \"web_search_result_location\", \"search_result_location\".\n\tType string `json:\"type\"`\n\t// This field is from variant [CitationPageLocation].\n\tEndPageNumber int64 `json:\"end_page_number\"`\n\t// This field is from variant [CitationPageLocation].\n\tStartPageNumber int64 `json:\"start_page_number\"`\n\tEndBlockIndex   int64 `json:\"end_block_index\"`\n\tStartBlockIndex int64 `json:\"start_block_index\"`\n\t// This field is from variant [CitationsWebSearchResultLocation].\n\tEncryptedIndex string `json:\"encrypted_index\"`\n\tTitle          string `json:\"title\"`\n\t// This field is from variant [CitationsWebSearchResultLocation].\n\tURL string `json:\"url\"`\n\t// This field is from variant [CitationsSearchResultLocation].\n\tSearchResultIndex int64 `json:\"search_result_index\"`\n\t// This field is from variant [CitationsSearchResultLocation].\n\tSource string `json:\"source\"`\n\tJSON   struct {\n\t\tCitedText         respjson.Field\n\t\tDocumentIndex     respjson.Field\n\t\tDocumentTitle     respjson.Field\n\t\tEndCharIndex      respjson.Field\n\t\tFileID            respjson.Field\n\t\tStartCharIndex    respjson.Field\n\t\tType              respjson.Field\n\t\tEndPageNumber     respjson.Field\n\t\tStartPageNumber   respjson.Field\n\t\tEndBlockIndex     respjson.Field\n\t\tStartBlockIndex   respjson.Field\n\t\tEncryptedIndex    respjson.Field\n\t\tTitle             respjson.Field\n\t\tURL               respjson.Field\n\t\tSearchResultIndex respjson.Field\n\t\tSource            respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// anyCitationsDeltaCitation is implemented by each variant of\n// [CitationsDeltaCitationUnion] to add type safety for the return type of\n// [CitationsDeltaCitationUnion.AsAny]\ntype anyCitationsDeltaCitation interface {\n\timplCitationsDeltaCitationUnion()\n}\n\nfunc (CitationCharLocation) implCitationsDeltaCitationUnion()             {}\nfunc (CitationPageLocation) implCitationsDeltaCitationUnion()             {}\nfunc (CitationContentBlockLocation) implCitationsDeltaCitationUnion()     {}\nfunc (CitationsWebSearchResultLocation) implCitationsDeltaCitationUnion() {}\nfunc (CitationsSearchResultLocation) implCitationsDeltaCitationUnion()    {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := CitationsDeltaCitationUnion.AsAny().(type) {\n//\tcase anthropic.CitationCharLocation:\n//\tcase anthropic.CitationPageLocation:\n//\tcase anthropic.CitationContentBlockLocation:\n//\tcase anthropic.CitationsWebSearchResultLocation:\n//\tcase anthropic.CitationsSearchResultLocation:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u CitationsDeltaCitationUnion) AsAny() anyCitationsDeltaCitation {\n\tswitch u.Type {\n\tcase \"char_location\":\n\t\treturn u.AsCharLocation()\n\tcase \"page_location\":\n\t\treturn u.AsPageLocation()\n\tcase \"content_block_location\":\n\t\treturn u.AsContentBlockLocation()\n\tcase \"web_search_result_location\":\n\t\treturn u.AsWebSearchResultLocation()\n\tcase \"search_result_location\":\n\t\treturn u.AsSearchResultLocation()\n\t}\n\treturn nil\n}\n\nfunc (u CitationsDeltaCitationUnion) AsCharLocation() (v CitationCharLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u CitationsDeltaCitationUnion) AsPageLocation() (v CitationPageLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u CitationsDeltaCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u CitationsDeltaCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u CitationsDeltaCitationUnion) AsSearchResultLocation() (v CitationsSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u CitationsDeltaCitationUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *CitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationsSearchResultLocation struct {\n\tCitedText         string                        `json:\"cited_text\" api:\"required\"`\n\tEndBlockIndex     int64                         `json:\"end_block_index\" api:\"required\"`\n\tSearchResultIndex int64                         `json:\"search_result_index\" api:\"required\"`\n\tSource            string                        `json:\"source\" api:\"required\"`\n\tStartBlockIndex   int64                         `json:\"start_block_index\" api:\"required\"`\n\tTitle             string                        `json:\"title\" api:\"required\"`\n\tType              constant.SearchResultLocation `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText         respjson.Field\n\t\tEndBlockIndex     respjson.Field\n\t\tSearchResultIndex respjson.Field\n\t\tSource            respjson.Field\n\t\tStartBlockIndex   respjson.Field\n\t\tTitle             respjson.Field\n\t\tType              respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationsSearchResultLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationsSearchResultLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CitationsWebSearchResultLocation struct {\n\tCitedText      string                           `json:\"cited_text\" api:\"required\"`\n\tEncryptedIndex string                           `json:\"encrypted_index\" api:\"required\"`\n\tTitle          string                           `json:\"title\" api:\"required\"`\n\tType           constant.WebSearchResultLocation `json:\"type\" api:\"required\"`\n\tURL            string                           `json:\"url\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitedText      respjson.Field\n\t\tEncryptedIndex respjson.Field\n\t\tTitle          respjson.Field\n\t\tType           respjson.Field\n\t\tURL            respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CitationsWebSearchResultLocation) RawJSON() string { return r.JSON.raw }\nfunc (r *CitationsWebSearchResultLocation) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CodeExecutionOutputBlock struct {\n\tFileID string                       `json:\"file_id\" api:\"required\"`\n\tType   constant.CodeExecutionOutput `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tFileID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CodeExecutionOutputBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *CodeExecutionOutputBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties FileID, Type are required.\ntype CodeExecutionOutputBlockParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_output\".\n\tType constant.CodeExecutionOutput `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionOutputBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CodeExecutionResultBlock struct {\n\tContent    []CodeExecutionOutputBlock   `json:\"content\" api:\"required\"`\n\tReturnCode int64                        `json:\"return_code\" api:\"required\"`\n\tStderr     string                       `json:\"stderr\" api:\"required\"`\n\tStdout     string                       `json:\"stdout\" api:\"required\"`\n\tType       constant.CodeExecutionResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tReturnCode  respjson.Field\n\t\tStderr      respjson.Field\n\t\tStdout      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CodeExecutionResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *CodeExecutionResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ReturnCode, Stderr, Stdout, Type are required.\ntype CodeExecutionResultBlockParam struct {\n\tContent    []CodeExecutionOutputBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tReturnCode int64                           `json:\"return_code\" api:\"required\"`\n\tStderr     string                          `json:\"stderr\" api:\"required\"`\n\tStdout     string                          `json:\"stdout\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_result\".\n\tType constant.CodeExecutionResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype CodeExecutionTool20250522Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"code_execution\".\n\tName constant.CodeExecution `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20250522\".\n\tType constant.CodeExecution20250522 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionTool20250522Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionTool20250522Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionTool20250522Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype CodeExecutionTool20250825Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"code_execution\".\n\tName constant.CodeExecution `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20250825\".\n\tType constant.CodeExecution20250825 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionTool20250825Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionTool20250825Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionTool20250825Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Code execution tool with REPL state persistence (daemon mode + gVisor\n// checkpoint).\n//\n// The properties Name, Type are required.\ntype CodeExecutionTool20260120Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"code_execution\".\n\tName constant.CodeExecution `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20260120\".\n\tType constant.CodeExecution20260120 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionTool20260120Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionTool20260120Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionTool20260120Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CodeExecutionToolResultBlock struct {\n\t// Code execution result with encrypted stdout for PFC + web_search results.\n\tContent   CodeExecutionToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                   `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.CodeExecutionToolResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *CodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// CodeExecutionToolResultBlockContentUnion contains all possible properties and\n// values from [CodeExecutionToolResultError], [CodeExecutionResultBlock],\n// [EncryptedCodeExecutionResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype CodeExecutionToolResultBlockContentUnion struct {\n\t// This field is from variant [CodeExecutionToolResultError].\n\tErrorCode  CodeExecutionToolResultErrorCode `json:\"error_code\"`\n\tType       string                           `json:\"type\"`\n\tContent    []CodeExecutionOutputBlock       `json:\"content\"`\n\tReturnCode int64                            `json:\"return_code\"`\n\tStderr     string                           `json:\"stderr\"`\n\t// This field is from variant [CodeExecutionResultBlock].\n\tStdout string `json:\"stdout\"`\n\t// This field is from variant [EncryptedCodeExecutionResultBlock].\n\tEncryptedStdout string `json:\"encrypted_stdout\"`\n\tJSON            struct {\n\t\tErrorCode       respjson.Field\n\t\tType            respjson.Field\n\t\tContent         respjson.Field\n\t\tReturnCode      respjson.Field\n\t\tStderr          respjson.Field\n\t\tStdout          respjson.Field\n\t\tEncryptedStdout respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\nfunc (u CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v CodeExecutionToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v CodeExecutionResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u CodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock() (v EncryptedCodeExecutionResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u CodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *CodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype CodeExecutionToolResultBlockParam struct {\n\t// Code execution result with encrypted stdout for PFC + web_search results.\n\tContent   CodeExecutionToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                        `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_tool_result\".\n\tType constant.CodeExecutionToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc CodeExecutionToolResultBlockParamContentOfRequestCodeExecutionToolResultError(errorCode CodeExecutionToolResultErrorCode) CodeExecutionToolResultBlockParamContentUnion {\n\tvar variant CodeExecutionToolResultErrorParam\n\tvariant.ErrorCode = errorCode\n\treturn CodeExecutionToolResultBlockParamContentUnion{OfRequestCodeExecutionToolResultError: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype CodeExecutionToolResultBlockParamContentUnion struct {\n\tOfRequestCodeExecutionToolResultError      *CodeExecutionToolResultErrorParam      `json:\",omitzero,inline\"`\n\tOfRequestCodeExecutionResultBlock          *CodeExecutionResultBlockParam          `json:\",omitzero,inline\"`\n\tOfRequestEncryptedCodeExecutionResultBlock *EncryptedCodeExecutionResultBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u CodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestCodeExecutionToolResultError, u.OfRequestCodeExecutionResultBlock, u.OfRequestEncryptedCodeExecutionResultBlock)\n}\nfunc (u *CodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *CodeExecutionToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestCodeExecutionToolResultError) {\n\t\treturn u.OfRequestCodeExecutionToolResultError\n\t} else if !param.IsOmitted(u.OfRequestCodeExecutionResultBlock) {\n\t\treturn u.OfRequestCodeExecutionResultBlock\n\t} else if !param.IsOmitted(u.OfRequestEncryptedCodeExecutionResultBlock) {\n\t\treturn u.OfRequestEncryptedCodeExecutionResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetStdout() *string {\n\tif vt := u.OfRequestCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.Stdout\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetEncryptedStdout() *string {\n\tif vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn &vt.EncryptedStdout\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64 {\n\tif vt := u.OfRequestCodeExecutionResultBlock; vt != nil {\n\t\treturn (*int64)(&vt.ReturnCode)\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn (*int64)(&vt.ReturnCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetStderr() *string {\n\tif vt := u.OfRequestCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Stderr)\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Stderr)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's Content property, if present.\nfunc (u CodeExecutionToolResultBlockParamContentUnion) GetContent() []CodeExecutionOutputBlockParam {\n\tif vt := u.OfRequestCodeExecutionResultBlock; vt != nil {\n\t\treturn vt.Content\n\t} else if vt := u.OfRequestEncryptedCodeExecutionResultBlock; vt != nil {\n\t\treturn vt.Content\n\t}\n\treturn nil\n}\n\ntype CodeExecutionToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode CodeExecutionToolResultErrorCode      `json:\"error_code\" api:\"required\"`\n\tType      constant.CodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CodeExecutionToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *CodeExecutionToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype CodeExecutionToolResultErrorCode string\n\nconst (\n\tCodeExecutionToolResultErrorCodeInvalidToolInput      CodeExecutionToolResultErrorCode = \"invalid_tool_input\"\n\tCodeExecutionToolResultErrorCodeUnavailable           CodeExecutionToolResultErrorCode = \"unavailable\"\n\tCodeExecutionToolResultErrorCodeTooManyRequests       CodeExecutionToolResultErrorCode = \"too_many_requests\"\n\tCodeExecutionToolResultErrorCodeExecutionTimeExceeded CodeExecutionToolResultErrorCode = \"execution_time_exceeded\"\n)\n\n// The properties ErrorCode, Type are required.\ntype CodeExecutionToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode CodeExecutionToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_tool_result_error\".\n\tType constant.CodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r CodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow CodeExecutionToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *CodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Information about the container used in the request (for the code execution\n// tool)\ntype Container struct {\n\t// Identifier for the container used in this request\n\tID string `json:\"id\" api:\"required\"`\n\t// The time at which the container will expire.\n\tExpiresAt time.Time `json:\"expires_at\" api:\"required\" format:\"date-time\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tExpiresAt   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Container) RawJSON() string { return r.JSON.raw }\nfunc (r *Container) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Response model for a file uploaded to the container.\ntype ContainerUploadBlock struct {\n\tFileID string                   `json:\"file_id\" api:\"required\"`\n\tType   constant.ContainerUpload `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tFileID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ContainerUploadBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ContainerUploadBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// A content block that represents a file to be uploaded to the container Files\n// uploaded via this block will be available in the container's input directory.\n//\n// The properties FileID, Type are required.\ntype ContainerUploadBlockParam struct {\n\tFileID string `json:\"file_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"container_upload\".\n\tType constant.ContainerUpload `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ContainerUploadBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ContainerUploadBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ContainerUploadBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockUnion contains all possible properties and values from [TextBlock],\n// [ThinkingBlock], [RedactedThinkingBlock], [ToolUseBlock], [ServerToolUseBlock],\n// [WebSearchToolResultBlock], [WebFetchToolResultBlock],\n// [CodeExecutionToolResultBlock], [BashCodeExecutionToolResultBlock],\n// [TextEditorCodeExecutionToolResultBlock], [ToolSearchToolResultBlock],\n// [ContainerUploadBlock].\n//\n// Use the [ContentBlockUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype ContentBlockUnion struct {\n\t// This field is from variant [TextBlock].\n\tCitations []TextCitationUnion `json:\"citations\"`\n\t// This field is from variant [TextBlock].\n\tText string `json:\"text\"`\n\t// Any of \"text\", \"thinking\", \"redacted_thinking\", \"tool_use\", \"server_tool_use\",\n\t// \"web_search_tool_result\", \"web_fetch_tool_result\", \"code_execution_tool_result\",\n\t// \"bash_code_execution_tool_result\", \"text_editor_code_execution_tool_result\",\n\t// \"tool_search_tool_result\", \"container_upload\".\n\tType string `json:\"type\"`\n\t// This field is from variant [ThinkingBlock].\n\tSignature string `json:\"signature\"`\n\t// This field is from variant [ThinkingBlock].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [RedactedThinkingBlock].\n\tData string `json:\"data\"`\n\tID   string `json:\"id\"`\n\t// necessary custom code modification\n\tInput json.RawMessage `json:\"input\"`\n\tName  string          `json:\"name\"`\n\t// This field is from variant [WebSearchToolResultBlock].\n\tContent WebSearchToolResultBlockContentUnion `json:\"content\"`\n\t// This field is from variant [WebSearchToolResultBlock].\n\tToolUseID string `json:\"tool_use_id\"`\n\tJSON      struct {\n\t\tCitations respjson.Field\n\t\tText      respjson.Field\n\t\tType      respjson.Field\n\t\tSignature respjson.Field\n\t\tThinking  respjson.Field\n\t\tData      respjson.Field\n\t\tID        respjson.Field\n\t\tCaller    respjson.Field\n\t\tInput     respjson.Field\n\t\tName      respjson.Field\n\t\tContent   respjson.Field\n\t\tToolUseID respjson.Field\n\t\tFileID    respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\n// anyContentBlock is implemented by each variant of [ContentBlockUnion] to add\n// type safety for the return type of [ContentBlockUnion.AsAny]\ntype anyContentBlock interface {\n\timplContentBlockUnion()\n\ttoParamUnion() ContentBlockParamUnion\n}\n\nfunc (TextBlock) implContentBlockUnion()                              {}\nfunc (ThinkingBlock) implContentBlockUnion()                          {}\nfunc (RedactedThinkingBlock) implContentBlockUnion()                  {}\nfunc (ToolUseBlock) implContentBlockUnion()                           {}\nfunc (ServerToolUseBlock) implContentBlockUnion()                     {}\nfunc (WebSearchToolResultBlock) implContentBlockUnion()               {}\nfunc (WebFetchToolResultBlock) implContentBlockUnion()                {}\nfunc (CodeExecutionToolResultBlock) implContentBlockUnion()           {}\nfunc (BashCodeExecutionToolResultBlock) implContentBlockUnion()       {}\nfunc (TextEditorCodeExecutionToolResultBlock) implContentBlockUnion() {}\nfunc (ToolSearchToolResultBlock) implContentBlockUnion()              {}\nfunc (ContainerUploadBlock) implContentBlockUnion()                   {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := ContentBlockUnion.AsAny().(type) {\n//\tcase anthropic.TextBlock:\n//\tcase anthropic.ThinkingBlock:\n//\tcase anthropic.RedactedThinkingBlock:\n//\tcase anthropic.ToolUseBlock:\n//\tcase anthropic.ServerToolUseBlock:\n//\tcase anthropic.WebSearchToolResultBlock:\n//\tcase anthropic.WebFetchToolResultBlock:\n//\tcase anthropic.CodeExecutionToolResultBlock:\n//\tcase anthropic.BashCodeExecutionToolResultBlock:\n//\tcase anthropic.TextEditorCodeExecutionToolResultBlock:\n//\tcase anthropic.ToolSearchToolResultBlock:\n//\tcase anthropic.ContainerUploadBlock:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u ContentBlockUnion) AsAny() anyContentBlock {\n\tswitch u.Type {\n\tcase \"text\":\n\t\treturn u.AsText()\n\tcase \"thinking\":\n\t\treturn u.AsThinking()\n\tcase \"redacted_thinking\":\n\t\treturn u.AsRedactedThinking()\n\tcase \"tool_use\":\n\t\treturn u.AsToolUse()\n\tcase \"server_tool_use\":\n\t\treturn u.AsServerToolUse()\n\tcase \"web_search_tool_result\":\n\t\treturn u.AsWebSearchToolResult()\n\tcase \"web_fetch_tool_result\":\n\t\treturn u.AsWebFetchToolResult()\n\tcase \"code_execution_tool_result\":\n\t\treturn u.AsCodeExecutionToolResult()\n\tcase \"bash_code_execution_tool_result\":\n\t\treturn u.AsBashCodeExecutionToolResult()\n\tcase \"text_editor_code_execution_tool_result\":\n\t\treturn u.AsTextEditorCodeExecutionToolResult()\n\tcase \"tool_search_tool_result\":\n\t\treturn u.AsToolSearchToolResult()\n\tcase \"container_upload\":\n\t\treturn u.AsContainerUpload()\n\t}\n\treturn nil\n}\n\nfunc (u ContentBlockUnion) AsText() (v TextBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsThinking() (v ThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsToolUse() (v ToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsWebFetchToolResult() (v WebFetchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsCodeExecutionToolResult() (v CodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsBashCodeExecutionToolResult() (v BashCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v TextEditorCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsToolSearchToolResult() (v ToolSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockUnion) AsContainerUpload() (v ContainerUploadBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u ContentBlockUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *ContentBlockUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockUnionCaller is an implicit subunion of [ContentBlockUnion].\n// ContentBlockUnionCaller provides convenient access to the sub-properties of the\n// union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [ContentBlockUnion].\ntype ContentBlockUnionCaller struct {\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\nfunc (r *ContentBlockUnionCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockUnionContent is an implicit subunion of [ContentBlockUnion].\n// ContentBlockUnionContent provides convenient access to the sub-properties of the\n// union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [ContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfWebSearchResultBlockArray]\ntype ContentBlockUnionContent struct {\n\t// This field will be present if the value is a [[]WebSearchResultBlock] instead of\n\t// an object.\n\tOfWebSearchResultBlockArray []WebSearchResultBlock `json:\",inline\"`\n\tErrorCode                   string                 `json:\"error_code\"`\n\tType                        string                 `json:\"type\"`\n\t// This field is a union of [DocumentBlock], [[]CodeExecutionOutputBlock],\n\t// [[]CodeExecutionOutputBlock], [[]BashCodeExecutionOutputBlock], [string]\n\tContent ContentBlockUnionContentContent `json:\"content\"`\n\t// This field is from variant [WebFetchToolResultBlockContentUnion].\n\tRetrievedAt string `json:\"retrieved_at\"`\n\t// This field is from variant [WebFetchToolResultBlockContentUnion].\n\tURL        string `json:\"url\"`\n\tReturnCode int64  `json:\"return_code\"`\n\tStderr     string `json:\"stderr\"`\n\tStdout     string `json:\"stdout\"`\n\t// This field is from variant [CodeExecutionToolResultBlockContentUnion].\n\tEncryptedStdout string `json:\"encrypted_stdout\"`\n\tErrorMessage    string `json:\"error_message\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tFileType TextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tNumLines int64 `json:\"num_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tStartLine int64 `json:\"start_line\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tTotalLines int64 `json:\"total_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tIsFileUpdate bool `json:\"is_file_update\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tLines []string `json:\"lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewLines int64 `json:\"new_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewStart int64 `json:\"new_start\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldLines int64 `json:\"old_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldStart int64 `json:\"old_start\"`\n\t// This field is from variant [ToolSearchToolResultBlockContentUnion].\n\tToolReferences []ToolReferenceBlock `json:\"tool_references\"`\n\tJSON           struct {\n\t\tOfWebSearchResultBlockArray respjson.Field\n\t\tErrorCode                   respjson.Field\n\t\tType                        respjson.Field\n\t\tContent                     respjson.Field\n\t\tRetrievedAt                 respjson.Field\n\t\tURL                         respjson.Field\n\t\tReturnCode                  respjson.Field\n\t\tStderr                      respjson.Field\n\t\tStdout                      respjson.Field\n\t\tEncryptedStdout             respjson.Field\n\t\tErrorMessage                respjson.Field\n\t\tFileType                    respjson.Field\n\t\tNumLines                    respjson.Field\n\t\tStartLine                   respjson.Field\n\t\tTotalLines                  respjson.Field\n\t\tIsFileUpdate                respjson.Field\n\t\tLines                       respjson.Field\n\t\tNewLines                    respjson.Field\n\t\tNewStart                    respjson.Field\n\t\tOldLines                    respjson.Field\n\t\tOldStart                    respjson.Field\n\t\tToolReferences              respjson.Field\n\t\traw                         string\n\t} `json:\"-\"`\n}\n\nfunc (r *ContentBlockUnionContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockUnionContentContent is an implicit subunion of [ContentBlockUnion].\n// ContentBlockUnionContentContent provides convenient access to the sub-properties\n// of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [ContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfContent OfString]\ntype ContentBlockUnionContentContent struct {\n\t// This field will be present if the value is a [[]CodeExecutionOutputBlock]\n\t// instead of an object.\n\tOfContent []CodeExecutionOutputBlock `json:\",inline\"`\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field is from variant [DocumentBlock].\n\tCitations CitationsConfig `json:\"citations\"`\n\t// This field is from variant [DocumentBlock].\n\tSource DocumentBlockSourceUnion `json:\"source\"`\n\t// This field is from variant [DocumentBlock].\n\tTitle string `json:\"title\"`\n\t// This field is from variant [DocumentBlock].\n\tType constant.Document `json:\"type\"`\n\tJSON struct {\n\t\tOfContent respjson.Field\n\t\tOfString  respjson.Field\n\t\tCitations respjson.Field\n\t\tSource    respjson.Field\n\t\tTitle     respjson.Field\n\t\tType      respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\nfunc (r *ContentBlockUnionContentContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc NewTextBlock(text string) ContentBlockParamUnion {\n\tvar variant TextBlockParam\n\tvariant.Text = text\n\treturn ContentBlockParamUnion{OfText: &variant}\n}\n\nfunc NewImageBlock[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockParamUnion {\n\tvar image ImageBlockParam\n\tswitch v := any(source).(type) {\n\tcase Base64ImageSourceParam:\n\t\timage.Source.OfBase64 = &v\n\tcase URLImageSourceParam:\n\t\timage.Source.OfURL = &v\n\t}\n\treturn ContentBlockParamUnion{OfImage: &image}\n}\n\nfunc NewImageBlockBase64(mediaType string, encodedData string) ContentBlockParamUnion {\n\treturn ContentBlockParamUnion{\n\t\tOfImage: &ImageBlockParam{\n\t\t\tSource: ImageBlockParamSourceUnion{\n\t\t\t\tOfBase64: &Base64ImageSourceParam{\n\t\t\t\t\tData:      encodedData,\n\t\t\t\t\tMediaType: Base64ImageSourceMediaType(mediaType),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}\n\nfunc NewDocumentBlock[\n\tT Base64PDFSourceParam | PlainTextSourceParam | ContentBlockSourceParam | URLPDFSourceParam,\n](source T) ContentBlockParamUnion {\n\tvar document DocumentBlockParam\n\tswitch v := any(source).(type) {\n\tcase Base64PDFSourceParam:\n\t\tdocument.Source.OfBase64 = &v\n\tcase PlainTextSourceParam:\n\t\tdocument.Source.OfText = &v\n\tcase ContentBlockSourceParam:\n\t\tdocument.Source.OfContent = &v\n\tcase URLPDFSourceParam:\n\t\tdocument.Source.OfURL = &v\n\t}\n\treturn ContentBlockParamUnion{OfDocument: &document}\n}\n\nfunc NewSearchResultBlock(content []TextBlockParam, source string, title string) ContentBlockParamUnion {\n\tvar searchResult SearchResultBlockParam\n\tsearchResult.Content = content\n\tsearchResult.Source = source\n\tsearchResult.Title = title\n\treturn ContentBlockParamUnion{OfSearchResult: &searchResult}\n}\n\nfunc NewThinkingBlock(signature string, thinking string) ContentBlockParamUnion {\n\tvar variant ThinkingBlockParam\n\tvariant.Signature = signature\n\tvariant.Thinking = thinking\n\treturn ContentBlockParamUnion{OfThinking: &variant}\n}\n\nfunc NewRedactedThinkingBlock(data string) ContentBlockParamUnion {\n\tvar redactedThinking RedactedThinkingBlockParam\n\tredactedThinking.Data = data\n\treturn ContentBlockParamUnion{OfRedactedThinking: &redactedThinking}\n}\n\nfunc NewToolUseBlock(id string, input any, name string) ContentBlockParamUnion {\n\tvar toolUse ToolUseBlockParam\n\ttoolUse.ID = id\n\ttoolUse.Input = input\n\ttoolUse.Name = name\n\treturn ContentBlockParamUnion{OfToolUse: &toolUse}\n}\n\nfunc NewToolResultBlock(toolUseID string, content string, isError bool) ContentBlockParamUnion {\n\ttoolBlock := ToolResultBlockParam{\n\t\tToolUseID: toolUseID,\n\t\tContent: []ToolResultBlockParamContentUnion{\n\t\t\t{OfText: &TextBlockParam{Text: content}},\n\t\t},\n\t\tIsError: Bool(isError),\n\t}\n\treturn ContentBlockParamUnion{OfToolResult: &toolBlock}\n}\n\nfunc NewServerToolUseBlock(id string, input any, name ServerToolUseBlockParamName) ContentBlockParamUnion {\n\tvar serverToolUse ServerToolUseBlockParam\n\tserverToolUse.ID = id\n\tserverToolUse.Input = input\n\tserverToolUse.Name = name\n\treturn ContentBlockParamUnion{OfServerToolUse: &serverToolUse}\n}\n\nfunc NewWebSearchToolResultBlock[\n\tT []WebSearchResultBlockParam | WebSearchToolRequestErrorParam,\n](content T, toolUseID string) ContentBlockParamUnion {\n\tvar webSearchToolResult WebSearchToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase []WebSearchResultBlockParam:\n\t\twebSearchToolResult.Content.OfWebSearchToolResultBlockItem = v\n\tcase WebSearchToolRequestErrorParam:\n\t\twebSearchToolResult.Content.OfRequestWebSearchToolResultError = &v\n\t}\n\twebSearchToolResult.ToolUseID = toolUseID\n\treturn ContentBlockParamUnion{OfWebSearchToolResult: &webSearchToolResult}\n}\n\nfunc NewWebFetchToolResultBlock[\n\tT WebFetchToolResultErrorBlockParam | WebFetchBlockParam,\n](content T, toolUseID string) ContentBlockParamUnion {\n\tvar webFetchToolResult WebFetchToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase WebFetchToolResultErrorBlockParam:\n\t\twebFetchToolResult.Content.OfRequestWebFetchToolResultError = &v\n\tcase WebFetchBlockParam:\n\t\twebFetchToolResult.Content.OfRequestWebFetchResultBlock = &v\n\t}\n\twebFetchToolResult.ToolUseID = toolUseID\n\treturn ContentBlockParamUnion{OfWebFetchToolResult: &webFetchToolResult}\n}\n\nfunc NewCodeExecutionToolResultBlock[\n\tT CodeExecutionToolResultErrorParam | CodeExecutionResultBlockParam | EncryptedCodeExecutionResultBlockParam,\n](content T, toolUseID string) ContentBlockParamUnion {\n\tvar codeExecutionToolResult CodeExecutionToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase CodeExecutionToolResultErrorParam:\n\t\tcodeExecutionToolResult.Content.OfRequestCodeExecutionToolResultError = &v\n\tcase CodeExecutionResultBlockParam:\n\t\tcodeExecutionToolResult.Content.OfRequestCodeExecutionResultBlock = &v\n\tcase EncryptedCodeExecutionResultBlockParam:\n\t\tcodeExecutionToolResult.Content.OfRequestEncryptedCodeExecutionResultBlock = &v\n\t}\n\tcodeExecutionToolResult.ToolUseID = toolUseID\n\treturn ContentBlockParamUnion{OfCodeExecutionToolResult: &codeExecutionToolResult}\n}\n\nfunc NewBashCodeExecutionToolResultBlock[\n\tT BashCodeExecutionToolResultErrorParam | BashCodeExecutionResultBlockParam,\n](content T, toolUseID string) ContentBlockParamUnion {\n\tvar bashCodeExecutionToolResult BashCodeExecutionToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase BashCodeExecutionToolResultErrorParam:\n\t\tbashCodeExecutionToolResult.Content.OfRequestBashCodeExecutionToolResultError = &v\n\tcase BashCodeExecutionResultBlockParam:\n\t\tbashCodeExecutionToolResult.Content.OfRequestBashCodeExecutionResultBlock = &v\n\t}\n\tbashCodeExecutionToolResult.ToolUseID = toolUseID\n\treturn ContentBlockParamUnion{OfBashCodeExecutionToolResult: &bashCodeExecutionToolResult}\n}\n\nfunc NewTextEditorCodeExecutionToolResultBlock[\n\tT TextEditorCodeExecutionToolResultErrorParam | TextEditorCodeExecutionViewResultBlockParam | TextEditorCodeExecutionCreateResultBlockParam | TextEditorCodeExecutionStrReplaceResultBlockParam,\n](content T, toolUseID string) ContentBlockParamUnion {\n\tvar textEditorCodeExecutionToolResult TextEditorCodeExecutionToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase TextEditorCodeExecutionToolResultErrorParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionToolResultError = &v\n\tcase TextEditorCodeExecutionViewResultBlockParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionViewResultBlock = &v\n\tcase TextEditorCodeExecutionCreateResultBlockParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionCreateResultBlock = &v\n\tcase TextEditorCodeExecutionStrReplaceResultBlockParam:\n\t\ttextEditorCodeExecutionToolResult.Content.OfRequestTextEditorCodeExecutionStrReplaceResultBlock = &v\n\t}\n\ttextEditorCodeExecutionToolResult.ToolUseID = toolUseID\n\treturn ContentBlockParamUnion{OfTextEditorCodeExecutionToolResult: &textEditorCodeExecutionToolResult}\n}\n\nfunc NewToolSearchToolResultBlock[\n\tT ToolSearchToolResultErrorParam | ToolSearchToolSearchResultBlockParam,\n](content T, toolUseID string) ContentBlockParamUnion {\n\tvar toolSearchToolResult ToolSearchToolResultBlockParam\n\tswitch v := any(content).(type) {\n\tcase ToolSearchToolResultErrorParam:\n\t\ttoolSearchToolResult.Content.OfRequestToolSearchToolResultError = &v\n\tcase ToolSearchToolSearchResultBlockParam:\n\t\ttoolSearchToolResult.Content.OfRequestToolSearchToolSearchResultBlock = &v\n\t}\n\ttoolSearchToolResult.ToolUseID = toolUseID\n\treturn ContentBlockParamUnion{OfToolSearchToolResult: &toolSearchToolResult}\n}\n\nfunc NewContainerUploadBlock(fileID string) ContentBlockParamUnion {\n\tvar containerUpload ContainerUploadBlockParam\n\tcontainerUpload.FileID = fileID\n\treturn ContentBlockParamUnion{OfContainerUpload: &containerUpload}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ContentBlockParamUnion struct {\n\tOfText                              *TextBlockParam                              `json:\",omitzero,inline\"`\n\tOfImage                             *ImageBlockParam                             `json:\",omitzero,inline\"`\n\tOfDocument                          *DocumentBlockParam                          `json:\",omitzero,inline\"`\n\tOfSearchResult                      *SearchResultBlockParam                      `json:\",omitzero,inline\"`\n\tOfThinking                          *ThinkingBlockParam                          `json:\",omitzero,inline\"`\n\tOfRedactedThinking                  *RedactedThinkingBlockParam                  `json:\",omitzero,inline\"`\n\tOfToolUse                           *ToolUseBlockParam                           `json:\",omitzero,inline\"`\n\tOfToolResult                        *ToolResultBlockParam                        `json:\",omitzero,inline\"`\n\tOfServerToolUse                     *ServerToolUseBlockParam                     `json:\",omitzero,inline\"`\n\tOfWebSearchToolResult               *WebSearchToolResultBlockParam               `json:\",omitzero,inline\"`\n\tOfWebFetchToolResult                *WebFetchToolResultBlockParam                `json:\",omitzero,inline\"`\n\tOfCodeExecutionToolResult           *CodeExecutionToolResultBlockParam           `json:\",omitzero,inline\"`\n\tOfBashCodeExecutionToolResult       *BashCodeExecutionToolResultBlockParam       `json:\",omitzero,inline\"`\n\tOfTextEditorCodeExecutionToolResult *TextEditorCodeExecutionToolResultBlockParam `json:\",omitzero,inline\"`\n\tOfToolSearchToolResult              *ToolSearchToolResultBlockParam              `json:\",omitzero,inline\"`\n\tOfContainerUpload                   *ContainerUploadBlockParam                   `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ContentBlockParamUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfText,\n\t\tu.OfImage,\n\t\tu.OfDocument,\n\t\tu.OfSearchResult,\n\t\tu.OfThinking,\n\t\tu.OfRedactedThinking,\n\t\tu.OfToolUse,\n\t\tu.OfToolResult,\n\t\tu.OfServerToolUse,\n\t\tu.OfWebSearchToolResult,\n\t\tu.OfWebFetchToolResult,\n\t\tu.OfCodeExecutionToolResult,\n\t\tu.OfBashCodeExecutionToolResult,\n\t\tu.OfTextEditorCodeExecutionToolResult,\n\t\tu.OfToolSearchToolResult,\n\t\tu.OfContainerUpload)\n}\nfunc (u *ContentBlockParamUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ContentBlockParamUnion) asAny() any {\n\tif !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfImage) {\n\t\treturn u.OfImage\n\t} else if !param.IsOmitted(u.OfDocument) {\n\t\treturn u.OfDocument\n\t} else if !param.IsOmitted(u.OfSearchResult) {\n\t\treturn u.OfSearchResult\n\t} else if !param.IsOmitted(u.OfThinking) {\n\t\treturn u.OfThinking\n\t} else if !param.IsOmitted(u.OfRedactedThinking) {\n\t\treturn u.OfRedactedThinking\n\t} else if !param.IsOmitted(u.OfToolUse) {\n\t\treturn u.OfToolUse\n\t} else if !param.IsOmitted(u.OfToolResult) {\n\t\treturn u.OfToolResult\n\t} else if !param.IsOmitted(u.OfServerToolUse) {\n\t\treturn u.OfServerToolUse\n\t} else if !param.IsOmitted(u.OfWebSearchToolResult) {\n\t\treturn u.OfWebSearchToolResult\n\t} else if !param.IsOmitted(u.OfWebFetchToolResult) {\n\t\treturn u.OfWebFetchToolResult\n\t} else if !param.IsOmitted(u.OfCodeExecutionToolResult) {\n\t\treturn u.OfCodeExecutionToolResult\n\t} else if !param.IsOmitted(u.OfBashCodeExecutionToolResult) {\n\t\treturn u.OfBashCodeExecutionToolResult\n\t} else if !param.IsOmitted(u.OfTextEditorCodeExecutionToolResult) {\n\t\treturn u.OfTextEditorCodeExecutionToolResult\n\t} else if !param.IsOmitted(u.OfToolSearchToolResult) {\n\t\treturn u.OfToolSearchToolResult\n\t} else if !param.IsOmitted(u.OfContainerUpload) {\n\t\treturn u.OfContainerUpload\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetText() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.Text\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetContext() *string {\n\tif vt := u.OfDocument; vt != nil && vt.Context.Valid() {\n\t\treturn &vt.Context.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetSignature() *string {\n\tif vt := u.OfThinking; vt != nil {\n\t\treturn &vt.Signature\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetThinking() *string {\n\tif vt := u.OfThinking; vt != nil {\n\t\treturn &vt.Thinking\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetData() *string {\n\tif vt := u.OfRedactedThinking; vt != nil {\n\t\treturn &vt.Data\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetIsError() *bool {\n\tif vt := u.OfToolResult; vt != nil && vt.IsError.Valid() {\n\t\treturn &vt.IsError.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetFileID() *string {\n\tif vt := u.OfContainerUpload; vt != nil {\n\t\treturn &vt.FileID\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetType() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfThinking; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRedactedThinking; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolUse; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfContainerUpload; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetTitle() *string {\n\tif vt := u.OfDocument; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Title)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetID() *string {\n\tif vt := u.OfToolUse; vt != nil {\n\t\treturn (*string)(&vt.ID)\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn (*string)(&vt.ID)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetName() *string {\n\tif vt := u.OfToolUse; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockParamUnion) GetToolUseID() *string {\n\tif vt := u.OfToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\treturn (*string)(&vt.ToolUseID)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u ContentBlockParamUnion) GetCacheControl() *CacheControlEphemeralParam {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolUse; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfContainerUpload; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u ContentBlockParamUnion) GetCitations() (res contentBlockParamUnionCitations) {\n\tif vt := u.OfText; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Citations\n\t}\n\treturn\n}\n\n// Can have the runtime types [*[]TextCitationParamUnion], [*CitationsConfigParam]\ntype contentBlockParamUnionCitations struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *[]anthropic.TextCitationParamUnion:\n//\tcase *anthropic.CitationsConfigParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u contentBlockParamUnionCitations) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionCitations) GetEnabled() *bool {\n\tswitch vt := u.any.(type) {\n\tcase *CitationsConfigParam:\n\t\treturn paramutil.AddrIfPresent(vt.Enabled)\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u ContentBlockParamUnion) GetSource() (res contentBlockParamUnionSource) {\n\tif vt := u.OfImage; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Source\n\t}\n\treturn\n}\n\n// Can have the runtime types [*Base64ImageSourceParam], [*URLImageSourceParam],\n// [*Base64PDFSourceParam], [*PlainTextSourceParam], [*ContentBlockSourceParam],\n// [*URLPDFSourceParam], [*string]\ntype contentBlockParamUnionSource struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.Base64ImageSourceParam:\n//\tcase *anthropic.URLImageSourceParam:\n//\tcase *anthropic.Base64PDFSourceParam:\n//\tcase *anthropic.PlainTextSourceParam:\n//\tcase *anthropic.ContentBlockSourceParam:\n//\tcase *anthropic.URLPDFSourceParam:\n//\tcase *string:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u contentBlockParamUnionSource) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionSource) GetContent() *ContentBlockSourceContentUnionParam {\n\tswitch vt := u.any.(type) {\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetContent()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionSource) GetData() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetData()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetData()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionSource) GetMediaType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetMediaType()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetMediaType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionSource) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetType()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionSource) GetURL() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetURL()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetURL()\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u ContentBlockParamUnion) GetContent() (res contentBlockParamUnionContent) {\n\tif vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Content\n\t} else if vt := u.OfToolResult; vt != nil {\n\t\tres.any = &vt.Content\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfCodeExecutionToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfBashCodeExecutionToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfTextEditorCodeExecutionToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t} else if vt := u.OfToolSearchToolResult; vt != nil {\n\t\tres.any = vt.Content.asAny()\n\t}\n\treturn\n}\n\n// Can have the runtime types [_[]TextBlockParam],\n// [_[]ToolResultBlockParamContentUnion], [*[]WebSearchResultBlockParam],\n// [*WebFetchToolResultErrorBlockParam], [*WebFetchBlockParam],\n// [*CodeExecutionToolResultErrorParam], [*CodeExecutionResultBlockParam],\n// [*EncryptedCodeExecutionResultBlockParam],\n// [*BashCodeExecutionToolResultErrorParam], [*BashCodeExecutionResultBlockParam],\n// [*TextEditorCodeExecutionToolResultErrorParam],\n// [*TextEditorCodeExecutionViewResultBlockParam],\n// [*TextEditorCodeExecutionCreateResultBlockParam],\n// [*TextEditorCodeExecutionStrReplaceResultBlockParam],\n// [*ToolSearchToolResultErrorParam], [*ToolSearchToolSearchResultBlockParam]\ntype contentBlockParamUnionContent struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *[]anthropic.TextBlockParam:\n//\tcase *[]anthropic.ToolResultBlockParamContentUnion:\n//\tcase *[]anthropic.WebSearchResultBlockParam:\n//\tcase *anthropic.WebFetchToolResultErrorBlockParam:\n//\tcase *anthropic.WebFetchBlockParam:\n//\tcase *anthropic.CodeExecutionToolResultErrorParam:\n//\tcase *anthropic.CodeExecutionResultBlockParam:\n//\tcase *anthropic.EncryptedCodeExecutionResultBlockParam:\n//\tcase *anthropic.BashCodeExecutionToolResultErrorParam:\n//\tcase *anthropic.BashCodeExecutionResultBlockParam:\n//\tcase *anthropic.TextEditorCodeExecutionToolResultErrorParam:\n//\tcase *anthropic.TextEditorCodeExecutionViewResultBlockParam:\n//\tcase *anthropic.TextEditorCodeExecutionCreateResultBlockParam:\n//\tcase *anthropic.TextEditorCodeExecutionStrReplaceResultBlockParam:\n//\tcase *anthropic.ToolSearchToolResultErrorParam:\n//\tcase *anthropic.ToolSearchToolSearchResultBlockParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u contentBlockParamUnionContent) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetURL() *string {\n\tswitch vt := u.any.(type) {\n\tcase *WebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetURL()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetRetrievedAt() *string {\n\tswitch vt := u.any.(type) {\n\tcase *WebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetRetrievedAt()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetEncryptedStdout() *string {\n\tswitch vt := u.any.(type) {\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetEncryptedStdout()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetErrorMessage() *string {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorMessage()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetFileType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetFileType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetNumLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetNumLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetStartLine() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStartLine()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetTotalLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetTotalLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetIsFileUpdate() *bool {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetIsFileUpdate()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetLines() []string {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetNewLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetNewLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetNewStart() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetNewStart()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetOldLines() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetOldLines()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetOldStart() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetOldStart()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetToolReferences() []ToolReferenceBlockParam {\n\tswitch vt := u.any.(type) {\n\tcase *ToolSearchToolResultBlockParamContentUnion:\n\t\treturn vt.GetToolReferences()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetErrorCode() *string {\n\tswitch vt := u.any.(type) {\n\tcase *WebSearchToolResultBlockParamContentUnion:\n\t\tif vt.OfRequestWebSearchToolResultError != nil {\n\t\t\treturn (*string)(&vt.OfRequestWebSearchToolResultError.ErrorCode)\n\t\t}\n\tcase *WebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *BashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\tcase *ToolSearchToolResultBlockParamContentUnion:\n\t\treturn vt.GetErrorCode()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *WebSearchToolResultBlockParamContentUnion:\n\t\tif vt.OfRequestWebSearchToolResultError != nil {\n\t\t\treturn (*string)(&vt.OfRequestWebSearchToolResultError.Type)\n\t\t}\n\tcase *WebFetchToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *BashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\tcase *ToolSearchToolResultBlockParamContentUnion:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetReturnCode() *int64 {\n\tswitch vt := u.any.(type) {\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetReturnCode()\n\tcase *BashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetReturnCode()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetStderr() *string {\n\tswitch vt := u.any.(type) {\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStderr()\n\tcase *BashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStderr()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionContent) GetStdout() *string {\n\tswitch vt := u.any.(type) {\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStdout()\n\tcase *BashCodeExecutionToolResultBlockParamContentUnion:\n\t\treturn vt.GetStdout()\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u contentBlockParamUnionContent) GetContent() (res contentBlockParamUnionContentContent) {\n\tswitch vt := u.any.(type) {\n\tcase *WebFetchToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\tcase *CodeExecutionToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\tcase *BashCodeExecutionToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\tcase *TextEditorCodeExecutionToolResultBlockParamContentUnion:\n\t\tres.any = vt.GetContent()\n\t}\n\treturn res\n}\n\n// Can have the runtime types [*DocumentBlockParam],\n// [_[]CodeExecutionOutputBlockParam], [_[]BashCodeExecutionOutputBlockParam],\n// [*string]\ntype contentBlockParamUnionContentContent struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.DocumentBlockParam:\n//\tcase *[]anthropic.CodeExecutionOutputBlockParam:\n//\tcase *[]anthropic.BashCodeExecutionOutputBlockParam:\n//\tcase *string:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u contentBlockParamUnionContentContent) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's Input property, if present.\nfunc (u ContentBlockParamUnion) GetInput() *any {\n\tif vt := u.OfToolUse; vt != nil {\n\t\treturn &vt.Input\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\treturn &vt.Input\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u ContentBlockParamUnion) GetCaller() (res contentBlockParamUnionCaller) {\n\tif vt := u.OfToolUse; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t} else if vt := u.OfServerToolUse; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t} else if vt := u.OfWebSearchToolResult; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t} else if vt := u.OfWebFetchToolResult; vt != nil {\n\t\tres.any = vt.Caller.asAny()\n\t}\n\treturn\n}\n\n// Can have the runtime types [*DirectCallerParam], [*ServerToolCallerParam],\n// [*ServerToolCaller20260120Param]\ntype contentBlockParamUnionCaller struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.DirectCallerParam:\n//\tcase *anthropic.ServerToolCallerParam:\n//\tcase *anthropic.ServerToolCaller20260120Param:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u contentBlockParamUnionCaller) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionCaller) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ToolUseBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\tcase *ServerToolUseBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\tcase *WebSearchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\tcase *WebFetchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u contentBlockParamUnionCaller) GetToolID() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ToolUseBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\tcase *ServerToolUseBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\tcase *WebSearchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\tcase *WebFetchToolResultBlockParamCallerUnion:\n\t\treturn vt.GetToolID()\n\t}\n\treturn nil\n}\n\nfunc init() {\n\tapijson.RegisterCustomDecoder[[]ContentBlockParamUnion](func(node gjson.Result, value reflect.Value, defaultDecoder func(gjson.Result, reflect.Value) error) error {\n\t\tif node.Type == gjson.String {\n\t\t\ttextBlock := TextBlockParam{Text: node.String(), Type: \"text\"}\n\t\t\tcontentUnion := ContentBlockParamUnion{OfText: &textBlock}\n\t\t\tarrayValue := reflect.MakeSlice(value.Type(), 1, 1)\n\t\t\tarrayValue.Index(0).Set(reflect.ValueOf(contentUnion))\n\t\t\tvalue.Set(arrayValue)\n\t\t\treturn nil\n\t\t}\n\t\treturn defaultDecoder(node, value)\n\t})\n}\n\nfunc init() {\n\tapijson.RegisterCustomDecoder[[]ToolResultBlockParamContentUnion](func(node gjson.Result, value reflect.Value, defaultDecoder func(gjson.Result, reflect.Value) error) error {\n\t\tif node.Type == gjson.String {\n\t\t\ttextBlock := TextBlockParam{Text: node.String(), Type: \"text\"}\n\t\t\tcontentUnion := ToolResultBlockParamContentUnion{OfText: &textBlock}\n\t\t\tarrayValue := reflect.MakeSlice(value.Type(), 1, 1)\n\t\t\tarrayValue.Index(0).Set(reflect.ValueOf(contentUnion))\n\t\t\tvalue.Set(arrayValue)\n\t\t\treturn nil\n\t\t}\n\t\treturn defaultDecoder(node, value)\n\t})\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ContentBlockParamUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[TextBlockParam](\"text\"),\n\t\tapijson.Discriminator[ImageBlockParam](\"image\"),\n\t\tapijson.Discriminator[DocumentBlockParam](\"document\"),\n\t\tapijson.Discriminator[SearchResultBlockParam](\"search_result\"),\n\t\tapijson.Discriminator[ThinkingBlockParam](\"thinking\"),\n\t\tapijson.Discriminator[RedactedThinkingBlockParam](\"redacted_thinking\"),\n\t\tapijson.Discriminator[ToolUseBlockParam](\"tool_use\"),\n\t\tapijson.Discriminator[ToolResultBlockParam](\"tool_result\"),\n\t\tapijson.Discriminator[ServerToolUseBlockParam](\"server_tool_use\"),\n\t\tapijson.Discriminator[WebSearchToolResultBlockParam](\"web_search_tool_result\"),\n\t\tapijson.Discriminator[WebFetchToolResultBlockParam](\"web_fetch_tool_result\"),\n\t\tapijson.Discriminator[CodeExecutionToolResultBlockParam](\"code_execution_tool_result\"),\n\t\tapijson.Discriminator[BashCodeExecutionToolResultBlockParam](\"bash_code_execution_tool_result\"),\n\t\tapijson.Discriminator[TextEditorCodeExecutionToolResultBlockParam](\"text_editor_code_execution_tool_result\"),\n\t\tapijson.Discriminator[ToolSearchToolResultBlockParam](\"tool_search_tool_result\"),\n\t\tapijson.Discriminator[ContainerUploadBlockParam](\"container_upload\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ContentBlockSourceContentItemUnionParam](\n\t\t\"type\",\n\t\tapijson.Discriminator[TextBlockParam](\"text\"),\n\t\tapijson.Discriminator[ImageBlockParam](\"image\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[DocumentBlockParamSourceUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[Base64PDFSourceParam](\"base64\"),\n\t\tapijson.Discriminator[PlainTextSourceParam](\"text\"),\n\t\tapijson.Discriminator[ContentBlockSourceParam](\"content\"),\n\t\tapijson.Discriminator[URLPDFSourceParam](\"url\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ImageBlockParamSourceUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[Base64ImageSourceParam](\"base64\"),\n\t\tapijson.Discriminator[URLImageSourceParam](\"url\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ServerToolUseBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[DirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[ServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[ServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[TextCitationParamUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[CitationCharLocationParam](\"char_location\"),\n\t\tapijson.Discriminator[CitationPageLocationParam](\"page_location\"),\n\t\tapijson.Discriminator[CitationContentBlockLocationParam](\"content_block_location\"),\n\t\tapijson.Discriminator[CitationWebSearchResultLocationParam](\"web_search_result_location\"),\n\t\tapijson.Discriminator[CitationSearchResultLocationParam](\"search_result_location\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ThinkingConfigParamUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[ThinkingConfigEnabledParam](\"enabled\"),\n\t\tapijson.Discriminator[ThinkingConfigDisabledParam](\"disabled\"),\n\t\tapijson.Discriminator[ThinkingConfigAdaptiveParam](\"adaptive\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ToolChoiceUnionParam](\n\t\t\"type\",\n\t\tapijson.Discriminator[ToolChoiceAutoParam](\"auto\"),\n\t\tapijson.Discriminator[ToolChoiceAnyParam](\"any\"),\n\t\tapijson.Discriminator[ToolChoiceToolParam](\"tool\"),\n\t\tapijson.Discriminator[ToolChoiceNoneParam](\"none\"),\n\t)\n}\n\n\nfunc init() {\n\tapijson.RegisterUnion[ToolResultBlockParamContentUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[TextBlockParam](\"text\"),\n\t\tapijson.Discriminator[ImageBlockParam](\"image\"),\n\t\tapijson.Discriminator[SearchResultBlockParam](\"search_result\"),\n\t\tapijson.Discriminator[DocumentBlockParam](\"document\"),\n\t\tapijson.Discriminator[ToolReferenceBlockParam](\"tool_reference\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[ToolUseBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[DirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[ServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[ServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[WebFetchToolResultBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[DirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[ServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[ServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\nfunc init() {\n\tapijson.RegisterUnion[WebSearchToolResultBlockParamCallerUnion](\n\t\t\"type\",\n\t\tapijson.Discriminator[DirectCallerParam](\"direct\"),\n\t\tapijson.Discriminator[ServerToolCallerParam](\"code_execution_20250825\"),\n\t\tapijson.Discriminator[ServerToolCaller20260120Param](\"code_execution_20260120\"),\n\t)\n}\n\n// The properties Content, Type are required.\ntype ContentBlockSourceParam struct {\n\tContent ContentBlockSourceContentUnionParam `json:\"content,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"content\".\n\tType constant.Content `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ContentBlockSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ContentBlockSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ContentBlockSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ContentBlockSourceContentUnionParam struct {\n\tOfString                    param.Opt[string]                         `json:\",omitzero,inline\"`\n\tOfContentBlockSourceContent []ContentBlockSourceContentItemUnionParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ContentBlockSourceContentUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfString, u.OfContentBlockSourceContent)\n}\nfunc (u *ContentBlockSourceContentUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ContentBlockSourceContentUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t} else if !param.IsOmitted(u.OfContentBlockSourceContent) {\n\t\treturn &u.OfContentBlockSourceContent\n\t}\n\treturn nil\n}\n\nfunc ContentBlockSourceContentItemParamOfText(text string) ContentBlockSourceContentItemUnionParam {\n\tvar variant TextBlockParam\n\tvariant.Text = text\n\treturn ContentBlockSourceContentItemUnionParam{OfText: &variant}\n}\n\nfunc ContentBlockSourceContentItemParamOfImage[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockSourceContentItemUnionParam {\n\tvar image ImageBlockParam\n\tswitch v := any(source).(type) {\n\tcase Base64ImageSourceParam:\n\t\timage.Source.OfBase64 = &v\n\tcase URLImageSourceParam:\n\t\timage.Source.OfURL = &v\n\t}\n\treturn ContentBlockSourceContentItemUnionParam{OfImage: &image}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ContentBlockSourceContentItemUnionParam struct {\n\tOfText  *TextBlockParam  `json:\",omitzero,inline\"`\n\tOfImage *ImageBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ContentBlockSourceContentItemUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfText, u.OfImage)\n}\nfunc (u *ContentBlockSourceContentItemUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ContentBlockSourceContentItemUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfImage) {\n\t\treturn u.OfImage\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockSourceContentItemUnionParam) GetText() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.Text\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockSourceContentItemUnionParam) GetCitations() []TextCitationParamUnion {\n\tif vt := u.OfText; vt != nil {\n\t\treturn vt.Citations\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockSourceContentItemUnionParam) GetSource() *ImageBlockParamSourceUnion {\n\tif vt := u.OfImage; vt != nil {\n\t\treturn &vt.Source\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ContentBlockSourceContentItemUnionParam) GetType() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u ContentBlockSourceContentItemUnionParam) GetCacheControl() *CacheControlEphemeralParam {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Tool invocation directly from the model.\ntype DirectCaller struct {\n\tType constant.Direct `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r DirectCaller) RawJSON() string { return r.JSON.raw }\nfunc (r *DirectCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this DirectCaller to a DirectCallerParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// DirectCallerParam.Overrides()\nfunc (r DirectCaller) ToParam() DirectCallerParam {\n\treturn param.Override[DirectCallerParam](json.RawMessage(r.RawJSON()))\n}\n\nfunc NewDirectCallerParam() DirectCallerParam {\n\treturn DirectCallerParam{\n\t\tType: \"direct\",\n\t}\n}\n\n// Tool invocation directly from the model.\n//\n// This struct has a constant value, construct it with [NewDirectCallerParam].\ntype DirectCallerParam struct {\n\tType constant.Direct `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r DirectCallerParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow DirectCallerParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *DirectCallerParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype DocumentBlock struct {\n\t// Citation configuration for the document\n\tCitations CitationsConfig          `json:\"citations\" api:\"required\"`\n\tSource    DocumentBlockSourceUnion `json:\"source\" api:\"required\"`\n\t// The title of the document\n\tTitle string            `json:\"title\" api:\"required\"`\n\tType  constant.Document `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitations   respjson.Field\n\t\tSource      respjson.Field\n\t\tTitle       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r DocumentBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *DocumentBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// DocumentBlockSourceUnion contains all possible properties and values from\n// [Base64PDFSource], [PlainTextSource].\n//\n// Use the [DocumentBlockSourceUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype DocumentBlockSourceUnion struct {\n\tData      string `json:\"data\"`\n\tMediaType string `json:\"media_type\"`\n\t// Any of \"base64\", \"text\".\n\tType string `json:\"type\"`\n\tJSON struct {\n\t\tData      respjson.Field\n\t\tMediaType respjson.Field\n\t\tType      respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\n// anyDocumentBlockSource is implemented by each variant of\n// [DocumentBlockSourceUnion] to add type safety for the return type of\n// [DocumentBlockSourceUnion.AsAny]\ntype anyDocumentBlockSource interface {\n\timplDocumentBlockSourceUnion()\n}\n\nfunc (Base64PDFSource) implDocumentBlockSourceUnion() {}\nfunc (PlainTextSource) implDocumentBlockSourceUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := DocumentBlockSourceUnion.AsAny().(type) {\n//\tcase anthropic.Base64PDFSource:\n//\tcase anthropic.PlainTextSource:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u DocumentBlockSourceUnion) AsAny() anyDocumentBlockSource {\n\tswitch u.Type {\n\tcase \"base64\":\n\t\treturn u.AsBase64()\n\tcase \"text\":\n\t\treturn u.AsText()\n\t}\n\treturn nil\n}\n\nfunc (u DocumentBlockSourceUnion) AsBase64() (v Base64PDFSource) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u DocumentBlockSourceUnion) AsText() (v PlainTextSource) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u DocumentBlockSourceUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *DocumentBlockSourceUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Source, Type are required.\ntype DocumentBlockParam struct {\n\tSource  DocumentBlockParamSourceUnion `json:\"source,omitzero\" api:\"required\"`\n\tContext param.Opt[string]             `json:\"context,omitzero\"`\n\tTitle   param.Opt[string]             `json:\"title,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tCitations    CitationsConfigParam       `json:\"citations,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"document\".\n\tType constant.Document `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r DocumentBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow DocumentBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *DocumentBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype DocumentBlockParamSourceUnion struct {\n\tOfBase64  *Base64PDFSourceParam    `json:\",omitzero,inline\"`\n\tOfText    *PlainTextSourceParam    `json:\",omitzero,inline\"`\n\tOfContent *ContentBlockSourceParam `json:\",omitzero,inline\"`\n\tOfURL     *URLPDFSourceParam       `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u DocumentBlockParamSourceUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfBase64, u.OfText, u.OfContent, u.OfURL)\n}\nfunc (u *DocumentBlockParamSourceUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *DocumentBlockParamSourceUnion) asAny() any {\n\tif !param.IsOmitted(u.OfBase64) {\n\t\treturn u.OfBase64\n\t} else if !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfContent) {\n\t\treturn u.OfContent\n\t} else if !param.IsOmitted(u.OfURL) {\n\t\treturn u.OfURL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u DocumentBlockParamSourceUnion) GetContent() *ContentBlockSourceContentUnionParam {\n\tif vt := u.OfContent; vt != nil {\n\t\treturn &vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u DocumentBlockParamSourceUnion) GetURL() *string {\n\tif vt := u.OfURL; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u DocumentBlockParamSourceUnion) GetData() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.Data)\n\t} else if vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Data)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u DocumentBlockParamSourceUnion) GetMediaType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.MediaType)\n\t} else if vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.MediaType)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u DocumentBlockParamSourceUnion) GetType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfContent; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfURL; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Code execution result with encrypted stdout for PFC + web_search results.\ntype EncryptedCodeExecutionResultBlock struct {\n\tContent         []CodeExecutionOutputBlock            `json:\"content\" api:\"required\"`\n\tEncryptedStdout string                                `json:\"encrypted_stdout\" api:\"required\"`\n\tReturnCode      int64                                 `json:\"return_code\" api:\"required\"`\n\tStderr          string                                `json:\"stderr\" api:\"required\"`\n\tType            constant.EncryptedCodeExecutionResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent         respjson.Field\n\t\tEncryptedStdout respjson.Field\n\t\tReturnCode      respjson.Field\n\t\tStderr          respjson.Field\n\t\tType            respjson.Field\n\t\tExtraFields     map[string]respjson.Field\n\t\traw             string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r EncryptedCodeExecutionResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *EncryptedCodeExecutionResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Code execution result with encrypted stdout for PFC + web_search results.\n//\n// The properties Content, EncryptedStdout, ReturnCode, Stderr, Type are required.\ntype EncryptedCodeExecutionResultBlockParam struct {\n\tContent         []CodeExecutionOutputBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tEncryptedStdout string                          `json:\"encrypted_stdout\" api:\"required\"`\n\tReturnCode      int64                           `json:\"return_code\" api:\"required\"`\n\tStderr          string                          `json:\"stderr\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"encrypted_code_execution_result\".\n\tType constant.EncryptedCodeExecutionResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r EncryptedCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow EncryptedCodeExecutionResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *EncryptedCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Source, Type are required.\ntype ImageBlockParam struct {\n\tSource ImageBlockParamSourceUnion `json:\"source,omitzero\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"image\".\n\tType constant.Image `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ImageBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ImageBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ImageBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ImageBlockParamSourceUnion struct {\n\tOfBase64 *Base64ImageSourceParam `json:\",omitzero,inline\"`\n\tOfURL    *URLImageSourceParam    `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ImageBlockParamSourceUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfBase64, u.OfURL)\n}\nfunc (u *ImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ImageBlockParamSourceUnion) asAny() any {\n\tif !param.IsOmitted(u.OfBase64) {\n\t\treturn u.OfBase64\n\t} else if !param.IsOmitted(u.OfURL) {\n\t\treturn u.OfURL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ImageBlockParamSourceUnion) GetData() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn &vt.Data\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ImageBlockParamSourceUnion) GetMediaType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.MediaType)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ImageBlockParamSourceUnion) GetURL() *string {\n\tif vt := u.OfURL; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ImageBlockParamSourceUnion) GetType() *string {\n\tif vt := u.OfBase64; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfURL; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype InputJSONDelta struct {\n\tPartialJSON string                  `json:\"partial_json\" api:\"required\"`\n\tType        constant.InputJSONDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tPartialJSON respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r InputJSONDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *InputJSONDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Schema, Type are required.\ntype JSONOutputFormatParam struct {\n\t// The JSON schema of the format\n\tSchema map[string]any `json:\"schema,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"json_schema\".\n\tType constant.JSONSchema `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r JSONOutputFormatParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow JSONOutputFormatParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *JSONOutputFormatParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype MemoryTool20250818Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any           `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"memory\".\n\tName constant.Memory `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"memory_20250818\".\n\tType constant.Memory20250818 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r MemoryTool20250818Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow MemoryTool20250818Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MemoryTool20250818Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype Message struct {\n\t// Unique object identifier.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// Information about the container used in the request (for the code execution\n\t// tool)\n\tContainer Container `json:\"container\" api:\"required\"`\n\t// Content generated by the model.\n\t//\n\t// This is an array of content blocks, each of which has a `type` that determines\n\t// its shape.\n\t//\n\t// Example:\n\t//\n\t// ```json\n\t// [{ \"type\": \"text\", \"text\": \"Hi, I'm Claude.\" }]\n\t// ```\n\t//\n\t// If the request input `messages` ended with an `assistant` turn, then the\n\t// response `content` will continue directly from that last turn. You can use this\n\t// to constrain the model's output.\n\t//\n\t// For example, if the input `messages` were:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Then the response `content` might be:\n\t//\n\t// ```json\n\t// [{ \"type\": \"text\", \"text\": \"B)\" }]\n\t// ```\n\tContent []ContentBlockUnion `json:\"content\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model\" api:\"required\"`\n\t// Conversational role of the generated message.\n\t//\n\t// This will always be `\"assistant\"`.\n\tRole constant.Assistant `json:\"role\" api:\"required\"`\n\t// The reason that we stopped.\n\t//\n\t// This may be one the following values:\n\t//\n\t//   - `\"end_turn\"`: the model reached a natural stopping point\n\t//   - `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n\t//   - `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n\t//   - `\"tool_use\"`: the model invoked one or more tools\n\t//   - `\"pause_turn\"`: we paused a long-running turn. You may provide the response\n\t//     back as-is in a subsequent request to let the model continue.\n\t//   - `\"refusal\"`: when streaming classifiers intervene to handle potential policy\n\t//     violations\n\t//\n\t// In non-streaming mode this value is always non-null. In streaming mode, it is\n\t// null in the `message_start` event and non-null otherwise.\n\t//\n\t// Any of \"end_turn\", \"max_tokens\", \"stop_sequence\", \"tool_use\", \"pause_turn\",\n\t// \"refusal\".\n\tStopReason StopReason `json:\"stop_reason\" api:\"required\"`\n\t// Which custom stop sequence was generated, if any.\n\t//\n\t// This value will be a non-null string if one of your custom stop sequences was\n\t// generated.\n\tStopSequence string `json:\"stop_sequence\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Messages, this is always `\"message\"`.\n\tType constant.Message `json:\"type\" api:\"required\"`\n\t// Billing and rate-limit usage.\n\t//\n\t// Anthropic's API bills and rate-limits by token counts, as tokens represent the\n\t// underlying cost to our systems.\n\t//\n\t// Under the hood, the API transforms requests into a format suitable for the\n\t// model. The model's output then goes through a parsing stage before becoming an\n\t// API response. As a result, the token counts in `usage` will not match one-to-one\n\t// with the exact visible content of an API request or response.\n\t//\n\t// For example, `output_tokens` will be non-zero, even for an empty string response\n\t// from Claude.\n\t//\n\t// Total input tokens in a request is the summation of `input_tokens`,\n\t// `cache_creation_input_tokens`, and `cache_read_input_tokens`.\n\tUsage Usage `json:\"usage\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID           respjson.Field\n\t\tContainer    respjson.Field\n\t\tContent      respjson.Field\n\t\tModel        respjson.Field\n\t\tRole         respjson.Field\n\t\tStopReason   respjson.Field\n\t\tStopSequence respjson.Field\n\t\tType         respjson.Field\n\t\tUsage        respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Message) RawJSON() string { return r.JSON.raw }\nfunc (r *Message) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n\nfunc MessageCountTokensToolParamOfTool(inputSchema ToolInputSchemaParam, name string) MessageCountTokensToolUnionParam {\n\tvar variant ToolParam\n\tvariant.InputSchema = inputSchema\n\tvariant.Name = name\n\treturn MessageCountTokensToolUnionParam{OfTool: &variant}\n}\n\nfunc MessageCountTokensToolParamOfToolSearchToolBm25_20251119(type_ ToolSearchToolBm25_20251119Type) MessageCountTokensToolUnionParam {\n\tvar variant ToolSearchToolBm25_20251119Param\n\tvariant.Type = type_\n\treturn MessageCountTokensToolUnionParam{OfToolSearchToolBm25_20251119: &variant}\n}\n\nfunc MessageCountTokensToolParamOfToolSearchToolRegex20251119(type_ ToolSearchToolRegex20251119Type) MessageCountTokensToolUnionParam {\n\tvar variant ToolSearchToolRegex20251119Param\n\tvariant.Type = type_\n\treturn MessageCountTokensToolUnionParam{OfToolSearchToolRegex20251119: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype MessageCountTokensToolUnionParam struct {\n\tOfTool                        *ToolParam                        `json:\",omitzero,inline\"`\n\tOfBashTool20250124            *ToolBash20250124Param            `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250522   *CodeExecutionTool20250522Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250825   *CodeExecutionTool20250825Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20260120   *CodeExecutionTool20260120Param   `json:\",omitzero,inline\"`\n\tOfMemoryTool20250818          *MemoryTool20250818Param          `json:\",omitzero,inline\"`\n\tOfTextEditor20250124          *ToolTextEditor20250124Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250429          *ToolTextEditor20250429Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250728          *ToolTextEditor20250728Param      `json:\",omitzero,inline\"`\n\tOfWebSearchTool20250305       *WebSearchTool20250305Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20250910        *WebFetchTool20250910Param        `json:\",omitzero,inline\"`\n\tOfWebSearchTool20260209       *WebSearchTool20260209Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260209        *WebFetchTool20260209Param        `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260309        *WebFetchTool20260309Param        `json:\",omitzero,inline\"`\n\tOfToolSearchToolBm25_20251119 *ToolSearchToolBm25_20251119Param `json:\",omitzero,inline\"`\n\tOfToolSearchToolRegex20251119 *ToolSearchToolRegex20251119Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u MessageCountTokensToolUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfTool,\n\t\tu.OfBashTool20250124,\n\t\tu.OfCodeExecutionTool20250522,\n\t\tu.OfCodeExecutionTool20250825,\n\t\tu.OfCodeExecutionTool20260120,\n\t\tu.OfMemoryTool20250818,\n\t\tu.OfTextEditor20250124,\n\t\tu.OfTextEditor20250429,\n\t\tu.OfTextEditor20250728,\n\t\tu.OfWebSearchTool20250305,\n\t\tu.OfWebFetchTool20250910,\n\t\tu.OfWebSearchTool20260209,\n\t\tu.OfWebFetchTool20260209,\n\t\tu.OfWebFetchTool20260309,\n\t\tu.OfToolSearchToolBm25_20251119,\n\t\tu.OfToolSearchToolRegex20251119)\n}\nfunc (u *MessageCountTokensToolUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *MessageCountTokensToolUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfTool) {\n\t\treturn u.OfTool\n\t} else if !param.IsOmitted(u.OfBashTool20250124) {\n\t\treturn u.OfBashTool20250124\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250522) {\n\t\treturn u.OfCodeExecutionTool20250522\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250825) {\n\t\treturn u.OfCodeExecutionTool20250825\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20260120) {\n\t\treturn u.OfCodeExecutionTool20260120\n\t} else if !param.IsOmitted(u.OfMemoryTool20250818) {\n\t\treturn u.OfMemoryTool20250818\n\t} else if !param.IsOmitted(u.OfTextEditor20250124) {\n\t\treturn u.OfTextEditor20250124\n\t} else if !param.IsOmitted(u.OfTextEditor20250429) {\n\t\treturn u.OfTextEditor20250429\n\t} else if !param.IsOmitted(u.OfTextEditor20250728) {\n\t\treturn u.OfTextEditor20250728\n\t} else if !param.IsOmitted(u.OfWebSearchTool20250305) {\n\t\treturn u.OfWebSearchTool20250305\n\t} else if !param.IsOmitted(u.OfWebFetchTool20250910) {\n\t\treturn u.OfWebFetchTool20250910\n\t} else if !param.IsOmitted(u.OfWebSearchTool20260209) {\n\t\treturn u.OfWebSearchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260209) {\n\t\treturn u.OfWebFetchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260309) {\n\t\treturn u.OfWebFetchTool20260309\n\t} else if !param.IsOmitted(u.OfToolSearchToolBm25_20251119) {\n\t\treturn u.OfToolSearchToolBm25_20251119\n\t} else if !param.IsOmitted(u.OfToolSearchToolRegex20251119) {\n\t\treturn u.OfToolSearchToolRegex20251119\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetInputSchema() *ToolInputSchemaParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.InputSchema\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetDescription() *string {\n\tif vt := u.OfTool; vt != nil && vt.Description.Valid() {\n\t\treturn &vt.Description.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetEagerInputStreaming() *bool {\n\tif vt := u.OfTool; vt != nil && vt.EagerInputStreaming.Valid() {\n\t\treturn &vt.EagerInputStreaming.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetMaxCharacters() *int64 {\n\tif vt := u.OfTextEditor20250728; vt != nil && vt.MaxCharacters.Valid() {\n\t\treturn &vt.MaxCharacters.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetUseCache() *bool {\n\tif vt := u.OfWebFetchTool20260309; vt != nil && vt.UseCache.Valid() {\n\t\treturn &vt.UseCache.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetName() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetDeferLoading() *bool {\n\tif vt := u.OfTool; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetStrict() *bool {\n\tif vt := u.OfTool; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetType() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetMaxUses() *int64 {\n\tif vt := u.OfWebSearchTool20250305; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetMaxContentTokens() *int64 {\n\tif vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedCallers property, if\n// present.\nfunc (u MessageCountTokensToolUnionParam) GetAllowedCallers() []string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetCacheControl() *CacheControlEphemeralParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's InputExamples property, if\n// present.\nfunc (u MessageCountTokensToolUnionParam) GetInputExamples() []map[string]any {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.InputExamples\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedDomains property, if\n// present.\nfunc (u MessageCountTokensToolUnionParam) GetAllowedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's BlockedDomains property, if\n// present.\nfunc (u MessageCountTokensToolUnionParam) GetBlockedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.BlockedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's UserLocation property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetUserLocation() *UserLocationParam {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.UserLocation\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.UserLocation\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's Citations property, if present.\nfunc (u MessageCountTokensToolUnionParam) GetCitations() *CitationsConfigParam {\n\tif vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.Citations\n\t}\n\treturn nil\n}\n\ntype MessageDeltaUsage struct {\n\t// The cumulative number of input tokens used to create the cache entry.\n\tCacheCreationInputTokens int64 `json:\"cache_creation_input_tokens\" api:\"required\"`\n\t// The cumulative number of input tokens read from the cache.\n\tCacheReadInputTokens int64 `json:\"cache_read_input_tokens\" api:\"required\"`\n\t// The cumulative number of input tokens which were used.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// The cumulative number of output tokens which were used.\n\tOutputTokens int64 `json:\"output_tokens\" api:\"required\"`\n\t// The number of server tool requests.\n\tServerToolUse ServerToolUsage `json:\"server_tool_use\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tServerToolUse            respjson.Field\n\t\tExtraFields              map[string]respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageDeltaUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageDeltaUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, Role are required.\ntype MessageParam struct {\n\tContent []ContentBlockParamUnion `json:\"content,omitzero\" api:\"required\"`\n\t// Any of \"user\", \"assistant\".\n\tRole MessageParamRole `json:\"role,omitzero\" api:\"required\"`\n\tparamObj\n}\n\nfunc NewUserMessage(blocks ...ContentBlockParamUnion) MessageParam {\n\treturn MessageParam{\n\t\tRole:    MessageParamRoleUser,\n\t\tContent: blocks,\n\t}\n}\n\nfunc NewAssistantMessage(blocks ...ContentBlockParamUnion) MessageParam {\n\treturn MessageParam{\n\t\tRole:    MessageParamRoleAssistant,\n\t\tContent: blocks,\n\t}\n}\n\nfunc (r MessageParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow MessageParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MessageParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageParamRole string\n\nconst (\n\tMessageParamRoleUser      MessageParamRole = \"user\"\n\tMessageParamRoleAssistant MessageParamRole = \"assistant\"\n)\n\ntype MessageTokensCount struct {\n\t// The total number of tokens across the provided list of messages, system prompt,\n\t// and tools.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tInputTokens respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageTokensCount) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageTokensCount) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MetadataParam struct {\n\t// An external identifier for the user who is associated with the request.\n\t//\n\t// This should be a uuid, hash value, or other opaque identifier. Anthropic may use\n\t// this id to help detect abuse. Do not include any identifying information such as\n\t// name, email address, or phone number.\n\tUserID param.Opt[string] `json:\"user_id,omitzero\"`\n\tparamObj\n}\n\nfunc (r MetadataParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow MetadataParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MetadataParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The model that will complete your prompt.\\n\\nSee\n// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n// details and options.\ntype Model = string\n\nconst (\n\tModelClaudeOpus4_6            Model = \"claude-opus-4-6\"\n\tModelClaudeSonnet4_6          Model = \"claude-sonnet-4-6\"\n\tModelClaudeHaiku4_5           Model = \"claude-haiku-4-5\"\n\tModelClaudeHaiku4_5_20251001  Model = \"claude-haiku-4-5-20251001\"\n\tModelClaudeOpus4_5            Model = \"claude-opus-4-5\"\n\tModelClaudeOpus4_5_20251101   Model = \"claude-opus-4-5-20251101\"\n\tModelClaudeSonnet4_5          Model = \"claude-sonnet-4-5\"\n\tModelClaudeSonnet4_5_20250929 Model = \"claude-sonnet-4-5-20250929\"\n\tModelClaudeOpus4_1            Model = \"claude-opus-4-1\"\n\tModelClaudeOpus4_1_20250805   Model = \"claude-opus-4-1-20250805\"\n\tModelClaudeOpus4_0            Model = \"claude-opus-4-0\"\n\tModelClaudeOpus4_20250514     Model = \"claude-opus-4-20250514\"\n\tModelClaudeSonnet4_0          Model = \"claude-sonnet-4-0\"\n\tModelClaudeSonnet4_20250514   Model = \"claude-sonnet-4-20250514\"\n\t// Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to\n\t// claude-haiku-4-5. Visit\n\t// https://docs.anthropic.com/en/docs/resources/model-deprecations for more\n\t// information.\n\tModelClaude_3_Haiku_20240307 Model = \"claude-3-haiku-20240307\"\n)\n\ntype OutputConfigParam struct {\n\t// All possible effort levels.\n\t//\n\t// Any of \"low\", \"medium\", \"high\", \"max\".\n\tEffort OutputConfigEffort `json:\"effort,omitzero\"`\n\t// A schema to specify Claude's output format in responses. See\n\t// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)\n\tFormat JSONOutputFormatParam `json:\"format,omitzero\"`\n\tparamObj\n}\n\nfunc (r OutputConfigParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow OutputConfigParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *OutputConfigParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// All possible effort levels.\ntype OutputConfigEffort string\n\nconst (\n\tOutputConfigEffortLow    OutputConfigEffort = \"low\"\n\tOutputConfigEffortMedium OutputConfigEffort = \"medium\"\n\tOutputConfigEffortHigh   OutputConfigEffort = \"high\"\n\tOutputConfigEffortMax    OutputConfigEffort = \"max\"\n)\n\ntype PlainTextSource struct {\n\tData      string             `json:\"data\" api:\"required\"`\n\tMediaType constant.TextPlain `json:\"media_type\" api:\"required\"`\n\tType      constant.Text      `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tMediaType   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r PlainTextSource) RawJSON() string { return r.JSON.raw }\nfunc (r *PlainTextSource) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this PlainTextSource to a PlainTextSourceParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// PlainTextSourceParam.Overrides()\nfunc (r PlainTextSource) ToParam() PlainTextSourceParam {\n\treturn param.Override[PlainTextSourceParam](json.RawMessage(r.RawJSON()))\n}\n\n// The properties Data, MediaType, Type are required.\ntype PlainTextSourceParam struct {\n\tData string `json:\"data\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"text/plain\".\n\tMediaType constant.TextPlain `json:\"media_type\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"text\".\n\tType constant.Text `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r PlainTextSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow PlainTextSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *PlainTextSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// RawContentBlockDeltaUnion contains all possible properties and values from\n// [TextDelta], [InputJSONDelta], [CitationsDelta], [ThinkingDelta],\n// [SignatureDelta].\n//\n// Use the [RawContentBlockDeltaUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype RawContentBlockDeltaUnion struct {\n\t// This field is from variant [TextDelta].\n\tText string `json:\"text\"`\n\t// Any of \"text_delta\", \"input_json_delta\", \"citations_delta\", \"thinking_delta\",\n\t// \"signature_delta\".\n\tType string `json:\"type\"`\n\t// This field is from variant [InputJSONDelta].\n\tPartialJSON string `json:\"partial_json\"`\n\t// This field is from variant [CitationsDelta].\n\tCitation CitationsDeltaCitationUnion `json:\"citation\"`\n\t// This field is from variant [ThinkingDelta].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [SignatureDelta].\n\tSignature string `json:\"signature\"`\n\tJSON      struct {\n\t\tText        respjson.Field\n\t\tType        respjson.Field\n\t\tPartialJSON respjson.Field\n\t\tCitation    respjson.Field\n\t\tThinking    respjson.Field\n\t\tSignature   respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// anyRawContentBlockDelta is implemented by each variant of\n// [RawContentBlockDeltaUnion] to add type safety for the return type of\n// [RawContentBlockDeltaUnion.AsAny]\ntype anyRawContentBlockDelta interface {\n\timplRawContentBlockDeltaUnion()\n}\n\nfunc (TextDelta) implRawContentBlockDeltaUnion()      {}\nfunc (InputJSONDelta) implRawContentBlockDeltaUnion() {}\nfunc (CitationsDelta) implRawContentBlockDeltaUnion() {}\nfunc (ThinkingDelta) implRawContentBlockDeltaUnion()  {}\nfunc (SignatureDelta) implRawContentBlockDeltaUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := RawContentBlockDeltaUnion.AsAny().(type) {\n//\tcase anthropic.TextDelta:\n//\tcase anthropic.InputJSONDelta:\n//\tcase anthropic.CitationsDelta:\n//\tcase anthropic.ThinkingDelta:\n//\tcase anthropic.SignatureDelta:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u RawContentBlockDeltaUnion) AsAny() anyRawContentBlockDelta {\n\tswitch u.Type {\n\tcase \"text_delta\":\n\t\treturn u.AsTextDelta()\n\tcase \"input_json_delta\":\n\t\treturn u.AsInputJSONDelta()\n\tcase \"citations_delta\":\n\t\treturn u.AsCitationsDelta()\n\tcase \"thinking_delta\":\n\t\treturn u.AsThinkingDelta()\n\tcase \"signature_delta\":\n\t\treturn u.AsSignatureDelta()\n\t}\n\treturn nil\n}\n\nfunc (u RawContentBlockDeltaUnion) AsTextDelta() (v TextDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u RawContentBlockDeltaUnion) AsInputJSONDelta() (v InputJSONDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u RawContentBlockDeltaUnion) AsCitationsDelta() (v CitationsDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u RawContentBlockDeltaUnion) AsThinkingDelta() (v ThinkingDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u RawContentBlockDeltaUnion) AsSignatureDelta() (v SignatureDelta) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u RawContentBlockDeltaUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *RawContentBlockDeltaUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ContentBlockDeltaEvent struct {\n\tDelta RawContentBlockDeltaUnion  `json:\"delta\" api:\"required\"`\n\tIndex int64                      `json:\"index\" api:\"required\"`\n\tType  constant.ContentBlockDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tDelta       respjson.Field\n\t\tIndex       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ContentBlockDeltaEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *ContentBlockDeltaEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ContentBlockStartEvent struct {\n\t// Response model for a file uploaded to the container.\n\tContentBlock ContentBlockStartEventContentBlockUnion `json:\"content_block\" api:\"required\"`\n\tIndex        int64                                   `json:\"index\" api:\"required\"`\n\tType         constant.ContentBlockStart              `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContentBlock respjson.Field\n\t\tIndex        respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ContentBlockStartEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *ContentBlockStartEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockStartEventContentBlockUnion contains all possible properties and\n// values from [TextBlock], [ThinkingBlock], [RedactedThinkingBlock],\n// [ToolUseBlock], [ServerToolUseBlock], [WebSearchToolResultBlock],\n// [WebFetchToolResultBlock], [CodeExecutionToolResultBlock],\n// [BashCodeExecutionToolResultBlock], [TextEditorCodeExecutionToolResultBlock],\n// [ToolSearchToolResultBlock], [ContainerUploadBlock].\n//\n// Use the [ContentBlockStartEventContentBlockUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype ContentBlockStartEventContentBlockUnion struct {\n\t// This field is from variant [TextBlock].\n\tCitations []TextCitationUnion `json:\"citations\"`\n\t// This field is from variant [TextBlock].\n\tText string `json:\"text\"`\n\t// Any of \"text\", \"thinking\", \"redacted_thinking\", \"tool_use\", \"server_tool_use\",\n\t// \"web_search_tool_result\", \"web_fetch_tool_result\", \"code_execution_tool_result\",\n\t// \"bash_code_execution_tool_result\", \"text_editor_code_execution_tool_result\",\n\t// \"tool_search_tool_result\", \"container_upload\".\n\tType string `json:\"type\"`\n\t// This field is from variant [ThinkingBlock].\n\tSignature string `json:\"signature\"`\n\t// This field is from variant [ThinkingBlock].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [RedactedThinkingBlock].\n\tData string `json:\"data\"`\n\tID   string `json:\"id\"`\n\t// This field is a union of [ToolUseBlockCallerUnion],\n\t// [ServerToolUseBlockCallerUnion], [WebSearchToolResultBlockCallerUnion],\n\t// [WebFetchToolResultBlockCallerUnion]\n\tCaller ContentBlockStartEventContentBlockUnionCaller `json:\"caller\"`\n\tInput  any                                           `json:\"input\"`\n\tName   string                                        `json:\"name\"`\n\t// This field is a union of [WebSearchToolResultBlockContentUnion],\n\t// [WebFetchToolResultBlockContentUnion],\n\t// [CodeExecutionToolResultBlockContentUnion],\n\t// [BashCodeExecutionToolResultBlockContentUnion],\n\t// [TextEditorCodeExecutionToolResultBlockContentUnion],\n\t// [ToolSearchToolResultBlockContentUnion]\n\tContent   ContentBlockStartEventContentBlockUnionContent `json:\"content\"`\n\tToolUseID string                                         `json:\"tool_use_id\"`\n\t// This field is from variant [ContainerUploadBlock].\n\tFileID string `json:\"file_id\"`\n\tJSON   struct {\n\t\tCitations respjson.Field\n\t\tText      respjson.Field\n\t\tType      respjson.Field\n\t\tSignature respjson.Field\n\t\tThinking  respjson.Field\n\t\tData      respjson.Field\n\t\tID        respjson.Field\n\t\tCaller    respjson.Field\n\t\tInput     respjson.Field\n\t\tName      respjson.Field\n\t\tContent   respjson.Field\n\t\tToolUseID respjson.Field\n\t\tFileID    respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\n// anyContentBlockStartEventContentBlock is implemented by each variant of\n// [ContentBlockStartEventContentBlockUnion] to add type safety for the return type\n// of [ContentBlockStartEventContentBlockUnion.AsAny]\ntype anyContentBlockStartEventContentBlock interface {\n\timplContentBlockStartEventContentBlockUnion()\n}\n\nfunc (TextBlock) implContentBlockStartEventContentBlockUnion()                              {}\nfunc (ThinkingBlock) implContentBlockStartEventContentBlockUnion()                          {}\nfunc (RedactedThinkingBlock) implContentBlockStartEventContentBlockUnion()                  {}\nfunc (ToolUseBlock) implContentBlockStartEventContentBlockUnion()                           {}\nfunc (ServerToolUseBlock) implContentBlockStartEventContentBlockUnion()                     {}\nfunc (WebSearchToolResultBlock) implContentBlockStartEventContentBlockUnion()               {}\nfunc (WebFetchToolResultBlock) implContentBlockStartEventContentBlockUnion()                {}\nfunc (CodeExecutionToolResultBlock) implContentBlockStartEventContentBlockUnion()           {}\nfunc (BashCodeExecutionToolResultBlock) implContentBlockStartEventContentBlockUnion()       {}\nfunc (TextEditorCodeExecutionToolResultBlock) implContentBlockStartEventContentBlockUnion() {}\nfunc (ToolSearchToolResultBlock) implContentBlockStartEventContentBlockUnion()              {}\nfunc (ContainerUploadBlock) implContentBlockStartEventContentBlockUnion()                   {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := ContentBlockStartEventContentBlockUnion.AsAny().(type) {\n//\tcase anthropic.TextBlock:\n//\tcase anthropic.ThinkingBlock:\n//\tcase anthropic.RedactedThinkingBlock:\n//\tcase anthropic.ToolUseBlock:\n//\tcase anthropic.ServerToolUseBlock:\n//\tcase anthropic.WebSearchToolResultBlock:\n//\tcase anthropic.WebFetchToolResultBlock:\n//\tcase anthropic.CodeExecutionToolResultBlock:\n//\tcase anthropic.BashCodeExecutionToolResultBlock:\n//\tcase anthropic.TextEditorCodeExecutionToolResultBlock:\n//\tcase anthropic.ToolSearchToolResultBlock:\n//\tcase anthropic.ContainerUploadBlock:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u ContentBlockStartEventContentBlockUnion) AsAny() anyContentBlockStartEventContentBlock {\n\tswitch u.Type {\n\tcase \"text\":\n\t\treturn u.AsText()\n\tcase \"thinking\":\n\t\treturn u.AsThinking()\n\tcase \"redacted_thinking\":\n\t\treturn u.AsRedactedThinking()\n\tcase \"tool_use\":\n\t\treturn u.AsToolUse()\n\tcase \"server_tool_use\":\n\t\treturn u.AsServerToolUse()\n\tcase \"web_search_tool_result\":\n\t\treturn u.AsWebSearchToolResult()\n\tcase \"web_fetch_tool_result\":\n\t\treturn u.AsWebFetchToolResult()\n\tcase \"code_execution_tool_result\":\n\t\treturn u.AsCodeExecutionToolResult()\n\tcase \"bash_code_execution_tool_result\":\n\t\treturn u.AsBashCodeExecutionToolResult()\n\tcase \"text_editor_code_execution_tool_result\":\n\t\treturn u.AsTextEditorCodeExecutionToolResult()\n\tcase \"tool_search_tool_result\":\n\t\treturn u.AsToolSearchToolResult()\n\tcase \"container_upload\":\n\t\treturn u.AsContainerUpload()\n\t}\n\treturn nil\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsText() (v TextBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsThinking() (v ThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsToolUse() (v ToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsWebFetchToolResult() (v WebFetchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult() (v CodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsBashCodeExecutionToolResult() (v BashCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v TextEditorCodeExecutionToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsToolSearchToolResult() (v ToolSearchToolResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ContentBlockStartEventContentBlockUnion) AsContainerUpload() (v ContainerUploadBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u ContentBlockStartEventContentBlockUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *ContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockStartEventContentBlockUnionCaller is an implicit subunion of\n// [ContentBlockStartEventContentBlockUnion].\n// ContentBlockStartEventContentBlockUnionCaller provides convenient access to the\n// sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [ContentBlockStartEventContentBlockUnion].\ntype ContentBlockStartEventContentBlockUnionCaller struct {\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\nfunc (r *ContentBlockStartEventContentBlockUnionCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockStartEventContentBlockUnionContent is an implicit subunion of\n// [ContentBlockStartEventContentBlockUnion].\n// ContentBlockStartEventContentBlockUnionContent provides convenient access to the\n// sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [ContentBlockStartEventContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfWebSearchResultBlockArray]\ntype ContentBlockStartEventContentBlockUnionContent struct {\n\t// This field will be present if the value is a [[]WebSearchResultBlock] instead of\n\t// an object.\n\tOfWebSearchResultBlockArray []WebSearchResultBlock `json:\",inline\"`\n\tErrorCode                   string                 `json:\"error_code\"`\n\tType                        string                 `json:\"type\"`\n\t// This field is a union of [DocumentBlock], [[]CodeExecutionOutputBlock],\n\t// [[]CodeExecutionOutputBlock], [[]BashCodeExecutionOutputBlock], [string]\n\tContent ContentBlockStartEventContentBlockUnionContentContent `json:\"content\"`\n\t// This field is from variant [WebFetchToolResultBlockContentUnion].\n\tRetrievedAt string `json:\"retrieved_at\"`\n\t// This field is from variant [WebFetchToolResultBlockContentUnion].\n\tURL        string `json:\"url\"`\n\tReturnCode int64  `json:\"return_code\"`\n\tStderr     string `json:\"stderr\"`\n\tStdout     string `json:\"stdout\"`\n\t// This field is from variant [CodeExecutionToolResultBlockContentUnion].\n\tEncryptedStdout string `json:\"encrypted_stdout\"`\n\tErrorMessage    string `json:\"error_message\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tFileType TextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tNumLines int64 `json:\"num_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tStartLine int64 `json:\"start_line\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tTotalLines int64 `json:\"total_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tIsFileUpdate bool `json:\"is_file_update\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tLines []string `json:\"lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewLines int64 `json:\"new_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tNewStart int64 `json:\"new_start\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldLines int64 `json:\"old_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].\n\tOldStart int64 `json:\"old_start\"`\n\t// This field is from variant [ToolSearchToolResultBlockContentUnion].\n\tToolReferences []ToolReferenceBlock `json:\"tool_references\"`\n\tJSON           struct {\n\t\tOfWebSearchResultBlockArray respjson.Field\n\t\tErrorCode                   respjson.Field\n\t\tType                        respjson.Field\n\t\tContent                     respjson.Field\n\t\tRetrievedAt                 respjson.Field\n\t\tURL                         respjson.Field\n\t\tReturnCode                  respjson.Field\n\t\tStderr                      respjson.Field\n\t\tStdout                      respjson.Field\n\t\tEncryptedStdout             respjson.Field\n\t\tErrorMessage                respjson.Field\n\t\tFileType                    respjson.Field\n\t\tNumLines                    respjson.Field\n\t\tStartLine                   respjson.Field\n\t\tTotalLines                  respjson.Field\n\t\tIsFileUpdate                respjson.Field\n\t\tLines                       respjson.Field\n\t\tNewLines                    respjson.Field\n\t\tNewStart                    respjson.Field\n\t\tOldLines                    respjson.Field\n\t\tOldStart                    respjson.Field\n\t\tToolReferences              respjson.Field\n\t\traw                         string\n\t} `json:\"-\"`\n}\n\nfunc (r *ContentBlockStartEventContentBlockUnionContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ContentBlockStartEventContentBlockUnionContentContent is an implicit subunion of\n// [ContentBlockStartEventContentBlockUnion].\n// ContentBlockStartEventContentBlockUnionContentContent provides convenient access\n// to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [ContentBlockStartEventContentBlockUnion].\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfContent OfString]\ntype ContentBlockStartEventContentBlockUnionContentContent struct {\n\t// This field will be present if the value is a [[]CodeExecutionOutputBlock]\n\t// instead of an object.\n\tOfContent []CodeExecutionOutputBlock `json:\",inline\"`\n\t// This field will be present if the value is a [string] instead of an object.\n\tOfString string `json:\",inline\"`\n\t// This field is from variant [DocumentBlock].\n\tCitations CitationsConfig `json:\"citations\"`\n\t// This field is from variant [DocumentBlock].\n\tSource DocumentBlockSourceUnion `json:\"source\"`\n\t// This field is from variant [DocumentBlock].\n\tTitle string `json:\"title\"`\n\t// This field is from variant [DocumentBlock].\n\tType constant.Document `json:\"type\"`\n\tJSON struct {\n\t\tOfContent respjson.Field\n\t\tOfString  respjson.Field\n\t\tCitations respjson.Field\n\t\tSource    respjson.Field\n\t\tTitle     respjson.Field\n\t\tType      respjson.Field\n\t\traw       string\n\t} `json:\"-\"`\n}\n\nfunc (r *ContentBlockStartEventContentBlockUnionContentContent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ContentBlockStopEvent struct {\n\tIndex int64                     `json:\"index\" api:\"required\"`\n\tType  constant.ContentBlockStop `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tIndex       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ContentBlockStopEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *ContentBlockStopEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageDeltaEvent struct {\n\tDelta MessageDeltaEventDelta `json:\"delta\" api:\"required\"`\n\tType  constant.MessageDelta  `json:\"type\" api:\"required\"`\n\t// Billing and rate-limit usage.\n\t//\n\t// Anthropic's API bills and rate-limits by token counts, as tokens represent the\n\t// underlying cost to our systems.\n\t//\n\t// Under the hood, the API transforms requests into a format suitable for the\n\t// model. The model's output then goes through a parsing stage before becoming an\n\t// API response. As a result, the token counts in `usage` will not match one-to-one\n\t// with the exact visible content of an API request or response.\n\t//\n\t// For example, `output_tokens` will be non-zero, even for an empty string response\n\t// from Claude.\n\t//\n\t// Total input tokens in a request is the summation of `input_tokens`,\n\t// `cache_creation_input_tokens`, and `cache_read_input_tokens`.\n\tUsage MessageDeltaUsage `json:\"usage\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tDelta       respjson.Field\n\t\tType        respjson.Field\n\t\tUsage       respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageDeltaEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageDeltaEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageDeltaEventDelta struct {\n\t// Information about the container used in the request (for the code execution\n\t// tool)\n\tContainer Container `json:\"container\" api:\"required\"`\n\t// Any of \"end_turn\", \"max_tokens\", \"stop_sequence\", \"tool_use\", \"pause_turn\",\n\t// \"refusal\".\n\tStopReason   StopReason `json:\"stop_reason\" api:\"required\"`\n\tStopSequence string     `json:\"stop_sequence\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContainer    respjson.Field\n\t\tStopReason   respjson.Field\n\t\tStopSequence respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageDeltaEventDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageDeltaEventDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageStartEvent struct {\n\tMessage Message               `json:\"message\" api:\"required\"`\n\tType    constant.MessageStart `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageStartEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageStartEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageStopEvent struct {\n\tType constant.MessageStop `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageStopEvent) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageStopEvent) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// MessageStreamEventUnion contains all possible properties and values from\n// [MessageStartEvent], [MessageDeltaEvent], [MessageStopEvent],\n// [ContentBlockStartEvent], [ContentBlockDeltaEvent], [ContentBlockStopEvent].\n//\n// Use the [MessageStreamEventUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype MessageStreamEventUnion struct {\n\t// This field is from variant [MessageStartEvent].\n\tMessage Message `json:\"message\"`\n\t// Any of \"message_start\", \"message_delta\", \"message_stop\", \"content_block_start\",\n\t// \"content_block_delta\", \"content_block_stop\".\n\tType string `json:\"type\"`\n\t// This field is a union of [MessageDeltaEventDelta], [RawContentBlockDeltaUnion]\n\tDelta MessageStreamEventUnionDelta `json:\"delta\"`\n\t// This field is from variant [MessageDeltaEvent].\n\tUsage MessageDeltaUsage `json:\"usage\"`\n\t// This field is from variant [ContentBlockStartEvent].\n\tContentBlock ContentBlockStartEventContentBlockUnion `json:\"content_block\"`\n\tIndex        int64                                   `json:\"index\"`\n\tJSON         struct {\n\t\tMessage      respjson.Field\n\t\tType         respjson.Field\n\t\tDelta        respjson.Field\n\t\tUsage        respjson.Field\n\t\tContentBlock respjson.Field\n\t\tIndex        respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// anyMessageStreamEvent is implemented by each variant of\n// [MessageStreamEventUnion] to add type safety for the return type of\n// [MessageStreamEventUnion.AsAny]\ntype anyMessageStreamEvent interface {\n\timplMessageStreamEventUnion()\n}\n\nfunc (MessageStartEvent) implMessageStreamEventUnion()      {}\nfunc (MessageDeltaEvent) implMessageStreamEventUnion()      {}\nfunc (MessageStopEvent) implMessageStreamEventUnion()       {}\nfunc (ContentBlockStartEvent) implMessageStreamEventUnion() {}\nfunc (ContentBlockDeltaEvent) implMessageStreamEventUnion() {}\nfunc (ContentBlockStopEvent) implMessageStreamEventUnion()  {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := MessageStreamEventUnion.AsAny().(type) {\n//\tcase anthropic.MessageStartEvent:\n//\tcase anthropic.MessageDeltaEvent:\n//\tcase anthropic.MessageStopEvent:\n//\tcase anthropic.ContentBlockStartEvent:\n//\tcase anthropic.ContentBlockDeltaEvent:\n//\tcase anthropic.ContentBlockStopEvent:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u MessageStreamEventUnion) AsAny() anyMessageStreamEvent {\n\tswitch u.Type {\n\tcase \"message_start\":\n\t\treturn u.AsMessageStart()\n\tcase \"message_delta\":\n\t\treturn u.AsMessageDelta()\n\tcase \"message_stop\":\n\t\treturn u.AsMessageStop()\n\tcase \"content_block_start\":\n\t\treturn u.AsContentBlockStart()\n\tcase \"content_block_delta\":\n\t\treturn u.AsContentBlockDelta()\n\tcase \"content_block_stop\":\n\t\treturn u.AsContentBlockStop()\n\t}\n\treturn nil\n}\n\nfunc (u MessageStreamEventUnion) AsMessageStart() (v MessageStartEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageStreamEventUnion) AsMessageDelta() (v MessageDeltaEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageStreamEventUnion) AsMessageStop() (v MessageStopEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageStreamEventUnion) AsContentBlockStart() (v ContentBlockStartEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageStreamEventUnion) AsContentBlockDelta() (v ContentBlockDeltaEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageStreamEventUnion) AsContentBlockStop() (v ContentBlockStopEvent) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u MessageStreamEventUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *MessageStreamEventUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// MessageStreamEventUnionDelta is an implicit subunion of\n// [MessageStreamEventUnion]. MessageStreamEventUnionDelta provides convenient\n// access to the sub-properties of the union.\n//\n// For type safety it is recommended to directly use a variant of the\n// [MessageStreamEventUnion].\ntype MessageStreamEventUnionDelta struct {\n\t// This field is from variant [MessageDeltaEventDelta].\n\tContainer Container `json:\"container\"`\n\t// This field is from variant [MessageDeltaEventDelta].\n\tStopReason StopReason `json:\"stop_reason\"`\n\t// This field is from variant [MessageDeltaEventDelta].\n\tStopSequence string `json:\"stop_sequence\"`\n\t// This field is from variant [RawContentBlockDeltaUnion].\n\tText string `json:\"text\"`\n\tType string `json:\"type\"`\n\t// This field is from variant [RawContentBlockDeltaUnion].\n\tPartialJSON string `json:\"partial_json\"`\n\t// This field is from variant [RawContentBlockDeltaUnion].\n\tCitation CitationsDeltaCitationUnion `json:\"citation\"`\n\t// This field is from variant [RawContentBlockDeltaUnion].\n\tThinking string `json:\"thinking\"`\n\t// This field is from variant [RawContentBlockDeltaUnion].\n\tSignature string `json:\"signature\"`\n\tJSON      struct {\n\t\tContainer    respjson.Field\n\t\tStopReason   respjson.Field\n\t\tStopSequence respjson.Field\n\t\tText         respjson.Field\n\t\tType         respjson.Field\n\t\tPartialJSON  respjson.Field\n\t\tCitation     respjson.Field\n\t\tThinking     respjson.Field\n\t\tSignature    respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\nfunc (r *MessageStreamEventUnionDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype RedactedThinkingBlock struct {\n\tData string                    `json:\"data\" api:\"required\"`\n\tType constant.RedactedThinking `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r RedactedThinkingBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *RedactedThinkingBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Data, Type are required.\ntype RedactedThinkingBlockParam struct {\n\tData string `json:\"data\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"redacted_thinking\".\n\tType constant.RedactedThinking `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r RedactedThinkingBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow RedactedThinkingBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *RedactedThinkingBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, Source, Title, Type are required.\ntype SearchResultBlockParam struct {\n\tContent []TextBlockParam `json:\"content,omitzero\" api:\"required\"`\n\tSource  string           `json:\"source\" api:\"required\"`\n\tTitle   string           `json:\"title\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tCitations    CitationsConfigParam       `json:\"citations,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"search_result\".\n\tType constant.SearchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r SearchResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow SearchResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *SearchResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Tool invocation generated by a server-side tool.\ntype ServerToolCaller struct {\n\tToolID string                         `json:\"tool_id\" api:\"required\"`\n\tType   constant.CodeExecution20250825 `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ServerToolCaller) RawJSON() string { return r.JSON.raw }\nfunc (r *ServerToolCaller) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this ServerToolCaller to a ServerToolCallerParam.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// ServerToolCallerParam.Overrides()\nfunc (r ServerToolCaller) ToParam() ServerToolCallerParam {\n\treturn param.Override[ServerToolCallerParam](json.RawMessage(r.RawJSON()))\n}\n\n// Tool invocation generated by a server-side tool.\n//\n// The properties ToolID, Type are required.\ntype ServerToolCallerParam struct {\n\tToolID string `json:\"tool_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20250825\".\n\tType constant.CodeExecution20250825 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ServerToolCallerParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ServerToolCallerParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ServerToolCallerParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ServerToolCaller20260120 struct {\n\tToolID string                         `json:\"tool_id\" api:\"required\"`\n\tType   constant.CodeExecution20260120 `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolID      respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ServerToolCaller20260120) RawJSON() string { return r.JSON.raw }\nfunc (r *ServerToolCaller20260120) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToParam converts this ServerToolCaller20260120 to a\n// ServerToolCaller20260120Param.\n//\n// Warning: the fields of the param type will not be present. ToParam should only\n// be used at the last possible moment before sending a request. Test for this with\n// ServerToolCaller20260120Param.Overrides()\nfunc (r ServerToolCaller20260120) ToParam() ServerToolCaller20260120Param {\n\treturn param.Override[ServerToolCaller20260120Param](json.RawMessage(r.RawJSON()))\n}\n\n// The properties ToolID, Type are required.\ntype ServerToolCaller20260120Param struct {\n\tToolID string `json:\"tool_id\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"code_execution_20260120\".\n\tType constant.CodeExecution20260120 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ServerToolCaller20260120Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ServerToolCaller20260120Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ServerToolCaller20260120Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ServerToolUsage struct {\n\t// The number of web fetch tool requests.\n\tWebFetchRequests int64 `json:\"web_fetch_requests\" api:\"required\"`\n\t// The number of web search tool requests.\n\tWebSearchRequests int64 `json:\"web_search_requests\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tWebFetchRequests  respjson.Field\n\t\tWebSearchRequests respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ServerToolUsage) RawJSON() string { return r.JSON.raw }\nfunc (r *ServerToolUsage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ServerToolUseBlock struct {\n\tID string `json:\"id\" api:\"required\"`\n\t// Tool invocation directly from the model.\n\tCaller ServerToolUseBlockCallerUnion `json:\"caller\" api:\"required\"`\n\tInput  any                           `json:\"input\" api:\"required\"`\n\t// Any of \"web_search\", \"web_fetch\", \"code_execution\", \"bash_code_execution\",\n\t// \"text_editor_code_execution\", \"tool_search_tool_regex\", \"tool_search_tool_bm25\".\n\tName ServerToolUseBlockName `json:\"name\" api:\"required\"`\n\tType constant.ServerToolUse `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tCaller      respjson.Field\n\t\tInput       respjson.Field\n\t\tName        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ServerToolUseBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ServerToolUseBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ServerToolUseBlockCallerUnion contains all possible properties and values from\n// [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120].\n//\n// Use the [ServerToolUseBlockCallerUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype ServerToolUseBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyServerToolUseBlockCaller is implemented by each variant of\n// [ServerToolUseBlockCallerUnion] to add type safety for the return type of\n// [ServerToolUseBlockCallerUnion.AsAny]\ntype anyServerToolUseBlockCaller interface {\n\timplServerToolUseBlockCallerUnion()\n}\n\nfunc (DirectCaller) implServerToolUseBlockCallerUnion()             {}\nfunc (ServerToolCaller) implServerToolUseBlockCallerUnion()         {}\nfunc (ServerToolCaller20260120) implServerToolUseBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := ServerToolUseBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.DirectCaller:\n//\tcase anthropic.ServerToolCaller:\n//\tcase anthropic.ServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u ServerToolUseBlockCallerUnion) AsAny() anyServerToolUseBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u ServerToolUseBlockCallerUnion) AsDirect() (v DirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ServerToolUseBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ServerToolUseBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u ServerToolUseBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *ServerToolUseBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ServerToolUseBlockName string\n\nconst (\n\tServerToolUseBlockNameWebSearch               ServerToolUseBlockName = \"web_search\"\n\tServerToolUseBlockNameWebFetch                ServerToolUseBlockName = \"web_fetch\"\n\tServerToolUseBlockNameCodeExecution           ServerToolUseBlockName = \"code_execution\"\n\tServerToolUseBlockNameBashCodeExecution       ServerToolUseBlockName = \"bash_code_execution\"\n\tServerToolUseBlockNameTextEditorCodeExecution ServerToolUseBlockName = \"text_editor_code_execution\"\n\tServerToolUseBlockNameToolSearchToolRegex     ServerToolUseBlockName = \"tool_search_tool_regex\"\n\tServerToolUseBlockNameToolSearchToolBm25      ServerToolUseBlockName = \"tool_search_tool_bm25\"\n)\n\n// The properties ID, Input, Name, Type are required.\ntype ServerToolUseBlockParam struct {\n\tID    string         `json:\"id\" api:\"required\"`\n\tInput any            `json:\"input,omitzero\" api:\"required\"`\n\t// Any of \"web_search\", \"web_fetch\", \"code_execution\", \"bash_code_execution\",\n\t// \"text_editor_code_execution\", \"tool_search_tool_regex\", \"tool_search_tool_bm25\".\n\tName ServerToolUseBlockParamName `json:\"name,omitzero\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller ServerToolUseBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"server_tool_use\".\n\tType constant.ServerToolUse `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ServerToolUseBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ServerToolUseBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ServerToolUseBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ServerToolUseBlockParamName string\n\nconst (\n\tServerToolUseBlockParamNameWebSearch               ServerToolUseBlockParamName = \"web_search\"\n\tServerToolUseBlockParamNameWebFetch                ServerToolUseBlockParamName = \"web_fetch\"\n\tServerToolUseBlockParamNameCodeExecution           ServerToolUseBlockParamName = \"code_execution\"\n\tServerToolUseBlockParamNameBashCodeExecution       ServerToolUseBlockParamName = \"bash_code_execution\"\n\tServerToolUseBlockParamNameTextEditorCodeExecution ServerToolUseBlockParamName = \"text_editor_code_execution\"\n\tServerToolUseBlockParamNameToolSearchToolRegex     ServerToolUseBlockParamName = \"tool_search_tool_regex\"\n\tServerToolUseBlockParamNameToolSearchToolBm25      ServerToolUseBlockParamName = \"tool_search_tool_bm25\"\n)\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ServerToolUseBlockParamCallerUnion struct {\n\tOfDirect                *DirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *ServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *ServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ServerToolUseBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *ServerToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ServerToolUseBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ServerToolUseBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ServerToolUseBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\ntype SignatureDelta struct {\n\tSignature string                  `json:\"signature\" api:\"required\"`\n\tType      constant.SignatureDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSignature   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r SignatureDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *SignatureDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype StopReason string\n\nconst (\n\tStopReasonEndTurn      StopReason = \"end_turn\"\n\tStopReasonMaxTokens    StopReason = \"max_tokens\"\n\tStopReasonStopSequence StopReason = \"stop_sequence\"\n\tStopReasonToolUse      StopReason = \"tool_use\"\n\tStopReasonPauseTurn    StopReason = \"pause_turn\"\n\tStopReasonRefusal      StopReason = \"refusal\"\n)\n\ntype TextBlock struct {\n\t// Citations supporting the text block.\n\t//\n\t// The type of citation returned will depend on the type of document being cited.\n\t// Citing a PDF results in `page_location`, plain text results in `char_location`,\n\t// and content document results in `content_block_location`.\n\tCitations []TextCitationUnion `json:\"citations\" api:\"required\"`\n\tText      string              `json:\"text\" api:\"required\"`\n\tType      constant.Text       `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCitations   respjson.Field\n\t\tText        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *TextBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Text, Type are required.\ntype TextBlockParam struct {\n\tText      string                   `json:\"text\" api:\"required\"`\n\tCitations []TextCitationParamUnion `json:\"citations,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"text\".\n\tType constant.Text `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r TextBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow TextBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *TextBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// TextCitationUnion contains all possible properties and values from\n// [CitationCharLocation], [CitationPageLocation], [CitationContentBlockLocation],\n// [CitationsWebSearchResultLocation], [CitationsSearchResultLocation].\n//\n// Use the [TextCitationUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype TextCitationUnion struct {\n\tCitedText     string `json:\"cited_text\"`\n\tDocumentIndex int64  `json:\"document_index\"`\n\tDocumentTitle string `json:\"document_title\"`\n\t// This field is from variant [CitationCharLocation].\n\tEndCharIndex int64  `json:\"end_char_index\"`\n\tFileID       string `json:\"file_id\"`\n\t// This field is from variant [CitationCharLocation].\n\tStartCharIndex int64 `json:\"start_char_index\"`\n\t// Any of \"char_location\", \"page_location\", \"content_block_location\",\n\t// \"web_search_result_location\", \"search_result_location\".\n\tType string `json:\"type\"`\n\t// This field is from variant [CitationPageLocation].\n\tEndPageNumber int64 `json:\"end_page_number\"`\n\t// This field is from variant [CitationPageLocation].\n\tStartPageNumber int64 `json:\"start_page_number\"`\n\tEndBlockIndex   int64 `json:\"end_block_index\"`\n\tStartBlockIndex int64 `json:\"start_block_index\"`\n\t// This field is from variant [CitationsWebSearchResultLocation].\n\tEncryptedIndex string `json:\"encrypted_index\"`\n\tTitle          string `json:\"title\"`\n\t// This field is from variant [CitationsWebSearchResultLocation].\n\tURL string `json:\"url\"`\n\t// This field is from variant [CitationsSearchResultLocation].\n\tSearchResultIndex int64 `json:\"search_result_index\"`\n\t// This field is from variant [CitationsSearchResultLocation].\n\tSource string `json:\"source\"`\n\tJSON   struct {\n\t\tCitedText         respjson.Field\n\t\tDocumentIndex     respjson.Field\n\t\tDocumentTitle     respjson.Field\n\t\tEndCharIndex      respjson.Field\n\t\tFileID            respjson.Field\n\t\tStartCharIndex    respjson.Field\n\t\tType              respjson.Field\n\t\tEndPageNumber     respjson.Field\n\t\tStartPageNumber   respjson.Field\n\t\tEndBlockIndex     respjson.Field\n\t\tStartBlockIndex   respjson.Field\n\t\tEncryptedIndex    respjson.Field\n\t\tTitle             respjson.Field\n\t\tURL               respjson.Field\n\t\tSearchResultIndex respjson.Field\n\t\tSource            respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// anyTextCitation is implemented by each variant of [TextCitationUnion] to add\n// type safety for the return type of [TextCitationUnion.AsAny]\ntype anyTextCitation interface {\n\timplTextCitationUnion()\n\ttoParamUnion() TextCitationParamUnion\n}\n\nfunc (CitationCharLocation) implTextCitationUnion()             {}\nfunc (CitationPageLocation) implTextCitationUnion()             {}\nfunc (CitationContentBlockLocation) implTextCitationUnion()     {}\nfunc (CitationsWebSearchResultLocation) implTextCitationUnion() {}\nfunc (CitationsSearchResultLocation) implTextCitationUnion()    {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := TextCitationUnion.AsAny().(type) {\n//\tcase anthropic.CitationCharLocation:\n//\tcase anthropic.CitationPageLocation:\n//\tcase anthropic.CitationContentBlockLocation:\n//\tcase anthropic.CitationsWebSearchResultLocation:\n//\tcase anthropic.CitationsSearchResultLocation:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u TextCitationUnion) AsAny() anyTextCitation {\n\tswitch u.Type {\n\tcase \"char_location\":\n\t\treturn u.AsCharLocation()\n\tcase \"page_location\":\n\t\treturn u.AsPageLocation()\n\tcase \"content_block_location\":\n\t\treturn u.AsContentBlockLocation()\n\tcase \"web_search_result_location\":\n\t\treturn u.AsWebSearchResultLocation()\n\tcase \"search_result_location\":\n\t\treturn u.AsSearchResultLocation()\n\t}\n\treturn nil\n}\n\nfunc (u TextCitationUnion) AsCharLocation() (v CitationCharLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextCitationUnion) AsPageLocation() (v CitationPageLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextCitationUnion) AsSearchResultLocation() (v CitationsSearchResultLocation) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u TextCitationUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *TextCitationUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype TextCitationParamUnion struct {\n\tOfCharLocation            *CitationCharLocationParam            `json:\",omitzero,inline\"`\n\tOfPageLocation            *CitationPageLocationParam            `json:\",omitzero,inline\"`\n\tOfContentBlockLocation    *CitationContentBlockLocationParam    `json:\",omitzero,inline\"`\n\tOfWebSearchResultLocation *CitationWebSearchResultLocationParam `json:\",omitzero,inline\"`\n\tOfSearchResultLocation    *CitationSearchResultLocationParam    `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u TextCitationParamUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfCharLocation,\n\t\tu.OfPageLocation,\n\t\tu.OfContentBlockLocation,\n\t\tu.OfWebSearchResultLocation,\n\t\tu.OfSearchResultLocation)\n}\nfunc (u *TextCitationParamUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *TextCitationParamUnion) asAny() any {\n\tif !param.IsOmitted(u.OfCharLocation) {\n\t\treturn u.OfCharLocation\n\t} else if !param.IsOmitted(u.OfPageLocation) {\n\t\treturn u.OfPageLocation\n\t} else if !param.IsOmitted(u.OfContentBlockLocation) {\n\t\treturn u.OfContentBlockLocation\n\t} else if !param.IsOmitted(u.OfWebSearchResultLocation) {\n\t\treturn u.OfWebSearchResultLocation\n\t} else if !param.IsOmitted(u.OfSearchResultLocation) {\n\t\treturn u.OfSearchResultLocation\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetEndCharIndex() *int64 {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn &vt.EndCharIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetStartCharIndex() *int64 {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn &vt.StartCharIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetEndPageNumber() *int64 {\n\tif vt := u.OfPageLocation; vt != nil {\n\t\treturn &vt.EndPageNumber\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetStartPageNumber() *int64 {\n\tif vt := u.OfPageLocation; vt != nil {\n\t\treturn &vt.StartPageNumber\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetEncryptedIndex() *string {\n\tif vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn &vt.EncryptedIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetURL() *string {\n\tif vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetSearchResultIndex() *int64 {\n\tif vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn &vt.SearchResultIndex\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetSource() *string {\n\tif vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn &vt.Source\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetCitedText() *string {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfPageLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.CitedText)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetDocumentIndex() *int64 {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn (*int64)(&vt.DocumentIndex)\n\t} else if vt := u.OfPageLocation; vt != nil {\n\t\treturn (*int64)(&vt.DocumentIndex)\n\t} else if vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*int64)(&vt.DocumentIndex)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetDocumentTitle() *string {\n\tif vt := u.OfCharLocation; vt != nil && vt.DocumentTitle.Valid() {\n\t\treturn &vt.DocumentTitle.Value\n\t} else if vt := u.OfPageLocation; vt != nil && vt.DocumentTitle.Valid() {\n\t\treturn &vt.DocumentTitle.Value\n\t} else if vt := u.OfContentBlockLocation; vt != nil && vt.DocumentTitle.Valid() {\n\t\treturn &vt.DocumentTitle.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetType() *string {\n\tif vt := u.OfCharLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfPageLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetEndBlockIndex() *int64 {\n\tif vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*int64)(&vt.EndBlockIndex)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*int64)(&vt.EndBlockIndex)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetStartBlockIndex() *int64 {\n\tif vt := u.OfContentBlockLocation; vt != nil {\n\t\treturn (*int64)(&vt.StartBlockIndex)\n\t} else if vt := u.OfSearchResultLocation; vt != nil {\n\t\treturn (*int64)(&vt.StartBlockIndex)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextCitationParamUnion) GetTitle() *string {\n\tif vt := u.OfWebSearchResultLocation; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t} else if vt := u.OfSearchResultLocation; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t}\n\treturn nil\n}\n\ntype TextDelta struct {\n\tText string             `json:\"text\" api:\"required\"`\n\tType constant.TextDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tText        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *TextDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionCreateResultBlock struct {\n\tIsFileUpdate bool                                         `json:\"is_file_update\" api:\"required\"`\n\tType         constant.TextEditorCodeExecutionCreateResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tIsFileUpdate respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextEditorCodeExecutionCreateResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *TextEditorCodeExecutionCreateResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties IsFileUpdate, Type are required.\ntype TextEditorCodeExecutionCreateResultBlockParam struct {\n\tIsFileUpdate bool `json:\"is_file_update\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_create_result\".\n\tType constant.TextEditorCodeExecutionCreateResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r TextEditorCodeExecutionCreateResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow TextEditorCodeExecutionCreateResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *TextEditorCodeExecutionCreateResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionStrReplaceResultBlock struct {\n\tLines    []string                                         `json:\"lines\" api:\"required\"`\n\tNewLines int64                                            `json:\"new_lines\" api:\"required\"`\n\tNewStart int64                                            `json:\"new_start\" api:\"required\"`\n\tOldLines int64                                            `json:\"old_lines\" api:\"required\"`\n\tOldStart int64                                            `json:\"old_start\" api:\"required\"`\n\tType     constant.TextEditorCodeExecutionStrReplaceResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tLines       respjson.Field\n\t\tNewLines    respjson.Field\n\t\tNewStart    respjson.Field\n\t\tOldLines    respjson.Field\n\t\tOldStart    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextEditorCodeExecutionStrReplaceResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *TextEditorCodeExecutionStrReplaceResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The property Type is required.\ntype TextEditorCodeExecutionStrReplaceResultBlockParam struct {\n\tNewLines param.Opt[int64] `json:\"new_lines,omitzero\"`\n\tNewStart param.Opt[int64] `json:\"new_start,omitzero\"`\n\tOldLines param.Opt[int64] `json:\"old_lines,omitzero\"`\n\tOldStart param.Opt[int64] `json:\"old_start,omitzero\"`\n\tLines    []string         `json:\"lines,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_str_replace_result\".\n\tType constant.TextEditorCodeExecutionStrReplaceResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r TextEditorCodeExecutionStrReplaceResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow TextEditorCodeExecutionStrReplaceResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *TextEditorCodeExecutionStrReplaceResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionToolResultBlock struct {\n\tContent   TextEditorCodeExecutionToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                             `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.TextEditorCodeExecutionToolResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextEditorCodeExecutionToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *TextEditorCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// TextEditorCodeExecutionToolResultBlockContentUnion contains all possible\n// properties and values from [TextEditorCodeExecutionToolResultError],\n// [TextEditorCodeExecutionViewResultBlock],\n// [TextEditorCodeExecutionCreateResultBlock],\n// [TextEditorCodeExecutionStrReplaceResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype TextEditorCodeExecutionToolResultBlockContentUnion struct {\n\t// This field is from variant [TextEditorCodeExecutionToolResultError].\n\tErrorCode TextEditorCodeExecutionToolResultErrorCode `json:\"error_code\"`\n\t// This field is from variant [TextEditorCodeExecutionToolResultError].\n\tErrorMessage string `json:\"error_message\"`\n\tType         string `json:\"type\"`\n\t// This field is from variant [TextEditorCodeExecutionViewResultBlock].\n\tContent string `json:\"content\"`\n\t// This field is from variant [TextEditorCodeExecutionViewResultBlock].\n\tFileType TextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\"`\n\t// This field is from variant [TextEditorCodeExecutionViewResultBlock].\n\tNumLines int64 `json:\"num_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionViewResultBlock].\n\tStartLine int64 `json:\"start_line\"`\n\t// This field is from variant [TextEditorCodeExecutionViewResultBlock].\n\tTotalLines int64 `json:\"total_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionCreateResultBlock].\n\tIsFileUpdate bool `json:\"is_file_update\"`\n\t// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].\n\tLines []string `json:\"lines\"`\n\t// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].\n\tNewLines int64 `json:\"new_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].\n\tNewStart int64 `json:\"new_start\"`\n\t// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].\n\tOldLines int64 `json:\"old_lines\"`\n\t// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].\n\tOldStart int64 `json:\"old_start\"`\n\tJSON     struct {\n\t\tErrorCode    respjson.Field\n\t\tErrorMessage respjson.Field\n\t\tType         respjson.Field\n\t\tContent      respjson.Field\n\t\tFileType     respjson.Field\n\t\tNumLines     respjson.Field\n\t\tStartLine    respjson.Field\n\t\tTotalLines   respjson.Field\n\t\tIsFileUpdate respjson.Field\n\t\tLines        respjson.Field\n\t\tNewLines     respjson.Field\n\t\tNewStart     respjson.Field\n\t\tOldLines     respjson.Field\n\t\tOldStart     respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\nfunc (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError() (v TextEditorCodeExecutionToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock() (v TextEditorCodeExecutionViewResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock() (v TextEditorCodeExecutionCreateResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock() (v TextEditorCodeExecutionStrReplaceResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u TextEditorCodeExecutionToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *TextEditorCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype TextEditorCodeExecutionToolResultBlockParam struct {\n\tContent   TextEditorCodeExecutionToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                                  `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_tool_result\".\n\tType constant.TextEditorCodeExecutionToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r TextEditorCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow TextEditorCodeExecutionToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *TextEditorCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype TextEditorCodeExecutionToolResultBlockParamContentUnion struct {\n\tOfRequestTextEditorCodeExecutionToolResultError       *TextEditorCodeExecutionToolResultErrorParam       `json:\",omitzero,inline\"`\n\tOfRequestTextEditorCodeExecutionViewResultBlock       *TextEditorCodeExecutionViewResultBlockParam       `json:\",omitzero,inline\"`\n\tOfRequestTextEditorCodeExecutionCreateResultBlock     *TextEditorCodeExecutionCreateResultBlockParam     `json:\",omitzero,inline\"`\n\tOfRequestTextEditorCodeExecutionStrReplaceResultBlock *TextEditorCodeExecutionStrReplaceResultBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestTextEditorCodeExecutionToolResultError, u.OfRequestTextEditorCodeExecutionViewResultBlock, u.OfRequestTextEditorCodeExecutionCreateResultBlock, u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock)\n}\nfunc (u *TextEditorCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *TextEditorCodeExecutionToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestTextEditorCodeExecutionToolResultError) {\n\t\treturn u.OfRequestTextEditorCodeExecutionToolResultError\n\t} else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionViewResultBlock) {\n\t\treturn u.OfRequestTextEditorCodeExecutionViewResultBlock\n\t} else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionCreateResultBlock) {\n\t\treturn u.OfRequestTextEditorCodeExecutionCreateResultBlock\n\t} else if !param.IsOmitted(u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock) {\n\t\treturn u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorMessage() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil && vt.ErrorMessage.Valid() {\n\t\treturn &vt.ErrorMessage.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetContent() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil {\n\t\treturn &vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetFileType() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil {\n\t\treturn (*string)(&vt.FileType)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNumLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.NumLines.Valid() {\n\t\treturn &vt.NumLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetStartLine() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.StartLine.Valid() {\n\t\treturn &vt.StartLine.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetTotalLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil && vt.TotalLines.Valid() {\n\t\treturn &vt.TotalLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetIsFileUpdate() *bool {\n\tif vt := u.OfRequestTextEditorCodeExecutionCreateResultBlock; vt != nil {\n\t\treturn &vt.IsFileUpdate\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetLines() []string {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil {\n\t\treturn vt.Lines\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.NewLines.Valid() {\n\t\treturn &vt.NewLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewStart() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.NewStart.Valid() {\n\t\treturn &vt.NewStart.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldLines() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.OldLines.Valid() {\n\t\treturn &vt.OldLines.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldStart() *int64 {\n\tif vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil && vt.OldStart.Valid() {\n\t\treturn &vt.OldStart.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u TextEditorCodeExecutionToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestTextEditorCodeExecutionToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestTextEditorCodeExecutionViewResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestTextEditorCodeExecutionCreateResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestTextEditorCodeExecutionStrReplaceResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype TextEditorCodeExecutionToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"file_not_found\".\n\tErrorCode    TextEditorCodeExecutionToolResultErrorCode      `json:\"error_code\" api:\"required\"`\n\tErrorMessage string                                          `json:\"error_message\" api:\"required\"`\n\tType         constant.TextEditorCodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode    respjson.Field\n\t\tErrorMessage respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextEditorCodeExecutionToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *TextEditorCodeExecutionToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionToolResultErrorCode string\n\nconst (\n\tTextEditorCodeExecutionToolResultErrorCodeInvalidToolInput      TextEditorCodeExecutionToolResultErrorCode = \"invalid_tool_input\"\n\tTextEditorCodeExecutionToolResultErrorCodeUnavailable           TextEditorCodeExecutionToolResultErrorCode = \"unavailable\"\n\tTextEditorCodeExecutionToolResultErrorCodeTooManyRequests       TextEditorCodeExecutionToolResultErrorCode = \"too_many_requests\"\n\tTextEditorCodeExecutionToolResultErrorCodeExecutionTimeExceeded TextEditorCodeExecutionToolResultErrorCode = \"execution_time_exceeded\"\n\tTextEditorCodeExecutionToolResultErrorCodeFileNotFound          TextEditorCodeExecutionToolResultErrorCode = \"file_not_found\"\n)\n\n// The properties ErrorCode, Type are required.\ntype TextEditorCodeExecutionToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\", \"file_not_found\".\n\tErrorCode    TextEditorCodeExecutionToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\tErrorMessage param.Opt[string]                          `json:\"error_message,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_tool_result_error\".\n\tType constant.TextEditorCodeExecutionToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r TextEditorCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow TextEditorCodeExecutionToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *TextEditorCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionViewResultBlock struct {\n\tContent string `json:\"content\" api:\"required\"`\n\t// Any of \"text\", \"image\", \"pdf\".\n\tFileType   TextEditorCodeExecutionViewResultBlockFileType `json:\"file_type\" api:\"required\"`\n\tNumLines   int64                                          `json:\"num_lines\" api:\"required\"`\n\tStartLine  int64                                          `json:\"start_line\" api:\"required\"`\n\tTotalLines int64                                          `json:\"total_lines\" api:\"required\"`\n\tType       constant.TextEditorCodeExecutionViewResult     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tFileType    respjson.Field\n\t\tNumLines    respjson.Field\n\t\tStartLine   respjson.Field\n\t\tTotalLines  respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TextEditorCodeExecutionViewResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *TextEditorCodeExecutionViewResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionViewResultBlockFileType string\n\nconst (\n\tTextEditorCodeExecutionViewResultBlockFileTypeText  TextEditorCodeExecutionViewResultBlockFileType = \"text\"\n\tTextEditorCodeExecutionViewResultBlockFileTypeImage TextEditorCodeExecutionViewResultBlockFileType = \"image\"\n\tTextEditorCodeExecutionViewResultBlockFileTypePDF   TextEditorCodeExecutionViewResultBlockFileType = \"pdf\"\n)\n\n// The properties Content, FileType, Type are required.\ntype TextEditorCodeExecutionViewResultBlockParam struct {\n\tContent string `json:\"content\" api:\"required\"`\n\t// Any of \"text\", \"image\", \"pdf\".\n\tFileType   TextEditorCodeExecutionViewResultBlockParamFileType `json:\"file_type,omitzero\" api:\"required\"`\n\tNumLines   param.Opt[int64]                                    `json:\"num_lines,omitzero\"`\n\tStartLine  param.Opt[int64]                                    `json:\"start_line,omitzero\"`\n\tTotalLines param.Opt[int64]                                    `json:\"total_lines,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_code_execution_view_result\".\n\tType constant.TextEditorCodeExecutionViewResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r TextEditorCodeExecutionViewResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow TextEditorCodeExecutionViewResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *TextEditorCodeExecutionViewResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype TextEditorCodeExecutionViewResultBlockParamFileType string\n\nconst (\n\tTextEditorCodeExecutionViewResultBlockParamFileTypeText  TextEditorCodeExecutionViewResultBlockParamFileType = \"text\"\n\tTextEditorCodeExecutionViewResultBlockParamFileTypeImage TextEditorCodeExecutionViewResultBlockParamFileType = \"image\"\n\tTextEditorCodeExecutionViewResultBlockParamFileTypePDF   TextEditorCodeExecutionViewResultBlockParamFileType = \"pdf\"\n)\n\ntype ThinkingBlock struct {\n\tSignature string            `json:\"signature\" api:\"required\"`\n\tThinking  string            `json:\"thinking\" api:\"required\"`\n\tType      constant.Thinking `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSignature   respjson.Field\n\t\tThinking    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ThinkingBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ThinkingBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Signature, Thinking, Type are required.\ntype ThinkingBlockParam struct {\n\tSignature string `json:\"signature\" api:\"required\"`\n\tThinking  string `json:\"thinking\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"thinking\".\n\tType constant.Thinking `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ThinkingBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ThinkingBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ThinkingBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The property Type is required.\ntype ThinkingConfigAdaptiveParam struct {\n\t// Controls how thinking content appears in the response. When set to `summarized`,\n\t// thinking is returned normally. When set to `omitted`, thinking content is\n\t// redacted but a signature is returned for multi-turn continuity. Defaults to\n\t// `summarized`.\n\t//\n\t// Any of \"summarized\", \"omitted\".\n\tDisplay ThinkingConfigAdaptiveDisplay `json:\"display,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"adaptive\".\n\tType constant.Adaptive `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ThinkingConfigAdaptiveParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ThinkingConfigAdaptiveParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ThinkingConfigAdaptiveParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Controls how thinking content appears in the response. When set to `summarized`,\n// thinking is returned normally. When set to `omitted`, thinking content is\n// redacted but a signature is returned for multi-turn continuity. Defaults to\n// `summarized`.\ntype ThinkingConfigAdaptiveDisplay string\n\nconst (\n\tThinkingConfigAdaptiveDisplaySummarized ThinkingConfigAdaptiveDisplay = \"summarized\"\n\tThinkingConfigAdaptiveDisplayOmitted    ThinkingConfigAdaptiveDisplay = \"omitted\"\n)\n\nfunc NewThinkingConfigDisabledParam() ThinkingConfigDisabledParam {\n\treturn ThinkingConfigDisabledParam{\n\t\tType: \"disabled\",\n\t}\n}\n\n// This struct has a constant value, construct it with\n// [NewThinkingConfigDisabledParam].\ntype ThinkingConfigDisabledParam struct {\n\tType constant.Disabled `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ThinkingConfigDisabledParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ThinkingConfigDisabledParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ThinkingConfigDisabledParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties BudgetTokens, Type are required.\ntype ThinkingConfigEnabledParam struct {\n\t// Determines how many tokens Claude can use for its internal reasoning process.\n\t// Larger budgets can enable more thorough analysis for complex problems, improving\n\t// response quality.\n\t//\n\t// Must be ≥1024 and less than `max_tokens`.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tBudgetTokens int64 `json:\"budget_tokens\" api:\"required\"`\n\t// Controls how thinking content appears in the response. When set to `summarized`,\n\t// thinking is returned normally. When set to `omitted`, thinking content is\n\t// redacted but a signature is returned for multi-turn continuity. Defaults to\n\t// `summarized`.\n\t//\n\t// Any of \"summarized\", \"omitted\".\n\tDisplay ThinkingConfigEnabledDisplay `json:\"display,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"enabled\".\n\tType constant.Enabled `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ThinkingConfigEnabledParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ThinkingConfigEnabledParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ThinkingConfigEnabledParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Controls how thinking content appears in the response. When set to `summarized`,\n// thinking is returned normally. When set to `omitted`, thinking content is\n// redacted but a signature is returned for multi-turn continuity. Defaults to\n// `summarized`.\ntype ThinkingConfigEnabledDisplay string\n\nconst (\n\tThinkingConfigEnabledDisplaySummarized ThinkingConfigEnabledDisplay = \"summarized\"\n\tThinkingConfigEnabledDisplayOmitted    ThinkingConfigEnabledDisplay = \"omitted\"\n)\n\nfunc ThinkingConfigParamOfEnabled(budgetTokens int64) ThinkingConfigParamUnion {\n\tvar enabled ThinkingConfigEnabledParam\n\tenabled.BudgetTokens = budgetTokens\n\treturn ThinkingConfigParamUnion{OfEnabled: &enabled}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ThinkingConfigParamUnion struct {\n\tOfEnabled  *ThinkingConfigEnabledParam  `json:\",omitzero,inline\"`\n\tOfDisabled *ThinkingConfigDisabledParam `json:\",omitzero,inline\"`\n\tOfAdaptive *ThinkingConfigAdaptiveParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ThinkingConfigParamUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfEnabled, u.OfDisabled, u.OfAdaptive)\n}\nfunc (u *ThinkingConfigParamUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ThinkingConfigParamUnion) asAny() any {\n\tif !param.IsOmitted(u.OfEnabled) {\n\t\treturn u.OfEnabled\n\t} else if !param.IsOmitted(u.OfDisabled) {\n\t\treturn u.OfDisabled\n\t} else if !param.IsOmitted(u.OfAdaptive) {\n\t\treturn u.OfAdaptive\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ThinkingConfigParamUnion) GetBudgetTokens() *int64 {\n\tif vt := u.OfEnabled; vt != nil {\n\t\treturn &vt.BudgetTokens\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ThinkingConfigParamUnion) GetType() *string {\n\tif vt := u.OfEnabled; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfDisabled; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfAdaptive; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ThinkingConfigParamUnion) GetDisplay() *string {\n\tif vt := u.OfEnabled; vt != nil {\n\t\treturn (*string)(&vt.Display)\n\t} else if vt := u.OfAdaptive; vt != nil {\n\t\treturn (*string)(&vt.Display)\n\t}\n\treturn nil\n}\n\ntype ThinkingDelta struct {\n\tThinking string                 `json:\"thinking\" api:\"required\"`\n\tType     constant.ThinkingDelta `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tThinking    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ThinkingDelta) RawJSON() string { return r.JSON.raw }\nfunc (r *ThinkingDelta) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties InputSchema, Name are required.\ntype ToolParam struct {\n\t// [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.\n\t//\n\t// This defines the shape of the `input` that your tool accepts and that the model\n\t// will produce.\n\tInputSchema ToolInputSchemaParam `json:\"input_schema,omitzero\" api:\"required\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\tName string `json:\"name\" api:\"required\"`\n\t// Enable eager input streaming for this tool. When true, tool input parameters\n\t// will be streamed incrementally as they are generated, and types will be inferred\n\t// on-the-fly rather than buffering the full JSON output. When false, streaming is\n\t// disabled for this tool even if the fine-grained-tool-streaming beta is active.\n\t// When null (default), uses the default behavior based on beta headers.\n\tEagerInputStreaming param.Opt[bool] `json:\"eager_input_streaming,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// Description of what this tool does.\n\t//\n\t// Tool descriptions should be as detailed as possible. The more information that\n\t// the model has about what the tool is and how to use it, the better it will\n\t// perform. You can use natural language descriptions to reinforce important\n\t// aspects of the tool input JSON schema.\n\tDescription param.Opt[string] `json:\"description,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"custom\".\n\tType ToolType `json:\"type,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any           `json:\"input_examples,omitzero\"`\n\tparamObj\n}\n\nfunc (r ToolParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.\n//\n// This defines the shape of the `input` that your tool accepts and that the model\n// will produce.\n//\n// The property Type is required.\ntype ToolInputSchemaParam struct {\n\tProperties any      `json:\"properties,omitzero\"`\n\tRequired   []string `json:\"required,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"object\".\n\tType        constant.Object `json:\"type\" api:\"required\"`\n\tExtraFields map[string]any  `json:\"-\"`\n\tparamObj\n}\n\nfunc (r ToolInputSchemaParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolInputSchemaParam\n\treturn param.MarshalWithExtras(r, (*shadow)(&r), r.ExtraFields)\n}\nfunc (r *ToolInputSchemaParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ToolType string\n\nconst (\n\tToolTypeCustom ToolType = \"custom\"\n)\n\n// The properties Name, Type are required.\ntype ToolBash20250124Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any           `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"bash\".\n\tName constant.Bash `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"bash_20250124\".\n\tType constant.Bash20250124 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolBash20250124Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolBash20250124Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolBash20250124Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc ToolChoiceParamOfTool(name string) ToolChoiceUnionParam {\n\tvar tool ToolChoiceToolParam\n\ttool.Name = name\n\treturn ToolChoiceUnionParam{OfTool: &tool}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ToolChoiceUnionParam struct {\n\tOfAuto *ToolChoiceAutoParam `json:\",omitzero,inline\"`\n\tOfAny  *ToolChoiceAnyParam  `json:\",omitzero,inline\"`\n\tOfTool *ToolChoiceToolParam `json:\",omitzero,inline\"`\n\tOfNone *ToolChoiceNoneParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ToolChoiceUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfAuto, u.OfAny, u.OfTool, u.OfNone)\n}\nfunc (u *ToolChoiceUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ToolChoiceUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfAuto) {\n\t\treturn u.OfAuto\n\t} else if !param.IsOmitted(u.OfAny) {\n\t\treturn u.OfAny\n\t} else if !param.IsOmitted(u.OfTool) {\n\t\treturn u.OfTool\n\t} else if !param.IsOmitted(u.OfNone) {\n\t\treturn u.OfNone\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolChoiceUnionParam) GetName() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.Name\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolChoiceUnionParam) GetType() *string {\n\tif vt := u.OfAuto; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfAny; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfNone; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolChoiceUnionParam) GetDisableParallelToolUse() *bool {\n\tif vt := u.OfAuto; vt != nil && vt.DisableParallelToolUse.Valid() {\n\t\treturn &vt.DisableParallelToolUse.Value\n\t} else if vt := u.OfAny; vt != nil && vt.DisableParallelToolUse.Valid() {\n\t\treturn &vt.DisableParallelToolUse.Value\n\t} else if vt := u.OfTool; vt != nil && vt.DisableParallelToolUse.Valid() {\n\t\treturn &vt.DisableParallelToolUse.Value\n\t}\n\treturn nil\n}\n\n// The model will use any available tools.\n//\n// The property Type is required.\ntype ToolChoiceAnyParam struct {\n\t// Whether to disable parallel tool use.\n\t//\n\t// Defaults to `false`. If set to `true`, the model will output exactly one tool\n\t// use.\n\tDisableParallelToolUse param.Opt[bool] `json:\"disable_parallel_tool_use,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"any\".\n\tType constant.Any `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolChoiceAnyParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolChoiceAnyParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolChoiceAnyParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The model will automatically decide whether to use tools.\n//\n// The property Type is required.\ntype ToolChoiceAutoParam struct {\n\t// Whether to disable parallel tool use.\n\t//\n\t// Defaults to `false`. If set to `true`, the model will output at most one tool\n\t// use.\n\tDisableParallelToolUse param.Opt[bool] `json:\"disable_parallel_tool_use,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"auto\".\n\tType constant.Auto `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolChoiceAutoParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolChoiceAutoParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolChoiceAutoParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc NewToolChoiceNoneParam() ToolChoiceNoneParam {\n\treturn ToolChoiceNoneParam{\n\t\tType: \"none\",\n\t}\n}\n\n// The model will not be allowed to use tools.\n//\n// This struct has a constant value, construct it with [NewToolChoiceNoneParam].\ntype ToolChoiceNoneParam struct {\n\tType constant.None `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolChoiceNoneParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolChoiceNoneParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolChoiceNoneParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The model will use the specified tool with `tool_choice.name`.\n//\n// The properties Name, Type are required.\ntype ToolChoiceToolParam struct {\n\t// The name of the tool to use.\n\tName string `json:\"name\" api:\"required\"`\n\t// Whether to disable parallel tool use.\n\t//\n\t// Defaults to `false`. If set to `true`, the model will output exactly one tool\n\t// use.\n\tDisableParallelToolUse param.Opt[bool] `json:\"disable_parallel_tool_use,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool\".\n\tType constant.Tool `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolChoiceToolParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolChoiceToolParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolChoiceToolParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ToolReferenceBlock struct {\n\tToolName string                 `json:\"tool_name\" api:\"required\"`\n\tType     constant.ToolReference `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolName    respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ToolReferenceBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ToolReferenceBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Tool reference block that can be included in tool_result content.\n//\n// The properties ToolName, Type are required.\ntype ToolReferenceBlockParam struct {\n\tToolName string `json:\"tool_name\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_reference\".\n\tType constant.ToolReference `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolReferenceBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolReferenceBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolReferenceBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ToolUseID, Type are required.\ntype ToolResultBlockParam struct {\n\tToolUseID string          `json:\"tool_use_id\" api:\"required\"`\n\tIsError   param.Opt[bool] `json:\"is_error,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam         `json:\"cache_control,omitzero\"`\n\tContent      []ToolResultBlockParamContentUnion `json:\"content,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_result\".\n\tType constant.ToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ToolResultBlockParamContentUnion struct {\n\tOfText          *TextBlockParam          `json:\",omitzero,inline\"`\n\tOfImage         *ImageBlockParam         `json:\",omitzero,inline\"`\n\tOfSearchResult  *SearchResultBlockParam  `json:\",omitzero,inline\"`\n\tOfDocument      *DocumentBlockParam      `json:\",omitzero,inline\"`\n\tOfToolReference *ToolReferenceBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfText,\n\t\tu.OfImage,\n\t\tu.OfSearchResult,\n\t\tu.OfDocument,\n\t\tu.OfToolReference)\n}\nfunc (u *ToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfText) {\n\t\treturn u.OfText\n\t} else if !param.IsOmitted(u.OfImage) {\n\t\treturn u.OfImage\n\t} else if !param.IsOmitted(u.OfSearchResult) {\n\t\treturn u.OfSearchResult\n\t} else if !param.IsOmitted(u.OfDocument) {\n\t\treturn u.OfDocument\n\t} else if !param.IsOmitted(u.OfToolReference) {\n\t\treturn u.OfToolReference\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetText() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.Text\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetContent() []TextBlockParam {\n\tif vt := u.OfSearchResult; vt != nil {\n\t\treturn vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetContext() *string {\n\tif vt := u.OfDocument; vt != nil && vt.Context.Valid() {\n\t\treturn &vt.Context.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetToolName() *string {\n\tif vt := u.OfToolReference; vt != nil {\n\t\treturn &vt.ToolName\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfText; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolReference; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetTitle() *string {\n\tif vt := u.OfSearchResult; vt != nil {\n\t\treturn (*string)(&vt.Title)\n\t} else if vt := u.OfDocument; vt != nil && vt.Title.Valid() {\n\t\treturn &vt.Title.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u ToolResultBlockParamContentUnion) GetCacheControl() *CacheControlEphemeralParam {\n\tif vt := u.OfText; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfImage; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfDocument; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolReference; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u ToolResultBlockParamContentUnion) GetCitations() (res toolResultBlockParamContentUnionCitations) {\n\tif vt := u.OfText; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Citations\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = &vt.Citations\n\t}\n\treturn\n}\n\n// Can have the runtime types [*[]TextCitationParamUnion], [*CitationsConfigParam]\ntype toolResultBlockParamContentUnionCitations struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *[]anthropic.TextCitationParamUnion:\n//\tcase *anthropic.CitationsConfigParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u toolResultBlockParamContentUnionCitations) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u toolResultBlockParamContentUnionCitations) GetEnabled() *bool {\n\tswitch vt := u.any.(type) {\n\tcase *CitationsConfigParam:\n\t\treturn paramutil.AddrIfPresent(vt.Enabled)\n\t}\n\treturn nil\n}\n\n// Returns a subunion which exports methods to access subproperties\n//\n// Or use AsAny() to get the underlying value\nfunc (u ToolResultBlockParamContentUnion) GetSource() (res toolResultBlockParamContentUnionSource) {\n\tif vt := u.OfImage; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t} else if vt := u.OfSearchResult; vt != nil {\n\t\tres.any = &vt.Source\n\t} else if vt := u.OfDocument; vt != nil {\n\t\tres.any = vt.Source.asAny()\n\t}\n\treturn\n}\n\n// Can have the runtime types [*Base64ImageSourceParam], [*URLImageSourceParam],\n// [*string], [*Base64PDFSourceParam], [*PlainTextSourceParam],\n// [*ContentBlockSourceParam], [*URLPDFSourceParam]\ntype toolResultBlockParamContentUnionSource struct{ any }\n\n// Use the following switch statement to get the type of the union:\n//\n//\tswitch u.AsAny().(type) {\n//\tcase *anthropic.Base64ImageSourceParam:\n//\tcase *anthropic.URLImageSourceParam:\n//\tcase *string:\n//\tcase *anthropic.Base64PDFSourceParam:\n//\tcase *anthropic.PlainTextSourceParam:\n//\tcase *anthropic.ContentBlockSourceParam:\n//\tcase *anthropic.URLPDFSourceParam:\n//\tdefault:\n//\t    fmt.Errorf(\"not present\")\n//\t}\nfunc (u toolResultBlockParamContentUnionSource) AsAny() any { return u.any }\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u toolResultBlockParamContentUnionSource) GetContent() *ContentBlockSourceContentUnionParam {\n\tswitch vt := u.any.(type) {\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetContent()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u toolResultBlockParamContentUnionSource) GetData() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetData()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetData()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u toolResultBlockParamContentUnionSource) GetMediaType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetMediaType()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetMediaType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u toolResultBlockParamContentUnionSource) GetType() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetType()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetType()\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u toolResultBlockParamContentUnionSource) GetURL() *string {\n\tswitch vt := u.any.(type) {\n\tcase *ImageBlockParamSourceUnion:\n\t\treturn vt.GetURL()\n\tcase *DocumentBlockParamSourceUnion:\n\t\treturn vt.GetURL()\n\t}\n\treturn nil\n}\n\n// The properties Name, Type are required.\ntype ToolSearchToolBm25_20251119Param struct {\n\t// Any of \"tool_search_tool_bm25_20251119\", \"tool_search_tool_bm25\".\n\tType ToolSearchToolBm25_20251119Type `json:\"type,omitzero\" api:\"required\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_bm25\".\n\tName constant.ToolSearchToolBm25 `json:\"name\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolSearchToolBm25_20251119Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolSearchToolBm25_20251119Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolSearchToolBm25_20251119Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ToolSearchToolBm25_20251119Type string\n\nconst (\n\tToolSearchToolBm25_20251119TypeToolSearchToolBm25_20251119 ToolSearchToolBm25_20251119Type = \"tool_search_tool_bm25_20251119\"\n\tToolSearchToolBm25_20251119TypeToolSearchToolBm25          ToolSearchToolBm25_20251119Type = \"tool_search_tool_bm25\"\n)\n\n// The properties Name, Type are required.\ntype ToolSearchToolRegex20251119Param struct {\n\t// Any of \"tool_search_tool_regex_20251119\", \"tool_search_tool_regex\".\n\tType ToolSearchToolRegex20251119Type `json:\"type,omitzero\" api:\"required\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_regex\".\n\tName constant.ToolSearchToolRegex `json:\"name\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolSearchToolRegex20251119Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolSearchToolRegex20251119Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolSearchToolRegex20251119Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ToolSearchToolRegex20251119Type string\n\nconst (\n\tToolSearchToolRegex20251119TypeToolSearchToolRegex20251119 ToolSearchToolRegex20251119Type = \"tool_search_tool_regex_20251119\"\n\tToolSearchToolRegex20251119TypeToolSearchToolRegex         ToolSearchToolRegex20251119Type = \"tool_search_tool_regex\"\n)\n\ntype ToolSearchToolResultBlock struct {\n\tContent   ToolSearchToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                                `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.ToolSearchToolResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ToolSearchToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ToolSearchToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToolSearchToolResultBlockContentUnion contains all possible properties and\n// values from [ToolSearchToolResultError], [ToolSearchToolSearchResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype ToolSearchToolResultBlockContentUnion struct {\n\t// This field is from variant [ToolSearchToolResultError].\n\tErrorCode ToolSearchToolResultErrorCode `json:\"error_code\"`\n\t// This field is from variant [ToolSearchToolResultError].\n\tErrorMessage string `json:\"error_message\"`\n\tType         string `json:\"type\"`\n\t// This field is from variant [ToolSearchToolSearchResultBlock].\n\tToolReferences []ToolReferenceBlock `json:\"tool_references\"`\n\tJSON           struct {\n\t\tErrorCode      respjson.Field\n\t\tErrorMessage   respjson.Field\n\t\tType           respjson.Field\n\t\tToolReferences respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\nfunc (u ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError() (v ToolSearchToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock() (v ToolSearchToolSearchResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u ToolSearchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *ToolSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype ToolSearchToolResultBlockParam struct {\n\tContent   ToolSearchToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                     `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_result\".\n\tType constant.ToolSearchToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolSearchToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolSearchToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolSearchToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ToolSearchToolResultBlockParamContentUnion struct {\n\tOfRequestToolSearchToolResultError       *ToolSearchToolResultErrorParam       `json:\",omitzero,inline\"`\n\tOfRequestToolSearchToolSearchResultBlock *ToolSearchToolSearchResultBlockParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ToolSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestToolSearchToolResultError, u.OfRequestToolSearchToolSearchResultBlock)\n}\nfunc (u *ToolSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ToolSearchToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestToolSearchToolResultError) {\n\t\treturn u.OfRequestToolSearchToolResultError\n\t} else if !param.IsOmitted(u.OfRequestToolSearchToolSearchResultBlock) {\n\t\treturn u.OfRequestToolSearchToolSearchResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolSearchToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestToolSearchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolSearchToolResultBlockParamContentUnion) GetToolReferences() []ToolReferenceBlockParam {\n\tif vt := u.OfRequestToolSearchToolSearchResultBlock; vt != nil {\n\t\treturn vt.ToolReferences\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolSearchToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestToolSearchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestToolSearchToolSearchResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\ntype ToolSearchToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode    ToolSearchToolResultErrorCode      `json:\"error_code\" api:\"required\"`\n\tErrorMessage string                             `json:\"error_message\" api:\"required\"`\n\tType         constant.ToolSearchToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode    respjson.Field\n\t\tErrorMessage respjson.Field\n\t\tType         respjson.Field\n\t\tExtraFields  map[string]respjson.Field\n\t\traw          string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ToolSearchToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *ToolSearchToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ToolSearchToolResultErrorCode string\n\nconst (\n\tToolSearchToolResultErrorCodeInvalidToolInput      ToolSearchToolResultErrorCode = \"invalid_tool_input\"\n\tToolSearchToolResultErrorCodeUnavailable           ToolSearchToolResultErrorCode = \"unavailable\"\n\tToolSearchToolResultErrorCodeTooManyRequests       ToolSearchToolResultErrorCode = \"too_many_requests\"\n\tToolSearchToolResultErrorCodeExecutionTimeExceeded ToolSearchToolResultErrorCode = \"execution_time_exceeded\"\n)\n\n// The properties ErrorCode, Type are required.\ntype ToolSearchToolResultErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"too_many_requests\",\n\t// \"execution_time_exceeded\".\n\tErrorCode ToolSearchToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_result_error\".\n\tType constant.ToolSearchToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolSearchToolResultErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolSearchToolResultErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolSearchToolResultErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ToolSearchToolSearchResultBlock struct {\n\tToolReferences []ToolReferenceBlock                `json:\"tool_references\" api:\"required\"`\n\tType           constant.ToolSearchToolSearchResult `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tToolReferences respjson.Field\n\t\tType           respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ToolSearchToolSearchResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ToolSearchToolSearchResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ToolReferences, Type are required.\ntype ToolSearchToolSearchResultBlockParam struct {\n\tToolReferences []ToolReferenceBlockParam `json:\"tool_references,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"tool_search_tool_search_result\".\n\tType constant.ToolSearchToolSearchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolSearchToolSearchResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolSearchToolSearchResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolSearchToolSearchResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype ToolTextEditor20250124Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any           `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_editor\".\n\tName constant.StrReplaceEditor `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20250124\".\n\tType constant.TextEditor20250124 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolTextEditor20250124Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolTextEditor20250124Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolTextEditor20250124Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype ToolTextEditor20250429Param struct {\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any           `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_based_edit_tool\".\n\tName constant.StrReplaceBasedEditTool `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20250429\".\n\tType constant.TextEditor20250429 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolTextEditor20250429Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolTextEditor20250429Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolTextEditor20250429Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype ToolTextEditor20250728Param struct {\n\t// Maximum number of characters to display when viewing a file. If not specified,\n\t// defaults to displaying the full file.\n\tMaxCharacters param.Opt[int64] `json:\"max_characters,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl  CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\tInputExamples []map[string]any           `json:\"input_examples,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as\n\t// \"str_replace_based_edit_tool\".\n\tName constant.StrReplaceBasedEditTool `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"text_editor_20250728\".\n\tType constant.TextEditor20250728 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolTextEditor20250728Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolTextEditor20250728Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolTextEditor20250728Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc ToolUnionParamOfTool(inputSchema ToolInputSchemaParam, name string) ToolUnionParam {\n\tvar variant ToolParam\n\tvariant.InputSchema = inputSchema\n\tvariant.Name = name\n\treturn ToolUnionParam{OfTool: &variant}\n}\n\nfunc ToolUnionParamOfToolSearchToolBm25_20251119(type_ ToolSearchToolBm25_20251119Type) ToolUnionParam {\n\tvar variant ToolSearchToolBm25_20251119Param\n\tvariant.Type = type_\n\treturn ToolUnionParam{OfToolSearchToolBm25_20251119: &variant}\n}\n\nfunc ToolUnionParamOfToolSearchToolRegex20251119(type_ ToolSearchToolRegex20251119Type) ToolUnionParam {\n\tvar variant ToolSearchToolRegex20251119Param\n\tvariant.Type = type_\n\treturn ToolUnionParam{OfToolSearchToolRegex20251119: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ToolUnionParam struct {\n\tOfTool                        *ToolParam                        `json:\",omitzero,inline\"`\n\tOfBashTool20250124            *ToolBash20250124Param            `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250522   *CodeExecutionTool20250522Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20250825   *CodeExecutionTool20250825Param   `json:\",omitzero,inline\"`\n\tOfCodeExecutionTool20260120   *CodeExecutionTool20260120Param   `json:\",omitzero,inline\"`\n\tOfMemoryTool20250818          *MemoryTool20250818Param          `json:\",omitzero,inline\"`\n\tOfTextEditor20250124          *ToolTextEditor20250124Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250429          *ToolTextEditor20250429Param      `json:\",omitzero,inline\"`\n\tOfTextEditor20250728          *ToolTextEditor20250728Param      `json:\",omitzero,inline\"`\n\tOfWebSearchTool20250305       *WebSearchTool20250305Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20250910        *WebFetchTool20250910Param        `json:\",omitzero,inline\"`\n\tOfWebSearchTool20260209       *WebSearchTool20260209Param       `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260209        *WebFetchTool20260209Param        `json:\",omitzero,inline\"`\n\tOfWebFetchTool20260309        *WebFetchTool20260309Param        `json:\",omitzero,inline\"`\n\tOfToolSearchToolBm25_20251119 *ToolSearchToolBm25_20251119Param `json:\",omitzero,inline\"`\n\tOfToolSearchToolRegex20251119 *ToolSearchToolRegex20251119Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ToolUnionParam) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfTool,\n\t\tu.OfBashTool20250124,\n\t\tu.OfCodeExecutionTool20250522,\n\t\tu.OfCodeExecutionTool20250825,\n\t\tu.OfCodeExecutionTool20260120,\n\t\tu.OfMemoryTool20250818,\n\t\tu.OfTextEditor20250124,\n\t\tu.OfTextEditor20250429,\n\t\tu.OfTextEditor20250728,\n\t\tu.OfWebSearchTool20250305,\n\t\tu.OfWebFetchTool20250910,\n\t\tu.OfWebSearchTool20260209,\n\t\tu.OfWebFetchTool20260209,\n\t\tu.OfWebFetchTool20260309,\n\t\tu.OfToolSearchToolBm25_20251119,\n\t\tu.OfToolSearchToolRegex20251119)\n}\nfunc (u *ToolUnionParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ToolUnionParam) asAny() any {\n\tif !param.IsOmitted(u.OfTool) {\n\t\treturn u.OfTool\n\t} else if !param.IsOmitted(u.OfBashTool20250124) {\n\t\treturn u.OfBashTool20250124\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250522) {\n\t\treturn u.OfCodeExecutionTool20250522\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20250825) {\n\t\treturn u.OfCodeExecutionTool20250825\n\t} else if !param.IsOmitted(u.OfCodeExecutionTool20260120) {\n\t\treturn u.OfCodeExecutionTool20260120\n\t} else if !param.IsOmitted(u.OfMemoryTool20250818) {\n\t\treturn u.OfMemoryTool20250818\n\t} else if !param.IsOmitted(u.OfTextEditor20250124) {\n\t\treturn u.OfTextEditor20250124\n\t} else if !param.IsOmitted(u.OfTextEditor20250429) {\n\t\treturn u.OfTextEditor20250429\n\t} else if !param.IsOmitted(u.OfTextEditor20250728) {\n\t\treturn u.OfTextEditor20250728\n\t} else if !param.IsOmitted(u.OfWebSearchTool20250305) {\n\t\treturn u.OfWebSearchTool20250305\n\t} else if !param.IsOmitted(u.OfWebFetchTool20250910) {\n\t\treturn u.OfWebFetchTool20250910\n\t} else if !param.IsOmitted(u.OfWebSearchTool20260209) {\n\t\treturn u.OfWebSearchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260209) {\n\t\treturn u.OfWebFetchTool20260209\n\t} else if !param.IsOmitted(u.OfWebFetchTool20260309) {\n\t\treturn u.OfWebFetchTool20260309\n\t} else if !param.IsOmitted(u.OfToolSearchToolBm25_20251119) {\n\t\treturn u.OfToolSearchToolBm25_20251119\n\t} else if !param.IsOmitted(u.OfToolSearchToolRegex20251119) {\n\t\treturn u.OfToolSearchToolRegex20251119\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetInputSchema() *ToolInputSchemaParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.InputSchema\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetDescription() *string {\n\tif vt := u.OfTool; vt != nil && vt.Description.Valid() {\n\t\treturn &vt.Description.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetEagerInputStreaming() *bool {\n\tif vt := u.OfTool; vt != nil && vt.EagerInputStreaming.Valid() {\n\t\treturn &vt.EagerInputStreaming.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetMaxCharacters() *int64 {\n\tif vt := u.OfTextEditor20250728; vt != nil && vt.MaxCharacters.Valid() {\n\t\treturn &vt.MaxCharacters.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetUseCache() *bool {\n\tif vt := u.OfWebFetchTool20260309; vt != nil && vt.UseCache.Valid() {\n\t\treturn &vt.UseCache.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetName() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Name)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetDeferLoading() *bool {\n\tif vt := u.OfTool; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.DeferLoading.Valid() {\n\t\treturn &vt.DeferLoading.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetStrict() *bool {\n\tif vt := u.OfTool; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfBashTool20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfMemoryTool20250818; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250124; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250429; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfTextEditor20250728; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil && vt.Strict.Valid() {\n\t\treturn &vt.Strict.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetType() *string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetMaxUses() *int64 {\n\tif vt := u.OfWebSearchTool20250305; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxUses.Valid() {\n\t\treturn &vt.MaxUses.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUnionParam) GetMaxContentTokens() *int64 {\n\tif vt := u.OfWebFetchTool20250910; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil && vt.MaxContentTokens.Valid() {\n\t\treturn &vt.MaxContentTokens.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedCallers property, if\n// present.\nfunc (u ToolUnionParam) GetAllowedCallers() []string {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn vt.AllowedCallers\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's CacheControl property, if present.\nfunc (u ToolUnionParam) GetCacheControl() *CacheControlEphemeralParam {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250522; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20250825; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfCodeExecutionTool20260120; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolBm25_20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t} else if vt := u.OfToolSearchToolRegex20251119; vt != nil {\n\t\treturn &vt.CacheControl\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's InputExamples property, if\n// present.\nfunc (u ToolUnionParam) GetInputExamples() []map[string]any {\n\tif vt := u.OfTool; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfBashTool20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfMemoryTool20250818; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250124; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250429; vt != nil {\n\t\treturn vt.InputExamples\n\t} else if vt := u.OfTextEditor20250728; vt != nil {\n\t\treturn vt.InputExamples\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's AllowedDomains property, if\n// present.\nfunc (u ToolUnionParam) GetAllowedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.AllowedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.AllowedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's BlockedDomains property, if\n// present.\nfunc (u ToolUnionParam) GetBlockedDomains() []string {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn vt.BlockedDomains\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn vt.BlockedDomains\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's UserLocation property, if present.\nfunc (u ToolUnionParam) GetUserLocation() *UserLocationParam {\n\tif vt := u.OfWebSearchTool20250305; vt != nil {\n\t\treturn &vt.UserLocation\n\t} else if vt := u.OfWebSearchTool20260209; vt != nil {\n\t\treturn &vt.UserLocation\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's Citations property, if present.\nfunc (u ToolUnionParam) GetCitations() *CitationsConfigParam {\n\tif vt := u.OfWebFetchTool20250910; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260209; vt != nil {\n\t\treturn &vt.Citations\n\t} else if vt := u.OfWebFetchTool20260309; vt != nil {\n\t\treturn &vt.Citations\n\t}\n\treturn nil\n}\n\ntype ToolUseBlock struct {\n\tID string `json:\"id\" api:\"required\"`\n\t// Tool invocation directly from the model.\n\tCaller ToolUseBlockCallerUnion `json:\"caller\" api:\"required\"`\n\t// necessary custom code modification\n\tInput json.RawMessage          `json:\"input,required\"`\n\tName   string                  `json:\"name\" api:\"required\"`\n\tType   constant.ToolUse        `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tCaller      respjson.Field\n\t\tInput       respjson.Field\n\t\tName        respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ToolUseBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *ToolUseBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// ToolUseBlockCallerUnion contains all possible properties and values from\n// [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120].\n//\n// Use the [ToolUseBlockCallerUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype ToolUseBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyToolUseBlockCaller is implemented by each variant of\n// [ToolUseBlockCallerUnion] to add type safety for the return type of\n// [ToolUseBlockCallerUnion.AsAny]\ntype anyToolUseBlockCaller interface {\n\timplToolUseBlockCallerUnion()\n}\n\nfunc (DirectCaller) implToolUseBlockCallerUnion()             {}\nfunc (ServerToolCaller) implToolUseBlockCallerUnion()         {}\nfunc (ServerToolCaller20260120) implToolUseBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := ToolUseBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.DirectCaller:\n//\tcase anthropic.ServerToolCaller:\n//\tcase anthropic.ServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u ToolUseBlockCallerUnion) AsAny() anyToolUseBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u ToolUseBlockCallerUnion) AsDirect() (v DirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ToolUseBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ToolUseBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u ToolUseBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *ToolUseBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ID, Input, Name, Type are required.\ntype ToolUseBlockParam struct {\n\tID    string `json:\"id\" api:\"required\"`\n\tInput any    `json:\"input,omitzero\" api:\"required\"`\n\tName  string `json:\"name\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller ToolUseBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"tool_use\".\n\tType constant.ToolUse `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r ToolUseBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow ToolUseBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *ToolUseBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype ToolUseBlockParamCallerUnion struct {\n\tOfDirect                *DirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *ServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *ServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u ToolUseBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *ToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *ToolUseBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUseBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u ToolUseBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\n// The properties Type, URL are required.\ntype URLImageSourceParam struct {\n\tURL string `json:\"url\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"url\".\n\tType constant.URL `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r URLImageSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow URLImageSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *URLImageSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Type, URL are required.\ntype URLPDFSourceParam struct {\n\tURL string `json:\"url\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as \"url\".\n\tType constant.URL `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r URLPDFSourceParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow URLPDFSourceParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *URLPDFSourceParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype Usage struct {\n\t// Breakdown of cached tokens by TTL\n\tCacheCreation CacheCreation `json:\"cache_creation\" api:\"required\"`\n\t// The number of input tokens used to create the cache entry.\n\tCacheCreationInputTokens int64 `json:\"cache_creation_input_tokens\" api:\"required\"`\n\t// The number of input tokens read from the cache.\n\tCacheReadInputTokens int64 `json:\"cache_read_input_tokens\" api:\"required\"`\n\t// The geographic region where inference was performed for this request.\n\tInferenceGeo string `json:\"inference_geo\" api:\"required\"`\n\t// The number of input tokens which were used.\n\tInputTokens int64 `json:\"input_tokens\" api:\"required\"`\n\t// The number of output tokens which were used.\n\tOutputTokens int64 `json:\"output_tokens\" api:\"required\"`\n\t// The number of server tool requests.\n\tServerToolUse ServerToolUsage `json:\"server_tool_use\" api:\"required\"`\n\t// If the request used the priority, standard, or batch tier.\n\t//\n\t// Any of \"standard\", \"priority\", \"batch\".\n\tServiceTier UsageServiceTier `json:\"service_tier\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCacheCreation            respjson.Field\n\t\tCacheCreationInputTokens respjson.Field\n\t\tCacheReadInputTokens     respjson.Field\n\t\tInferenceGeo             respjson.Field\n\t\tInputTokens              respjson.Field\n\t\tOutputTokens             respjson.Field\n\t\tServerToolUse            respjson.Field\n\t\tServiceTier              respjson.Field\n\t\tExtraFields              map[string]respjson.Field\n\t\traw                      string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Usage) RawJSON() string { return r.JSON.raw }\nfunc (r *Usage) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// If the request used the priority, standard, or batch tier.\ntype UsageServiceTier string\n\nconst (\n\tUsageServiceTierStandard UsageServiceTier = \"standard\"\n\tUsageServiceTierPriority UsageServiceTier = \"priority\"\n\tUsageServiceTierBatch    UsageServiceTier = \"batch\"\n)\n\n// The property Type is required.\ntype UserLocationParam struct {\n\t// The city of the user.\n\tCity param.Opt[string] `json:\"city,omitzero\"`\n\t// The two letter\n\t// [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the\n\t// user.\n\tCountry param.Opt[string] `json:\"country,omitzero\"`\n\t// The region of the user.\n\tRegion param.Opt[string] `json:\"region,omitzero\"`\n\t// The [IANA timezone](https://nodatime.org/TimeZones) of the user.\n\tTimezone param.Opt[string] `json:\"timezone,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"approximate\".\n\tType constant.Approximate `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r UserLocationParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow UserLocationParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *UserLocationParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype WebFetchBlock struct {\n\tContent DocumentBlock `json:\"content\" api:\"required\"`\n\t// ISO 8601 timestamp when the content was retrieved\n\tRetrievedAt string                  `json:\"retrieved_at\" api:\"required\"`\n\tType        constant.WebFetchResult `json:\"type\" api:\"required\"`\n\t// Fetched content URL\n\tURL string `json:\"url\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tContent     respjson.Field\n\t\tRetrievedAt respjson.Field\n\t\tType        respjson.Field\n\t\tURL         respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r WebFetchBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *WebFetchBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, Type, URL are required.\ntype WebFetchBlockParam struct {\n\tContent DocumentBlockParam `json:\"content,omitzero\" api:\"required\"`\n\t// Fetched content URL\n\tURL string `json:\"url\" api:\"required\"`\n\t// ISO 8601 timestamp when the content was retrieved\n\tRetrievedAt param.Opt[string] `json:\"retrieved_at,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as \"web_fetch_result\".\n\tType constant.WebFetchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebFetchBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebFetchBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebFetchBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype WebFetchTool20250910Param struct {\n\t// Maximum number of tokens used by including web page text content in the context.\n\t// The limit is approximate and does not apply to binary content such as PDFs.\n\tMaxContentTokens param.Opt[int64] `json:\"max_content_tokens,omitzero\"`\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// List of domains to allow fetching from\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// List of domains to block fetching from\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Citations configuration for fetched documents. Citations are disabled by\n\t// default.\n\tCitations CitationsConfigParam `json:\"citations,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_fetch\".\n\tName constant.WebFetch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_20250910\".\n\tType constant.WebFetch20250910 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebFetchTool20250910Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebFetchTool20250910Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebFetchTool20250910Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype WebFetchTool20260209Param struct {\n\t// Maximum number of tokens used by including web page text content in the context.\n\t// The limit is approximate and does not apply to binary content such as PDFs.\n\tMaxContentTokens param.Opt[int64] `json:\"max_content_tokens,omitzero\"`\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// List of domains to allow fetching from\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// List of domains to block fetching from\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Citations configuration for fetched documents. Citations are disabled by\n\t// default.\n\tCitations CitationsConfigParam `json:\"citations,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_fetch\".\n\tName constant.WebFetch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_20260209\".\n\tType constant.WebFetch20260209 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebFetchTool20260209Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebFetchTool20260209Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebFetchTool20260209Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Web fetch tool with use_cache parameter for bypassing cached content.\n//\n// The properties Name, Type are required.\ntype WebFetchTool20260309Param struct {\n\t// Maximum number of tokens used by including web page text content in the context.\n\t// The limit is approximate and does not apply to binary content such as PDFs.\n\tMaxContentTokens param.Opt[int64] `json:\"max_content_tokens,omitzero\"`\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// Whether to use cached content. Set to false to bypass the cache and fetch fresh\n\t// content. Only set to false when the user explicitly requests fresh content or\n\t// when fetching rapidly-changing sources.\n\tUseCache param.Opt[bool] `json:\"use_cache,omitzero\"`\n\t// List of domains to allow fetching from\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// List of domains to block fetching from\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Citations configuration for fetched documents. Citations are disabled by\n\t// default.\n\tCitations CitationsConfigParam `json:\"citations,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_fetch\".\n\tName constant.WebFetch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_20260309\".\n\tType constant.WebFetch20260309 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebFetchTool20260309Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebFetchTool20260309Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebFetchTool20260309Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype WebFetchToolResultBlock struct {\n\t// Tool invocation directly from the model.\n\tCaller    WebFetchToolResultBlockCallerUnion  `json:\"caller\" api:\"required\"`\n\tContent   WebFetchToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                              `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.WebFetchToolResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCaller      respjson.Field\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r WebFetchToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *WebFetchToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// WebFetchToolResultBlockCallerUnion contains all possible properties and values\n// from [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120].\n//\n// Use the [WebFetchToolResultBlockCallerUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype WebFetchToolResultBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyWebFetchToolResultBlockCaller is implemented by each variant of\n// [WebFetchToolResultBlockCallerUnion] to add type safety for the return type of\n// [WebFetchToolResultBlockCallerUnion.AsAny]\ntype anyWebFetchToolResultBlockCaller interface {\n\timplWebFetchToolResultBlockCallerUnion()\n}\n\nfunc (DirectCaller) implWebFetchToolResultBlockCallerUnion()             {}\nfunc (ServerToolCaller) implWebFetchToolResultBlockCallerUnion()         {}\nfunc (ServerToolCaller20260120) implWebFetchToolResultBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := WebFetchToolResultBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.DirectCaller:\n//\tcase anthropic.ServerToolCaller:\n//\tcase anthropic.ServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u WebFetchToolResultBlockCallerUnion) AsAny() anyWebFetchToolResultBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u WebFetchToolResultBlockCallerUnion) AsDirect() (v DirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u WebFetchToolResultBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u WebFetchToolResultBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u WebFetchToolResultBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *WebFetchToolResultBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// WebFetchToolResultBlockContentUnion contains all possible properties and values\n// from [WebFetchToolResultErrorBlock], [WebFetchBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype WebFetchToolResultBlockContentUnion struct {\n\t// This field is from variant [WebFetchToolResultErrorBlock].\n\tErrorCode WebFetchToolResultErrorCode `json:\"error_code\"`\n\tType      string                      `json:\"type\"`\n\t// This field is from variant [WebFetchBlock].\n\tContent DocumentBlock `json:\"content\"`\n\t// This field is from variant [WebFetchBlock].\n\tRetrievedAt string `json:\"retrieved_at\"`\n\t// This field is from variant [WebFetchBlock].\n\tURL  string `json:\"url\"`\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tContent     respjson.Field\n\t\tRetrievedAt respjson.Field\n\t\tURL         respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\nfunc (u WebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError() (v WebFetchToolResultErrorBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u WebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock() (v WebFetchBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u WebFetchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *WebFetchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype WebFetchToolResultBlockParam struct {\n\tContent   WebFetchToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                   `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller WebFetchToolResultBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_tool_result\".\n\tType constant.WebFetchToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebFetchToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebFetchToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebFetchToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype WebFetchToolResultBlockParamContentUnion struct {\n\tOfRequestWebFetchToolResultError *WebFetchToolResultErrorBlockParam `json:\",omitzero,inline\"`\n\tOfRequestWebFetchResultBlock     *WebFetchBlockParam                `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u WebFetchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfRequestWebFetchToolResultError, u.OfRequestWebFetchResultBlock)\n}\nfunc (u *WebFetchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *WebFetchToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfRequestWebFetchToolResultError) {\n\t\treturn u.OfRequestWebFetchToolResultError\n\t} else if !param.IsOmitted(u.OfRequestWebFetchResultBlock) {\n\t\treturn u.OfRequestWebFetchResultBlock\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamContentUnion) GetErrorCode() *string {\n\tif vt := u.OfRequestWebFetchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.ErrorCode)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamContentUnion) GetContent() *DocumentBlockParam {\n\tif vt := u.OfRequestWebFetchResultBlock; vt != nil {\n\t\treturn &vt.Content\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamContentUnion) GetURL() *string {\n\tif vt := u.OfRequestWebFetchResultBlock; vt != nil {\n\t\treturn &vt.URL\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamContentUnion) GetRetrievedAt() *string {\n\tif vt := u.OfRequestWebFetchResultBlock; vt != nil && vt.RetrievedAt.Valid() {\n\t\treturn &vt.RetrievedAt.Value\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamContentUnion) GetType() *string {\n\tif vt := u.OfRequestWebFetchToolResultError; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfRequestWebFetchResultBlock; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype WebFetchToolResultBlockParamCallerUnion struct {\n\tOfDirect                *DirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *ServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *ServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u WebFetchToolResultBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *WebFetchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *WebFetchToolResultBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebFetchToolResultBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\ntype WebFetchToolResultErrorBlock struct {\n\t// Any of \"invalid_tool_input\", \"url_too_long\", \"url_not_allowed\",\n\t// \"url_not_accessible\", \"unsupported_content_type\", \"too_many_requests\",\n\t// \"max_uses_exceeded\", \"unavailable\".\n\tErrorCode WebFetchToolResultErrorCode      `json:\"error_code\" api:\"required\"`\n\tType      constant.WebFetchToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r WebFetchToolResultErrorBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *WebFetchToolResultErrorBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ErrorCode, Type are required.\ntype WebFetchToolResultErrorBlockParam struct {\n\t// Any of \"invalid_tool_input\", \"url_too_long\", \"url_not_allowed\",\n\t// \"url_not_accessible\", \"unsupported_content_type\", \"too_many_requests\",\n\t// \"max_uses_exceeded\", \"unavailable\".\n\tErrorCode WebFetchToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_fetch_tool_result_error\".\n\tType constant.WebFetchToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebFetchToolResultErrorBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebFetchToolResultErrorBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebFetchToolResultErrorBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype WebFetchToolResultErrorCode string\n\nconst (\n\tWebFetchToolResultErrorCodeInvalidToolInput       WebFetchToolResultErrorCode = \"invalid_tool_input\"\n\tWebFetchToolResultErrorCodeURLTooLong             WebFetchToolResultErrorCode = \"url_too_long\"\n\tWebFetchToolResultErrorCodeURLNotAllowed          WebFetchToolResultErrorCode = \"url_not_allowed\"\n\tWebFetchToolResultErrorCodeURLNotAccessible       WebFetchToolResultErrorCode = \"url_not_accessible\"\n\tWebFetchToolResultErrorCodeUnsupportedContentType WebFetchToolResultErrorCode = \"unsupported_content_type\"\n\tWebFetchToolResultErrorCodeTooManyRequests        WebFetchToolResultErrorCode = \"too_many_requests\"\n\tWebFetchToolResultErrorCodeMaxUsesExceeded        WebFetchToolResultErrorCode = \"max_uses_exceeded\"\n\tWebFetchToolResultErrorCodeUnavailable            WebFetchToolResultErrorCode = \"unavailable\"\n)\n\ntype WebSearchResultBlock struct {\n\tEncryptedContent string                   `json:\"encrypted_content\" api:\"required\"`\n\tPageAge          string                   `json:\"page_age\" api:\"required\"`\n\tTitle            string                   `json:\"title\" api:\"required\"`\n\tType             constant.WebSearchResult `json:\"type\" api:\"required\"`\n\tURL              string                   `json:\"url\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tEncryptedContent respjson.Field\n\t\tPageAge          respjson.Field\n\t\tTitle            respjson.Field\n\t\tType             respjson.Field\n\t\tURL              respjson.Field\n\t\tExtraFields      map[string]respjson.Field\n\t\traw              string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r WebSearchResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *WebSearchResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties EncryptedContent, Title, Type, URL are required.\ntype WebSearchResultBlockParam struct {\n\tEncryptedContent string            `json:\"encrypted_content\" api:\"required\"`\n\tTitle            string            `json:\"title\" api:\"required\"`\n\tURL              string            `json:\"url\" api:\"required\"`\n\tPageAge          param.Opt[string] `json:\"page_age,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_result\".\n\tType constant.WebSearchResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebSearchResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebSearchResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebSearchResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype WebSearchTool20250305Param struct {\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// If provided, only these domains will be included in results. Cannot be used\n\t// alongside `blocked_domains`.\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// If provided, these domains will never appear in results. Cannot be used\n\t// alongside `allowed_domains`.\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Parameters for the user's location. Used to provide more relevant search\n\t// results.\n\tUserLocation UserLocationParam `json:\"user_location,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_search\".\n\tName constant.WebSearch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_20250305\".\n\tType constant.WebSearch20250305 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebSearchTool20250305Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebSearchTool20250305Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebSearchTool20250305Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Name, Type are required.\ntype WebSearchTool20260209Param struct {\n\t// Maximum number of times the tool can be used in the API request.\n\tMaxUses param.Opt[int64] `json:\"max_uses,omitzero\"`\n\t// If true, tool will not be included in initial system prompt. Only loaded when\n\t// returned via tool_reference from tool search.\n\tDeferLoading param.Opt[bool] `json:\"defer_loading,omitzero\"`\n\t// When true, guarantees schema validation on tool names and inputs\n\tStrict param.Opt[bool] `json:\"strict,omitzero\"`\n\t// If provided, only these domains will be included in results. Cannot be used\n\t// alongside `blocked_domains`.\n\tAllowedDomains []string `json:\"allowed_domains,omitzero\"`\n\t// If provided, these domains will never appear in results. Cannot be used\n\t// alongside `allowed_domains`.\n\tBlockedDomains []string `json:\"blocked_domains,omitzero\"`\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tAllowedCallers []string `json:\"allowed_callers,omitzero\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Parameters for the user's location. Used to provide more relevant search\n\t// results.\n\tUserLocation UserLocationParam `json:\"user_location,omitzero\"`\n\t// Name of the tool.\n\t//\n\t// This is how the tool will be called by the model and in `tool_use` blocks.\n\t//\n\t// This field can be elided, and will marshal its zero value as \"web_search\".\n\tName constant.WebSearch `json:\"name\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_20260209\".\n\tType constant.WebSearch20260209 `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebSearchTool20260209Param) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebSearchTool20260209Param\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebSearchTool20260209Param) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties ErrorCode, Type are required.\ntype WebSearchToolRequestErrorParam struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"max_uses_exceeded\",\n\t// \"too_many_requests\", \"query_too_long\", \"request_too_large\".\n\tErrorCode WebSearchToolResultErrorCode `json:\"error_code,omitzero\" api:\"required\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_tool_result_error\".\n\tType constant.WebSearchToolResultError `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebSearchToolRequestErrorParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebSearchToolRequestErrorParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebSearchToolRequestErrorParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype WebSearchToolResultBlock struct {\n\t// Tool invocation directly from the model.\n\tCaller    WebSearchToolResultBlockCallerUnion  `json:\"caller\" api:\"required\"`\n\tContent   WebSearchToolResultBlockContentUnion `json:\"content\" api:\"required\"`\n\tToolUseID string                               `json:\"tool_use_id\" api:\"required\"`\n\tType      constant.WebSearchToolResult         `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCaller      respjson.Field\n\t\tContent     respjson.Field\n\t\tToolUseID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r WebSearchToolResultBlock) RawJSON() string { return r.JSON.raw }\nfunc (r *WebSearchToolResultBlock) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// WebSearchToolResultBlockCallerUnion contains all possible properties and values\n// from [DirectCaller], [ServerToolCaller], [ServerToolCaller20260120].\n//\n// Use the [WebSearchToolResultBlockCallerUnion.AsAny] method to switch on the\n// variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype WebSearchToolResultBlockCallerUnion struct {\n\t// Any of \"direct\", \"code_execution_20250825\", \"code_execution_20260120\".\n\tType   string `json:\"type\"`\n\tToolID string `json:\"tool_id\"`\n\tJSON   struct {\n\t\tType   respjson.Field\n\t\tToolID respjson.Field\n\t\traw    string\n\t} `json:\"-\"`\n}\n\n// anyWebSearchToolResultBlockCaller is implemented by each variant of\n// [WebSearchToolResultBlockCallerUnion] to add type safety for the return type of\n// [WebSearchToolResultBlockCallerUnion.AsAny]\ntype anyWebSearchToolResultBlockCaller interface {\n\timplWebSearchToolResultBlockCallerUnion()\n}\n\nfunc (DirectCaller) implWebSearchToolResultBlockCallerUnion()             {}\nfunc (ServerToolCaller) implWebSearchToolResultBlockCallerUnion()         {}\nfunc (ServerToolCaller20260120) implWebSearchToolResultBlockCallerUnion() {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := WebSearchToolResultBlockCallerUnion.AsAny().(type) {\n//\tcase anthropic.DirectCaller:\n//\tcase anthropic.ServerToolCaller:\n//\tcase anthropic.ServerToolCaller20260120:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u WebSearchToolResultBlockCallerUnion) AsAny() anyWebSearchToolResultBlockCaller {\n\tswitch u.Type {\n\tcase \"direct\":\n\t\treturn u.AsDirect()\n\tcase \"code_execution_20250825\":\n\t\treturn u.AsCodeExecution20250825()\n\tcase \"code_execution_20260120\":\n\t\treturn u.AsCodeExecution20260120()\n\t}\n\treturn nil\n}\n\nfunc (u WebSearchToolResultBlockCallerUnion) AsDirect() (v DirectCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u WebSearchToolResultBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u WebSearchToolResultBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u WebSearchToolResultBlockCallerUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *WebSearchToolResultBlockCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// WebSearchToolResultBlockContentUnion contains all possible properties and values\n// from [WebSearchToolResultError], [[]WebSearchResultBlock].\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\n//\n// If the underlying value is not a json object, one of the following properties\n// will be valid: OfWebSearchResultBlockArray]\ntype WebSearchToolResultBlockContentUnion struct {\n\t// This field will be present if the value is a [[]WebSearchResultBlock] instead of\n\t// an object.\n\tOfWebSearchResultBlockArray []WebSearchResultBlock `json:\",inline\"`\n\t// This field is from variant [WebSearchToolResultError].\n\tErrorCode WebSearchToolResultErrorCode `json:\"error_code\"`\n\t// This field is from variant [WebSearchToolResultError].\n\tType constant.WebSearchToolResultError `json:\"type\"`\n\tJSON struct {\n\t\tOfWebSearchResultBlockArray respjson.Field\n\t\tErrorCode                   respjson.Field\n\t\tType                        respjson.Field\n\t\traw                         string\n\t} `json:\"-\"`\n}\n\nfunc (u WebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v WebSearchToolResultError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u WebSearchToolResultBlockContentUnion) AsWebSearchResultBlockArray() (v []WebSearchResultBlock) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u WebSearchToolResultBlockContentUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *WebSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties Content, ToolUseID, Type are required.\ntype WebSearchToolResultBlockParam struct {\n\tContent   WebSearchToolResultBlockParamContentUnion `json:\"content,omitzero\" api:\"required\"`\n\tToolUseID string                                    `json:\"tool_use_id\" api:\"required\"`\n\t// Create a cache control breakpoint at this content block.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Tool invocation directly from the model.\n\tCaller WebSearchToolResultBlockParamCallerUnion `json:\"caller,omitzero\"`\n\t// This field can be elided, and will marshal its zero value as\n\t// \"web_search_tool_result\".\n\tType constant.WebSearchToolResult `json:\"type\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r WebSearchToolResultBlockParam) MarshalJSON() (data []byte, err error) {\n\ttype shadow WebSearchToolResultBlockParam\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *WebSearchToolResultBlockParam) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype WebSearchToolResultBlockParamCallerUnion struct {\n\tOfDirect                *DirectCallerParam             `json:\",omitzero,inline\"`\n\tOfCodeExecution20250825 *ServerToolCallerParam         `json:\",omitzero,inline\"`\n\tOfCodeExecution20260120 *ServerToolCaller20260120Param `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u WebSearchToolResultBlockParamCallerUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfDirect, u.OfCodeExecution20250825, u.OfCodeExecution20260120)\n}\nfunc (u *WebSearchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *WebSearchToolResultBlockParamCallerUnion) asAny() any {\n\tif !param.IsOmitted(u.OfDirect) {\n\t\treturn u.OfDirect\n\t} else if !param.IsOmitted(u.OfCodeExecution20250825) {\n\t\treturn u.OfCodeExecution20250825\n\t} else if !param.IsOmitted(u.OfCodeExecution20260120) {\n\t\treturn u.OfCodeExecution20260120\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebSearchToolResultBlockParamCallerUnion) GetType() *string {\n\tif vt := u.OfDirect; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.Type)\n\t}\n\treturn nil\n}\n\n// Returns a pointer to the underlying variant's property, if present.\nfunc (u WebSearchToolResultBlockParamCallerUnion) GetToolID() *string {\n\tif vt := u.OfCodeExecution20250825; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t} else if vt := u.OfCodeExecution20260120; vt != nil {\n\t\treturn (*string)(&vt.ToolID)\n\t}\n\treturn nil\n}\n\nfunc NewWebSearchToolRequestError(errorCode WebSearchToolResultErrorCode) WebSearchToolResultBlockParamContentUnion {\n\tvar variant WebSearchToolRequestErrorParam\n\tvariant.ErrorCode = errorCode\n\treturn WebSearchToolResultBlockParamContentUnion{OfRequestWebSearchToolResultError: &variant}\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype WebSearchToolResultBlockParamContentUnion struct {\n\tOfWebSearchToolResultBlockItem    []WebSearchResultBlockParam     `json:\",omitzero,inline\"`\n\tOfRequestWebSearchToolResultError *WebSearchToolRequestErrorParam `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u WebSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfWebSearchToolResultBlockItem, u.OfRequestWebSearchToolResultError)\n}\nfunc (u *WebSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *WebSearchToolResultBlockParamContentUnion) asAny() any {\n\tif !param.IsOmitted(u.OfWebSearchToolResultBlockItem) {\n\t\treturn &u.OfWebSearchToolResultBlockItem\n\t} else if !param.IsOmitted(u.OfRequestWebSearchToolResultError) {\n\t\treturn u.OfRequestWebSearchToolResultError\n\t}\n\treturn nil\n}\n\ntype WebSearchToolResultError struct {\n\t// Any of \"invalid_tool_input\", \"unavailable\", \"max_uses_exceeded\",\n\t// \"too_many_requests\", \"query_too_long\", \"request_too_large\".\n\tErrorCode WebSearchToolResultErrorCode      `json:\"error_code\" api:\"required\"`\n\tType      constant.WebSearchToolResultError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tErrorCode   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r WebSearchToolResultError) RawJSON() string { return r.JSON.raw }\nfunc (r *WebSearchToolResultError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype WebSearchToolResultErrorCode string\n\nconst (\n\tWebSearchToolResultErrorCodeInvalidToolInput WebSearchToolResultErrorCode = \"invalid_tool_input\"\n\tWebSearchToolResultErrorCodeUnavailable      WebSearchToolResultErrorCode = \"unavailable\"\n\tWebSearchToolResultErrorCodeMaxUsesExceeded  WebSearchToolResultErrorCode = \"max_uses_exceeded\"\n\tWebSearchToolResultErrorCodeTooManyRequests  WebSearchToolResultErrorCode = \"too_many_requests\"\n\tWebSearchToolResultErrorCodeQueryTooLong     WebSearchToolResultErrorCode = \"query_too_long\"\n\tWebSearchToolResultErrorCodeRequestTooLarge  WebSearchToolResultErrorCode = \"request_too_large\"\n)\n\ntype MessageNewParams struct {\n\t// The maximum number of tokens to generate before stopping.\n\t//\n\t// Note that our models may stop _before_ reaching this maximum. This parameter\n\t// only specifies the absolute maximum number of tokens to generate.\n\t//\n\t// Different models have different maximum values for this parameter. See\n\t// [models](https://docs.claude.com/en/docs/models-overview) for details.\n\tMaxTokens int64 `json:\"max_tokens\" api:\"required\"`\n\t// Input messages.\n\t//\n\t// Our models are trained to operate on alternating `user` and `assistant`\n\t// conversational turns. When creating a new `Message`, you specify the prior\n\t// conversational turns with the `messages` parameter, and the model then generates\n\t// the next `Message` in the conversation. Consecutive `user` or `assistant` turns\n\t// in your request will be combined into a single turn.\n\t//\n\t// Each input message must be an object with a `role` and `content`. You can\n\t// specify a single `user`-role message, or you can include multiple `user` and\n\t// `assistant` messages.\n\t//\n\t// If the final message uses the `assistant` role, the response content will\n\t// continue immediately from the content in that message. This can be used to\n\t// constrain part of the model's response.\n\t//\n\t// Example with a single `user` message:\n\t//\n\t// ```json\n\t// [{ \"role\": \"user\", \"content\": \"Hello, Claude\" }]\n\t// ```\n\t//\n\t// Example with multiple conversational turns:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{ \"role\": \"user\", \"content\": \"Hello there.\" },\n\t//\t{ \"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\" },\n\t//\t{ \"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Example with a partially-filled response from Claude:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Each input message `content` may be either a single `string` or an array of\n\t// content blocks, where each block has a specific `type`. Using a `string` for\n\t// `content` is shorthand for an array of one content block of type `\"text\"`. The\n\t// following input messages are equivalent:\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": \"Hello, Claude\" }\n\t// ```\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": [{ \"type\": \"text\", \"text\": \"Hello, Claude\" }] }\n\t// ```\n\t//\n\t// See [input examples](https://docs.claude.com/en/api/messages-examples).\n\t//\n\t// Note that if you want to include a\n\t// [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the\n\t// top-level `system` parameter — there is no `\"system\"` role for input messages in\n\t// the Messages API.\n\t//\n\t// There is a limit of 100,000 messages in a single request.\n\tMessages []MessageParam `json:\"messages,omitzero\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// Container identifier for reuse across requests.\n\tContainer param.Opt[string] `json:\"container,omitzero\"`\n\t// Specifies the geographic region for inference processing. If not specified, the\n\t// workspace's `default_inference_geo` is used.\n\tInferenceGeo param.Opt[string] `json:\"inference_geo,omitzero\"`\n\t// Amount of randomness injected into the response.\n\t//\n\t// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`\n\t// for analytical / multiple choice, and closer to `1.0` for creative and\n\t// generative tasks.\n\t//\n\t// Note that even with `temperature` of `0.0`, the results will not be fully\n\t// deterministic.\n\tTemperature param.Opt[float64] `json:\"temperature,omitzero\"`\n\t// Only sample from the top K options for each subsequent token.\n\t//\n\t// Used to remove \"long tail\" low probability responses.\n\t// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopK param.Opt[int64] `json:\"top_k,omitzero\"`\n\t// Use nucleus sampling.\n\t//\n\t// In nucleus sampling, we compute the cumulative distribution over all the options\n\t// for each subsequent token in decreasing probability order and cut it off once it\n\t// reaches a particular probability specified by `top_p`. You should either alter\n\t// `temperature` or `top_p`, but not both.\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopP param.Opt[float64] `json:\"top_p,omitzero\"`\n\t// Top-level cache control automatically applies a cache_control marker to the last\n\t// cacheable block in the request.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// An object describing metadata about the request.\n\tMetadata MetadataParam `json:\"metadata,omitzero\"`\n\t// Configuration options for the model's output, such as the output format.\n\tOutputConfig OutputConfigParam `json:\"output_config,omitzero\"`\n\t// Determines whether to use priority capacity (if available) or standard capacity\n\t// for this request.\n\t//\n\t// Anthropic offers different levels of service for your API requests. See\n\t// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.\n\t//\n\t// Any of \"auto\", \"standard_only\".\n\tServiceTier MessageNewParamsServiceTier `json:\"service_tier,omitzero\"`\n\t// Custom text sequences that will cause the model to stop generating.\n\t//\n\t// Our models will normally stop when they have naturally completed their turn,\n\t// which will result in a response `stop_reason` of `\"end_turn\"`.\n\t//\n\t// If you want the model to stop generating when it encounters custom strings of\n\t// text, you can use the `stop_sequences` parameter. If the model encounters one of\n\t// the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"`\n\t// and the response `stop_sequence` value will contain the matched stop sequence.\n\tStopSequences []string `json:\"stop_sequences,omitzero\"`\n\t// System prompt.\n\t//\n\t// A system prompt is a way of providing context and instructions to Claude, such\n\t// as specifying a particular goal or role. See our\n\t// [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).\n\tSystem []TextBlockParam `json:\"system,omitzero\"`\n\t// Configuration for enabling Claude's extended thinking.\n\t//\n\t// When enabled, responses include `thinking` content blocks showing Claude's\n\t// thinking process before the final answer. Requires a minimum budget of 1,024\n\t// tokens and counts towards your `max_tokens` limit.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tThinking ThinkingConfigParamUnion `json:\"thinking,omitzero\"`\n\t// How the model should use the provided tools. The model can use a specific tool,\n\t// any available tool, decide by itself, or not use tools at all.\n\tToolChoice ToolChoiceUnionParam `json:\"tool_choice,omitzero\"`\n\t// Definitions of tools that the model may use.\n\t//\n\t// If you include `tools` in your API request, the model may return `tool_use`\n\t// content blocks that represent the model's use of those tools. You can then run\n\t// those tools using the tool input generated by the model and then optionally\n\t// return results back to the model using `tool_result` content blocks.\n\t//\n\t// There are two types of tools: **client tools** and **server tools**. The\n\t// behavior described below applies to client tools. For\n\t// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),\n\t// see their individual documentation as each has its own behavior (e.g., the\n\t// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\t//\n\t// Each tool definition includes:\n\t//\n\t//   - `name`: Name of the tool.\n\t//   - `description`: Optional, but strongly-recommended description of the tool.\n\t//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the\n\t//     tool `input` shape that the model will produce in `tool_use` output content\n\t//     blocks.\n\t//\n\t// For example, if you defined `tools` as:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"description\": \"Get the current stock price for a given ticker symbol.\",\n\t//\t  \"input_schema\": {\n\t//\t    \"type\": \"object\",\n\t//\t    \"properties\": {\n\t//\t      \"ticker\": {\n\t//\t        \"type\": \"string\",\n\t//\t        \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n\t//\t      }\n\t//\t    },\n\t//\t    \"required\": [\"ticker\"]\n\t//\t  }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// And then asked the model \"What's the S&P 500 at today?\", the model might produce\n\t// `tool_use` content blocks in the response like this:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_use\",\n\t//\t  \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"input\": { \"ticker\": \"^GSPC\" }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// You might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an\n\t// input, and return the following back to the model in a subsequent `user`\n\t// message:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_result\",\n\t//\t  \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"content\": \"259.75 USD\"\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Tools can be used for workflows that include running client-side tools and\n\t// functions, or more generally whenever you want the model to produce a particular\n\t// JSON structure of output.\n\t//\n\t// See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.\n\tTools []ToolUnionParam `json:\"tools,omitzero\"`\n\tparamObj\n}\n\nfunc (r MessageNewParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow MessageNewParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MessageNewParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Determines whether to use priority capacity (if available) or standard capacity\n// for this request.\n//\n// Anthropic offers different levels of service for your API requests. See\n// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.\ntype MessageNewParamsServiceTier string\n\nconst (\n\tMessageNewParamsServiceTierAuto         MessageNewParamsServiceTier = \"auto\"\n\tMessageNewParamsServiceTierStandardOnly MessageNewParamsServiceTier = \"standard_only\"\n)\n\ntype MessageCountTokensParams struct {\n\t// Input messages.\n\t//\n\t// Our models are trained to operate on alternating `user` and `assistant`\n\t// conversational turns. When creating a new `Message`, you specify the prior\n\t// conversational turns with the `messages` parameter, and the model then generates\n\t// the next `Message` in the conversation. Consecutive `user` or `assistant` turns\n\t// in your request will be combined into a single turn.\n\t//\n\t// Each input message must be an object with a `role` and `content`. You can\n\t// specify a single `user`-role message, or you can include multiple `user` and\n\t// `assistant` messages.\n\t//\n\t// If the final message uses the `assistant` role, the response content will\n\t// continue immediately from the content in that message. This can be used to\n\t// constrain part of the model's response.\n\t//\n\t// Example with a single `user` message:\n\t//\n\t// ```json\n\t// [{ \"role\": \"user\", \"content\": \"Hello, Claude\" }]\n\t// ```\n\t//\n\t// Example with multiple conversational turns:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{ \"role\": \"user\", \"content\": \"Hello there.\" },\n\t//\t{ \"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\" },\n\t//\t{ \"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Example with a partially-filled response from Claude:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Each input message `content` may be either a single `string` or an array of\n\t// content blocks, where each block has a specific `type`. Using a `string` for\n\t// `content` is shorthand for an array of one content block of type `\"text\"`. The\n\t// following input messages are equivalent:\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": \"Hello, Claude\" }\n\t// ```\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": [{ \"type\": \"text\", \"text\": \"Hello, Claude\" }] }\n\t// ```\n\t//\n\t// See [input examples](https://docs.claude.com/en/api/messages-examples).\n\t//\n\t// Note that if you want to include a\n\t// [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the\n\t// top-level `system` parameter — there is no `\"system\"` role for input messages in\n\t// the Messages API.\n\t//\n\t// There is a limit of 100,000 messages in a single request.\n\tMessages []MessageParam `json:\"messages,omitzero\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// Top-level cache control automatically applies a cache_control marker to the last\n\t// cacheable block in the request.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// Configuration options for the model's output, such as the output format.\n\tOutputConfig OutputConfigParam `json:\"output_config,omitzero\"`\n\t// System prompt.\n\t//\n\t// A system prompt is a way of providing context and instructions to Claude, such\n\t// as specifying a particular goal or role. See our\n\t// [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).\n\tSystem MessageCountTokensParamsSystemUnion `json:\"system,omitzero\"`\n\t// Configuration for enabling Claude's extended thinking.\n\t//\n\t// When enabled, responses include `thinking` content blocks showing Claude's\n\t// thinking process before the final answer. Requires a minimum budget of 1,024\n\t// tokens and counts towards your `max_tokens` limit.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tThinking ThinkingConfigParamUnion `json:\"thinking,omitzero\"`\n\t// How the model should use the provided tools. The model can use a specific tool,\n\t// any available tool, decide by itself, or not use tools at all.\n\tToolChoice ToolChoiceUnionParam `json:\"tool_choice,omitzero\"`\n\t// Definitions of tools that the model may use.\n\t//\n\t// If you include `tools` in your API request, the model may return `tool_use`\n\t// content blocks that represent the model's use of those tools. You can then run\n\t// those tools using the tool input generated by the model and then optionally\n\t// return results back to the model using `tool_result` content blocks.\n\t//\n\t// There are two types of tools: **client tools** and **server tools**. The\n\t// behavior described below applies to client tools. For\n\t// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),\n\t// see their individual documentation as each has its own behavior (e.g., the\n\t// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\t//\n\t// Each tool definition includes:\n\t//\n\t//   - `name`: Name of the tool.\n\t//   - `description`: Optional, but strongly-recommended description of the tool.\n\t//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the\n\t//     tool `input` shape that the model will produce in `tool_use` output content\n\t//     blocks.\n\t//\n\t// For example, if you defined `tools` as:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"description\": \"Get the current stock price for a given ticker symbol.\",\n\t//\t  \"input_schema\": {\n\t//\t    \"type\": \"object\",\n\t//\t    \"properties\": {\n\t//\t      \"ticker\": {\n\t//\t        \"type\": \"string\",\n\t//\t        \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n\t//\t      }\n\t//\t    },\n\t//\t    \"required\": [\"ticker\"]\n\t//\t  }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// And then asked the model \"What's the S&P 500 at today?\", the model might produce\n\t// `tool_use` content blocks in the response like this:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_use\",\n\t//\t  \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"input\": { \"ticker\": \"^GSPC\" }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// You might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an\n\t// input, and return the following back to the model in a subsequent `user`\n\t// message:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_result\",\n\t//\t  \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"content\": \"259.75 USD\"\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Tools can be used for workflows that include running client-side tools and\n\t// functions, or more generally whenever you want the model to produce a particular\n\t// JSON structure of output.\n\t//\n\t// See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.\n\tTools []MessageCountTokensToolUnionParam `json:\"tools,omitzero\"`\n\tparamObj\n}\n\nfunc (r MessageCountTokensParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow MessageCountTokensParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MessageCountTokensParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Only one field can be non-zero.\n//\n// Use [param.IsOmitted] to confirm if a field is set.\ntype MessageCountTokensParamsSystemUnion struct {\n\tOfString         param.Opt[string] `json:\",omitzero,inline\"`\n\tOfTextBlockArray []TextBlockParam  `json:\",omitzero,inline\"`\n\tparamUnion\n}\n\nfunc (u MessageCountTokensParamsSystemUnion) MarshalJSON() ([]byte, error) {\n\treturn param.MarshalUnion(u, u.OfString, u.OfTextBlockArray)\n}\nfunc (u *MessageCountTokensParamsSystemUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, u)\n}\n\nfunc (u *MessageCountTokensParamsSystemUnion) asAny() any {\n\tif !param.IsOmitted(u.OfString) {\n\t\treturn &u.OfString.Value\n\t} else if !param.IsOmitted(u.OfTextBlockArray) {\n\t\treturn &u.OfTextBlockArray\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "message_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\nfunc TestMessageNewWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t},\n\t\t\t\t\tCitations: []anthropic.TextCitationParamUnion{{\n\t\t\t\t\t\tOfCharLocation: &anthropic.CitationCharLocationParam{\n\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t},\n\t\tContainer:    anthropic.String(\"container\"),\n\t\tInferenceGeo: anthropic.String(\"inference_geo\"),\n\t\tMetadata: anthropic.MetadataParam{\n\t\t\tUserID: anthropic.String(\"13803d75-b4b5-4c3e-b2a2-6f21399b021b\"),\n\t\t},\n\t\tOutputConfig: anthropic.OutputConfigParam{\n\t\t\tEffort: anthropic.OutputConfigEffortLow,\n\t\t\tFormat: anthropic.JSONOutputFormatParam{\n\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tServiceTier:   anthropic.MessageNewParamsServiceTierAuto,\n\t\tStopSequences: []string{\"string\"},\n\t\tSystem: []anthropic.TextBlockParam{{\n\t\t\tText: \"Today's date is 2024-06-01.\",\n\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t},\n\t\t\tCitations: []anthropic.TextCitationParamUnion{{\n\t\t\t\tOfCharLocation: &anthropic.CitationCharLocationParam{\n\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t},\n\t\t\t}},\n\t\t}},\n\t\tTemperature: anthropic.Float(1),\n\t\tThinking: anthropic.ThinkingConfigParamUnion{\n\t\t\tOfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{\n\t\t\t\tDisplay: anthropic.ThinkingConfigAdaptiveDisplaySummarized,\n\t\t\t},\n\t\t},\n\t\tToolChoice: anthropic.ToolChoiceUnionParam{\n\t\t\tOfAuto: &anthropic.ToolChoiceAutoParam{\n\t\t\t\tDisableParallelToolUse: anthropic.Bool(true),\n\t\t\t},\n\t\t},\n\t\tTools: []anthropic.ToolUnionParam{{\n\t\t\tOfTool: &anthropic.ToolParam{\n\t\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\t\"location\": \"bar\",\n\t\t\t\t\t\t\"unit\":     \"bar\",\n\t\t\t\t\t},\n\t\t\t\t\tRequired: []string{\"location\"},\n\t\t\t\t},\n\t\t\t\tName:           \"name\",\n\t\t\t\tAllowedCallers: []string{\"direct\"},\n\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tDeferLoading:        anthropic.Bool(true),\n\t\t\t\tDescription:         anthropic.String(\"Get the current weather in a given location\"),\n\t\t\t\tEagerInputStreaming: anthropic.Bool(true),\n\t\t\t\tInputExamples: []map[string]any{{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t}},\n\t\t\t\tStrict: anthropic.Bool(true),\n\t\t\t\tType:   anthropic.ToolTypeCustom,\n\t\t\t},\n\t\t}},\n\t\tTopK: anthropic.Int(5),\n\t\tTopP: anthropic.Float(0.7),\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestMessageCountTokensWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.CountTokens(context.TODO(), anthropic.MessageCountTokensParams{\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t},\n\t\t\t\t\tCitations: []anthropic.TextCitationParamUnion{{\n\t\t\t\t\t\tOfCharLocation: &anthropic.CitationCharLocationParam{\n\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t},\n\t\tOutputConfig: anthropic.OutputConfigParam{\n\t\t\tEffort: anthropic.OutputConfigEffortLow,\n\t\t\tFormat: anthropic.JSONOutputFormatParam{\n\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tSystem: anthropic.MessageCountTokensParamsSystemUnion{\n\t\t\tOfTextBlockArray: []anthropic.TextBlockParam{{\n\t\t\t\tText: \"Today's date is 2024-06-01.\",\n\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tCitations: []anthropic.TextCitationParamUnion{{\n\t\t\t\t\tOfCharLocation: &anthropic.CitationCharLocationParam{\n\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t}},\n\t\t},\n\t\tThinking: anthropic.ThinkingConfigParamUnion{\n\t\t\tOfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{\n\t\t\t\tDisplay: anthropic.ThinkingConfigAdaptiveDisplaySummarized,\n\t\t\t},\n\t\t},\n\t\tToolChoice: anthropic.ToolChoiceUnionParam{\n\t\t\tOfAuto: &anthropic.ToolChoiceAutoParam{\n\t\t\t\tDisableParallelToolUse: anthropic.Bool(true),\n\t\t\t},\n\t\t},\n\t\tTools: []anthropic.MessageCountTokensToolUnionParam{{\n\t\t\tOfTool: &anthropic.ToolParam{\n\t\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\t\"location\": \"bar\",\n\t\t\t\t\t\t\"unit\":     \"bar\",\n\t\t\t\t\t},\n\t\t\t\t\tRequired: []string{\"location\"},\n\t\t\t\t},\n\t\t\t\tName:           \"name\",\n\t\t\t\tAllowedCallers: []string{\"direct\"},\n\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tDeferLoading:        anthropic.Bool(true),\n\t\t\t\tDescription:         anthropic.String(\"Get the current weather in a given location\"),\n\t\t\t\tEagerInputStreaming: anthropic.Bool(true),\n\t\t\t\tInputExamples: []map[string]any{{\n\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t}},\n\t\t\t\tStrict: anthropic.Bool(true),\n\t\t\t\tType:   anthropic.ToolTypeCustom,\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestAccumulate(t *testing.T) {\n\tfor name, testCase := range map[string]struct {\n\t\texpected anthropic.Message\n\t\tevents   []string\n\t}{\n\t\t\"empty message\": {\n\t\t\texpected: anthropic.Message{Usage: anthropic.Usage{}},\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type: \"message_stop\"}`,\n\t\t\t},\n\t\t},\n\t\t\"text content block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"text\", \"text\": \"This \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\", \"text\": \"is a \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\": \"text\": \"text block!\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"text\", Text: \"This is a text block!\"},\n\t\t\t}},\n\t\t},\n\t\t\"text content block with citations\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"text\", \"text\": \"1 + 1\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\", \"text\": \" = 2\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"citations_delta\", \"citation\": {\"type\": \"char_location\", \"cited_text\": \"1 + 1 = 2\", \"document_index\": 0, \"document_title\": \"Math Facts\", \"start_char_index\": 300, \"end_char_index\": 310 }}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"text\", Text: \"1 + 1 = 2\", Citations: []anthropic.TextCitationUnion{{\n\t\t\t\t\tType:           \"char_location\",\n\t\t\t\t\tCitedText:      \"1 + 1 = 2\",\n\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\tDocumentTitle:  \"Math Facts\",\n\t\t\t\t\tStartCharIndex: 300,\n\t\t\t\t\tEndCharIndex:   310,\n\t\t\t\t}}},\n\t\t\t}},\n\t\t},\n\t\t\"tool use block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"tool_use\", \"id\": \"toolu_id\", \"name\": \"tool_name\", \"input\": {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"{\\\"argument\\\":\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \" \\\"value\\\"}\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"tool_use\", ID: \"toolu_id\", Name: \"tool_name\", Input: []byte(`{\"argument\": \"value\"}`)},\n\t\t\t}},\n\t\t},\n\t\t\"tool use block with no params\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\": \"index\": 0, \"content_block\": {\"type\": \"tool_use\", \"id\": \"toolu_id\", \"name\": \"tool_name\", input: {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"tool_use\", ID: \"toolu_id\", Name: \"tool_name\"},\n\t\t\t}},\n\t\t},\n\t\t\"server tool use block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\": \"index\": 0, \"content_block\": {\"type\": \"server_tool_use\", \"id\": \"srvtoolu_id\", \"name\": \"web_search\", input: {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"{\\\"query\\\": \\\"weat\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"her\\\"}\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"server_tool_use\", ID: \"srvtoolu_id\", Name: \"web_search\", Input: []byte(`{\"query\": \"weather\"}`)},\n\t\t\t}},\n\t\t},\n\t\t\"thinking block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"thinking\", \"thinking\": \"Let me think...\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"\nFirst, let's try this...\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"\nTherefore, the answer is...\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"signature_delta\", \"signature\": \"ThinkingSignature\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"thinking\", Thinking: \"Let me think...\\nFirst, let's try this...\\nTherefore, the answer is...\", Signature: \"ThinkingSignature\"},\n\t\t\t}},\n\t\t},\n\t\t\"redacted thinking block\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"redacted_thinking\", \"data\": \"Redacted\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"redacted_thinking\", Data: \"Redacted\"},\n\t\t\t}},\n\t\t},\n\t\t\"multiple content blocks\": {\n\t\t\tevents: []string{\n\t\t\t\t`{\"type\": \"message_start\", \"message\": {}}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 0, \"content_block\": {\"type\": \"text\", \"text\": \"Let me look up \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\", \"text\": \"the weather for \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 0, \"delta\": {\"type\": \"text_delta\": \"text\": \"you.\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 0}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 1, \"content_block\": {\"type\": \"thinking\", \"thinking\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 1, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"I can look this \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 1, \"delta\": {\"type\": \"thinking_delta\", \"thinking\": \"up using a tool.\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 1}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 2, \"content_block\": {\"type\": \"tool_use\", \"id\": \"toolu_id\", \"name\": \"get_weather\", \"input\": {}}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 2, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"{\\\"city\\\": \"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 2, \"delta\": {\"type\": \"input_json_delta\", \"partial_json\": \"\\\"Los Angeles\\\"}\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 2}`,\n\t\t\t\t`{\"type\": \"content_block_start\", \"index\": 3, \"content_block\": {\"type\": \"text\", \"text\": \"\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 3, \"delta\": {\"type\": \"text_delta\", \"text\": \"The weather in Los Angeles\"}}`,\n\t\t\t\t`{\"type\": \"content_block_delta\", \"index\": 3, \"delta\": {\"type\": \"text_delta\", \"text\": \" is 85 degrees Fahrenheit!\"}}`,\n\t\t\t\t`{\"type\": \"content_block_stop\", \"index\": 3\"}`,\n\t\t\t\t`{\"type\": \"message_stop\"}`,\n\t\t\t},\n\t\t\texpected: anthropic.Message{Content: []anthropic.ContentBlockUnion{\n\t\t\t\t{Type: \"text\", Text: \"Let me look up the weather for you.\"},\n\t\t\t\t{Type: \"thinking\", Thinking: \"I can look this up using a tool.\"},\n\t\t\t\t{Type: \"tool_use\", ID: \"toolu_id\", Name: \"get_weather\", Input: []byte(`{\"city\": \"Los Angeles\"}`)},\n\t\t\t\t{Type: \"text\", Text: \"The weather in Los Angeles is 85 degrees Fahrenheit!\"},\n\t\t\t}},\n\t\t},\n\t} {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tmessage := anthropic.Message{}\n\t\t\tfor _, eventStr := range testCase.events {\n\t\t\t\tevent := anthropic.MessageStreamEventUnion{}\n\t\t\t\terr := (&event).UnmarshalJSON([]byte(eventStr))\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t\t(&message).Accumulate(event)\n\t\t\t}\n\t\t\tmarshaledMessage, err := json.Marshal(message)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tmarshaledExpectedMessage, err := json.Marshal(testCase.expected)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tif string(marshaledMessage) != string(marshaledExpectedMessage) {\n\t\t\t\tt.Fatalf(\"Mismatched message: expected %s but got %s\", marshaledExpectedMessage, marshaledMessage)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestMessageNewWithNonStreamingTimeoutLimits(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\n\t// Set a model with known token limits\n\tmodel := anthropic.ModelClaudeOpus4_20250514\n\ttestModelLimit := constant.ModelNonStreamingTokens[string(model)]\n\n\t// This test verifies that we can still create a message with tokens below the limit\n\tsafeParams := anthropic.MessageNewParams{\n\t\tMaxTokens: int64(testModelLimit - 1000), // Well below the limit\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{Text: \"What is a quaternion?\"},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: model,\n\t}\n\n\t_, err := client.Messages.New(context.TODO(), safeParams)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"Expected no error for tokens below limit, got: %v\", err)\n\t}\n\n\t// This test verifies that we get an error when exceeding the limit\n\tunsafeParams := anthropic.MessageNewParams{\n\t\tMaxTokens: int64(testModelLimit + 1000), // Exceed the limit\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{Text: \"What is a quaternion?\"},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: model,\n\t}\n\n\t_, err = client.Messages.New(context.TODO(), unsafeParams)\n\tif err == nil {\n\t\tt.Fatal(\"Expected error for tokens above limit, got nil\")\n\t}\n}\n\nfunc TestCalculateNonStreamingTimeout(t *testing.T) {\n\t// Store original model token limits to restore after test\n\toriginalModelTokenLimits := make(map[string]int)\n\tfor k, v := range constant.ModelNonStreamingTokens {\n\t\toriginalModelTokenLimits[k] = v\n\t}\n\tdefer func() {\n\t\t// Restore original model token limits\n\t\tconstant.ModelNonStreamingTokens = originalModelTokenLimits\n\t}()\n\n\t// Set up a test model for consistent testing\n\tconstant.ModelNonStreamingTokens = map[string]int{\n\t\t\"test-model\": 8192,\n\t}\n\tdefaultTimeout := 10 * time.Minute\n\n\ttests := []struct {\n\t\tname          string\n\t\tmaxTokens     int\n\t\tmodel         string\n\t\texpectTimeout time.Duration\n\t\texpectError   bool\n\t\topts          []option.RequestOption\n\t}{\n\t\t{\n\t\t\tname:          \"small token count returns default timeout\",\n\t\t\tmaxTokens:     1000,\n\t\t\tmodel:         \"any-model\",\n\t\t\texpectTimeout: defaultTimeout,\n\t\t\texpectError:   false,\n\t\t},\n\t\t{\n\t\t\tname:          \"large token count above default time limit throws error\",\n\t\t\tmaxTokens:     100000,\n\t\t\tmodel:         \"any-model\",\n\t\t\texpectTimeout: 0,\n\t\t\texpectError:   true,\n\t\t},\n\t\t{\n\t\t\tname:          \"token count above model specific limit throws error\",\n\t\t\tmaxTokens:     9000,\n\t\t\tmodel:         \"test-model\",\n\t\t\texpectTimeout: 0,\n\t\t\texpectError:   true,\n\t\t},\n\t\t{\n\t\t\tname:          \"token count below model specific limit is ok\",\n\t\t\tmaxTokens:     8000,\n\t\t\tmodel:         \"test-model\",\n\t\t\texpectTimeout: defaultTimeout,\n\t\t\texpectError:   false,\n\t\t},\n\t\t{\n\t\t\tname:          \"user supplies custom timeout so we'll use that instead\",\n\t\t\tmaxTokens:     1000,\n\t\t\tmodel:         \"test-model\",\n\t\t\texpectTimeout: 30 * time.Second, // Custom timeout\n\t\t\texpectError:   false,\n\t\t\topts: []option.RequestOption{\n\t\t\t\toption.WithRequestTimeout(30 * time.Second),\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, tc := range tests {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\ttimeout, err := anthropic.CalculateNonStreamingTimeout(tc.maxTokens, anthropic.Model(tc.model), tc.opts)\n\n\t\t\tif tc.expectError && err == nil {\n\t\t\t\tt.Error(\"Expected error but got nil\")\n\t\t\t}\n\n\t\t\tif !tc.expectError && err != nil {\n\t\t\t\tt.Errorf(\"Did not expect error but got: %v\", err)\n\t\t\t}\n\n\t\t\tif timeout != tc.expectTimeout {\n\t\t\t\tt.Errorf(\"Expected timeout %v but got %v\", tc.expectTimeout, timeout)\n\t\t\t}\n\t\t})\n\t}\n}\n\n// Test specific model limits\nfunc TestModelLimits(t *testing.T) {\n\t// Verify the model limits are defined for opus-4 models\n\tif _, exists := constant.ModelNonStreamingTokens[\"claude-opus-4-20250514\"]; !exists {\n\t\tt.Error(\"Expected model limit for claude-opus-4-20250514 but not found\")\n\t}\n\n\tif _, exists := constant.ModelNonStreamingTokens[\"anthropic.claude-opus-4-20250514-v1:0\"]; !exists {\n\t\tt.Error(\"Expected model limit for anthropic.claude-opus-4-20250514-v1:0 but not found\")\n\t}\n\n\tif _, exists := constant.ModelNonStreamingTokens[\"claude-opus-4@20250514\"]; !exists {\n\t\tt.Error(\"Expected model limit for claude-opus-4@20250514 but not found\")\n\t}\n}\n\nfunc TestToolResultBlockParamStringContent(t *testing.T) {\n\ttoolResultJSON := `{\"type\":\"tool_result\",\"content\":\"error message\",\"tool_use_id\":\"123\"}`\n\tvar toolResult anthropic.ToolResultBlockParam\n\terr := json.Unmarshal([]byte(toolResultJSON), &toolResult)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(toolResult.Content) != 1 || toolResult.Content[0].OfText.Text != \"error message\" {\n\t\tt.Error(\"String content not converted to TextBlock\")\n\t}\n}\n\nfunc TestMessageParamStringContent(t *testing.T) {\n\tmessageJSON := `{\"role\":\"user\",\"content\":\"hello world\"}`\n\tvar message anthropic.MessageParam\n\terr := json.Unmarshal([]byte(messageJSON), &message)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(message.Content) != 1 || message.Content[0].OfText.Text != \"hello world\" {\n\t\tt.Error(\"String content not converted to TextBlock\")\n\t}\n}\n\nfunc TestMessageParamArrayContent(t *testing.T) {\n\tmessageJSON := `{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"first block\"},{\"type\":\"text\",\"text\":\"second block\"}]}`\n\tvar message anthropic.MessageParam\n\terr := json.Unmarshal([]byte(messageJSON), &message)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(message.Content) != 2 {\n\t\tt.Errorf(\"Expected 2 content blocks, got %d\", len(message.Content))\n\t}\n\tif message.Content[0].OfText.Text != \"first block\" {\n\t\tt.Errorf(\"Expected first block text 'first block', got '%s'\", message.Content[0].OfText.Text)\n\t}\n\tif message.Content[1].OfText.Text != \"second block\" {\n\t\tt.Errorf(\"Expected second block text 'second block', got '%s'\", message.Content[1].OfText.Text)\n\t}\n}\n"
  },
  {
    "path": "messagebatch.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/jsonl\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// MessageBatchService contains methods and other services that help with\n// interacting with the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewMessageBatchService] method instead.\ntype MessageBatchService struct {\n\tOptions []option.RequestOption\n}\n\n// NewMessageBatchService generates a new service that applies the given options to\n// each request. These options are applied after the parent client's options (if\n// there is one), and before any request-specific options.\nfunc NewMessageBatchService(opts ...option.RequestOption) (r MessageBatchService) {\n\tr = MessageBatchService{}\n\tr.Options = opts\n\treturn\n}\n\n// Send a batch of Message creation requests.\n//\n// The Message Batches API can be used to process multiple Messages API requests at\n// once. Once a Message Batch is created, it begins processing immediately. Batches\n// can take up to 24 hours to complete.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) New(ctx context.Context, body MessageBatchNewParams, opts ...option.RequestOption) (res *MessageBatch, err error) {\n\topts = slices.Concat(r.Options, opts)\n\tpath := \"v1/messages/batches\"\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)\n\treturn res, err\n}\n\n// This endpoint is idempotent and can be used to poll for Message Batch\n// completion. To access the results of a Message Batch, make a request to the\n// `results_url` field in the response.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) Get(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error) {\n\topts = slices.Concat(r.Options, opts)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// List all Message Batches within a Workspace. Most recently created batches are\n// returned first.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) List(ctx context.Context, query MessageBatchListParams, opts ...option.RequestOption) (res *pagination.Page[MessageBatch], err error) {\n\tvar raw *http.Response\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)\n\tpath := \"v1/messages/batches\"\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List all Message Batches within a Workspace. Most recently created batches are\n// returned first.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) ListAutoPaging(ctx context.Context, query MessageBatchListParams, opts ...option.RequestOption) *pagination.PageAutoPager[MessageBatch] {\n\treturn pagination.NewPageAutoPager(r.List(ctx, query, opts...))\n}\n\n// Delete a Message Batch.\n//\n// Message Batches can only be deleted once they've finished processing. If you'd\n// like to delete an in-progress batch, you must first cancel it.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) Delete(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *DeletedMessageBatch, err error) {\n\topts = slices.Concat(r.Options, opts)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Batches may be canceled any time before processing ends. Once cancellation is\n// initiated, the batch enters a `canceling` state, at which time the system may\n// complete any in-progress, non-interruptible requests before finalizing\n// cancellation.\n//\n// The number of canceled requests is specified in `request_counts`. To determine\n// which requests were canceled, check the individual results within the batch.\n// Note that cancellation may not result in any canceled requests if they were\n// non-interruptible.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) Cancel(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error) {\n\topts = slices.Concat(r.Options, opts)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s/cancel\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// Streams the results of a Message Batch as a `.jsonl` file.\n//\n// Each line in the file is a JSON object containing the result of a single request\n// in the Message Batch. Results are not guaranteed to be in the same order as\n// requests. Use the `custom_id` field to match results to requests.\n//\n// Learn more about the Message Batches API in our\n// [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)\nfunc (r *MessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (stream *jsonl.Stream[MessageBatchIndividualResponse]) {\n\tvar (\n\t\traw *http.Response\n\t\terr error\n\t)\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithHeader(\"Accept\", \"application/x-jsonl\")}, opts...)\n\tif messageBatchID == \"\" {\n\t\terr = errors.New(\"missing required message_batch_id parameter\")\n\t\treturn jsonl.NewStream[MessageBatchIndividualResponse](nil, err)\n\t}\n\tpath := fmt.Sprintf(\"v1/messages/batches/%s/results\", messageBatchID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &raw, opts...)\n\treturn jsonl.NewStream[MessageBatchIndividualResponse](raw, err)\n}\n\ntype DeletedMessageBatch struct {\n\t// ID of the Message Batch.\n\tID string `json:\"id\" api:\"required\"`\n\t// Deleted object type.\n\t//\n\t// For Message Batches, this is always `\"message_batch_deleted\"`.\n\tType constant.MessageBatchDeleted `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID          respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r DeletedMessageBatch) RawJSON() string { return r.JSON.raw }\nfunc (r *DeletedMessageBatch) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageBatch struct {\n\t// Unique object identifier.\n\t//\n\t// The format and length of IDs may change over time.\n\tID string `json:\"id\" api:\"required\"`\n\t// RFC 3339 datetime string representing the time at which the Message Batch was\n\t// archived and its results became unavailable.\n\tArchivedAt time.Time `json:\"archived_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which cancellation was\n\t// initiated for the Message Batch. Specified only if cancellation was initiated.\n\tCancelInitiatedAt time.Time `json:\"cancel_initiated_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which the Message Batch was\n\t// created.\n\tCreatedAt time.Time `json:\"created_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which processing for the\n\t// Message Batch ended. Specified only once processing ends.\n\t//\n\t// Processing ends when every request in a Message Batch has either succeeded,\n\t// errored, canceled, or expired.\n\tEndedAt time.Time `json:\"ended_at\" api:\"required\" format:\"date-time\"`\n\t// RFC 3339 datetime string representing the time at which the Message Batch will\n\t// expire and end processing, which is 24 hours after creation.\n\tExpiresAt time.Time `json:\"expires_at\" api:\"required\" format:\"date-time\"`\n\t// Processing status of the Message Batch.\n\t//\n\t// Any of \"in_progress\", \"canceling\", \"ended\".\n\tProcessingStatus MessageBatchProcessingStatus `json:\"processing_status\" api:\"required\"`\n\t// Tallies requests within the Message Batch, categorized by their status.\n\t//\n\t// Requests start as `processing` and move to one of the other statuses only once\n\t// processing of the entire batch ends. The sum of all values always matches the\n\t// total number of requests in the batch.\n\tRequestCounts MessageBatchRequestCounts `json:\"request_counts\" api:\"required\"`\n\t// URL to a `.jsonl` file containing the results of the Message Batch requests.\n\t// Specified only once processing ends.\n\t//\n\t// Results in the file are not guaranteed to be in the same order as requests. Use\n\t// the `custom_id` field to match results to requests.\n\tResultsURL string `json:\"results_url\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Message Batches, this is always `\"message_batch\"`.\n\tType constant.MessageBatch `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID                respjson.Field\n\t\tArchivedAt        respjson.Field\n\t\tCancelInitiatedAt respjson.Field\n\t\tCreatedAt         respjson.Field\n\t\tEndedAt           respjson.Field\n\t\tExpiresAt         respjson.Field\n\t\tProcessingStatus  respjson.Field\n\t\tRequestCounts     respjson.Field\n\t\tResultsURL        respjson.Field\n\t\tType              respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatch) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatch) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Processing status of the Message Batch.\ntype MessageBatchProcessingStatus string\n\nconst (\n\tMessageBatchProcessingStatusInProgress MessageBatchProcessingStatus = \"in_progress\"\n\tMessageBatchProcessingStatusCanceling  MessageBatchProcessingStatus = \"canceling\"\n\tMessageBatchProcessingStatusEnded      MessageBatchProcessingStatus = \"ended\"\n)\n\ntype MessageBatchCanceledResult struct {\n\tType constant.Canceled `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatchCanceledResult) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatchCanceledResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageBatchErroredResult struct {\n\tError shared.ErrorResponse `json:\"error\" api:\"required\"`\n\tType  constant.Errored     `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tError       respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatchErroredResult) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatchErroredResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageBatchExpiredResult struct {\n\tType constant.Expired `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatchExpiredResult) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatchExpiredResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// This is a single line in the response `.jsonl` file and does not represent the\n// response as a whole.\ntype MessageBatchIndividualResponse struct {\n\t// Developer-provided ID created for each request in a Message Batch. Useful for\n\t// matching results to requests, as results may be given out of request order.\n\t//\n\t// Must be unique for each request within the Message Batch.\n\tCustomID string `json:\"custom_id\" api:\"required\"`\n\t// Processing result for this request.\n\t//\n\t// Contains a Message output if processing was successful, an error response if\n\t// processing failed, or the reason why processing was not attempted, such as\n\t// cancellation or expiration.\n\tResult MessageBatchResultUnion `json:\"result\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCustomID    respjson.Field\n\t\tResult      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatchIndividualResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatchIndividualResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageBatchRequestCounts struct {\n\t// Number of requests in the Message Batch that have been canceled.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tCanceled int64 `json:\"canceled\" api:\"required\"`\n\t// Number of requests in the Message Batch that encountered an error.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tErrored int64 `json:\"errored\" api:\"required\"`\n\t// Number of requests in the Message Batch that have expired.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tExpired int64 `json:\"expired\" api:\"required\"`\n\t// Number of requests in the Message Batch that are processing.\n\tProcessing int64 `json:\"processing\" api:\"required\"`\n\t// Number of requests in the Message Batch that have completed successfully.\n\t//\n\t// This is zero until processing of the entire Message Batch has ended.\n\tSucceeded int64 `json:\"succeeded\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tCanceled    respjson.Field\n\t\tErrored     respjson.Field\n\t\tExpired     respjson.Field\n\t\tProcessing  respjson.Field\n\t\tSucceeded   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatchRequestCounts) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatchRequestCounts) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// MessageBatchResultUnion contains all possible properties and values from\n// [MessageBatchSucceededResult], [MessageBatchErroredResult],\n// [MessageBatchCanceledResult], [MessageBatchExpiredResult].\n//\n// Use the [MessageBatchResultUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype MessageBatchResultUnion struct {\n\t// This field is from variant [MessageBatchSucceededResult].\n\tMessage Message `json:\"message\"`\n\t// Any of \"succeeded\", \"errored\", \"canceled\", \"expired\".\n\tType string `json:\"type\"`\n\t// This field is from variant [MessageBatchErroredResult].\n\tError shared.ErrorResponse `json:\"error\"`\n\tJSON  struct {\n\t\tMessage respjson.Field\n\t\tType    respjson.Field\n\t\tError   respjson.Field\n\t\traw     string\n\t} `json:\"-\"`\n}\n\n// anyMessageBatchResult is implemented by each variant of\n// [MessageBatchResultUnion] to add type safety for the return type of\n// [MessageBatchResultUnion.AsAny]\ntype anyMessageBatchResult interface {\n\timplMessageBatchResultUnion()\n}\n\nfunc (MessageBatchSucceededResult) implMessageBatchResultUnion() {}\nfunc (MessageBatchErroredResult) implMessageBatchResultUnion()   {}\nfunc (MessageBatchCanceledResult) implMessageBatchResultUnion()  {}\nfunc (MessageBatchExpiredResult) implMessageBatchResultUnion()   {}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := MessageBatchResultUnion.AsAny().(type) {\n//\tcase anthropic.MessageBatchSucceededResult:\n//\tcase anthropic.MessageBatchErroredResult:\n//\tcase anthropic.MessageBatchCanceledResult:\n//\tcase anthropic.MessageBatchExpiredResult:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u MessageBatchResultUnion) AsAny() anyMessageBatchResult {\n\tswitch u.Type {\n\tcase \"succeeded\":\n\t\treturn u.AsSucceeded()\n\tcase \"errored\":\n\t\treturn u.AsErrored()\n\tcase \"canceled\":\n\t\treturn u.AsCanceled()\n\tcase \"expired\":\n\t\treturn u.AsExpired()\n\t}\n\treturn nil\n}\n\nfunc (u MessageBatchResultUnion) AsSucceeded() (v MessageBatchSucceededResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageBatchResultUnion) AsErrored() (v MessageBatchErroredResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageBatchResultUnion) AsCanceled() (v MessageBatchCanceledResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u MessageBatchResultUnion) AsExpired() (v MessageBatchExpiredResult) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u MessageBatchResultUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *MessageBatchResultUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageBatchSucceededResult struct {\n\tMessage Message            `json:\"message\" api:\"required\"`\n\tType    constant.Succeeded `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r MessageBatchSucceededResult) RawJSON() string { return r.JSON.raw }\nfunc (r *MessageBatchSucceededResult) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype MessageBatchNewParams struct {\n\t// List of requests for prompt completion. Each is an individual request to create\n\t// a Message.\n\tRequests []MessageBatchNewParamsRequest `json:\"requests,omitzero\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r MessageBatchNewParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow MessageBatchNewParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MessageBatchNewParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// The properties CustomID, Params are required.\ntype MessageBatchNewParamsRequest struct {\n\t// Developer-provided ID created for each request in a Message Batch. Useful for\n\t// matching results to requests, as results may be given out of request order.\n\t//\n\t// Must be unique for each request within the Message Batch.\n\tCustomID string `json:\"custom_id\" api:\"required\"`\n\t// Messages API creation parameters for the individual request.\n\t//\n\t// See the [Messages API reference](https://docs.claude.com/en/api/messages) for\n\t// full documentation on available parameters.\n\tParams MessageBatchNewParamsRequestParams `json:\"params,omitzero\" api:\"required\"`\n\tparamObj\n}\n\nfunc (r MessageBatchNewParamsRequest) MarshalJSON() (data []byte, err error) {\n\ttype shadow MessageBatchNewParamsRequest\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MessageBatchNewParamsRequest) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Messages API creation parameters for the individual request.\n//\n// See the [Messages API reference](https://docs.claude.com/en/api/messages) for\n// full documentation on available parameters.\n//\n// The properties MaxTokens, Messages, Model are required.\ntype MessageBatchNewParamsRequestParams struct {\n\t// The maximum number of tokens to generate before stopping.\n\t//\n\t// Note that our models may stop _before_ reaching this maximum. This parameter\n\t// only specifies the absolute maximum number of tokens to generate.\n\t//\n\t// Different models have different maximum values for this parameter. See\n\t// [models](https://docs.claude.com/en/docs/models-overview) for details.\n\tMaxTokens int64 `json:\"max_tokens\" api:\"required\"`\n\t// Input messages.\n\t//\n\t// Our models are trained to operate on alternating `user` and `assistant`\n\t// conversational turns. When creating a new `Message`, you specify the prior\n\t// conversational turns with the `messages` parameter, and the model then generates\n\t// the next `Message` in the conversation. Consecutive `user` or `assistant` turns\n\t// in your request will be combined into a single turn.\n\t//\n\t// Each input message must be an object with a `role` and `content`. You can\n\t// specify a single `user`-role message, or you can include multiple `user` and\n\t// `assistant` messages.\n\t//\n\t// If the final message uses the `assistant` role, the response content will\n\t// continue immediately from the content in that message. This can be used to\n\t// constrain part of the model's response.\n\t//\n\t// Example with a single `user` message:\n\t//\n\t// ```json\n\t// [{ \"role\": \"user\", \"content\": \"Hello, Claude\" }]\n\t// ```\n\t//\n\t// Example with multiple conversational turns:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{ \"role\": \"user\", \"content\": \"Hello there.\" },\n\t//\t{ \"role\": \"assistant\", \"content\": \"Hi, I'm Claude. How can I help you?\" },\n\t//\t{ \"role\": \"user\", \"content\": \"Can you explain LLMs in plain English?\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Example with a partially-filled response from Claude:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"role\": \"user\",\n\t//\t  \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n\t//\t},\n\t//\t{ \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Each input message `content` may be either a single `string` or an array of\n\t// content blocks, where each block has a specific `type`. Using a `string` for\n\t// `content` is shorthand for an array of one content block of type `\"text\"`. The\n\t// following input messages are equivalent:\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": \"Hello, Claude\" }\n\t// ```\n\t//\n\t// ```json\n\t// { \"role\": \"user\", \"content\": [{ \"type\": \"text\", \"text\": \"Hello, Claude\" }] }\n\t// ```\n\t//\n\t// See [input examples](https://docs.claude.com/en/api/messages-examples).\n\t//\n\t// Note that if you want to include a\n\t// [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the\n\t// top-level `system` parameter — there is no `\"system\"` role for input messages in\n\t// the Messages API.\n\t//\n\t// There is a limit of 100,000 messages in a single request.\n\tMessages []MessageParam `json:\"messages,omitzero\" api:\"required\"`\n\t// The model that will complete your prompt.\\n\\nSee\n\t// [models](https://docs.anthropic.com/en/docs/models-overview) for additional\n\t// details and options.\n\tModel Model `json:\"model,omitzero\" api:\"required\"`\n\t// Container identifier for reuse across requests.\n\tContainer param.Opt[string] `json:\"container,omitzero\"`\n\t// Specifies the geographic region for inference processing. If not specified, the\n\t// workspace's `default_inference_geo` is used.\n\tInferenceGeo param.Opt[string] `json:\"inference_geo,omitzero\"`\n\t// Whether to incrementally stream the response using server-sent events.\n\t//\n\t// See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.\n\tStream param.Opt[bool] `json:\"stream,omitzero\"`\n\t// Amount of randomness injected into the response.\n\t//\n\t// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`\n\t// for analytical / multiple choice, and closer to `1.0` for creative and\n\t// generative tasks.\n\t//\n\t// Note that even with `temperature` of `0.0`, the results will not be fully\n\t// deterministic.\n\tTemperature param.Opt[float64] `json:\"temperature,omitzero\"`\n\t// Only sample from the top K options for each subsequent token.\n\t//\n\t// Used to remove \"long tail\" low probability responses.\n\t// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopK param.Opt[int64] `json:\"top_k,omitzero\"`\n\t// Use nucleus sampling.\n\t//\n\t// In nucleus sampling, we compute the cumulative distribution over all the options\n\t// for each subsequent token in decreasing probability order and cut it off once it\n\t// reaches a particular probability specified by `top_p`. You should either alter\n\t// `temperature` or `top_p`, but not both.\n\t//\n\t// Recommended for advanced use cases only. You usually only need to use\n\t// `temperature`.\n\tTopP param.Opt[float64] `json:\"top_p,omitzero\"`\n\t// Top-level cache control automatically applies a cache_control marker to the last\n\t// cacheable block in the request.\n\tCacheControl CacheControlEphemeralParam `json:\"cache_control,omitzero\"`\n\t// An object describing metadata about the request.\n\tMetadata MetadataParam `json:\"metadata,omitzero\"`\n\t// Configuration options for the model's output, such as the output format.\n\tOutputConfig OutputConfigParam `json:\"output_config,omitzero\"`\n\t// Determines whether to use priority capacity (if available) or standard capacity\n\t// for this request.\n\t//\n\t// Anthropic offers different levels of service for your API requests. See\n\t// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.\n\t//\n\t// Any of \"auto\", \"standard_only\".\n\tServiceTier string `json:\"service_tier,omitzero\"`\n\t// Custom text sequences that will cause the model to stop generating.\n\t//\n\t// Our models will normally stop when they have naturally completed their turn,\n\t// which will result in a response `stop_reason` of `\"end_turn\"`.\n\t//\n\t// If you want the model to stop generating when it encounters custom strings of\n\t// text, you can use the `stop_sequences` parameter. If the model encounters one of\n\t// the custom sequences, the response `stop_reason` value will be `\"stop_sequence\"`\n\t// and the response `stop_sequence` value will contain the matched stop sequence.\n\tStopSequences []string `json:\"stop_sequences,omitzero\"`\n\t// System prompt.\n\t//\n\t// A system prompt is a way of providing context and instructions to Claude, such\n\t// as specifying a particular goal or role. See our\n\t// [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).\n\tSystem []TextBlockParam `json:\"system,omitzero\"`\n\t// Configuration for enabling Claude's extended thinking.\n\t//\n\t// When enabled, responses include `thinking` content blocks showing Claude's\n\t// thinking process before the final answer. Requires a minimum budget of 1,024\n\t// tokens and counts towards your `max_tokens` limit.\n\t//\n\t// See\n\t// [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)\n\t// for details.\n\tThinking ThinkingConfigParamUnion `json:\"thinking,omitzero\"`\n\t// How the model should use the provided tools. The model can use a specific tool,\n\t// any available tool, decide by itself, or not use tools at all.\n\tToolChoice ToolChoiceUnionParam `json:\"tool_choice,omitzero\"`\n\t// Definitions of tools that the model may use.\n\t//\n\t// If you include `tools` in your API request, the model may return `tool_use`\n\t// content blocks that represent the model's use of those tools. You can then run\n\t// those tools using the tool input generated by the model and then optionally\n\t// return results back to the model using `tool_result` content blocks.\n\t//\n\t// There are two types of tools: **client tools** and **server tools**. The\n\t// behavior described below applies to client tools. For\n\t// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),\n\t// see their individual documentation as each has its own behavior (e.g., the\n\t// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).\n\t//\n\t// Each tool definition includes:\n\t//\n\t//   - `name`: Name of the tool.\n\t//   - `description`: Optional, but strongly-recommended description of the tool.\n\t//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the\n\t//     tool `input` shape that the model will produce in `tool_use` output content\n\t//     blocks.\n\t//\n\t// For example, if you defined `tools` as:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"description\": \"Get the current stock price for a given ticker symbol.\",\n\t//\t  \"input_schema\": {\n\t//\t    \"type\": \"object\",\n\t//\t    \"properties\": {\n\t//\t      \"ticker\": {\n\t//\t        \"type\": \"string\",\n\t//\t        \"description\": \"The stock ticker symbol, e.g. AAPL for Apple Inc.\"\n\t//\t      }\n\t//\t    },\n\t//\t    \"required\": [\"ticker\"]\n\t//\t  }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// And then asked the model \"What's the S&P 500 at today?\", the model might produce\n\t// `tool_use` content blocks in the response like this:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_use\",\n\t//\t  \"id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"name\": \"get_stock_price\",\n\t//\t  \"input\": { \"ticker\": \"^GSPC\" }\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// You might then run your `get_stock_price` tool with `{\"ticker\": \"^GSPC\"}` as an\n\t// input, and return the following back to the model in a subsequent `user`\n\t// message:\n\t//\n\t// ```json\n\t// [\n\t//\n\t//\t{\n\t//\t  \"type\": \"tool_result\",\n\t//\t  \"tool_use_id\": \"toolu_01D7FLrfh4GYq7yT1ULFeyMV\",\n\t//\t  \"content\": \"259.75 USD\"\n\t//\t}\n\t//\n\t// ]\n\t// ```\n\t//\n\t// Tools can be used for workflows that include running client-side tools and\n\t// functions, or more generally whenever you want the model to produce a particular\n\t// JSON structure of output.\n\t//\n\t// See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.\n\tTools []ToolUnionParam `json:\"tools,omitzero\"`\n\tparamObj\n}\n\nfunc (r MessageBatchNewParamsRequestParams) MarshalJSON() (data []byte, err error) {\n\ttype shadow MessageBatchNewParamsRequestParams\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\nfunc (r *MessageBatchNewParamsRequestParams) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc init() {\n\tapijson.RegisterFieldValidator[MessageBatchNewParamsRequestParams](\n\t\t\"service_tier\", \"auto\", \"standard_only\",\n\t)\n}\n\ntype MessageBatchListParams struct {\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately after this object.\n\tAfterID param.Opt[string] `query:\"after_id,omitzero\" json:\"-\"`\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately before this object.\n\tBeforeID param.Opt[string] `query:\"before_id,omitzero\" json:\"-\"`\n\t// Number of items to return per page.\n\t//\n\t// Defaults to `20`. Ranges from `1` to `1000`.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [MessageBatchListParams]'s query parameters as `url.Values`.\nfunc (r MessageBatchListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n"
  },
  {
    "path": "messagebatch_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestMessageBatchNew(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.Batches.New(context.TODO(), anthropic.MessageBatchNewParams{\n\t\tRequests: []anthropic.MessageBatchNewParamsRequest{{\n\t\t\tCustomID: \"my-custom-id-1\",\n\t\t\tParams: anthropic.MessageBatchNewParamsRequestParams{\n\t\t\t\tMaxTokens: 1024,\n\t\t\t\tMessages: []anthropic.MessageParam{{\n\t\t\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\t\t\tText: \"x\",\n\t\t\t\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tCitations: []anthropic.TextCitationParamUnion{{\n\t\t\t\t\t\t\t\tOfCharLocation: &anthropic.CitationCharLocationParam{\n\t\t\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t\t\t}},\n\t\t\t\tModel: anthropic.ModelClaudeOpus4_6,\n\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t},\n\t\t\t\tContainer:    anthropic.String(\"container\"),\n\t\t\t\tInferenceGeo: anthropic.String(\"inference_geo\"),\n\t\t\t\tMetadata: anthropic.MetadataParam{\n\t\t\t\t\tUserID: anthropic.String(\"13803d75-b4b5-4c3e-b2a2-6f21399b021b\"),\n\t\t\t\t},\n\t\t\t\tOutputConfig: anthropic.OutputConfigParam{\n\t\t\t\t\tEffort: anthropic.OutputConfigEffortLow,\n\t\t\t\t\tFormat: anthropic.JSONOutputFormatParam{\n\t\t\t\t\t\tSchema: map[string]any{\n\t\t\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tServiceTier:   \"auto\",\n\t\t\t\tStopSequences: []string{\"string\"},\n\t\t\t\tStream:        anthropic.Bool(true),\n\t\t\t\tSystem: []anthropic.TextBlockParam{{\n\t\t\t\t\tText: \"Today's date is 2024-06-01.\",\n\t\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t},\n\t\t\t\t\tCitations: []anthropic.TextCitationParamUnion{{\n\t\t\t\t\t\tOfCharLocation: &anthropic.CitationCharLocationParam{\n\t\t\t\t\t\t\tCitedText:      \"cited_text\",\n\t\t\t\t\t\t\tDocumentIndex:  0,\n\t\t\t\t\t\t\tDocumentTitle:  anthropic.String(\"x\"),\n\t\t\t\t\t\t\tEndCharIndex:   0,\n\t\t\t\t\t\t\tStartCharIndex: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}},\n\t\t\t\t}},\n\t\t\t\tTemperature: anthropic.Float(1),\n\t\t\t\tThinking: anthropic.ThinkingConfigParamUnion{\n\t\t\t\t\tOfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{\n\t\t\t\t\t\tDisplay: anthropic.ThinkingConfigAdaptiveDisplaySummarized,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tToolChoice: anthropic.ToolChoiceUnionParam{\n\t\t\t\t\tOfAuto: &anthropic.ToolChoiceAutoParam{\n\t\t\t\t\t\tDisableParallelToolUse: anthropic.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tTools: []anthropic.ToolUnionParam{{\n\t\t\t\t\tOfTool: &anthropic.ToolParam{\n\t\t\t\t\t\tInputSchema: anthropic.ToolInputSchemaParam{\n\t\t\t\t\t\t\tProperties: map[string]any{\n\t\t\t\t\t\t\t\t\"location\": \"bar\",\n\t\t\t\t\t\t\t\t\"unit\":     \"bar\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tRequired: []string{\"location\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tName:           \"name\",\n\t\t\t\t\t\tAllowedCallers: []string{\"direct\"},\n\t\t\t\t\t\tCacheControl: anthropic.CacheControlEphemeralParam{\n\t\t\t\t\t\t\tTTL: anthropic.CacheControlEphemeralTTLTTL5m,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tDeferLoading:        anthropic.Bool(true),\n\t\t\t\t\t\tDescription:         anthropic.String(\"Get the current weather in a given location\"),\n\t\t\t\t\t\tEagerInputStreaming: anthropic.Bool(true),\n\t\t\t\t\t\tInputExamples: []map[string]any{{\n\t\t\t\t\t\t\t\"foo\": \"bar\",\n\t\t\t\t\t\t}},\n\t\t\t\t\t\tStrict: anthropic.Bool(true),\n\t\t\t\t\t\tType:   anthropic.ToolTypeCustom,\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t\tTopK: anthropic.Int(5),\n\t\t\t\tTopP: anthropic.Float(0.7),\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestMessageBatchGet(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.Batches.Get(context.TODO(), \"message_batch_id\")\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestMessageBatchListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.Batches.List(context.TODO(), anthropic.MessageBatchListParams{\n\t\tAfterID:  anthropic.String(\"after_id\"),\n\t\tBeforeID: anthropic.String(\"before_id\"),\n\t\tLimit:    anthropic.Int(1),\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestMessageBatchDelete(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.Batches.Delete(context.TODO(), \"message_batch_id\")\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestMessageBatchCancel(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Messages.Batches.Cancel(context.TODO(), \"message_batch_id\")\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "messageutil.go",
    "content": "package anthropic\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/paramutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n)\n\n// Accumulate builds up the Message incrementally from a MessageStreamEvent. The Message then can be used as\n// any other Message, except with the caveat that the Message.JSON field which normally can be used to inspect\n// the JSON sent over the network may not be populated fully.\n//\n//\tmessage := anthropic.Message{}\n//\tfor stream.Next() {\n//\t\tevent := stream.Current()\n//\t\tmessage.Accumulate(event)\n//\t}\nfunc (acc *Message) Accumulate(event MessageStreamEventUnion) error {\n\tif acc == nil {\n\t\treturn fmt.Errorf(\"accumulate: cannot accumulate into nil Message\")\n\t}\n\n\tswitch event := event.AsAny().(type) {\n\tcase MessageStartEvent:\n\t\t*acc = event.Message\n\tcase MessageDeltaEvent:\n\t\tacc.StopReason = event.Delta.StopReason\n\t\tacc.StopSequence = event.Delta.StopSequence\n\t\tacc.Usage.OutputTokens = event.Usage.OutputTokens\n\tcase ContentBlockStartEvent:\n\t\tacc.Content = append(acc.Content, ContentBlockUnion{})\n\t\terr := acc.Content[len(acc.Content)-1].UnmarshalJSON([]byte(event.ContentBlock.RawJSON()))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tcase ContentBlockDeltaEvent:\n\t\tif len(acc.Content) == 0 {\n\t\t\treturn fmt.Errorf(\"received event of type %s but there was no content block\", event.Type)\n\t\t}\n\t\tcb := &acc.Content[len(acc.Content)-1]\n\t\tswitch delta := event.Delta.AsAny().(type) {\n\t\tcase TextDelta:\n\t\t\tcb.Text += delta.Text\n\t\tcase InputJSONDelta:\n\t\t\tif len(delta.PartialJSON) != 0 {\n\t\t\t\tif string(cb.Input) == \"{}\" {\n\t\t\t\t\tcb.Input = []byte(delta.PartialJSON)\n\t\t\t\t} else {\n\t\t\t\t\tcb.Input = append(cb.Input, []byte(delta.PartialJSON)...)\n\t\t\t\t}\n\t\t\t}\n\t\tcase ThinkingDelta:\n\t\t\tcb.Thinking += delta.Thinking\n\t\tcase SignatureDelta:\n\t\t\tcb.Signature += delta.Signature\n\t\tcase CitationsDelta:\n\t\t\tcitation := TextCitationUnion{}\n\t\t\terr := citation.UnmarshalJSON([]byte(delta.Citation.RawJSON()))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not unmarshal citation delta into citation type: %w\", err)\n\t\t\t}\n\t\t\tcb.Citations = append(cb.Citations, citation)\n\t\t}\n\tcase MessageStopEvent:\n\t\t// Re-marshal the accumulated message to update JSON.raw so that AsAny()\n\t\t// returns the accumulated data rather than the original stream data\n\t\taccJSON, err := json.Marshal(acc)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error converting accumulated message to JSON: %w\", err)\n\t\t}\n\t\tacc.JSON.raw = string(accJSON)\n\tcase ContentBlockStopEvent:\n\t\t// Re-marshal the content block to update JSON.raw so that AsAny()\n\t\t// returns the accumulated data rather than the original stream data\n\t\tif len(acc.Content) == 0 {\n\t\t\treturn fmt.Errorf(\"received event of type %s but there was no content block\", event.Type)\n\t\t}\n\t\tcontentBlock := &acc.Content[len(acc.Content)-1]\n\t\tcbJSON, err := json.Marshal(contentBlock)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error converting content block to JSON: %w\", err)\n\t\t}\n\t\tcontentBlock.JSON.raw = string(cbJSON)\n\t}\n\n\treturn nil\n}\n\n// ToParam converters\n\nfunc (r Message) ToParam() MessageParam {\n\tvar p MessageParam\n\tp.Role = MessageParamRole(r.Role)\n\tp.Content = make([]ContentBlockParamUnion, len(r.Content))\n\tfor i, c := range r.Content {\n\t\tp.Content[i] = c.ToParam()\n\t}\n\treturn p\n}\n\nfunc (r ContentBlockUnion) ToParam() ContentBlockParamUnion {\n\treturn r.AsAny().toParamUnion()\n}\n\nfunc (variant TextBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfText: &p}\n}\n\nfunc (variant ToolUseBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfToolUse: &p}\n}\n\nfunc (variant WebSearchToolResultBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfWebSearchToolResult: &p}\n}\n\nfunc (variant ServerToolUseBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfServerToolUse: &p}\n}\n\nfunc (variant ThinkingBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfThinking: &p}\n}\n\nfunc (variant RedactedThinkingBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfRedactedThinking: &p}\n}\n\nfunc (r RedactedThinkingBlock) ToParam() RedactedThinkingBlockParam {\n\tvar p RedactedThinkingBlockParam\n\tp.Type = r.Type\n\tp.Data = r.Data\n\treturn p\n}\n\nfunc (r ToolUseBlock) ToParam() ToolUseBlockParam {\n\tvar toolUse ToolUseBlockParam\n\ttoolUse.Type = r.Type\n\ttoolUse.ID = r.ID\n\ttoolUse.Input = r.Input\n\ttoolUse.Name = r.Name\n\treturn toolUse\n}\n\nfunc (citationVariant CitationCharLocation) toParamUnion() TextCitationParamUnion {\n\tvar citationParam CitationCharLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.DocumentTitle = paramutil.ToOpt(citationVariant.DocumentTitle, citationVariant.JSON.DocumentTitle)\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.DocumentIndex = citationVariant.DocumentIndex\n\tcitationParam.EndCharIndex = citationVariant.EndCharIndex\n\tcitationParam.StartCharIndex = citationVariant.StartCharIndex\n\treturn TextCitationParamUnion{OfCharLocation: &citationParam}\n}\n\nfunc (citationVariant CitationPageLocation) toParamUnion() TextCitationParamUnion {\n\tvar citationParam CitationPageLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.DocumentTitle = paramutil.ToOpt(citationVariant.DocumentTitle, citationVariant.JSON.DocumentTitle)\n\tcitationParam.DocumentIndex = citationVariant.DocumentIndex\n\tcitationParam.EndPageNumber = citationVariant.EndPageNumber\n\tcitationParam.StartPageNumber = citationVariant.StartPageNumber\n\treturn TextCitationParamUnion{OfPageLocation: &citationParam}\n}\n\nfunc (citationVariant CitationContentBlockLocation) toParamUnion() TextCitationParamUnion {\n\tvar citationParam CitationContentBlockLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.DocumentTitle = paramutil.ToOpt(citationVariant.DocumentTitle, citationVariant.JSON.DocumentTitle)\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.DocumentIndex = citationVariant.DocumentIndex\n\tcitationParam.EndBlockIndex = citationVariant.EndBlockIndex\n\tcitationParam.StartBlockIndex = citationVariant.StartBlockIndex\n\treturn TextCitationParamUnion{OfContentBlockLocation: &citationParam}\n}\n\nfunc (citationVariant CitationsSearchResultLocation) toParamUnion() TextCitationParamUnion {\n\tvar citationParam CitationSearchResultLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.Title = paramutil.ToOpt(citationVariant.Title, citationVariant.JSON.Title)\n\treturn TextCitationParamUnion{OfSearchResultLocation: &citationParam}\n}\n\nfunc (citationVariant CitationsWebSearchResultLocation) toParamUnion() TextCitationParamUnion {\n\tvar citationParam CitationWebSearchResultLocationParam\n\tcitationParam.Type = citationVariant.Type\n\tcitationParam.CitedText = citationVariant.CitedText\n\tcitationParam.Title = paramutil.ToOpt(citationVariant.Title, citationVariant.JSON.Title)\n\treturn TextCitationParamUnion{OfWebSearchResultLocation: &citationParam}\n}\n\nfunc (r TextBlock) ToParam() TextBlockParam {\n\tvar p TextBlockParam\n\tp.Type = r.Type\n\tp.Text = r.Text\n\n\t// Distinguish between a nil and zero length slice, since some compatible\n\t// APIs may not require citations.\n\tif r.Citations != nil {\n\t\tp.Citations = make([]TextCitationParamUnion, 0, len(r.Citations))\n\t}\n\n\tfor _, citation := range r.Citations {\n\t\tp.Citations = append(p.Citations, citation.AsAny().toParamUnion())\n\t}\n\n\treturn p\n}\n\nfunc (r ThinkingBlock) ToParam() ThinkingBlockParam {\n\tvar p ThinkingBlockParam\n\tp.Type = r.Type\n\tp.Signature = r.Signature\n\tp.Thinking = r.Thinking\n\treturn p\n}\n\nfunc (r ServerToolUseBlock) ToParam() ServerToolUseBlockParam {\n\tvar p ServerToolUseBlockParam\n\tp.Type = r.Type\n\tp.ID = r.ID\n\tp.Input = r.Input\n\tp.Name = ServerToolUseBlockParamName(r.Name)\n\treturn p\n}\n\nfunc (r WebSearchToolResultBlock) ToParam() WebSearchToolResultBlockParam {\n\tvar p WebSearchToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tp.Content = r.Content.ToParam()\n\treturn p\n}\n\nfunc (r WebSearchResultBlock) ToParam() WebSearchResultBlockParam {\n\tvar p WebSearchResultBlockParam\n\tp.Type = r.Type\n\tp.EncryptedContent = r.EncryptedContent\n\tp.Title = r.Title\n\tp.URL = r.URL\n\tp.PageAge = paramutil.ToOpt(r.PageAge, r.JSON.PageAge)\n\treturn p\n}\n\nfunc (r WebSearchToolResultBlockContentUnion) ToParam() WebSearchToolResultBlockParamContentUnion {\n\tvar p WebSearchToolResultBlockParamContentUnion\n\n\tif len(r.OfWebSearchResultBlockArray) > 0 {\n\t\tfor _, block := range r.OfWebSearchResultBlockArray {\n\t\t\tp.OfWebSearchToolResultBlockItem = append(p.OfWebSearchToolResultBlockItem, block.ToParam())\n\t\t}\n\t\treturn p\n\t}\n\n\tp.OfRequestWebSearchToolResultError = &WebSearchToolRequestErrorParam{\n\t\tErrorCode: WebSearchToolResultErrorCode(r.ErrorCode),\n\t}\n\treturn p\n}\n\nfunc (variant WebFetchToolResultBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfWebFetchToolResult: &p}\n}\n\nfunc (variant CodeExecutionToolResultBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfCodeExecutionToolResult: &p}\n}\n\nfunc (variant BashCodeExecutionToolResultBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfBashCodeExecutionToolResult: &p}\n}\n\nfunc (variant TextEditorCodeExecutionToolResultBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfTextEditorCodeExecutionToolResult: &p}\n}\n\nfunc (variant ToolSearchToolResultBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfToolSearchToolResult: &p}\n}\n\nfunc (variant ContainerUploadBlock) toParamUnion() ContentBlockParamUnion {\n\tp := variant.ToParam()\n\treturn ContentBlockParamUnion{OfContainerUpload: &p}\n}\n\nfunc (r WebFetchToolResultBlock) ToParam() WebFetchToolResultBlockParam {\n\tvar p WebFetchToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\treturn p\n}\n\nfunc (r ContainerUploadBlock) ToParam() ContainerUploadBlockParam {\n\tvar p ContainerUploadBlockParam\n\tp.Type = r.Type\n\tp.FileID = r.FileID\n\treturn p\n}\n\nfunc (r BashCodeExecutionToolResultBlock) ToParam() BashCodeExecutionToolResultBlockParam {\n\tvar p BashCodeExecutionToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestBashCodeExecutionToolResultError = &BashCodeExecutionToolResultErrorParam{\n\t\t\tErrorCode: BashCodeExecutionToolResultErrorCode(r.Content.ErrorCode),\n\t\t}\n\t} else {\n\t\trequestBashContentResult := &BashCodeExecutionResultBlockParam{\n\t\t\tReturnCode: r.Content.ReturnCode,\n\t\t\tStderr:     r.Content.Stderr,\n\t\t\tStdout:     r.Content.Stdout,\n\t\t}\n\t\tfor _, block := range r.Content.Content {\n\t\t\trequestBashContentResult.Content = append(requestBashContentResult.Content, block.ToParam())\n\t\t}\n\t\tp.Content.OfRequestBashCodeExecutionResultBlock = requestBashContentResult\n\t}\n\n\treturn p\n}\n\nfunc (r BashCodeExecutionOutputBlock) ToParam() BashCodeExecutionOutputBlockParam {\n\tvar p BashCodeExecutionOutputBlockParam\n\tp.Type = r.Type\n\tp.FileID = r.FileID\n\treturn p\n}\n\nfunc (r CodeExecutionToolResultBlock) ToParam() CodeExecutionToolResultBlockParam {\n\tvar p CodeExecutionToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestCodeExecutionToolResultError = &CodeExecutionToolResultErrorParam{\n\t\t\tErrorCode: r.Content.ErrorCode,\n\t\t}\n\t} else {\n\t\tp.Content.OfRequestCodeExecutionResultBlock = &CodeExecutionResultBlockParam{\n\t\t\tReturnCode: r.Content.ReturnCode,\n\t\t\tStderr:     r.Content.Stderr,\n\t\t\tStdout:     r.Content.Stdout,\n\t\t}\n\t\tfor _, block := range r.Content.Content {\n\t\t\tp.Content.OfRequestCodeExecutionResultBlock.Content = append(p.Content.OfRequestCodeExecutionResultBlock.Content, block.ToParam())\n\t\t}\n\t}\n\treturn p\n}\n\nfunc (r CodeExecutionOutputBlock) ToParam() CodeExecutionOutputBlockParam {\n\tvar p CodeExecutionOutputBlockParam\n\tp.Type = r.Type\n\tp.FileID = r.FileID\n\treturn p\n}\n\nfunc (r TextEditorCodeExecutionToolResultBlock) ToParam() TextEditorCodeExecutionToolResultBlockParam {\n\tvar p TextEditorCodeExecutionToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestTextEditorCodeExecutionToolResultError = &TextEditorCodeExecutionToolResultErrorParam{\n\t\t\tErrorCode:    TextEditorCodeExecutionToolResultErrorCode(r.Content.ErrorCode),\n\t\t\tErrorMessage: paramutil.ToOpt(r.Content.ErrorMessage, r.Content.JSON.ErrorMessage),\n\t\t}\n\t} else {\n\t\tp.Content = param.Override[TextEditorCodeExecutionToolResultBlockParamContentUnion](r.Content.RawJSON())\n\t}\n\treturn p\n}\n\nfunc (r ToolSearchToolResultBlock) ToParam() ToolSearchToolResultBlockParam {\n\tvar p ToolSearchToolResultBlockParam\n\tp.Type = r.Type\n\tp.ToolUseID = r.ToolUseID\n\tif r.Content.JSON.ErrorCode.Valid() {\n\t\tp.Content.OfRequestToolSearchToolResultError = &ToolSearchToolResultErrorParam{\n\t\t\tErrorCode: ToolSearchToolResultErrorCode(r.Content.ErrorCode),\n\t\t}\n\t} else {\n\t\tp.Content.OfRequestToolSearchToolSearchResultBlock = &ToolSearchToolSearchResultBlockParam{}\n\t\tfor _, block := range r.Content.ToolReferences {\n\t\t\tp.Content.OfRequestToolSearchToolSearchResultBlock.ToolReferences = append(\n\t\t\t\tp.Content.OfRequestToolSearchToolSearchResultBlock.ToolReferences,\n\t\t\t\tblock.ToParam(),\n\t\t\t)\n\t\t}\n\t}\n\treturn p\n}\n\nfunc (r ToolReferenceBlock) ToParam() ToolReferenceBlockParam {\n\tvar p ToolReferenceBlockParam\n\tp.Type = r.Type\n\tp.ToolName = r.ToolName\n\treturn p\n}\n"
  },
  {
    "path": "messageutil_test.go",
    "content": "package anthropic_test\n\nimport (\n\t\"encoding/json\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\nfunc unmarshalContentBlockParam(t *testing.T, jsonData string) anthropic.ContentBlockParamUnion {\n\tvar block anthropic.ContentBlockUnion\n\terr := json.Unmarshal([]byte(jsonData), &block)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to unmarshal JSON: %v\", err)\n\t}\n\tresult := block.ToParam()\n\treturn result\n}\n\nfunc TestContentBlockUnionToParam(t *testing.T) {\n\tt.Run(\"TextBlock with text only\", func(t *testing.T) {\n\t\tresult := unmarshalContentBlockParam(t, `{\"type\":\"text\",\"text\":\"Hello, world!\"}`)\n\t\tif result.OfText == nil {\n\t\t\tt.Fatal(\"Expected OfText to be non-nil\")\n\t\t}\n\t\tif result.OfText.Text != \"Hello, world!\" {\n\t\t\tt.Errorf(\"Expected text 'Hello, world!', got '%s'\", result.OfText.Text)\n\t\t}\n\t\tif result.OfText.Type != constant.Text(\"text\") {\n\t\t\tt.Errorf(\"Expected type 'text', got '%s'\", result.OfText.Type)\n\t\t}\n\t})\n\n\tt.Run(\"WebSearchToolResultBlock with search results\", func(t *testing.T) {\n\t\tresult := unmarshalContentBlockParam(t, `{\"type\":\"web_search_tool_result\",\"tool_use_id\":\"test123\",\"content\":[{\"type\":\"web_search_result\",\"title\":\"Test Web Title\",\"url\":\"https://test.com\",\"encrypted_content\":\"abc123\",\"page_age\":\"1 day ago\"}]}`)\n\t\tvar block anthropic.ContentBlockUnion\n\t\tif err := json.Unmarshal([]byte(`{\"type\":\"web_search_tool_result\",\"tool_use_id\":\"test123\",\"content\":[{\"type\":\"web_search_result\",\"title\":\"Test Web Title\",\"url\":\"https://test.com\",\"encrypted_content\":\"abc123\",\"page_age\":\"1 day ago\"}]}`), &block); err != nil {\n\t\t\tt.Fatalf(\"Failed to unmarshal: %v\", err)\n\t\t}\n\n\t\tif len(block.Content.OfWebSearchResultBlockArray) != 1 {\n\t\t\tt.Errorf(\"Expected Content.OfWebSearchResultBlockArray to have 1 result, got %d\", len(block.Content.OfWebSearchResultBlockArray))\n\t\t}\n\t\tif len(block.Content.OfWebSearchResultBlockArray) > 0 && block.Content.OfWebSearchResultBlockArray[0].Title != \"Test Web Title\" {\n\t\t\tt.Errorf(\"Expected title '', got '%s'\", block.Content.OfWebSearchResultBlockArray[0].Title)\n\t\t}\n\n\t\tif result.OfWebSearchToolResult == nil {\n\t\t\tt.Fatal(\"Expected OfWebSearchToolResult to be non-nil\")\n\t\t}\n\t\tif len(result.OfWebSearchToolResult.Content.OfWebSearchToolResultBlockItem) != 1 {\n\t\t\tt.Errorf(\"Expected 1 search result in param, got %d\", len(result.OfWebSearchToolResult.Content.OfWebSearchToolResultBlockItem))\n\t\t}\n\t})\n}\n"
  },
  {
    "path": "model.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"slices\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apiquery\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/pagination\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// ModelService contains methods and other services that help with interacting with\n// the anthropic API.\n//\n// Note, unlike clients, this service does not read variables from the environment\n// automatically. You should not instantiate this service directly, and instead use\n// the [NewModelService] method instead.\ntype ModelService struct {\n\tOptions []option.RequestOption\n}\n\n// NewModelService generates a new service that applies the given options to each\n// request. These options are applied after the parent client's options (if there\n// is one), and before any request-specific options.\nfunc NewModelService(opts ...option.RequestOption) (r ModelService) {\n\tr = ModelService{}\n\tr.Options = opts\n\treturn\n}\n\n// Get a specific model.\n//\n// The Models API response can be used to determine information about a specific\n// model or resolve a model alias to a model ID.\nfunc (r *ModelService) Get(ctx context.Context, modelID string, query ModelGetParams, opts ...option.RequestOption) (res *ModelInfo, err error) {\n\tfor _, v := range query.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\tif modelID == \"\" {\n\t\terr = errors.New(\"missing required model_id parameter\")\n\t\treturn nil, err\n\t}\n\tpath := fmt.Sprintf(\"v1/models/%s\", modelID)\n\terr = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)\n\treturn res, err\n}\n\n// List available models.\n//\n// The Models API response can be used to determine which models are available for\n// use in the API. More recently released models are listed first.\nfunc (r *ModelService) List(ctx context.Context, params ModelListParams, opts ...option.RequestOption) (res *pagination.Page[ModelInfo], err error) {\n\tvar raw *http.Response\n\tfor _, v := range params.Betas {\n\t\topts = append(opts, option.WithHeaderAdd(\"anthropic-beta\", fmt.Sprintf(\"%v\", v)))\n\t}\n\topts = slices.Concat(r.Options, opts)\n\topts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)\n\tpath := \"v1/models\"\n\tcfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\n// List available models.\n//\n// The Models API response can be used to determine which models are available for\n// use in the API. More recently released models are listed first.\nfunc (r *ModelService) ListAutoPaging(ctx context.Context, params ModelListParams, opts ...option.RequestOption) *pagination.PageAutoPager[ModelInfo] {\n\treturn pagination.NewPageAutoPager(r.List(ctx, params, opts...))\n}\n\n// Indicates whether a capability is supported.\ntype CapabilitySupport struct {\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSupported   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r CapabilitySupport) RawJSON() string { return r.JSON.raw }\nfunc (r *CapabilitySupport) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Context management capability details.\ntype ContextManagementCapability struct {\n\t// Indicates whether a capability is supported.\n\tClearThinking20251015 CapabilitySupport `json:\"clear_thinking_20251015\" api:\"required\"`\n\t// Indicates whether a capability is supported.\n\tClearToolUses20250919 CapabilitySupport `json:\"clear_tool_uses_20250919\" api:\"required\"`\n\t// Indicates whether a capability is supported.\n\tCompact20260112 CapabilitySupport `json:\"compact_20260112\" api:\"required\"`\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tClearThinking20251015 respjson.Field\n\t\tClearToolUses20250919 respjson.Field\n\t\tCompact20260112       respjson.Field\n\t\tSupported             respjson.Field\n\t\tExtraFields           map[string]respjson.Field\n\t\traw                   string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ContextManagementCapability) RawJSON() string { return r.JSON.raw }\nfunc (r *ContextManagementCapability) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Effort (reasoning_effort) capability details.\ntype EffortCapability struct {\n\t// Whether the model supports high effort level.\n\tHigh CapabilitySupport `json:\"high\" api:\"required\"`\n\t// Whether the model supports low effort level.\n\tLow CapabilitySupport `json:\"low\" api:\"required\"`\n\t// Whether the model supports max effort level.\n\tMax CapabilitySupport `json:\"max\" api:\"required\"`\n\t// Whether the model supports medium effort level.\n\tMedium CapabilitySupport `json:\"medium\" api:\"required\"`\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tHigh        respjson.Field\n\t\tLow         respjson.Field\n\t\tMax         respjson.Field\n\t\tMedium      respjson.Field\n\t\tSupported   respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r EffortCapability) RawJSON() string { return r.JSON.raw }\nfunc (r *EffortCapability) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Model capability information.\ntype ModelCapabilities struct {\n\t// Whether the model supports the Batch API.\n\tBatch CapabilitySupport `json:\"batch\" api:\"required\"`\n\t// Whether the model supports citation generation.\n\tCitations CapabilitySupport `json:\"citations\" api:\"required\"`\n\t// Whether the model supports code execution tools.\n\tCodeExecution CapabilitySupport `json:\"code_execution\" api:\"required\"`\n\t// Context management support and available strategies.\n\tContextManagement ContextManagementCapability `json:\"context_management\" api:\"required\"`\n\t// Effort (reasoning_effort) support and available levels.\n\tEffort EffortCapability `json:\"effort\" api:\"required\"`\n\t// Whether the model accepts image content blocks.\n\tImageInput CapabilitySupport `json:\"image_input\" api:\"required\"`\n\t// Whether the model accepts PDF content blocks.\n\tPDFInput CapabilitySupport `json:\"pdf_input\" api:\"required\"`\n\t// Whether the model supports structured output / JSON mode / strict tool schemas.\n\tStructuredOutputs CapabilitySupport `json:\"structured_outputs\" api:\"required\"`\n\t// Thinking capability and supported type configurations.\n\tThinking ThinkingCapability `json:\"thinking\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tBatch             respjson.Field\n\t\tCitations         respjson.Field\n\t\tCodeExecution     respjson.Field\n\t\tContextManagement respjson.Field\n\t\tEffort            respjson.Field\n\t\tImageInput        respjson.Field\n\t\tPDFInput          respjson.Field\n\t\tStructuredOutputs respjson.Field\n\t\tThinking          respjson.Field\n\t\tExtraFields       map[string]respjson.Field\n\t\traw               string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ModelCapabilities) RawJSON() string { return r.JSON.raw }\nfunc (r *ModelCapabilities) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ModelInfo struct {\n\t// Unique model identifier.\n\tID string `json:\"id\" api:\"required\"`\n\t// Model capability information.\n\tCapabilities ModelCapabilities `json:\"capabilities\" api:\"required\"`\n\t// RFC 3339 datetime string representing the time at which the model was released.\n\t// May be set to an epoch value if the release date is unknown.\n\tCreatedAt time.Time `json:\"created_at\" api:\"required\" format:\"date-time\"`\n\t// A human-readable name for the model.\n\tDisplayName string `json:\"display_name\" api:\"required\"`\n\t// Maximum input context window size in tokens for this model.\n\tMaxInputTokens int64 `json:\"max_input_tokens\" api:\"required\"`\n\t// Maximum value for the `max_tokens` parameter when using this model.\n\tMaxTokens int64 `json:\"max_tokens\" api:\"required\"`\n\t// Object type.\n\t//\n\t// For Models, this is always `\"model\"`.\n\tType constant.Model `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tID             respjson.Field\n\t\tCapabilities   respjson.Field\n\t\tCreatedAt      respjson.Field\n\t\tDisplayName    respjson.Field\n\t\tMaxInputTokens respjson.Field\n\t\tMaxTokens      respjson.Field\n\t\tType           respjson.Field\n\t\tExtraFields    map[string]respjson.Field\n\t\traw            string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ModelInfo) RawJSON() string { return r.JSON.raw }\nfunc (r *ModelInfo) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Thinking capability details.\ntype ThinkingCapability struct {\n\t// Whether this capability is supported by the model.\n\tSupported bool `json:\"supported\" api:\"required\"`\n\t// Supported thinking type configurations.\n\tTypes ThinkingTypes `json:\"types\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tSupported   respjson.Field\n\t\tTypes       respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ThinkingCapability) RawJSON() string { return r.JSON.raw }\nfunc (r *ThinkingCapability) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// Supported thinking type configurations.\ntype ThinkingTypes struct {\n\t// Whether the model supports thinking with type 'adaptive' (auto).\n\tAdaptive CapabilitySupport `json:\"adaptive\" api:\"required\"`\n\t// Whether the model supports thinking with type 'enabled'.\n\tEnabled CapabilitySupport `json:\"enabled\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tAdaptive    respjson.Field\n\t\tEnabled     respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ThinkingTypes) RawJSON() string { return r.JSON.raw }\nfunc (r *ThinkingTypes) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ModelGetParams struct {\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\ntype ModelListParams struct {\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately after this object.\n\tAfterID param.Opt[string] `query:\"after_id,omitzero\" json:\"-\"`\n\t// ID of the object to use as a cursor for pagination. When provided, returns the\n\t// page of results immediately before this object.\n\tBeforeID param.Opt[string] `query:\"before_id,omitzero\" json:\"-\"`\n\t// Number of items to return per page.\n\t//\n\t// Defaults to `20`. Ranges from `1` to `1000`.\n\tLimit param.Opt[int64] `query:\"limit,omitzero\" json:\"-\"`\n\t// Optional header to specify the beta version(s) you want to use.\n\tBetas []AnthropicBeta `header:\"anthropic-beta,omitzero\" json:\"-\"`\n\tparamObj\n}\n\n// URLQuery serializes [ModelListParams]'s query parameters as `url.Values`.\nfunc (r ModelListParams) URLQuery() (v url.Values, err error) {\n\treturn apiquery.MarshalWithSettings(r, apiquery.QuerySettings{\n\t\tArrayFormat:  apiquery.ArrayQueryFormatComma,\n\t\tNestedFormat: apiquery.NestedQueryFormatBrackets,\n\t})\n}\n"
  },
  {
    "path": "model_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestModelGetWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Models.Get(\n\t\tcontext.TODO(),\n\t\t\"model_id\",\n\t\tanthropic.ModelGetParams{\n\t\t\tBetas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t\t},\n\t)\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n\nfunc TestModelListWithOptionalParams(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\t_, err := client.Models.List(context.TODO(), anthropic.ModelListParams{\n\t\tAfterID:  anthropic.String(\"after_id\"),\n\t\tBeforeID: anthropic.String(\"before_id\"),\n\t\tLimit:    anthropic.Int(1),\n\t\tBetas:    []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},\n\t})\n\tif err != nil {\n\t\tvar apierr *anthropic.Error\n\t\tif errors.As(err, &apierr) {\n\t\t\tt.Log(string(apierr.DumpRequest(true)))\n\t\t}\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "option/middleware.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage option\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\t\"net/http/httputil\"\n)\n\n// WithDebugLog logs the HTTP request and response content.\n// If the logger parameter is nil, it uses the default logger.\n//\n// WithDebugLog is for debugging and development purposes only.\n// It should not be used in production code. The behavior and interface\n// of WithDebugLog is not guaranteed to be stable.\nfunc WithDebugLog(logger *log.Logger) RequestOption {\n\treturn WithMiddleware(func(req *http.Request, nxt MiddlewareNext) (*http.Response, error) {\n\t\tif logger == nil {\n\t\t\tlogger = log.Default()\n\t\t}\n\n\t\tif reqBytes, err := httputil.DumpRequest(req, true); err == nil {\n\t\t\tlogger.Printf(\"Request Content:\\n%s\\n\", reqBytes)\n\t\t}\n\n\t\tresp, err := nxt(req)\n\t\tif err != nil {\n\t\t\treturn resp, err\n\t\t}\n\n\t\tif respBytes, err := httputil.DumpResponse(resp, true); err == nil {\n\t\t\tlogger.Printf(\"Response Content:\\n%s\\n\", respBytes)\n\t\t}\n\n\t\treturn resp, err\n\t})\n}\n"
  },
  {
    "path": "option/requestoption.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage option\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/tidwall/sjson\"\n)\n\n// RequestOption is an option for the requests made by the anthropic API Client\n// which can be supplied to clients, services, and methods. You can read more about this functional\n// options pattern in our [README].\n//\n// [README]: https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go#readme-requestoptions\ntype RequestOption = requestconfig.RequestOption\n\n// WithBaseURL returns a RequestOption that sets the BaseURL for the client.\n//\n// For security reasons, ensure that the base URL is trusted.\nfunc WithBaseURL(base string) RequestOption {\n\tu, err := url.Parse(base)\n\tif err == nil && u.Path != \"\" && !strings.HasSuffix(u.Path, \"/\") {\n\t\tu.Path += \"/\"\n\t}\n\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"requestoption: WithBaseURL failed to parse url %s\", err)\n\t\t}\n\n\t\tr.BaseURL = u\n\t\treturn nil\n\t})\n}\n\n// HTTPClient is primarily used to describe an [*http.Client], but also\n// supports custom implementations.\n//\n// For bespoke implementations, prefer using an [*http.Client] with a\n// custom transport. See [http.RoundTripper] for further information.\ntype HTTPClient interface {\n\tDo(*http.Request) (*http.Response, error)\n}\n\n// WithHTTPClient returns a RequestOption that changes the underlying http client used to make this\n// request, which by default is [http.DefaultClient].\n//\n// For custom uses cases, it is recommended to provide an [*http.Client] with a custom\n// [http.RoundTripper] as its transport, rather than directly implementing [HTTPClient].\nfunc WithHTTPClient(client HTTPClient) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tif client == nil {\n\t\t\treturn fmt.Errorf(\"requestoption: custom http client cannot be nil\")\n\t\t}\n\n\t\tif c, ok := client.(*http.Client); ok {\n\t\t\t// Prefer the native client if possible.\n\t\t\tr.HTTPClient = c\n\t\t\tr.CustomHTTPDoer = nil\n\t\t} else {\n\t\t\tr.CustomHTTPDoer = client\n\t\t}\n\n\t\treturn nil\n\t})\n}\n\n// MiddlewareNext is a function which is called by a middleware to pass an HTTP request\n// to the next stage in the middleware chain.\ntype MiddlewareNext = func(*http.Request) (*http.Response, error)\n\n// Middleware is a function which intercepts HTTP requests, processing or modifying\n// them, and then passing the request to the next middleware or handler\n// in the chain by calling the provided MiddlewareNext function.\ntype Middleware = func(*http.Request, MiddlewareNext) (*http.Response, error)\n\n// WithMiddleware returns a RequestOption that applies the given middleware\n// to the requests made. Each middleware will execute in the order they were given.\nfunc WithMiddleware(middlewares ...Middleware) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.Middlewares = append(r.Middlewares, middlewares...)\n\t\treturn nil\n\t})\n}\n\n// WithMaxRetries returns a RequestOption that sets the maximum number of retries that the client\n// attempts to make. When given 0, the client only makes one request. By\n// default, the client retries two times.\n//\n// WithMaxRetries panics when retries is negative.\nfunc WithMaxRetries(retries int) RequestOption {\n\tif retries < 0 {\n\t\tpanic(\"option: cannot have fewer than 0 retries\")\n\t}\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.MaxRetries = retries\n\t\treturn nil\n\t})\n}\n\n// WithHeader returns a RequestOption that sets the header value to the associated key. It overwrites\n// any value if there was one already present.\nfunc WithHeader(key, value string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.Request.Header.Set(key, value)\n\t\treturn nil\n\t})\n}\n\n// WithHeaderAdd returns a RequestOption that adds the header value to the associated key. It appends\n// onto any existing values.\nfunc WithHeaderAdd(key, value string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.Request.Header.Add(key, value)\n\t\treturn nil\n\t})\n}\n\n// WithHeaderDel returns a RequestOption that deletes the header value(s) associated with the given key.\nfunc WithHeaderDel(key string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.Request.Header.Del(key)\n\t\treturn nil\n\t})\n}\n\n// WithQuery returns a RequestOption that sets the query value to the associated key. It overwrites\n// any value if there was one already present.\nfunc WithQuery(key, value string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tquery := r.Request.URL.Query()\n\t\tquery.Set(key, value)\n\t\tr.Request.URL.RawQuery = query.Encode()\n\t\treturn nil\n\t})\n}\n\n// WithQueryAdd returns a RequestOption that adds the query value to the associated key. It appends\n// onto any existing values.\nfunc WithQueryAdd(key, value string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tquery := r.Request.URL.Query()\n\t\tquery.Add(key, value)\n\t\tr.Request.URL.RawQuery = query.Encode()\n\t\treturn nil\n\t})\n}\n\n// WithQueryDel returns a RequestOption that deletes the query value(s) associated with the key.\nfunc WithQueryDel(key string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tquery := r.Request.URL.Query()\n\t\tquery.Del(key)\n\t\tr.Request.URL.RawQuery = query.Encode()\n\t\treturn nil\n\t})\n}\n\n// WithJSONSet returns a RequestOption that sets the body's JSON value associated with the key.\n// The key accepts a string as defined by the [sjson format].\n//\n// [sjson format]: https://github.com/tidwall/sjson\nfunc WithJSONSet(key string, value any) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) (err error) {\n\t\tvar b []byte\n\n\t\tif r.Body == nil {\n\t\t\tb, err = sjson.SetBytes(nil, key, value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else if buffer, ok := r.Body.(*bytes.Buffer); ok {\n\t\t\tb = buffer.Bytes()\n\t\t\tb, err = sjson.SetBytes(b, key, value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"cannot use WithJSONSet on a body that is not serialized as *bytes.Buffer\")\n\t\t}\n\n\t\tr.Body = bytes.NewBuffer(b)\n\t\treturn nil\n\t})\n}\n\n// WithJSONDel returns a RequestOption that deletes the body's JSON value associated with the key.\n// The key accepts a string as defined by the [sjson format].\n//\n// [sjson format]: https://github.com/tidwall/sjson\nfunc WithJSONDel(key string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) (err error) {\n\t\tif buffer, ok := r.Body.(*bytes.Buffer); ok {\n\t\t\tb := buffer.Bytes()\n\t\t\tb, err = sjson.DeleteBytes(b, key)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tr.Body = bytes.NewBuffer(b)\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"cannot use WithJSONDel on a body that is not serialized as *bytes.Buffer\")\n\t})\n}\n\n// WithResponseBodyInto returns a RequestOption that overwrites the deserialization target with\n// the given destination. If provided, we don't deserialize into the default struct.\nfunc WithResponseBodyInto(dst any) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.ResponseBodyInto = dst\n\t\treturn nil\n\t})\n}\n\n// WithResponseInto returns a RequestOption that copies the [*http.Response] into the given address.\nfunc WithResponseInto(dst **http.Response) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.ResponseInto = dst\n\t\treturn nil\n\t})\n}\n\n// WithRequestBody returns a RequestOption that provides a custom serialized body with the given\n// content type.\n//\n// body accepts an io.Reader or raw []bytes.\nfunc WithRequestBody(contentType string, body any) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tif reader, ok := body.(io.Reader); ok {\n\t\t\tr.Body = reader\n\t\t\treturn r.Apply(WithHeader(\"Content-Type\", contentType))\n\t\t}\n\n\t\tif b, ok := body.([]byte); ok {\n\t\t\tr.Body = bytes.NewBuffer(b)\n\t\t\treturn r.Apply(WithHeader(\"Content-Type\", contentType))\n\t\t}\n\n\t\treturn fmt.Errorf(\"body must be a byte slice or implement io.Reader\")\n\t})\n}\n\n// WithRequestTimeout returns a RequestOption that sets the timeout for\n// each request attempt. This should be smaller than the timeout defined in\n// the context, which spans all retries.\nfunc WithRequestTimeout(dur time.Duration) RequestOption {\n\t// we need this to be a PreRequestOptionFunc so that it can be applied at the endpoint level\n\t// see: CalculateNonStreamingTimeout\n\treturn requestconfig.PreRequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.RequestTimeout = dur\n\t\treturn nil\n\t})\n}\n\n// WithEnvironmentProduction returns a RequestOption that sets the current\n// environment to be the \"production\" environment. An environment specifies which base URL\n// to use by default.\nfunc WithEnvironmentProduction() RequestOption {\n\treturn requestconfig.WithDefaultBaseURL(\"https://api.anthropic.com/\")\n}\n\n// WithAPIKey returns a RequestOption that sets the client setting \"api_key\".\nfunc WithAPIKey(value string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.APIKey = value\n\t\treturn r.Apply(WithHeader(\"X-Api-Key\", r.APIKey))\n\t})\n}\n\n// WithAuthToken returns a RequestOption that sets the client setting \"auth_token\".\nfunc WithAuthToken(value string) RequestOption {\n\treturn requestconfig.RequestOptionFunc(func(r *requestconfig.RequestConfig) error {\n\t\tr.AuthToken = value\n\t\treturn r.Apply(WithHeader(\"authorization\", fmt.Sprintf(\"Bearer %s\", r.AuthToken)))\n\t})\n}\n"
  },
  {
    "path": "packages/jsonl/jsonl.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage jsonl\n\nimport (\n\t\"bufio\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\ntype Stream[T any] struct {\n\trc  io.ReadCloser\n\tscn *bufio.Scanner\n\tcur T\n\terr error\n}\n\nfunc NewStream[T any](res *http.Response, err error) *Stream[T] {\n\tif err != nil {\n\t\treturn &Stream[T]{err: err}\n\t}\n\n\tif res == nil || res.Body == nil {\n\t\treturn &Stream[T]{err: fmt.Errorf(\"No streaming response body\")}\n\t}\n\n\treturn &Stream[T]{\n\t\trc:  res.Body,\n\t\tscn: bufio.NewScanner(res.Body),\n\t\terr: err,\n\t}\n}\n\nfunc (s *Stream[T]) Next() bool {\n\tif s.err != nil {\n\t\treturn false\n\t}\n\n\tif !s.scn.Scan() {\n\t\treturn false\n\t}\n\n\tline := s.scn.Bytes()\n\tvar nxt T\n\ts.err = json.Unmarshal(line, &nxt)\n\ts.cur = nxt\n\treturn s.err == nil\n}\n\nfunc (s *Stream[T]) Current() T {\n\treturn s.cur\n}\n\nfunc (s *Stream[T]) Err() error {\n\treturn s.err\n}\n\nfunc (s *Stream[T]) Close() error {\n\treturn s.rc.Close()\n}\n"
  },
  {
    "path": "packages/pagination/pagination.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage pagination\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n)\n\n// aliased to make [param.APIUnion] private when embedding\ntype paramUnion = param.APIUnion\n\n// aliased to make [param.APIObject] private when embedding\ntype paramObj = param.APIObject\n\ntype Page[T any] struct {\n\tData    []T    `json:\"data\"`\n\tHasMore bool   `json:\"has_more\"`\n\tFirstID string `json:\"first_id\" api:\"nullable\"`\n\tLastID  string `json:\"last_id\" api:\"nullable\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tHasMore     respjson.Field\n\t\tFirstID     respjson.Field\n\t\tLastID      respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n\tcfg *requestconfig.RequestConfig\n\tres *http.Response\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r Page[T]) RawJSON() string { return r.JSON.raw }\nfunc (r *Page[T]) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// GetNextPage returns the next page as defined by this pagination style. When\n// there is no next page, this function will return a 'nil' for the page value, but\n// will not return an error\nfunc (r *Page[T]) GetNextPage() (res *Page[T], err error) {\n\tif len(r.Data) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif r.JSON.HasMore.Valid() && r.HasMore == false {\n\t\treturn nil, nil\n\t}\n\tcfg := r.cfg.Clone(r.cfg.Context)\n\tif r.cfg.Request.URL.Query().Has(\"before_id\") {\n\t\tnext := r.FirstID\n\t\tif next == \"\" {\n\t\t\treturn nil, nil\n\t\t}\n\t\terr = cfg.Apply(option.WithQuery(\"before_id\", next))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tnext := r.LastID\n\t\tif next == \"\" {\n\t\t\treturn nil, nil\n\t\t}\n\t\terr = cfg.Apply(option.WithQuery(\"after_id\", next))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tvar raw *http.Response\n\tcfg.ResponseInto = &raw\n\tcfg.ResponseBodyInto = &res\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\nfunc (r *Page[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {\n\tif r == nil {\n\t\tr = &Page[T]{}\n\t}\n\tr.cfg = cfg\n\tr.res = res\n}\n\ntype PageAutoPager[T any] struct {\n\tpage *Page[T]\n\tcur  T\n\tidx  int\n\trun  int\n\terr  error\n\tparamObj\n}\n\nfunc NewPageAutoPager[T any](page *Page[T], err error) *PageAutoPager[T] {\n\treturn &PageAutoPager[T]{\n\t\tpage: page,\n\t\terr:  err,\n\t}\n}\n\nfunc (r *PageAutoPager[T]) Next() bool {\n\tif r.page == nil || len(r.page.Data) == 0 {\n\t\treturn false\n\t}\n\tif r.idx >= len(r.page.Data) {\n\t\tr.idx = 0\n\t\tr.page, r.err = r.page.GetNextPage()\n\t\tif r.err != nil || r.page == nil || len(r.page.Data) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\tr.cur = r.page.Data[r.idx]\n\tr.run += 1\n\tr.idx += 1\n\treturn true\n}\n\nfunc (r *PageAutoPager[T]) Current() T {\n\treturn r.cur\n}\n\nfunc (r *PageAutoPager[T]) Err() error {\n\treturn r.err\n}\n\nfunc (r *PageAutoPager[T]) Index() int {\n\treturn r.run\n}\n\ntype TokenPage[T any] struct {\n\tData     []T    `json:\"data\"`\n\tHasMore  bool   `json:\"has_more\"`\n\tNextPage string `json:\"next_page\" api:\"nullable\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tHasMore     respjson.Field\n\t\tNextPage    respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n\tcfg *requestconfig.RequestConfig\n\tres *http.Response\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r TokenPage[T]) RawJSON() string { return r.JSON.raw }\nfunc (r *TokenPage[T]) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// GetNextPage returns the next page as defined by this pagination style. When\n// there is no next page, this function will return a 'nil' for the page value, but\n// will not return an error\nfunc (r *TokenPage[T]) GetNextPage() (res *TokenPage[T], err error) {\n\tif len(r.Data) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif r.JSON.HasMore.Valid() && r.HasMore == false {\n\t\treturn nil, nil\n\t}\n\tnext := r.NextPage\n\tif len(next) == 0 {\n\t\treturn nil, nil\n\t}\n\tcfg := r.cfg.Clone(r.cfg.Context)\n\terr = cfg.Apply(option.WithQuery(\"page_token\", next))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar raw *http.Response\n\tcfg.ResponseInto = &raw\n\tcfg.ResponseBodyInto = &res\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\nfunc (r *TokenPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {\n\tif r == nil {\n\t\tr = &TokenPage[T]{}\n\t}\n\tr.cfg = cfg\n\tr.res = res\n}\n\ntype TokenPageAutoPager[T any] struct {\n\tpage *TokenPage[T]\n\tcur  T\n\tidx  int\n\trun  int\n\terr  error\n\tparamObj\n}\n\nfunc NewTokenPageAutoPager[T any](page *TokenPage[T], err error) *TokenPageAutoPager[T] {\n\treturn &TokenPageAutoPager[T]{\n\t\tpage: page,\n\t\terr:  err,\n\t}\n}\n\nfunc (r *TokenPageAutoPager[T]) Next() bool {\n\tif r.page == nil || len(r.page.Data) == 0 {\n\t\treturn false\n\t}\n\tif r.idx >= len(r.page.Data) {\n\t\tr.idx = 0\n\t\tr.page, r.err = r.page.GetNextPage()\n\t\tif r.err != nil || r.page == nil || len(r.page.Data) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\tr.cur = r.page.Data[r.idx]\n\tr.run += 1\n\tr.idx += 1\n\treturn true\n}\n\nfunc (r *TokenPageAutoPager[T]) Current() T {\n\treturn r.cur\n}\n\nfunc (r *TokenPageAutoPager[T]) Err() error {\n\treturn r.err\n}\n\nfunc (r *TokenPageAutoPager[T]) Index() int {\n\treturn r.run\n}\n\ntype PageCursor[T any] struct {\n\tData     []T    `json:\"data\"`\n\tHasMore  bool   `json:\"has_more\"`\n\tNextPage string `json:\"next_page\" api:\"nullable\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tData        respjson.Field\n\t\tHasMore     respjson.Field\n\t\tNextPage    respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n\tcfg *requestconfig.RequestConfig\n\tres *http.Response\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r PageCursor[T]) RawJSON() string { return r.JSON.raw }\nfunc (r *PageCursor[T]) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\n// GetNextPage returns the next page as defined by this pagination style. When\n// there is no next page, this function will return a 'nil' for the page value, but\n// will not return an error\nfunc (r *PageCursor[T]) GetNextPage() (res *PageCursor[T], err error) {\n\tif len(r.Data) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif r.JSON.HasMore.Valid() && r.HasMore == false {\n\t\treturn nil, nil\n\t}\n\tnext := r.NextPage\n\tif len(next) == 0 {\n\t\treturn nil, nil\n\t}\n\tcfg := r.cfg.Clone(r.cfg.Context)\n\terr = cfg.Apply(option.WithQuery(\"page\", next))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar raw *http.Response\n\tcfg.ResponseInto = &raw\n\tcfg.ResponseBodyInto = &res\n\terr = cfg.Execute()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tres.SetPageConfig(cfg, raw)\n\treturn res, nil\n}\n\nfunc (r *PageCursor[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {\n\tif r == nil {\n\t\tr = &PageCursor[T]{}\n\t}\n\tr.cfg = cfg\n\tr.res = res\n}\n\ntype PageCursorAutoPager[T any] struct {\n\tpage *PageCursor[T]\n\tcur  T\n\tidx  int\n\trun  int\n\terr  error\n\tparamObj\n}\n\nfunc NewPageCursorAutoPager[T any](page *PageCursor[T], err error) *PageCursorAutoPager[T] {\n\treturn &PageCursorAutoPager[T]{\n\t\tpage: page,\n\t\terr:  err,\n\t}\n}\n\nfunc (r *PageCursorAutoPager[T]) Next() bool {\n\tif r.page == nil || len(r.page.Data) == 0 {\n\t\treturn false\n\t}\n\tif r.idx >= len(r.page.Data) {\n\t\tr.idx = 0\n\t\tr.page, r.err = r.page.GetNextPage()\n\t\tif r.err != nil || r.page == nil || len(r.page.Data) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\tr.cur = r.page.Data[r.idx]\n\tr.run += 1\n\tr.idx += 1\n\treturn true\n}\n\nfunc (r *PageCursorAutoPager[T]) Current() T {\n\treturn r.cur\n}\n\nfunc (r *PageCursorAutoPager[T]) Err() error {\n\treturn r.err\n}\n\nfunc (r *PageCursorAutoPager[T]) Index() int {\n\treturn r.run\n}\n"
  },
  {
    "path": "packages/param/encoder.go",
    "content": "package param\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strings\"\n\t\"time\"\n\n\tshimjson \"github.com/anthropics/anthropic-sdk-go/internal/encoding/json\"\n\n\t\"github.com/tidwall/sjson\"\n)\n\n// EncodedAsDate is not be stable and shouldn't be relied upon\ntype EncodedAsDate Opt[time.Time]\n\n// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have\n// special characters that sjson interprets as a path.\nvar EscapeSJSONKey = strings.NewReplacer(\"\\\\\", \"\\\\\\\\\", \"|\", \"\\\\|\", \"#\", \"\\\\#\", \"@\", \"\\\\@\", \"*\", \"\\\\*\", \".\", \"\\\\.\", \":\", \"\\\\:\", \"?\", \"\\\\?\").Replace\n\ntype forceOmit int\n\nfunc (m EncodedAsDate) MarshalJSON() ([]byte, error) {\n\tunderlying := Opt[time.Time](m)\n\tbytes := underlying.MarshalJSONWithTimeLayout(\"2006-01-02\")\n\tif len(bytes) > 0 {\n\t\treturn bytes, nil\n\t}\n\treturn underlying.MarshalJSON()\n}\n\n// MarshalObject uses a shimmed 'encoding/json' from Go 1.24, to support the 'omitzero' tag\n//\n// Stability for the API of MarshalObject is not guaranteed.\nfunc MarshalObject[T ParamStruct](f T, underlying any) ([]byte, error) {\n\treturn MarshalWithExtras(f, underlying, f.extraFields())\n}\n\n// MarshalWithExtras is used to marshal a struct with additional properties.\n//\n// Stability for the API of MarshalWithExtras is not guaranteed.\nfunc MarshalWithExtras[T ParamStruct, R any](f T, underlying any, extras map[string]R) ([]byte, error) {\n\tif f.null() {\n\t\treturn []byte(\"null\"), nil\n\t} else if len(extras) > 0 {\n\t\tbytes, err := shimjson.Marshal(underlying)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor k, v := range extras {\n\t\t\tvar a any = v\n\t\t\tif a == Omit {\n\t\t\t\t// Errors when handling ForceOmitted are ignored.\n\t\t\t\tif b, e := sjson.DeleteBytes(bytes, k); e == nil {\n\t\t\t\t\tbytes = b\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbytes, err = sjson.SetBytes(bytes, EscapeSJSONKey(k), v)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn bytes, nil\n\t} else if ovr, ok := f.Overrides(); ok {\n\t\treturn shimjson.Marshal(ovr)\n\t} else {\n\t\treturn shimjson.Marshal(underlying)\n\t}\n}\n\n// MarshalUnion uses a shimmed 'encoding/json' from Go 1.24, to support the 'omitzero' tag\n//\n// Stability for the API of MarshalUnion is not guaranteed.\nfunc MarshalUnion[T ParamStruct](metadata T, variants ...any) ([]byte, error) {\n\tnPresent := 0\n\tpresentIdx := -1\n\tfor i, variant := range variants {\n\t\tif !IsOmitted(variant) {\n\t\t\tnPresent++\n\t\t\tpresentIdx = i\n\t\t}\n\t}\n\tif nPresent == 0 || presentIdx == -1 {\n\t\tif metadata.null() {\n\t\t\treturn []byte(\"null\"), nil\n\t\t}\n\t\tif ovr, ok := metadata.Overrides(); ok {\n\t\t\treturn shimjson.Marshal(ovr)\n\t\t}\n\t\treturn []byte(`null`), nil\n\t} else if nPresent > 1 {\n\t\treturn nil, &json.MarshalerError{\n\t\t\tType: typeFor[T](),\n\t\t\tErr:  fmt.Errorf(\"expected union to have only one present variant, got %d\", nPresent),\n\t\t}\n\t}\n\treturn shimjson.Marshal(variants[presentIdx])\n}\n\n// typeFor is shimmed from Go 1.23 \"reflect\" package\nfunc typeFor[T any]() reflect.Type {\n\tvar v T\n\tif t := reflect.TypeOf(v); t != nil {\n\t\treturn t // optimize for T being a non-interface kind\n\t}\n\treturn reflect.TypeOf((*T)(nil)).Elem() // only for an interface kind\n}\n"
  },
  {
    "path": "packages/param/encoder_test.go",
    "content": "package param_test\n\nimport (\n\t\"encoding/json\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n)\n\ntype Struct struct {\n\tA string `json:\"a\"`\n\tB int64  `json:\"b\"`\n\tparam.APIObject\n}\n\nfunc (r Struct) MarshalJSON() (data []byte, err error) {\n\ttype shadow Struct\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\n\n// Note that the order of fields affects the JSON\n// key order. Changing the order of the fields in this struct\n// will fail tests unnecessarily.\ntype FieldStruct struct {\n\tA param.Opt[string]    `json:\"a,omitzero\"`\n\tB param.Opt[int64]     `json:\"b,omitzero\"`\n\tC Struct               `json:\"c,omitzero\"`\n\tD time.Time            `json:\"d,omitzero\" format:\"date\"`\n\tE time.Time            `json:\"e,omitzero\"`\n\tF param.Opt[time.Time] `json:\"f,omitzero\" format:\"date\"`\n\tG param.Opt[time.Time] `json:\"g,omitzero\"`\n\tH param.Opt[time.Time] `json:\"h,omitzero\" format:\"date-time\"`\n\tparam.APIObject\n}\n\nfunc (r FieldStruct) MarshalJSON() (data []byte, err error) {\n\ttype shadow FieldStruct\n\treturn param.MarshalObject(r, (*shadow)(&r))\n}\n\ntype StructWithAdditionalProperties struct {\n\tFirst       string         `json:\"first\"`\n\tSecond      int            `json:\"second\"`\n\tExtraFields map[string]any `json:\"-\"`\n\tparam.APIObject\n}\n\nfunc (s StructWithAdditionalProperties) MarshalJSON() ([]byte, error) {\n\ttype shadow StructWithAdditionalProperties\n\treturn param.MarshalWithExtras(s, (*shadow)(&s), s.ExtraFields)\n}\n\nfunc TestIsNullish(t *testing.T) {\n\tnullTests := map[string]param.ParamNullable{\n\t\t\"null_string\": param.Null[string](),\n\t\t\"null_int64\":  param.Null[int64](),\n\t\t\"null_time\":   param.Null[time.Time](),\n\t\t\"null_struct\": param.NullStruct[Struct](),\n\t}\n\n\tfor name, test := range nullTests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tif !param.IsNull(test) {\n\t\t\t\tt.Fatalf(\"expected %s to be null\", name)\n\t\t\t}\n\t\t\tif param.IsOmitted(test) {\n\t\t\t\tt.Fatalf(\"expected %s to not be omitted\", name)\n\t\t\t}\n\t\t})\n\t}\n\n\tomitTests := map[string]param.ParamNullable{\n\t\t\"omit_string\": param.Opt[string]{},\n\t\t\"omit_int64\":  param.Opt[int64]{},\n\t\t\"omit_time\":   param.Opt[time.Time]{},\n\t\t\"omit_struct\": Struct{},\n\t}\n\n\tfor name, test := range omitTests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tif param.IsNull(test) {\n\t\t\t\tt.Fatalf(\"expected %s to be null\", name)\n\t\t\t}\n\t\t\tif !param.IsOmitted(test) {\n\t\t\t\tt.Fatalf(\"expected %s to not be omitted\", name)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestFieldMarshal(t *testing.T) {\n\ttests := map[string]struct {\n\t\tvalue    any\n\t\texpected string\n\t}{\n\t\t\"null_string\": {param.Null[string](), \"null\"},\n\t\t\"null_int64\":  {param.Null[int64](), \"null\"},\n\t\t\"null_time\":   {param.Null[time.Time](), \"null\"},\n\t\t\"null_struct\": {param.NullStruct[Struct](), \"null\"},\n\n\t\t\"float_zero\":  {param.NewOpt(float64(0.0)), \"0\"},\n\t\t\"string_zero\": {param.NewOpt(\"\"), `\"\"`},\n\t\t\"time_zero\":   {param.NewOpt(time.Time{}), `\"0001-01-01T00:00:00Z\"`},\n\n\t\t\"string\": {param.Opt[string]{Value: \"string\"}, `\"string\"`},\n\t\t\"int\":    {param.Opt[int64]{Value: 123}, \"123\"},\n\t\t\"int64\":  {param.Opt[int64]{Value: int64(123456789123456789)}, \"123456789123456789\"},\n\t\t\"struct\": {Struct{A: \"yo\", B: 123}, `{\"a\":\"yo\",\"b\":123}`},\n\t\t\"datetime\": {\n\t\t\tparam.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t`\"2023-03-18T14:47:38Z\"`,\n\t\t},\n\t\t\"optional_date\": {\n\t\t\tFieldStruct{\n\t\t\t\tF: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t},\n\t\t\t`{\"f\":\"2023-03-18\"}`,\n\t\t},\n\t\t\"optional_time\": {\n\t\t\tFieldStruct{\n\t\t\t\tG: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t},\n\t\t\t`{\"g\":\"2023-03-18T14:47:38Z\"}`,\n\t\t},\n\t\t\"optional_datetime_explicit_format\": {\n\t\t\tFieldStruct{\n\t\t\t\tH: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t},\n\t\t\t`{\"h\":\"2023-03-18T14:47:38Z\"}`,\n\t\t},\n\t\t\"param_struct\": {\n\t\t\tFieldStruct{\n\t\t\t\tA: param.Opt[string]{Value: \"hello\"},\n\t\t\t\tB: param.Opt[int64]{Value: int64(12)},\n\t\t\t\tD: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC),\n\t\t\t\tE: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC),\n\t\t\t\tF: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t\tG: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t\tH: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t},\n\t\t\t`{\"a\":\"hello\",\"b\":12,\"d\":\"2023-03-18\",\"e\":\"2023-03-18T14:47:38Z\",\"f\":\"2023-03-18\",\"g\":\"2023-03-18T14:47:38Z\",\"h\":\"2023-03-18T14:47:38Z\"}`,\n\t\t},\n\t}\n\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb, err := json.Marshal(test.value)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"didn't expect error %v, expected %s\", err, test.expected)\n\t\t\t}\n\t\t\tif string(b) != test.expected {\n\t\t\t\tt.Fatalf(\"expected %s, received %s\", test.expected, string(b))\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestAdditionalProperties(t *testing.T) {\n\ts := StructWithAdditionalProperties{\n\t\tFirst:  \"hello\",\n\t\tSecond: 14,\n\t\tExtraFields: map[string]any{\n\t\t\t\"hi\": \"there\",\n\t\t},\n\t}\n\texp := `{\"first\":\"hello\",\"second\":14,\"hi\":\"there\"}`\n\n\tbytes, err := json.Marshal(s)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to marshal: %v\", err)\n\t}\n\n\tif string(bytes) != exp {\n\t\tt.Fatalf(\"expected %s, got %s\", exp, string(bytes))\n\t}\n}\n\nfunc TestExtraFields(t *testing.T) {\n\tv := Struct{\n\t\tA: \"hello\",\n\t\tB: 123,\n\t}\n\tv.SetExtraFields(map[string]any{\n\t\t\"extra\": Struct{A: \"recursive\"},\n\t\t\"b\":     nil,\n\t})\n\tbytes, err := json.Marshal(v)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to marshal: %v\", err)\n\t}\n\tif string(bytes) != `{\"a\":\"hello\",\"b\":null,\"extra\":{\"a\":\"recursive\",\"b\":0}}` {\n\t\tt.Fatalf(\"failed to marshal: got %v\", string(bytes))\n\t}\n\tif v.B != 123 {\n\t\tt.Fatalf(\"marshal modified field B: got %v\", v.B)\n\t}\n}\n\nfunc TestExtraFieldsForceOmitted(t *testing.T) {\n\tv := Struct{\n\t\t// Testing with the zero value.\n\t\t// A: \"\",\n\t\t// B: 0,\n\t}\n\tv.SetExtraFields(map[string]any{\n\t\t\"b\": param.Omit,\n\t})\n\tbytes, err := json.Marshal(v)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to marshal: %v\", err)\n\t}\n\tif string(bytes) != `{\"a\":\"\"}` {\n\t\tt.Fatalf(\"failed to marshal: got %v\", string(bytes))\n\t}\n}\n\ntype UnionWithDates struct {\n\tOfDate param.Opt[time.Time]\n\tOfTime param.Opt[time.Time]\n\tparam.APIUnion\n}\n\nfunc (r UnionWithDates) MarshalJSON() (data []byte, err error) {\n\treturn param.MarshalUnion(r, param.EncodedAsDate(r.OfDate), r.OfTime)\n}\n\nfunc TestUnionDateMarshal(t *testing.T) {\n\ttests := map[string]struct {\n\t\tvalue    UnionWithDates\n\t\texpected string\n\t}{\n\t\t\"date_only\": {\n\t\t\tUnionWithDates{\n\t\t\t\tOfDate: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 0, 0, 0, 0, time.UTC)},\n\t\t\t},\n\t\t\t`\"2023-03-18\"`,\n\t\t},\n\t\t\"datetime_only\": {\n\t\t\tUnionWithDates{\n\t\t\t\tOfTime: param.Opt[time.Time]{Value: time.Date(2023, time.March, 18, 14, 47, 38, 0, time.UTC)},\n\t\t\t},\n\t\t\t`\"2023-03-18T14:47:38Z\"`,\n\t\t},\n\t}\n\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb, err := json.Marshal(test.value)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"didn't expect error %v, expected %s\", err, test.expected)\n\t\t\t}\n\t\t\tif string(b) != test.expected {\n\t\t\t\tt.Fatalf(\"expected %s, received %s\", test.expected, string(b))\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestOverride(t *testing.T) {\n\ttests := map[string]struct {\n\t\tvalue    param.ParamStruct\n\t\texpected string\n\t}{\n\t\t\"param_struct\": {\n\t\t\tparam.Override[FieldStruct](map[string]any{\n\t\t\t\t\"a\": \"hello\",\n\t\t\t\t\"b\": 12,\n\t\t\t\t\"c\": nil,\n\t\t\t}),\n\t\t\t`{\"a\":\"hello\",\"b\":12,\"c\":null}`,\n\t\t},\n\t\t\"param_struct_primitive\": {\n\t\t\tparam.Override[FieldStruct](12),\n\t\t\t`12`,\n\t\t},\n\t\t\"param_struct_null\": {\n\t\t\tparam.Override[FieldStruct](nil),\n\t\t\t`null`,\n\t\t},\n\t}\n\n\tf := FieldStruct{}\n\n\tf.SetExtraFields(map[string]any{\n\t\t\"z\": \"ok\",\n\t})\n\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb, err := json.Marshal(test.value)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"didn't expect error %v, expected %s\", err, test.expected)\n\t\t\t}\n\t\t\tif string(b) != test.expected {\n\t\t\t\tt.Fatalf(\"expected %s, received %s\", test.expected, string(b))\n\t\t\t}\n\t\t\tif _, ok := test.value.Overrides(); !ok {\n\t\t\t\tt.Fatalf(\"expected to be overridden\")\n\t\t\t}\n\t\t})\n\t}\n}\n\n// Despite implementing the interface, this struct is not an param.Optional\n// since it was defined in a different package.\ntype almostOpt struct{}\n\nfunc (almostOpt) Valid() bool  { return true }\nfunc (almostOpt) Null() bool   { return false }\nfunc (almostOpt) isZero() bool { return false }\n\nfunc (almostOpt) implOpt() {}\n\nfunc TestOptionalInterfaceAssignability(t *testing.T) {\n\toptInt := param.Opt[int]{}\n\tif _, ok := any(optInt).(param.Optional); !ok {\n\t\tt.Fatalf(\"failed to assign\")\n\t}\n\n\tnotOpt := almostOpt{}\n\tif _, ok := any(notOpt).(param.Optional); ok {\n\t\tt.Fatalf(\"unexpected successful assignment\")\n\t}\n\n\tnotOpt.implOpt() // silence the warning\n}\n\ntype PrimitiveUnion struct {\n\tOfString param.Opt[string]\n\tOfInt    param.Opt[int]\n\tparam.APIUnion\n}\n\nfunc (p PrimitiveUnion) MarshalJSON() (data []byte, err error) {\n\treturn param.MarshalUnion(p, p.OfString, p.OfInt)\n}\n\nfunc TestOverriddenUnion(t *testing.T) {\n\ttests := map[string]struct {\n\t\tvalue    PrimitiveUnion\n\t\texpected string\n\t}{\n\t\t\"string\": {\n\t\t\tparam.Override[PrimitiveUnion](json.RawMessage(`\"hello\"`)),\n\t\t\t`\"hello\"`,\n\t\t},\n\t\t\"int\": {\n\t\t\tparam.Override[PrimitiveUnion](json.RawMessage(`42`)),\n\t\t\t`42`,\n\t\t},\n\t}\n\n\tfor name, test := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb, err := json.Marshal(test.value)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"didn't expect error %v, expected %s\", err, test.expected)\n\t\t\t}\n\t\t\tif string(b) != test.expected {\n\t\t\t\tt.Fatalf(\"expected %s, received %s\", test.expected, string(b))\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestNullStructUnion(t *testing.T) {\n\tnullUnion := param.NullStruct[PrimitiveUnion]()\n\n\tb, err := json.Marshal(nullUnion)\n\tif err != nil {\n\t\tt.Fatalf(\"didn't expect error %v\", err)\n\t}\n\tif string(b) != \"null\" {\n\t\tt.Fatalf(\"expected null, received %s\", string(b))\n\t}\n}\n"
  },
  {
    "path": "packages/param/null.go",
    "content": "package param\n\nimport \"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/sentinel\"\n\n// NullMap returns a non-nil map with a length of 0.\n// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.\n//\n// It is unspecified behavior to mutate the map returned by [NullMap].\nfunc NullMap[MapT ~map[string]T, T any]() MapT {\n\treturn sentinel.NewNullSentinel(func() MapT { return make(MapT, 1) })\n}\n\n// NullSlice returns a non-nil slice with a length of 0.\n// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.\n//\n// It is unspecified behavior to mutate the slice returned by [NullSlice].\nfunc NullSlice[SliceT ~[]T, T any]() SliceT {\n\treturn sentinel.NewNullSentinel(func() SliceT { return make(SliceT, 0, 1) })\n}\n"
  },
  {
    "path": "packages/param/null_test.go",
    "content": "package param_test\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"testing\"\n)\n\ntype Nullables struct {\n\tSlice []int          `json:\"slice,omitzero\"`\n\tMap   map[string]int `json:\"map,omitzero\"`\n\tparam.APIObject\n}\n\nfunc (n Nullables) MarshalJSON() ([]byte, error) {\n\ttype shadow Nullables\n\treturn param.MarshalObject(n, (*shadow)(&n))\n}\n\nfunc TestNullMarshal(t *testing.T) {\n\tbytes, err := json.Marshal(Nullables{})\n\tif err != nil {\n\t\tt.Fatalf(\"json error %v\", err.Error())\n\t}\n\tif string(bytes) != `{}` {\n\t\tt.Fatalf(\"expected empty object, got %s\", string(bytes))\n\t}\n\n\tobj := Nullables{\n\t\tSlice: param.NullSlice[[]int](),\n\t\tMap:   param.NullMap[map[string]int](),\n\t}\n\tbytes, err = json.Marshal(obj)\n\n\tif !param.IsNull(obj.Slice) {\n\t\tt.Fatal(\"failed null check\")\n\t}\n\tif !param.IsNull(obj.Map) {\n\t\tt.Fatal(\"failed null check\")\n\t}\n\n\tif err != nil {\n\t\tt.Fatalf(\"json error %v\", err.Error())\n\t}\n\texp := `{\"slice\":null,\"map\":null}`\n\tif string(bytes) != exp {\n\t\tt.Fatalf(\"expected %s, got %s\", exp, string(bytes))\n\t}\n}\n"
  },
  {
    "path": "packages/param/option.go",
    "content": "package param\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\tshimjson \"github.com/anthropics/anthropic-sdk-go/internal/encoding/json\"\n\t\"time\"\n)\n\nfunc NewOpt[T comparable](v T) Opt[T] {\n\treturn Opt[T]{Value: v, status: included}\n}\n\n// Null creates optional field with the JSON value \"null\".\n//\n// To set a struct to null, use [NullStruct].\nfunc Null[T comparable]() Opt[T] { return Opt[T]{status: null} }\n\ntype status int8\n\nconst (\n\tomitted status = iota\n\tnull\n\tincluded\n)\n\n// Opt represents an optional parameter of type T. Use\n// the [Opt.Valid] method to confirm.\ntype Opt[T comparable] struct {\n\tValue T\n\t// indicates whether the field should be omitted, null, or valid\n\tstatus status\n\topt\n}\n\n// Valid returns true if the value is not \"null\" or omitted.\n//\n// To check if explicitly null, use [Opt.Null].\nfunc (o Opt[T]) Valid() bool {\n\tvar empty Opt[T]\n\treturn o.status == included || o != empty && o.status != null\n}\n\nfunc (o Opt[T]) Or(v T) T {\n\tif o.Valid() {\n\t\treturn o.Value\n\t}\n\treturn v\n}\n\nfunc (o Opt[T]) String() string {\n\tif o.null() {\n\t\treturn \"null\"\n\t}\n\tif s, ok := any(o.Value).(fmt.Stringer); ok {\n\t\treturn s.String()\n\t}\n\treturn fmt.Sprintf(\"%v\", o.Value)\n}\n\nfunc (o Opt[T]) MarshalJSON() ([]byte, error) {\n\tif !o.Valid() {\n\t\treturn []byte(\"null\"), nil\n\t}\n\treturn shimjson.Marshal(o.Value)\n}\n\nfunc (o *Opt[T]) UnmarshalJSON(data []byte) error {\n\tif string(data) == \"null\" {\n\t\to.status = null\n\t\treturn nil\n\t}\n\n\tvar value *T\n\tif err := json.Unmarshal(data, &value); err != nil {\n\t\treturn err\n\t}\n\n\tif value == nil {\n\t\to.status = omitted\n\t\treturn nil\n\t}\n\n\to.status = included\n\to.Value = *value\n\treturn nil\n}\n\n// MarshalJSONWithTimeLayout is necessary to bypass the internal caching performed\n// by [json.Marshal]. Prefer to use [Opt.MarshalJSON] instead.\n//\n// This function requires that the generic type parameter of [Opt] is not [time.Time].\nfunc (o Opt[T]) MarshalJSONWithTimeLayout(format string) []byte {\n\tt, ok := any(o.Value).(time.Time)\n\tif !ok || o.null() {\n\t\treturn nil\n\t}\n\n\tb, err := shimjson.Marshal(t.Format(shimjson.TimeLayout(format)))\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn b\n}\n\nfunc (o Opt[T]) null() bool   { return o.status == null }\nfunc (o Opt[T]) isZero() bool { return o == Opt[T]{} }\n\n// opt helps limit the [Optional] interface to only types in this package\ntype opt struct{}\n\nfunc (opt) implOpt() {}\n\n// This interface is useful for internal purposes.\ntype Optional interface {\n\tValid() bool\n\tnull() bool\n\n\tisZero() bool\n\timplOpt()\n}\n"
  },
  {
    "path": "packages/param/param.go",
    "content": "package param\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/sentinel\"\n\t\"reflect\"\n)\n\n// NullStruct is used to set a struct to the JSON value null.\n// Check for null structs with [IsNull].\n//\n// Only the first type parameter should be provided,\n// the type PtrT will be inferred.\n//\n//\tjson.Marshal(param.NullStruct[MyStruct]()) -> 'null'\n//\n// To send null to an [Opt] field use [Null].\nfunc NullStruct[T ParamStruct, PtrT InferPtr[T]]() T {\n\tvar t T\n\tpt := PtrT(&t)\n\tpt.setMetadata(nil)\n\treturn *pt\n}\n\n// Override replaces the value of a struct with any type.\n//\n// Only the first type parameter should be provided,\n// the type PtrT will be inferred.\n//\n// It's often useful for providing raw JSON\n//\n//\tparam.Override[MyStruct](json.RawMessage(`{\"foo\": \"bar\"}`))\n//\n// The public fields of the returned struct T will be unset.\n//\n// To override a specific field in a struct, use its [SetExtraFields] method.\nfunc Override[T ParamStruct, PtrT InferPtr[T]](v any) T {\n\tvar t T\n\tpt := PtrT(&t)\n\tpt.setMetadata(v)\n\treturn *pt\n}\n\n// SetJSON configures a param struct to serialize with the provided raw JSON data.\n// Use this when you have existing JSON that you want to send as request parameters.\n//\n//\tvar req example.NewUserParams\n//\tvar rawJSON = []byte(`{\"name\": \"...\", \"age\": 40}`)\n//\tparam.SetJSON(rawJSON, &req)\n//\tres, err := client.Users.New(ctx, req)\n//\n// Note: The struct's existing fields will be ignored; only the provided JSON is serialized.\nfunc SetJSON(rawJSON []byte, ptr anyParamStruct) {\n\tptr.setMetadata(json.RawMessage(rawJSON))\n}\n\n// IsOmitted returns true if v is the zero value of its type.\n//\n// If IsOmitted is true, and the field uses a `json:\"...,omitzero\"` tag,\n// the field will be omitted from the request.\n//\n// If v is set explicitly to the JSON value \"null\", IsOmitted returns false.\nfunc IsOmitted(v any) bool {\n\tif v == nil {\n\t\treturn false\n\t}\n\tif o, ok := v.(Optional); ok {\n\t\treturn o.isZero()\n\t}\n\treturn reflect.ValueOf(v).IsZero()\n}\n\n// IsNull returns true if v was set to the JSON value null.\n//\n// To set a param to null use [NullStruct], [Null], [NullMap], or [NullSlice]\n// depending on the type of v.\n//\n// IsNull returns false if the value is omitted.\nfunc IsNull[T any](v T) bool {\n\tif nullable, ok := any(v).(ParamNullable); ok {\n\t\treturn nullable.null()\n\t}\n\n\tswitch reflect.TypeOf(v).Kind() {\n\tcase reflect.Slice, reflect.Map:\n\t\treturn sentinel.IsNull(v)\n\t}\n\n\treturn false\n}\n\n// ParamNullable encapsulates all structs in parameters,\n// and all [Opt] types in parameters.\ntype ParamNullable interface {\n\tnull() bool\n}\n\n// ParamStruct represents the set of all structs that are\n// used in API parameters, by convention these usually end in\n// \"Params\" or \"Param\".\ntype ParamStruct interface {\n\tOverrides() (any, bool)\n\tnull() bool\n\textraFields() map[string]any\n}\n\n// A pointer to ParamStruct\ntype anyParamStruct interface {\n\tsetMetadata(any)\n}\n\n// This is an implementation detail and should never be explicitly set.\ntype InferPtr[T ParamStruct] interface {\n\tsetMetadata(any)\n\t*T\n}\n\n// APIObject should be embedded in api object fields, preferably using an alias to make private\ntype APIObject struct{ metadata }\n\n// APIUnion should be embedded in all api unions fields, preferably using an alias to make private\ntype APIUnion struct{ metadata }\n\n// Overrides returns the value of the struct when it is created with\n// [Override], the second argument helps differentiate an explicit null.\nfunc (m metadata) Overrides() (any, bool) {\n\tif _, ok := m.any.(metadataExtraFields); ok {\n\t\treturn nil, false\n\t}\n\treturn m.any, m.any != nil\n}\n\n// ExtraFields returns the extra fields added to the JSON object.\nfunc (m metadata) ExtraFields() map[string]any {\n\tif extras, ok := m.any.(metadataExtraFields); ok {\n\t\treturn extras\n\t}\n\treturn nil\n}\n\n// Omit can be used with [metadata.SetExtraFields] to ensure that a\n// required field is omitted. This is useful as an escape hatch for\n// when a required is unwanted for some unexpected reason.\nconst Omit forceOmit = -1\n\n// SetExtraFields adds extra fields to the JSON object.\n//\n// SetExtraFields will override any existing fields with the same key.\n// For security reasons, ensure this is only used with trusted input data.\n//\n// To intentionally omit a required field, use [Omit].\n//\n//\tfoo.SetExtraFields(map[string]any{\"bar\": Omit})\n//\n// If the struct already contains the field ExtraFields, then this\n// method will have no effect.\nfunc (m *metadata) SetExtraFields(extraFields map[string]any) {\n\tm.any = metadataExtraFields(extraFields)\n}\n\n// extraFields aliases [metadata.ExtraFields] to avoid name collisions.\nfunc (m metadata) extraFields() map[string]any { return m.ExtraFields() }\n\nfunc (m metadata) null() bool {\n\tif _, ok := m.any.(metadataNull); ok {\n\t\treturn true\n\t}\n\n\tif msg, ok := m.any.(json.RawMessage); ok {\n\t\treturn string(msg) == \"null\"\n\t}\n\n\treturn false\n}\n\ntype metadata struct{ any }\ntype metadataNull struct{}\ntype metadataExtraFields map[string]any\n\nfunc (m *metadata) setMetadata(override any) {\n\tif override == nil {\n\t\tm.any = metadataNull{}\n\t\treturn\n\t}\n\tm.any = override\n}\n"
  },
  {
    "path": "packages/respjson/decoder_test.go",
    "content": "package respjson_test\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\trj \"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"reflect\"\n\t\"testing\"\n)\n\ntype UnionOfStringIntOrObject struct {\n\tOfString string    `json:\",inline\"`\n\tOfInt    int       `json:\",inline\"`\n\tType     string    `json:\"type\"`\n\tFunction SubFields `json:\"function\"`\n\tJSON     struct {\n\t\tOfString rj.Field\n\t\tOfInt    rj.Field\n\t\tType     rj.Field\n\t\tFunction rj.Field\n\t\traw      string\n\t} `json:\"-\"`\n}\n\nfunc (u UnionOfStringIntOrObject) RawJSON() string { return u.JSON.raw }\nfunc (r *UnionOfStringIntOrObject) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype SubFields struct {\n\tOfBool bool   `json:\",inline\"`\n\tName   string `json:\"name\" api:\"required\"`\n\tJSON   struct {\n\t\tOfBool      rj.Field\n\t\tName        rj.Field\n\t\tExtraFields map[string]rj.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\nfunc (r SubFields) RawJSON() string { return r.JSON.raw }\nfunc (r *SubFields) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc TestUnmarshalUnionString(t *testing.T) {\n\trawJSON := `\"123\"`\n\ttestUnmarshalUnion(t, rawJSON, func(res UnionOfStringIntOrObject) map[string]error {\n\t\treturn map[string]error{\n\t\t\t\"rawJSON\": checkEqual(res.RawJSON(), rawJSON),\n\n\t\t\t\"string\":          checkEqual(res.OfString, \"123\"),\n\t\t\t\"int\":             checkEqual(res.OfInt, 0),\n\t\t\t\"$.type\":          checkEqual(res.Type, \"\"),\n\t\t\t\"$.function.name\": checkEqual(res.Function.Name, \"\"),\n\n\t\t\t\"string.meta\":          checkMeta(res.JSON.OfString, rawJSON, shouldBePresent),\n\t\t\t\"int.meta\":             checkMeta(res.JSON.OfInt, \"\", shouldBeNullish),\n\t\t\t\"$.type.meta\":          checkMeta(res.JSON.Type, \"\", shouldBeNullish),\n\t\t\t\"$.function.meta\":      checkMeta(res.Function.JSON.Name, \"\", shouldBeNullish),\n\t\t\t\"$.function.name.meta\": checkMeta(res.Function.JSON.Name, \"\", shouldBeNullish),\n\t\t}\n\t})\n}\n\nfunc TestUnmarshalUnionInt(t *testing.T) {\n\trawJSON := `123`\n\ttestUnmarshalUnion(t, rawJSON, func(res UnionOfStringIntOrObject) map[string]error {\n\t\treturn map[string]error{\n\t\t\t\"rawJSON\": checkEqual(res.RawJSON(), rawJSON),\n\n\t\t\t\"string\":          checkEqual(res.OfString, \"\"),\n\t\t\t\"int\":             checkEqual(res.OfInt, 123),\n\t\t\t\"$.type\":          checkEqual(res.Type, \"\"),\n\t\t\t\"$.function.name\": checkEqual(res.Function.Name, \"\"),\n\t\t\t\"$.function.bool\": checkEqual(res.Function.OfBool, false),\n\n\t\t\t\"string.meta\":          checkMeta(res.JSON.OfString, \"\", shouldBeNullish),\n\t\t\t\"int.meta\":             checkMeta(res.JSON.OfInt, rawJSON, shouldBePresent),\n\t\t\t\"$.type.meta\":          checkMeta(res.JSON.Type, \"\", shouldBeNullish),\n\t\t\t\"$.function.meta\":      checkMeta(res.Function.JSON.Name, \"\", shouldBeNullish),\n\t\t\t\"$.function.name.meta\": checkMeta(res.Function.JSON.Name, \"\", shouldBeNullish),\n\t\t}\n\t})\n\n\ttestUnmarshalUnion(t, `0`, func(res UnionOfStringIntOrObject) map[string]error {\n\t\treturn map[string]error{\n\t\t\t\"rawJSON\": checkEqual(res.RawJSON(), \"0\"),\n\t\t\t\"string\":  checkEqual(res.OfString, \"\"),\n\n\t\t\t\"int\":         checkEqual(res.OfInt, 0),\n\t\t\t\"int.meta\":    checkMeta(res.JSON.OfInt, \"0\", shouldBePresent),\n\t\t\t\"string.meta\": checkMeta(res.JSON.OfString, \"\", shouldBeNullish),\n\t\t}\n\t})\n}\n\nfunc TestUnmarshalUnionObject(t *testing.T) {\n\trawJSON := `{\"type\":\"auto\",\"function\":{\"name\":\"test_fn\"}}`\n\ttestUnmarshalUnion(t, rawJSON, func(res UnionOfStringIntOrObject) map[string]error {\n\t\treturn map[string]error{\n\t\t\t\"rawJSON\": checkEqual(res.RawJSON(), rawJSON),\n\n\t\t\t\"string\":          checkEqual(res.OfString, \"\"),\n\t\t\t\"int\":             checkEqual(res.OfInt, 0),\n\t\t\t\"$.type\":          checkEqual(res.Type, \"auto\"),\n\t\t\t\"$.function.name\": checkEqual(res.Function.Name, \"test_fn\"),\n\t\t\t\"$.function.bool\": checkEqual(res.Function.OfBool, false),\n\n\t\t\t\"string.meta\":          checkMeta(res.JSON.OfString, \"\", shouldBeNullish),\n\t\t\t\"int.meta\":             checkMeta(res.JSON.OfInt, \"\", shouldBeNullish),\n\t\t\t\"$.type.meta\":          checkMeta(res.JSON.Type, `\"auto\"`, shouldBePresent),\n\t\t\t\"$.function.meta\":      checkMeta(res.JSON.Function, `{\"name\":\"test_fn\"}`, shouldBePresent),\n\t\t\t\"$.function.name.meta\": checkMeta(res.Function.JSON.Name, `\"test_fn\"`, shouldBePresent),\n\t\t\t\"$.function.bool.meta\": checkMeta(res.Function.JSON.OfBool, \"\", shouldBeNullish),\n\t\t}\n\t})\n}\n\nfunc TestUnmarshalUnionObjectWithInlineSubUnion(t *testing.T) {\n\trawJSON := `{\"type\":\"auto\",\"function\":true}`\n\ttestUnmarshalUnion(t, rawJSON, func(res UnionOfStringIntOrObject) map[string]error {\n\t\treturn map[string]error{\n\t\t\t\"rawJSON\": checkEqual(res.RawJSON(), rawJSON),\n\n\t\t\t\"string\":     checkEqual(res.OfString, \"\"),\n\t\t\t\"int\":        checkEqual(res.OfInt, 0),\n\t\t\t\"$.type\":     checkEqual(res.Type, \"auto\"),\n\t\t\t\"$.function\": checkEqual(res.Function.OfBool, true),\n\n\t\t\t\"string.meta\":          checkMeta(res.JSON.OfString, \"\", shouldBeNullish),\n\t\t\t\"int.meta\":             checkMeta(res.JSON.OfInt, \"\", shouldBeNullish),\n\t\t\t\"$.type.meta\":          checkMeta(res.JSON.Type, `\"auto\"`, shouldBePresent),\n\t\t\t\"$.function.meta\":      checkMeta(res.JSON.Function, `true`, shouldBePresent),\n\t\t\t\"$.function.name.meta\": checkMeta(res.Function.JSON.Name, \"\", shouldBeNullish),\n\t\t\t\"$.function.bool.meta\": checkMeta(res.Function.JSON.OfBool, `true`, shouldBePresent),\n\t\t}\n\t})\n}\n\n/*********/\n/* UTILS */\n/*********/\n\nfunc testUnmarshalUnion[T any](t *testing.T, raw string, check testChecks[T]) {\n\tvar res T\n\terr := json.Unmarshal([]byte(raw), &res)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to unmarshal %v\", err.Error())\n\t}\n\n\tfor label, fail := range check(res) {\n\t\tif fail != nil {\n\t\t\tt.Errorf(\"failed check %v: %v\", label, fail.Error())\n\t\t}\n\t}\n}\n\nfunc checkEqual[T any](got, expected T) error {\n\tif reflect.DeepEqual(got, expected) {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"not equal: got %v, expected %v\", got, expected)\n}\n\ntype metaStatus int\n\nconst (\n\tshouldBePresent metaStatus = iota\n\tshouldBeNullish\n\tshouldBeInvalid\n)\n\ntype testChecks[T any] func(T) map[string]error\n\nfunc checkMeta(got rj.Field, raw string, stat metaStatus) error {\n\tswitch stat {\n\tcase shouldBePresent:\n\t\tif !got.Valid() {\n\t\t\treturn fmt.Errorf(\"expected field to be present, but got nullish\")\n\t\t}\n\t\tif got.Raw() != raw {\n\t\t\treturn fmt.Errorf(\"expected field to be present with raw value %v, but got %v\", raw, got.Raw())\n\t\t}\n\tcase shouldBeNullish:\n\t\tif got.Valid() {\n\t\t\treturn fmt.Errorf(\"expected field to be nullish, but got %v\", got.Raw())\n\t\t}\n\t\tif got.Raw() != rj.Omitted && got.Raw() != rj.Null {\n\t\t\treturn fmt.Errorf(\"expected field to be nullish, but got %v\", got.Raw())\n\t\t}\n\tcase shouldBeInvalid:\n\t\tif !got.Valid() || got.Raw() == \"\" {\n\t\t\treturn fmt.Errorf(\"expected field to be invalid, but got valid value %v\", got.Raw())\n\t\t}\n\t\tif got.Raw() != raw {\n\t\t\treturn fmt.Errorf(\"expected field to be invalid, but got valid value %v\", got.Raw())\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown metaStatus: %v\", stat)\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "packages/respjson/respjson.go",
    "content": "package respjson\n\n// A Field provides metadata to indicate the presence of a value.\n//\n// Use [Field.Valid] to check if an optional value was null or omitted.\n//\n// A Field will always occur in the following structure, where it\n// mirrors the original field in its parent struct:\n//\n//\ttype ExampleObject struct {\n//\t\tFoo bool\t`json:\"foo\"`\n//\t\tBar int\t\t`json:\"bar\"`\n//\t\t// ...\n//\n//\t\t// JSON provides metadata about the object.\n//\t\tJSON struct {\n//\t\t\tFoo Field\n//\t\t\tBar Field\n//\t\t\t// ...\n//\t\t} `json:\"-\"`\n//\t}\n//\n// To differentiate a \"nullish\" value from the zero value,\n// use the [Field.Valid] method.\n//\n//\tif !example.JSON.Foo.Valid() {\n//\t\tprintln(\"Foo is null or omitted\")\n//\t}\n//\n//\tif example.Foo {\n//\t\tprintln(\"Foo is true\")\n//\t} else {\n//\t\tprintln(\"Foo is false\")\n//\t}\n//\n// To differentiate if a field was omitted or the JSON value \"null\",\n// use the [Field.Raw] method.\n//\n//\tif example.JSON.Foo.Raw() == \"null\" {\n//\t\tprintln(\"Foo is null\")\n//\t}\n//\n//\tif example.JSON.Foo.Raw() == \"\" {\n//\t\tprintln(\"Foo was omitted\")\n//\t}\n//\n// Otherwise, if the field was invalid and couldn't be marshalled successfully,\n// [Field.Valid] will be false and [Field.Raw] will not be empty.\ntype Field struct {\n\tstatus\n\traw string\n}\n\nconst (\n\tomitted status = iota\n\tnull\n\tinvalid\n\tvalid\n)\n\ntype status int8\n\n// Valid returns true if the parent field was set.\n// Valid returns false if the value doesn't exist, is JSON null, or\n// is an unexpected type.\nfunc (j Field) Valid() bool { return j.status > invalid }\n\nconst Null string = \"null\"\nconst Omitted string = \"\"\n\n// Returns the raw JSON value of the field.\nfunc (j Field) Raw() string {\n\tif j.status == omitted {\n\t\treturn \"\"\n\t}\n\treturn j.raw\n}\n\nfunc NewField(raw string) Field {\n\tif raw == \"null\" {\n\t\treturn Field{status: null, raw: Null}\n\t}\n\treturn Field{status: valid, raw: raw}\n}\n\nfunc NewInvalidField(raw string) Field {\n\treturn Field{status: invalid, raw: raw}\n}\n"
  },
  {
    "path": "packages/ssestream/ssestream.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage ssestream\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\ntype Decoder interface {\n\tEvent() Event\n\tNext() bool\n\tClose() error\n\tErr() error\n}\n\nfunc NewDecoder(res *http.Response) Decoder {\n\tif res == nil || res.Body == nil {\n\t\treturn nil\n\t}\n\n\tvar decoder Decoder\n\tcontentType := res.Header.Get(\"content-type\")\n\tif t, ok := decoderTypes[contentType]; ok {\n\t\tdecoder = t(res.Body)\n\t} else {\n\t\tscn := bufio.NewScanner(res.Body)\n\t\tscn.Buffer(nil, bufio.MaxScanTokenSize<<9)\n\t\tdecoder = &eventStreamDecoder{rc: res.Body, scn: scn}\n\t}\n\treturn decoder\n}\n\nvar decoderTypes = map[string](func(io.ReadCloser) Decoder){}\n\nfunc RegisterDecoder(contentType string, decoder func(io.ReadCloser) Decoder) {\n\tdecoderTypes[strings.ToLower(contentType)] = decoder\n}\n\ntype Event struct {\n\tType string\n\tData []byte\n}\n\n// A base implementation of a Decoder for text/event-stream.\ntype eventStreamDecoder struct {\n\tevt Event\n\trc  io.ReadCloser\n\tscn *bufio.Scanner\n\terr error\n}\n\nfunc (s *eventStreamDecoder) Next() bool {\n\tif s.err != nil {\n\t\treturn false\n\t}\n\n\tevent := \"\"\n\tdata := bytes.NewBuffer(nil)\n\n\tfor s.scn.Scan() {\n\t\ttxt := s.scn.Bytes()\n\n\t\t// Dispatch event on an empty line\n\t\tif len(txt) == 0 {\n\t\t\ts.evt = Event{\n\t\t\t\tType: event,\n\t\t\t\tData: data.Bytes(),\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\t// Split a string like \"event: bar\" into name=\"event\" and value=\" bar\".\n\t\tname, value, _ := bytes.Cut(txt, []byte(\":\"))\n\n\t\t// Consume an optional space after the colon if it exists.\n\t\tif len(value) > 0 && value[0] == ' ' {\n\t\t\tvalue = value[1:]\n\t\t}\n\n\t\tswitch string(name) {\n\t\tcase \"\":\n\t\t\t// An empty line in the for \": something\" is a comment and should be ignored.\n\t\t\tcontinue\n\t\tcase \"event\":\n\t\t\tevent = string(value)\n\t\tcase \"data\":\n\t\t\t_, s.err = data.Write(value)\n\t\t\tif s.err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t_, s.err = data.WriteRune('\\n')\n\t\t\tif s.err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif s.scn.Err() != nil {\n\t\ts.err = s.scn.Err()\n\t}\n\n\treturn false\n}\n\nfunc (s *eventStreamDecoder) Event() Event {\n\treturn s.evt\n}\n\nfunc (s *eventStreamDecoder) Close() error {\n\treturn s.rc.Close()\n}\n\nfunc (s *eventStreamDecoder) Err() error {\n\treturn s.err\n}\n\ntype Stream[T any] struct {\n\tdecoder Decoder\n\tcur     T\n\terr     error\n}\n\nfunc NewStream[T any](decoder Decoder, err error) *Stream[T] {\n\treturn &Stream[T]{\n\t\tdecoder: decoder,\n\t\terr:     err,\n\t}\n}\n\n// Next returns false if the stream has ended or an error occurred.\n// Call Stream.Current() to get the current value.\n// Call Stream.Err() to get the error.\n//\n//\t\tfor stream.Next() {\n//\t\t\tdata := stream.Current()\n//\t\t}\n//\n//\t \tif stream.Err() != nil {\n//\t\t\t...\n//\t \t}\nfunc (s *Stream[T]) Next() bool {\n\tif s.err != nil {\n\t\treturn false\n\t}\n\n\tfor s.decoder.Next() {\n\t\tswitch s.decoder.Event().Type {\n\t\tcase \"completion\":\n\t\t\tvar nxt T\n\t\t\ts.err = json.Unmarshal(s.decoder.Event().Data, &nxt)\n\t\t\tif s.err != nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.cur = nxt\n\t\t\treturn true\n\t\tcase \"message_start\", \"message_delta\", \"message_stop\", \"content_block_start\", \"content_block_delta\", \"content_block_stop\":\n\t\t\tvar nxt T\n\t\t\ts.err = json.Unmarshal(s.decoder.Event().Data, &nxt)\n\t\t\tif s.err != nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts.cur = nxt\n\t\t\treturn true\n\t\tcase \"ping\":\n\t\t\tcontinue\n\t\tcase \"error\":\n\t\t\ts.err = fmt.Errorf(\"received error while streaming: %s\", string(s.decoder.Event().Data))\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// decoder.Next() may be false because of an error\n\ts.err = s.decoder.Err()\n\n\treturn false\n}\n\nfunc (s *Stream[T]) Current() T {\n\treturn s.cur\n}\n\nfunc (s *Stream[T]) Err() error {\n\treturn s.err\n}\n\nfunc (s *Stream[T]) Close() error {\n\tif s.decoder == nil {\n\t\t// already closed\n\t\treturn nil\n\t}\n\treturn s.decoder.Close()\n}\n"
  },
  {
    "path": "paginationauto_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestAutoPagination(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\titer := client.Beta.Messages.Batches.ListAutoPaging(context.TODO(), anthropic.BetaMessageBatchListParams{\n\t\tLimit: anthropic.Int(20),\n\t})\n\t// The mock server isn't going to give us real pagination\n\tfor i := 0; i < 3 && iter.Next(); i++ {\n\t\tbatch := iter.Current()\n\t\tt.Logf(\"%+v\\n\", batch.ID)\n\t}\n\tif err := iter.Err(); err != nil {\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "paginationmanual_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestManualPagination(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\tpage, err := client.Beta.Messages.Batches.List(context.TODO(), anthropic.BetaMessageBatchListParams{\n\t\tLimit: anthropic.Int(20),\n\t})\n\tif err != nil {\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n\tfor _, batch := range page.Data {\n\t\tt.Logf(\"%+v\\n\", batch.ID)\n\t}\n\t// The mock server isn't going to give us real pagination\n\tpage, err = page.GetNextPage()\n\tif err != nil {\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n\tif page != nil {\n\t\tfor _, batch := range page.Data {\n\t\t\tt.Logf(\"%+v\\n\", batch.ID)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "release-please-config.json",
    "content": "{\n  \"packages\": {\n    \".\": {}\n  },\n  \"$schema\": \"https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json\",\n  \"include-v-in-tag\": true,\n  \"include-component-in-tag\": false,\n  \"versioning\": \"prerelease\",\n  \"prerelease\": true,\n  \"bump-minor-pre-major\": true,\n  \"bump-patch-for-minor-pre-major\": false,\n  \"pull-request-header\": \"Automated Release PR\",\n  \"pull-request-title-pattern\": \"release: ${version}\",\n  \"changelog-sections\": [\n    {\n      \"type\": \"feat\",\n      \"section\": \"Features\"\n    },\n    {\n      \"type\": \"fix\",\n      \"section\": \"Bug Fixes\"\n    },\n    {\n      \"type\": \"perf\",\n      \"section\": \"Performance Improvements\"\n    },\n    {\n      \"type\": \"revert\",\n      \"section\": \"Reverts\"\n    },\n    {\n      \"type\": \"chore\",\n      \"section\": \"Chores\"\n    },\n    {\n      \"type\": \"docs\",\n      \"section\": \"Documentation\"\n    },\n    {\n      \"type\": \"style\",\n      \"section\": \"Styles\"\n    },\n    {\n      \"type\": \"refactor\",\n      \"section\": \"Refactors\"\n    },\n    {\n      \"type\": \"test\",\n      \"section\": \"Tests\",\n      \"hidden\": true\n    },\n    {\n      \"type\": \"build\",\n      \"section\": \"Build System\"\n    },\n    {\n      \"type\": \"ci\",\n      \"section\": \"Continuous Integration\",\n      \"hidden\": true\n    }\n  ],\n  \"release-type\": \"go\",\n  \"extra-files\": [\n    \"internal/version.go\",\n    \"README.md\",\n    \".github/workflows/create-releases.yml\"\n  ]\n}"
  },
  {
    "path": "schemautil.go",
    "content": "package anthropic\n\nimport (\n\t\"fmt\"\n\t\"maps\"\n\t\"slices\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// BetaJSONSchemaOutputFormat creates a BetaJSONOutputFormatParam from a JSON schema map.\n// It transforms the schema to ensure compatibility with Anthropic's JSON schema requirements.\n//\n// Example:\n//\n//\tschema := map[string]any{\n//\t    \"type\": \"object\",\n//\t    \"properties\": map[string]any{\n//\t        \"name\": map[string]any{\"type\": \"string\"},\n//\t        \"age\": map[string]any{\"type\": \"integer\", \"minimum\": 0},\n//\t    },\n//\t    \"required\": []string{\"name\"},\n//\t}\n//\toutputFormat := BetaJSONSchemaOutputFormat(schema)\n//\n//\tmsg, _ := client.Beta.Messages.New(ctx, anthropic.BetaMessageNewParams{\n//\t    Model: anthropic.Model(\"claude-sonnet-4-5\"),\n//\t    Messages: anthropic.F([]anthropic.BetaMessageParam{...}),\n//\t    MaxTokens: 1024,\n//\t    OutputFormat: outputFormat,\n//\t})\nfunc BetaJSONSchemaOutputFormat(jsonSchema map[string]any) BetaJSONOutputFormatParam {\n\treturn BetaJSONOutputFormatParam{Schema: transformSchema(jsonSchema)}\n}\n\n// BetaToolInputSchema creates a BetaToolInputSchemaParam from a JSON schema map.\n// It transforms the schema to ensure compatibility with Anthropic's tool calling requirements.\nfunc BetaToolInputSchema(jsonSchema map[string]any) BetaToolInputSchemaParam {\n\treturn BetaToolInputSchemaParam{ExtraFields: transformSchema(jsonSchema)}\n}\n\nvar supportedStringFormats = []string{\n\t\"date-time\",\n\t\"time\",\n\t\"date\",\n\t\"duration\",\n\t\"email\",\n\t\"hostname\",\n\t\"uri\",\n\t\"ipv4\",\n\t\"ipv6\",\n\t\"uuid\",\n}\nvar supportedSchemaKeys = []string{\n\t// Top-level schema keys\n\t\"$ref\",\n\t\"$defs\",\n\t\"type\",\n\t\"anyOf\",\n\t\"oneOf\",\n\t\"description\",\n\t\"title\",\n\n\t// Object-specific keys\n\t\"properties\",\n\t\"additionalProperties\",\n\t\"required\",\n\n\t// Array-specific keys\n\t\"items\",\n\t\"minItems\",\n\n\t// String-specific keys\n\t\"format\",\n}\n\n// TransformSchema transforms a JSON schema to ensure it conforms to the Anthropic API's expectations.\n// It returns nil if the transformed schema is empty.\n//\n// The transformation process:\n// - Preserves $ref references\n// - Transforms $defs recursively\n// - Handles anyOf/oneOf by converting oneOf to anyOf\n// - Ensures objects have additionalProperties: false\n// - Filters string formats to only supported ones\n// - Limits array minItems to 0 or 1\n// - Appends unsupported properties to the description\n//\n// Example:\n//\n//\tschema := map[string]any{\n//\t    \"type\": \"integer\",\n//\t    \"minimum\": 1,\n//\t    \"maximum\": 10,\n//\t    \"description\": \"A number\",\n//\t}\n//\ttransformed := TransformSchema(schema)\n//\t// Result: {\"type\": \"integer\", \"description\": \"A number\\n\\n{minimum: 1, maximum: 10}\"}\nfunc transformSchema(jsonSchema map[string]any) map[string]any {\n\tif jsonSchema == nil {\n\t\treturn nil\n\t}\n\n\tstrictSchema := make(map[string]any)\n\n\t// Create a copy to avoid modifying the original\n\tschemaCopy := make(map[string]any)\n\tmaps.Copy(schemaCopy, jsonSchema)\n\n\t// $ref is not supported alongside other properties\n\tif ref, ok := schemaCopy[\"$ref\"]; ok {\n\t\tstrictSchema[\"$ref\"] = ref\n\t\treturn strictSchema\n\t}\n\n\tfor _, key := range supportedSchemaKeys {\n\t\tvalue, exists := schemaCopy[key]\n\t\tif exists {\n\t\t\tdelete(schemaCopy, key)\n\t\t\tstrictSchema[key] = value\n\t\t}\n\t}\n\n\tif defs, ok := strictSchema[\"$defs\"]; ok {\n\t\tif defsMap, ok := defs.(map[string]any); ok {\n\t\t\tstrictDefs := make(map[string]any)\n\t\t\tstrictSchema[\"$defs\"] = strictDefs\n\n\t\t\tfor name, schema := range defsMap {\n\t\t\t\tif schemaMap, ok := schema.(map[string]any); ok {\n\t\t\t\t\tstrictDefs[name] = transformSchema(schemaMap)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttypeValue, _ := strictSchema[\"type\"]\n\tanyOf, _ := strictSchema[\"anyOf\"]\n\toneOf, _ := strictSchema[\"oneOf\"]\n\n\tif anyOfSlice, ok := anyOf.([]any); ok {\n\t\ttransformedVariants := make([]any, 0, len(anyOfSlice))\n\t\tfor _, variant := range anyOfSlice {\n\t\t\tvariantMap, ok := variant.(map[string]any)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif transformed := transformSchema(variantMap); transformed != nil {\n\t\t\t\ttransformedVariants = append(transformedVariants, transformed)\n\t\t\t}\n\t\t}\n\t\tstrictSchema[\"anyOf\"] = transformedVariants\n\t} else if oneOfSlice, ok := oneOf.([]any); ok {\n\t\ttransformedVariants := make([]any, 0, len(oneOfSlice))\n\t\tfor _, variant := range oneOfSlice {\n\t\t\tif variantMap, ok := variant.(map[string]any); ok {\n\t\t\t\tif transformed := transformSchema(variantMap); transformed != nil {\n\t\t\t\t\ttransformedVariants = append(transformedVariants, transformed)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdelete(strictSchema, \"oneOf\")\n\t\tstrictSchema[\"anyOf\"] = transformedVariants\n\t} else {\n\t\tif typeValue == nil {\n\t\t\t// schema is completely invalid, we have to bail\n\t\t\treturn nil\n\t\t}\n\n\t\tstrictSchema[\"type\"] = typeValue\n\t}\n\n\ttypeStr, _ := typeValue.(string)\n\tswitch typeStr {\n\tcase \"object\":\n\t\tif properties, ok := strictSchema[\"properties\"]; ok {\n\t\t\tif propsMap, ok := properties.(map[string]any); ok {\n\t\t\t\ttransformedProps := make(map[string]any)\n\t\t\t\tfor key, propSchema := range propsMap {\n\t\t\t\t\tif propSchemaMap, ok := propSchema.(map[string]any); ok {\n\t\t\t\t\t\ttransformedProps[key] = transformSchema(propSchemaMap)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstrictSchema[\"properties\"] = transformedProps\n\t\t\t}\n\t\t} else {\n\t\t\tstrictSchema[\"properties\"] = make(map[string]any)\n\t\t}\n\n\t\tstrictSchema[\"additionalProperties\"] = false\n\n\tcase \"string\":\n\t\tif format, ok := strictSchema[\"format\"]; ok {\n\t\t\tif formatStr, ok := format.(string); ok {\n\t\t\t\tif !slices.Contains(supportedStringFormats, formatStr) {\n\t\t\t\t\tschemaCopy[\"format\"] = format\n\t\t\t\t\tdelete(strictSchema, \"format\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tcase \"array\":\n\t\tif items, ok := strictSchema[\"items\"]; ok {\n\t\t\tif itemsMap, ok := items.(map[string]any); ok {\n\t\t\t\tstrictSchema[\"items\"] = transformSchema(itemsMap)\n\t\t\t}\n\t\t}\n\n\t\tif minItems, ok := strictSchema[\"minItems\"]; ok {\n\t\t\tif minItems != 0 && minItems != 1 {\n\t\t\t\tschemaCopy[\"minItems\"] = minItems\n\t\t\t\tdelete(strictSchema, \"minItems\")\n\t\t\t}\n\t\t}\n\n\tcase \"boolean\", \"integer\", \"number\", \"null\":\n\t\t// These types are supported as-is\n\t}\n\n\tif len(schemaCopy) > 0 {\n\t\tdescription := strictSchema[\"description\"]\n\t\tdescStr, _ := description.(string)\n\n\t\t// Sort keys for deterministic output\n\t\tkeys := make([]string, 0, len(schemaCopy))\n\t\tfor key := range schemaCopy {\n\t\t\tkeys = append(keys, key)\n\t\t}\n\t\tsort.Strings(keys)\n\n\t\textraProps := make([]string, 0, len(keys))\n\t\tfor _, key := range keys {\n\t\t\textraProps = append(extraProps, fmt.Sprintf(\"%s: %v\", key, schemaCopy[key]))\n\t\t}\n\n\t\tif descStr != \"\" {\n\t\t\tstrictSchema[\"description\"] = descStr + \"\\n\\n{\" + strings.Join(extraProps, \", \") + \"}\"\n\t\t} else {\n\t\t\tstrictSchema[\"description\"] = \"{\" + strings.Join(extraProps, \", \") + \"}\"\n\t\t}\n\t}\n\n\treturn strictSchema\n}\n"
  },
  {
    "path": "schemautil_test.go",
    "content": "package anthropic\n\nimport (\n\t\"encoding/json\"\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc TestTransformSchema(t *testing.T) {\n\ttests := []struct {\n\t\tname     string\n\t\tinput    map[string]any\n\t\texpected map[string]any\n\t}{\n\t\t{\n\t\t\tname: \"basic integer with unsupported properties\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\":        \"integer\",\n\t\t\t\t\"minimum\":     1,\n\t\t\t\t\"maximum\":     10,\n\t\t\t\t\"description\": \"A number\",\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\":        \"integer\",\n\t\t\t\t\"description\": \"A number\\n\\n{maximum: 10, minimum: 1}\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"object with properties\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\": \"object\",\n\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\"name\": map[string]any{\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t},\n\t\t\t\t\t\"age\": map[string]any{\n\t\t\t\t\t\t\"type\": \"integer\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"required\":             []string{\"name\"},\n\t\t\t\t\"additionalProperties\": true,\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\": \"object\",\n\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\"name\": map[string]any{\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t},\n\t\t\t\t\t\"age\": map[string]any{\n\t\t\t\t\t\t\"type\": \"integer\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"required\":             []string{\"name\"},\n\t\t\t\t\"additionalProperties\": false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"string with supported format\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\":   \"string\",\n\t\t\t\t\"format\": \"date-time\",\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\":   \"string\",\n\t\t\t\t\"format\": \"date-time\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"string with unsupported format\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\":   \"string\",\n\t\t\t\t\"format\": \"binary\",\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\"description\": \"{format: binary}\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"array with minItems 1\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": map[string]any{\n\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t},\n\t\t\t\t\"minItems\": 1,\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": map[string]any{\n\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t},\n\t\t\t\t\"minItems\": 1,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"array with minItems 5\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": map[string]any{\n\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t},\n\t\t\t\t\"minItems\": 5,\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\": \"array\",\n\t\t\t\t\"items\": map[string]any{\n\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t},\n\t\t\t\t\"description\": \"{minItems: 5}\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"schema with $ref\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"$ref\": \"#/definitions/Person\",\n\t\t\t\t\"type\": \"object\",\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"$ref\": \"#/definitions/Person\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"schema with anyOf\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"anyOf\": []any{\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t},\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"anyOf\": []any{\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t},\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"schema with oneOf converted to anyOf\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"oneOf\": []any{\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t},\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"anyOf\": []any{\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t},\n\t\t\t\t\tmap[string]any{\n\t\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"schema with $defs\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"type\": \"object\",\n\t\t\t\t\"$defs\": map[string]any{\n\t\t\t\t\t\"Person\": map[string]any{\n\t\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\t\t\"name\": map[string]any{\n\t\t\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\"user\": map[string]any{\n\t\t\t\t\t\t\"$ref\": \"#/$defs/Person\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpected: map[string]any{\n\t\t\t\t\"type\": \"object\",\n\t\t\t\t\"$defs\": map[string]any{\n\t\t\t\t\t\"Person\": map[string]any{\n\t\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\t\t\"name\": map[string]any{\n\t\t\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"additionalProperties\": false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\"user\": map[string]any{\n\t\t\t\t\t\t\"$ref\": \"#/$defs/Person\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"additionalProperties\": false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname:     \"nil schema returns nil\",\n\t\t\tinput:    nil,\n\t\t\texpected: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"schema without type returns nil\",\n\t\t\tinput: map[string]any{\n\t\t\t\t\"description\": \"A schema without type\",\n\t\t\t},\n\t\t\texpected: nil,\n\t\t},\n\t}\n\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tresult := transformSchema(tt.input)\n\t\t\tif !reflect.DeepEqual(result, tt.expected) {\n\t\t\t\tresultJSON, _ := json.MarshalIndent(result, \"\", \"  \")\n\t\t\t\texpectedJSON, _ := json.MarshalIndent(tt.expected, \"\", \"  \")\n\t\t\t\tt.Errorf(\"TransformSchema() mismatch:\\ngot:\\n%s\\nwant:\\n%s\", resultJSON, expectedJSON)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "scripts/bootstrap",
    "content": "#!/usr/bin/env bash\n\nset -e\n\ncd \"$(dirname \"$0\")/..\"\n\nif [ -f \"Brewfile\" ] && [ \"$(uname -s)\" = \"Darwin\" ] && [ \"$SKIP_BREW\" != \"1\" ] && [ -t 0 ]; then\n  brew bundle check >/dev/null 2>&1 || {\n    echo -n \"==> Install Homebrew dependencies? (y/N): \"\n    read -r response\n    case \"$response\" in\n      [yY][eE][sS]|[yY])\n        brew bundle\n        ;;\n      *)\n        ;;\n    esac\n    echo\n  }\nfi\n\necho \"==> Installing Go dependencies…\"\n\ngo mod tidy -e\n"
  },
  {
    "path": "scripts/detect-breaking-changes",
    "content": "#!/usr/bin/env bash\n\nset -e\n\ncd \"$(dirname \"$0\")/..\"\n\necho \"==> Detecting breaking changes\"\n\nTEST_PATHS=(\n\tclient_test.go\n\tcompletion_test.go\n\tmessage_test.go\n\tmessagebatch_test.go\n\tmodel_test.go\n\tbetamodel_test.go\n\tbetamessage_test.go\n\tbetamessagebatch_test.go\n\tbetafile_test.go\n\tbetaskill_test.go\n\tbetaskillversion_test.go\n\tusage_test.go\n\tpaginationauto_test.go\n\tpaginationmanual_test.go\n)\n\nfor PATHSPEC in \"${TEST_PATHS[@]}\"; do\n    # Try to check out previous versions of the test files\n    # with the current SDK.\n    git checkout \"$1\" -- \"${PATHSPEC}\" 2>/dev/null || true\ndone\n\n# Instead of running the tests, use the linter to check if an\n# older test is no longer compatible with the latest SDK.\n./scripts/lint\n"
  },
  {
    "path": "scripts/format",
    "content": "#!/usr/bin/env bash\n\nset -e\n\ncd \"$(dirname \"$0\")/..\"\n\necho \"==> Running gofmt -s -w\"\ngofmt -s -w .\n"
  },
  {
    "path": "scripts/lint",
    "content": "#!/usr/bin/env bash\n\nset -e\n\ncd \"$(dirname \"$0\")/..\"\n\necho \"==> Running Go build\"\ngo build ./...\n\necho \"==> Checking tests compile\"\ngo test -run=^$ ./...\n\necho \"==> Building examples\"\ncd examples && go build ./...\n"
  },
  {
    "path": "scripts/mock",
    "content": "#!/usr/bin/env bash\n\nset -e\n\ncd \"$(dirname \"$0\")/..\"\n\nif [[ -n \"$1\" && \"$1\" != '--'* ]]; then\n  URL=\"$1\"\n  shift\nelse\n  URL=\"$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)\"\nfi\n\n# Check if the URL is empty\nif [ -z \"$URL\" ]; then\n  echo \"Error: No OpenAPI spec path/url provided or found in .stats.yml\"\n  exit 1\nfi\n\necho \"==> Starting mock server with URL ${URL}\"\n\n# Run steady mock on the given spec\nif [ \"$1\" == \"--daemon\" ]; then\n  # Pre-install the package so the download doesn't eat into the startup timeout\n  npm exec --package=@stdy/cli@0.19.3 -- steady --version\n\n  npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=brackets \"$URL\" &> .stdy.log &\n\n  # Wait for server to come online via health endpoint (max 30s)\n  echo -n \"Waiting for server\"\n  attempts=0\n  while ! curl --silent --fail \"http://127.0.0.1:4010/_x-steady/health\" >/dev/null 2>&1; do\n    if ! kill -0 $! 2>/dev/null; then\n      echo\n      cat .stdy.log\n      exit 1\n    fi\n    attempts=$((attempts + 1))\n    if [ \"$attempts\" -ge 300 ]; then\n      echo\n      echo \"Timed out waiting for Steady server to start\"\n      cat .stdy.log\n      exit 1\n    fi\n    echo -n \".\"\n    sleep 0.1\n  done\n\n  echo\nelse\n  npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=brackets \"$URL\"\nfi\n"
  },
  {
    "path": "scripts/test",
    "content": "#!/usr/bin/env bash\n\nset -e\n\ncd \"$(dirname \"$0\")/..\"\n\nRED='\\033[0;31m'\nGREEN='\\033[0;32m'\nYELLOW='\\033[0;33m'\nNC='\\033[0m' # No Color\n\nfunction steady_is_running() {\n  curl --silent \"http://127.0.0.1:4010/_x-steady/health\" >/dev/null 2>&1\n}\n\nkill_server_on_port() {\n  pids=$(lsof -t -i tcp:\"$1\" || echo \"\")\n  if [ \"$pids\" != \"\" ]; then\n    kill \"$pids\"\n    echo \"Stopped $pids.\"\n  fi\n}\n\nfunction is_overriding_api_base_url() {\n  [ -n \"$TEST_API_BASE_URL\" ]\n}\n\nif ! is_overriding_api_base_url && ! steady_is_running ; then\n  # When we exit this script, make sure to kill the background mock server process\n  trap 'kill_server_on_port 4010' EXIT\n\n  # Start the dev server\n  ./scripts/mock --daemon\nfi\n\nif is_overriding_api_base_url ; then\n  echo -e \"${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}\"\n  echo\nelif ! steady_is_running ; then\n  echo -e \"${RED}ERROR:${NC} The test suite will not run without a mock Steady server\"\n  echo -e \"running against your OpenAPI spec.\"\n  echo\n  echo -e \"To run the server, pass in the path or url of your OpenAPI\"\n  echo -e \"spec to the steady command:\"\n  echo\n  echo -e \"  \\$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=brackets${NC}\"\n  echo\n\n  exit 1\nelse\n  echo -e \"${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}\"\n  echo\nfi\n\necho \"==> Running tests\"\ngo test ./... \"$@\"\n"
  },
  {
    "path": "scripts/utils/upload-artifact.sh",
    "content": "#!/usr/bin/env bash\nset -exuo pipefail\n\nDIST_DIR=\"dist\"\nFILENAME=\"source.zip\"\n\nmapfile -d '' files < <(\n  find . -type f \\\n    \\( -name '*.go' -o -name 'go.mod' -o -name 'go.sum' \\) \\\n    ! -path \"./${DIST_DIR}/*\" \\\n    -print0\n)\n\nif [[ ${#files[@]} -eq 0 ]]; then\n  echo -e \"\\033[31mNo Go source files found for packaging.\\033[0m\"\n  exit 1\nfi\n\nmkdir -p \"$DIST_DIR\"\nrm -f \"${DIST_DIR}/${FILENAME}\"\n\nrelative_files=()\nfor file in \"${files[@]}\"; do\n  relative_files+=(\"${file#./}\")\ndone\n\nzip \"${DIST_DIR}/${FILENAME}\" \"${relative_files[@]}\"\n\nRESPONSE=$(curl -X POST \"$URL?filename=$FILENAME\" \\\n  -H \"Authorization: Bearer $AUTH\" \\\n  -H \"Content-Type: application/json\")\n\nSIGNED_URL=$(echo \"$RESPONSE\" | jq -r '.url')\n\nif [[ \"$SIGNED_URL\" == \"null\" ]]; then\n  echo -e \"\\033[31mFailed to get signed URL.\\033[0m\"\n  exit 1\nfi\n\nUPLOAD_RESPONSE=$(curl -v -X PUT \\\n  -H \"Content-Type: application/zip\" \\\n  --data-binary \"@${DIST_DIR}/${FILENAME}\" \"$SIGNED_URL\" 2>&1)\n\nif echo \"$UPLOAD_RESPONSE\" | grep -q \"HTTP/[0-9.]* 200\"; then\n  echo -e \"\\033[32mUploaded build to Stainless storage.\\033[0m\"\n  echo -e \"\\033[32mInstallation: Download and unzip: 'https://pkg.stainless.com/s/anthropic-go/$SHA'. Run 'go mod edit -replace github.com/anthropics/anthropic-sdk-go=/path/to/unzipped_directory'.\\033[0m\"\nelse\n  echo -e \"\\033[31mFailed to upload artifact.\\033[0m\"\n  exit 1\nfi\n"
  },
  {
    "path": "shared/constant/constants.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage constant\n\nimport (\n\tshimjson \"github.com/anthropics/anthropic-sdk-go/internal/encoding/json\"\n)\n\n// ModelNonStreamingTokens defines the maximum tokens for models that should limit\n// non-streaming requests.\nvar ModelNonStreamingTokens = map[string]int{\n\t\"claude-opus-4-20250514\":                  8192,\n\t\"claude-4-opus-20250514\":                  8192,\n\t\"claude-opus-4-0\":                         8192,\n\t\"anthropic.claude-opus-4-20250514-v1:0\":   8192,\n\t\"claude-opus-4@20250514\":                  8192,\n\t\"claude-opus-4-1-20250805\":                8192,\n\t\"anthropic.claude-opus-4-1-20250805-v1:0\": 8192,\n\t\"claude-opus-4-1@20250805\":                8192,\n}\n\ntype Constant[T any] interface {\n\tDefault() T\n}\n\n// ValueOf gives the default value of a constant from its type. It's helpful when\n// constructing constants as variants in a one-of. Note that empty structs are\n// marshalled by default. Usage: constant.ValueOf[constant.Foo]()\nfunc ValueOf[T Constant[T]]() T {\n\tvar t T\n\treturn t.Default()\n}\n\ntype Adaptive string                                // Always \"adaptive\"\ntype All string                                     // Always \"all\"\ntype Any string                                     // Always \"any\"\ntype APIError string                                // Always \"api_error\"\ntype ApplicationPDF string                          // Always \"application/pdf\"\ntype Approximate string                             // Always \"approximate\"\ntype Assistant string                               // Always \"assistant\"\ntype AuthenticationError string                     // Always \"authentication_error\"\ntype Auto string                                    // Always \"auto\"\ntype Base64 string                                  // Always \"base64\"\ntype Bash string                                    // Always \"bash\"\ntype Bash20241022 string                            // Always \"bash_20241022\"\ntype Bash20250124 string                            // Always \"bash_20250124\"\ntype BashCodeExecutionOutput string                 // Always \"bash_code_execution_output\"\ntype BashCodeExecutionResult string                 // Always \"bash_code_execution_result\"\ntype BashCodeExecutionToolResult string             // Always \"bash_code_execution_tool_result\"\ntype BashCodeExecutionToolResultError string        // Always \"bash_code_execution_tool_result_error\"\ntype BillingError string                            // Always \"billing_error\"\ntype Canceled string                                // Always \"canceled\"\ntype CharLocation string                            // Always \"char_location\"\ntype CitationsDelta string                          // Always \"citations_delta\"\ntype ClearThinking20251015 string                   // Always \"clear_thinking_20251015\"\ntype ClearToolUses20250919 string                   // Always \"clear_tool_uses_20250919\"\ntype CodeExecution string                           // Always \"code_execution\"\ntype CodeExecution20250522 string                   // Always \"code_execution_20250522\"\ntype CodeExecution20250825 string                   // Always \"code_execution_20250825\"\ntype CodeExecution20260120 string                   // Always \"code_execution_20260120\"\ntype CodeExecutionOutput string                     // Always \"code_execution_output\"\ntype CodeExecutionResult string                     // Always \"code_execution_result\"\ntype CodeExecutionToolResult string                 // Always \"code_execution_tool_result\"\ntype CodeExecutionToolResultError string            // Always \"code_execution_tool_result_error\"\ntype Compact20260112 string                         // Always \"compact_20260112\"\ntype Compaction string                              // Always \"compaction\"\ntype CompactionDelta string                         // Always \"compaction_delta\"\ntype Completion string                              // Always \"completion\"\ntype Computer string                                // Always \"computer\"\ntype Computer20241022 string                        // Always \"computer_20241022\"\ntype Computer20250124 string                        // Always \"computer_20250124\"\ntype Computer20251124 string                        // Always \"computer_20251124\"\ntype ContainerUpload string                         // Always \"container_upload\"\ntype Content string                                 // Always \"content\"\ntype ContentBlockDelta string                       // Always \"content_block_delta\"\ntype ContentBlockLocation string                    // Always \"content_block_location\"\ntype ContentBlockStart string                       // Always \"content_block_start\"\ntype ContentBlockStop string                        // Always \"content_block_stop\"\ntype Create string                                  // Always \"create\"\ntype Delete string                                  // Always \"delete\"\ntype Direct string                                  // Always \"direct\"\ntype Disabled string                                // Always \"disabled\"\ntype Document string                                // Always \"document\"\ntype Enabled string                                 // Always \"enabled\"\ntype EncryptedCodeExecutionResult string            // Always \"encrypted_code_execution_result\"\ntype Ephemeral string                               // Always \"ephemeral\"\ntype Error string                                   // Always \"error\"\ntype Errored string                                 // Always \"errored\"\ntype Expired string                                 // Always \"expired\"\ntype File string                                    // Always \"file\"\ntype Image string                                   // Always \"image\"\ntype InputJSONDelta string                          // Always \"input_json_delta\"\ntype InputTokens string                             // Always \"input_tokens\"\ntype Insert string                                  // Always \"insert\"\ntype InvalidRequestError string                     // Always \"invalid_request_error\"\ntype JSONSchema string                              // Always \"json_schema\"\ntype MCPToolResult string                           // Always \"mcp_tool_result\"\ntype MCPToolUse string                              // Always \"mcp_tool_use\"\ntype MCPToolset string                              // Always \"mcp_toolset\"\ntype Memory string                                  // Always \"memory\"\ntype Memory20250818 string                          // Always \"memory_20250818\"\ntype Message string                                 // Always \"message\"\ntype MessageBatch string                            // Always \"message_batch\"\ntype MessageBatchDeleted string                     // Always \"message_batch_deleted\"\ntype MessageDelta string                            // Always \"message_delta\"\ntype MessageStart string                            // Always \"message_start\"\ntype MessageStop string                             // Always \"message_stop\"\ntype Model string                                   // Always \"model\"\ntype None string                                    // Always \"none\"\ntype NotFoundError string                           // Always \"not_found_error\"\ntype Object string                                  // Always \"object\"\ntype OverloadedError string                         // Always \"overloaded_error\"\ntype PageLocation string                            // Always \"page_location\"\ntype PermissionError string                         // Always \"permission_error\"\ntype RateLimitError string                          // Always \"rate_limit_error\"\ntype RedactedThinking string                        // Always \"redacted_thinking\"\ntype Rename string                                  // Always \"rename\"\ntype SearchResult string                            // Always \"search_result\"\ntype SearchResultLocation string                    // Always \"search_result_location\"\ntype ServerToolUse string                           // Always \"server_tool_use\"\ntype SignatureDelta string                          // Always \"signature_delta\"\ntype StrReplace string                              // Always \"str_replace\"\ntype StrReplaceBasedEditTool string                 // Always \"str_replace_based_edit_tool\"\ntype StrReplaceEditor string                        // Always \"str_replace_editor\"\ntype Succeeded string                               // Always \"succeeded\"\ntype Text string                                    // Always \"text\"\ntype TextDelta string                               // Always \"text_delta\"\ntype TextEditor20241022 string                      // Always \"text_editor_20241022\"\ntype TextEditor20250124 string                      // Always \"text_editor_20250124\"\ntype TextEditor20250429 string                      // Always \"text_editor_20250429\"\ntype TextEditor20250728 string                      // Always \"text_editor_20250728\"\ntype TextEditorCodeExecutionCreateResult string     // Always \"text_editor_code_execution_create_result\"\ntype TextEditorCodeExecutionStrReplaceResult string // Always \"text_editor_code_execution_str_replace_result\"\ntype TextEditorCodeExecutionToolResult string       // Always \"text_editor_code_execution_tool_result\"\ntype TextEditorCodeExecutionToolResultError string  // Always \"text_editor_code_execution_tool_result_error\"\ntype TextEditorCodeExecutionViewResult string       // Always \"text_editor_code_execution_view_result\"\ntype TextPlain string                               // Always \"text/plain\"\ntype Thinking string                                // Always \"thinking\"\ntype ThinkingDelta string                           // Always \"thinking_delta\"\ntype ThinkingTurns string                           // Always \"thinking_turns\"\ntype TimeoutError string                            // Always \"timeout_error\"\ntype Tool string                                    // Always \"tool\"\ntype ToolReference string                           // Always \"tool_reference\"\ntype ToolResult string                              // Always \"tool_result\"\ntype ToolSearchToolBm25 string                      // Always \"tool_search_tool_bm25\"\ntype ToolSearchToolRegex string                     // Always \"tool_search_tool_regex\"\ntype ToolSearchToolResult string                    // Always \"tool_search_tool_result\"\ntype ToolSearchToolResultError string               // Always \"tool_search_tool_result_error\"\ntype ToolSearchToolSearchResult string              // Always \"tool_search_tool_search_result\"\ntype ToolUse string                                 // Always \"tool_use\"\ntype ToolUses string                                // Always \"tool_uses\"\ntype URL string                                     // Always \"url\"\ntype View string                                    // Always \"view\"\ntype WebFetch string                                // Always \"web_fetch\"\ntype WebFetch20250910 string                        // Always \"web_fetch_20250910\"\ntype WebFetch20260209 string                        // Always \"web_fetch_20260209\"\ntype WebFetch20260309 string                        // Always \"web_fetch_20260309\"\ntype WebFetchResult string                          // Always \"web_fetch_result\"\ntype WebFetchToolResult string                      // Always \"web_fetch_tool_result\"\ntype WebFetchToolResultError string                 // Always \"web_fetch_tool_result_error\"\ntype WebSearch string                               // Always \"web_search\"\ntype WebSearch20250305 string                       // Always \"web_search_20250305\"\ntype WebSearch20260209 string                       // Always \"web_search_20260209\"\ntype WebSearchResult string                         // Always \"web_search_result\"\ntype WebSearchResultLocation string                 // Always \"web_search_result_location\"\ntype WebSearchToolResult string                     // Always \"web_search_tool_result\"\ntype WebSearchToolResultError string                // Always \"web_search_tool_result_error\"\n\nfunc (c Adaptive) Default() Adaptive                       { return \"adaptive\" }\nfunc (c All) Default() All                                 { return \"all\" }\nfunc (c Any) Default() Any                                 { return \"any\" }\nfunc (c APIError) Default() APIError                       { return \"api_error\" }\nfunc (c ApplicationPDF) Default() ApplicationPDF           { return \"application/pdf\" }\nfunc (c Approximate) Default() Approximate                 { return \"approximate\" }\nfunc (c Assistant) Default() Assistant                     { return \"assistant\" }\nfunc (c AuthenticationError) Default() AuthenticationError { return \"authentication_error\" }\nfunc (c Auto) Default() Auto                               { return \"auto\" }\nfunc (c Base64) Default() Base64                           { return \"base64\" }\nfunc (c Bash) Default() Bash                               { return \"bash\" }\nfunc (c Bash20241022) Default() Bash20241022               { return \"bash_20241022\" }\nfunc (c Bash20250124) Default() Bash20250124               { return \"bash_20250124\" }\nfunc (c BashCodeExecutionOutput) Default() BashCodeExecutionOutput {\n\treturn \"bash_code_execution_output\"\n}\nfunc (c BashCodeExecutionResult) Default() BashCodeExecutionResult {\n\treturn \"bash_code_execution_result\"\n}\nfunc (c BashCodeExecutionToolResult) Default() BashCodeExecutionToolResult {\n\treturn \"bash_code_execution_tool_result\"\n}\nfunc (c BashCodeExecutionToolResultError) Default() BashCodeExecutionToolResultError {\n\treturn \"bash_code_execution_tool_result_error\"\n}\nfunc (c BillingError) Default() BillingError                   { return \"billing_error\" }\nfunc (c Canceled) Default() Canceled                           { return \"canceled\" }\nfunc (c CharLocation) Default() CharLocation                   { return \"char_location\" }\nfunc (c CitationsDelta) Default() CitationsDelta               { return \"citations_delta\" }\nfunc (c ClearThinking20251015) Default() ClearThinking20251015 { return \"clear_thinking_20251015\" }\nfunc (c ClearToolUses20250919) Default() ClearToolUses20250919 { return \"clear_tool_uses_20250919\" }\nfunc (c CodeExecution) Default() CodeExecution                 { return \"code_execution\" }\nfunc (c CodeExecution20250522) Default() CodeExecution20250522 { return \"code_execution_20250522\" }\nfunc (c CodeExecution20250825) Default() CodeExecution20250825 { return \"code_execution_20250825\" }\nfunc (c CodeExecution20260120) Default() CodeExecution20260120 { return \"code_execution_20260120\" }\nfunc (c CodeExecutionOutput) Default() CodeExecutionOutput     { return \"code_execution_output\" }\nfunc (c CodeExecutionResult) Default() CodeExecutionResult     { return \"code_execution_result\" }\nfunc (c CodeExecutionToolResult) Default() CodeExecutionToolResult {\n\treturn \"code_execution_tool_result\"\n}\nfunc (c CodeExecutionToolResultError) Default() CodeExecutionToolResultError {\n\treturn \"code_execution_tool_result_error\"\n}\nfunc (c Compact20260112) Default() Compact20260112           { return \"compact_20260112\" }\nfunc (c Compaction) Default() Compaction                     { return \"compaction\" }\nfunc (c CompactionDelta) Default() CompactionDelta           { return \"compaction_delta\" }\nfunc (c Completion) Default() Completion                     { return \"completion\" }\nfunc (c Computer) Default() Computer                         { return \"computer\" }\nfunc (c Computer20241022) Default() Computer20241022         { return \"computer_20241022\" }\nfunc (c Computer20250124) Default() Computer20250124         { return \"computer_20250124\" }\nfunc (c Computer20251124) Default() Computer20251124         { return \"computer_20251124\" }\nfunc (c ContainerUpload) Default() ContainerUpload           { return \"container_upload\" }\nfunc (c Content) Default() Content                           { return \"content\" }\nfunc (c ContentBlockDelta) Default() ContentBlockDelta       { return \"content_block_delta\" }\nfunc (c ContentBlockLocation) Default() ContentBlockLocation { return \"content_block_location\" }\nfunc (c ContentBlockStart) Default() ContentBlockStart       { return \"content_block_start\" }\nfunc (c ContentBlockStop) Default() ContentBlockStop         { return \"content_block_stop\" }\nfunc (c Create) Default() Create                             { return \"create\" }\nfunc (c Delete) Default() Delete                             { return \"delete\" }\nfunc (c Direct) Default() Direct                             { return \"direct\" }\nfunc (c Disabled) Default() Disabled                         { return \"disabled\" }\nfunc (c Document) Default() Document                         { return \"document\" }\nfunc (c Enabled) Default() Enabled                           { return \"enabled\" }\nfunc (c EncryptedCodeExecutionResult) Default() EncryptedCodeExecutionResult {\n\treturn \"encrypted_code_execution_result\"\n}\nfunc (c Ephemeral) Default() Ephemeral                       { return \"ephemeral\" }\nfunc (c Error) Default() Error                               { return \"error\" }\nfunc (c Errored) Default() Errored                           { return \"errored\" }\nfunc (c Expired) Default() Expired                           { return \"expired\" }\nfunc (c File) Default() File                                 { return \"file\" }\nfunc (c Image) Default() Image                               { return \"image\" }\nfunc (c InputJSONDelta) Default() InputJSONDelta             { return \"input_json_delta\" }\nfunc (c InputTokens) Default() InputTokens                   { return \"input_tokens\" }\nfunc (c Insert) Default() Insert                             { return \"insert\" }\nfunc (c InvalidRequestError) Default() InvalidRequestError   { return \"invalid_request_error\" }\nfunc (c JSONSchema) Default() JSONSchema                     { return \"json_schema\" }\nfunc (c MCPToolResult) Default() MCPToolResult               { return \"mcp_tool_result\" }\nfunc (c MCPToolUse) Default() MCPToolUse                     { return \"mcp_tool_use\" }\nfunc (c MCPToolset) Default() MCPToolset                     { return \"mcp_toolset\" }\nfunc (c Memory) Default() Memory                             { return \"memory\" }\nfunc (c Memory20250818) Default() Memory20250818             { return \"memory_20250818\" }\nfunc (c Message) Default() Message                           { return \"message\" }\nfunc (c MessageBatch) Default() MessageBatch                 { return \"message_batch\" }\nfunc (c MessageBatchDeleted) Default() MessageBatchDeleted   { return \"message_batch_deleted\" }\nfunc (c MessageDelta) Default() MessageDelta                 { return \"message_delta\" }\nfunc (c MessageStart) Default() MessageStart                 { return \"message_start\" }\nfunc (c MessageStop) Default() MessageStop                   { return \"message_stop\" }\nfunc (c Model) Default() Model                               { return \"model\" }\nfunc (c None) Default() None                                 { return \"none\" }\nfunc (c NotFoundError) Default() NotFoundError               { return \"not_found_error\" }\nfunc (c Object) Default() Object                             { return \"object\" }\nfunc (c OverloadedError) Default() OverloadedError           { return \"overloaded_error\" }\nfunc (c PageLocation) Default() PageLocation                 { return \"page_location\" }\nfunc (c PermissionError) Default() PermissionError           { return \"permission_error\" }\nfunc (c RateLimitError) Default() RateLimitError             { return \"rate_limit_error\" }\nfunc (c RedactedThinking) Default() RedactedThinking         { return \"redacted_thinking\" }\nfunc (c Rename) Default() Rename                             { return \"rename\" }\nfunc (c SearchResult) Default() SearchResult                 { return \"search_result\" }\nfunc (c SearchResultLocation) Default() SearchResultLocation { return \"search_result_location\" }\nfunc (c ServerToolUse) Default() ServerToolUse               { return \"server_tool_use\" }\nfunc (c SignatureDelta) Default() SignatureDelta             { return \"signature_delta\" }\nfunc (c StrReplace) Default() StrReplace                     { return \"str_replace\" }\nfunc (c StrReplaceBasedEditTool) Default() StrReplaceBasedEditTool {\n\treturn \"str_replace_based_edit_tool\"\n}\nfunc (c StrReplaceEditor) Default() StrReplaceEditor     { return \"str_replace_editor\" }\nfunc (c Succeeded) Default() Succeeded                   { return \"succeeded\" }\nfunc (c Text) Default() Text                             { return \"text\" }\nfunc (c TextDelta) Default() TextDelta                   { return \"text_delta\" }\nfunc (c TextEditor20241022) Default() TextEditor20241022 { return \"text_editor_20241022\" }\nfunc (c TextEditor20250124) Default() TextEditor20250124 { return \"text_editor_20250124\" }\nfunc (c TextEditor20250429) Default() TextEditor20250429 { return \"text_editor_20250429\" }\nfunc (c TextEditor20250728) Default() TextEditor20250728 { return \"text_editor_20250728\" }\nfunc (c TextEditorCodeExecutionCreateResult) Default() TextEditorCodeExecutionCreateResult {\n\treturn \"text_editor_code_execution_create_result\"\n}\nfunc (c TextEditorCodeExecutionStrReplaceResult) Default() TextEditorCodeExecutionStrReplaceResult {\n\treturn \"text_editor_code_execution_str_replace_result\"\n}\nfunc (c TextEditorCodeExecutionToolResult) Default() TextEditorCodeExecutionToolResult {\n\treturn \"text_editor_code_execution_tool_result\"\n}\nfunc (c TextEditorCodeExecutionToolResultError) Default() TextEditorCodeExecutionToolResultError {\n\treturn \"text_editor_code_execution_tool_result_error\"\n}\nfunc (c TextEditorCodeExecutionViewResult) Default() TextEditorCodeExecutionViewResult {\n\treturn \"text_editor_code_execution_view_result\"\n}\nfunc (c TextPlain) Default() TextPlain                       { return \"text/plain\" }\nfunc (c Thinking) Default() Thinking                         { return \"thinking\" }\nfunc (c ThinkingDelta) Default() ThinkingDelta               { return \"thinking_delta\" }\nfunc (c ThinkingTurns) Default() ThinkingTurns               { return \"thinking_turns\" }\nfunc (c TimeoutError) Default() TimeoutError                 { return \"timeout_error\" }\nfunc (c Tool) Default() Tool                                 { return \"tool\" }\nfunc (c ToolReference) Default() ToolReference               { return \"tool_reference\" }\nfunc (c ToolResult) Default() ToolResult                     { return \"tool_result\" }\nfunc (c ToolSearchToolBm25) Default() ToolSearchToolBm25     { return \"tool_search_tool_bm25\" }\nfunc (c ToolSearchToolRegex) Default() ToolSearchToolRegex   { return \"tool_search_tool_regex\" }\nfunc (c ToolSearchToolResult) Default() ToolSearchToolResult { return \"tool_search_tool_result\" }\nfunc (c ToolSearchToolResultError) Default() ToolSearchToolResultError {\n\treturn \"tool_search_tool_result_error\"\n}\nfunc (c ToolSearchToolSearchResult) Default() ToolSearchToolSearchResult {\n\treturn \"tool_search_tool_search_result\"\n}\nfunc (c ToolUse) Default() ToolUse                       { return \"tool_use\" }\nfunc (c ToolUses) Default() ToolUses                     { return \"tool_uses\" }\nfunc (c URL) Default() URL                               { return \"url\" }\nfunc (c View) Default() View                             { return \"view\" }\nfunc (c WebFetch) Default() WebFetch                     { return \"web_fetch\" }\nfunc (c WebFetch20250910) Default() WebFetch20250910     { return \"web_fetch_20250910\" }\nfunc (c WebFetch20260209) Default() WebFetch20260209     { return \"web_fetch_20260209\" }\nfunc (c WebFetch20260309) Default() WebFetch20260309     { return \"web_fetch_20260309\" }\nfunc (c WebFetchResult) Default() WebFetchResult         { return \"web_fetch_result\" }\nfunc (c WebFetchToolResult) Default() WebFetchToolResult { return \"web_fetch_tool_result\" }\nfunc (c WebFetchToolResultError) Default() WebFetchToolResultError {\n\treturn \"web_fetch_tool_result_error\"\n}\nfunc (c WebSearch) Default() WebSearch                 { return \"web_search\" }\nfunc (c WebSearch20250305) Default() WebSearch20250305 { return \"web_search_20250305\" }\nfunc (c WebSearch20260209) Default() WebSearch20260209 { return \"web_search_20260209\" }\nfunc (c WebSearchResult) Default() WebSearchResult     { return \"web_search_result\" }\nfunc (c WebSearchResultLocation) Default() WebSearchResultLocation {\n\treturn \"web_search_result_location\"\n}\nfunc (c WebSearchToolResult) Default() WebSearchToolResult { return \"web_search_tool_result\" }\nfunc (c WebSearchToolResultError) Default() WebSearchToolResultError {\n\treturn \"web_search_tool_result_error\"\n}\n\nfunc (c Adaptive) MarshalJSON() ([]byte, error)                            { return marshalString(c) }\nfunc (c All) MarshalJSON() ([]byte, error)                                 { return marshalString(c) }\nfunc (c Any) MarshalJSON() ([]byte, error)                                 { return marshalString(c) }\nfunc (c APIError) MarshalJSON() ([]byte, error)                            { return marshalString(c) }\nfunc (c ApplicationPDF) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c Approximate) MarshalJSON() ([]byte, error)                         { return marshalString(c) }\nfunc (c Assistant) MarshalJSON() ([]byte, error)                           { return marshalString(c) }\nfunc (c AuthenticationError) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c Auto) MarshalJSON() ([]byte, error)                                { return marshalString(c) }\nfunc (c Base64) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c Bash) MarshalJSON() ([]byte, error)                                { return marshalString(c) }\nfunc (c Bash20241022) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c Bash20250124) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c BashCodeExecutionOutput) MarshalJSON() ([]byte, error)             { return marshalString(c) }\nfunc (c BashCodeExecutionResult) MarshalJSON() ([]byte, error)             { return marshalString(c) }\nfunc (c BashCodeExecutionToolResult) MarshalJSON() ([]byte, error)         { return marshalString(c) }\nfunc (c BashCodeExecutionToolResultError) MarshalJSON() ([]byte, error)    { return marshalString(c) }\nfunc (c BillingError) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c Canceled) MarshalJSON() ([]byte, error)                            { return marshalString(c) }\nfunc (c CharLocation) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c CitationsDelta) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c ClearThinking20251015) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c ClearToolUses20250919) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c CodeExecution) MarshalJSON() ([]byte, error)                       { return marshalString(c) }\nfunc (c CodeExecution20250522) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c CodeExecution20250825) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c CodeExecution20260120) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c CodeExecutionOutput) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c CodeExecutionResult) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c CodeExecutionToolResult) MarshalJSON() ([]byte, error)             { return marshalString(c) }\nfunc (c CodeExecutionToolResultError) MarshalJSON() ([]byte, error)        { return marshalString(c) }\nfunc (c Compact20260112) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c Compaction) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c CompactionDelta) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c Completion) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c Computer) MarshalJSON() ([]byte, error)                            { return marshalString(c) }\nfunc (c Computer20241022) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c Computer20250124) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c Computer20251124) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c ContainerUpload) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c Content) MarshalJSON() ([]byte, error)                             { return marshalString(c) }\nfunc (c ContentBlockDelta) MarshalJSON() ([]byte, error)                   { return marshalString(c) }\nfunc (c ContentBlockLocation) MarshalJSON() ([]byte, error)                { return marshalString(c) }\nfunc (c ContentBlockStart) MarshalJSON() ([]byte, error)                   { return marshalString(c) }\nfunc (c ContentBlockStop) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c Create) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c Delete) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c Direct) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c Disabled) MarshalJSON() ([]byte, error)                            { return marshalString(c) }\nfunc (c Document) MarshalJSON() ([]byte, error)                            { return marshalString(c) }\nfunc (c Enabled) MarshalJSON() ([]byte, error)                             { return marshalString(c) }\nfunc (c EncryptedCodeExecutionResult) MarshalJSON() ([]byte, error)        { return marshalString(c) }\nfunc (c Ephemeral) MarshalJSON() ([]byte, error)                           { return marshalString(c) }\nfunc (c Error) MarshalJSON() ([]byte, error)                               { return marshalString(c) }\nfunc (c Errored) MarshalJSON() ([]byte, error)                             { return marshalString(c) }\nfunc (c Expired) MarshalJSON() ([]byte, error)                             { return marshalString(c) }\nfunc (c File) MarshalJSON() ([]byte, error)                                { return marshalString(c) }\nfunc (c Image) MarshalJSON() ([]byte, error)                               { return marshalString(c) }\nfunc (c InputJSONDelta) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c InputTokens) MarshalJSON() ([]byte, error)                         { return marshalString(c) }\nfunc (c Insert) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c InvalidRequestError) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c JSONSchema) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c MCPToolResult) MarshalJSON() ([]byte, error)                       { return marshalString(c) }\nfunc (c MCPToolUse) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c MCPToolset) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c Memory) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c Memory20250818) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c Message) MarshalJSON() ([]byte, error)                             { return marshalString(c) }\nfunc (c MessageBatch) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c MessageBatchDeleted) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c MessageDelta) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c MessageStart) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c MessageStop) MarshalJSON() ([]byte, error)                         { return marshalString(c) }\nfunc (c Model) MarshalJSON() ([]byte, error)                               { return marshalString(c) }\nfunc (c None) MarshalJSON() ([]byte, error)                                { return marshalString(c) }\nfunc (c NotFoundError) MarshalJSON() ([]byte, error)                       { return marshalString(c) }\nfunc (c Object) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c OverloadedError) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c PageLocation) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c PermissionError) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c RateLimitError) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c RedactedThinking) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c Rename) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c SearchResult) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c SearchResultLocation) MarshalJSON() ([]byte, error)                { return marshalString(c) }\nfunc (c ServerToolUse) MarshalJSON() ([]byte, error)                       { return marshalString(c) }\nfunc (c SignatureDelta) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c StrReplace) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c StrReplaceBasedEditTool) MarshalJSON() ([]byte, error)             { return marshalString(c) }\nfunc (c StrReplaceEditor) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c Succeeded) MarshalJSON() ([]byte, error)                           { return marshalString(c) }\nfunc (c Text) MarshalJSON() ([]byte, error)                                { return marshalString(c) }\nfunc (c TextDelta) MarshalJSON() ([]byte, error)                           { return marshalString(c) }\nfunc (c TextEditor20241022) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c TextEditor20250124) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c TextEditor20250429) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c TextEditor20250728) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c TextEditorCodeExecutionCreateResult) MarshalJSON() ([]byte, error) { return marshalString(c) }\nfunc (c TextEditorCodeExecutionStrReplaceResult) MarshalJSON() ([]byte, error) {\n\treturn marshalString(c)\n}\nfunc (c TextEditorCodeExecutionToolResult) MarshalJSON() ([]byte, error) { return marshalString(c) }\nfunc (c TextEditorCodeExecutionToolResultError) MarshalJSON() ([]byte, error) {\n\treturn marshalString(c)\n}\nfunc (c TextEditorCodeExecutionViewResult) MarshalJSON() ([]byte, error) { return marshalString(c) }\nfunc (c TextPlain) MarshalJSON() ([]byte, error)                         { return marshalString(c) }\nfunc (c Thinking) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c ThinkingDelta) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c ThinkingTurns) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c TimeoutError) MarshalJSON() ([]byte, error)                      { return marshalString(c) }\nfunc (c Tool) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c ToolReference) MarshalJSON() ([]byte, error)                     { return marshalString(c) }\nfunc (c ToolResult) MarshalJSON() ([]byte, error)                        { return marshalString(c) }\nfunc (c ToolSearchToolBm25) MarshalJSON() ([]byte, error)                { return marshalString(c) }\nfunc (c ToolSearchToolRegex) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c ToolSearchToolResult) MarshalJSON() ([]byte, error)              { return marshalString(c) }\nfunc (c ToolSearchToolResultError) MarshalJSON() ([]byte, error)         { return marshalString(c) }\nfunc (c ToolSearchToolSearchResult) MarshalJSON() ([]byte, error)        { return marshalString(c) }\nfunc (c ToolUse) MarshalJSON() ([]byte, error)                           { return marshalString(c) }\nfunc (c ToolUses) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c URL) MarshalJSON() ([]byte, error)                               { return marshalString(c) }\nfunc (c View) MarshalJSON() ([]byte, error)                              { return marshalString(c) }\nfunc (c WebFetch) MarshalJSON() ([]byte, error)                          { return marshalString(c) }\nfunc (c WebFetch20250910) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c WebFetch20260209) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c WebFetch20260309) MarshalJSON() ([]byte, error)                  { return marshalString(c) }\nfunc (c WebFetchResult) MarshalJSON() ([]byte, error)                    { return marshalString(c) }\nfunc (c WebFetchToolResult) MarshalJSON() ([]byte, error)                { return marshalString(c) }\nfunc (c WebFetchToolResultError) MarshalJSON() ([]byte, error)           { return marshalString(c) }\nfunc (c WebSearch) MarshalJSON() ([]byte, error)                         { return marshalString(c) }\nfunc (c WebSearch20250305) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c WebSearch20260209) MarshalJSON() ([]byte, error)                 { return marshalString(c) }\nfunc (c WebSearchResult) MarshalJSON() ([]byte, error)                   { return marshalString(c) }\nfunc (c WebSearchResultLocation) MarshalJSON() ([]byte, error)           { return marshalString(c) }\nfunc (c WebSearchToolResult) MarshalJSON() ([]byte, error)               { return marshalString(c) }\nfunc (c WebSearchToolResultError) MarshalJSON() ([]byte, error)          { return marshalString(c) }\n\ntype constant[T any] interface {\n\tConstant[T]\n\t*T\n}\n\nfunc marshalString[T ~string, PT constant[T]](v T) ([]byte, error) {\n\tvar zero T\n\tif v == zero {\n\t\tv = PT(&v).Default()\n\t}\n\treturn shimjson.Marshal(string(v))\n}\n"
  },
  {
    "path": "shared/shared.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage shared\n\nimport (\n\t\"encoding/json\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/apijson\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/param\"\n\t\"github.com/anthropics/anthropic-sdk-go/packages/respjson\"\n\t\"github.com/anthropics/anthropic-sdk-go/shared/constant\"\n)\n\n// aliased to make [param.APIUnion] private when embedding\ntype paramUnion = param.APIUnion\n\n// aliased to make [param.APIObject] private when embedding\ntype paramObj = param.APIObject\n\ntype APIErrorObject struct {\n\tMessage string            `json:\"message\" api:\"required\"`\n\tType    constant.APIError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r APIErrorObject) RawJSON() string { return r.JSON.raw }\nfunc (r *APIErrorObject) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (APIErrorObject) ImplErrorObjectUnion() {}\n\ntype AuthenticationError struct {\n\tMessage string                       `json:\"message\" api:\"required\"`\n\tType    constant.AuthenticationError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r AuthenticationError) RawJSON() string { return r.JSON.raw }\nfunc (r *AuthenticationError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (AuthenticationError) ImplErrorObjectUnion() {}\n\ntype BillingError struct {\n\tMessage string                `json:\"message\" api:\"required\"`\n\tType    constant.BillingError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r BillingError) RawJSON() string { return r.JSON.raw }\nfunc (r *BillingError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (BillingError) ImplErrorObjectUnion() {}\n\n// ErrorObjectUnion contains all possible properties and values from\n// [InvalidRequestError], [AuthenticationError], [BillingError], [PermissionError],\n// [NotFoundError], [RateLimitError], [GatewayTimeoutError], [APIErrorObject],\n// [OverloadedError].\n//\n// Use the [ErrorObjectUnion.AsAny] method to switch on the variant.\n//\n// Use the methods beginning with 'As' to cast the union to one of its variants.\ntype ErrorObjectUnion struct {\n\tMessage string `json:\"message\"`\n\t// Any of \"invalid_request_error\", \"authentication_error\", \"billing_error\",\n\t// \"permission_error\", \"not_found_error\", \"rate_limit_error\", \"timeout_error\",\n\t// \"api_error\", \"overloaded_error\".\n\tType string `json:\"type\"`\n\tJSON struct {\n\t\tMessage respjson.Field\n\t\tType    respjson.Field\n\t\traw     string\n\t} `json:\"-\"`\n}\n\n// anyErrorObject is implemented by each variant of [ErrorObjectUnion] to add type\n// safety for the return type of [ErrorObjectUnion.AsAny]\ntype anyErrorObject interface {\n\tImplErrorObjectUnion()\n}\n\n// Use the following switch statement to find the correct variant\n//\n//\tswitch variant := ErrorObjectUnion.AsAny().(type) {\n//\tcase shared.InvalidRequestError:\n//\tcase shared.AuthenticationError:\n//\tcase shared.BillingError:\n//\tcase shared.PermissionError:\n//\tcase shared.NotFoundError:\n//\tcase shared.RateLimitError:\n//\tcase shared.GatewayTimeoutError:\n//\tcase shared.APIErrorObject:\n//\tcase shared.OverloadedError:\n//\tdefault:\n//\t  fmt.Errorf(\"no variant present\")\n//\t}\nfunc (u ErrorObjectUnion) AsAny() anyErrorObject {\n\tswitch u.Type {\n\tcase \"invalid_request_error\":\n\t\treturn u.AsInvalidRequestError()\n\tcase \"authentication_error\":\n\t\treturn u.AsAuthenticationError()\n\tcase \"billing_error\":\n\t\treturn u.AsBillingError()\n\tcase \"permission_error\":\n\t\treturn u.AsPermissionError()\n\tcase \"not_found_error\":\n\t\treturn u.AsNotFoundError()\n\tcase \"rate_limit_error\":\n\t\treturn u.AsRateLimitError()\n\tcase \"timeout_error\":\n\t\treturn u.AsTimeoutError()\n\tcase \"api_error\":\n\t\treturn u.AsAPIError()\n\tcase \"overloaded_error\":\n\t\treturn u.AsOverloadedError()\n\t}\n\treturn nil\n}\n\nfunc (u ErrorObjectUnion) AsInvalidRequestError() (v InvalidRequestError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsAuthenticationError() (v AuthenticationError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsBillingError() (v BillingError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsPermissionError() (v PermissionError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsNotFoundError() (v NotFoundError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsRateLimitError() (v RateLimitError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsTimeoutError() (v GatewayTimeoutError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsAPIError() (v APIErrorObject) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\nfunc (u ErrorObjectUnion) AsOverloadedError() (v OverloadedError) {\n\tapijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)\n\treturn\n}\n\n// Returns the unmodified JSON received from the API\nfunc (u ErrorObjectUnion) RawJSON() string { return u.JSON.raw }\n\nfunc (r *ErrorObjectUnion) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype ErrorResponse struct {\n\tError     ErrorObjectUnion `json:\"error\" api:\"required\"`\n\tRequestID string           `json:\"request_id\" api:\"required\"`\n\tType      constant.Error   `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tError       respjson.Field\n\t\tRequestID   respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r ErrorResponse) RawJSON() string { return r.JSON.raw }\nfunc (r *ErrorResponse) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\ntype GatewayTimeoutError struct {\n\tMessage string                `json:\"message\" api:\"required\"`\n\tType    constant.TimeoutError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r GatewayTimeoutError) RawJSON() string { return r.JSON.raw }\nfunc (r *GatewayTimeoutError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (GatewayTimeoutError) ImplErrorObjectUnion() {}\n\ntype InvalidRequestError struct {\n\tMessage string                       `json:\"message\" api:\"required\"`\n\tType    constant.InvalidRequestError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r InvalidRequestError) RawJSON() string { return r.JSON.raw }\nfunc (r *InvalidRequestError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (InvalidRequestError) ImplErrorObjectUnion() {}\n\ntype NotFoundError struct {\n\tMessage string                 `json:\"message\" api:\"required\"`\n\tType    constant.NotFoundError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r NotFoundError) RawJSON() string { return r.JSON.raw }\nfunc (r *NotFoundError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (NotFoundError) ImplErrorObjectUnion() {}\n\ntype OverloadedError struct {\n\tMessage string                   `json:\"message\" api:\"required\"`\n\tType    constant.OverloadedError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r OverloadedError) RawJSON() string { return r.JSON.raw }\nfunc (r *OverloadedError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (OverloadedError) ImplErrorObjectUnion() {}\n\ntype PermissionError struct {\n\tMessage string                   `json:\"message\" api:\"required\"`\n\tType    constant.PermissionError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r PermissionError) RawJSON() string { return r.JSON.raw }\nfunc (r *PermissionError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (PermissionError) ImplErrorObjectUnion() {}\n\ntype RateLimitError struct {\n\tMessage string                  `json:\"message\" api:\"required\"`\n\tType    constant.RateLimitError `json:\"type\" api:\"required\"`\n\t// JSON contains metadata for fields, check presence with [respjson.Field.Valid].\n\tJSON struct {\n\t\tMessage     respjson.Field\n\t\tType        respjson.Field\n\t\tExtraFields map[string]respjson.Field\n\t\traw         string\n\t} `json:\"-\"`\n}\n\n// Returns the unmodified JSON received from the API\nfunc (r RateLimitError) RawJSON() string { return r.JSON.raw }\nfunc (r *RateLimitError) UnmarshalJSON(data []byte) error {\n\treturn apijson.UnmarshalRoot(data, r)\n}\n\nfunc (RateLimitError) ImplErrorObjectUnion() {}\n"
  },
  {
    "path": "toolrunner/runner_test.go",
    "content": "package toolrunner_test\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"testing\"\n\t\"time\"\n\n\tanthropic \"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/anthropics/anthropic-sdk-go/toolrunner\"\n)\n\n// schemaToBytes converts a map schema to JSON bytes for use with NewBetaToolFromBytes.\nfunc schemaToBytes(t *testing.T, schema map[string]any) []byte {\n\tt.Helper()\n\tbytes, err := json.Marshal(schema)\n\tif err != nil {\n\t\tt.Fatalf(\"marshal schema: %v\", err)\n\t}\n\treturn bytes\n}\n\n// assistantText extracts concatenated assistant text blocks from a BetaMessage.\nfunc assistantText(msg *anthropic.BetaMessage) string {\n\tvar b strings.Builder\n\tfor _, c := range msg.Content {\n\t\tif tb, ok := c.AsAny().(anthropic.BetaTextBlock); ok {\n\t\t\tb.WriteString(tb.Text)\n\t\t}\n\t}\n\treturn b.String()\n}\n\n// Shared weather tool used by tests\ntype weatherRequest struct {\n\tCity  string `json:\"city\"`\n\tUnits string `json:\"units,omitempty\"`\n}\n\nvar weatherSchema = map[string]any{\n\t\"type\": \"object\",\n\t\"properties\": map[string]any{\n\t\t\"city\":  map[string]any{\"type\": \"string\"},\n\t\t\"units\": map[string]any{\"type\": \"string\", \"enum\": []string{\"celsius\", \"fahrenheit\"}},\n\t},\n\t\"required\": []string{\"city\"},\n}\n\nfunc weatherTool(t *testing.T) anthropic.BetaTool {\n\tt.Helper()\n\ttool, err := toolrunner.NewBetaToolFromBytes(\"get_weather\", \"Get weather\", schemaToBytes(t, weatherSchema),\n\t\tfunc(ctx context.Context, req weatherRequest) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t\ttemp := 20\n\t\t\tif req.Units == \"fahrenheit\" {\n\t\t\t\ttemp = 68\n\t\t\t}\n\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\t\t\tOfText: &anthropic.BetaTextBlockParam{Text: fmt.Sprintf(\"The weather in %s is %d degrees %s.\", req.City, temp, req.Units)},\n\t\t\t}, nil\n\t\t})\n\tif err != nil {\n\t\tt.Fatalf(\"create weather tool: %v\", err)\n\t}\n\treturn tool\n}\n\nfunc newClientWithVCR(t *testing.T, cassette string) anthropic.Client {\n\tt.Helper()\n\thttpClient, _ := testutil.NewVCRHTTPClient(t, cassette)\n\treturn anthropic.NewClient(option.WithHTTPClient(httpClient))\n}\n\n// Test All() end-to-end\n\nfunc TestToolRunner_All_Basic(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_basic\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather in San Francisco? Use fahrenheit.\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tctx := context.Background()\n\tvar last *anthropic.BetaMessage\n\tfor msg, err := range runner.All(ctx) {\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"runner error: %v\", err)\n\t\t}\n\t\tlast = msg\n\t}\n\tif last == nil {\n\t\tt.Fatalf(\"no final message produced\")\n\t}\n\n\t// Extract assistant text content concisely\n\tgot := []byte(assistantText(last) + \"\\n\")\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_basic.golden\", got)\n}\n\nfunc TestToolRunner_RunToCompletion(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_run_to_completion\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather in San Francisco? Use fahrenheit.\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tctx := context.Background()\n\tlast, err := runner.RunToCompletion(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"RunToCompletion: %v\", err)\n\t}\n\n\t// Extract assistant text content concisely\n\tgot := []byte(assistantText(last) + \"\\n\")\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_run_to_completion.golden\", got)\n}\n\n// Test NextMessage step-wise, ensuring an intermediate tool_result is appended, then final answer\n\nfunc TestToolRunner_NextMessage_Step(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_next_message\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather in SF? Use celsius.\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tctx := context.Background()\n\t// Turn 1: expect tool_use\n\tmsg, err := runner.NextMessage(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"NextMessage 1: %v\", err)\n\t}\n\tif msg == nil {\n\t\tt.Fatalf(\"expected first message\")\n\t}\n\n\tgot := []byte(assistantText(msg) + \"\\n\")\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_next_message_step_1.golden\", got)\n\t// Turn 2: tool results sent, expect final assistant\n\tmsg, err = runner.NextMessage(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"NextMessage 2: %v\", err)\n\t}\n\tif msg == nil {\n\t\tt.Fatalf(\"expected final message\")\n\t}\n\n\tgot = []byte(assistantText(msg) + \"\\n\")\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_next_message_step_2.golden\", got)\n}\n\n// Test AllStreaming end-to-end collects final text and compares\n\nfunc TestToolRunner_AllStreaming(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_streaming_all\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunnerStreaming([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"Weather in SF in fahrenheit?\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tctx := context.Background()\n\tassistantMessages := []string{}\n\tfor iterator, err := range runner.AllStreaming(ctx) {\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"stream err: %v\", err)\n\t\t}\n\t\tstringBuilder := strings.Builder{}\n\t\tfor ev := range iterator {\n\t\t\tswitch evVariant := ev.AsAny().(type) {\n\t\t\tcase anthropic.BetaRawContentBlockDeltaEvent:\n\t\t\t\tswitch deltaVariant := evVariant.Delta.AsAny().(type) {\n\t\t\t\tcase anthropic.BetaTextDelta:\n\t\t\t\t\tstringBuilder.WriteString(deltaVariant.Text)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tassistantMessages = append(assistantMessages, stringBuilder.String())\n\t}\n\n\tgot := []byte(strings.Join(assistantMessages, \"\\n\"))\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_streaming_all.golden\", got)\n}\n\n// Test NextStreaming for a single turn; verify event types set is stable\n\nfunc TestToolRunner_NextStreaming_EventTypes(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_next_streaming\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunnerStreaming([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"Weather in SF?\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 1,\n\t})\n\n\tctx := context.Background()\n\tevents := runner.NextStreaming(ctx)\n\n\teventsTypes := []string{}\n\tfor ev := range events {\n\t\teventsTypes = append(eventsTypes, ev.Type)\n\t}\n\n\tsort.Strings(eventsTypes)\n\n\tgot := []byte(strings.Join(eventsTypes, \"\\n\") + \"\\n\")\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_next_streaming_types.golden\", got)\n}\n\n// Test that tool error is surfaced as a tool_result with is_error and the flow completes\n\nfunc TestToolRunner_ToolCallError_ThenSuccess(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_tool_call_error\")\n\tcalled := false\n\ttool, err := toolrunner.NewBetaToolFromBytes(\"get_weather\", \"Get weather\", schemaToBytes(t, weatherSchema),\n\t\tfunc(ctx context.Context, req weatherRequest) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t\tif !called {\n\t\t\t\tcalled = true\n\t\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{}, fmt.Errorf(\"Unexpected error, try again\")\n\t\t\t}\n\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{OfText: &anthropic.BetaTextBlockParam{Text: \"Sunny 68°F\"}}, nil\n\t\t})\n\tif err != nil {\n\t\tt.Fatalf(\"create tool: %v\", err)\n\t}\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"Weather in San Francisco?\")),\n\t\t\t},\n\t\t},\n\t})\n\n\tctx := context.Background()\n\tmsg, err := runner.RunToCompletion(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"RunToCompletion: %v\", err)\n\t}\n\n\tmessages := runner.Messages()\n\tif len(messages) == 0 {\n\t\tt.Fatalf(\"expected messages in runner\")\n\t}\n\n\t// look through all the messages to find the tool results\n\t// 1. should be an error\n\t// 2. should be a success\n\ttoolResultBlocks := []*anthropic.BetaToolResultBlockParam{}\n\tfor _, msg := range messages {\n\t\tfor _, c := range msg.Content {\n\t\t\tif tr := c.OfToolResult; tr != nil {\n\t\t\t\ttoolResultBlocks = append(toolResultBlocks, tr)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(toolResultBlocks) != 2 {\n\t\tt.Fatalf(\"expected 2 tool result blocks, got %d\", len(toolResultBlocks))\n\t}\n\n\terrorToolResultBlock := toolResultBlocks[0]\n\tif !errorToolResultBlock.IsError.Value {\n\t\tt.Fatalf(\"expected first tool result to be an error\")\n\t}\n\terrorText := errorToolResultBlock.Content[0].OfText.Text\n\tif !strings.Contains(errorText, \"Unexpected error\") {\n\t\tt.Fatalf(\"expected error message in tool result, got: %s\", errorText)\n\t}\n\n\tsuccessToolResultBlock := toolResultBlocks[1]\n\tif successToolResultBlock.IsError.Value {\n\t\tt.Fatalf(\"expected second tool result to be a success\")\n\t}\n\tsuccessText := successToolResultBlock.Content[0].OfText.Text\n\tif successText != \"Sunny 68°F\" {\n\t\tt.Fatalf(\"expected success message in tool result, got: %s\", successText)\n\t}\n\n\t// Final assistant golden snapshot and iteration count\n\ttestutil.CompareGolden(t, \"testdata/snapshots/tool_runner_tool_call_error_assistant.golden\", []byte(assistantText(msg)+\"\\n\"))\n\tif runner.IterationCount() != 3 {\n\t\tt.Fatalf(\"expected 3 iterations, got %d\", runner.IterationCount())\n\t}\n}\n\n// Test custom handling: intercept tool_use, push our own tool_result, and disable tools for next turn\n\nfunc TestToolRunner_CustomHandlingWithPushMessages(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_custom_handling\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather in SF in celsius?\")),\n\t\t\t},\n\t\t},\n\t})\n\n\tctx := context.Background()\n\t// First assistant message with tool_use\n\tmsg, err := runner.NextMessage(ctx)\n\tif err != nil || msg == nil {\n\t\tt.Fatalf(\"turn 1: %v %v\", msg, err)\n\t}\n\t// Find first tool_use id\n\tvar toolUseID string\n\tfor _, c := range msg.Content {\n\t\tif tu, ok := c.AsAny().(anthropic.BetaToolUseBlock); ok {\n\t\t\ttoolUseID = tu.ID\n\t\t\tbreak\n\t\t}\n\t}\n\tif toolUseID == \"\" {\n\t\tt.Fatalf(\"expected a tool_use block\")\n\t}\n\t// Build a new runner with our custom tool_result appended to messages to avoid\n\t// automatic execution for the prior assistant tool_use turn.\n\tmsgs := runner.Messages()\n\tmsgs = append(msgs, anthropic.NewBetaUserMessage(\n\t\tanthropic.BetaContentBlockParamUnion{OfToolResult: &anthropic.BetaToolResultBlockParam{ToolUseID: toolUseID, Content: []anthropic.BetaToolResultBlockParamContentUnion{{OfText: &anthropic.BetaTextBlockParam{Text: \"Celsius 20°C\"}}}}},\n\t))\n\n\t// No tools so the next turn is just the assistant producing final text\n\trunner2 := client.Beta.Messages.NewToolRunner(nil, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages:  msgs,\n\t\t},\n\t})\n\n\t// Next turn should finalize with assistant text\n\tmsg, err = runner2.NextMessage(ctx)\n\tif err != nil || msg == nil {\n\t\tt.Fatalf(\"turn 2: %v %v\", msg, err)\n\t}\n}\n\n// Test max iterations stops further calls\n\nfunc TestToolRunner_MaxIterations(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_max_iterations\")\n\ttool := weatherTool(t)\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{tool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"Check weather in SF and NY, step by step\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 2,\n\t})\n\n\tctx := context.Background()\n\tfor {\n\t\tmsg, err := runner.NextMessage(ctx)\n\t\tif msg == nil {\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"runner error: %v\", err)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tif got := runner.IterationCount(); got != 2 {\n\t\tt.Fatalf(\"expected 2 iterations, got %d\", got)\n\t}\n}\n\n// Test concurrent tool execution (multiple tools in one message)\n\nfunc TestToolRunner_ConcurrentToolExecution(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_concurrent\")\n\n\t// Track execution with timing to verify concurrency\n\tvar callCount atomic.Int32\n\tvar executionTimes sync.Map\n\tstartTime := time.Now()\n\n\tweatherTool, err := toolrunner.NewBetaToolFromBytes(\"get_weather\", \"Get weather for a city\", schemaToBytes(t, weatherSchema),\n\t\tfunc(ctx context.Context, req weatherRequest) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t\texecutionTimes.Store(req.City, time.Since(startTime))\n\t\t\tcallCount.Add(1)\n\t\t\t// Small delay - if sequential this would take 3x longer\n\t\t\ttime.Sleep(50 * time.Millisecond)\n\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\t\t\tOfText: &anthropic.BetaTextBlockParam{Text: fmt.Sprintf(\"Weather in %s: Sunny 72°F\", req.City)},\n\t\t\t}, nil\n\t\t})\n\tif err != nil {\n\t\tt.Fatalf(\"create weather tool: %v\", err)\n\t}\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{weatherTool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\n\t\t\t\t\t\"What's the weather in San Francisco, New York, and London? Check all three cities at once.\",\n\t\t\t\t)),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tctx := context.Background()\n\t_, err = runner.RunToCompletion(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"RunToCompletion: %v\", err)\n\t}\n\n\t// Verify multiple tools were called\n\tcount := callCount.Load()\n\tif count < 2 {\n\t\tt.Fatalf(\"expected at least 2 concurrent tool calls, got %d\", count)\n\t}\n\n\t// Verify tool results are in the messages\n\tmessages := runner.Messages()\n\ttoolResultCount := 0\n\tfor _, msg := range messages {\n\t\tfor _, c := range msg.Content {\n\t\t\tif c.OfToolResult != nil {\n\t\t\t\ttoolResultCount++\n\t\t\t}\n\t\t}\n\t}\n\tif toolResultCount < 2 {\n\t\tt.Fatalf(\"expected at least 2 tool results, got %d\", toolResultCount)\n\t}\n}\n\n// Test context cancellation during tool execution\n\nfunc TestToolRunner_ContextCancellation(t *testing.T) {\n\tt.Parallel()\n\tclient := newClientWithVCR(t, \"tool_runner_context_cancel\")\n\n\ttoolStarted := make(chan struct{})\n\ttoolCompleted := make(chan struct{})\n\n\tslowSchema := map[string]any{\n\t\t\"type\":       \"object\",\n\t\t\"properties\": map[string]any{\"input\": map[string]any{\"type\": \"string\"}},\n\t}\n\tslowTool, err := toolrunner.NewBetaToolFromBytes(\"slow_tool\", \"A slow tool\", schemaToBytes(t, slowSchema),\n\t\tfunc(ctx context.Context, req struct{ Input string }) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t\tclose(toolStarted)\n\t\t\t// Wait for context cancellation or timeout\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{}, ctx.Err()\n\t\t\tcase <-time.After(5 * time.Second):\n\t\t\t\tclose(toolCompleted)\n\t\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\t\t\t\tOfText: &anthropic.BetaTextBlockParam{Text: \"completed\"},\n\t\t\t\t}, nil\n\t\t\t}\n\t\t})\n\tif err != nil {\n\t\tt.Fatalf(\"create slow tool: %v\", err)\n\t}\n\n\trunner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{slowTool}, anthropic.BetaToolRunnerParams{\n\t\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\t\tModel:     anthropic.ModelClaudeSonnet4_5,\n\t\t\tMaxTokens: 512,\n\t\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"Call the slow_tool with input 'test'\")),\n\t\t\t},\n\t\t},\n\t\tMaxIterations: 5,\n\t})\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\t// Start the runner in a goroutine\n\tdone := make(chan struct{})\n\tgo func() {\n\t\tdefer close(done)\n\t\trunner.RunToCompletion(ctx)\n\t}()\n\n\t// Wait for tool to start, then cancel\n\tselect {\n\tcase <-toolStarted:\n\t\tcancel()\n\tcase <-time.After(10 * time.Second):\n\t\tt.Fatal(\"tool never started\")\n\t}\n\n\t// Verify runner completes quickly after cancellation (not waiting 5 seconds)\n\tselect {\n\tcase <-done:\n\t\t// Good - runner completed\n\tcase <-toolCompleted:\n\t\tt.Fatal(\"tool completed without cancellation being respected\")\n\tcase <-time.After(2 * time.Second):\n\t\tt.Fatal(\"runner did not complete promptly after cancellation\")\n\t}\n}\n\n// Test malformed JSON input error handling through Execute\n\nfunc TestToolRunner_MalformedJSONInput(t *testing.T) {\n\tt.Parallel()\n\n\ttype StrictInput struct {\n\t\tRequiredField string `json:\"required_field\"`\n\t\tNumberField   int    `json:\"number_field\"`\n\t}\n\n\tstrictSchema := map[string]any{\n\t\t\"type\": \"object\",\n\t\t\"properties\": map[string]any{\n\t\t\t\"required_field\": map[string]any{\"type\": \"string\"},\n\t\t\t\"number_field\":   map[string]any{\"type\": \"integer\"},\n\t\t},\n\t\t\"required\": []string{\"required_field\"},\n\t}\n\ttool, err := toolrunner.NewBetaToolFromBytes(\"strict_tool\", \"A tool with strict input\", schemaToBytes(t, strictSchema),\n\t\tfunc(ctx context.Context, input StrictInput) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\t\t\tOfText: &anthropic.BetaTextBlockParam{Text: \"success\"},\n\t\t\t}, nil\n\t\t})\n\tif err != nil {\n\t\tt.Fatalf(\"create tool: %v\", err)\n\t}\n\n\t// Test Execute with valid JSON\n\tvalidJSON := json.RawMessage(`{\"required_field\": \"test\", \"number_field\": 42}`)\n\tresult, err := tool.Execute(context.Background(), validJSON)\n\tif err != nil {\n\t\tt.Fatalf(\"Execute valid JSON failed: %v\", err)\n\t}\n\tif result.OfText == nil || result.OfText.Text != \"success\" {\n\t\tt.Fatalf(\"Execute returned unexpected result: %+v\", result)\n\t}\n\n\t// Test Execute with malformed JSON (invalid syntax)\n\tmalformedJSON := json.RawMessage(`{\"required_field\": \"test\", \"number_field\": }`)\n\t_, err = tool.Execute(context.Background(), malformedJSON)\n\tif err == nil {\n\t\tt.Fatal(\"expected error for malformed JSON, got nil\")\n\t}\n\n\t// Test Execute with type mismatch (string instead of int)\n\ttypeMismatchJSON := json.RawMessage(`{\"required_field\": \"test\", \"number_field\": \"not a number\"}`)\n\t_, err = tool.Execute(context.Background(), typeMismatchJSON)\n\tif err == nil {\n\t\tt.Fatal(\"expected error for type mismatch, got nil\")\n\t}\n\n\t// Test Execute with invalid JSON propagates error\n\tinvalidJSON := json.RawMessage(`{invalid json}`)\n\t_, err = tool.Execute(context.Background(), invalidJSON)\n\tif err == nil {\n\t\tt.Fatal(\"expected error for invalid JSON in Execute\")\n\t}\n}\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_basic.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco? Use fahrenheit.\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01VLZuPg94y7NULJySZhEDJY\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''ll\n      get the current weather in San Francisco for you in Fahrenheit.\"},{\"type\":\"tool_use\",\"id\":\"toolu_01TZR6ZrLHdpAWdmhVPuDfjQ\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"fahrenheit\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":402,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":89,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3997\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe5f5e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeEZVNjY7M6qwNV9k6\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1371\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco? Use fahrenheit.\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      get the current weather in San Francisco for you in Fahrenheit.\",\"type\":\"text\"},{\"id\":\"toolu_01TZR6ZrLHdpAWdmhVPuDfjQ\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"fahrenheit\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01TZR6ZrLHdpAWdmhVPuDfjQ\",\"content\":[{\"text\":\"The\n      weather in San Francisco is 68 degrees fahrenheit.\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_014SddXAzPYwR72fa37nJ8N2\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"The\n      current temperature in San Francisco is 68 degrees Fahrenheit.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":514,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":19,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3998\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c394fc8465e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:38 GMT\n      Request-Id:\n      - req_011CUdgeLbdAHJifhfifciof\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"711\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_concurrent.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco, New York, and London? Check all three cities at once.\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather for a city\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.19.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.19.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.25.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01GhukHZbus69MS8zCp3tqTa\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''d\n      be happy to check the weather for San Francisco, New York, and London for you.\n      I''ll need to look up each city individually.\"},{\"type\":\"tool_use\",\"id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":414,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":85,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 4b663dca-f14e-490d-9965-801817fd453d\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"39000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2026-01-23T07:42:01Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2026-01-23T07:42:02Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"1000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"998\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2026-01-23T07:42:00Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"55000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2026-01-23T07:42:01Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 9c25a6e2df5aa143-LAX\n      Content-Type:\n      - application/json\n      Date:\n      - Fri, 23 Jan 2026 07:42:01 GMT\n      Request-Id:\n      - req_011CXPw5fUs1tb4koxa1VUac\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1637\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco, New York, and London? Check all three cities at once.\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''d\n      be happy to check the weather for San Francisco, New York, and London for you.\n      I''ll need to look up each city individually.\",\"type\":\"text\"},{\"id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"content\":[{\"text\":\"Weather\n      in San Francisco: Sunny 72°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather for a city\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.19.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.19.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.25.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_0146jGKLKCa86wwR9aHbrEfe\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"tool_use\",\"id\":\"toolu_015Sh8xNQBhJJnBCLz8x9F6f\",\"name\":\"get_weather\",\"input\":{\"city\":\"New\n      York\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":521,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":55,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 4b663dca-f14e-490d-9965-801817fd453d\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2026-01-23T07:42:02Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2026-01-23T07:42:03Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"1000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2026-01-23T07:42:02Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2026-01-23T07:42:02Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 9c25a6edf8f7a143-LAX\n      Content-Type:\n      - application/json\n      Date:\n      - Fri, 23 Jan 2026 07:42:02 GMT\n      Request-Id:\n      - req_011CXPw5o5mF8wtv3QiE2tkd\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1008\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco, New York, and London? Check all three cities at once.\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''d\n      be happy to check the weather for San Francisco, New York, and London for you.\n      I''ll need to look up each city individually.\",\"type\":\"text\"},{\"id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"content\":[{\"text\":\"Weather\n      in San Francisco: Sunny 72°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"},{\"content\":[{\"id\":\"toolu_015Sh8xNQBhJJnBCLz8x9F6f\",\"input\":{\"city\":\"New\n      York\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_015Sh8xNQBhJJnBCLz8x9F6f\",\"content\":[{\"text\":\"Weather\n      in New York: Sunny 72°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather for a city\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.19.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.19.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.25.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_018RyYEDtaKf3WyN2AVY7DVZ\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"tool_use\",\"id\":\"toolu_019FKPTDNUQxrGzdjFtpP9Yp\",\"name\":\"get_weather\",\"input\":{\"city\":\"London\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":598,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":54,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 4b663dca-f14e-490d-9965-801817fd453d\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2026-01-23T07:42:04Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2026-01-23T07:42:04Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"1000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2026-01-23T07:42:03Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2026-01-23T07:42:04Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 9c25a6f52a45a143-LAX\n      Content-Type:\n      - application/json\n      Date:\n      - Fri, 23 Jan 2026 07:42:04 GMT\n      Request-Id:\n      - req_011CXPw5t2fvWR46n9QUQ9Qm\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"945\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco, New York, and London? Check all three cities at once.\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''d\n      be happy to check the weather for San Francisco, New York, and London for you.\n      I''ll need to look up each city individually.\",\"type\":\"text\"},{\"id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_019dfQh1VSo4ykF3MUFvGpMg\",\"content\":[{\"text\":\"Weather\n      in San Francisco: Sunny 72°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"},{\"content\":[{\"id\":\"toolu_015Sh8xNQBhJJnBCLz8x9F6f\",\"input\":{\"city\":\"New\n      York\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_015Sh8xNQBhJJnBCLz8x9F6f\",\"content\":[{\"text\":\"Weather\n      in New York: Sunny 72°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"},{\"content\":[{\"id\":\"toolu_019FKPTDNUQxrGzdjFtpP9Yp\",\"input\":{\"city\":\"London\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_019FKPTDNUQxrGzdjFtpP9Yp\",\"content\":[{\"text\":\"Weather\n      in London: Sunny 72°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather for a city\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.19.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.19.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.25.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01U2itU4GfWtWJXqw43f4XB1\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"Here''s\n      the current weather for all three cities:\\n\\n- San Francisco: Sunny 72°F\\n-\n      New York: Sunny 72°F\\n- London: Sunny 72°F\\n\\nWould you like me to check any\n      other cities or get the weather in Celsius instead?\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":673,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":65,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 4b663dca-f14e-490d-9965-801817fd453d\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2026-01-23T07:42:05Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2026-01-23T07:42:05Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"1000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2026-01-23T07:42:04Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2026-01-23T07:42:05Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 9c25a6fbfae2a143-LAX\n      Content-Type:\n      - application/json\n      Date:\n      - Fri, 23 Jan 2026 07:42:05 GMT\n      Request-Id:\n      - req_011CXPw5xhTv4tqQceCdq8iZ\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1320\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_context_cancel.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Call the slow_tool with\n      input ''test''\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"input\":{\"type\":\"string\"}},\"type\":\"object\"},\"name\":\"slow_tool\",\"description\":\"A\n      slow tool\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.19.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.19.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.25.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_0142PtqubSsNMQyL4EiyyEs6\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I\n      can help you call the slow_tool with the input ''test''. I''ll use the function\n      call now:\"},{\"type\":\"tool_use\",\"id\":\"toolu_01CbQoxtE6Qg5V9pW5SX66i5\",\"name\":\"slow_tool\",\"input\":{\"input\":\"test\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":376,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":78,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 4b663dca-f14e-490d-9965-801817fd453d\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"40000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2026-01-23T07:42:01Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"16000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2026-01-23T07:42:01Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"1000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2026-01-23T07:42:00Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"56000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2026-01-23T07:42:01Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 9c25a6e2df5ca143-LAX\n      Content-Type:\n      - application/json\n      Date:\n      - Fri, 23 Jan 2026 07:42:01 GMT\n      Request-Id:\n      - req_011CXPw5fUcysxR74k3PTTtN\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1425\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_custom_handling.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in SF in celsius?\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01SKjgb16h4feir85VSwDQY3\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''ll\n      check the current weather in San Francisco for you in Celsius.\"},{\"type\":\"tool_use\",\"id\":\"toolu_01RemJnygsv2MuzBdGC1Amou\",\"name\":\"get_weather\",\"input\":{\"city\":\"SF\",\"units\":\"celsius\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":399,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":86,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3995\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe625e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeEayGXg3uus6w2iF3\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1330\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in SF in celsius?\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      check the current weather in San Francisco for you in Celsius.\",\"type\":\"text\"},{\"id\":\"toolu_01RemJnygsv2MuzBdGC1Amou\",\"input\":{\"city\":\"SF\",\"units\":\"celsius\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01RemJnygsv2MuzBdGC1Amou\",\"content\":[{\"text\":\"Celsius\n      20°C\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01AotAbnCJmEFVVkkw6rNfXP\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"It''s\n      currently 20°C in San Francisco.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":119,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":15,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c394f88085e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:38 GMT\n      Request-Id:\n      - req_011CUdgeLTSmFd3yzdcPJc5d\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"788\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_max_iterations.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Check weather in SF\n      and NY, step by step\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01Q2mACVzNZQUHB5En8kt88w\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''ll\n      check the weather in San Francisco and New York step by step.\\n\\nFirst, let\n      me check the weather in San Francisco:\"},{\"type\":\"tool_use\",\"id\":\"toolu_01CHZ5yWb5v7HP4EavruQtj8\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":400,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":82,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3994\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe5e5e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeEaEDRiyx96pje4xj\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1748\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Check weather in SF\n      and NY, step by step\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      check the weather in San Francisco and New York step by step.\\n\\nFirst, let\n      me check the weather in San Francisco:\",\"type\":\"text\"},{\"id\":\"toolu_01CHZ5yWb5v7HP4EavruQtj8\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01CHZ5yWb5v7HP4EavruQtj8\",\"content\":[{\"text\":\"The\n      weather in San Francisco is 20 degrees .\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01TF3a1zCD17o4pQHPZXJsdS\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"Now,\n      let me check the weather in New York:\"},{\"type\":\"tool_use\",\"id\":\"toolu_01FS9cCtrd1NyGHq5aHiBYTQ\",\"name\":\"get_weather\",\"input\":{\"city\":\"New\n      York\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":504,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":67,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:39Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c39523b215e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:39 GMT\n      Request-Id:\n      - req_011CUdgeNJpSrFv7D5t4RV3m\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1943\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_next_message.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in SF? Use celsius.\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01AMULp5HCeVjmUHkfitquk5\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''ll\n      check the weather in San Francisco for you using Celsius units.\"},{\"type\":\"tool_use\",\"id\":\"toolu_01Na4b3cjX4XZw88mccd5HyP\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"celsius\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":400,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":87,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3995\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe555e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeEZUym6SoQVcZV75Q\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1517\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in SF? Use celsius.\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      check the weather in San Francisco for you using Celsius units.\",\"type\":\"text\"},{\"id\":\"toolu_01Na4b3cjX4XZw88mccd5HyP\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"celsius\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01Na4b3cjX4XZw88mccd5HyP\",\"content\":[{\"text\":\"The\n      weather in San Francisco is 20 degrees celsius.\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01Y2wUmtAZCFJ2zbfZ37NZui\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"The\n      current weather in San Francisco is 20 degrees Celsius.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":509,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":18,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3950b9785e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:38 GMT\n      Request-Id:\n      - req_011CUdgeMDLV8cZ2aqH8bTW3\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1050\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_next_streaming.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Weather in SF?\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}],\"stream\":true}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: |+\n      event: message_start\n      data: {\"type\":\"message_start\",\"message\":{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01P7nF1bmxyzFZjF8zwbUDBM\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":394,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":1,\"service_tier\":\"standard\"}}       }\n\n      event: content_block_start\n      data: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"} }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"I\"}      }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"'\"}        }\n\n      event: ping\n      data: {\"type\": \"ping\"}\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"d be\"}               }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" happy to check\"}      }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" the weather\"}              }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" in\"}  }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" San Francisco for you.\"}}\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" Let\"}       }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" me get\"}  }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" that\"}}\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" information for you right\"}    }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" away\"} }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\".\"}     }\n\n      event: content_block_stop\n      data: {\"type\":\"content_block_stop\",\"index\":0               }\n\n      event: content_block_start\n      data: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"tool_use\",\"id\":\"toolu_017QoD96fYwGzCWvLfaPADWg\",\"name\":\"get_weather\",\"input\":{}}   }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"\"} }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"city\\\": \\\"Sa\"}  }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"n Francis\"}   }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"co\\\"}\"}         }\n\n      event: content_block_stop\n      data: {\"type\":\"content_block_stop\",\"index\":1     }\n\n      event: message_delta\n      data: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":394,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":79} }\n\n      event: message_stop\n      data: {\"type\":\"message_stop\"       }\n\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cache-Control:\n      - no-cache\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe585e6a-EWR\n      Content-Type:\n      - text/event-stream; charset=utf-8\n      Date:\n      - Thu, 30 Oct 2025 16:17:36 GMT\n      Request-Id:\n      - req_011CUdgeEggCMUt3Y8mNfvTP\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1133\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_run_to_completion.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco? Use fahrenheit.\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_018ot5fJ8BmAG1WxW5B7WkJX\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''ll\n      get the current weather in San Francisco for you using Fahrenheit units.\"},{\"type\":\"tool_use\",\"id\":\"toolu_01RspNj5YbBdaKwpEEcKirBJ\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"fahrenheit\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":402,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":90,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3998\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe5d5e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeEZV6311MCdLraHEj\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1535\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"What''s the weather\n      in San Francisco? Use fahrenheit.\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      get the current weather in San Francisco for you using Fahrenheit units.\",\"type\":\"text\"},{\"id\":\"toolu_01RspNj5YbBdaKwpEEcKirBJ\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"fahrenheit\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01RspNj5YbBdaKwpEEcKirBJ\",\"content\":[{\"text\":\"The\n      weather in San Francisco is 68 degrees fahrenheit.\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01D2irNnbwPJPt2d5D6B4ovq\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"The\n      weather in San Francisco is currently 68 degrees Fahrenheit.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":515,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":19,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3950d98c5e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:38 GMT\n      Request-Id:\n      - req_011CUdgeMJ3okUzCzuFRSRcg\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"588\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_streaming_all.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Weather in SF in fahrenheit?\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}],\"stream\":true}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: |+\n      event: message_start\n      data: {\"type\":\"message_start\",\"message\":{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01H1pwRRkQxKbUGKi785gT4M\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":397,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":2,\"service_tier\":\"standard\"}}      }\n\n      event: content_block_start\n      data: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}              }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"I'll\"}    }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" get\"}   }\n\n      event: ping\n      data: {\"type\": \"ping\"}\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" the current weather in\"}        }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" San Francisco for you in\"}      }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" Fahrenheit.\"}      }\n\n      event: content_block_stop\n      data: {\"type\":\"content_block_stop\",\"index\":0}\n\n      event: content_block_start\n      data: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"tool_use\",\"id\":\"toolu_01RaX2WYWRWCbaeFHssmGJXG\",\"name\":\"get_weather\",\"input\":{}}             }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"\"}               }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"city\"}        }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"\\\": \\\"S\"}              }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"an F\"}  }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"ra\"}               }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"ncisco\"}          }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"\\\"\"}}\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\", \\\"units\\\"\"}           }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\": \\\"fahr\"}              }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"enhei\"}   }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"t\\\"}\"}          }\n\n      event: content_block_stop\n      data: {\"type\":\"content_block_stop\",\"index\":1         }\n\n      event: message_delta\n      data: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":397,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":89}           }\n\n      event: message_stop\n      data: {\"type\":\"message_stop\"  }\n\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3996\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Cache-Control:\n      - no-cache\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe5c5e6a-EWR\n      Content-Type:\n      - text/event-stream; charset=utf-8\n      Date:\n      - Thu, 30 Oct 2025 16:17:36 GMT\n      Request-Id:\n      - req_011CUdgeEaEXcfa9PDdxrNMk\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"344\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Weather in SF in fahrenheit?\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      get the current weather in San Francisco for you in Fahrenheit.\",\"type\":\"text\"},{\"id\":\"toolu_01RaX2WYWRWCbaeFHssmGJXG\",\"input\":{\"city\":\"San\n      Francisco\",\"units\":\"fahrenheit\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01RaX2WYWRWCbaeFHssmGJXG\",\"content\":[{\"text\":\"The\n      weather in San Francisco is 68 degrees fahrenheit.\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}],\"stream\":true}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: |+\n      event: message_start\n      data: {\"type\":\"message_start\",\"message\":{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01Hh7yjeiaEaEREnpywjByCo\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":509,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":2,\"service_tier\":\"standard\"}}   }\n\n      event: content_block_start\n      data: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}       }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"The\"}  }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" current weather\"}  }\n\n      event: ping\n      data: {\"type\": \"ping\"}\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" in San Francisco is \"}  }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"68 degrees Fahren\"}        }\n\n      event: content_block_delta\n      data: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"heit.\"}     }\n\n      event: content_block_stop\n      data: {\"type\":\"content_block_stop\",\"index\":0     }\n\n      event: message_delta\n      data: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":509,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":19}        }\n\n      event: message_stop\n      data: {\"type\":\"message_stop\"       }\n\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Cache-Control:\n      - no-cache\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c394fc8455e6a-EWR\n      Content-Type:\n      - text/event-stream; charset=utf-8\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeLebtjP3oqrQZ6wp1\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"409\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/cassettes/tool_runner_tool_call_error.yaml",
    "content": "---\nversion: 1\ninteractions:\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Weather in San Francisco?\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_014tfMBTf8yzH6aC9ohZ94k3\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I''ll\n      check the current weather in San Francisco for you.\"},{\"type\":\"tool_use\",\"id\":\"toolu_01XKSJ1fM9PHM9vpwH1p7PDT\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":395,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":67,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:35Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:36Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c3946fe615e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:37 GMT\n      Request-Id:\n      - req_011CUdgeEYzbWH4BW7aH5Dbx\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1378\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Weather in San Francisco?\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      check the current weather in San Francisco for you.\",\"type\":\"text\"},{\"id\":\"toolu_01XKSJ1fM9PHM9vpwH1p7PDT\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01XKSJ1fM9PHM9vpwH1p7PDT\",\"is_error\":true,\"content\":[{\"text\":\"Error:\n      Unexpected error, try again\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01WkcabYzR3oCnHMEPgBcSAa\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"I\n      apologize for the error. Let me try checking the weather in San Francisco again.\"},{\"type\":\"tool_use\",\"id\":\"toolu_01LELQc5n8mDyvS1bApN4qPi\",\"name\":\"get_weather\",\"input\":{\"city\":\"San\n      Francisco\"}}],\"stop_reason\":\"tool_use\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":489,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":74,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"199000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3998\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"279000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:37Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c394fd8575e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:38 GMT\n      Request-Id:\n      - req_011CUdgeLfMAoXNWKXy99k2B\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"1260\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n- request:\n    body: '{\"max_tokens\":512,\"messages\":[{\"content\":[{\"text\":\"Weather in San Francisco?\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I''ll\n      check the current weather in San Francisco for you.\",\"type\":\"text\"},{\"id\":\"toolu_01XKSJ1fM9PHM9vpwH1p7PDT\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01XKSJ1fM9PHM9vpwH1p7PDT\",\"is_error\":true,\"content\":[{\"text\":\"Error:\n      Unexpected error, try again\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I\n      apologize for the error. Let me try checking the weather in San Francisco again.\",\"type\":\"text\"},{\"id\":\"toolu_01LELQc5n8mDyvS1bApN4qPi\",\"input\":{\"city\":\"San\n      Francisco\"},\"name\":\"get_weather\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_01LELQc5n8mDyvS1bApN4qPi\",\"content\":[{\"text\":\"Sunny\n      68°F\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-3-7-sonnet-latest\",\"tools\":[{\"input_schema\":{\"properties\":{\"city\":{\"type\":\"string\"},\"units\":{\"enum\":[\"celsius\",\"fahrenheit\"],\"type\":\"string\"}},\"required\":[\"city\"],\"type\":\"object\"},\"name\":\"get_weather\",\"description\":\"Get\n      weather\"}]}'\n    form: {}\n    headers:\n      Accept:\n      - application/json\n      Anthropic-Version:\n      - \"2023-06-01\"\n      Content-Type:\n      - application/json\n      User-Agent:\n      - Anthropic/Go 1.16.0\n      X-Api-Key:\n      - fake-api-key-for-testing-only\n      X-Stainless-Arch:\n      - arm64\n      X-Stainless-Lang:\n      - go\n      X-Stainless-Os:\n      - MacOS\n      X-Stainless-Package-Version:\n      - 1.16.0\n      X-Stainless-Retry-Count:\n      - \"0\"\n      X-Stainless-Runtime:\n      - go\n      X-Stainless-Runtime-Version:\n      - go1.24.5\n      X-Stainless-Timeout:\n      - \"600\"\n    url: https://api.anthropic.com/v1/messages?beta=true\n    method: POST\n  response:\n    body: '{\"model\":\"claude-3-7-sonnet-20250219\",\"id\":\"msg_01BT54to51fGtyrvodmSUuUw\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"The\n      current weather in San Francisco is sunny with a temperature of 68°F.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":580,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":21,\"service_tier\":\"standard\"}}'\n    headers:\n      Anthropic-Organization-Id:\n      - 1577a8a6-174a-4705-916c-6b22ae7a49e6\n      Anthropic-Ratelimit-Input-Tokens-Limit:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Remaining:\n      - \"200000\"\n      Anthropic-Ratelimit-Input-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Output-Tokens-Limit:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Remaining:\n      - \"80000\"\n      Anthropic-Ratelimit-Output-Tokens-Reset:\n      - \"2025-10-30T16:17:39Z\"\n      Anthropic-Ratelimit-Requests-Limit:\n      - \"4000\"\n      Anthropic-Ratelimit-Requests-Remaining:\n      - \"3999\"\n      Anthropic-Ratelimit-Requests-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Anthropic-Ratelimit-Tokens-Limit:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Remaining:\n      - \"280000\"\n      Anthropic-Ratelimit-Tokens-Reset:\n      - \"2025-10-30T16:17:38Z\"\n      Cf-Cache-Status:\n      - DYNAMIC\n      Cf-Ray:\n      - 996c39580aab5e6a-EWR\n      Content-Type:\n      - application/json\n      Date:\n      - Thu, 30 Oct 2025 16:17:39 GMT\n      Request-Id:\n      - req_011CUdgeSDTmEigNbh79UCJo\n      Server:\n      - cloudflare\n      Strict-Transport-Security:\n      - max-age=31536000; includeSubDomains; preload\n      X-Envoy-Upstream-Service-Time:\n      - \"605\"\n      X-Robots-Tag:\n      - none\n    status: 200 OK\n    code: 200\n    duration: \"\"\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_basic.golden",
    "content": "The current temperature in San Francisco is 68 degrees Fahrenheit.\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_next_message_step_1.golden",
    "content": "I'll check the weather in San Francisco for you using Celsius units.\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_next_message_step_2.golden",
    "content": "The current weather in San Francisco is 20 degrees Celsius.\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_next_streaming_types.golden",
    "content": "content_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_delta\ncontent_block_start\ncontent_block_start\ncontent_block_stop\ncontent_block_stop\nmessage_delta\nmessage_start\nmessage_stop\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_run_to_completion.golden",
    "content": "The weather in San Francisco is currently 68 degrees Fahrenheit.\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_streaming_all.golden",
    "content": "I'll get the current weather in San Francisco for you in Fahrenheit.\nThe current weather in San Francisco is 68 degrees Fahrenheit.\n"
  },
  {
    "path": "toolrunner/testdata/snapshots/tool_runner_tool_call_error_assistant.golden",
    "content": "The current weather in San Francisco is sunny with a temperature of 68°F.\n"
  },
  {
    "path": "toolrunner/tool.go",
    "content": "package toolrunner\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\tanthropic \"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/invopop/jsonschema\"\n)\n\n// betaTool is the internal generic implementation of anthropic.BetaTool.\n// Users never see this type directly - they work with the BetaTool interface.\n// The generic type parameter T is used internally for type-safe JSON unmarshaling.\ntype betaTool[T any] struct {\n\tname        string\n\tdescription string\n\tschema      anthropic.BetaToolInputSchemaParam\n\thandler     func(context.Context, T) (anthropic.BetaToolResultBlockParamContentUnion, error)\n}\n\nfunc (t *betaTool[T]) Name() string                                    { return t.name }\nfunc (t *betaTool[T]) Description() string                             { return t.description }\nfunc (t *betaTool[T]) InputSchema() anthropic.BetaToolInputSchemaParam { return t.schema }\n\nfunc (t *betaTool[T]) Execute(ctx context.Context, input json.RawMessage) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\tparsed, err := t.parse(input)\n\tif err != nil {\n\t\treturn anthropic.BetaToolResultBlockParamContentUnion{}, fmt.Errorf(\"failed to parse tool input: %w\", err)\n\t}\n\treturn t.handler(ctx, parsed)\n}\n\n// parse validates and parses the input according to the tool's schema.\n// This method handles special cases for json.RawMessage and []byte type parameters.\nfunc (t *betaTool[T]) parse(input json.RawMessage) (T, error) {\n\tvar parsed T\n\n\tswitch any(parsed).(type) {\n\tcase json.RawMessage:\n\t\t// If T is json.RawMessage, return the input as is\n\t\tif result, ok := any(input).(T); ok {\n\t\t\treturn result, nil\n\t\t}\n\t\treturn parsed, fmt.Errorf(\"type assertion failed for json.RawMessage\")\n\tcase []byte:\n\t\t// If T is []byte, return the raw JSON input as bytes\n\t\tif result, ok := any([]byte(input)).(T); ok {\n\t\t\treturn result, nil\n\t\t}\n\t\treturn parsed, fmt.Errorf(\"type assertion failed for []byte\")\n\tdefault:\n\t\t// For all other types (structs), unmarshal the input\n\t\tif err := json.Unmarshal(input, &parsed); err != nil {\n\t\t\treturn parsed, err\n\t\t}\n\t\treturn parsed, nil\n\t}\n}\n\nfunc parseSchemaMap(s map[string]any) (anthropic.BetaToolInputSchemaParam, error) {\n\tbytes, err := json.Marshal(s)\n\tif err != nil {\n\t\treturn anthropic.BetaToolInputSchemaParam{}, fmt.Errorf(\"failed to marshal schema: %w\", err)\n\t}\n\n\tvar schema anthropic.BetaToolInputSchemaParam\n\tif err := json.Unmarshal(bytes, &schema); err != nil {\n\t\treturn anthropic.BetaToolInputSchemaParam{}, fmt.Errorf(\"failed to unmarshal schema: %w\", err)\n\t}\n\n\treturn schema, nil\n}\n\n// NewBetaToolFromBytes creates a BetaTool from JSON schema bytes.\nfunc NewBetaToolFromBytes[T any](\n\tname, description string,\n\tschemaJSON []byte,\n\thandler func(context.Context, T) (anthropic.BetaToolResultBlockParamContentUnion, error),\n) (anthropic.BetaTool, error) {\n\tvar schema anthropic.BetaToolInputSchemaParam\n\tif err := schema.UnmarshalJSON(schemaJSON); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal schema: %w\", err)\n\t}\n\treturn NewBetaTool(name, description, schema, handler), nil\n}\n\n// NewBetaToolFromJSONSchema creates a BetaTool by inferring the schema from struct type T using reflection.\n// The struct should use jsonschema tags to define the schema (e.g., `jsonschema:\"required,description=...\"`).\nfunc NewBetaToolFromJSONSchema[T any](\n\tname, description string,\n\thandler func(context.Context, T) (anthropic.BetaToolResultBlockParamContentUnion, error),\n) (anthropic.BetaTool, error) {\n\tvar zeroValue T\n\treflector := jsonschema.Reflector{\n\t\tAllowAdditionalProperties:  false,\n\t\tRequiredFromJSONSchemaTags: true,\n\t\tDoNotReference:             true,\n\t}\n\n\tschema := reflector.Reflect(zeroValue)\n\n\tschemaBytes, err := json.Marshal(schema)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar schemaMap map[string]any\n\tif err := json.Unmarshal(schemaBytes, &schemaMap); err != nil {\n\t\treturn nil, err\n\t}\n\n\tinputSchema, err := parseSchemaMap(schemaMap)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn NewBetaTool(name, description, inputSchema, handler), nil\n}\n\n// NewBetaTool creates a BetaTool with a BetaToolInputSchemaParam directly.\nfunc NewBetaTool[T any](\n\tname, description string,\n\tschema anthropic.BetaToolInputSchemaParam,\n\thandler func(context.Context, T) (anthropic.BetaToolResultBlockParamContentUnion, error),\n) anthropic.BetaTool {\n\treturn &betaTool[T]{\n\t\tname:        name,\n\t\tdescription: description,\n\t\tschema:      schema,\n\t\thandler:     handler,\n\t}\n}\n"
  },
  {
    "path": "tools.md",
    "content": "# Tool Helpers\n\nThe SDK provides helper functions for defining tools and automatically running the conversation loop between Claude and your tools until Claude produces a final response.\n\n## Defining Tools\n\nUse the `toolrunner` package to create a `BetaTool` that combines the tool definition with its execution handler. There are three ways to create tools:\n\n- `NewBetaToolFromJSONSchema` - Automatically generates schema from a struct with `jsonschema` tags (recommended)\n- `NewBetaToolFromBytes` - Creates a tool from JSON schema bytes\n- `NewBetaTool` - Creates a tool from an explicit `BetaToolInputSchemaParam`\n\nThe generic type parameter is automatically inferred from your handler function's signature, so you don't need to specify it explicitly.\n\n### Automatic Schema Generation from Structs (Recommended)\n\nThe easiest approach is to use `NewBetaToolFromJSONSchema`, which automatically generates the schema from your struct using `jsonschema` tags:\n\n```go\ntype GetWeatherInput struct {\n\tCity  string `json:\"city\" jsonschema:\"required,description=The city name\"`\n\tUnits string `json:\"units,omitempty\" jsonschema:\"enum=celsius,enum=fahrenheit,description=Temperature units\"`\n}\n\nweatherTool, err := toolrunner.NewBetaToolFromJSONSchema(\n\t\"get_weather\",\n\t\"Get current weather for a city\",\n\tfunc(ctx context.Context, input GetWeatherInput) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\treturn anthropic.BetaToolResultBlockParamContentUnion{\n\t\t\tOfText: &anthropic.BetaTextBlockParam{\n\t\t\t\tText: fmt.Sprintf(\"Weather in %s: 72°F, sunny\", input.City),\n\t\t\t},\n\t\t}, nil\n\t},\n)\n```\n\n### Using JSON Bytes\n\nYou can provide the schema as JSON bytes using `NewBetaToolFromBytes`:\n\n```go\ntype GetWeatherInput struct {\n\tCity string `json:\"city\"`\n}\n\nweatherTool, err := toolrunner.NewBetaToolFromBytes(\n\t\"get_weather\",\n\t\"Get current weather for a city\",\n\t[]byte(`{\n\t\t\"type\": \"object\",\n\t\t\"properties\": {\n\t\t\t\"city\": {\"type\": \"string\", \"description\": \"The city name\"}\n\t\t},\n\t\t\"required\": [\"city\"]\n\t}`),\n\tfunc(ctx context.Context, input GetWeatherInput) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t// Your handler here\n\t},\n)\n```\n\n### Using an Explicit Schema\n\nFor full control, use `NewBetaTool` with a `BetaToolInputSchemaParam` directly:\n\n```go\nweatherTool := toolrunner.NewBetaTool(\n\t\"get_weather\",\n\t\"Get current weather for a city\",\n\tanthropic.BetaToolInputSchemaParam{\n\t\tProperties: map[string]any{\n\t\t\t\"city\": map[string]any{\n\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\"description\": \"The city name\",\n\t\t\t},\n\t\t},\n\t},\n\thandler,\n)\n```\n\n### Raw JSON Input\n\nIf you prefer to handle JSON parsing yourself, use `json.RawMessage` or `[]byte` as the input type:\n\n```go\nrawTool, err := toolrunner.NewBetaToolFromBytes(\n\t\"process_data\",\n\t\"Process raw JSON data\",\n\tschemaBytes,\n\tfunc(ctx context.Context, input json.RawMessage) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\t\t// Parse the JSON yourself\n\t\tvar data map[string]any\n\t\tjson.Unmarshal(input, &data)\n\t\t// ...\n\t},\n)\n\n## Tool Runner\n\nThe `BetaToolRunner` automatically handles the conversation loop between Claude and your tools. On each iteration, it:\n\n1. Sends the current messages to Claude\n2. If Claude responds with tool calls, executes them in parallel\n3. Adds the tool results to the conversation\n4. Repeats until Claude produces a final response (no tool calls)\n\n### Basic Usage\n\n```go\ntools := []anthropic.BetaTool{weatherTool}\n\nrunner := client.Beta.Messages.NewToolRunner(tools, anthropic.BetaToolRunnerParams{\n\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\tModel:     anthropic.ModelClaudeSonnet4_20250514,\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather in Tokyo?\")),\n\t\t},\n\t},\n})\n\n// Run the entire conversation to completion\nmessage, err := runner.RunToCompletion(context.Background())\n```\n\n### Iterating Over Messages\n\nUse `All()` to iterate over each message in the conversation:\n\n```go\nfor message, err := range runner.All(ctx) {\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor _, block := range message.Content {\n\t\tswitch b := block.AsAny().(type) {\n\t\tcase anthropic.BetaTextBlock:\n\t\t\tfmt.Println(\"[assistant]:\", b.Text)\n\t\tcase anthropic.BetaToolUseBlock:\n\t\t\tfmt.Printf(\"[tool call]: %s(%v)\\n\", b.Name, b.Input)\n\t\t}\n\t}\n}\n```\n\n### Step-by-Step Iteration\n\nFor more control, use `NextMessage()` to advance one turn at a time:\n\n```go\nfor {\n\tmessage, err := runner.NextMessage(ctx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif message == nil {\n\t\tbreak // Conversation complete\n\t}\n\t// Process the message...\n}\n```\n\n### Streaming\n\nUse `BetaToolRunnerStreaming` via `NewToolRunnerStreaming()` for streaming responses:\n\n```go\nrunner := client.Beta.Messages.NewToolRunnerStreaming(tools, anthropic.BetaToolRunnerParams{\n\tBetaMessageNewParams: anthropic.BetaMessageNewParams{\n\t\tModel:     anthropic.ModelClaudeSonnet4_20250514,\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.BetaMessageParam{\n\t\t\tanthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(\"What's the weather in Tokyo?\")),\n\t\t},\n\t},\n})\n\nfor eventsIterator := range runner.AllStreaming(ctx) {\n\tfor event, err := range eventsIterator {\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tswitch e := event.AsAny().(type) {\n\t\tcase anthropic.BetaRawContentBlockDeltaEvent:\n\t\t\tswitch delta := e.Delta.AsAny().(type) {\n\t\t\tcase anthropic.BetaTextDelta:\n\t\t\t\tfmt.Print(delta.Text)\n\t\t\t}\n\t\t}\n\t}\n}\n```\n\nOr use `NextStreaming()` for step-by-step streaming:\n\n```go\nfor !runner.IsCompleted() {\n\tfor event, err := range runner.NextStreaming(ctx) {\n\t\t// Handle streaming events...\n\t}\n}\n```\n\n## Configuration\n\n### Max Iterations\n\nLimit the number of API calls to prevent runaway loops. When set to 0 (the default), there is no limit and the runner continues until the model stops using tools:\n\n```go\nrunner := client.Beta.Messages.NewToolRunner(tools, anthropic.BetaToolRunnerParams{\n\t// ...\n\tMaxIterations: 10, // Stop after 10 API calls (0 = no limit)\n})\n```\n\n### Modifying Parameters Mid-Conversation\n\nThe `Params` field is exported, so you can modify parameters directly:\n\n```go\n// Update maximum tokens\nrunner.Params.MaxTokens = 2048\n\n// Update maximum iterations\nrunner.Params.MaxIterations = 10\n\n// Update system prompt\nrunner.Params.System = []anthropic.BetaTextBlockParam{\n\t{Text: \"You are a helpful assistant.\"},\n}\n\n// Add messages to the conversation (direct field access)\nrunner.Params.Messages = append(runner.Params.Messages, anthropic.NewBetaUserMessage(\n\tanthropic.NewBetaTextBlock(\"Now check the weather in London too\"),\n))\n\n// Or use the convenience method\nrunner.AppendMessages(anthropic.NewBetaUserMessage(\n\tanthropic.NewBetaTextBlock(\"Now check the weather in London too\"),\n))\n```\n\n### Inspecting State\n\n```go\n// Get most recent assistant message\nlastMsg := runner.LastMessage()\n\n// Get full conversation history (returns a copy)\nmessages := runner.Messages()\n\n// Check iteration count\ncount := runner.IterationCount()\n\n// Check if completed\nif runner.IsCompleted() {\n\t// ...\n}\n```\n\n## Error Handling\n\nTool execution errors are automatically converted to error results and sent back to Claude, allowing it to recover or try a different approach:\n\n```go\nfunc handler(ctx context.Context, input MyInput) (anthropic.BetaToolResultBlockParamContentUnion, error) {\n\tif input.City == \"\" {\n\t\treturn anthropic.BetaToolResultBlockParamContentUnion{}, errors.New(\"city is required\")\n\t}\n\t// ...\n}\n```\n\nThe error message will be sent to Claude as a tool result with `is_error: true`.\n\n## Parallel Tool Execution\n\nWhen Claude requests multiple tool calls in a single message, they are executed in parallel using an `errgroup`. This provides:\n\n- Concurrent execution for better performance\n- Proper context cancellation handling\n- Results returned in the correct order\n\n## Examples\n\nSee the [examples](./examples) directory for complete working examples:\n\n- [examples/tool-runner](./examples/tool-runner) - Basic tool runner usage\n- [examples/tool-runner-streaming](./examples/tool-runner-streaming) - Streaming with tool runner\n"
  },
  {
    "path": "usage_test.go",
    "content": "// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.\n\npackage anthropic_test\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/anthropics/anthropic-sdk-go\"\n\t\"github.com/anthropics/anthropic-sdk-go/internal/testutil\"\n\t\"github.com/anthropics/anthropic-sdk-go/option\"\n)\n\nfunc TestUsage(t *testing.T) {\n\tbaseURL := \"http://localhost:4010\"\n\tif envURL, ok := os.LookupEnv(\"TEST_API_BASE_URL\"); ok {\n\t\tbaseURL = envURL\n\t}\n\tif !testutil.CheckTestServer(t, baseURL) {\n\t\treturn\n\t}\n\tclient := anthropic.NewClient(\n\t\toption.WithBaseURL(baseURL),\n\t\toption.WithAPIKey(\"my-anthropic-api-key\"),\n\t)\n\tmessage, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{\n\t\tMaxTokens: 1024,\n\t\tMessages: []anthropic.MessageParam{{\n\t\t\tContent: []anthropic.ContentBlockParamUnion{{\n\t\t\t\tOfText: &anthropic.TextBlockParam{\n\t\t\t\t\tText: \"x\",\n\t\t\t\t},\n\t\t\t}},\n\t\t\tRole: anthropic.MessageParamRoleUser,\n\t\t}},\n\t\tModel: anthropic.ModelClaudeSonnet4_5_20250929,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(\"err should be nil: %s\", err.Error())\n\t}\n\tt.Logf(\"%+v\\n\", message.Content)\n}\n"
  },
  {
    "path": "vertex/vertex.go",
    "content": "package vertex\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\n\t\"golang.org/x/oauth2/google\"\n\t\"google.golang.org/api/option\"\n\t\"google.golang.org/api/transport\"\n\n\t\"github.com/anthropics/anthropic-sdk-go/internal/requestconfig\"\n\tsdkoption \"github.com/anthropics/anthropic-sdk-go/option\"\n\t\"github.com/tidwall/gjson\"\n\t\"github.com/tidwall/sjson\"\n)\n\nconst DefaultVersion = \"vertex-2023-10-16\"\n\n// WithGoogleAuth returns a request option which loads the [Application Default Credentials] for Google Vertex AI and registers\n// middleware that intercepts requests to the Messages API.\n//\n// If you already have a [*google.Credentials], it is recommended that you instead call [WithCredentials] directly.\n//\n// [Application Default Credentials]: https://cloud.google.com/docs/authentication/application-default-credentials\nfunc WithGoogleAuth(ctx context.Context, region string, projectID string, scopes ...string) sdkoption.RequestOption {\n\tif region == \"\" {\n\t\tpanic(\"region must be provided\")\n\t}\n\tcreds, err := google.FindDefaultCredentials(ctx, scopes...)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"failed to find default credentials: %v\", err))\n\t}\n\treturn WithCredentials(ctx, region, projectID, creds)\n}\n\n// WithCredentials returns a request option which uses the provided credentials for Google Vertex AI and registers middleware that\n// intercepts request to the Messages API.\nfunc WithCredentials(ctx context.Context, region string, projectID string, creds *google.Credentials) sdkoption.RequestOption {\n\tclient, _, err := transport.NewHTTPClient(ctx, option.WithTokenSource(creds.TokenSource))\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"failed to create HTTP client: %v\", err))\n\t}\n\tmiddleware := vertexMiddleware(region, projectID)\n\n\tvar baseURL string\n\tif region == \"global\" {\n\t\tbaseURL = \"https://aiplatform.googleapis.com/\"\n\t} else {\n\t\tbaseURL = fmt.Sprintf(\"https://%s-aiplatform.googleapis.com/\", region)\n\t}\n\n\treturn requestconfig.RequestOptionFunc(func(rc *requestconfig.RequestConfig) error {\n\t\treturn rc.Apply(\n\t\t\tsdkoption.WithBaseURL(baseURL),\n\t\t\tsdkoption.WithMiddleware(middleware),\n\t\t\tsdkoption.WithHTTPClient(client),\n\t\t)\n\t})\n}\n\nfunc vertexMiddleware(region, projectID string) sdkoption.Middleware {\n\treturn func(r *http.Request, next sdkoption.MiddlewareNext) (*http.Response, error) {\n\t\tif r.Body != nil {\n\t\t\tbody, err := io.ReadAll(r.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tr.Body.Close()\n\n\t\t\tif !gjson.GetBytes(body, \"anthropic_version\").Exists() {\n\t\t\t\tbody, _ = sjson.SetBytes(body, \"anthropic_version\", DefaultVersion)\n\t\t\t}\n\n\t\t\tif r.URL.Path == \"/v1/messages\" && r.Method == http.MethodPost {\n\t\t\t\tif projectID == \"\" {\n\t\t\t\t\treturn nil, fmt.Errorf(\"no projectId was given and it could not be resolved from credentials\")\n\t\t\t\t}\n\n\t\t\t\tmodel := gjson.GetBytes(body, \"model\").String()\n\t\t\t\tstream := gjson.GetBytes(body, \"stream\").Bool()\n\n\t\t\t\tbody, _ = sjson.DeleteBytes(body, \"model\")\n\n\t\t\t\tspecifier := \"rawPredict\"\n\t\t\t\tif stream {\n\t\t\t\t\tspecifier = \"streamRawPredict\"\n\t\t\t\t}\n\n\t\t\t\tr.URL.Path = fmt.Sprintf(\"/v1/projects/%s/locations/%s/publishers/anthropic/models/%s:%s\", projectID, region, model, specifier)\n\t\t\t}\n\n\t\t\tif r.URL.Path == \"/v1/messages/count_tokens\" && r.Method == http.MethodPost {\n\t\t\t\tif projectID == \"\" {\n\t\t\t\t\treturn nil, fmt.Errorf(\"no projectId was given and it could not be resolved from credentials\")\n\t\t\t\t}\n\n\t\t\t\tr.URL.Path = fmt.Sprintf(\"/v1/projects/%s/locations/%s/publishers/anthropic/models/count-tokens:rawPredict\", projectID, region)\n\t\t\t}\n\n\t\t\treader := bytes.NewReader(body)\n\t\t\tr.Body = io.NopCloser(reader)\n\t\t\tr.GetBody = func() (io.ReadCloser, error) {\n\t\t\t\t_, err := reader.Seek(0, 0)\n\t\t\t\treturn io.NopCloser(reader), err\n\t\t\t}\n\t\t\tr.ContentLength = int64(len(body))\n\t\t}\n\n\t\treturn next(r)\n\t}\n}\n"
  }
]