API Reference claude_agent_sdk v#0.14.0

Copy Markdown View Source

Modules

An Elixir SDK for Claude Code.

Lightweight cancellation token shared with callbacks.

Agent definition for custom agent profiles.

Enumerates assistant-level error codes surfaced by the Claude CLI.

Multi-provider authentication abstraction.

Anthropic-specific authentication via claude setup-token.

AWS Bedrock authentication.

Google Vertex AI authentication.

Persistent token storage for authentication.

Authentication checker and environment validator for Claude Code SDK.

Manages authentication tokens for Claude Code SDK.

Centralized Claude CLI discovery and version tracking.

Bidirectional client for Claude Code with hooks support.

Top-level configuration facade for the SDK.

Authentication configuration: file paths, TTLs, and token prefixes.

Buffer sizes, batch limits, and display truncation lengths.

CLI binary discovery, version constraints, and shared flag builders.

Canonical registry of all environment variable names the SDK reads.

Concurrency limits, retry policies, and orchestrator defaults.

Canonical timeout values for the SDK.

Content extraction helper for Claude Code SDK messages.

Control protocol message encoding and decoding.

Comprehensive debugging and diagnostics for Claude Code SDK.

Structured error types for programmatic handling.

Raised when the SDK fails to connect to the Claude CLI process.

Raised when the SDK fails to decode JSON output from the CLI.

Raised when the Claude CLI executable cannot be found.

Base exception for all Claude Agent SDK errors.

Guard macros for pattern matching SDK errors.

Raised when a message from the CLI cannot be parsed into a known type.

Raised when the Claude CLI process exits with an error.

Type definitions and utilities for Claude Code Hooks.

Hook matcher configuration.

Hook output structure and helpers.

Hook callback registration and ID management.

Simple JSON parser for Claude Code SDK.

SDK-scoped logger wrapper with a configurable minimum log level.

Represents a message from Claude Code CLI.

Mock implementation for the Claude Code CLI for testing purposes.

Mock process implementation that returns predefined responses instead of spawning a CLI.

Config-driven model validation and normalization.

Smart option builder for Claude Code SDK configurations.

Configuration options for Claude Code SDK requests.

Concurrent query orchestration with rate limiting and error recovery.

Permission System for Claude Agent SDK.

Permission context passed to permission callbacks.

Permission result returned by permission callbacks.

Permission rule value struct.

Permission update types for configuring permissions via the control protocol.

Handles spawning and communicating with the Claude Code CLI process using erlexec.

Handles querying Claude Code and processing responses.

Streams CLI-only query responses over a transport.

Wraps the ClaudeAgentSDK.Client GenServer to provide a Stream interface.

Helper functions for working with Claude sessions.

Persistent session storage and management.

Bidirectional streaming for interactive Claude conversations.

Utilities for working with heterogeneous streaming event/message streams.

Parses streaming events from Claude CLI's --include-partial-messages output.

GenServer managing a persistent bidirectional streaming session with Claude.

Shared termination logic for streaming sessions.

Optional Task.Supervisor for supervised callback execution.

Tool definition macro for creating in-process MCP tools.

GenServer that manages tool registration and execution for SDK MCP servers.

Behaviour describing the transport layer used to communicate with the Claude CLI.

Transport implementation backed by erlexec.

Selects streaming transport based on required features.

Mix Tasks

Sets up a long-lived authentication token for Claude Code SDK.

Runs Elixir scripts against the live Claude API instead of using mocks.

Run the Claude Code SDK comprehensive showcase.

Runs tests against the live Claude API instead of using mocks.