Install
openclaw skills install @avikalpg/byok-relayOpenAI-compatible LLM gateway for any client-side application (browser, mobile, React Native, Flutter, VS Code extensions, browser extensions, Electron, smart TV, and more). Routes requests to OpenAI, Anthropic, Gemini, Groq, Mistral, and 200+ models, handling CORS, key encryption, and streaming without a dedicated backend. Uniquely supports BYOK (bring your own key): users connect their own provider API keys so the developer pays nothing for inference. Use for multi-provider LLM access, client-safe AI API calls, or any product where users supply their own API credentials.
openclaw skills install @avikalpg/byok-relayThis skill helps you integrate byok-relay - an OpenAI-compatible LLM gateway for any client-side application (browser, mobile, extensions, Electron, smart TV, and more) that handles CORS, encrypts API keys, and supports multiple providers through a single relay endpoint.
Use this skill whenever:
Browser apps can't call AI APIs directly:
api.openai.com, api.anthropic.com, etc. block cross-origin requests from browsers, mobile webviews, and extensions via CORSbyok-relay is a single relay that handles all of this: OpenAI-compatible endpoint, CORS-safe, multi-provider, with optional BYOK so users (or their organization) supply their own credentials and the developer pays nothing for inference.
Individuals / prosumers: Each user registers their own personal API key. Common for developer tools, research UIs, AI power-user products.
Teams / B2B (company-managed key): A company admin registers one shared company API key via POST /keys/:provider (e.g. /keys/openai). In the current implementation, keys are stored per relay-token (user); to share a key across team members, the admin can share their relay token or register the same company key under each member's account. Org-level key sharing (one stored key → multiple relay tokens) is on the roadmap. The developer doesn't touch the key — it belongs to the customer's organization.
If you are building a frontend-only, browser-only, or client-side-only application (Lovable, Bolt, Replit, plain HTML, Vite, React without a backend, mobile app, extension), use the hosted relay directly. No cloning, no server setup needed.
const RELAY_URL = 'https://relay.byokrelay.com';
That's the only configuration needed. Skip to the Integration section below.
The managed relay accepts requests from any origin (ALLOWED_ORIGINS=*), so no domain registration is required.
Use this if you want to run your own relay on your infrastructure (VPS, Railway, Fly.io, etc.).
git clone https://github.com/avikalpg/byok-relay.git
cd byok-relay && npm install
echo "ENCRYPTION_SECRET=$(openssl rand -hex 32)" > .env
echo "ALLOWED_ORIGINS=https://your-app.com" >> .env
npm start
For production: see the systemd + nginx setup in the README.
Use RELAY_URL = 'https://relay.byokrelay.com' for the managed relay, or your own host for self-hosted.
async function getRelayToken(relayUrl, appId) {
const res = await fetch(`${relayUrl}/users`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ app_id: appId })
});
const { token } = await res.json();
localStorage.setItem('relay_token', token);
return token;
}
async function storeApiKey(relayUrl, token, provider, apiKey) {
// provider: 'openai' | 'anthropic' | 'google' | 'groq' | 'mistral' | 'openrouter'
await fetch(`${relayUrl}/keys/${provider}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-relay-token': token
},
body: JSON.stringify({ key: apiKey })
});
}
// OpenAI via relay
async function chat(relayUrl, token, messages) {
const res = await fetch(`${relayUrl}/relay/openai/v1/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-relay-token': token
},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages,
stream: true
})
});
return res; // SSE stream, handle with EventSource or manual ReadableStream
}
// Anthropic via relay
async function claudeChat(relayUrl, token, messages) {
const res = await fetch(`${relayUrl}/relay/anthropic/v1/messages`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01',
'x-relay-token': token
},
body: JSON.stringify({
model: 'claude-3-5-haiku-20241022',
max_tokens: 1024,
messages,
stream: true
})
});
return res;
}
| Provider | Relay path | Notes |
|---|---|---|
| OpenAI | /relay/openai/... | Full OpenAI API compatibility |
| Anthropic | /relay/anthropic/... | Claude models, SSE streaming |
/relay/google/... | Gemini API | |
| Groq | /relay/groq/... | Fast inference |
| Mistral | /relay/mistral/... | Mistral models |
| OpenRouter | /relay/openrouter/... | 200+ models |
| Any OpenAI-compatible | /relay/openai-compatible/... | Pass x-relay-base-url header |