mirror of
https://github.com/ghndrx/starlane-router.git
synced 2026-02-09 22:34:58 +00:00
main
a2a-router (FastAPI + DigitalOcean Gradient)
Super-basic app that routes messages either to a local echo or to a DigitalOcean Gradient inference endpoint.
Features
- FastAPI with
/routeand/healthz - Simple router: keyword/length heuristic or explicit
route_hint - Config via env/ConfigMap/Secret
- Docker + Kubernetes manifests (Deployment, Service, Ingress)
- Script to create a tiny DO Kubernetes cluster via
doctl
Configure
Environment variables used by the app:
GRADIENT_ENDPOINT_URL: Full URL to your Gradient inference endpointGRADIENT_API_KEY: API key/token for GradientGRADIENT_AUTH_SCHEME:authorization_bearer(default) orx_api_keyROUTE_KEYWORDS: comma-separated keywords to force Gradient routing
Local Run
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8080
Test:
curl -s http://localhost:8080/healthz
curl -s -X POST http://localhost:8080/route -H 'Content-Type: application/json' \
-d '{"message":"call the gradient model"}' | jq
Build & Push Image
Replace YOUR_REGISTRY/YOUR_IMAGE:tag appropriately.
docker build -t YOUR_REGISTRY/YOUR_IMAGE:latest .
docker push YOUR_REGISTRY/YOUR_IMAGE:latest
Create a Small DO K8s Cluster
Requires doctl and kubectl.
chmod +x scripts/doctl_create_cluster.sh
./scripts/doctl_create_cluster.sh a2a-cluster nyc1 s-1vcpu-2gb 1.29.1-do.0 1
Install nginx ingress controller if needed:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.1/deploy/static/provider/cloud/deploy.yaml
Deploy to Kubernetes
- Create/update secrets and config:
kubectl apply -f k8s/config-secrets.yaml
- Set the image and domain in manifests, then apply:
# edit k8s/deployment.yaml -> set image
# edit k8s/ingress.yaml -> set host domain
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/ingress.yaml
- Get the ingress address and point your DNS (A/AAAA record) to it manually.
kubectl get ingress a2a-router -o wide
API
POST /route- body:
{ message: string, route_hint?: 'local'|'gradient', metadata?: object } - response:
{ route: 'local'|'gradient', output: object }
- body:
GET /healthz
Notes
- To force Gradient usage, pass
route_hint: "gradient"or include a keyword inROUTE_KEYWORDS. - If Gradient call fails, endpoint returns 502 with message.
Description
Languages
Python
73.7%
Shell
18.5%
Dockerfile
7.8%