For Local Machine
Prerequisites
Ensure the following are installed and configured on your system:
Node.js (v16 or higher) Download Node.js
npm (Node Package Manager) Comes bundled with Node.js.
Firebase Service Account Key Required for local Firestore authentication.
OpenAI API Key Obtain an API key from OpenAI.
Dependencies
The project utilizes the following dependencies:
express
^4.21.2
Web framework for building API endpoints.
cors
^2.8.5
Middleware to handle Cross-Origin Resource Sharing (CORS).
firebase-admin
^13.0.2
Firebase Admin SDK for Firestore integration.
dotenv
^16.4.7
Secure management of environment variables.
openai
^4.77.3
Integration with OpenAI’s GPT models for AI interactions.
Install all dependencies:
Setup
1. Clone the Repository
2. Install Dependencies
3. Configure Environment Variables
Create a .env file in the root directory:
Add the following variables to your .env file:
4. Add Firebase Credentials
Copy the sample file and replace placeholders with your Firebase credentials:
Edit: serviceAccountKey.json
Running the API Locally
Start the server:
Access the API locally:
API Endpoints
1. Fetch Agent Details
Retrieve metadata for an AI agent.
GET /api/agent/:name
Request Example:
Response Example:
2. Interact with an Agent (GET Method)
Interact with an AI agent using a query parameter.
GET /api/agent/:name/interact?message=YourMessage
Request Example:
Response Example:
3. Interact with an Agent (POST Method)
Interact with an AI agent using a JSON payload.
POST /api/agent/:name/interact
Request Example:
Response Example:
Example Usage in Node.js
Here’s how you can interact with the API programmatically:
Last updated