Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ethical AI Proxy

A lightweight CORS proxy that lets Ethical Tech CoLab GitHub Pages demos make live AI calls — to the Claude API, GPU-hosted models, or both — without exposing API keys in client-side code.

The Problem

GitHub Pages is static hosting. You can't:

  • Hide API keys (everything is visible in the browser)
  • Make server-side API calls
  • Bypass CORS restrictions to reach your own GPU server

The Solution

GitHub Pages (static)  →  This Proxy (your server)  →  Claude API
                                                    →  GPU models (vLLM, Ollama, etc.)
                              ↑
                         - holds API keys
                         - allowlists origins
                         - rate limits
                         - handles CORS

The proxy runs on your GPU server (or any server). Only allowlisted origins (your GitHub Pages sites) can call it.

Setup

1. Install on your server

git clone https://github.com/Ethical-Tech-CoLab/ethical-ai-proxy.git
cd ethical-ai-proxy
npm install

2. Configure

cp .env.example .env

Edit .env:

ANTHROPIC_API_KEY=sk-ant-your-key-here
GPU_SERVER_URL=http://localhost:8000
ALLOWED_ORIGINS=https://ethical-tech-colab.github.io
PORT=3001

3. Run

npm start

For production, use pm2 or systemd:

# pm2
npm install -g pm2
pm2 start server.js --name ethical-ai-proxy
pm2 save

# systemd (create /etc/systemd/system/ethical-ai-proxy.service)

4. Use from any GitHub Pages demo

Add the client helper to your page:

<script src="https://ethical-tech-colab.github.io/ethical-ai-proxy/client.js"></script>
<script>
  const ai = new EthicalAI('https://your-proxy-server.com:3001');

  // Simple ask
  const answer = await ai.ask('Analyze this artwork.');

  // Streaming
  await ai.stream('Describe this image', (text) => {
    document.getElementById('output').textContent += text;
  });

  // GPU model
  const result = await ai.gpu('v1/completions', { prompt: '...' });
</script>

API Endpoints

Endpoint Method Description
/health GET Status check — shows what's configured
/api/claude POST Proxy to Claude API (messages)
/api/claude/stream POST Streaming proxy to Claude API
/api/gpu/* ANY Forward to GPU inference server

Security

  • Origin allowlist — only configured origins can call the proxy
  • API keys stay server-side — never exposed to the browser
  • Rate limiting — configurable per-origin request cap
  • No open relay — GPU proxy only forwards to the configured server

Architecture for the Lab

┌─────────────────────────────────────┐
│  GitHub Pages (static demos)        │
│  ethical-tech-colab.github.io/*     │
│                                     │
│  - digital-passport-artworks        │
│  - other demos...                   │
└──────────────┬──────────────────────┘
               │ HTTPS (CORS allowed)
               ▼
┌─────────────────────────────────────┐
│  Ethical AI Proxy (this server)     │
│  running on your GPU server         │
│                                     │
│  - checks origin allowlist          │
│  - rate limits                      │
│  - holds API keys                   │
└──────┬───────────────┬──────────────┘
       │               │
       ▼               ▼
┌─────────────┐  ┌──────────────────┐
│ Claude API  │  │ GPU Models       │
│ (Anthropic) │  │ (vLLM/TGI/etc.) │
└─────────────┘  └──────────────────┘

About

CORS proxy for Ethical Tech CoLab GitHub Pages — routes AI calls to Claude API and GPU models with origin allowlisting and rate limiting

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages