bumpy-boots-2043
07/14/2023, 10:06 AMBearer TOKENEXAMPLE
,
"Content-Type": "application/json"
}
const data = {
"in-0": workflow.question,
}
try {
const response = await axios.post(endpoint, data, { headers })
workflow.apiResponse = response.data["out-0"]
} catch (error) {
throw new Error(stack-error: ${error}
)
}acceptable-kangaroo-64719
07/14/2023, 11:48 AMjs
// Set these to the names of your stack-AI in/out nodes
var inNode = 'in-0'
var outNode = 'out-0'
// Change this to your Stack-AI URL
let url =
'https://www.stack-inference.com/run_deployed_flow?flow_id=64b12e0b300d2b8f5f828099&org=8dc59f7b-40a4-41c4-ad11-d5e0f4691e27'
try {
const response = await axios.post(
url,
{ [inNode]: `${event.preview}` },
// Be sure to set your API key as an env variable
{ headers: { Authorization: `Bearer ${env.apiKey}`, 'Content-Type': 'application/json' } }
)
workflow.stackAIResponse = response.data[outNode]
} catch (e) {
console.error(`There was an error calling Stack-AI: ${e}`)
}
acceptable-kangaroo-64719
07/14/2023, 11:49 AMapiKey
with your Stack ai API keybumpy-boots-2043
07/14/2023, 1:18 PM