Skip to main content

Overview

The sketricgen Python package provides one typed SketricGenClient for the Runtime API and the supported Admin API operations. Use it to run agents, stream responses, attach files, handle human-in-the-loop (HITL) pauses, browse Teamspace resources, and manage Brand Agents and connectors. SDK version 0.3.0 removed the separate AdminClient. The same client now routes runtime and management calls to the correct API.

Requirements

  • Python 3.9 or later
  • sketricgen>=0.3.0
  • A Teamspace API key beginning with sk_api_
Create the key from Teamspace settings → API keys → Create key. Enable Run agents for workflow calls, Manage resources for control-plane calls, or both for the complete SDK surface. Project scope, agent restrictions, and management role still apply.

Installation

Or with another package manager:

Configure the client

Set the single supported API-key environment variable:
Then create one client for runtime and management operations:
You can also pass the key directly:
SKETRICGEN_RUNTIME_API_KEY, SKETRICGEN_ADMIN_API_KEY, and AdminClient are not supported in version 0.3.0. Replace them with SKETRICGEN_API_KEY and SketricGenClient.

Run an agent

Async

Sync

Both methods accept the same arguments:
user_input is required unless the request resumes a HITL pause or includes at least one file. Its maximum length is 10,000 characters.

Stream a response

run_workflow(..., stream=True) returns an async iterator. The synchronous method returns a regular iterator.
The SDK marks RUN_FINISHED, RUN_ERROR, and RUN_PAUSED_HITL as terminal through event.is_terminal.

Handle human-in-the-loop requests

HITL is opt-in. Set enable_hitl=True on the initial request and every resume request where the agent may pause for an answer, approval, or rejection.
Each decision must use a type allowed by the corresponding review_configs entry: For multiple pending actions, provide one decision per action in the same order as hitl_request.action_requests. Resume on the same conversation_id, include the returned request_id, and do not send a new user_input. A resumed run can pause again. For streaming runs, capture the deep_agents_hitl custom event and stop when RUN_PAUSED_HITL arrives. Resume with a new run_workflow() call using the same typed HitlResume payload.

Attach files

Pass one or more local paths through file_paths. The SDK uploads them in parallel, registers the resulting assets, and includes them in the workflow request.
Each file can be up to 20 MB.

Supported file types

An unsupported type raises SketricGenContentTypeError; an oversized file raises SketricGenFileSizeError.

Use the control plane

Management operations use namespaces on the same SketricGenClient. The API key must have Manage resources access.

Identify the Teamspace

List scoped resources

Project, agent, and knowledge-base lists transparently follow pagination. They fetch pages lazily as you consume the iterator.
Use list_sync() on each namespace for synchronous iteration.

Manage Brand Agents

The namespace also provides list_templates(), create(), and get_status(). Every async method has a synchronous _sync variant.

Manage connectors

Connector methods also have synchronous _sync variants. Opening the hosted connection link and completing external authorization remains a human step.

Response models

ChatResponse

StreamEvent

Error handling

Control-plane errors expose a machine-readable code. All SDK-specific errors inherit from SketricGenError.