MCPcopy
hub / github.com/simstudioai/sim / basicExample

Function basicExample

packages/ts-sdk/examples/basic-usage.ts:4–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3// Example 1: Basic workflow execution
4async 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
31async function withInputExample() {

Callers 1

runExamplesFunction · 0.85

Calls 3

executeWorkflowMethod · 0.95
logMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected