TypeScript SDK
The TypeScript SDK gives you type-safe access to the GEN API from any Node.js or TypeScript project. Zero dependencies — uses native fetch.
Installation
Section titled “Installation”npm install @poweredbygen/gen-sdkQuick start
Section titled “Quick start”import { GenClient } from '@poweredbygen/gen-sdk';
const client = new GenClient({ apiKey: process.env.GEN_API_KEY });
// List your agentsconst agents = await client.listAgents();console.log(agents);
// Get an engineconst engine = await client.getEngine(agents[0].id, engineId);
// Generate content and wait for completionconst gen = await client.generateContent(agentId, engineId, cellId, 'text', { model: 'gemini', prompt: 'Write a 30-second script about morning routines',});const result = await client.waitForGeneration(gen.generation_id);console.log(result);Configuration
Section titled “Configuration”const client = new GenClient({ apiKey: 'your-api-key', // Required baseUrl: 'https://api.gen.pro/v1', // Optional (this is the default)});Available methods
Section titled “Available methods”Discovery
Section titled “Discovery”| Method | Description |
|---|---|
getMe() | Get authenticated user profile |
listWorkspaces() | List workspaces |
listAgents(workspaceId?) | List agents |
Agents
Section titled “Agents”| Method | Description |
|---|---|
createAgent(params) | Create a new agent |
getAgent(agentId) | Get agent details |
updateAgent(agentId, params) | Update agent |
deleteAgent(agentId) | Delete agent |
Organizations
Section titled “Organizations”| Method | Description |
|---|---|
listOrganizations() | List workspaces with credits and plan info |
createOrganization(name) | Create workspace |
getOrganization(orgId) | Get workspace details |
updateOrganization(orgId, params) | Update workspace |
deleteOrganization(orgId) | Delete workspace (irreversible) |
Content Engines
Section titled “Content Engines”| Method | Description |
|---|---|
createEngine(agentId, title) | Create engine |
getEngine(agentId, engineId) | Get engine with all data |
cloneEngine(agentId, engineId, targetAgentId?) | Clone engine |
Rows & Columns
Section titled “Rows & Columns”| Method | Description |
|---|---|
listRows(agentId, engineId) | List rows |
createRow(agentId, engineId) | Create row |
duplicateRow(agentId, engineId, rowId) | Duplicate row |
listColumns(agentId, engineId) | List columns |
createColumn(agentId, engineId, params) | Create column |
Cells & Layers
Section titled “Cells & Layers”| Method | Description |
|---|---|
getCell(agentId, engineId, cellId) | Get cell value |
updateCell(agentId, engineId, cellId, value) | Update cell |
createLayer(agentId, engineId, cellId, params) | Create layer |
deleteLayer(agentId, engineId, cellId, layerId) | Delete layer |
Generations
Section titled “Generations”| Method | Description |
|---|---|
generateContent(agentId, engineId, cellId, type, data?) | Trigger generation |
generateLayer(agentId, engineId, cellId, layerId) | Generate layer |
getGeneration(generationId) | Check status |
stopGeneration(generationId) | Stop generation |
waitForGeneration(generationId, options?) | Poll until complete (default 5 min timeout) |
Content Resources
Section titled “Content Resources”| Method | Description |
|---|---|
listContentResources(agentId, params?) | List files |
getContentResource(agentId, resourceId) | Get file details |
deleteContentResource(agentId, resourceId) | Delete file |
Generation types
Section titled “Generation types”Pass these as the type parameter to generateContent():
| Content | Type | Example data |
|---|---|---|
| Text | text | { model: 'gemini', prompt: '...' } |
| Image | image_from_text | { prompt: '...', model: 'gemini_pro_image', aspect_ratio: '1:1' } |
| Video | video_from_text | { prompt: '...', model: 'veo_3', duration: 10 } |
| Video from image | video_from_image | { prompt: '...', model: 'kling_2_1', image_resource_id: 123 } |
| Video from ingredients | video_from_ingredients | { prompt: '...', model: 'pika', asset_resource_ids: [123, 456] } |
| Speech | speech_from_text | { voice_method: 'my_voices', voice_id: '...', script: '...' } |
| Lipsync | lipsync | { model: 'sync_so', video_resource_id: 123, audio_resource_id: 456 } |
| Captions | captions | { source_resource_id: 123 } |
See Creation Cards for full parameter details.
Error handling
Section titled “Error handling”import { GenClient, GenApiError } from '@poweredbygen/gen-sdk';
try { await client.generateContent(agentId, engineId, cellId, 'text', { model: 'gemini', prompt: 'Write a hook', });} catch (error) { if (error instanceof GenApiError) { console.error(error.status); // 422 console.error(error.errorCode); // 'usable_gen_credit_required' console.error(error.message); // 'No active credits...' }}