Skip to content

FindMalek/ai-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Undrstnd AI API

Hosting an OpenAI compatible API.


Introduction

AI API is an OpenAI compatible API that is hosted on Render. The API is built using FastAPI.

How It Works

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

Demo

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.

Developing Locally

To develop locally, follow these steps:

  1. Clone the repository:

    git clone https://github.com/undrstnd-labs/ai-api.git
    cd undrstnd-ai-api
  2. Set up a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure environment variables: Copy .env.example to .env and update it with your configuration.

    cp .env.example .env
  5. Run the server:

    uvicorn api.main:app --reload
  6. Access the API: The API will be available at http://127.0.0.1:8000/v1/.

Getting Started

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.

Learn More

For more information about the project, you can visit our website at Undrstnd Labs.

Testing

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.