Hosting an OpenAI compatible API.
AI API is an OpenAI compatible API that is hosted on Render. The API is built using FastAPI.
The Python/FastAPI server is mapped under /api/
. The project structure is organized as follows:
├── api
│ ├── init.py
│ ├── db.py
│ ├── models.py
│ ├── inference.py
│ ├── request.py
│ ├── type.py
│ └── routers
│ ├── init.py
│ ├── completion.py
│ └── health.py
├── config
│ ├── site.py
│ └── public
│ ├── logo.png
│ └── models.json
├── tests
│ ├── init.py
│ ├── test_completion.py
│ ├── test_health.py
│ └── conftest.py
├── .env
├── .env.example
├── .gitignore
├── LICENSE
├── README.md
├── requirements.txt
└── run.sh
You can see the API in action by visiting our demo page at Undrstnd AI API Demo. The demo showcases the various endpoints and functionalities provided by the API.
To develop locally, follow these steps:
-
Clone the repository:
git clone https://github.com/undrstnd-labs/ai-api.git cd undrstnd-ai-api
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables: Copy
.env.example
to.env
and update it with your configuration.cp .env.example .env
-
Run the server:
uvicorn api.main:app --reload
-
Access the API: The API will be available at
http://127.0.0.1:8000/v1/
.
To get started with the API, you can use the following endpoints:
- Health Check:
GET /v1/health
- Completion:
POST /v1/chat/completions
(requires a valid API key)
Refer to the OpenAI API documentation for more details on the endpoints and their usage.
For more information about the project, you can visit our website at Undrstnd Labs.
To run the tests, use the following command:
sh test.sh
This will execute the test suite located in the tests directory. Feel free to contribute to the project by opening issues or submitting pull requests.