Run a workflow through the API

To run a workflow through the API, use API access in AI Flowi Workflow by Ai Flowi. Create a workflow API key, choose the component fields to expose, and copy a Python, JavaScript or cURL example. Send a request to the workflow endpoint and check the response. Endpoint Name allows up to 20 characters.

Published · Updated

Product: AI Flowi Workflow by Ai Flowi · Task: Run a saved workflow through its API

When to use this

Use API access when your application needs to send input to a workflow and read its response. Workflow API keys call the workflow endpoint; API Hub keys belong to the separate model-access service.

Related: API gateway: understand entry routing, policies and backend boundaries.

Before you start

  • Open the saved workflow you intend to call and test it with harmless input.
  • Have the workspace host address ready for your request.
  • Keep the secret API key in server-side code. Do not expose it in browser code or share it with others.

Steps

1. API Keys · Add New

Open Settings, then API Keys, and select Add New. In Create API Key, enter an optional Description and select Generate API Key. Save the generated secret somewhere safe; you cannot view it again through your account. Generate a new key if you lose it.

2. Share · API access

Return to the workflow canvas. Open Share and choose API access. The API access dialog links to key creation in settings and provides request examples for the current workflow.

3. Input Schema · Endpoint Name · Expose API

Open Input Schema. Under Expose API, select the component fields to include as API inputs. The generated request includes selected component values in tweaks when they are present.

Endpoint Name is optional. Use letters, numbers, hyphens or underscores, with a maximum of 20 characters. Leave it empty to use the workflow ID in the run URL. Close Input Schema and save the workflow before copying the request.

4. Python, JavaScript or cURL

Choose Python, JavaScript or cURL and copy the generated code. For cURL, select macOS/Linux or Windows to match your shell. Replace the API key placeholder with your workflow API key and review the request input.

This macOS/Linux example sends text to a workflow with chat input and chat output. Replace YOUR-WORKSPACE, YOUR_WORKFLOW_ID and YOUR_API_KEY_HERE before running it. For other workflows, use the input_type, output_type and tweaks from your generated example.

curl --request POST \
  --url 'https://YOUR-WORKSPACE/api/v1/run/YOUR_WORKFLOW_ID?stream=false' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --data '{"input_value":"Hello","input_type":"chat","output_type":"chat","session_id":"YOUR_SESSION_ID_HERE"}'

Run the request from your server or terminal and inspect the response. Compare the returned output with your tested workflow before connecting it to your application.

Common mistakes

  • Using an API Hub key where the workflow request expects a workflow API key.
  • Copying a request before saving an Endpoint Name change.
  • Using Windows shell syntax in a macOS/Linux terminal, or the reverse.
  • Assuming a text-only example includes file-upload steps. For file inputs, follow the upload steps in the generated example before the run request.

Troubleshooting

If the request fails, inspect the error response and check the host, workflow ID or Endpoint Name, key and request body. In API Keys, review Last Used and Total Uses when checking whether a key has been used.

To remove an unused key, select its row in API Keys and use the table deletion control. Check that the key is removed from the list; the page reports a deletion error if the request fails.

Related

Documentation · AI Flowi Workflow · API Hub model access · Language and display settings · Workflow publishing · Publish a workflow as a web app · Pricing · Book a demo