Skip to main content
Status: Actively Maintained - The Python SDK is actively maintained alongside the TypeScript SDK and provides full feature parity.

Chucky Client

The main client class for interacting with Chucky in Python.

Installation

Or with Poetry:

Import

Constructor

Parameters

Example

Methods

prompt()

Send a one-shot prompt and get the response.

Parameters

Returns

PromptResult with the response.

Example


stream()

Send a prompt with streaming response.

Example


create_session()

Create a new conversation session. Returns a Session immediately; connection happens on first send().

Example


close()

Close the client and release resources.

Example

Session Class

The Session class provides a multi-turn conversation interface.

Methods

send()

Send a message to the session. Use stream() to get the response.

stream()

Stream the response after sending a message.
Returns an async iterator of SDK messages (dicts with type, message, etc.).

receive()

Alias for stream() for V2 SDK compatibility.

close()

Close the session and release resources.

Properties

session_id

The session’s unique identifier.

Session Example

Message Types

Messages are dictionaries matching the SDK protocol.

Result Message

Assistant Message

Helper Functions

Use these helpers to extract text from messages:

StreamEvent (Legacy)

For the legacy client.stream() API:

Complete Example

Error Handling

Errors are returned as result messages with subtype: 'error':
For streaming, check for error messages: