feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from './beta/index';

View File

@@ -0,0 +1,601 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as FilesAPI from './files';
import {
DeletedFile,
FileDeleteParams,
FileDownloadParams,
FileListParams,
FileMetadata,
FileMetadataPage,
FileRetrieveMetadataParams,
FileUploadParams,
Files,
} from './files';
import * as ModelsAPI from './models';
import {
BetaCapabilitySupport,
BetaContextManagementCapability,
BetaEffortCapability,
BetaModelCapabilities,
BetaModelInfo,
BetaModelInfosPage,
BetaThinkingCapability,
BetaThinkingTypes,
ModelListParams,
ModelRetrieveParams,
Models,
} from './models';
import * as MessagesAPI from './messages/messages';
import {
BetaAllThinkingTurns,
BetaBase64ImageSource,
BetaBase64PDFBlock,
BetaBase64PDFSource,
BetaBashCodeExecutionOutputBlock,
BetaBashCodeExecutionOutputBlockParam,
BetaBashCodeExecutionResultBlock,
BetaBashCodeExecutionResultBlockParam,
BetaBashCodeExecutionToolResultBlock,
BetaBashCodeExecutionToolResultBlockParam,
BetaBashCodeExecutionToolResultError,
BetaBashCodeExecutionToolResultErrorParam,
BetaCacheControlEphemeral,
BetaCacheCreation,
BetaCitationCharLocation,
BetaCitationCharLocationParam,
BetaCitationConfig,
BetaCitationContentBlockLocation,
BetaCitationContentBlockLocationParam,
BetaCitationPageLocation,
BetaCitationPageLocationParam,
BetaCitationSearchResultLocation,
BetaCitationSearchResultLocationParam,
BetaCitationWebSearchResultLocationParam,
BetaCitationsConfigParam,
BetaCitationsDelta,
BetaCitationsWebSearchResultLocation,
BetaClearThinking20251015Edit,
BetaClearThinking20251015EditResponse,
BetaClearToolUses20250919Edit,
BetaClearToolUses20250919EditResponse,
BetaCodeExecutionOutputBlock,
BetaCodeExecutionOutputBlockParam,
BetaCodeExecutionResultBlock,
BetaCodeExecutionResultBlockParam,
BetaCodeExecutionTool20250522,
BetaCodeExecutionTool20250825,
BetaCodeExecutionTool20260120,
BetaCodeExecutionToolResultBlock,
BetaCodeExecutionToolResultBlockContent,
BetaCodeExecutionToolResultBlockParam,
BetaCodeExecutionToolResultBlockParamContent,
BetaCodeExecutionToolResultError,
BetaCodeExecutionToolResultErrorCode,
BetaCodeExecutionToolResultErrorParam,
BetaCompact20260112Edit,
BetaCompactionBlock,
BetaCompactionBlockParam,
BetaCompactionContentBlockDelta,
BetaCompactionIterationUsage,
BetaContainer,
BetaContainerParams,
BetaContainerUploadBlock,
BetaContainerUploadBlockParam,
BetaContentBlock,
BetaContentBlockParam,
BetaContentBlockSource,
BetaContentBlockSourceContent,
BetaContextManagementConfig,
BetaContextManagementResponse,
BetaCountTokensContextManagementResponse,
BetaDirectCaller,
BetaDocumentBlock,
BetaEncryptedCodeExecutionResultBlock,
BetaEncryptedCodeExecutionResultBlockParam,
BetaFileDocumentSource,
BetaFileImageSource,
BetaImageBlockParam,
BetaInputJSONDelta,
BetaJSONOutputFormat,
BetaInputTokensClearAtLeast,
BetaInputTokensTrigger,
BetaMCPToolResultBlock,
BetaMCPToolUseBlock,
BetaMCPToolUseBlockParam,
BetaMCPToolset,
BetaMemoryTool20250818,
BetaMemoryTool20250818Command,
BetaMemoryTool20250818CreateCommand,
BetaMemoryTool20250818DeleteCommand,
BetaMemoryTool20250818InsertCommand,
BetaMemoryTool20250818RenameCommand,
BetaMemoryTool20250818StrReplaceCommand,
BetaMemoryTool20250818ViewCommand,
BetaMessage,
BetaMessageDeltaUsage,
BetaMessageIterationUsage,
BetaMessageParam,
BetaMessageTokensCount,
BetaMetadata,
BetaOutputConfig,
BetaPlainTextSource,
BetaRawContentBlockDelta,
BetaRawContentBlockDeltaEvent,
BetaRawContentBlockStartEvent,
BetaRawContentBlockStopEvent,
BetaRawMessageDeltaEvent,
BetaRawMessageStartEvent,
BetaRawMessageStopEvent,
BetaRawMessageStreamEvent,
BetaRedactedThinkingBlock,
BetaRedactedThinkingBlockParam,
BetaRequestDocumentBlock,
BetaRequestMCPServerToolConfiguration,
BetaRequestMCPServerURLDefinition,
BetaRequestMCPToolResultBlockParam,
BetaSearchResultBlockParam,
BetaServerToolCaller,
BetaServerToolCaller20260120,
BetaServerToolUsage,
BetaServerToolUseBlock,
BetaServerToolUseBlockParam,
BetaSignatureDelta,
BetaSkill,
BetaSkillParams,
BetaStopReason,
BetaTextBlock,
BetaTextBlockParam,
BetaTextCitation,
BetaTextCitationParam,
BetaTextDelta,
BetaTextEditorCodeExecutionCreateResultBlock,
BetaTextEditorCodeExecutionCreateResultBlockParam,
BetaTextEditorCodeExecutionStrReplaceResultBlock,
BetaTextEditorCodeExecutionStrReplaceResultBlockParam,
BetaTextEditorCodeExecutionToolResultBlock,
BetaTextEditorCodeExecutionToolResultBlockParam,
BetaTextEditorCodeExecutionToolResultError,
BetaTextEditorCodeExecutionToolResultErrorParam,
BetaTextEditorCodeExecutionViewResultBlock,
BetaTextEditorCodeExecutionViewResultBlockParam,
BetaThinkingBlock,
BetaThinkingBlockParam,
BetaThinkingConfigAdaptive,
BetaThinkingConfigDisabled,
BetaThinkingConfigEnabled,
BetaThinkingConfigParam,
BetaThinkingDelta,
BetaThinkingTurns,
BetaTool,
BetaToolBash20241022,
BetaToolBash20250124,
BetaToolChoice,
BetaToolChoiceAny,
BetaToolChoiceAuto,
BetaToolChoiceNone,
BetaToolChoiceTool,
BetaToolComputerUse20241022,
BetaToolComputerUse20250124,
BetaToolComputerUse20251124,
BetaToolReferenceBlock,
BetaToolReferenceBlockParam,
BetaToolResultBlockParam,
BetaToolTextEditor20241022,
BetaToolTextEditor20250124,
BetaToolTextEditor20250429,
BetaToolTextEditor20250728,
BetaToolUnion,
BetaToolUseBlock,
BetaToolUseBlockParam,
BetaToolUsesKeep,
BetaToolUsesTrigger,
BetaURLImageSource,
BetaURLPDFSource,
BetaUsage,
BetaUserLocation,
BetaWebFetchBlock,
BetaWebFetchBlockParam,
BetaWebFetchTool20250910,
BetaWebFetchTool20260209,
BetaWebFetchTool20260309,
BetaWebFetchToolResultBlock,
BetaWebFetchToolResultBlockParam,
BetaWebFetchToolResultErrorBlock,
BetaWebFetchToolResultErrorBlockParam,
BetaWebFetchToolResultErrorCode,
BetaWebSearchResultBlock,
BetaWebSearchResultBlockParam,
BetaWebSearchTool20250305,
BetaWebSearchTool20260209,
BetaWebSearchToolRequestError,
BetaWebSearchToolResultBlock,
BetaWebSearchToolResultBlockContent,
BetaWebSearchToolResultBlockParam,
BetaWebSearchToolResultBlockParamContent,
BetaWebSearchToolResultError,
BetaWebSearchToolResultErrorCode,
MessageCountTokensParams,
MessageCreateParams,
MessageCreateParamsNonStreaming,
MessageCreateParamsStreaming,
Messages,
BetaMCPToolConfig,
BetaMCPToolDefaultConfig,
} from './messages/messages';
import * as SkillsAPI from './skills/skills';
import {
SkillCreateParams,
SkillCreateResponse,
SkillDeleteParams,
SkillDeleteResponse,
SkillListParams,
SkillListResponse,
SkillListResponsesPageCursor,
SkillRetrieveParams,
SkillRetrieveResponse,
Skills,
} from './skills/skills';
export class Beta extends APIResource {
models: ModelsAPI.Models = new ModelsAPI.Models(this._client);
messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
files: FilesAPI.Files = new FilesAPI.Files(this._client);
skills: SkillsAPI.Skills = new SkillsAPI.Skills(this._client);
}
export type AnthropicBeta =
| (string & {})
| 'message-batches-2024-09-24'
| 'prompt-caching-2024-07-31'
| 'computer-use-2024-10-22'
| 'computer-use-2025-01-24'
| 'pdfs-2024-09-25'
| 'token-counting-2024-11-01'
| 'token-efficient-tools-2025-02-19'
| 'output-128k-2025-02-19'
| 'files-api-2025-04-14'
| 'mcp-client-2025-04-04'
| 'mcp-client-2025-11-20'
| 'dev-full-thinking-2025-05-14'
| 'interleaved-thinking-2025-05-14'
| 'code-execution-2025-05-22'
| 'extended-cache-ttl-2025-04-11'
| 'context-1m-2025-08-07'
| 'context-management-2025-06-27'
| 'model-context-window-exceeded-2025-08-26'
| 'skills-2025-10-02'
| 'fast-mode-2026-02-01'
| 'output-300k-2026-03-24';
export interface BetaAPIError {
message: string;
type: 'api_error';
}
export interface BetaAuthenticationError {
message: string;
type: 'authentication_error';
}
export interface BetaBillingError {
message: string;
type: 'billing_error';
}
export type BetaError =
| BetaInvalidRequestError
| BetaAuthenticationError
| BetaBillingError
| BetaPermissionError
| BetaNotFoundError
| BetaRateLimitError
| BetaGatewayTimeoutError
| BetaAPIError
| BetaOverloadedError;
export interface BetaErrorResponse {
error: BetaError;
request_id: string | null;
type: 'error';
}
export interface BetaGatewayTimeoutError {
message: string;
type: 'timeout_error';
}
export interface BetaInvalidRequestError {
message: string;
type: 'invalid_request_error';
}
export interface BetaNotFoundError {
message: string;
type: 'not_found_error';
}
export interface BetaOverloadedError {
message: string;
type: 'overloaded_error';
}
export interface BetaPermissionError {
message: string;
type: 'permission_error';
}
export interface BetaRateLimitError {
message: string;
type: 'rate_limit_error';
}
Beta.Models = Models;
Beta.Messages = Messages;
Beta.Files = Files;
Beta.Skills = Skills;
export declare namespace Beta {
export {
type AnthropicBeta as AnthropicBeta,
type BetaAPIError as BetaAPIError,
type BetaAuthenticationError as BetaAuthenticationError,
type BetaBillingError as BetaBillingError,
type BetaError as BetaError,
type BetaErrorResponse as BetaErrorResponse,
type BetaGatewayTimeoutError as BetaGatewayTimeoutError,
type BetaInvalidRequestError as BetaInvalidRequestError,
type BetaNotFoundError as BetaNotFoundError,
type BetaOverloadedError as BetaOverloadedError,
type BetaPermissionError as BetaPermissionError,
type BetaRateLimitError as BetaRateLimitError,
};
export {
Models as Models,
type BetaCapabilitySupport as BetaCapabilitySupport,
type BetaContextManagementCapability as BetaContextManagementCapability,
type BetaEffortCapability as BetaEffortCapability,
type BetaModelCapabilities as BetaModelCapabilities,
type BetaModelInfo as BetaModelInfo,
type BetaThinkingCapability as BetaThinkingCapability,
type BetaThinkingTypes as BetaThinkingTypes,
type BetaModelInfosPage as BetaModelInfosPage,
type ModelRetrieveParams as ModelRetrieveParams,
type ModelListParams as ModelListParams,
};
export {
Messages as Messages,
type BetaAllThinkingTurns as BetaAllThinkingTurns,
type BetaBase64ImageSource as BetaBase64ImageSource,
type BetaBase64PDFSource as BetaBase64PDFSource,
type BetaBashCodeExecutionOutputBlock as BetaBashCodeExecutionOutputBlock,
type BetaBashCodeExecutionOutputBlockParam as BetaBashCodeExecutionOutputBlockParam,
type BetaBashCodeExecutionResultBlock as BetaBashCodeExecutionResultBlock,
type BetaBashCodeExecutionResultBlockParam as BetaBashCodeExecutionResultBlockParam,
type BetaBashCodeExecutionToolResultBlock as BetaBashCodeExecutionToolResultBlock,
type BetaBashCodeExecutionToolResultBlockParam as BetaBashCodeExecutionToolResultBlockParam,
type BetaBashCodeExecutionToolResultError as BetaBashCodeExecutionToolResultError,
type BetaBashCodeExecutionToolResultErrorParam as BetaBashCodeExecutionToolResultErrorParam,
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
type BetaCacheCreation as BetaCacheCreation,
type BetaCitationCharLocation as BetaCitationCharLocation,
type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
type BetaCitationConfig as BetaCitationConfig,
type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
type BetaCitationPageLocation as BetaCitationPageLocation,
type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
type BetaCitationSearchResultLocation as BetaCitationSearchResultLocation,
type BetaCitationSearchResultLocationParam as BetaCitationSearchResultLocationParam,
type BetaCitationWebSearchResultLocationParam as BetaCitationWebSearchResultLocationParam,
type BetaCitationsConfigParam as BetaCitationsConfigParam,
type BetaCitationsDelta as BetaCitationsDelta,
type BetaCitationsWebSearchResultLocation as BetaCitationsWebSearchResultLocation,
type BetaClearThinking20251015Edit as BetaClearThinking20251015Edit,
type BetaClearThinking20251015EditResponse as BetaClearThinking20251015EditResponse,
type BetaClearToolUses20250919Edit as BetaClearToolUses20250919Edit,
type BetaClearToolUses20250919EditResponse as BetaClearToolUses20250919EditResponse,
type BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock,
type BetaCodeExecutionOutputBlockParam as BetaCodeExecutionOutputBlockParam,
type BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock,
type BetaCodeExecutionResultBlockParam as BetaCodeExecutionResultBlockParam,
type BetaCodeExecutionTool20250522 as BetaCodeExecutionTool20250522,
type BetaCodeExecutionTool20250825 as BetaCodeExecutionTool20250825,
type BetaCodeExecutionTool20260120 as BetaCodeExecutionTool20260120,
type BetaCodeExecutionToolResultBlock as BetaCodeExecutionToolResultBlock,
type BetaCodeExecutionToolResultBlockContent as BetaCodeExecutionToolResultBlockContent,
type BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
type BetaCodeExecutionToolResultBlockParamContent as BetaCodeExecutionToolResultBlockParamContent,
type BetaCodeExecutionToolResultError as BetaCodeExecutionToolResultError,
type BetaCodeExecutionToolResultErrorCode as BetaCodeExecutionToolResultErrorCode,
type BetaCodeExecutionToolResultErrorParam as BetaCodeExecutionToolResultErrorParam,
type BetaCompact20260112Edit as BetaCompact20260112Edit,
type BetaCompactionBlock as BetaCompactionBlock,
type BetaCompactionBlockParam as BetaCompactionBlockParam,
type BetaCompactionContentBlockDelta as BetaCompactionContentBlockDelta,
type BetaCompactionIterationUsage as BetaCompactionIterationUsage,
type BetaContainer as BetaContainer,
type BetaContainerParams as BetaContainerParams,
type BetaContainerUploadBlock as BetaContainerUploadBlock,
type BetaContainerUploadBlockParam as BetaContainerUploadBlockParam,
type BetaContentBlock as BetaContentBlock,
type BetaContentBlockParam as BetaContentBlockParam,
type BetaContentBlockSource as BetaContentBlockSource,
type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
type BetaContextManagementConfig as BetaContextManagementConfig,
type BetaContextManagementResponse as BetaContextManagementResponse,
type BetaCountTokensContextManagementResponse as BetaCountTokensContextManagementResponse,
type BetaDirectCaller as BetaDirectCaller,
type BetaDocumentBlock as BetaDocumentBlock,
type BetaEncryptedCodeExecutionResultBlock as BetaEncryptedCodeExecutionResultBlock,
type BetaEncryptedCodeExecutionResultBlockParam as BetaEncryptedCodeExecutionResultBlockParam,
type BetaFileDocumentSource as BetaFileDocumentSource,
type BetaFileImageSource as BetaFileImageSource,
type BetaImageBlockParam as BetaImageBlockParam,
type BetaInputJSONDelta as BetaInputJSONDelta,
type BetaJSONOutputFormat as BetaJSONOutputFormat,
type BetaInputTokensClearAtLeast as BetaInputTokensClearAtLeast,
type BetaInputTokensTrigger as BetaInputTokensTrigger,
type BetaMCPToolConfig as BetaMCPToolConfig,
type BetaMCPToolDefaultConfig as BetaMCPToolDefaultConfig,
type BetaMCPToolResultBlock as BetaMCPToolResultBlock,
type BetaMCPToolUseBlock as BetaMCPToolUseBlock,
type BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam,
type BetaMCPToolset as BetaMCPToolset,
type BetaMemoryTool20250818 as BetaMemoryTool20250818,
type BetaMemoryTool20250818Command as BetaMemoryTool20250818Command,
type BetaMemoryTool20250818CreateCommand as BetaMemoryTool20250818CreateCommand,
type BetaMemoryTool20250818DeleteCommand as BetaMemoryTool20250818DeleteCommand,
type BetaMemoryTool20250818InsertCommand as BetaMemoryTool20250818InsertCommand,
type BetaMemoryTool20250818RenameCommand as BetaMemoryTool20250818RenameCommand,
type BetaMemoryTool20250818StrReplaceCommand as BetaMemoryTool20250818StrReplaceCommand,
type BetaMemoryTool20250818ViewCommand as BetaMemoryTool20250818ViewCommand,
type BetaMessage as BetaMessage,
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
type BetaMessageIterationUsage as BetaMessageIterationUsage,
type BetaMessageParam as BetaMessageParam,
type BetaMessageTokensCount as BetaMessageTokensCount,
type BetaMetadata as BetaMetadata,
type BetaOutputConfig as BetaOutputConfig,
type BetaPlainTextSource as BetaPlainTextSource,
type BetaRawContentBlockDelta as BetaRawContentBlockDelta,
type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
type BetaRawMessageDeltaEvent as BetaRawMessageDeltaEvent,
type BetaRawMessageStartEvent as BetaRawMessageStartEvent,
type BetaRawMessageStopEvent as BetaRawMessageStopEvent,
type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
type BetaRedactedThinkingBlock as BetaRedactedThinkingBlock,
type BetaRedactedThinkingBlockParam as BetaRedactedThinkingBlockParam,
type BetaRequestDocumentBlock as BetaRequestDocumentBlock,
type BetaRequestMCPServerToolConfiguration as BetaRequestMCPServerToolConfiguration,
type BetaRequestMCPServerURLDefinition as BetaRequestMCPServerURLDefinition,
type BetaRequestMCPToolResultBlockParam as BetaRequestMCPToolResultBlockParam,
type BetaSearchResultBlockParam as BetaSearchResultBlockParam,
type BetaServerToolCaller as BetaServerToolCaller,
type BetaServerToolCaller20260120 as BetaServerToolCaller20260120,
type BetaServerToolUsage as BetaServerToolUsage,
type BetaServerToolUseBlock as BetaServerToolUseBlock,
type BetaServerToolUseBlockParam as BetaServerToolUseBlockParam,
type BetaSignatureDelta as BetaSignatureDelta,
type BetaSkill as BetaSkill,
type BetaSkillParams as BetaSkillParams,
type BetaStopReason as BetaStopReason,
type BetaTextBlock as BetaTextBlock,
type BetaTextBlockParam as BetaTextBlockParam,
type BetaTextCitation as BetaTextCitation,
type BetaTextCitationParam as BetaTextCitationParam,
type BetaTextDelta as BetaTextDelta,
type BetaTextEditorCodeExecutionCreateResultBlock as BetaTextEditorCodeExecutionCreateResultBlock,
type BetaTextEditorCodeExecutionCreateResultBlockParam as BetaTextEditorCodeExecutionCreateResultBlockParam,
type BetaTextEditorCodeExecutionStrReplaceResultBlock as BetaTextEditorCodeExecutionStrReplaceResultBlock,
type BetaTextEditorCodeExecutionStrReplaceResultBlockParam as BetaTextEditorCodeExecutionStrReplaceResultBlockParam,
type BetaTextEditorCodeExecutionToolResultBlock as BetaTextEditorCodeExecutionToolResultBlock,
type BetaTextEditorCodeExecutionToolResultBlockParam as BetaTextEditorCodeExecutionToolResultBlockParam,
type BetaTextEditorCodeExecutionToolResultError as BetaTextEditorCodeExecutionToolResultError,
type BetaTextEditorCodeExecutionToolResultErrorParam as BetaTextEditorCodeExecutionToolResultErrorParam,
type BetaTextEditorCodeExecutionViewResultBlock as BetaTextEditorCodeExecutionViewResultBlock,
type BetaTextEditorCodeExecutionViewResultBlockParam as BetaTextEditorCodeExecutionViewResultBlockParam,
type BetaThinkingBlock as BetaThinkingBlock,
type BetaThinkingBlockParam as BetaThinkingBlockParam,
type BetaThinkingConfigAdaptive as BetaThinkingConfigAdaptive,
type BetaThinkingConfigDisabled as BetaThinkingConfigDisabled,
type BetaThinkingConfigEnabled as BetaThinkingConfigEnabled,
type BetaThinkingConfigParam as BetaThinkingConfigParam,
type BetaThinkingDelta as BetaThinkingDelta,
type BetaThinkingTurns as BetaThinkingTurns,
type BetaTool as BetaTool,
type BetaToolBash20241022 as BetaToolBash20241022,
type BetaToolBash20250124 as BetaToolBash20250124,
type BetaToolChoice as BetaToolChoice,
type BetaToolChoiceAny as BetaToolChoiceAny,
type BetaToolChoiceAuto as BetaToolChoiceAuto,
type BetaToolChoiceNone as BetaToolChoiceNone,
type BetaToolChoiceTool as BetaToolChoiceTool,
type BetaToolComputerUse20241022 as BetaToolComputerUse20241022,
type BetaToolComputerUse20250124 as BetaToolComputerUse20250124,
type BetaToolComputerUse20251124 as BetaToolComputerUse20251124,
type BetaToolReferenceBlock as BetaToolReferenceBlock,
type BetaToolReferenceBlockParam as BetaToolReferenceBlockParam,
type BetaToolResultBlockParam as BetaToolResultBlockParam,
type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
type BetaToolTextEditor20250124 as BetaToolTextEditor20250124,
type BetaToolTextEditor20250429 as BetaToolTextEditor20250429,
type BetaToolTextEditor20250728 as BetaToolTextEditor20250728,
type BetaToolUnion as BetaToolUnion,
type BetaToolUseBlock as BetaToolUseBlock,
type BetaToolUseBlockParam as BetaToolUseBlockParam,
type BetaToolUsesKeep as BetaToolUsesKeep,
type BetaToolUsesTrigger as BetaToolUsesTrigger,
type BetaURLImageSource as BetaURLImageSource,
type BetaURLPDFSource as BetaURLPDFSource,
type BetaUsage as BetaUsage,
type BetaUserLocation as BetaUserLocation,
type BetaWebFetchBlock as BetaWebFetchBlock,
type BetaWebFetchBlockParam as BetaWebFetchBlockParam,
type BetaWebFetchTool20250910 as BetaWebFetchTool20250910,
type BetaWebFetchTool20260209 as BetaWebFetchTool20260209,
type BetaWebFetchTool20260309 as BetaWebFetchTool20260309,
type BetaWebFetchToolResultBlock as BetaWebFetchToolResultBlock,
type BetaWebFetchToolResultBlockParam as BetaWebFetchToolResultBlockParam,
type BetaWebFetchToolResultErrorBlock as BetaWebFetchToolResultErrorBlock,
type BetaWebFetchToolResultErrorBlockParam as BetaWebFetchToolResultErrorBlockParam,
type BetaWebFetchToolResultErrorCode as BetaWebFetchToolResultErrorCode,
type BetaWebSearchResultBlock as BetaWebSearchResultBlock,
type BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam,
type BetaWebSearchTool20250305 as BetaWebSearchTool20250305,
type BetaWebSearchTool20260209 as BetaWebSearchTool20260209,
type BetaWebSearchToolRequestError as BetaWebSearchToolRequestError,
type BetaWebSearchToolResultBlock as BetaWebSearchToolResultBlock,
type BetaWebSearchToolResultBlockContent as BetaWebSearchToolResultBlockContent,
type BetaWebSearchToolResultBlockParam as BetaWebSearchToolResultBlockParam,
type BetaWebSearchToolResultBlockParamContent as BetaWebSearchToolResultBlockParamContent,
type BetaWebSearchToolResultError as BetaWebSearchToolResultError,
type BetaWebSearchToolResultErrorCode as BetaWebSearchToolResultErrorCode,
type BetaBase64PDFBlock as BetaBase64PDFBlock,
type MessageCreateParams as MessageCreateParams,
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
type MessageCountTokensParams as MessageCountTokensParams,
};
export {
Files as Files,
type DeletedFile as DeletedFile,
type FileMetadata as FileMetadata,
type FileMetadataPage as FileMetadataPage,
type FileListParams as FileListParams,
type FileDeleteParams as FileDeleteParams,
type FileDownloadParams as FileDownloadParams,
type FileRetrieveMetadataParams as FileRetrieveMetadataParams,
type FileUploadParams as FileUploadParams,
};
export {
Skills as Skills,
type SkillCreateResponse as SkillCreateResponse,
type SkillRetrieveResponse as SkillRetrieveResponse,
type SkillListResponse as SkillListResponse,
type SkillDeleteResponse as SkillDeleteResponse,
type SkillListResponsesPageCursor as SkillListResponsesPageCursor,
type SkillCreateParams as SkillCreateParams,
type SkillRetrieveParams as SkillRetrieveParams,
type SkillListParams as SkillListParams,
type SkillDeleteParams as SkillDeleteParams,
};
}

