Skip to content

Commit 1fecdb2

Browse files
authored
Update README.md
1 parent 7338cd9 commit 1fecdb2

File tree

1 file changed

+41
-20
lines changed

1 file changed

+41
-20
lines changed

README.md

+41-20
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ Welcome to the **AI Models Integration** repository! This project provides seaml
66

77
## 🚀 Features
88

9-
- **Unified API**:Interact with multiple AI models through a single, streamlined interface
10-
- **Extensibility**:Easily add and integrate new AI models as they become available
11-
- **Scalability**:Designed to handle multiple requests efficiently, ensuring optimal performance
9+
- **Unified API**: Interact with multiple AI models through a single, streamlined interface.
10+
- **Extensibility**: Easily add and integrate new AI models as they become available.
11+
- **Scalability**: Designed to handle multiple requests efficiently, ensuring optimal performance.
12+
- **Rate Limiting**: Exponential backoff retries to prevent abuse.
13+
- **Caching**: Redis is used to cache frequent queries for better performance.
14+
- **Validation**: All user input is validated with Zod for a secure and reliable API.
15+
- **Streaming**: Real-time responses for long-running processes.
16+
- **Monitoring**: Integrated Prometheus metrics to track API usage and errors.
1217

1318
## 🧠 Integrated AI Models
1419

@@ -24,8 +29,13 @@ Welcome to the **AI Models Integration** repository! This project provides seaml
2429
- *Node.js*: JavaScript runtime environment.
2530
- *Express*: Fast, unopinionated, minimalist web framework for Node.js.
2631
- *OpenAI SDK*: Integration with OpenAI's API for AI model interaction.
32+
- *Redis*: In-memory data structure store used for caching and rate limiting.
33+
- *Zod*: Input validation for secure and structured API interactions.
34+
- *Prometheus*: Monitoring of API usage, errors, and performance.
35+
- *ioredis*: Redis client used for integrating caching and rate limiting features.
2736

2837
## 📦 Installation
38+
2939
### Step 1: Clone the Repository
3040
```bash
3141
git clone https://github.com/JawherKl/ai-models-integration.git
@@ -38,24 +48,28 @@ npm install
3848
```
3949

4050
### Step 3: Set up Environment Variables
41-
- Create a .env file in the root directory.
42-
- Add your configuration variables (e.g., API keys, model endpoints).
43-
```bash
44-
API_KEY=api_key_from_openrouter.ai
45-
BASE_URL=https://openrouter.ai/api/v1
46-
```
51+
- Create a `.env` file in the root directory.
52+
- Add your configuration variables (e.g., API keys, model endpoints).
53+
```bash
54+
API_KEY=api_key_from_openrouter.ai
55+
BASE_URL=https://openrouter.ai/api/v1
56+
REDIS_HOST=127.0.0.1
57+
REDIS_PORT=6379
58+
```
4759

4860
## 🚀 Usage
61+
4962
### Start the Server
5063
```bash
5164
npm start
5265
```
5366

5467
### Access the API
55-
-The server will run on http://localhost:3000 by default.
56-
-Use the provided endpoints to interact with the integrated AI models.
68+
- The server will run on `http://localhost:3000` by default.
69+
- Use the provided endpoints to interact with the integrated AI models.
5770

5871
### Example Requests
72+
5973
#### Search request
6074
```bash
6175
curl -X POST http://localhost:3000/search \
@@ -70,6 +84,14 @@ curl -X POST http://localhost:3000/analyze \
7084
-d '{"model": "change_with_model_example", "text": "Tesla announced new solar roof technology with 25% improved efficiency in Q4 2023."}'
7185
```
7286

87+
## 🔒 Best Practices Implemented
88+
89+
- **Rate Limiting**: To prevent abuse and ensure fair usage, rate limiting is implemented with **exponential backoff**. If the user exceeds the allowed number of requests, they will be temporarily blocked from making more requests.
90+
- **Caching**: Redis is used to cache frequent queries, reducing the load on the AI models and improving the response times.
91+
- **Input Validation**: We validate all incoming requests using **Zod** to ensure the data is structured and safe.
92+
- **Streaming**: For long-running processes, such as AI completions, we stream the responses in real-time.
93+
- **Monitoring**: The API tracks usage metrics and errors via **Prometheus**, allowing you to monitor the health and performance of your system in real-time.
94+
7395
## 🤝 Contributing
7496
Contributions are welcome! If you have suggestions, improvements, or bug fixes, please open an issue or submit a pull request.
7597

@@ -80,13 +102,12 @@ This project is licensed under the **MIT License**. See the [LICENSE](./LICENSE)
80102
- Special thanks to all contributors and the open-source community.
81103
- Gratitude to the maintainers of the libraries used in this project.
82104

105+
---
106+
107+
### **Additional Notes:**
83108

84-
<!--
85-
model: "anthropic/claude-3.5-sonnet",
86-
model: "google/gemini-flash-1.5",
87-
model: "deepseek/deepseek-r1",
88-
model: "openai/gpt-4o-mini",
89-
model: "meta-llama/llama-3.2-3b-instruct",
90-
model: "mistralai/mistral-small",
91-
https://openrouter.ai/models
92-
-->
109+
- The **Rate Limiting** feature uses Redis for storing request counts, ensuring that users cannot flood the system with requests.
110+
- **Caching** stores frequently requested data in Redis, which minimizes the number of redundant calls to the AI models, improving efficiency and speed.
111+
- **Zod** ensures that all user inputs are validated before they are processed, making the application more secure and reliable.
112+
- **Streaming** allows for real-time responses, reducing the wait time for users interacting with models that take longer to process.
113+
- **Prometheus** provides valuable insights into the health of the API, making it easier to monitor usage, errors, and response times.

0 commit comments

Comments
 (0)