MCPcopy Index your code
hub / github.com/simstudioai/sim / streamingExample

Function streamingExample

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

Source from the content-addressed store, hash-verified

108
109// Example 4: Workflow execution with streaming
110async function streamingExample() {
111 const client = new SimStudioClient({
112 apiKey: process.env.SIM_API_KEY!,
113 })
114
115 try {
116 const result = await client.executeWorkflow('your-workflow-id', {
117 input: {
118 message: 'Count to five',
119 },
120 stream: true,
121 selectedOutputs: ['agent1.content'], // Use blockName.attribute format
122 timeout: 60000,
123 })
124
125 if (result.success) {
126 console.log('✅ Workflow executed successfully!')
127 console.log('Output:', result.output)
128 console.log('Duration:', result.metadata?.duration, 'ms')
129 } else {
130 console.log('❌ Workflow failed:', result.error)
131 }
132 } catch (error) {
133 if (error instanceof SimStudioError) {
134 console.error('SDK Error:', error.message, 'Code:', error.code)
135 } else {
136 console.error('Unexpected error:', error)
137 }
138 }
139}
140
141// Run examples
142if (require.main === module) {

Callers 1

runExamplesFunction · 0.85

Calls 3

executeWorkflowMethod · 0.95
logMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected