Run Recipe via REST API
This provides instructions on how to execute Omnitool recipes through the REST API, enabling seamless integration into your system.
Last updated
This provides instructions on how to execute Omnitool recipes through the REST API, enabling seamless integration into your system.
Last updated
To generate a JWT token, use the provided script with the following syntax:
Parameters
<action>
: String parameter for the intended action (use exec
for running recipes).
<subject>
: String parameter specifying the JWT subject, typically the recipe to execute.
<expires_in>
: Integer parameter for the token's validity in milliseconds.
<recipe_id>
: (Optional) Unique ID of the recipe.
Example
Generate a JWT for a recipe execution with 1-hour validity by running the command in Omnitool chat window:
Output
The script outputs a JWT for use in API request headers.
Security Considerations
Ensure JWT security to prevent unauthorized recipe access.
Use secure connections for API interactions.
Rotate tokens regularly and prefer short expiration times.
Troubleshooting
If you encounter authorization issues, verify the JWT's expiration, correct header setup, and parameter accuracy.
With your JWT, make a POST request to the recipe execution API, including the JWT in the Authorization header.
Endpoint
Header
<token>
is the JWT acquired from the /generateJwtToken script.
Curl Example
To make the request using curl, you would use the following command, replacing with your actual JWT:
Request Body
The args
parameter acts as a input container for executing recipes, capable of passing various data types to the Chat Input as a starting block. These data types include images, text, audio, video, documents, and even structured JSON objects.
Response
Upon success, the API will initiate the specified recipe. You will receive a JSON response containing details about the recipe's execution status, including any outputs or errors.
Ensure that your recipe includes the 'Recipe Output' block for proper execution and result retrieval.
Once a job is finished, retrieve results with:
Refer to examples/api.mjs for a end-to-end sample JavaScript implementation.