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
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 aSession 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. Usestream() to get the response.
stream()
Stream the response after sending a message.type, message, etc.).
receive()
Alias forstream() 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 legacyclient.stream() API:
Complete Example
Error Handling
Errors are returned as result messages withsubtype: 'error':