Overview
Node.js SDK for the SketricGen Chat Server API. Build AI-powered workflows, chat applications, and document analysis tools with TypeScript or JavaScript.Requirements
- Node.js 18 or later (uses built-in
fetch,FormData,Blob, and streams) - ESM: use
"type": "module"inpackage.jsonor.mjsfiles
Installation
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 (paths or explicit upload)
- TypeScript: Full type definitions included
- Error Handling: Typed error classes (e.g.
SketricGenAPIError,SketricGenValidationError) - CLI Help: Run
npx sketricgen --helpornpx sketricgen --help runWorkflowfor usage
Client Reference
SketricGenClient
The main client for interacting with the SketricGen API.Constructor
From Environment Variables
runWorkflow()
Execute a workflow/chat request.Promise<ChatResponse> if stream is false or omitted; AsyncGenerator<StreamEvent> if stream: true.
Example: Non-Streaming
Example: Streaming
files.upload()
Upload a file and get afileId for use in runWorkflow(..., { assets: [fileId] }).
file is a path string, filename and contentType are optional (inferred from the path). When file is a Buffer or Node Readable stream, filename is required.
Response Models
ChatResponse
Response from a non-streaming workflow request.StreamEvent
Individual event from a streaming response.
Parse
event.data with JSON.parse(event.data) to access the payload. The parsed object may include a type field matching event_type.
Streaming Events
The streaming API uses the AG-UI Protocol. Parse thedata field as JSON to access event details.