View File

@@ -0,0 +1,261 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as BetaAPI from './beta';
import { APIPromise } from '../../core/api-promise';
import { Page, type PageParams, PagePromise } from '../../core/pagination';
import { type Uploadable } from '../../core/uploads';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { stainlessHelperHeaderFromFile } from '../../lib/stainless-helper-header';
import { multipartFormRequestOptions } from '../../internal/uploads';
import { path } from '../../internal/utils/path';
export class Files extends APIResource {
/**
* List Files
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const fileMetadata of client.beta.files.list()) {
* // ...
* }
* ```
*/
list(
params: FileListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<FileMetadataPage, FileMetadata> {
const { betas, ...query } = params ?? {};
return this._client.getAPIList('/v1/files', Page<FileMetadata>, {
query,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
options?.headers,
]),
});
}
/**
* Delete File
*
* @example
* ```ts
* const deletedFile = await client.beta.files.delete(
* 'file_id',
* );
* ```
*/
delete(
fileID: string,
params: FileDeleteParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<DeletedFile> {
const { betas } = params ?? {};
return this._client.delete(path`/v1/files/${fileID}`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
options?.headers,
]),
});
}
/**
* Download File
*
* @example
* ```ts
* const response = await client.beta.files.download(
* 'file_id',
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
download(
fileID: string,
params: FileDownloadParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<Response> {
const { betas } = params ?? {};
return this._client.get(path`/v1/files/${fileID}/content`, {
...options,
headers: buildHeaders([
{
'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString(),
Accept: 'application/binary',
},
options?.headers,
]),
__binaryResponse: true,
});
}
/**
* Get File Metadata
*
* @example
* ```ts
* const fileMetadata =
* await client.beta.files.retrieveMetadata('file_id');
* ```
*/
retrieveMetadata(
fileID: string,
params: FileRetrieveMetadataParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<FileMetadata> {
const { betas } = params ?? {};
return this._client.get(path`/v1/files/${fileID}`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
options?.headers,
]),
});
}
/**
* Upload File
*
* @example
* ```ts
* const fileMetadata = await client.beta.files.upload({
* file: fs.createReadStream('path/to/file'),
* });
* ```
*/
upload(params: FileUploadParams, options?: RequestOptions): APIPromise<FileMetadata> {
const { betas, ...body } = params;
return this._client.post(
'/v1/files',
multipartFormRequestOptions(
{
body,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'files-api-2025-04-14'].toString() },
stainlessHelperHeaderFromFile(body.file),
options?.headers,
]),
},
this._client,
),
);
}
}
export type FileMetadataPage = Page<FileMetadata>;
export interface DeletedFile {
/**
* ID of the deleted file.
*/
id: string;
/**
* Deleted object type.
*
* For file deletion, this is always `"file_deleted"`.
*/
type?: 'file_deleted';
}
export interface FileMetadata {
/**
* Unique object identifier.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* RFC 3339 datetime string representing when the file was created.
*/
created_at: string;
/**
* Original filename of the uploaded file.
*/
filename: string;
/**
* MIME type of the file.
*/
mime_type: string;
/**
* Size of the file in bytes.
*/
size_bytes: number;
/**
* Object type.
*
* For files, this is always `"file"`.
*/
type: 'file';
/**
* Whether the file can be downloaded.
*/
downloadable?: boolean;
}
export interface FileListParams extends PageParams {
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface FileDeleteParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface FileDownloadParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface FileRetrieveMetadataParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface FileUploadParams {
/**
* Body param: The file to upload
*/
file: Uploadable;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export declare namespace Files {
export {
type DeletedFile as DeletedFile,
type FileMetadata as FileMetadata,
type FileMetadataPage as FileMetadataPage,
type FileListParams as FileListParams,
type FileDeleteParams as FileDeleteParams,
type FileDownloadParams as FileDownloadParams,
type FileRetrieveMetadataParams as FileRetrieveMetadataParams,
type FileUploadParams as FileUploadParams,
};
}

View File

@@ -0,0 +1,258 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export {
Beta,
type AnthropicBeta,
type BetaAPIError,
type BetaAuthenticationError,
type BetaBillingError,
type BetaError,
type BetaErrorResponse,
type BetaGatewayTimeoutError,
type BetaInvalidRequestError,
type BetaNotFoundError,
type BetaOverloadedError,
type BetaPermissionError,
type BetaRateLimitError,
} from './beta';
export {
Files,
type DeletedFile,
type FileMetadata,
type FileListParams,
type FileDeleteParams,
type FileDownloadParams,
type FileRetrieveMetadataParams,
type FileUploadParams,
type FileMetadataPage,
} from './files';
export {
Messages,
type BetaAllThinkingTurns,
type BetaBase64ImageSource,
type BetaBase64PDFSource,
type BetaBashCodeExecutionOutputBlock,
type BetaBashCodeExecutionOutputBlockParam,
type BetaBashCodeExecutionResultBlock,
type BetaBashCodeExecutionResultBlockParam,
type BetaBashCodeExecutionToolResultBlock,
type BetaBashCodeExecutionToolResultBlockParam,
type BetaBashCodeExecutionToolResultError,
type BetaBashCodeExecutionToolResultErrorParam,
type BetaCacheControlEphemeral,
type BetaCacheCreation,
type BetaCitationCharLocation,
type BetaCitationCharLocationParam,
type BetaCitationConfig,
type BetaCitationContentBlockLocation,
type BetaCitationContentBlockLocationParam,
type BetaCitationPageLocation,
type BetaCitationPageLocationParam,
type BetaCitationSearchResultLocation,
type BetaCitationSearchResultLocationParam,
type BetaCitationWebSearchResultLocationParam,
type BetaCitationsConfigParam,
type BetaCitationsDelta,
type BetaCitationsWebSearchResultLocation,
type BetaClearThinking20251015Edit,
type BetaClearThinking20251015EditResponse,
type BetaClearToolUses20250919Edit,
type BetaClearToolUses20250919EditResponse,
type BetaCodeExecutionOutputBlock,
type BetaCodeExecutionOutputBlockParam,
type BetaCodeExecutionResultBlock,
type BetaCodeExecutionResultBlockParam,
type BetaCodeExecutionTool20250522,
type BetaCodeExecutionTool20250825,
type BetaCodeExecutionTool20260120,
type BetaCodeExecutionToolResultBlock,
type BetaCodeExecutionToolResultBlockContent,
type BetaCodeExecutionToolResultBlockParam,
type BetaCodeExecutionToolResultBlockParamContent,
type BetaCodeExecutionToolResultError,
type BetaCodeExecutionToolResultErrorCode,
type BetaCodeExecutionToolResultErrorParam,
type BetaCompact20260112Edit,
type BetaCompactionBlock,
type BetaCompactionBlockParam,
type BetaCompactionContentBlockDelta,
type BetaCompactionIterationUsage,
type BetaContainer,
type BetaContainerParams,
type BetaContainerUploadBlock,
type BetaContainerUploadBlockParam,
type BetaContentBlock,
type BetaContentBlockParam,
type BetaContentBlockSource,
type BetaContentBlockSourceContent,
type BetaContextManagementConfig,
type BetaContextManagementResponse,
type BetaCountTokensContextManagementResponse,
type BetaDirectCaller,
type BetaDocumentBlock,
type BetaEncryptedCodeExecutionResultBlock,
type BetaEncryptedCodeExecutionResultBlockParam,
type BetaFileDocumentSource,
type BetaFileImageSource,
type BetaImageBlockParam,
type BetaInputJSONDelta,
type BetaInputTokensClearAtLeast,
type BetaInputTokensTrigger,
type BetaJSONOutputFormat,
type BetaMCPToolConfig,
type BetaMCPToolDefaultConfig,
type BetaMCPToolResultBlock,
type BetaMCPToolUseBlock,
type BetaMCPToolUseBlockParam,
type BetaMCPToolset,
type BetaMemoryTool20250818,
type BetaMemoryTool20250818Command,
type BetaMemoryTool20250818CreateCommand,
type BetaMemoryTool20250818DeleteCommand,
type BetaMemoryTool20250818InsertCommand,
type BetaMemoryTool20250818RenameCommand,
type BetaMemoryTool20250818StrReplaceCommand,
type BetaMemoryTool20250818ViewCommand,
type BetaMessage,
type BetaMessageDeltaUsage,
type BetaMessageIterationUsage,
type BetaMessageParam,
type BetaMessageTokensCount,
type BetaMetadata,
type BetaOutputConfig,
type BetaPlainTextSource,
type BetaRawContentBlockDelta,
type BetaRawContentBlockDeltaEvent,
type BetaRawContentBlockStartEvent,
type BetaRawContentBlockStopEvent,
type BetaRawMessageDeltaEvent,
type BetaRawMessageStartEvent,
type BetaRawMessageStopEvent,
type BetaRawMessageStreamEvent,
type BetaRedactedThinkingBlock,
type BetaRedactedThinkingBlockParam,
type BetaRequestDocumentBlock,
type BetaRequestMCPServerToolConfiguration,
type BetaRequestMCPServerURLDefinition,
type BetaRequestMCPToolResultBlockParam,
type BetaSearchResultBlockParam,
type BetaServerToolCaller,
type BetaServerToolCaller20260120,
type BetaServerToolUsage,
type BetaServerToolUseBlock,
type BetaServerToolUseBlockParam,
type BetaSignatureDelta,
type BetaSkill,
type BetaSkillParams,
type BetaStopReason,
type BetaTextBlock,
type BetaTextBlockParam,
type BetaTextCitation,
type BetaTextCitationParam,
type BetaTextDelta,
type BetaTextEditorCodeExecutionCreateResultBlock,
type BetaTextEditorCodeExecutionCreateResultBlockParam,
type BetaTextEditorCodeExecutionStrReplaceResultBlock,
type BetaTextEditorCodeExecutionStrReplaceResultBlockParam,
type BetaTextEditorCodeExecutionToolResultBlock,
type BetaTextEditorCodeExecutionToolResultBlockParam,
type BetaTextEditorCodeExecutionToolResultError,
type BetaTextEditorCodeExecutionToolResultErrorParam,
type BetaTextEditorCodeExecutionViewResultBlock,
type BetaTextEditorCodeExecutionViewResultBlockParam,
type BetaThinkingBlock,
type BetaThinkingBlockParam,
type BetaThinkingConfigAdaptive,
type BetaThinkingConfigDisabled,
type BetaThinkingConfigEnabled,
type BetaThinkingConfigParam,
type BetaThinkingDelta,
type BetaThinkingTurns,
type BetaTool,
type BetaToolBash20241022,
type BetaToolBash20250124,
type BetaToolChoice,
type BetaToolChoiceAny,
type BetaToolChoiceAuto,
type BetaToolChoiceNone,
type BetaToolChoiceTool,
type BetaToolComputerUse20241022,
type BetaToolComputerUse20250124,
type BetaToolComputerUse20251124,
type BetaToolReferenceBlock,
type BetaToolReferenceBlockParam,
type BetaToolResultBlockParam,
type BetaToolSearchToolBm25_20251119,
type BetaToolSearchToolRegex20251119,
type BetaToolSearchToolResultBlock,
type BetaToolSearchToolResultBlockParam,
type BetaToolSearchToolResultError,
type BetaToolSearchToolResultErrorParam,
type BetaToolSearchToolSearchResultBlock,
type BetaToolSearchToolSearchResultBlockParam,
type BetaToolTextEditor20241022,
type BetaToolTextEditor20250124,
type BetaToolTextEditor20250429,
type BetaToolTextEditor20250728,
type BetaToolUnion,
type BetaToolUseBlock,
type BetaToolUseBlockParam,
type BetaToolUsesKeep,
type BetaToolUsesTrigger,
type BetaURLImageSource,
type BetaURLPDFSource,
type BetaUsage,
type BetaUserLocation,
type BetaWebFetchBlock,
type BetaWebFetchBlockParam,
type BetaWebFetchTool20250910,
type BetaWebFetchTool20260209,
type BetaWebFetchTool20260309,
type BetaWebFetchToolResultBlock,
type BetaWebFetchToolResultBlockParam,
type BetaWebFetchToolResultErrorBlock,
type BetaWebFetchToolResultErrorBlockParam,
type BetaWebFetchToolResultErrorCode,
type BetaWebSearchResultBlock,
type BetaWebSearchResultBlockParam,
type BetaWebSearchTool20250305,
type BetaWebSearchTool20260209,
type BetaWebSearchToolRequestError,
type BetaWebSearchToolResultBlock,
type BetaWebSearchToolResultBlockContent,
type BetaWebSearchToolResultBlockParam,
type BetaWebSearchToolResultBlockParamContent,
type BetaWebSearchToolResultError,
type BetaWebSearchToolResultErrorCode,
type BetaBase64PDFBlock,
type MessageCreateParams,
type MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming,
type MessageCountTokensParams,
type BetaToolResultContentBlockParam,
} from './messages/index';
export {
Models,
type BetaCapabilitySupport,
type BetaContextManagementCapability,
type BetaEffortCapability,
type BetaModelCapabilities,
type BetaModelInfo,
type BetaThinkingCapability,
type BetaThinkingTypes,
type ModelRetrieveParams,
type ModelListParams,
type BetaModelInfosPage,
} from './models';
export {
Skills,
type SkillCreateResponse,
type SkillRetrieveResponse,
type SkillListResponse,
type SkillDeleteResponse,
type SkillCreateParams,
type SkillRetrieveParams,
type SkillListParams,
type SkillDeleteParams,
type SkillListResponsesPageCursor,
} from './skills/index';

View File

@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from './messages/index';

View File

@@ -0,0 +1,827 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import * as BetaAPI from '../beta';
import { APIPromise } from '../../../core/api-promise';
import * as BetaMessagesAPI from './messages';
import { Page, type PageParams, PagePromise } from '../../../core/pagination';
import { buildHeaders } from '../../../internal/headers';
import { RequestOptions } from '../../../internal/request-options';
import { JSONLDecoder } from '../../../internal/decoders/jsonl';
import { AnthropicError } from '../../../error';
import { path } from '../../../internal/utils/path';
import * as MessagesApi from '../../messages/messages';
export class Batches extends APIResource {
/**
* Send a batch of Message creation requests.
*
* The Message Batches API can be used to process multiple Messages API requests at
* once. Once a Message Batch is created, it begins processing immediately. Batches
* can take up to 24 hours to complete.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatch =
* await client.beta.messages.batches.create({
* requests: [
* {
* custom_id: 'my-custom-id-1',
* params: {
* max_tokens: 1024,
* messages: [
* { content: 'Hello, world', role: 'user' },
* ],
* model: 'claude-opus-4-6',
* },
* },
* ],
* });
* ```
*/
create(params: BatchCreateParams, options?: RequestOptions): APIPromise<BetaMessageBatch> {
const { betas, ...body } = params;
return this._client.post('/v1/messages/batches?beta=true', {
body,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString() },
options?.headers,
]),
});
}
/**
* This endpoint is idempotent and can be used to poll for Message Batch
* completion. To access the results of a Message Batch, make a request to the
* `results_url` field in the response.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatch =
* await client.beta.messages.batches.retrieve(
* 'message_batch_id',
* );
* ```
*/
retrieve(
messageBatchID: string,
params: BatchRetrieveParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<BetaMessageBatch> {
const { betas } = params ?? {};
return this._client.get(path`/v1/messages/batches/${messageBatchID}?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString() },
options?.headers,
]),
});
}
/**
* List all Message Batches within a Workspace. Most recently created batches are
* returned first.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const betaMessageBatch of client.beta.messages.batches.list()) {
* // ...
* }
* ```
*/
list(
params: BatchListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<BetaMessageBatchesPage, BetaMessageBatch> {
const { betas, ...query } = params ?? {};
return this._client.getAPIList('/v1/messages/batches?beta=true', Page<BetaMessageBatch>, {
query,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString() },
options?.headers,
]),
});
}
/**
* Delete a Message Batch.
*
* Message Batches can only be deleted once they've finished processing. If you'd
* like to delete an in-progress batch, you must first cancel it.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaDeletedMessageBatch =
* await client.beta.messages.batches.delete(
* 'message_batch_id',
* );
* ```
*/
delete(
messageBatchID: string,
params: BatchDeleteParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<BetaDeletedMessageBatch> {
const { betas } = params ?? {};
return this._client.delete(path`/v1/messages/batches/${messageBatchID}?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString() },
options?.headers,
]),
});
}
/**
* Batches may be canceled any time before processing ends. Once cancellation is
* initiated, the batch enters a `canceling` state, at which time the system may
* complete any in-progress, non-interruptible requests before finalizing
* cancellation.
*
* The number of canceled requests is specified in `request_counts`. To determine
* which requests were canceled, check the individual results within the batch.
* Note that cancellation may not result in any canceled requests if they were
* non-interruptible.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatch =
* await client.beta.messages.batches.cancel(
* 'message_batch_id',
* );
* ```
*/
cancel(
messageBatchID: string,
params: BatchCancelParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<BetaMessageBatch> {
const { betas } = params ?? {};
return this._client.post(path`/v1/messages/batches/${messageBatchID}/cancel?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString() },
options?.headers,
]),
});
}
/**
* Streams the results of a Message Batch as a `.jsonl` file.
*
* Each line in the file is a JSON object containing the result of a single request
* in the Message Batch. Results are not guaranteed to be in the same order as
* requests. Use the `custom_id` field to match results to requests.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatchIndividualResponse =
* await client.beta.messages.batches.results(
* 'message_batch_id',
* );
* ```
*/
async results(
messageBatchID: string,
params: BatchResultsParams | undefined = {},
options?: RequestOptions,
): Promise<JSONLDecoder<BetaMessageBatchIndividualResponse>> {
const batch = await this.retrieve(messageBatchID);
if (!batch.results_url) {
throw new AnthropicError(
`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`,
);
}
const { betas } = params ?? {};
return this._client
.get(batch.results_url, {
...options,
headers: buildHeaders([
{
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
Accept: 'application/binary',
},
options?.headers,
]),
stream: true,
__binaryResponse: true,
})
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller)) as APIPromise<
JSONLDecoder<BetaMessageBatchIndividualResponse>
>;
}
}
export type BetaMessageBatchesPage = Page<BetaMessageBatch>;
export interface BetaDeletedMessageBatch {
/**
* ID of the Message Batch.
*/
id: string;
/**
* Deleted object type.
*
* For Message Batches, this is always `"message_batch_deleted"`.
*/
type: 'message_batch_deleted';
}
export interface BetaMessageBatch {
/**
* Unique object identifier.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* RFC 3339 datetime string representing the time at which the Message Batch was
* archived and its results became unavailable.
*/
archived_at: string | null;
/**
* RFC 3339 datetime string representing the time at which cancellation was
* initiated for the Message Batch. Specified only if cancellation was initiated.
*/
cancel_initiated_at: string | null;
/**
* RFC 3339 datetime string representing the time at which the Message Batch was
* created.
*/
created_at: string;
/**
* RFC 3339 datetime string representing the time at which processing for the
* Message Batch ended. Specified only once processing ends.
*
* Processing ends when every request in a Message Batch has either succeeded,
* errored, canceled, or expired.
*/
ended_at: string | null;
/**
* RFC 3339 datetime string representing the time at which the Message Batch will
* expire and end processing, which is 24 hours after creation.
*/
expires_at: string;
/**
* Processing status of the Message Batch.
*/
processing_status: 'in_progress' | 'canceling' | 'ended';
/**
* Tallies requests within the Message Batch, categorized by their status.
*
* Requests start as `processing` and move to one of the other statuses only once
* processing of the entire batch ends. The sum of all values always matches the
* total number of requests in the batch.
*/
request_counts: BetaMessageBatchRequestCounts;
/**
* URL to a `.jsonl` file containing the results of the Message Batch requests.
* Specified only once processing ends.
*
* Results in the file are not guaranteed to be in the same order as requests. Use
* the `custom_id` field to match results to requests.
*/
results_url: string | null;
/**
* Object type.
*
* For Message Batches, this is always `"message_batch"`.
*/
type: 'message_batch';
}
export interface BetaMessageBatchCanceledResult {
type: 'canceled';
}
export interface BetaMessageBatchErroredResult {
error: BetaAPI.BetaErrorResponse;
type: 'errored';
}
export interface BetaMessageBatchExpiredResult {
type: 'expired';
}
/**
* This is a single line in the response `.jsonl` file and does not represent the
* response as a whole.
*/
export interface BetaMessageBatchIndividualResponse {
/**
* Developer-provided ID created for each request in a Message Batch. Useful for
* matching results to requests, as results may be given out of request order.
*
* Must be unique for each request within the Message Batch.
*/
custom_id: string;
/**
* Processing result for this request.
*
* Contains a Message output if processing was successful, an error response if
* processing failed, or the reason why processing was not attempted, such as
* cancellation or expiration.
*/
result: BetaMessageBatchResult;
}
export interface BetaMessageBatchRequestCounts {
/**
* Number of requests in the Message Batch that have been canceled.
*
* This is zero until processing of the entire Message Batch has ended.
*/
canceled: number;
/**
* Number of requests in the Message Batch that encountered an error.
*
* This is zero until processing of the entire Message Batch has ended.
*/
errored: number;
/**
* Number of requests in the Message Batch that have expired.
*
* This is zero until processing of the entire Message Batch has ended.
*/
expired: number;
/**
* Number of requests in the Message Batch that are processing.
*/
processing: number;
/**
* Number of requests in the Message Batch that have completed successfully.
*
* This is zero until processing of the entire Message Batch has ended.
*/
succeeded: number;
}
/**
* Processing result for this request.
*
* Contains a Message output if processing was successful, an error response if
* processing failed, or the reason why processing was not attempted, such as
* cancellation or expiration.
*/
export type BetaMessageBatchResult =
| BetaMessageBatchSucceededResult
| BetaMessageBatchErroredResult
| BetaMessageBatchCanceledResult
| BetaMessageBatchExpiredResult;
export interface BetaMessageBatchSucceededResult {
message: BetaMessagesAPI.BetaMessage;
type: 'succeeded';
}
export interface BatchCreateParams {
/**
* Body param: List of requests for prompt completion. Each is an individual
* request to create a Message.
*/
requests: Array<BatchCreateParams.Request>;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export namespace BatchCreateParams {
export interface Request {
/**
* Developer-provided ID created for each request in a Message Batch. Useful for
* matching results to requests, as results may be given out of request order.
*
* Must be unique for each request within the Message Batch.
*/
custom_id: string;
/**
* Messages API creation parameters for the individual request.
*
* See the [Messages API reference](https://docs.claude.com/en/api/messages) for
* full documentation on available parameters.
*/
params: Request.Params;
}
export namespace Request {
/**
* Messages API creation parameters for the individual request.
*
* See the [Messages API reference](https://docs.claude.com/en/api/messages) for
* full documentation on available parameters.
*/
export interface Params {
/**
* The maximum number of tokens to generate before stopping.
*
* Note that our models may stop _before_ reaching this maximum. This parameter
* only specifies the absolute maximum number of tokens to generate.
*
* Different models have different maximum values for this parameter. See
* [models](https://docs.claude.com/en/docs/models-overview) for details.
*/
max_tokens: number;
/**
* Input messages.
*
* Our models are trained to operate on alternating `user` and `assistant`
* conversational turns. When creating a new `Message`, you specify the prior
* conversational turns with the `messages` parameter, and the model then generates
* the next `Message` in the conversation. Consecutive `user` or `assistant` turns
* in your request will be combined into a single turn.
*
* Each input message must be an object with a `role` and `content`. You can
* specify a single `user`-role message, or you can include multiple `user` and
* `assistant` messages.
*
* If the final message uses the `assistant` role, the response content will
* continue immediately from the content in that message. This can be used to
* constrain part of the model's response.
*
* Example with a single `user` message:
*
* ```json
* [{ "role": "user", "content": "Hello, Claude" }]
* ```
*
* Example with multiple conversational turns:
*
* ```json
* [
* { "role": "user", "content": "Hello there." },
* { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
* { "role": "user", "content": "Can you explain LLMs in plain English?" }
* ]
* ```
*
* Example with a partially-filled response from Claude:
*
* ```json
* [
* {
* "role": "user",
* "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
* },
* { "role": "assistant", "content": "The best answer is (" }
* ]
* ```
*
* Each input message `content` may be either a single `string` or an array of
* content blocks, where each block has a specific `type`. Using a `string` for
* `content` is shorthand for an array of one content block of type `"text"`. The
* following input messages are equivalent:
*
* ```json
* { "role": "user", "content": "Hello, Claude" }
* ```
*
* ```json
* { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
* ```
*
* See [input examples](https://docs.claude.com/en/api/messages-examples).
*
* Note that if you want to include a
* [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the
* top-level `system` parameter — there is no `"system"` role for input messages in
* the Messages API.
*
* There is a limit of 100,000 messages in a single request.
*/
messages: Array<BetaMessagesAPI.BetaMessageParam>;
/**
* The model that will complete your prompt.\n\nSee
* [models](https://docs.anthropic.com/en/docs/models-overview) for additional
* details and options.
*/
model: MessagesApi.Model;
/**
* Top-level cache control automatically applies a cache_control marker to the last
* cacheable block in the request.
*/
cache_control?: BetaMessagesAPI.BetaCacheControlEphemeral | null;
/**
* Container identifier for reuse across requests.
*/
container?: BetaMessagesAPI.BetaContainerParams | string | null;
/**
* Context management configuration.
*
* This allows you to control how Claude manages context across multiple requests,
* such as whether to clear function results or not.
*/
context_management?: BetaMessagesAPI.BetaContextManagementConfig | null;
/**
* Specifies the geographic region for inference processing. If not specified, the
* workspace's `default_inference_geo` is used.
*/
inference_geo?: string | null;
/**
* MCP servers to be utilized in this request
*/
mcp_servers?: Array<BetaMessagesAPI.BetaRequestMCPServerURLDefinition>;
/**
* An object describing metadata about the request.
*/
metadata?: BetaMessagesAPI.BetaMetadata;
/**
* Configuration options for the model's output, such as the output format.
*/
output_config?: BetaMessagesAPI.BetaOutputConfig;
/**
* @deprecated Deprecated: Use `output_config.format` instead. See
* [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
*
* A schema to specify Claude's output format in responses. This parameter will be
* removed in a future release.
*/
output_format?: BetaMessagesAPI.BetaJSONOutputFormat | null;
/**
* Determines whether to use priority capacity (if available) or standard capacity
* for this request.
*
* Anthropic offers different levels of service for your API requests. See
* [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
*/
service_tier?: 'auto' | 'standard_only';
/**
* The inference speed mode for this request. `"fast"` enables high
* output-tokens-per-second inference.
*/
speed?: 'standard' | 'fast' | null;
/**
* Custom text sequences that will cause the model to stop generating.
*
* Our models will normally stop when they have naturally completed their turn,
* which will result in a response `stop_reason` of `"end_turn"`.
*
* If you want the model to stop generating when it encounters custom strings of
* text, you can use the `stop_sequences` parameter. If the model encounters one of
* the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
* and the response `stop_sequence` value will contain the matched stop sequence.
*/
stop_sequences?: Array<string>;
/**
* Whether to incrementally stream the response using server-sent events.
*
* See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
*/
stream?: boolean;
/**
* System prompt.
*
* A system prompt is a way of providing context and instructions to Claude, such
* as specifying a particular goal or role. See our
* [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
*/
system?: string | Array<BetaMessagesAPI.BetaTextBlockParam>;
/**
* Amount of randomness injected into the response.
*
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
* for analytical / multiple choice, and closer to `1.0` for creative and
* generative tasks.
*
* Note that even with `temperature` of `0.0`, the results will not be fully
* deterministic.
*/
temperature?: number;
/**
* Configuration for enabling Claude's extended thinking.
*
* When enabled, responses include `thinking` content blocks showing Claude's
* thinking process before the final answer. Requires a minimum budget of 1,024
* tokens and counts towards your `max_tokens` limit.
*
* See
* [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
* for details.
*/
thinking?: BetaMessagesAPI.BetaThinkingConfigParam;
/**
* How the model should use the provided tools. The model can use a specific tool,
* any available tool, decide by itself, or not use tools at all.
*/
tool_choice?: BetaMessagesAPI.BetaToolChoice;
/**
* Definitions of tools that the model may use.
*
* If you include `tools` in your API request, the model may return `tool_use`
* content blocks that represent the model's use of those tools. You can then run
* those tools using the tool input generated by the model and then optionally
* return results back to the model using `tool_result` content blocks.
*
* There are two types of tools: **client tools** and **server tools**. The
* behavior described below applies to client tools. For
* [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
* see their individual documentation as each has its own behavior (e.g., the
* [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
*
* Each tool definition includes:
*
* - `name`: Name of the tool.
* - `description`: Optional, but strongly-recommended description of the tool.
* - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
* tool `input` shape that the model will produce in `tool_use` output content
* blocks.
*
* For example, if you defined `tools` as:
*
* ```json
* [
* {
* "name": "get_stock_price",
* "description": "Get the current stock price for a given ticker symbol.",
* "input_schema": {
* "type": "object",
* "properties": {
* "ticker": {
* "type": "string",
* "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
* }
* },
* "required": ["ticker"]
* }
* }
* ]
* ```
*
* And then asked the model "What's the S&P 500 at today?", the model might produce
* `tool_use` content blocks in the response like this:
*
* ```json
* [
* {
* "type": "tool_use",
* "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
* "name": "get_stock_price",
* "input": { "ticker": "^GSPC" }
* }
* ]
* ```
*
* You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
* input, and return the following back to the model in a subsequent `user`
* message:
*
* ```json
* [
* {
* "type": "tool_result",
* "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
* "content": "259.75 USD"
* }
* ]
* ```
*
* Tools can be used for workflows that include running client-side tools and
* functions, or more generally whenever you want the model to produce a particular
* JSON structure of output.
*
* See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
*/
tools?: Array<BetaMessagesAPI.BetaToolUnion>;
/**
* Only sample from the top K options for each subsequent token.
*
* Used to remove "long tail" low probability responses.
* [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
*
* Recommended for advanced use cases only. You usually only need to use
* `temperature`.
*/
top_k?: number;
/**
* Use nucleus sampling.
*
* In nucleus sampling, we compute the cumulative distribution over all the options
* for each subsequent token in decreasing probability order and cut it off once it
* reaches a particular probability specified by `top_p`. You should either alter
* `temperature` or `top_p`, but not both.
*
* Recommended for advanced use cases only. You usually only need to use
* `temperature`.
*/
top_p?: number;
}
}
}
export interface BatchRetrieveParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface BatchListParams extends PageParams {
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface BatchDeleteParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface BatchCancelParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface BatchResultsParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export declare namespace Batches {
export {
type BetaDeletedMessageBatch as BetaDeletedMessageBatch,
type BetaMessageBatch as BetaMessageBatch,
type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult,
type BetaMessageBatchExpiredResult as BetaMessageBatchExpiredResult,
type BetaMessageBatchIndividualResponse as BetaMessageBatchIndividualResponse,
type BetaMessageBatchRequestCounts as BetaMessageBatchRequestCounts,
type BetaMessageBatchResult as BetaMessageBatchResult,
type BetaMessageBatchSucceededResult as BetaMessageBatchSucceededResult,
type BetaMessageBatchesPage as BetaMessageBatchesPage,
type BatchCreateParams as BatchCreateParams,
type BatchRetrieveParams as BatchRetrieveParams,
type BatchListParams as BatchListParams,
type BatchDeleteParams as BatchDeleteParams,
type BatchCancelParams as BatchCancelParams,
type BatchResultsParams as BatchResultsParams,
};
}

View File

@@ -0,0 +1,228 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export {
Batches,
type BetaDeletedMessageBatch,
type BetaMessageBatch,
type BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult,
type BetaMessageBatchExpiredResult,
type BetaMessageBatchIndividualResponse,
type BetaMessageBatchRequestCounts,
type BetaMessageBatchResult,
type BetaMessageBatchSucceededResult,
type BatchCreateParams,
type BatchRetrieveParams,
type BatchListParams,
type BatchDeleteParams,
type BatchCancelParams,
type BatchResultsParams,
type BetaMessageBatchesPage,
} from './batches';
export {
Messages,
type BetaAllThinkingTurns,
type BetaBase64ImageSource,
type BetaBase64PDFSource,
type BetaBashCodeExecutionOutputBlock,
type BetaBashCodeExecutionOutputBlockParam,
type BetaBashCodeExecutionResultBlock,
type BetaBashCodeExecutionResultBlockParam,
type BetaBashCodeExecutionToolResultBlock,
type BetaBashCodeExecutionToolResultBlockParam,
type BetaBashCodeExecutionToolResultError,
type BetaBashCodeExecutionToolResultErrorParam,
type BetaCacheControlEphemeral,
type BetaCacheCreation,
type BetaCitationCharLocation,
type BetaCitationCharLocationParam,
type BetaCitationConfig,
type BetaCitationContentBlockLocation,
type BetaCitationContentBlockLocationParam,
type BetaCitationPageLocation,
type BetaCitationPageLocationParam,
type BetaCitationSearchResultLocation,
type BetaCitationSearchResultLocationParam,
type BetaCitationWebSearchResultLocationParam,
type BetaCitationsConfigParam,
type BetaCitationsDelta,
type BetaCitationsWebSearchResultLocation,
type BetaClearThinking20251015Edit,
type BetaClearThinking20251015EditResponse,
type BetaClearToolUses20250919Edit,
type BetaClearToolUses20250919EditResponse,
type BetaCodeExecutionOutputBlock,
type BetaCodeExecutionOutputBlockParam,
type BetaCodeExecutionResultBlock,
type BetaCodeExecutionResultBlockParam,
type BetaCodeExecutionTool20250522,
type BetaCodeExecutionTool20250825,
type BetaCodeExecutionTool20260120,
type BetaCodeExecutionToolResultBlock,
type BetaCodeExecutionToolResultBlockContent,
type BetaCodeExecutionToolResultBlockParam,
type BetaCodeExecutionToolResultBlockParamContent,
type BetaCodeExecutionToolResultError,
type BetaCodeExecutionToolResultErrorCode,
type BetaCodeExecutionToolResultErrorParam,
type BetaCompact20260112Edit,
type BetaCompactionBlock,
type BetaCompactionBlockParam,
type BetaCompactionContentBlockDelta,
type BetaCompactionIterationUsage,
type BetaContainer,
type BetaContainerParams,
type BetaContainerUploadBlock,
type BetaContainerUploadBlockParam,
type BetaContentBlock,
type BetaContentBlockParam,
type BetaContentBlockSource,
type BetaContentBlockSourceContent,
type BetaContextManagementConfig,
type BetaContextManagementResponse,
type BetaCountTokensContextManagementResponse,
type BetaDirectCaller,
type BetaDocumentBlock,
type BetaEncryptedCodeExecutionResultBlock,
type BetaEncryptedCodeExecutionResultBlockParam,
type BetaFileDocumentSource,
type BetaFileImageSource,
type BetaImageBlockParam,
type BetaInputJSONDelta,
type BetaInputTokensClearAtLeast,
type BetaInputTokensTrigger,
type BetaJSONOutputFormat,
type BetaMCPToolResultBlock,
type BetaMCPToolUseBlock,
type BetaMCPToolUseBlockParam,
type BetaMCPToolset,
type BetaMemoryTool20250818,
type BetaMemoryTool20250818Command,
type BetaMemoryTool20250818CreateCommand,
type BetaMemoryTool20250818DeleteCommand,
type BetaMemoryTool20250818InsertCommand,
type BetaMemoryTool20250818RenameCommand,
type BetaMemoryTool20250818StrReplaceCommand,
type BetaMemoryTool20250818ViewCommand,
type BetaMessage,
type BetaMessageDeltaUsage,
type BetaMessageIterationUsage,
type BetaMessageParam,
type BetaMessageTokensCount,
type BetaMetadata,
type BetaOutputConfig,
type BetaPlainTextSource,
type BetaRawContentBlockDelta,
type BetaRawContentBlockDeltaEvent,
type BetaRawContentBlockStartEvent,
type BetaRawContentBlockStopEvent,
type BetaRawMessageDeltaEvent,
type BetaRawMessageStartEvent,
type BetaRawMessageStopEvent,
type BetaRawMessageStreamEvent,
type BetaRedactedThinkingBlock,
type BetaRedactedThinkingBlockParam,
type BetaRequestDocumentBlock,
type BetaRequestMCPServerToolConfiguration,
type BetaRequestMCPServerURLDefinition,
type BetaRequestMCPToolResultBlockParam,
type BetaSearchResultBlockParam,
type BetaServerToolCaller,
type BetaServerToolCaller20260120,
type BetaServerToolUsage,
type BetaServerToolUseBlock,
type BetaServerToolUseBlockParam,
type BetaSignatureDelta,
type BetaSkill,
type BetaSkillParams,
type BetaStopReason,
type BetaTextBlock,
type BetaTextBlockParam,
type BetaTextCitation,
type BetaTextCitationParam,
type BetaTextDelta,
type BetaTextEditorCodeExecutionCreateResultBlock,
type BetaTextEditorCodeExecutionCreateResultBlockParam,
type BetaTextEditorCodeExecutionStrReplaceResultBlock,
type BetaTextEditorCodeExecutionStrReplaceResultBlockParam,
type BetaTextEditorCodeExecutionToolResultBlock,
type BetaTextEditorCodeExecutionToolResultBlockParam,
type BetaTextEditorCodeExecutionToolResultError,
type BetaTextEditorCodeExecutionToolResultErrorParam,
type BetaTextEditorCodeExecutionViewResultBlock,
type BetaTextEditorCodeExecutionViewResultBlockParam,
type BetaThinkingBlock,
type BetaThinkingBlockParam,
type BetaThinkingConfigAdaptive,
type BetaThinkingConfigDisabled,
type BetaThinkingConfigEnabled,
type BetaThinkingConfigParam,
type BetaThinkingDelta,
type BetaThinkingTurns,
type BetaTool,
type BetaToolBash20241022,
type BetaToolBash20250124,
type BetaToolChoice,
type BetaToolChoiceAny,
type BetaToolChoiceAuto,
type BetaToolChoiceNone,
type BetaToolChoiceTool,
type BetaToolComputerUse20241022,
type BetaToolComputerUse20250124,
type BetaToolComputerUse20251124,
type BetaToolReferenceBlock,
type BetaToolReferenceBlockParam,
type BetaToolResultBlockParam,
type BetaToolTextEditor20241022,
type BetaToolTextEditor20250124,
type BetaToolTextEditor20250429,
type BetaToolTextEditor20250728,
type BetaToolUnion,
type BetaToolUseBlock,
type BetaToolUseBlockParam,
type BetaToolUsesKeep,
type BetaToolUsesTrigger,
type BetaURLImageSource,
type BetaURLPDFSource,
type BetaUsage,
type BetaUserLocation,
type BetaWebFetchBlock,
type BetaWebFetchBlockParam,
type BetaWebFetchTool20250910,
type BetaWebFetchTool20260209,
type BetaWebFetchTool20260309,
type BetaWebFetchToolResultBlock,
type BetaWebFetchToolResultBlockParam,
type BetaWebFetchToolResultErrorBlock,
type BetaWebFetchToolResultErrorBlockParam,
type BetaWebFetchToolResultErrorCode,
type BetaWebSearchResultBlock,
type BetaWebSearchResultBlockParam,
type BetaWebSearchTool20250305,
type BetaWebSearchTool20260209,
type BetaWebSearchToolRequestError,
type BetaWebSearchToolResultBlock,
type BetaWebSearchToolResultBlockContent,
type BetaWebSearchToolResultBlockParam,
type BetaWebSearchToolResultBlockParamContent,
type BetaWebSearchToolResultError,
type BetaWebSearchToolResultErrorCode,
type BetaBase64PDFBlock,
type MessageCreateParams,
type MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming,
type MessageCountTokensParams,
type BetaMessageStreamParams,
type BetaToolSearchToolBm25_20251119,
type BetaToolSearchToolRegex20251119,
type BetaToolSearchToolResultBlock,
type BetaToolSearchToolResultBlockParam,
type BetaToolSearchToolResultError,
type BetaToolSearchToolResultErrorParam,
type BetaToolSearchToolSearchResultBlock,
type BetaToolSearchToolSearchResultBlockParam,
type BetaMCPToolConfig,
type BetaMCPToolDefaultConfig,
type BetaToolResultContentBlockParam,
} from './messages';
export { BetaToolRunner, type BetaToolRunnerParams, ToolError } from './messages';

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,284 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as BetaAPI from './beta';
import { APIPromise } from '../../core/api-promise';
import { Page, type PageParams, PagePromise } from '../../core/pagination';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Models extends APIResource {
/**
* Get a specific model.
*
* The Models API response can be used to determine information about a specific
* model or resolve a model alias to a model ID.
*
* @example
* ```ts
* const betaModelInfo = await client.beta.models.retrieve(
* 'model_id',
* );
* ```
*/
retrieve(
modelID: string,
params: ModelRetrieveParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<BetaModelInfo> {
const { betas } = params ?? {};
return this._client.get(path`/v1/models/${modelID}?beta=true`, {
...options,
headers: buildHeaders([
{ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
options?.headers,
]),
});
}
/**
* List available models.
*
* The Models API response can be used to determine which models are available for
* use in the API. More recently released models are listed first.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const betaModelInfo of client.beta.models.list()) {
* // ...
* }
* ```
*/
list(
params: ModelListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<BetaModelInfosPage, BetaModelInfo> {
const { betas, ...query } = params ?? {};
return this._client.getAPIList('/v1/models?beta=true', Page<BetaModelInfo>, {
query,
...options,
headers: buildHeaders([
{ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
options?.headers,
]),
});
}
}
export type BetaModelInfosPage = Page<BetaModelInfo>;
/**
* Indicates whether a capability is supported.
*/
export interface BetaCapabilitySupport {
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
}
/**
* Context management capability details.
*/
export interface BetaContextManagementCapability {
/**
* Indicates whether a capability is supported.
*/
clear_thinking_20251015: BetaCapabilitySupport | null;
/**
* Indicates whether a capability is supported.
*/
clear_tool_uses_20250919: BetaCapabilitySupport | null;
/**
* Indicates whether a capability is supported.
*/
compact_20260112: BetaCapabilitySupport | null;
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
}
/**
* Effort (reasoning_effort) capability details.
*/
export interface BetaEffortCapability {
/**
* Whether the model supports high effort level.
*/
high: BetaCapabilitySupport;
/**
* Whether the model supports low effort level.
*/
low: BetaCapabilitySupport;
/**
* Whether the model supports max effort level.
*/
max: BetaCapabilitySupport;
/**
* Whether the model supports medium effort level.
*/
medium: BetaCapabilitySupport;
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
}
/**
* Model capability information.
*/
export interface BetaModelCapabilities {
/**
* Whether the model supports the Batch API.
*/
batch: BetaCapabilitySupport;
/**
* Whether the model supports citation generation.
*/
citations: BetaCapabilitySupport;
/**
* Whether the model supports code execution tools.
*/
code_execution: BetaCapabilitySupport;
/**
* Context management support and available strategies.
*/
context_management: BetaContextManagementCapability;
/**
* Effort (reasoning_effort) support and available levels.
*/
effort: BetaEffortCapability;
/**
* Whether the model accepts image content blocks.
*/
image_input: BetaCapabilitySupport;
/**
* Whether the model accepts PDF content blocks.
*/
pdf_input: BetaCapabilitySupport;
/**
* Whether the model supports structured output / JSON mode / strict tool schemas.
*/
structured_outputs: BetaCapabilitySupport;
/**
* Thinking capability and supported type configurations.
*/
thinking: BetaThinkingCapability;
}
export interface BetaModelInfo {
/**
* Unique model identifier.
*/
id: string;
/**
* Model capability information.
*/
capabilities: BetaModelCapabilities | null;
/**
* RFC 3339 datetime string representing the time at which the model was released.
* May be set to an epoch value if the release date is unknown.
*/
created_at: string;
/**
* A human-readable name for the model.
*/
display_name: string;
/**
* Maximum input context window size in tokens for this model.
*/
max_input_tokens: number | null;
/**
* Maximum value for the `max_tokens` parameter when using this model.
*/
max_tokens: number | null;
/**
* Object type.
*
* For Models, this is always `"model"`.
*/
type: 'model';
}
/**
* Thinking capability details.
*/
export interface BetaThinkingCapability {
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
/**
* Supported thinking type configurations.
*/
types: BetaThinkingTypes;
}
/**
* Supported thinking type configurations.
*/
export interface BetaThinkingTypes {
/**
* Whether the model supports thinking with type 'adaptive' (auto).
*/
adaptive: BetaCapabilitySupport;
/**
* Whether the model supports thinking with type 'enabled'.
*/
enabled: BetaCapabilitySupport;
}
export interface ModelRetrieveParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface ModelListParams extends PageParams {
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export declare namespace Models {
export {
type BetaCapabilitySupport as BetaCapabilitySupport,
type BetaContextManagementCapability as BetaContextManagementCapability,
type BetaEffortCapability as BetaEffortCapability,
type BetaModelCapabilities as BetaModelCapabilities,
type BetaModelInfo as BetaModelInfo,
type BetaThinkingCapability as BetaThinkingCapability,
type BetaThinkingTypes as BetaThinkingTypes,
type BetaModelInfosPage as BetaModelInfosPage,
type ModelRetrieveParams as ModelRetrieveParams,
type ModelListParams as ModelListParams,
};
}

View File

@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from './skills/index';

View File

@@ -0,0 +1,26 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export {
Skills,
type SkillCreateResponse,
type SkillRetrieveResponse,
type SkillListResponse,
type SkillDeleteResponse,
type SkillCreateParams,
type SkillRetrieveParams,
type SkillListParams,
type SkillDeleteParams,
type SkillListResponsesPageCursor,
} from './skills';
export {
Versions,
type VersionCreateResponse,
type VersionRetrieveResponse,
type VersionListResponse,
type VersionDeleteResponse,
type VersionCreateParams,
type VersionRetrieveParams,
type VersionListParams,
type VersionDeleteParams,
type VersionListResponsesPageCursor,
} from './versions';

View File

@@ -0,0 +1,384 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import * as BetaAPI from '../beta';
import * as VersionsAPI from './versions';
import {
VersionCreateParams,
VersionCreateResponse,
VersionDeleteParams,
VersionDeleteResponse,
VersionListParams,
VersionListResponse,
VersionListResponsesPageCursor,
VersionRetrieveParams,
VersionRetrieveResponse,
Versions,
} from './versions';
import { APIPromise } from '../../../core/api-promise';
import { PageCursor, type PageCursorParams, PagePromise } from '../../../core/pagination';
import { type Uploadable } from '../../../core/uploads';
import { buildHeaders } from '../../../internal/headers';
import { RequestOptions } from '../../../internal/request-options';
import { multipartFormRequestOptions } from '../../../internal/uploads';
import { path } from '../../../internal/utils/path';
export class Skills extends APIResource {
versions: VersionsAPI.Versions = new VersionsAPI.Versions(this._client);
/**
* Create Skill
*
* @example
* ```ts
* const skill = await client.beta.skills.create();
* ```
*/
create(
params: SkillCreateParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<SkillCreateResponse> {
const { betas, ...body } = params ?? {};
return this._client.post(
'/v1/skills?beta=true',
multipartFormRequestOptions(
{
body,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
},
this._client,
false,
),
);
}
/**
* Get Skill
*
* @example
* ```ts
* const skill = await client.beta.skills.retrieve('skill_id');
* ```
*/
retrieve(
skillID: string,
params: SkillRetrieveParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<SkillRetrieveResponse> {
const { betas } = params ?? {};
return this._client.get(path`/v1/skills/${skillID}?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
});
}
/**
* List Skills
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const skillListResponse of client.beta.skills.list()) {
* // ...
* }
* ```
*/
list(
params: SkillListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<SkillListResponsesPageCursor, SkillListResponse> {
const { betas, ...query } = params ?? {};
return this._client.getAPIList('/v1/skills?beta=true', PageCursor<SkillListResponse>, {
query,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
});
}
/**
* Delete Skill
*
* @example
* ```ts
* const skill = await client.beta.skills.delete('skill_id');
* ```
*/
delete(
skillID: string,
params: SkillDeleteParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<SkillDeleteResponse> {
const { betas } = params ?? {};
return this._client.delete(path`/v1/skills/${skillID}?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
});
}
}
export type SkillListResponsesPageCursor = PageCursor<SkillListResponse>;
export interface SkillCreateResponse {
/**
* Unique identifier for the skill.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* ISO 8601 timestamp of when the skill was created.
*/
created_at: string;
/**
* Display title for the skill.
*
* This is a human-readable label that is not included in the prompt sent to the
* model.
*/
display_title: string | null;
/**
* The latest version identifier for the skill.
*
* This represents the most recent version of the skill that has been created.
*/
latest_version: string | null;
/**
* Source of the skill.
*
* This may be one of the following values:
*
* - `"custom"`: the skill was created by a user
* - `"anthropic"`: the skill was created by Anthropic
*/
source: string;
/**
* Object type.
*
* For Skills, this is always `"skill"`.
*/
type: string;
/**
* ISO 8601 timestamp of when the skill was last updated.
*/
updated_at: string;
}
export interface SkillRetrieveResponse {
/**
* Unique identifier for the skill.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* ISO 8601 timestamp of when the skill was created.
*/
created_at: string;
/**
* Display title for the skill.
*
* This is a human-readable label that is not included in the prompt sent to the
* model.
*/
display_title: string | null;
/**
* The latest version identifier for the skill.
*
* This represents the most recent version of the skill that has been created.
*/
latest_version: string | null;
/**
* Source of the skill.
*
* This may be one of the following values:
*
* - `"custom"`: the skill was created by a user
* - `"anthropic"`: the skill was created by Anthropic
*/
source: string;
/**
* Object type.
*
* For Skills, this is always `"skill"`.
*/
type: string;
/**
* ISO 8601 timestamp of when the skill was last updated.
*/
updated_at: string;
}
export interface SkillListResponse {
/**
* Unique identifier for the skill.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* ISO 8601 timestamp of when the skill was created.
*/
created_at: string;
/**
* Display title for the skill.
*
* This is a human-readable label that is not included in the prompt sent to the
* model.
*/
display_title: string | null;
/**
* The latest version identifier for the skill.
*
* This represents the most recent version of the skill that has been created.
*/
latest_version: string | null;
/**
* Source of the skill.
*
* This may be one of the following values:
*
* - `"custom"`: the skill was created by a user
* - `"anthropic"`: the skill was created by Anthropic
*/
source: string;
/**
* Object type.
*
* For Skills, this is always `"skill"`.
*/
type: string;
/**
* ISO 8601 timestamp of when the skill was last updated.
*/
updated_at: string;
}
export interface SkillDeleteResponse {
/**
* Unique identifier for the skill.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* Deleted object type.
*
* For Skills, this is always `"skill_deleted"`.
*/
type: string;
}
export interface SkillCreateParams {
/**
* Body param: Display title for the skill.
*
* This is a human-readable label that is not included in the prompt sent to the
* model.
*/
display_title?: string | null;
/**
* Body param: Files to upload for the skill.
*
* All files must be in the same top-level directory and must include a SKILL.md
* file at the root of that directory.
*/
files?: Array<Uploadable> | null;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface SkillRetrieveParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface SkillListParams extends PageCursorParams {
/**
* Query param: Filter skills by source.
*
* If provided, only skills from the specified source will be returned:
*
* - `"custom"`: only return user-created skills
* - `"anthropic"`: only return Anthropic-created skills
*/
source?: string | null;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface SkillDeleteParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
Skills.Versions = Versions;
export declare namespace Skills {
export {
type SkillCreateResponse as SkillCreateResponse,
type SkillRetrieveResponse as SkillRetrieveResponse,
type SkillListResponse as SkillListResponse,
type SkillDeleteResponse as SkillDeleteResponse,
type SkillListResponsesPageCursor as SkillListResponsesPageCursor,
type SkillCreateParams as SkillCreateParams,
type SkillRetrieveParams as SkillRetrieveParams,
type SkillListParams as SkillListParams,
type SkillDeleteParams as SkillDeleteParams,
};
export {
Versions as Versions,
type VersionCreateResponse as VersionCreateResponse,
type VersionRetrieveResponse as VersionRetrieveResponse,
type VersionListResponse as VersionListResponse,
type VersionDeleteResponse as VersionDeleteResponse,
type VersionListResponsesPageCursor as VersionListResponsesPageCursor,
type VersionCreateParams as VersionCreateParams,
type VersionRetrieveParams as VersionRetrieveParams,
type VersionListParams as VersionListParams,
type VersionDeleteParams as VersionDeleteParams,
};
}

View File

@@ -0,0 +1,374 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import * as BetaAPI from '../beta';
import { APIPromise } from '../../../core/api-promise';
import { PageCursor, type PageCursorParams, PagePromise } from '../../../core/pagination';
import { type Uploadable } from '../../../core/uploads';
import { buildHeaders } from '../../../internal/headers';
import { RequestOptions } from '../../../internal/request-options';
import { multipartFormRequestOptions } from '../../../internal/uploads';
import { path } from '../../../internal/utils/path';
export class Versions extends APIResource {
/**
* Create Skill Version
*
* @example
* ```ts
* const version = await client.beta.skills.versions.create(
* 'skill_id',
* );
* ```
*/
create(
skillID: string,
params: VersionCreateParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<VersionCreateResponse> {
const { betas, ...body } = params ?? {};
return this._client.post(
path`/v1/skills/${skillID}/versions?beta=true`,
multipartFormRequestOptions(
{
body,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
},
this._client,
),
);
}
/**
* Get Skill Version
*
* @example
* ```ts
* const version = await client.beta.skills.versions.retrieve(
* 'version',
* { skill_id: 'skill_id' },
* );
* ```
*/
retrieve(
version: string,
params: VersionRetrieveParams,
options?: RequestOptions,
): APIPromise<VersionRetrieveResponse> {
const { skill_id, betas } = params;
return this._client.get(path`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
});
}
/**
* List Skill Versions
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const versionListResponse of client.beta.skills.versions.list(
* 'skill_id',
* )) {
* // ...
* }
* ```
*/
list(
skillID: string,
params: VersionListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<VersionListResponsesPageCursor, VersionListResponse> {
const { betas, ...query } = params ?? {};
return this._client.getAPIList(
path`/v1/skills/${skillID}/versions?beta=true`,
PageCursor<VersionListResponse>,
{
query,
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
},
);
}
/**
* Delete Skill Version
*
* @example
* ```ts
* const version = await client.beta.skills.versions.delete(
* 'version',
* { skill_id: 'skill_id' },
* );
* ```
*/
delete(
version: string,
params: VersionDeleteParams,
options?: RequestOptions,
): APIPromise<VersionDeleteResponse> {
const { skill_id, betas } = params;
return this._client.delete(path`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
...options,
headers: buildHeaders([
{ 'anthropic-beta': [...(betas ?? []), 'skills-2025-10-02'].toString() },
options?.headers,
]),
});
}
}
export type VersionListResponsesPageCursor = PageCursor<VersionListResponse>;
export interface VersionCreateResponse {
/**
* Unique identifier for the skill version.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* ISO 8601 timestamp of when the skill version was created.
*/
created_at: string;
/**
* Description of the skill version.
*
* This is extracted from the SKILL.md file in the skill upload.
*/
description: string;
/**
* Directory name of the skill version.
*
* This is the top-level directory name that was extracted from the uploaded files.
*/
directory: string;
/**
* Human-readable name of the skill version.
*
* This is extracted from the SKILL.md file in the skill upload.
*/
name: string;
/**
* Identifier for the skill that this version belongs to.
*/
skill_id: string;
/**
* Object type.
*
* For Skill Versions, this is always `"skill_version"`.
*/
type: string;
/**
* Version identifier for the skill.
*
* Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
*/
version: string;
}
export interface VersionRetrieveResponse {
/**
* Unique identifier for the skill version.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* ISO 8601 timestamp of when the skill version was created.
*/
created_at: string;
/**
* Description of the skill version.
*
* This is extracted from the SKILL.md file in the skill upload.
*/
description: string;
/**
* Directory name of the skill version.
*
* This is the top-level directory name that was extracted from the uploaded files.
*/
directory: string;
/**
* Human-readable name of the skill version.
*
* This is extracted from the SKILL.md file in the skill upload.
*/
name: string;
/**
* Identifier for the skill that this version belongs to.
*/
skill_id: string;
/**
* Object type.
*
* For Skill Versions, this is always `"skill_version"`.
*/
type: string;
/**
* Version identifier for the skill.
*
* Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
*/
version: string;
}
export interface VersionListResponse {
/**
* Unique identifier for the skill version.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* ISO 8601 timestamp of when the skill version was created.
*/
created_at: string;
/**
* Description of the skill version.
*
* This is extracted from the SKILL.md file in the skill upload.
*/
description: string;
/**
* Directory name of the skill version.
*
* This is the top-level directory name that was extracted from the uploaded files.
*/
directory: string;
/**
* Human-readable name of the skill version.
*
* This is extracted from the SKILL.md file in the skill upload.
*/
name: string;
/**
* Identifier for the skill that this version belongs to.
*/
skill_id: string;
/**
* Object type.
*
* For Skill Versions, this is always `"skill_version"`.
*/
type: string;
/**
* Version identifier for the skill.
*
* Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
*/
version: string;
}
export interface VersionDeleteResponse {
/**
* Version identifier for the skill.
*
* Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
*/
id: string;
/**
* Deleted object type.
*
* For Skill Versions, this is always `"skill_version_deleted"`.
*/
type: string;
}
export interface VersionCreateParams {
/**
* Body param: Files to upload for the skill.
*
* All files must be in the same top-level directory and must include a SKILL.md
* file at the root of that directory.
*/
files?: Array<Uploadable> | null;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface VersionRetrieveParams {
/**
* Path param: Unique identifier for the skill.
*
* The format and length of IDs may change over time.
*/
skill_id: string;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface VersionListParams extends PageCursorParams {
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface VersionDeleteParams {
/**
* Path param: Unique identifier for the skill.
*
* The format and length of IDs may change over time.
*/
skill_id: string;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export declare namespace Versions {
export {
type VersionCreateResponse as VersionCreateResponse,
type VersionRetrieveResponse as VersionRetrieveResponse,
type VersionListResponse as VersionListResponse,
type VersionDeleteResponse as VersionDeleteResponse,
type VersionListResponsesPageCursor as VersionListResponsesPageCursor,
type VersionCreateParams as VersionCreateParams,
type VersionRetrieveParams as VersionRetrieveParams,
type VersionListParams as VersionListParams,
type VersionDeleteParams as VersionDeleteParams,
};
}

View File

@@ -0,0 +1,230 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as CompletionsAPI from './completions';
import * as BetaAPI from './beta/beta';
import * as MessagesAPI from './messages/messages';
import { APIPromise } from '../core/api-promise';
import { Stream } from '../core/streaming';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
export class Completions extends APIResource {
/**
* [Legacy] Create a Text Completion.
*
* The Text Completions API is a legacy API. We recommend using the
* [Messages API](https://docs.claude.com/en/api/messages) going forward.
*
* Future models and features will not be compatible with Text Completions. See our
* [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)
* for guidance in migrating from Text Completions to Messages.
*
* @example
* ```ts
* const completion = await client.completions.create({
* max_tokens_to_sample: 256,
* model: 'claude-opus-4-6',
* prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
* });
* ```
*/
create(params: CompletionCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Completion>;
create(params: CompletionCreateParamsStreaming, options?: RequestOptions): APIPromise<Stream<Completion>>;
create(
params: CompletionCreateParamsBase,
options?: RequestOptions,
): APIPromise<Stream<Completion> | Completion>;
create(
params: CompletionCreateParams,
options?: RequestOptions,
): APIPromise<Completion> | APIPromise<Stream<Completion>> {
const { betas, ...body } = params;
return this._client.post('/v1/complete', {
body,
timeout: (this._client as any)._options.timeout ?? 600000,
...options,
headers: buildHeaders([
{ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
options?.headers,
]),
stream: params.stream ?? false,
}) as APIPromise<Completion> | APIPromise<Stream<Completion>>;
}
}
export interface Completion {
/**
* Unique object identifier.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* The resulting completion up to and excluding the stop sequences.
*/
completion: string;
/**
* The model that will complete your prompt.\n\nSee
* [models](https://docs.anthropic.com/en/docs/models-overview) for additional
* details and options.
*/
model: MessagesAPI.Model;
/**
* The reason that we stopped.
*
* This may be one the following values:
*
* - `"stop_sequence"`: we reached a stop sequence — either provided by you via the
* `stop_sequences` parameter, or a stop sequence built into the model
* - `"max_tokens"`: we exceeded `max_tokens_to_sample` or the model's maximum
*/
stop_reason: string | null;
/**
* Object type.
*
* For Text Completions, this is always `"completion"`.
*/
type: 'completion';
}
export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;
export interface CompletionCreateParamsBase {
/**
* Body param: The maximum number of tokens to generate before stopping.
*
* Note that our models may stop _before_ reaching this maximum. This parameter
* only specifies the absolute maximum number of tokens to generate.
*/
max_tokens_to_sample: number;
/**
* Body param: The model that will complete your prompt.\n\nSee
* [models](https://docs.anthropic.com/en/docs/models-overview) for additional
* details and options.
*/
model: MessagesAPI.Model;
/**
* Body param: The prompt that you want Claude to complete.
*
* For proper response generation you will need to format your prompt using
* alternating `\n\nHuman:` and `\n\nAssistant:` conversational turns. For example:
*
* ```
* "\n\nHuman: {userQuestion}\n\nAssistant:"
* ```
*
* See [prompt validation](https://docs.claude.com/en/api/prompt-validation) and
* our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting)
* for more details.
*/
prompt: string;
/**
* Body param: An object describing metadata about the request.
*/
metadata?: MessagesAPI.Metadata;
/**
* Body param: Sequences that will cause the model to stop generating.
*
* Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
* sequences in the future. By providing the stop_sequences parameter, you may
* include additional strings that will cause the model to stop generating.
*/
stop_sequences?: Array<string>;
/**
* Body param: Whether to incrementally stream the response using server-sent
* events.
*
* See [streaming](https://docs.claude.com/en/api/streaming) for details.
*/
stream?: boolean;
/**
* Body param: Amount of randomness injected into the response.
*
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
* for analytical / multiple choice, and closer to `1.0` for creative and
* generative tasks.
*
* Note that even with `temperature` of `0.0`, the results will not be fully
* deterministic.
*/
temperature?: number;
/**
* Body param: Only sample from the top K options for each subsequent token.
*
* Used to remove "long tail" low probability responses.
* [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
*
* Recommended for advanced use cases only. You usually only need to use
* `temperature`.
*/
top_k?: number;
/**
* Body param: Use nucleus sampling.
*
* In nucleus sampling, we compute the cumulative distribution over all the options
* for each subsequent token in decreasing probability order and cut it off once it
* reaches a particular probability specified by `top_p`. You should either alter
* `temperature` or `top_p`, but not both.
*
* Recommended for advanced use cases only. You usually only need to use
* `temperature`.
*/
top_p?: number;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export namespace CompletionCreateParams {
/**
* @deprecated use `Anthropic.Messages.Metadata` instead
*/
export type Metadata = MessagesAPI.Metadata;
export type CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
export type CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;
}
export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
/**
* Body param: Whether to incrementally stream the response using server-sent
* events.
*
* See [streaming](https://docs.claude.com/en/api/streaming) for details.
*/
stream?: false;
}
export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
/**
* Body param: Whether to incrementally stream the response using server-sent
* events.
*
* See [streaming](https://docs.claude.com/en/api/streaming) for details.
*/
stream: true;
}
export declare namespace Completions {
export {
type Completion as Completion,
type CompletionCreateParams as CompletionCreateParams,
type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
};
}

View File

@@ -0,0 +1,205 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from './shared';
export {
Beta,
type AnthropicBeta,
type BetaAPIError,
type BetaAuthenticationError,
type BetaBillingError,
type BetaError,
type BetaErrorResponse,
type BetaGatewayTimeoutError,
type BetaInvalidRequestError,
type BetaNotFoundError,
type BetaOverloadedError,
type BetaPermissionError,
type BetaRateLimitError,
} from './beta/beta';
export {
Completions,
type Completion,
type CompletionCreateParams,
type CompletionCreateParamsNonStreaming,
type CompletionCreateParamsStreaming,
} from './completions';
export {
Messages,
type Base64ImageSource,
type Base64PDFSource,
type BashCodeExecutionOutputBlock,
type BashCodeExecutionOutputBlockParam,
type BashCodeExecutionResultBlock,
type BashCodeExecutionResultBlockParam,
type BashCodeExecutionToolResultBlock,
type BashCodeExecutionToolResultBlockParam,
type BashCodeExecutionToolResultError,
type BashCodeExecutionToolResultErrorCode,
type BashCodeExecutionToolResultErrorParam,
type CacheControlEphemeral,
type CacheCreation,
type CitationCharLocation,
type CitationCharLocationParam,
type CitationContentBlockLocation,
type CitationContentBlockLocationParam,
type CitationPageLocation,
type CitationPageLocationParam,
type CitationSearchResultLocationParam,
type CitationWebSearchResultLocationParam,
type CitationsConfig,
type CitationsConfigParam,
type CitationsDelta,
type CitationsSearchResultLocation,
type CitationsWebSearchResultLocation,
type CodeExecutionOutputBlock,
type CodeExecutionOutputBlockParam,
type CodeExecutionResultBlock,
type CodeExecutionResultBlockParam,
type CodeExecutionTool20250522,
type CodeExecutionTool20250825,
type CodeExecutionTool20260120,
type CodeExecutionToolResultBlock,
type CodeExecutionToolResultBlockContent,
type CodeExecutionToolResultBlockParam,
type CodeExecutionToolResultBlockParamContent,
type CodeExecutionToolResultError,
type CodeExecutionToolResultErrorCode,
type CodeExecutionToolResultErrorParam,
type Container,
type ContainerUploadBlock,
type ContainerUploadBlockParam,
type ContentBlock,
type ContentBlockParam,
type ContentBlockStartEvent,
type ContentBlockStopEvent,
type ContentBlockSource,
type ContentBlockSourceContent,
type DirectCaller,
type DocumentBlock,
type DocumentBlockParam,
type EncryptedCodeExecutionResultBlock,
type EncryptedCodeExecutionResultBlockParam,
type ImageBlockParam,
type InputJSONDelta,
type JSONOutputFormat,
type MemoryTool20250818,
type Message,
type MessageCountTokensTool,
type MessageDeltaEvent,
type MessageDeltaUsage,
type MessageParam,
type MessageStreamParams,
type MessageTokensCount,
type Metadata,
type Model,
type OutputConfig,
type PlainTextSource,
type RawContentBlockDelta,
type RawContentBlockDeltaEvent,
type RawContentBlockStartEvent,
type RawContentBlockStopEvent,
type RawMessageDeltaEvent,
type RawMessageStartEvent,
type RawMessageStopEvent,
type RawMessageStreamEvent,
type RedactedThinkingBlock,
type RedactedThinkingBlockParam,
type SearchResultBlockParam,
type ServerToolCaller,
type ServerToolCaller20260120,
type ServerToolUsage,
type ServerToolUseBlock,
type ServerToolUseBlockParam,
type SignatureDelta,
type StopReason,
type TextBlock,
type TextBlockParam,
type TextCitation,
type TextCitationParam,
type TextDelta,
type TextEditorCodeExecutionCreateResultBlock,
type TextEditorCodeExecutionCreateResultBlockParam,
type TextEditorCodeExecutionStrReplaceResultBlock,
type TextEditorCodeExecutionStrReplaceResultBlockParam,
type TextEditorCodeExecutionToolResultBlock,
type TextEditorCodeExecutionToolResultBlockParam,
type TextEditorCodeExecutionToolResultError,
type TextEditorCodeExecutionToolResultErrorCode,
type TextEditorCodeExecutionToolResultErrorParam,
type TextEditorCodeExecutionViewResultBlock,
type TextEditorCodeExecutionViewResultBlockParam,
type ThinkingBlock,
type ThinkingBlockParam,
type ThinkingConfigAdaptive,
type ThinkingConfigDisabled,
type ThinkingConfigEnabled,
type ThinkingConfigParam,
type ThinkingDelta,
type Tool,
type ToolBash20250124,
type ToolChoice,
type ToolChoiceAny,
type ToolChoiceAuto,
type ToolChoiceNone,
type ToolChoiceTool,
type ToolReferenceBlock,
type ToolReferenceBlockParam,
type ToolResultBlockParam,
type ToolSearchToolBm25_20251119,
type ToolSearchToolRegex20251119,
type ToolSearchToolResultBlock,
type ToolSearchToolResultBlockParam,
type ToolSearchToolResultError,
type ToolSearchToolResultErrorCode,
type ToolSearchToolResultErrorParam,
type ToolSearchToolSearchResultBlock,
type ToolSearchToolSearchResultBlockParam,
type ToolTextEditor20250124,
type ToolTextEditor20250429,
type ToolTextEditor20250728,
type ToolUnion,
type ToolUseBlock,
type ToolUseBlockParam,
type URLImageSource,
type URLPDFSource,
type Usage,
type UserLocation,
type WebFetchBlock,
type WebFetchBlockParam,
type WebFetchTool20250910,
type WebFetchTool20260209,
type WebFetchTool20260309,
type WebFetchToolResultBlock,
type WebFetchToolResultBlockParam,
type WebFetchToolResultErrorBlock,
type WebFetchToolResultErrorBlockParam,
type WebFetchToolResultErrorCode,
type WebSearchResultBlock,
type WebSearchResultBlockParam,
type WebSearchTool20250305,
type WebSearchTool20260209,
type WebSearchToolRequestError,
type WebSearchToolResultBlock,
type WebSearchToolResultBlockContent,
type WebSearchToolResultBlockParam,
type WebSearchToolResultBlockParamContent,
type WebSearchToolResultError,
type WebSearchToolResultErrorCode,
type MessageCreateParams,
type MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming,
type MessageCountTokensParams,
} from './messages/messages';
export {
Models,
type CapabilitySupport,
type ContextManagementCapability,
type EffortCapability,
type ModelCapabilities,
type ModelInfo,
type ThinkingCapability,
type ThinkingTypes,
type ModelRetrieveParams,
type ModelListParams,
type ModelInfosPage,
} from './models';

View File

@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export * from './messages/index';

View File

@@ -0,0 +1,396 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as Shared from '../shared';
import * as MessagesAPI from './messages';
import { APIPromise } from '../../core/api-promise';
import { Page, type PageParams, PagePromise } from '../../core/pagination';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { JSONLDecoder } from '../../internal/decoders/jsonl';
import { AnthropicError } from '../../error';
import { path } from '../../internal/utils/path';
export class Batches extends APIResource {
/**
* Send a batch of Message creation requests.
*
* The Message Batches API can be used to process multiple Messages API requests at
* once. Once a Message Batch is created, it begins processing immediately. Batches
* can take up to 24 hours to complete.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const messageBatch = await client.messages.batches.create({
* requests: [
* {
* custom_id: 'my-custom-id-1',
* params: {
* max_tokens: 1024,
* messages: [
* { content: 'Hello, world', role: 'user' },
* ],
* model: 'claude-opus-4-6',
* },
* },
* ],
* });
* ```
*/
create(body: BatchCreateParams, options?: RequestOptions): APIPromise<MessageBatch> {
return this._client.post('/v1/messages/batches', { body, ...options });
}
/**
* This endpoint is idempotent and can be used to poll for Message Batch
* completion. To access the results of a Message Batch, make a request to the
* `results_url` field in the response.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const messageBatch = await client.messages.batches.retrieve(
* 'message_batch_id',
* );
* ```
*/
retrieve(messageBatchID: string, options?: RequestOptions): APIPromise<MessageBatch> {
return this._client.get(path`/v1/messages/batches/${messageBatchID}`, options);
}
/**
* List all Message Batches within a Workspace. Most recently created batches are
* returned first.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const messageBatch of client.messages.batches.list()) {
* // ...
* }
* ```
*/
list(
query: BatchListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<MessageBatchesPage, MessageBatch> {
return this._client.getAPIList('/v1/messages/batches', Page<MessageBatch>, { query, ...options });
}
/**
* Delete a Message Batch.
*
* Message Batches can only be deleted once they've finished processing. If you'd
* like to delete an in-progress batch, you must first cancel it.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const deletedMessageBatch =
* await client.messages.batches.delete('message_batch_id');
* ```
*/
delete(messageBatchID: string, options?: RequestOptions): APIPromise<DeletedMessageBatch> {
return this._client.delete(path`/v1/messages/batches/${messageBatchID}`, options);
}
/**
* Batches may be canceled any time before processing ends. Once cancellation is
* initiated, the batch enters a `canceling` state, at which time the system may
* complete any in-progress, non-interruptible requests before finalizing
* cancellation.
*
* The number of canceled requests is specified in `request_counts`. To determine
* which requests were canceled, check the individual results within the batch.
* Note that cancellation may not result in any canceled requests if they were
* non-interruptible.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const messageBatch = await client.messages.batches.cancel(
* 'message_batch_id',
* );
* ```
*/
cancel(messageBatchID: string, options?: RequestOptions): APIPromise<MessageBatch> {
return this._client.post(path`/v1/messages/batches/${messageBatchID}/cancel`, options);
}
/**
* Streams the results of a Message Batch as a `.jsonl` file.
*
* Each line in the file is a JSON object containing the result of a single request
* in the Message Batch. Results are not guaranteed to be in the same order as
* requests. Use the `custom_id` field to match results to requests.
*
* Learn more about the Message Batches API in our
* [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const messageBatchIndividualResponse =
* await client.messages.batches.results('message_batch_id');
* ```
*/
async results(
messageBatchID: string,
options?: RequestOptions,
): Promise<JSONLDecoder<MessageBatchIndividualResponse>> {
const batch = await this.retrieve(messageBatchID);
if (!batch.results_url) {
throw new AnthropicError(
`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`,
);
}
return this._client
.get(batch.results_url, {
...options,
headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
stream: true,
__binaryResponse: true,
})
._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller)) as APIPromise<
JSONLDecoder<MessageBatchIndividualResponse>
>;
}
}
export type MessageBatchesPage = Page<MessageBatch>;
export interface DeletedMessageBatch {
/**
* ID of the Message Batch.
*/
id: string;
/**
* Deleted object type.
*
* For Message Batches, this is always `"message_batch_deleted"`.
*/
type: 'message_batch_deleted';
}
export interface MessageBatch {
/**
* Unique object identifier.
*
* The format and length of IDs may change over time.
*/
id: string;
/**
* RFC 3339 datetime string representing the time at which the Message Batch was
* archived and its results became unavailable.
*/
archived_at: string | null;
/**
* RFC 3339 datetime string representing the time at which cancellation was
* initiated for the Message Batch. Specified only if cancellation was initiated.
*/
cancel_initiated_at: string | null;
/**
* RFC 3339 datetime string representing the time at which the Message Batch was
* created.
*/
created_at: string;
/**
* RFC 3339 datetime string representing the time at which processing for the
* Message Batch ended. Specified only once processing ends.
*
* Processing ends when every request in a Message Batch has either succeeded,
* errored, canceled, or expired.
*/
ended_at: string | null;
/**
* RFC 3339 datetime string representing the time at which the Message Batch will
* expire and end processing, which is 24 hours after creation.
*/
expires_at: string;
/**
* Processing status of the Message Batch.
*/
processing_status: 'in_progress' | 'canceling' | 'ended';
/**
* Tallies requests within the Message Batch, categorized by their status.
*
* Requests start as `processing` and move to one of the other statuses only once
* processing of the entire batch ends. The sum of all values always matches the
* total number of requests in the batch.
*/
request_counts: MessageBatchRequestCounts;
/**
* URL to a `.jsonl` file containing the results of the Message Batch requests.
* Specified only once processing ends.
*
* Results in the file are not guaranteed to be in the same order as requests. Use
* the `custom_id` field to match results to requests.
*/
results_url: string | null;
/**
* Object type.
*
* For Message Batches, this is always `"message_batch"`.
*/
type: 'message_batch';
}
export interface MessageBatchCanceledResult {
type: 'canceled';
}
export interface MessageBatchErroredResult {
error: Shared.ErrorResponse;
type: 'errored';
}
export interface MessageBatchExpiredResult {
type: 'expired';
}
/**
* This is a single line in the response `.jsonl` file and does not represent the
* response as a whole.
*/
export interface MessageBatchIndividualResponse {
/**
* Developer-provided ID created for each request in a Message Batch. Useful for
* matching results to requests, as results may be given out of request order.
*
* Must be unique for each request within the Message Batch.
*/
custom_id: string;
/**
* Processing result for this request.
*
* Contains a Message output if processing was successful, an error response if
* processing failed, or the reason why processing was not attempted, such as
* cancellation or expiration.
*/
result: MessageBatchResult;
}
export interface MessageBatchRequestCounts {
/**
* Number of requests in the Message Batch that have been canceled.
*
* This is zero until processing of the entire Message Batch has ended.
*/
canceled: number;
/**
* Number of requests in the Message Batch that encountered an error.
*
* This is zero until processing of the entire Message Batch has ended.
*/
errored: number;
/**
* Number of requests in the Message Batch that have expired.
*
* This is zero until processing of the entire Message Batch has ended.
*/
expired: number;
/**
* Number of requests in the Message Batch that are processing.
*/
processing: number;
/**
* Number of requests in the Message Batch that have completed successfully.
*
* This is zero until processing of the entire Message Batch has ended.
*/
succeeded: number;
}
/**
* Processing result for this request.
*
* Contains a Message output if processing was successful, an error response if
* processing failed, or the reason why processing was not attempted, such as
* cancellation or expiration.
*/
export type MessageBatchResult =
| MessageBatchSucceededResult
| MessageBatchErroredResult
| MessageBatchCanceledResult
| MessageBatchExpiredResult;
export interface MessageBatchSucceededResult {
message: MessagesAPI.Message;
type: 'succeeded';
}
export interface BatchCreateParams {
/**
* List of requests for prompt completion. Each is an individual request to create
* a Message.
*/
requests: Array<BatchCreateParams.Request>;
}
export namespace BatchCreateParams {
export interface Request {
/**
* Developer-provided ID created for each request in a Message Batch. Useful for
* matching results to requests, as results may be given out of request order.
*
* Must be unique for each request within the Message Batch.
*/
custom_id: string;
/**
* Messages API creation parameters for the individual request.
*
* See the [Messages API reference](https://docs.claude.com/en/api/messages) for
* full documentation on available parameters.
*/
params: MessagesAPI.MessageCreateParamsNonStreaming;
}
}
export interface BatchListParams extends PageParams {}
export declare namespace Batches {
export {
type DeletedMessageBatch as DeletedMessageBatch,
type MessageBatch as MessageBatch,
type MessageBatchCanceledResult as MessageBatchCanceledResult,
type MessageBatchErroredResult as MessageBatchErroredResult,
type MessageBatchExpiredResult as MessageBatchExpiredResult,
type MessageBatchIndividualResponse as MessageBatchIndividualResponse,
type MessageBatchRequestCounts as MessageBatchRequestCounts,
type MessageBatchResult as MessageBatchResult,
type MessageBatchSucceededResult as MessageBatchSucceededResult,
type MessageBatchesPage as MessageBatchesPage,
type BatchCreateParams as BatchCreateParams,
type BatchListParams as BatchListParams,
};
}

View File

@@ -0,0 +1,188 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export {
Batches,
type DeletedMessageBatch,
type MessageBatch,
type MessageBatchCanceledResult,
type MessageBatchErroredResult,
type MessageBatchExpiredResult,
type MessageBatchIndividualResponse,
type MessageBatchRequestCounts,
type MessageBatchResult,
type MessageBatchSucceededResult,
type BatchCreateParams,
type BatchListParams,
type MessageBatchesPage,
} from './batches';
export {
Messages,
type Base64ImageSource,
type Base64PDFSource,
type BashCodeExecutionOutputBlock,
type BashCodeExecutionOutputBlockParam,
type BashCodeExecutionResultBlock,
type BashCodeExecutionResultBlockParam,
type BashCodeExecutionToolResultBlock,
type BashCodeExecutionToolResultBlockParam,
type BashCodeExecutionToolResultError,
type BashCodeExecutionToolResultErrorCode,
type BashCodeExecutionToolResultErrorParam,
type CacheControlEphemeral,
type CacheCreation,
type CitationCharLocation,
type CitationCharLocationParam,
type CitationContentBlockLocation,
type CitationContentBlockLocationParam,
type CitationPageLocation,
type CitationPageLocationParam,
type CitationSearchResultLocationParam,
type CitationWebSearchResultLocationParam,
type CitationsConfig,
type CitationsConfigParam,
type CitationsDelta,
type CitationsSearchResultLocation,
type CitationsWebSearchResultLocation,
type CodeExecutionOutputBlock,
type CodeExecutionOutputBlockParam,
type CodeExecutionResultBlock,
type CodeExecutionResultBlockParam,
type CodeExecutionTool20250522,
type CodeExecutionTool20250825,
type CodeExecutionTool20260120,
type CodeExecutionToolResultBlock,
type CodeExecutionToolResultBlockContent,
type CodeExecutionToolResultBlockParam,
type CodeExecutionToolResultBlockParamContent,
type CodeExecutionToolResultError,
type CodeExecutionToolResultErrorCode,
type CodeExecutionToolResultErrorParam,
type Container,
type ContainerUploadBlock,
type ContainerUploadBlockParam,
type ContentBlock,
type ContentBlockParam,
type ContentBlockStartEvent,
type ContentBlockStopEvent,
type ContentBlockSource,
type ContentBlockSourceContent,
type DirectCaller,
type DocumentBlock,
type DocumentBlockParam,
type EncryptedCodeExecutionResultBlock,
type EncryptedCodeExecutionResultBlockParam,
type ImageBlockParam,
type InputJSONDelta,
type JSONOutputFormat,
type MemoryTool20250818,
type Message,
type MessageCountTokensTool,
type MessageDeltaEvent,
type MessageDeltaUsage,
type MessageParam,
type MessageTokensCount,
type Metadata,
type Model,
type OutputConfig,
type PlainTextSource,
type RawContentBlockDelta,
type RawContentBlockDeltaEvent,
type RawContentBlockStartEvent,
type RawContentBlockStopEvent,
type RawMessageDeltaEvent,
type RawMessageStartEvent,
type RawMessageStopEvent,
type RawMessageStreamEvent,
type RedactedThinkingBlock,
type RedactedThinkingBlockParam,
type SearchResultBlockParam,
type ServerToolCaller,
type ServerToolCaller20260120,
type ServerToolUsage,
type ServerToolUseBlock,
type ServerToolUseBlockParam,
type SignatureDelta,
type StopReason,
type TextBlock,
type TextBlockParam,
type TextCitation,
type TextCitationParam,
type TextDelta,
type TextEditorCodeExecutionCreateResultBlock,
type TextEditorCodeExecutionCreateResultBlockParam,
type TextEditorCodeExecutionStrReplaceResultBlock,
type TextEditorCodeExecutionStrReplaceResultBlockParam,
type TextEditorCodeExecutionToolResultBlock,
type TextEditorCodeExecutionToolResultBlockParam,
type TextEditorCodeExecutionToolResultError,
type TextEditorCodeExecutionToolResultErrorCode,
type TextEditorCodeExecutionToolResultErrorParam,
type TextEditorCodeExecutionViewResultBlock,
type TextEditorCodeExecutionViewResultBlockParam,
type ThinkingBlock,
type ThinkingBlockParam,
type ThinkingConfigAdaptive,
type ThinkingConfigDisabled,
type ThinkingConfigEnabled,
type ThinkingConfigParam,
type ThinkingDelta,
type Tool,
type ToolBash20250124,
type ToolChoice,
type ToolChoiceAny,
type ToolChoiceAuto,
type ToolChoiceNone,
type ToolChoiceTool,
type ToolReferenceBlock,
type ToolReferenceBlockParam,
type ToolResultBlockParam,
type ToolSearchToolBm25_20251119,
type ToolSearchToolRegex20251119,
type ToolSearchToolResultBlock,
type ToolSearchToolResultBlockParam,
type ToolSearchToolResultError,
type ToolSearchToolResultErrorCode,
type ToolSearchToolResultErrorParam,
type ToolSearchToolSearchResultBlock,
type ToolSearchToolSearchResultBlockParam,
type ToolTextEditor20250124,
type ToolTextEditor20250429,
type ToolTextEditor20250728,
type ToolUnion,
type ToolUseBlock,
type ToolUseBlockParam,
type URLImageSource,
type URLPDFSource,
type Usage,
type UserLocation,
type WebFetchBlock,
type WebFetchBlockParam,
type WebFetchTool20250910,
type WebFetchTool20260209,
type WebFetchTool20260309,
type WebFetchToolResultBlock,
type WebFetchToolResultBlockParam,
type WebFetchToolResultErrorBlock,
type WebFetchToolResultErrorBlockParam,
type WebFetchToolResultErrorCode,
type WebSearchResultBlock,
type WebSearchResultBlockParam,
type WebSearchTool20250305,
type WebSearchTool20260209,
type WebSearchToolRequestError,
type WebSearchToolResultBlock,
type WebSearchToolResultBlockContent,
type WebSearchToolResultBlockParam,
type WebSearchToolResultBlockParamContent,
type WebSearchToolResultError,
type WebSearchToolResultErrorCode,
type MessageStreamEvent,
type MessageStartEvent,
type MessageStopEvent,
type ContentBlockDeltaEvent,
type MessageCreateParams,
type MessageCreateParamsBase,
type MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming,
type MessageCountTokensParams,
} from './messages';

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,269 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as BetaAPI from './beta/beta';
import { APIPromise } from '../core/api-promise';
import { Page, type PageParams, PagePromise } from '../core/pagination';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
export class Models extends APIResource {
/**
* Get a specific model.
*
* The Models API response can be used to determine information about a specific
* model or resolve a model alias to a model ID.
*/
retrieve(
modelID: string,
params: ModelRetrieveParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<ModelInfo> {
const { betas } = params ?? {};
return this._client.get(path`/v1/models/${modelID}`, {
...options,
headers: buildHeaders([
{ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
options?.headers,
]),
});
}
/**
* List available models.
*
* The Models API response can be used to determine which models are available for
* use in the API. More recently released models are listed first.
*/
list(
params: ModelListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<ModelInfosPage, ModelInfo> {
const { betas, ...query } = params ?? {};
return this._client.getAPIList('/v1/models', Page<ModelInfo>, {
query,
...options,
headers: buildHeaders([
{ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
options?.headers,
]),
});
}
}
export type ModelInfosPage = Page<ModelInfo>;
/**
* Indicates whether a capability is supported.
*/
export interface CapabilitySupport {
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
}
/**
* Context management capability details.
*/
export interface ContextManagementCapability {
/**
* Indicates whether a capability is supported.
*/
clear_thinking_20251015: CapabilitySupport | null;
/**
* Indicates whether a capability is supported.
*/
clear_tool_uses_20250919: CapabilitySupport | null;
/**
* Indicates whether a capability is supported.
*/
compact_20260112: CapabilitySupport | null;
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
}
/**
* Effort (reasoning_effort) capability details.
*/
export interface EffortCapability {
/**
* Whether the model supports high effort level.
*/
high: CapabilitySupport;
/**
* Whether the model supports low effort level.
*/
low: CapabilitySupport;
/**
* Whether the model supports max effort level.
*/
max: CapabilitySupport;
/**
* Whether the model supports medium effort level.
*/
medium: CapabilitySupport;
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
}
/**
* Model capability information.
*/
export interface ModelCapabilities {
/**
* Whether the model supports the Batch API.
*/
batch: CapabilitySupport;
/**
* Whether the model supports citation generation.
*/
citations: CapabilitySupport;
/**
* Whether the model supports code execution tools.
*/
code_execution: CapabilitySupport;
/**
* Context management support and available strategies.
*/
context_management: ContextManagementCapability;
/**
* Effort (reasoning_effort) support and available levels.
*/
effort: EffortCapability;
/**
* Whether the model accepts image content blocks.
*/
image_input: CapabilitySupport;
/**
* Whether the model accepts PDF content blocks.
*/
pdf_input: CapabilitySupport;
/**
* Whether the model supports structured output / JSON mode / strict tool schemas.
*/
structured_outputs: CapabilitySupport;
/**
* Thinking capability and supported type configurations.
*/
thinking: ThinkingCapability;
}
export interface ModelInfo {
/**
* Unique model identifier.
*/
id: string;
/**
* Model capability information.
*/
capabilities: ModelCapabilities | null;
/**
* RFC 3339 datetime string representing the time at which the model was released.
* May be set to an epoch value if the release date is unknown.
*/
created_at: string;
/**
* A human-readable name for the model.
*/
display_name: string;
/**
* Maximum input context window size in tokens for this model.
*/
max_input_tokens: number | null;
/**
* Maximum value for the `max_tokens` parameter when using this model.
*/
max_tokens: number | null;
/**
* Object type.
*
* For Models, this is always `"model"`.
*/
type: 'model';
}
/**
* Thinking capability details.
*/
export interface ThinkingCapability {
/**
* Whether this capability is supported by the model.
*/
supported: boolean;
/**
* Supported thinking type configurations.
*/
types: ThinkingTypes;
}
/**
* Supported thinking type configurations.
*/
export interface ThinkingTypes {
/**
* Whether the model supports thinking with type 'adaptive' (auto).
*/
adaptive: CapabilitySupport;
/**
* Whether the model supports thinking with type 'enabled'.
*/
enabled: CapabilitySupport;
}
export interface ModelRetrieveParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export interface ModelListParams extends PageParams {
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}
export declare namespace Models {
export {
type CapabilitySupport as CapabilitySupport,
type ContextManagementCapability as ContextManagementCapability,
type EffortCapability as EffortCapability,
type ModelCapabilities as ModelCapabilities,
type ModelInfo as ModelInfo,
type ThinkingCapability as ThinkingCapability,
type ThinkingTypes as ThinkingTypes,
type ModelInfosPage as ModelInfosPage,
type ModelRetrieveParams as ModelRetrieveParams,
type ModelListParams as ModelListParams,
};
}

View File

@@ -0,0 +1,85 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export interface APIErrorObject {
message: string;
type: 'api_error';
}
export interface AuthenticationError {
message: string;
type: 'authentication_error';
}
export interface BillingError {
message: string;
type: 'billing_error';
}
export type ErrorObject =
| InvalidRequestError
| AuthenticationError
| BillingError
| PermissionError
| NotFoundError
| RateLimitError
| GatewayTimeoutError
| APIErrorObject
| OverloadedError;
export interface ErrorResponse {
error: ErrorObject;
request_id: string | null;
type: 'error';
}
export type ErrorType =
| 'invalid_request_error'
| 'authentication_error'
| 'permission_error'
| 'not_found_error'
| 'rate_limit_error'
| 'timeout_error'
| 'overloaded_error'
| 'api_error'
| 'billing_error';
export interface GatewayTimeoutError {
message: string;
type: 'timeout_error';
}
export interface InvalidRequestError {
message: string;
type: 'invalid_request_error';
}
export interface NotFoundError {
message: string;
type: 'not_found_error';
}
export interface OverloadedError {
message: string;
type: 'overloaded_error';
}
export interface PermissionError {
message: string;
type: 'permission_error';
}
export interface RateLimitError {
message: string;
type: 'rate_limit_error';
}

View File

@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export {};