Step 2: Add Hydra AI
In this step, we'll install Hydra, add a Hydra config file to the app, and get a Hydra API key set.
Add Hydra AI
Before we can have Hydra respond to messages and control UI components, we need to install and configure it.
-
Install Hydra AI dependency
First, we'll install Hydra AI by running the following command:
-
Add Hydra Config file
Next, we'll create a Hydra config file, where we create an instance of Hydra and eventually register the components we want it to use.
Add a new file called
hydra-config.ts
undersrc/
with the following contents:You can see that this HydraClient is initialized with the API key from the environment variables. We'll set that up next.
-
Set Hydra API key
Finally, we'll set the Hydra API key in the environment variables.
You can get a Hydra API key by creating a new Hydra "project" in the Hydra dashboard here.
Once you've created a project and copied an API key, add the following to the
.env
file:Now your full
.env
file should look like this:
In the next step, we'll add a message listener that uses Hydra to respond to user messages.