Gensx
The TypeScript framework for agents & workflows with react-like components. Lightning fast dev loop. Easy to learn. Easy to extend.
Install / Use
/learn @gensx-inc/GensxREADME
GenSX ⚡️
GenSX is a simple TypeScript framework for building complex LLM applications. It's a workflow engine designed for building agents, chatbots, and long-running workflows.
Why GenSX?
- 🎯 Pure Functions: Components are pure TypeScript functions that are easily testable, reusable, and sharable
- 🌴 Natural Composition: Building workflows is as simple as composing functions together
- 🔒 Type-safe: Full TypeScript support with no DSLs or special syntax - just standard language features
- 🚀 Built for Scale: Start simple and evolve to complex patterns like agents and reflection without changing your programming model
- 📊 Automatic Tracing: Real-time tracing of all component inputs/outputs, tool calls, and LLM calls making debugging and observability easy
- ☁️ One-Click Deployment: Deploy workflows as REST APIs with a single command, optimized for long-running LLM workloads up to 60 minutes
- 💾 Built-in Storage: Zero-config blob storage, SQL databases, and vector search for building stateful agents and workflows
Check out the documentation to learn more about building LLM applications with GenSX.
Building a workflow
Most LLM frameworks are graph oriented--you express your workflow with nodes, edges, and a global state object. GenSX takes a different approach--you compose your workflow with components, and GenSX handles the execution for you.
Components in GenSX look a lot like functions. You create them by passing in a function and a name to gensx.Component(), a higher order function::
import * as gensx from "@gensx/core";
import { openai } from "@ai-sdk/openai";
import { generateText } from "@gensx/vercel-ai";
// input interface
interface WriteDraftInput {
research: string[];
prompt: string;
}
// components are pure functions that are reusable by default
const WriteDraft = gensx.Component(
"WriteDraft",
async ({ prompt, research }: WriteDraftInput) => {
const systemMessage = `You're an expert technical writer.
Use the information when responding to users: ${research}`;
const result = await generateText({
messages: [
{
role: "system",
content: systemMessage,
},
{
role: "user",
content: `Write a blog post about ${prompt}`,
},
],
model: openai("gpt-4.1-mini"),
});
return result.text;
},
);
Components can be composed together to create more complex agents and workflows:
import * as gensx from "@gensx/core";
import { OpenAIProvider } from "gensx/openai";
import { Research, WriteDraft, EditDraft } from "./writeBlog";
interface WriteBlogInput {
title: string;
description: string;
}
const WriteBlog = gensx.Workflow(
"WriteBlog",
async ({ title, description }: WriteBlogInput) => {
const queries = await GenerateQueries({
title,
description,
});
const research = await ResearchBlog({ queries });
const draft = await WriteDraft({ title, context: research });
const final = await EditDraft({ title, content: draft });
return final;
},
);
const result = await WriteBlog({
title: "How AI broke modern infra",
description: "Long-running workflows require a new approach to infra",
});
Getting Started
Check out the Quickstart Guide to build your first workflow in just a few minutes.
Examples
This repo contains a number of examples to help you get up and running with GenSX.
To run an example:
cd examples/<example-name>
pnpm install
pnpm start
Basic Examples
| Example | Description | | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | | 🔄 Reflection | Shows how to use a self-reflection pattern with GenSX | | 🦾 Anthropic Examples | Examples showing how to use @gensx/anthropic | | 🧠 OpenAI Examples | Examples showing how to use @gensx/openai | | 🌊 Vercel AI SDK Examples | Examples showing how to use @gensx/vercel-ai |
Full Examples
| Example | Description | | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------- | | 🔍 Hacker News Analyzer | Analyzes HN posts and generates summaries and trends using Paul Graham's writing style | | ✍️ Blog Writer | Generates blogs through an end-to-end workflow including topic research and content creation | | 🔬 Deep Research | Generates a report from a prompt after researching and summarizing a list of research papers | | 💻 Computer Use | Demonstrates how to use the OpenAI computer use tool with GenSX | | 🗄️ Text to SQL | Shows how to use database storage to translate natural language to SQL queries | | 🔎 RAG | Demonstrates retrieval augmented generation using vector search storage | | 💬 Chat Memory | Shows how to build a chat application with persistent chat history using blob storage |
Working with this repo
This monorepo contains GenSX, its related packages, examples, and documentation. You can find more detailed instructions in CONTRIBUTING.md.
Repository Structure
packages/- Published packagesexamples/- Example applications and use caseswebsite/- GenSX website
