New: Audio API, Embeddings & Realtime WebSocket now available!
osmAPI LogoosmAPI

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:

ModeDescription
CreditsosmAPI uses its own provider keys. You pay via osmAPI credits.
API Keys (BYOK)osmAPI routes requests using your provider keys. Zero markup.
HybridUses 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

  1. Go to your Organization Settings in the dashboard.
  2. Navigate to Provider Keys.
  3. Click Add Provider Key.
  4. Select the provider (e.g., OpenAI, Google AI Studio).
  5. Paste your API key.
  6. 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

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

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

Moonshot

Fireworks

Sarvam AI

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.
  • 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 /v2 in 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?