Provider Keys (BYOK)
Bring your own API keys from OpenAI, Google, Anthropic, and other providers to use with osmAPI.
Provider Keys (BYOK)
osmAPI lets you bring your own API keys from supported providers. Use your existing OpenAI, Google AI Studio, Anthropic, or other provider keys directly through osmAPI — get unified routing, analytics, and failover while keeping full control of your provider accounts.
How It Works
osmAPI supports three project modes that control how requests are authenticated with upstream providers:
| Mode | Description |
|---|---|
| Credits | osmAPI uses its own provider keys. You pay via osmAPI credits. |
| API Keys (BYOK) | osmAPI routes requests using your provider keys. Zero markup. |
| Hybrid | Uses your provider key if available, falls back to credits otherwise. |
You can change your project mode anytime from Project Settings in the dashboard.
Adding a Provider Key
- Go to your Organization Settings in the dashboard.
- Navigate to Provider Keys.
- Click Add Provider Key.
- Select the provider (e.g., OpenAI, Google AI Studio).
- Paste your API key.
- osmAPI validates the key with a test request before saving.
Provider keys are encrypted and never shown again after creation. You can only see a masked version in the dashboard.
Supported Providers
OpenAI
- Get your key: platform.openai.com/api-keys
- Supports: Chat, embeddings, audio (TTS & STT), image generation
- No additional configuration needed — just paste your API key.
Google AI Studio
- Get your key: aistudio.google.com/apikey
- Supports: Chat (Gemini models), embeddings
Do not include /v1beta or /v1 in the base URL. osmAPI automatically appends the correct API version path. If you provide a custom base URL, use only the root domain:
- Correct:
https://generativelanguage.googleapis.com - Incorrect:
https://generativelanguage.googleapis.com/v1beta
Anthropic
- Get your key: console.anthropic.com/settings/keys
- Supports: Chat (Claude models)
- No additional configuration needed.
Groq
- Get your key: console.groq.com/keys
- Supports: Chat, audio (STT via Whisper)
- No additional configuration needed.
Cerebras
- Get your key: cloud.cerebras.ai
- Supports: Chat (Llama models with ultra-fast inference)
DeepSeek
- Get your key: platform.deepseek.com/api_keys
- Supports: Chat (DeepSeek models with reasoning)
Moonshot
- Get your key: platform.moonshot.cn
- Supports: Chat (Kimi models)
Fireworks
- Get your key: fireworks.ai/account/api-keys
- Supports: Chat (open-source models with fast inference)
Sarvam AI
- Get your key: dashboard.sarvam.ai
- Supports: Chat (Indic language models)
Custom Providers
You can add any OpenAI-compatible provider. See Custom Providers for details.
Using Your Provider Keys
Once configured, requests work exactly the same — osmAPI automatically uses your provider key when your project is in API Keys or Hybrid mode:
curl -X POST "https://api.osmapi.com/v1/chat/completions" \
-H "Authorization: Bearer $OSM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'from openai import OpenAI
client = OpenAI(
api_key="your-osm-api-key",
base_url="https://api.osmapi.com/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "your-osm-api-key",
baseURL: "https://api.osmapi.com/v1",
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});Your osmAPI key authenticates with osmAPI. Behind the scenes, osmAPI uses your provider key to call the upstream provider.
Embeddings with Provider Keys
Provider keys work with the embeddings endpoint too. If you have a Google AI Studio key, you can use Gemini embedding models at zero markup:
curl -X POST "https://api.osmapi.com/v1/embeddings" \
-H "Authorization: Bearer $OSM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-001",
"input": "Hello world"
}'Project Modes in Detail
Credits Mode
- osmAPI handles all provider authentication.
- You pay via osmAPI credits with transparent per-request pricing.
- Best for getting started quickly.
API Keys Mode (BYOK)
- All requests use your provider keys.
- You must have a key for the provider you're requesting.
- If no key is configured for a provider, the request fails with an error.
- Zero markup — you pay your provider directly.
Hybrid Mode (Recommended)
- If you have a provider key for the requested provider, it uses your key (zero markup).
- If not, falls back to osmAPI credits.
- Best of both worlds — add keys for your most-used providers and let credits handle the rest.
Hybrid mode is the default for new projects. You get the cost savings of BYOK for providers where you have keys, with the convenience of credits as a fallback.
Managing Keys
Deactivating a Key
You can temporarily deactivate a provider key without deleting it. When deactivated:
- Hybrid mode: Falls back to credits.
- API Keys mode: Requests to that provider will fail until the key is reactivated.
Deleting a Key
Deleting a provider key removes it permanently. If your project is in API Keys mode, ensure you have an alternative before deleting.
One Key Per Provider
Each organization can have one active key per provider. To update a key, delete the existing one and add a new one.
Troubleshooting
404 Error When Adding a Key
If you get a 404 during key validation, check your base URL:
- Do not include API version paths like
/v1,/v1beta, or/v2in the base URL. - osmAPI appends the correct path automatically for each provider.
Key Validation Failed
osmAPI validates your key by making a small test request. If validation fails:
- Verify the key is correct and active on the provider's dashboard.
- Check that the key has permissions for chat completions (the test uses a basic chat request).
- Ensure the key hasn't exceeded the provider's rate limits.
Provider Not Available
If a provider isn't listed in the dropdown, it may be available through credits or hybrid mode only. Check the Model Catalog for the full list of supported models and providers.
How is this guide?