Skip to content

igardev/llmsimpleapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM Simple API Application

A FastAPI service to interact with Large Language Models (LLMs). It exposes endpoints to configure the target LLM (endpoint, model, API key) and to send prompts.

image

Setup

  1. Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt

Run

uvicorn main:app --reload

The server runs at http://localhost:8000.

Endpoints

  • GET / — Welcome message
  • GET /health — Health check
  • POST /configure — Update endpoint, model, and api_key (all optional)
  • POST /configure/endpoint — Update only endpoint
  • POST /configure/model — Update only model
  • POST /configure/key — Update only api_key
  • GET /configure/get — Fetch current endpoint, model, and api_key
  • POST /ask — Send a prompt to the configured LLM and get the response

Request Examples

Update endpoint/model/api_key:

curl -X POST http://localhost:8000/configure \
  -H "Content-Type: application/json" \
  -d '{"endpoint": "http://127.0.0.1:8011/v1/chat/completions", "model": "gpt-4.1", "api_key": "your-key"}'

Ask the LLM:

curl -X POST http://localhost:8000/ask \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello, how are you?"}'

Notes

  • The configuration is stored in memory; restart resets values to defaults defined in main.py.
  • Ensure your editor uses the project virtualenv to resolve imports and suppress linter warnings.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages