Skip to main content
Community Maintained - This SDK is functional but receives limited maintenance. For production use, we recommend the TypeScript SDK or Python SDK.

Session

The Session manages multi-turn conversations with Claude.

Creating Sessions

Sessions are created via the client.

Methods

Send()

Send a message to Claude. Auto-connects if needed.

Example


Stream()

Stream the response after sending a message. Returns a channel that yields incoming messages.

Message Types

Example


Receive()

Alias for Stream().

Connect()

Manually connect the session. Called automatically by Send().

Close()

Close the session and release resources.

Example


On()

Register event handlers.

SessionEventHandlers

Example


ID()

Get the session ID.

State()

Get the current session state.

SessionState Values

Helper Functions

GetAssistantText()

Extract text content from an assistant message.

Example


GetResultText()

Extract result text from a result message.

Usage Patterns

Basic Conversation

With Timeout

Error Handling