Skip to content

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.

Terminal window
npm install @poweredbygen/gen-sdk
import { GenClient } from '@poweredbygen/gen-sdk';
const client = new GenClient({ apiKey: process.env.GEN_API_KEY });
// List your agents
const agents = await client.listAgents();
console.log(agents);
// Get an engine
const engine = await client.getEngine(agents[0].id, engineId);
// Generate content and wait for completion
const 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);
const client = new GenClient({
apiKey: 'your-api-key', // Required
baseUrl: 'https://api.gen.pro/v1', // Optional (this is the default)
});
MethodDescription
getMe()Get authenticated user profile
listWorkspaces()List workspaces
listAgents(workspaceId?)List agents
MethodDescription
createAgent(params)Create a new agent
getAgent(agentId)Get agent details
updateAgent(agentId, params)Update agent
deleteAgent(agentId)Delete agent
MethodDescription
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)
MethodDescription
createEngine(agentId, title)Create engine
getEngine(agentId, engineId)Get engine with all data
cloneEngine(agentId, engineId, targetAgentId?)Clone engine
MethodDescription
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
MethodDescription
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
MethodDescription
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)
MethodDescription
listContentResources(agentId, params?)List files
getContentResource(agentId, resourceId)Get file details
deleteContentResource(agentId, resourceId)Delete file

Pass these as the type parameter to generateContent():

ContentTypeExample data
Texttext{ model: 'gemini', prompt: '...' }
Imageimage_from_text{ prompt: '...', model: 'gemini_pro_image', aspect_ratio: '1:1' }
Videovideo_from_text{ prompt: '...', model: 'veo_3', duration: 10 }
Video from imagevideo_from_image{ prompt: '...', model: 'kling_2_1', image_resource_id: 123 }
Video from ingredientsvideo_from_ingredients{ prompt: '...', model: 'pika', asset_resource_ids: [123, 456] }
Speechspeech_from_text{ voice_method: 'my_voices', voice_id: '...', script: '...' }
Lipsynclipsync{ model: 'sync_so', video_resource_id: 123, audio_resource_id: 456 }
Captionscaptions{ source_resource_id: 123 }

See Creation Cards for full parameter details.

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...'
}
}