Chapter 10
Other Types
Additional type definitions for API keys, models, MCP servers, configuration, and sandbox settings.
ApiKeySourceType Alias
Indicates the source of the API key being used.
type ApiKeySource = 'user' | 'project' | 'org' | 'temporary';
| Value | Description |
|---|---|
'user' | API key from user settings |
'project' | API key from project configuration |
'org' | API key from organization |
'temporary' | Temporary API key for current session |
SdkBetaType Alias
Available beta features that can be enabled via the betas option. See Beta headers for more information.
type SdkBeta = 'context-1m-2025-08-07';
| Value | Description | Compatible Models |
|---|---|---|
'context-1m-2025-08-07' | Enables 1 million token context window | Claude Sonnet 4, Claude Sonnet 4.5 |
SlashCommandType
Information about an available slash command.
type SlashCommand = {
name: string;
description: string;
argumentHint: string;
}| Property | Type | Description |
|---|---|---|
name | string | The command name (without slash) |
description | string | Description of what the command does |
argumentHint | string | Hint for expected arguments |
ModelInfoType
Information about an available model.
type ModelInfo = {
value: string;
displayName: string;
description: string;
}| Property | Type | Description |
|---|---|---|
value | string | The model identifier |
displayName | string | Human-readable name for display |
description | string | Description of the model capabilities |
McpServerStatusType
Status of a connected MCP server.
type McpServerStatus = {
name: string;
status: 'connected' | 'failed' | 'needs-auth' | 'pending';
serverInfo?: {
name: string;
version: string;
};
}| Property | Type | Description |
|---|---|---|
name | string | The MCP server name |
status | 'connected' | 'failed' | 'needs-auth' | 'pending' | Current connection status |
serverInfo | object? | Optional server metadata (name, version) |
Status values:
'connected' | Successfully connected |
'failed' | Connection failed |
'needs-auth' | Requires authentication |
'pending' | Connection in progress |
AccountInfoType
Account information for the authenticated user.
type AccountInfo = {
email?: string;
organization?: string;
subscriptionType?: string;
tokenSource?: string;
apiKeySource?: string;
}| Property | Type | Description |
|---|---|---|
email | string? | User's email address |
organization | string? | Organization name |
subscriptionType | string? | Type of subscription |
tokenSource | string? | Source of the authentication token |
apiKeySource | string? | Source of the API key |
ModelUsageType
Per-model usage statistics returned in result messages.
type ModelUsage = {
inputTokens: number;
outputTokens: number;
cacheReadInputTokens: number;
cacheCreationInputTokens: number;
webSearchRequests: number;
costUSD: number;
contextWindow: number;
}| Property | Type | Description |
|---|---|---|
inputTokens | number | Number of input tokens used |
outputTokens | number | Number of output tokens generated |
cacheReadInputTokens | number | Tokens read from cache |
cacheCreationInputTokens | number | Tokens used to create cache |
webSearchRequests | number | Number of web search requests |
costUSD | number | Total cost in USD |
contextWindow | number | Context window size used |
ConfigScopeType Alias
Specifies the scope of configuration settings.
type ConfigScope = 'local' | 'user' | 'project';
| Value | Description |
|---|---|
'local' | Local (gitignored) settings |
'user' | Global user settings |
'project' | Project-specific settings |
UsageType
Token usage statistics (from @anthropic-ai/sdk).
type Usage = {
input_tokens: number | null;
output_tokens: number | null;
cache_creation_input_tokens?: number | null;
cache_read_input_tokens?: number | null;
}| Property | Type | Description |
|---|---|---|
input_tokens | number | null | Number of input tokens |
output_tokens | number | null | Number of output tokens |
cache_creation_input_tokens | number | null? | Tokens used to create cache |
cache_read_input_tokens | number | null? | Tokens read from cache |
NonNullableUsageType
A version of Usage with all nullable fields made non-nullable.
type NonNullableUsage = {
[K in keyof Usage]: NonNullable<Usage[K]>;
}CallToolResultType
MCP tool result type (from @modelcontextprotocol/sdk/types.js).
type CallToolResult = {
content: Array<{
type: 'text' | 'image' | 'resource';
// Additional fields vary by type
}>;
isError?: boolean;
}| Property | Type | Description |
|---|---|---|
content | Array | Array of content items (text, image, or resource) |
isError | boolean? | Whether the result represents an error |
AbortErrorClass
Custom error class for abort operations.
class AbortError extends Error {}Sandbox Configuration
Configuration for sandbox behavior. Use this to enable command sandboxing and configure network restrictions programmatically.
SandboxSettingsType
Configuration for sandbox behavior.
type SandboxSettings = {
enabled?: boolean;
autoAllowBashIfSandboxed?: boolean;
excludedCommands?: string[];
allowUnsandboxedCommands?: boolean;
network?: NetworkSandboxSettings;
ignoreViolations?: SandboxIgnoreViolations;
enableWeakerNestedSandbox?: boolean;
}| Property | Type | Description |
|---|---|---|
enabled | boolean? | Enable sandbox mode |
autoAllowBashIfSandboxed | boolean? | Auto-allow bash commands when sandboxed |
excludedCommands | string[]? | Commands excluded from sandbox |
allowUnsandboxedCommands | boolean? | Allow commands to run outside sandbox |
network | NetworkSandboxSettings? | Network restriction settings |
ignoreViolations | SandboxIgnoreViolations? | Which violations to ignore |
enableWeakerNestedSandbox | boolean? | Enable weaker nested sandbox mode |