@vibecodeapp/proxy
v2.0.0
Published
Transparent fetch proxy for Vibecode - auto-patches global fetch on import
Readme
@vibecodeapp/proxy
A transparent fetch proxy that auto-patches global fetch on import. Zero configuration required—just import and go.
Installation
bun add @vibecodeapp/proxyQuick Start
import '@vibecodeapp/proxy'
// That's it! All fetch requests to supported AI APIs are now proxied.
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: { 'Authorization': 'Bearer sk-...' },
body: JSON.stringify({ model: 'gpt-4', messages: [...] })
})Configuration
Environment Variables
Set your project ID via environment variable:
VIBECODE_PROJECT_ID=your-project-idProgrammatic Configuration
import { setProxyProjectId, setProxiedDomains } from '@vibecodeapp/proxy'
// Set project ID at runtime
setProxyProjectId('your-project-id')
// Override the list of proxied domains
setProxiedDomains([
'api.openai.com',
'api.anthropic.com',
'custom-api.example.com'
])Proxied Domains
By default, requests to these domains are routed through the proxy:
api.openai.comapi.anthropic.comapi.x.aiamazonaws.com(includes Bedrock)generativelanguage.googleapis.comapi.elevenlabs.io
The proxy also fetches an updated domain list from the server on initialization.
How It Works
- Import-time patching: When you import the package, it immediately patches
globalThis.fetch - URL matching: Each fetch request is checked against the list of proxied domains
- Transparent routing: Matching requests are rewritten to go through
proxy.vibecodeapp.com - Credential injection: Your project ID is added to proxied requests for authentication
Original: https://api.openai.com/v1/chat/completions
Proxied: https://api.openai.com.proxy.vibecodeapp.com/v1/chat/completionsAPI Reference
setProxyProjectId(projectId: string): void
Set the project ID used for authentication with the proxy.
setProxiedDomains(domains: string[]): void
Override the list of domains that should be routed through the proxy.
getOriginalFetch(): typeof fetch
Get the original, unpatched fetch function if you need to bypass the proxy.
import { getOriginalFetch } from '@vibecodeapp/proxy'
const originalFetch = getOriginalFetch()
await originalFetch('https://api.openai.com/...') // Bypasses proxyRuntime Support
- ✅ Node.js
- ✅ Bun
- ✅ Deno
The package also patches undici when available for better Node.js SDK compatibility.
License
MIT
