Simple API emulator for OpenAI API and Ollama API, built with FastAPI and deployable on Google App Engine.
OpenAI-style:
GET /v1/modelsPOST /v1/chat/completionsPOST /v1/completionsPOST /v1/embeddings
Ollama-style:
GET /api/tagsPOST /api/generatePOST /api/chat
Health:
GET /healthz
Image emulation:
POST /image(returns dummyimage/png)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reloadOpenAI chat completion:
curl -s http://127.0.0.1:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
}'Ollama generate:
curl -s http://127.0.0.1:8000/api/generate \
-H "Content-Type: application/json" \
-d '{"model": "llama3", "prompt": "Say hi"}'gcloud app deployAfter deployment, replace your client base URL with your App Engine URL.
Workflow file: .github/workflows/ci-cd.yml
- On
pull_requesttomain: installs dependencies and runspytest. - On
pushtomain(including merged PRs): runs tests, then deploys to App Engine.
Required GitHub repository secrets:
GCP_SA_KEY: Google Cloud service account key JSON (as secret value).GCP_PROJECT_ID: Google Cloud project ID.