Skip to main content

Overview

Python SDK for the SketricGen Chat Server API. Build AI-powered workflows, chat applications, and document analysis tools.

Requirements

  • Python 3.9+
  • Dependencies: httpx>=0.25.0, pydantic>=2.0.0, typing-extensions>=4.0.0

Installation

Or with other package managers:

Quick Start

Features

  • Run Workflows: Execute chat/workflow requests with AI agents
  • Streaming: Real-time streaming responses using Server-Sent Events
  • File Attachments: Attach images and PDFs to workflows
  • Async & Sync: Both async and synchronous API support
  • Type Safety: Full type hints for IDE support
  • Error Handling: Comprehensive custom exception types

Client Reference

SketricGenClient

The main client for interacting with the SketricGen API.

Constructor

From Environment Variables


run_workflow()

Execute a workflow/chat request (async).
Returns: ChatResponse if stream=False, AsyncIterator[StreamEvent] if stream=True

Example: Non-Streaming

Example: Streaming


run_workflow_sync()

Synchronous version of run_workflow().
Returns: ChatResponse if stream=False, Iterator[StreamEvent] if stream=True

Example


Response Models

ChatResponse

Response from a non-streaming workflow request.

StreamEvent

Individual event from a streaming response.

Streaming Events

The streaming API uses the AG-UI Protocol. Parse the data field as JSON to access event details.

Event Types

Complete Streaming Example


File Attachments

Attach files to workflows for document analysis and image understanding.

Supported File Types

Single File

Multiple Files

Streaming with Files