Skip to main content

Overview

SketricGen provides a high-performance Public API service that enables AI-powered conversational workflows using custom agents you design in the Web App. This API provides endpoints for running AI workflows, managing conversations, and streaming real-time responses. Base URL: https://chat-v2.sketricgen.ai/api/v1

Authentication

All API requests require authentication via an API key in the request headers. Required Header:
api-key: your_api_key_here
(You can retrieve it from your account setting at app.sketricgen.ai/profile)

Endpoints

Run Workflow

POST /run-workflow Execute an AI workflow using a specified agent to generate intelligent responses based on user input.

Request Headers

HeaderTypeRequiredDescription
api-keystringYesYour API authentication key
Content-TypestringYesMust be application/json

Request Body

FieldTypeRequiredDescriptionConstraints
agent_idstringYesUnique identifier for the AI agent to use-
user_inputstringYesThe user’s message or query to processMax 10,000 characters
conversation_idstringNoID of existing conversation to continueIf omitted, creates new conversation
contact_idstringNoExternal identifier to associate conversation with a contactMax 255 characters
streambooleanNoEnable real-time response streamingDefault: false

Example Request

{
	"agent_id": "agent_abc123xyz",
	"user_input": "Help me analyze this quarterly sales data",
	"conversation_id": "conv_def456ghi",
	"contact_id": "customer_12345",
	"stream": false
}

Response Formats

The endpoint supports two response modes.

1. Standard Response (stream: false)

HTTP Status: 201 Created Response Body:
FieldTypeDescription
agent_idstringThe agent that processed the request
user_idstringIdentifier for the user account
conversation_idstringID of the conversation (new or existing)
contact_idstringExternal contact identifier (if provided)
responsestringThe AI agent’s generated response
ownerstringOwner of the agent
errorbooleanIndicates if an error occurred
Example Response:
{
	"agent_id": "agent_abc123xyz",
	"user_id": "user_789xyz",
	"conversation_id": "conv_def456ghi",
	"contact_id": "customer_12345",
	"response": "I'll help you analyze your quarterly sales data. Please share the data file or provide the key metrics you'd like me to examine.",
	"owner": "company_abc",
	"error": false
}

2. Streaming Response (stream: true)

HTTP Status: 200 OK Content-Type: text/event-stream When streaming is enabled, the endpoint returns real-time Server-Sent Events (SSE) as the AI processes the request. Event Types:
Event TypeDescription
RUN_STARTEDWorkflow execution has begun
TEXT_MESSAGE_STARTAI has started generating a text response
TEXT_MESSAGE_CONTENTIncremental text content (streaming)
TEXT_MESSAGE_ENDAI has finished generating text response
TOOL_CALL_STARTAI has started using a tool/function
TOOL_CALL_ENDAI has finished using a tool/function
RUN_FINISHEDWorkflow execution completed successfully
RUN_ERRORAn error occurred during execution
Example Streaming Events:
data: {"type": "RUN_STARTED", "timestamp": 1640995200, "thread_id": "conv_def456ghi", "run_id": "run_123abc"}

data: {"type": "TEXT_MESSAGE_START", "timestamp": 1640995201, "message_id": "msg_456def"}

data: {"type": "TEXT_MESSAGE_CONTENT", "timestamp": 1640995202, "message_id": "msg_456def", "delta": "I'll help"}

data: {"type": "TEXT_MESSAGE_CONTENT", "timestamp": 1640995203, "message_id": "msg_456def", "delta": " you analyze"}

data: {"type": "TEXT_MESSAGE_END", "timestamp": 1640995210, "message_id": "msg_456def"}

data: {"type": "RUN_FINISHED", "timestamp": 1640995211, "thread_id": "conv_def456ghi", "run_id": "run_123abc"}
I