What is GreenOps AI Studio?
GreenOps AI Studio is a multi-tier SaaS platform designed to proxy and optimize LLM workloads through an OpenAI-compatible AI API Gateway. It applies semantic caching on Cloudflare Workers, FinOps telemetry for token spend and carbon footprint, and a PII anonymization API before requests reach Gemini, OpenAI, or a local GPU runtime. Teams use it as a drop-in proxy alternative to calling provider APIs directly when they need cost control, privacy, and greener inference at the edge.
Introduction & architecture
GreenOps AI is an OpenAI-compatible LLM gateway on Cloudflare Workers. Every chat request is authenticated, PII-masked, optionally served from a semantic KV cache, then routed to Gemini, OpenAI, or a local GPU runtime.
Edge Worker
TypeScript proxy at the Cloudflare PoP. OpenAI-compatible POST /v1/chat/completions.
Semantic cache
WASM prompt hash + KV GREENOPS_CACHE. HIT replies skip the GPU and cost $0 / 0 g CO₂.
PII masking
Emails, cards, phones and tax IDs are anonymized before upstream. Count is returned on X-PII-Redacted-Count.
FinOps / ESG
Response headers expose USD saved, CO₂ avoided, cache HIT/MISS and user tier.
- Cold path (MISS): trim + hash in WASM, call the LLM, write KV, emit FinOps headers.
- Hot path (HIT): KV read only — typically tens of milliseconds on the same PoP.
- Failover: Gemini 429/5xx automatically retries then falls back to OpenAI when configured.
Authentication & setup
Protected routes accept the gateway key as Authorization: Bearer <key> or the native header X-Proxy-Auth. For local and sandbox testing use the bootstrap key GreenOpsKey123.
Quick test key
Send Authorization: Bearer GreenOpsKey123 on chat, analytics and audit calls. Paid plans receive a gop_pro_… key after Stripe checkout. Provider keys (Gemini/OpenAI) are optional when the Worker already has server-side credentials.
| Header | Required | Meaning |
|---|---|---|
Authorization | Yes* | Bearer token. Example: Bearer GreenOpsKey123. |
X-Proxy-Auth | Yes* | Equivalent gateway key if you do not send Authorization. |
X-User-Role | No | User (default), FinOps, Compliance, Admin. |
X-User-Gemini-Key | No | Bring-your-own Gemini key. |
X-User-OpenAI-Key | No | Bring-your-own OpenAI key. |
X-Local-LLM-Url | No | OpenAI-compatible local runtime (Ollama / GPU). |
X-Webhook-Url | No | Slack / Teams incoming webhook for spend and security alerts. |
Endpoints & API reference
Proxy URL: https://greenops-ai-proxy.copycomp-ai.workers.dev
https://greenops-ai-proxy.copycomp-ai.workers.dev
https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/chat/completions
| Method | Path | Auth | Purpose |
|---|---|---|---|
| POST | /v1/chat/completions | Yes | OpenAI-compatible chat (JSON or SSE if stream: true) |
| GET | /health | No | Liveness + WASM engine |
| GET | /v1/health | No | KV / Gemini / OpenAI readiness |
| GET | /v1/analytics | Yes | FinOps / ESG totals |
| GET | /v1/audit/logs | Yes | EU AI Act audit trail (Compliance / Admin) |
| POST | /v1/webhooks/stripe | Stripe-Signature | Checkout → Pro key, cancel → Free |
| GET | /v1/openapi.json | No | OpenAPI 3.0 spec |
Chat Completions
POST JSON with model + messages. Testing uses Bearer GreenOpsKey123. Swap in your provisioned key for production.
curl https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer GreenOpsKey123" \
-d '{
"model": "gemini-3.5-flash",
"messages": [{"role": "user", "content": "Hello GreenOps"}]
}'
const res = await fetch('https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer GreenOpsKey123',
},
body: JSON.stringify({
model: 'gemini-3.5-flash',
messages: [{ role: 'user', content: 'Hello GreenOps' }],
}),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data.choices?.[0]?.message?.content);
import requests
url = "https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer GreenOpsKey123",
}
payload = {
"model": "gemini-3.5-flash",
"messages": [{"role": "user", "content": "Hello GreenOps"}],
}
r = requests.post(url, json=payload, headers=headers, timeout=60)
if r.status_code == 401:
raise SystemExit("Unauthorized: check Bearer GreenOpsKey123")
if r.status_code == 429:
raise SystemExit(r.json())
r.raise_for_status()
print(r.json()["choices"][0]["message"]["content"])
Stripe webhooks
Point the Stripe Dashboard endpoint at the URL below. The Worker verifies Stripe-Signature when STRIPE_WEBHOOK_SECRET is set.
https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/webhooks/stripe
checkout.session.completedissues an active Pro license (gop_pro_…, 100,000 req/month).customer.subscription.deleteddeactivates the license and returns the account to Free.- Configure the endpoint in Stripe as POST /v1/webhooks/stripe. No browser CORS is required.
curl -X POST https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/webhooks/stripe \
-H "Content-Type: application/json" \
-H "Stripe-Signature: t=1700000000,v1=…" \
-d '{"type":"checkout.session.completed","data":{"object":{"customer_email":"dev@acme.com"}}}'
await fetch('https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/webhooks/stripe', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Stripe-Signature': 't=1700000000,v1=…',
},
body: JSON.stringify({
type: 'checkout.session.completed',
data: { object: { customer_email: 'dev@acme.com' } },
}),
});
import requests
requests.post(
"https://greenops-ai-proxy.copycomp-ai.workers.dev/v1/webhooks/stripe",
headers={
"Content-Type": "application/json",
"Stripe-Signature": "t=1700000000,v1=…",
},
json={
"type": "checkout.session.completed",
"data": {"object": {"customer_email": "dev@acme.com"}},
},
timeout=30,
)
Pricing tiers & quotas
Limits are enforced at the edge. Free is daily + burst; Pro and Business are monthly; Enterprise is unlimited.
| Plan | Price | Request limits | Features |
|---|---|---|---|
| Free | $0/mo | 1,000 req/day · 30 req/min | Standard semantic caching, baseline PII masking, Community & Docs |
| Pro | $29/mo | 100,000 req/month | Priority processing, real-time ESG/FinOps telemetry, automated PII anonymization |
| Business | $149/mo | 1,000,000 req/month | ESG/FinOps PDF & CSV export, advanced PII rules, priority support |
| Enterprise | $499+/mo | Unlimited | Dedicated Workers & storage, custom ESG audit, 99.9% uptime SLA |
Error handling & status codes
The gateway returns JSON errors. Chat quota responses include error.code, error.message and error.upgrade_url.
| Status | Name | Typical cause | What to do |
|---|---|---|---|
| 401 | Unauthorized | Missing/invalid Bearer or X-Proxy-Auth. | Send Authorization: Bearer GreenOpsKey123 (test) or your provisioned key. Check for extra spaces. |
| 429 | Rate Limit Exceeded | Free 1,000/day or 30/min; Pro 100k/mo; Business 1M/mo. | Wait for Retry-After, or upgrade. Burst resets every 60 seconds. |
| 500 | Gateway Error | Unhandled Worker exception or upstream failure after retries. | Retry with backoff. Check GET /v1/health. Confirm Gemini/OpenAI keys if the model is cloud-hosted. |
- 403: RBAC blocked the route (for example Audit requires Compliance/Admin) or prompt injection was rejected.
- 400: malformed JSON, missing messages[], or a required provider key is absent for that model.
- SSE: send
stream: true. Cache is bypassed on streaming responses.