https://github.com/mathis-lambert/api
This repository hosts the core API infrastructure for my web services, built with Python and FastAPI. It serves essential utilities and functionalities across all my web services, accessible under api.mathislambert.fr. The goal is to provide a robust and scalable backend for various web applications.
https://github.com/mathis-lambert/api
fastapi llm openai python qdrant
Last synced: about 2 months ago
JSON representation
This repository hosts the core API infrastructure for my web services, built with Python and FastAPI. It serves essential utilities and functionalities across all my web services, accessible under api.mathislambert.fr. The goal is to provide a robust and scalable backend for various web applications.
- Host: GitHub
- URL: https://github.com/mathis-lambert/api
- Owner: mathis-lambert
- Created: 2025-02-18T20:10:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-19T01:10:05.000Z (over 1 year ago)
- Last Synced: 2025-02-19T02:23:35.685Z (over 1 year ago)
- Topics: fastapi, llm, openai, python, qdrant
- Language: Python
- Homepage: https://api.mathislambert.fr
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API Repository
Welcome to the `api` repository! This repository hosts the core API infrastructure for my web services, built using Python 3.13 and FastAPI. The API is designed to serve essential utilities and functionalities across all my web services, accessible under the domain `api.mathislambert.fr`.
## Projet structure

## 🌟 Features
- **FastAPI**: A modern, fast (high-performance) web framework for building APIs with Python 3.13 based on standard Python type hints.
- **MongoDB**: A NoSQL database used for storing application data, offering flexibility and scalability.
- **Qdrant**: A vector database used for implementing Retrieval-Augmented Generation (RAG) features, enhancing information retrieval capabilities.
- **LLM Integration**: OpenAI-compatible chat completions proxied to OpenRouter.
- **Versioning**: A systematic versioning approach with endpoints like `/v1`, `/v2`, etc., to manage API changes and ensure backward compatibility.
## 🚀 Getting Started
### Prerequisites
- Python 3.13
- MongoDB instance
- Qdrant instance
- OpenRouter API key
### Installation
1. **Clone the Repository**:
```bash
git clone https://github.com/your-username/api.git self_api
cd self_api
```
2. **Set Up a Virtual Environment**:
```bash
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```
3. **Install Dependencies**:
```bash
pip install -r requirements.txt
```
4. **Configure Environment Variables**:
Create a `.env` file in the root directory and add the following variables:
```
MONGODB_URI=your_mongodb_connection_string
QDRANT_URI=your_qdrant_connection_string
OPENROUTER_API_KEY=your_openrouter_api_key
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_SITE_URL=https://your-site.example
OPENROUTER_APP_NAME=your-app-name
```
### Running the API
Start the FastAPI server using:
```bash
uvicorn main:app --host 0.0.0.0 --port 3001 --reload
```
The API will be accessible at `http://127.0.0.1:3001`.
## 🛣️ API Endpoints
### Versioning
- **Base URL**: `https://api.mathislambert.fr`
- **Versioning Structure**: `/v1`, `/v2`, etc.
### Example Endpoints
- **Health Check**:
- `GET /v1/health`: Check the status of the API.
- **LLM Routes**:
- `POST /v1/chat/completions`: OpenAI-compatible chat completions proxied to OpenRouter (metadata-only logging to MongoDB).
- `POST /v1/responses`: OpenAI-compatible responses proxied to OpenRouter (metadata-only logging to MongoDB).
- **Data Routes**:
- `GET /v1/data`: Retrieve data from MongoDB.
- `POST /v1/data`: Insert data into MongoDB.
- **RAG Features**:
- `POST /v1/rag/query`: Query the Qdrant database for enhanced information retrieval using RAG.
## 🤝 Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request. Let's build something amazing together!
## 📜 License
This project is licensed under the MIT License. Feel free to explore, modify, and share!
## 📞 Contact
Have questions or want to chat? Feel free to reach out!
- [LinkedIn](https://www.linkedin.com/in/mathis-lambert) 🔗
---
Happy coding! 💻✨