()
| 2 | |
| 3 | // Example 1: Basic workflow execution |
| 4 | async function basicExample() { |
| 5 | const client = new SimStudioClient({ |
| 6 | apiKey: process.env.SIM_API_KEY!, |
| 7 | baseUrl: 'https://sim.ai', |
| 8 | }) |
| 9 | |
| 10 | try { |
| 11 | // Execute a workflow without input |
| 12 | const result = await client.executeWorkflow('your-workflow-id') |
| 13 | |
| 14 | if (result.success) { |
| 15 | console.log('✅ Workflow executed successfully!') |
| 16 | console.log('Output:', result.output) |
| 17 | console.log('Duration:', result.metadata?.duration, 'ms') |
| 18 | } else { |
| 19 | console.log('❌ Workflow failed:', result.error) |
| 20 | } |
| 21 | } catch (error) { |
| 22 | if (error instanceof SimStudioError) { |
| 23 | console.error('SDK Error:', error.message, 'Code:', error.code) |
| 24 | } else { |
| 25 | console.error('Unexpected error:', error) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // Example 2: Workflow execution with input data |
| 31 | async function withInputExample() { |
no test coverage detected