Deploy an Agent System as an API
Deploying an agent system means exporting the trained agent system, loading it into your production environment, and then asking the agent system for decisions. In AMESA, the export is a json file called agent.json that contains all you need to deploy your agent system. You can load the agent system file to use in your IT infrastructure with many ways.
This document will show how you can deploy your agent system as an API using Python and Flask.
Step 1: Accessing and Preparing the Files
To deploy the agent system as an API, we need to extract the agent.json model, get the agent_api.py script to start the API, requirements.txt to install packages. You can find a sample for these files in our GitHub repo: https://github.com/AMESA/examples.composabl.io/tree/main/deploy_agent
This is the structure needed for the API:

*** How to extract the agent.json ***
Log into the AMESA UI (https://app.amesa.com/onboarding), train your agent system, and navigate to the training sessions section.
Check the status of the agent system:
Green status (Done) indicates finished training.
Download the agent system essential file:
The agent system file (a
.gzcompressed file).Extract the agent system file
agent.jsonto themodelfolder
Step 2: Get the API python file
Step 3: Install the requirement packages
Run the following in your terminal:
It will install these packages:
composabl
flask[async]
numpy
Step 4: Export your license and start the API
To start AMESA API, you will need to export your license as an environment variable and then use Python to start the Flask API with your agent system.
Step 5: Test your API
After running the API, you can test it by opening the terminal and run the script below:
In the POST request, we pass the use case "observation" with sensor variables and their values to receive an action from the agent system. The code above is related to the agent.json demo for Chemical Process Control.
Last updated