Why Use a Gateway
Instead of calling OpenAI directly, your application calls SBproxy. SBproxy adds auth, rate limiting, model fallbacks, spend tracking, and guardrails, all in config, no code changes required.
Install SBproxy
brew tap soapbucket/tap && brew install sbproxy
Not on macOS? See the install page for Linux, Docker, and binary downloads.
Create Your Config
Create a file called sb.yml:
proxy:
http_bind_port: 8080
origins:
"ai.example.com":
action:
type: ai_proxy
providers:
- name: openai
api_key: ${OPENAI_API_KEY}
models: [gpt-4o, gpt-4o-mini]
default_model: gpt-4o-mini
routing:
strategy: fallback_chain
Start the Gateway
export OPENAI_API_KEY=sk-...
sbproxy serve -f sb.yml
Send a Request
curl -H "Host: ai.example.com" http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'
Your existing application code does not change. Only the base URL changes from https://api.openai.com to your SBproxy address.
Add a Second Provider
Add Anthropic as a fallback. If OpenAI is down, requests automatically route to Claude:
proxy:
http_bind_port: 8080
origins:
"ai.example.com":
action:
type: ai_proxy
providers:
- name: openai
api_key: ${OPENAI_API_KEY}
models: [gpt-4o, gpt-4o-mini]
- name: anthropic
api_key: ${ANTHROPIC_API_KEY}
models: [claude-sonnet-4-20250514]
default_model: gpt-4o-mini
routing:
strategy: fallback_chain
Add API Key Auth for Users
Give each team or application its own API key:
origins:
"ai.example.com":
action:
type: ai_proxy
providers:
- name: openai
api_key: ${OPENAI_API_KEY}
models: [gpt-4o, gpt-4o-mini]
default_model: gpt-4o-mini
routing:
strategy: fallback_chain
authentication:
type: api_key
api_keys:
- name: frontend-team
key: sk-frontend-abc123
- name: backend-team
key: sk-backend-def456
Add Per-Key Rate Limits
Prevent any single team from exhausting your provider quota:
policies:
- type: rate_limiting
requests_per_minute: 60
key: 'request.headers["x-api-key"]'
Next Steps
- Model Routing - weighted, cost-optimized, and latency-based routing strategies
- Guardrails - content policies, PII redaction, and token budgets
- Providers - full list of 200+ models across 72 native providers