Skip to content

ZettCode SDK ​

The ZettCode SDK brings the coding agent to your Python programs without a terminal. Everything the terminal application offers — running prompts, streaming progress, answering approvals, managing sessions, switching models, compacting, exporting — is available from code, running the same agent, tools, plugins, MCP servers, skills, and project instructions.

What it does ​

python
import zettcode.sdk as zc

result = await zc.prompt("fix the failing test", workspace=".", permission="safe")
print(result.text)
  • Run prompts and read the result, or stream events as they happen
  • Answer approvals and questions with handlers or by responding to events
  • Manage sessions — create, continue, fork, export, and read history
  • Switch models and permission levels mid-conversation
  • Resume interrupted requests from where they stopped
  • Compact, measure context, check usage programmatically

The same session can be started in code and continued in the terminal, or the other way round. The SDK uses the same session store.

Who it's for ​

  • Scripts that need an agent to run unattended: test fixtures, CI pipelines, batch processing
  • Tools that embed ZettCode: editors, IDEs, automation frameworks
  • Custom UIs that want the agent without the terminal application's interface
  • Research and experimentation where the conversation is data

Installation ​

bash
pip install zettcode

The SDK is part of the zettcode package. Importing it costs nothing; the agent loads when a client is made.

python
import zettcode.sdk as zc

First steps ​

Guides ​

Examples ​

The Cookbook shows complete programs:

  • Unattended scripts with approval rules
  • Progress bars and live output
  • Multi-session workflows
  • Error handling and retry logic
  • Integration with existing code

Reference ​

API reference — every class, method, and attribute

Key differences from the terminal ​

  • No broker by default: sessions_enabled=False, so terminal sessions cannot message SDK clients
  • No release checks: update_enabled=False
  • Working directory: creating a client changes it to the workspace; closing the last client restores it
  • One workspace per process: two clients on different workspaces cannot be open at once

Next ​

Start with the Quickstart to see the SDK in action, then move to Core concepts for how the pieces fit together.

Released under the MIT license.