@anthropic-ai/sdk 0.125.0 → 0.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/client.d.mts +12 -11
- package/client.d.mts.map +1 -1
- package/client.d.ts +12 -11
- package/client.d.ts.map +1 -1
- package/client.js +865 -845
- package/client.js.map +1 -1
- package/client.mjs +866 -840
- package/client.mjs.map +1 -1
- package/core/api-promise.js +71 -68
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs +71 -64
- package/core/api-promise.mjs.map +1 -1
- package/core/error.js +5 -2
- package/core/error.js.map +1 -1
- package/core/error.mjs +5 -2
- package/core/error.mjs.map +1 -1
- package/core/pagination.js +56 -50
- package/core/pagination.js.map +1 -1
- package/core/pagination.mjs +56 -41
- package/core/pagination.mjs.map +1 -1
- package/core/streaming.js +212 -209
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +212 -209
- package/core/streaming.mjs.map +1 -1
- package/helpers/beta/mcp.js +14 -19
- package/helpers/beta/mcp.js.map +1 -1
- package/helpers/beta/mcp.mjs +14 -13
- package/helpers/beta/mcp.mjs.map +1 -1
- package/internal/constants.js +1 -1
- package/internal/constants.js.map +1 -1
- package/internal/decoders/jsonl.js +27 -24
- package/internal/decoders/jsonl.js.map +1 -1
- package/internal/decoders/jsonl.mjs +27 -24
- package/internal/decoders/jsonl.mjs.map +1 -1
- package/internal/decoders/line.js +52 -49
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +52 -43
- package/internal/decoders/line.mjs.map +1 -1
- package/internal/file-store.js +256 -258
- package/internal/file-store.js.map +1 -1
- package/internal/file-store.mjs +256 -243
- package/internal/file-store.mjs.map +1 -1
- package/internal/node.browser.d.mts.map +1 -1
- package/internal/node.browser.d.ts.map +1 -1
- package/internal/node.browser.js.map +1 -1
- package/internal/node.browser.mjs +7 -7
- package/internal/node.browser.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +2 -2
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +3 -3
- package/internal/parse.mjs.map +1 -1
- package/internal/shim-types.js +0 -6
- package/internal/shim-types.js.map +1 -1
- package/internal/shim-types.mjs +0 -6
- package/internal/shim-types.mjs.map +1 -1
- package/internal/shims.d.mts +3 -3
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +3 -3
- package/internal/shims.d.ts.map +1 -1
- package/internal/shims.js +0 -6
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +0 -6
- package/internal/shims.mjs.map +1 -1
- package/internal/stainless-helper-header.js +6 -6
- package/internal/stainless-helper-header.js.map +1 -1
- package/internal/utils/async-queue.js +66 -63
- package/internal/utils/async-queue.js.map +1 -1
- package/internal/utils/async-queue.mjs +66 -56
- package/internal/utils/async-queue.mjs.map +1 -1
- package/internal/utils/bytes.d.mts +1 -1
- package/internal/utils/bytes.d.mts.map +1 -1
- package/internal/utils/bytes.d.ts +1 -1
- package/internal/utils/bytes.d.ts.map +1 -1
- package/internal/utils/log.d.mts +7 -12
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +7 -12
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +12 -0
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +11 -0
- package/internal/utils/log.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +595 -590
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +595 -590
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.js +544 -541
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +544 -541
- package/lib/MessageStream.mjs.map +1 -1
- package/lib/beta-parser.d.mts +1 -3
- package/lib/beta-parser.d.mts.map +1 -1
- package/lib/beta-parser.d.ts +1 -3
- package/lib/beta-parser.d.ts.map +1 -1
- package/lib/beta-parser.js.map +1 -1
- package/lib/beta-parser.mjs.map +1 -1
- package/lib/environments/poller.js +180 -174
- package/lib/environments/poller.js.map +1 -1
- package/lib/environments/poller.mjs +180 -153
- package/lib/environments/poller.mjs.map +1 -1
- package/lib/environments/worker.js +375 -369
- package/lib/environments/worker.js.map +1 -1
- package/lib/environments/worker.mjs +374 -329
- package/lib/environments/worker.mjs.map +1 -1
- package/lib/internal/stub.d.mts +2 -0
- package/lib/internal/stub.d.mts.map +1 -0
- package/lib/internal/stub.d.ts +2 -0
- package/lib/internal/stub.d.ts.map +1 -0
- package/lib/internal/stub.js +6 -0
- package/lib/internal/stub.js.map +1 -0
- package/lib/internal/stub.mjs +3 -0
- package/lib/internal/stub.mjs.map +1 -0
- package/lib/internal/types.d.mts +5 -0
- package/lib/internal/types.d.mts.map +1 -0
- package/lib/internal/types.d.ts +5 -0
- package/lib/internal/types.d.ts.map +1 -0
- package/lib/internal/types.js +3 -0
- package/lib/internal/types.js.map +1 -0
- package/lib/internal/types.mjs +2 -0
- package/lib/internal/types.mjs.map +1 -0
- package/lib/middleware.js +6 -1
- package/lib/middleware.js.map +1 -1
- package/lib/middleware.mjs +6 -1
- package/lib/middleware.mjs.map +1 -1
- package/lib/parser.d.mts +1 -3
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts +1 -3
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs.map +1 -1
- package/lib/tools/BetaToolRunner.d.mts +21 -6
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts +21 -6
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +415 -310
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +414 -303
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/lib/tools/SessionToolRunner.js +241 -235
- package/lib/tools/SessionToolRunner.js.map +1 -1
- package/lib/tools/SessionToolRunner.mjs +241 -192
- package/lib/tools/SessionToolRunner.mjs.map +1 -1
- package/lib/tools/ToolError.js +39 -36
- package/lib/tools/ToolError.js.map +1 -1
- package/lib/tools/ToolError.mjs +39 -13
- package/lib/tools/ToolError.mjs.map +1 -1
- package/lib/transform-json-schema.js +7 -5
- package/lib/transform-json-schema.js.map +1 -1
- package/lib/transform-json-schema.mjs +7 -5
- package/lib/transform-json-schema.mjs.map +1 -1
- package/package.json +4 -3
- package/resources/beta/agents/agents.js +135 -132
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs +135 -132
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/beta.d.mts +5 -5
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +5 -5
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +39 -36
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +39 -36
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/deployment-runs.d.mts +4 -0
- package/resources/beta/deployment-runs.d.mts.map +1 -1
- package/resources/beta/deployment-runs.d.ts +4 -0
- package/resources/beta/deployment-runs.d.ts.map +1 -1
- package/resources/beta/deployments.d.mts +5 -0
- package/resources/beta/deployments.d.mts.map +1 -1
- package/resources/beta/deployments.d.ts +5 -0
- package/resources/beta/deployments.d.ts.map +1 -1
- package/resources/beta/dreams.d.mts +19 -28
- package/resources/beta/dreams.d.mts.map +1 -1
- package/resources/beta/dreams.d.ts +19 -28
- package/resources/beta/dreams.d.ts.map +1 -1
- package/resources/beta/environments/environments.js +157 -154
- package/resources/beta/environments/environments.js.map +1 -1
- package/resources/beta/environments/environments.mjs +157 -154
- package/resources/beta/environments/environments.mjs.map +1 -1
- package/resources/beta/environments/work.js +255 -252
- package/resources/beta/environments/work.js.map +1 -1
- package/resources/beta/environments/work.mjs +255 -252
- package/resources/beta/environments/work.mjs.map +1 -1
- package/resources/beta/index.d.mts +2 -2
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/memory-stores/memories.d.mts +6 -0
- package/resources/beta/memory-stores/memories.d.mts.map +1 -1
- package/resources/beta/memory-stores/memories.d.ts +6 -0
- package/resources/beta/memory-stores/memories.d.ts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.js +150 -147
- package/resources/beta/memory-stores/memory-stores.js.map +1 -1
- package/resources/beta/memory-stores/memory-stores.mjs +150 -147
- package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.mts +7 -0
- package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.ts +7 -0
- package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
- package/resources/beta/messages/batches.d.mts +12 -1
- package/resources/beta/messages/batches.d.mts.map +1 -1
- package/resources/beta/messages/batches.d.ts +12 -1
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +239 -101
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +239 -101
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +113 -110
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +113 -110
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/models.d.mts +22 -1
- package/resources/beta/models.d.mts.map +1 -1
- package/resources/beta/models.d.ts +22 -1
- package/resources/beta/models.d.ts.map +1 -1
- package/resources/beta/organization/federation/federation.js +11 -8
- package/resources/beta/organization/federation/federation.js.map +1 -1
- package/resources/beta/organization/federation/federation.mjs +11 -8
- package/resources/beta/organization/federation/federation.mjs.map +1 -1
- package/resources/beta/organization/federation/rules/rules.js +187 -184
- package/resources/beta/organization/federation/rules/rules.js.map +1 -1
- package/resources/beta/organization/federation/rules/rules.mjs +187 -184
- package/resources/beta/organization/federation/rules/rules.mjs.map +1 -1
- package/resources/beta/organization/index.d.mts +1 -1
- package/resources/beta/organization/index.d.mts.map +1 -1
- package/resources/beta/organization/index.d.ts +1 -1
- package/resources/beta/organization/index.d.ts.map +1 -1
- package/resources/beta/organization/index.js.map +1 -1
- package/resources/beta/organization/index.mjs.map +1 -1
- package/resources/beta/organization/organization.d.mts +2 -2
- package/resources/beta/organization/organization.d.mts.map +1 -1
- package/resources/beta/organization/organization.d.ts +2 -2
- package/resources/beta/organization/organization.d.ts.map +1 -1
- package/resources/beta/organization/organization.js +38 -35
- package/resources/beta/organization/organization.js.map +1 -1
- package/resources/beta/organization/organization.mjs +38 -35
- package/resources/beta/organization/organization.mjs.map +1 -1
- package/resources/beta/organization/rate-limits.d.mts +87 -5
- package/resources/beta/organization/rate-limits.d.mts.map +1 -1
- package/resources/beta/organization/rate-limits.d.ts +87 -5
- package/resources/beta/organization/rate-limits.d.ts.map +1 -1
- package/resources/beta/organization/service-accounts/service-accounts.js +163 -160
- package/resources/beta/organization/service-accounts/service-accounts.js.map +1 -1
- package/resources/beta/organization/service-accounts/service-accounts.mjs +163 -160
- package/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.d.mts +9 -4
- package/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.d.ts +9 -4
- package/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.js.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.d.mts +3 -3
- package/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.d.ts +3 -3
- package/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.js +97 -94
- package/resources/beta/organization/workspaces/workspaces.js.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.mjs +97 -94
- package/resources/beta/organization/workspaces/workspaces.mjs.map +1 -1
- package/resources/beta/sessions/events.d.mts +12 -21
- package/resources/beta/sessions/events.d.mts.map +1 -1
- package/resources/beta/sessions/events.d.ts +12 -21
- package/resources/beta/sessions/events.d.ts.map +1 -1
- package/resources/beta/sessions/events.js +118 -115
- package/resources/beta/sessions/events.js.map +1 -1
- package/resources/beta/sessions/events.mjs +118 -115
- package/resources/beta/sessions/events.mjs.map +1 -1
- package/resources/beta/sessions/resources.d.mts +0 -3
- package/resources/beta/sessions/resources.d.mts.map +1 -1
- package/resources/beta/sessions/resources.d.ts +0 -3
- package/resources/beta/sessions/resources.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.d.mts +8 -2
- package/resources/beta/sessions/sessions.d.mts.map +1 -1
- package/resources/beta/sessions/sessions.d.ts +8 -2
- package/resources/beta/sessions/sessions.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.js +161 -158
- package/resources/beta/sessions/sessions.js.map +1 -1
- package/resources/beta/sessions/sessions.mjs +161 -158
- package/resources/beta/sessions/sessions.mjs.map +1 -1
- package/resources/beta/sessions/threads/threads.js +86 -83
- package/resources/beta/sessions/threads/threads.js.map +1 -1
- package/resources/beta/sessions/threads/threads.mjs +86 -83
- package/resources/beta/sessions/threads/threads.mjs.map +1 -1
- package/resources/beta/skills/skills.js +104 -101
- package/resources/beta/skills/skills.js.map +1 -1
- package/resources/beta/skills/skills.mjs +104 -101
- package/resources/beta/skills/skills.mjs.map +1 -1
- package/resources/beta/tunnels/certificates.d.mts +2 -2
- package/resources/beta/tunnels/certificates.d.ts +2 -2
- package/resources/beta/tunnels/tunnels.js +188 -185
- package/resources/beta/tunnels/tunnels.js.map +1 -1
- package/resources/beta/tunnels/tunnels.mjs +188 -185
- package/resources/beta/tunnels/tunnels.mjs.map +1 -1
- package/resources/beta/user-profiles.d.mts +45 -0
- package/resources/beta/user-profiles.d.mts.map +1 -1
- package/resources/beta/user-profiles.d.ts +45 -0
- package/resources/beta/user-profiles.d.ts.map +1 -1
- package/resources/beta/user-profiles.js +25 -10
- package/resources/beta/user-profiles.js.map +1 -1
- package/resources/beta/user-profiles.mjs +25 -10
- package/resources/beta/user-profiles.mjs.map +1 -1
- package/resources/beta/vaults/credentials.d.mts +19 -19
- package/resources/beta/vaults/credentials.d.mts.map +1 -1
- package/resources/beta/vaults/credentials.d.ts +19 -19
- package/resources/beta/vaults/credentials.d.ts.map +1 -1
- package/resources/beta/vaults/vaults.js +156 -153
- package/resources/beta/vaults/vaults.js.map +1 -1
- package/resources/beta/vaults/vaults.mjs +156 -153
- package/resources/beta/vaults/vaults.mjs.map +1 -1
- package/resources/completions.d.mts +1 -1
- package/resources/completions.d.ts +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/index.d.mts +1 -1
- package/resources/messages/index.d.mts.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.mts +100 -63
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +100 -63
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +115 -112
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +115 -112
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/skills/skills.js +88 -85
- package/resources/skills/skills.js.map +1 -1
- package/resources/skills/skills.mjs +88 -85
- package/resources/skills/skills.mjs.map +1 -1
- package/resources/top-level.js +0 -1
- package/resources/top-level.js.map +1 -1
- package/resources/top-level.mjs +0 -1
- package/resources/top-level.mjs.map +1 -1
- package/src/client.ts +95 -72
- package/src/internal/node.browser.ts +7 -7
- package/src/internal/parse.ts +8 -11
- package/src/internal/shims.ts +4 -3
- package/src/internal/utils/bytes.ts +1 -1
- package/src/internal/utils/log.ts +16 -2
- package/src/lib/BetaMessageStream.ts +7 -5
- package/src/lib/beta-parser.ts +1 -3
- package/src/lib/internal/stub.ts +2 -0
- package/src/lib/internal/types.ts +2 -0
- package/src/lib/middleware.ts +6 -1
- package/src/lib/parser.ts +1 -3
- package/src/lib/tools/BetaToolRunner.ts +157 -24
- package/src/lib/transform-json-schema.ts +8 -6
- package/src/resources/beta/beta.ts +24 -1
- package/src/resources/beta/deployment-runs.ts +4 -0
- package/src/resources/beta/deployments.ts +5 -0
- package/src/resources/beta/dreams.ts +19 -28
- package/src/resources/beta/index.ts +11 -0
- package/src/resources/beta/memory-stores/memories.ts +6 -0
- package/src/resources/beta/memory-stores/memory-versions.ts +7 -0
- package/src/resources/beta/messages/batches.ts +13 -1
- package/src/resources/beta/messages/index.ts +10 -0
- package/src/resources/beta/messages/messages.ts +289 -100
- package/src/resources/beta/models.ts +25 -0
- package/src/resources/beta/organization/index.ts +6 -0
- package/src/resources/beta/organization/organization.ts +12 -0
- package/src/resources/beta/organization/rate-limits.ts +112 -4
- package/src/resources/beta/organization/workspaces/rate-limits.ts +16 -4
- package/src/resources/beta/organization/workspaces/workspaces.ts +3 -3
- package/src/resources/beta/sessions/events.ts +12 -21
- package/src/resources/beta/sessions/resources.ts +0 -3
- package/src/resources/beta/sessions/sessions.ts +8 -2
- package/src/resources/beta/tunnels/certificates.ts +2 -2
- package/src/resources/beta/user-profiles.ts +75 -10
- package/src/resources/beta/vaults/credentials.ts +19 -19
- package/src/resources/completions.ts +1 -1
- package/src/resources/index.ts +6 -0
- package/src/resources/messages/index.ts +6 -0
- package/src/resources/messages/messages.ts +128 -62
- package/src/tsconfig.json +13 -3
- package/src/version.ts +1 -1
- package/tools/agent-toolset/fs-util.js +0 -6
- package/tools/agent-toolset/fs-util.js.map +1 -1
- package/tools/agent-toolset/fs-util.mjs +0 -6
- package/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/tools/agent-toolset/memories.js +4 -4
- package/tools/agent-toolset/memories.js.map +1 -1
- package/tools/agent-toolset/memories.mjs +2 -2
- package/tools/agent-toolset/memories.mjs.map +1 -1
- package/tools/agent-toolset/node.browser.js +12 -12
- package/tools/agent-toolset/node.browser.js.map +1 -1
- package/tools/agent-toolset/node.js +142 -139
- package/tools/agent-toolset/node.js.map +1 -1
- package/tools/agent-toolset/node.mjs +132 -125
- package/tools/agent-toolset/node.mjs.map +1 -1
- package/tools/agent-toolset/skills.js +5 -5
- package/tools/agent-toolset/skills.js.map +1 -1
- package/tools/agent-toolset/sync-interval.js +3 -3
- package/tools/agent-toolset/sync-interval.js.map +1 -1
- package/tools/memory/node.browser.js +2 -2
- package/tools/memory/node.browser.js.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -10,123 +10,126 @@ const parser_1 = require("../../lib/parser.js");
|
|
|
10
10
|
const BatchesAPI = tslib_1.__importStar(require("./batches.js"));
|
|
11
11
|
const batches_1 = require("./batches.js");
|
|
12
12
|
const constants_1 = require("../../internal/constants.js");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
create(params, options) {
|
|
19
|
-
const { user_profile_id, workspace_id, ...body } = params;
|
|
20
|
-
if (body.model in DEPRECATED_MODELS) {
|
|
21
|
-
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
13
|
+
var Messages = /* @__PURE__ */ (() => {
|
|
14
|
+
class Messages extends resource_1.APIResource {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.batches = new BatchesAPI.Batches(this._client);
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
body
|
|
25
|
-
body.
|
|
26
|
-
|
|
19
|
+
create(params, options) {
|
|
20
|
+
const { user_profile_id, workspace_id, ...body } = params;
|
|
21
|
+
if (body.model in DEPRECATED_MODELS) {
|
|
22
|
+
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
23
|
+
}
|
|
24
|
+
if (MODELS_TO_WARN_WITH_THINKING_ENABLED.includes(body.model) &&
|
|
25
|
+
body.thinking &&
|
|
26
|
+
body.thinking.type === 'enabled') {
|
|
27
|
+
console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
|
|
28
|
+
}
|
|
29
|
+
let timeout = options?.timeout ?? this._client._options.timeout;
|
|
30
|
+
if (!body.stream && timeout == null) {
|
|
31
|
+
const maxNonstreamingTokens = constants_1.MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
|
|
32
|
+
timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
|
|
33
|
+
}
|
|
34
|
+
// Collect helper info from tools and messages
|
|
35
|
+
const helperHeader = (0, stainless_helper_header_1.stainlessHelperHeader)(body.tools, body.messages);
|
|
36
|
+
return this._client.post('/v1/messages', {
|
|
37
|
+
body,
|
|
38
|
+
timeout: timeout ?? 600000,
|
|
39
|
+
...options,
|
|
40
|
+
headers: (0, headers_1.buildHeaders)([
|
|
41
|
+
{
|
|
42
|
+
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
43
|
+
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
44
|
+
},
|
|
45
|
+
helperHeader,
|
|
46
|
+
options?.headers,
|
|
47
|
+
]),
|
|
48
|
+
stream: params.stream ?? false,
|
|
49
|
+
});
|
|
27
50
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
|
|
53
|
+
* the response will be automatically parsed and available in the `parsed_output` property of the message.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const message = await client.messages.parse({
|
|
58
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
59
|
+
* max_tokens: 1024,
|
|
60
|
+
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
61
|
+
* output_config: {
|
|
62
|
+
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
63
|
+
* },
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* console.log(message.parsed_output?.answer); // 4
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
parse(params, options) {
|
|
70
|
+
return this.create(params, options).then((message) => (0, parser_1.parseMessage)(message, params, { logger: this._client.logger ?? console }));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create a Message stream.
|
|
74
|
+
*
|
|
75
|
+
* If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
|
|
76
|
+
* the final message will include a `parsed_output` property with the parsed content.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const stream = client.messages.stream({
|
|
81
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
82
|
+
* max_tokens: 1024,
|
|
83
|
+
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
84
|
+
* output_config: {
|
|
85
|
+
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
86
|
+
* },
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* const message = await stream.finalMessage();
|
|
90
|
+
* console.log(message.parsed_output?.answer); // 4
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
stream(body, options) {
|
|
94
|
+
return MessageStream_1.MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Count the number of tokens in a Message.
|
|
98
|
+
*
|
|
99
|
+
* The Token Count API can be used to count the number of tokens in a Message,
|
|
100
|
+
* including tools, images, and documents, without creating it.
|
|
101
|
+
*
|
|
102
|
+
* Learn more about token counting in our
|
|
103
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const messageTokensCount =
|
|
108
|
+
* await client.messages.countTokens({
|
|
109
|
+
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
110
|
+
* model: 'claude-opus-5',
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
countTokens(params, options) {
|
|
115
|
+
const { user_profile_id, workspace_id, ...body } = params;
|
|
116
|
+
return this._client.post('/v1/messages/count_tokens', {
|
|
117
|
+
body,
|
|
118
|
+
...options,
|
|
119
|
+
headers: (0, headers_1.buildHeaders)([
|
|
120
|
+
{
|
|
121
|
+
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
122
|
+
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
123
|
+
},
|
|
124
|
+
options?.headers,
|
|
125
|
+
]),
|
|
126
|
+
});
|
|
32
127
|
}
|
|
33
|
-
// Collect helper info from tools and messages
|
|
34
|
-
const helperHeader = (0, stainless_helper_header_1.stainlessHelperHeader)(body.tools, body.messages);
|
|
35
|
-
return this._client.post('/v1/messages', {
|
|
36
|
-
body,
|
|
37
|
-
timeout: timeout ?? 600000,
|
|
38
|
-
...options,
|
|
39
|
-
headers: (0, headers_1.buildHeaders)([
|
|
40
|
-
{
|
|
41
|
-
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
42
|
-
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
43
|
-
},
|
|
44
|
-
helperHeader,
|
|
45
|
-
options?.headers,
|
|
46
|
-
]),
|
|
47
|
-
stream: params.stream ?? false,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
|
|
52
|
-
* the response will be automatically parsed and available in the `parsed_output` property of the message.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* const message = await client.messages.parse({
|
|
57
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
58
|
-
* max_tokens: 1024,
|
|
59
|
-
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
60
|
-
* output_config: {
|
|
61
|
-
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
62
|
-
* },
|
|
63
|
-
* });
|
|
64
|
-
*
|
|
65
|
-
* console.log(message.parsed_output?.answer); // 4
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
parse(params, options) {
|
|
69
|
-
return this.create(params, options).then((message) => (0, parser_1.parseMessage)(message, params, { logger: this._client.logger ?? console }));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create a Message stream.
|
|
73
|
-
*
|
|
74
|
-
* If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
|
|
75
|
-
* the final message will include a `parsed_output` property with the parsed content.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```ts
|
|
79
|
-
* const stream = client.messages.stream({
|
|
80
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
81
|
-
* max_tokens: 1024,
|
|
82
|
-
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
83
|
-
* output_config: {
|
|
84
|
-
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
85
|
-
* },
|
|
86
|
-
* });
|
|
87
|
-
*
|
|
88
|
-
* const message = await stream.finalMessage();
|
|
89
|
-
* console.log(message.parsed_output?.answer); // 4
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
stream(body, options) {
|
|
93
|
-
return MessageStream_1.MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Count the number of tokens in a Message.
|
|
97
|
-
*
|
|
98
|
-
* The Token Count API can be used to count the number of tokens in a Message,
|
|
99
|
-
* including tools, images, and documents, without creating it.
|
|
100
|
-
*
|
|
101
|
-
* Learn more about token counting in our
|
|
102
|
-
* [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* const messageTokensCount =
|
|
107
|
-
* await client.messages.countTokens({
|
|
108
|
-
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
109
|
-
* model: 'claude-opus-5',
|
|
110
|
-
* });
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
countTokens(params, options) {
|
|
114
|
-
const { user_profile_id, workspace_id, ...body } = params;
|
|
115
|
-
return this._client.post('/v1/messages/count_tokens', {
|
|
116
|
-
body,
|
|
117
|
-
...options,
|
|
118
|
-
headers: (0, headers_1.buildHeaders)([
|
|
119
|
-
{
|
|
120
|
-
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
121
|
-
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
122
|
-
},
|
|
123
|
-
options?.headers,
|
|
124
|
-
]),
|
|
125
|
-
});
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
Messages.Batches = batches_1.Batches;
|
|
130
|
+
return Messages;
|
|
131
|
+
})();
|
|
128
132
|
exports.Messages = Messages;
|
|
129
133
|
const DEPRECATED_MODELS = {};
|
|
130
134
|
const MODELS_TO_WARN_WITH_THINKING_ENABLED = ['claude-mythos-preview', 'claude-opus-4-6'];
|
|
131
|
-
Messages.Batches = batches_1.Batches;
|
|
132
135
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":";;;;AACA,qDAAkD;AAElD,uDAAsD;AAEtD,uFAA+E;AAC/E,8DAAwD;AACxD,gDAK0B;AAC1B,iEAAwC;AACxC,0CAkBmB;AAGnB,2DAAqE
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":";;;;AACA,qDAAkD;AAElD,uDAAsD;AAEtD,uFAA+E;AAC/E,8DAAwD;AACxD,gDAK0B;AAC1B,iEAAwC;AACxC,0CAkBmB;AAGnB,2DAAqE;;IAErE,MAAa,QAAS,SAAQ,sBAAW;QAAzC;;YACE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAwKrE,CAAC;QA1IC,MAAM,CACJ,MAA2B,EAC3B,OAAwB;YAExB,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;YAC1D,IAAI,IAAI,CAAC,KAAK,IAAI,iBAAiB,EAAE,CAAC;gBACpC,OAAO,CAAC,IAAI,CACV,cAAc,IAAI,CAAC,KAAK,iDACtB,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAC9B,gIAAgI,CACjI,CAAC;YACJ,CAAC;YACD,IACE,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;gBACzD,IAAI,C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,oCAAoC,GAAY,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC"}
|
|
@@ -6,122 +6,125 @@ import { parseMessage, } from "../../lib/parser.mjs";
|
|
|
6
6
|
import * as BatchesAPI from "./batches.mjs";
|
|
7
7
|
import { Batches, } from "./batches.mjs";
|
|
8
8
|
import { MODEL_NONSTREAMING_TOKENS } from "../../internal/constants.mjs";
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
create(params, options) {
|
|
15
|
-
const { user_profile_id, workspace_id, ...body } = params;
|
|
16
|
-
if (body.model in DEPRECATED_MODELS) {
|
|
17
|
-
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
9
|
+
export var Messages = /* @__PURE__ */ (() => {
|
|
10
|
+
class Messages extends APIResource {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.batches = new BatchesAPI.Batches(this._client);
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
body
|
|
21
|
-
body.
|
|
22
|
-
|
|
15
|
+
create(params, options) {
|
|
16
|
+
const { user_profile_id, workspace_id, ...body } = params;
|
|
17
|
+
if (body.model in DEPRECATED_MODELS) {
|
|
18
|
+
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
19
|
+
}
|
|
20
|
+
if (MODELS_TO_WARN_WITH_THINKING_ENABLED.includes(body.model) &&
|
|
21
|
+
body.thinking &&
|
|
22
|
+
body.thinking.type === 'enabled') {
|
|
23
|
+
console.warn(`Using Claude with ${body.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);
|
|
24
|
+
}
|
|
25
|
+
let timeout = options?.timeout ?? this._client._options.timeout;
|
|
26
|
+
if (!body.stream && timeout == null) {
|
|
27
|
+
const maxNonstreamingTokens = MODEL_NONSTREAMING_TOKENS[body.model] ?? undefined;
|
|
28
|
+
timeout = this._client.calculateNonstreamingTimeout(body.max_tokens, maxNonstreamingTokens);
|
|
29
|
+
}
|
|
30
|
+
// Collect helper info from tools and messages
|
|
31
|
+
const helperHeader = stainlessHelperHeader(body.tools, body.messages);
|
|
32
|
+
return this._client.post('/v1/messages', {
|
|
33
|
+
body,
|
|
34
|
+
timeout: timeout ?? 600000,
|
|
35
|
+
...options,
|
|
36
|
+
headers: buildHeaders([
|
|
37
|
+
{
|
|
38
|
+
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
39
|
+
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
40
|
+
},
|
|
41
|
+
helperHeader,
|
|
42
|
+
options?.headers,
|
|
43
|
+
]),
|
|
44
|
+
stream: params.stream ?? false,
|
|
45
|
+
});
|
|
23
46
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
|
|
49
|
+
* the response will be automatically parsed and available in the `parsed_output` property of the message.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const message = await client.messages.parse({
|
|
54
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
55
|
+
* max_tokens: 1024,
|
|
56
|
+
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
57
|
+
* output_config: {
|
|
58
|
+
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
59
|
+
* },
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* console.log(message.parsed_output?.answer); // 4
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
parse(params, options) {
|
|
66
|
+
return this.create(params, options).then((message) => parseMessage(message, params, { logger: this._client.logger ?? console }));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a Message stream.
|
|
70
|
+
*
|
|
71
|
+
* If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
|
|
72
|
+
* the final message will include a `parsed_output` property with the parsed content.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const stream = client.messages.stream({
|
|
77
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
78
|
+
* max_tokens: 1024,
|
|
79
|
+
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
80
|
+
* output_config: {
|
|
81
|
+
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
82
|
+
* },
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const message = await stream.finalMessage();
|
|
86
|
+
* console.log(message.parsed_output?.answer); // 4
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
stream(body, options) {
|
|
90
|
+
return MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Count the number of tokens in a Message.
|
|
94
|
+
*
|
|
95
|
+
* The Token Count API can be used to count the number of tokens in a Message,
|
|
96
|
+
* including tools, images, and documents, without creating it.
|
|
97
|
+
*
|
|
98
|
+
* Learn more about token counting in our
|
|
99
|
+
* [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const messageTokensCount =
|
|
104
|
+
* await client.messages.countTokens({
|
|
105
|
+
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
106
|
+
* model: 'claude-opus-5',
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
countTokens(params, options) {
|
|
111
|
+
const { user_profile_id, workspace_id, ...body } = params;
|
|
112
|
+
return this._client.post('/v1/messages/count_tokens', {
|
|
113
|
+
body,
|
|
114
|
+
...options,
|
|
115
|
+
headers: buildHeaders([
|
|
116
|
+
{
|
|
117
|
+
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
118
|
+
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
119
|
+
},
|
|
120
|
+
options?.headers,
|
|
121
|
+
]),
|
|
122
|
+
});
|
|
28
123
|
}
|
|
29
|
-
// Collect helper info from tools and messages
|
|
30
|
-
const helperHeader = stainlessHelperHeader(body.tools, body.messages);
|
|
31
|
-
return this._client.post('/v1/messages', {
|
|
32
|
-
body,
|
|
33
|
-
timeout: timeout ?? 600000,
|
|
34
|
-
...options,
|
|
35
|
-
headers: buildHeaders([
|
|
36
|
-
{
|
|
37
|
-
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
38
|
-
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
39
|
-
},
|
|
40
|
-
helperHeader,
|
|
41
|
-
options?.headers,
|
|
42
|
-
]),
|
|
43
|
-
stream: params.stream ?? false,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Send a structured list of input messages with text and/or image content, along with an expected `output_config.format` and
|
|
48
|
-
* the response will be automatically parsed and available in the `parsed_output` property of the message.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* const message = await client.messages.parse({
|
|
53
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
54
|
-
* max_tokens: 1024,
|
|
55
|
-
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
56
|
-
* output_config: {
|
|
57
|
-
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
58
|
-
* },
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* console.log(message.parsed_output?.answer); // 4
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
parse(params, options) {
|
|
65
|
-
return this.create(params, options).then((message) => parseMessage(message, params, { logger: this._client.logger ?? console }));
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Create a Message stream.
|
|
69
|
-
*
|
|
70
|
-
* If `output_config.format` is provided with a parseable format (like `zodOutputFormat()`),
|
|
71
|
-
* the final message will include a `parsed_output` property with the parsed content.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const stream = client.messages.stream({
|
|
76
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
77
|
-
* max_tokens: 1024,
|
|
78
|
-
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
79
|
-
* output_config: {
|
|
80
|
-
* format: zodOutputFormat(z.object({ answer: z.number() })),
|
|
81
|
-
* },
|
|
82
|
-
* });
|
|
83
|
-
*
|
|
84
|
-
* const message = await stream.finalMessage();
|
|
85
|
-
* console.log(message.parsed_output?.answer); // 4
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
stream(body, options) {
|
|
89
|
-
return MessageStream.createMessage(this, body, options, { logger: this._client.logger ?? console });
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Count the number of tokens in a Message.
|
|
93
|
-
*
|
|
94
|
-
* The Token Count API can be used to count the number of tokens in a Message,
|
|
95
|
-
* including tools, images, and documents, without creating it.
|
|
96
|
-
*
|
|
97
|
-
* Learn more about token counting in our
|
|
98
|
-
* [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* const messageTokensCount =
|
|
103
|
-
* await client.messages.countTokens({
|
|
104
|
-
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
105
|
-
* model: 'claude-opus-5',
|
|
106
|
-
* });
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
countTokens(params, options) {
|
|
110
|
-
const { user_profile_id, workspace_id, ...body } = params;
|
|
111
|
-
return this._client.post('/v1/messages/count_tokens', {
|
|
112
|
-
body,
|
|
113
|
-
...options,
|
|
114
|
-
headers: buildHeaders([
|
|
115
|
-
{
|
|
116
|
-
...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
|
|
117
|
-
...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined),
|
|
118
|
-
},
|
|
119
|
-
options?.headers,
|
|
120
|
-
]),
|
|
121
|
-
});
|
|
122
124
|
}
|
|
123
|
-
|
|
125
|
+
Messages.Batches = Batches;
|
|
126
|
+
return Messages;
|
|
127
|
+
})();
|
|
124
128
|
const DEPRECATED_MODELS = {};
|
|
125
129
|
const MODELS_TO_WARN_WITH_THINKING_ENABLED = ['claude-mythos-preview', 'claude-opus-4-6'];
|
|
126
|
-
Messages.Batches = Batches;
|
|
127
130
|
//# sourceMappingURL=messages.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAElD,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,qBAAqB,EAAE,mDAA+C;AAC/E,OAAO,EAAE,aAAa,EAAE,oCAAgC;AACxD,OAAO,EACL,YAAY,GAIb,6BAAyB;AAC1B,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EAOL,OAAO,GAWR,sBAAkB;AAGnB,OAAO,EAAE,yBAAyB,EAAE,qCAAiC;AAErE,MAAM,
|
|
1
|
+
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../src/resources/messages/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gCAA4B;AAElD,OAAO,EAAE,YAAY,EAAE,mCAA+B;AAEtD,OAAO,EAAE,qBAAqB,EAAE,mDAA+C;AAC/E,OA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