Files

28 lines
761 B
JavaScript

const url = `${process.env.FLOW_SERVER_URL ?? ""}/v1/run/${process.env.FLOW_ID ?? ""}`;
const options = {
method: 'POST',
headers: {
"Content-Type": `application/json`,
"x-api-key": `${process.env.FLOW_API_KEY ?? ""}`,
"X-FLOW-GLOBAL-VAR-OPENAI_API_KEY": `sk-...`,
"X-FLOW-GLOBAL-VAR-USER_ID": `user123`,
"X-FLOW-GLOBAL-VAR-ENVIRONMENT": `production`,
},
body: JSON.stringify({
"input_value": "Tell me about something interesting!",
"input_type": "chat",
"output_type": "chat"
}),
};
fetch(url, options)
.then(async (response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
console.log(text);
})
.catch((error) => console.error(error));