Bring your own key (BYOK) lets you use an OpenAI, Anthropic or Cerebras provider key for selected requests. Available providers are shown under BYOK. Your SingleAPI key still authenticates your application; your provider key pays the provider. SingleAPI makes no wallet reservation, deduction, charge or ledger entry for a BYOK request.
Store and select a provider key
Open BYOK in the dashboard to store a provider key. Choose the same provider as the model you will call. For an API request, explicitly select the stored credential by its UUID. You can copy the ID from the dashboard or obtain it through the BYOK API. Multiple credentials per provider are supported.
With client and model_id configured as in the quickstart, set SINGLEAPI_PROVIDER_CREDENTIAL_ID to that UUID and send:
import os
response = client.chat.completions.create(
model=model_id,
messages=[{"role": "user", "content": "Say hello in one sentence."}],
extra_headers={"X-SingleAPI-Provider-Credential-ID": os.environ["SINGLEAPI_PROVIDER_CREDENTIAL_ID"]},
)
print(response.choices[0].message.content)For HTTP, use the environment variables from the quickstart and the credential UUID copied from BYOK:
export SINGLEAPI_PROVIDER_CREDENTIAL_ID="YOUR_PROVIDER_CREDENTIAL_UUID"
curl "$SINGLEAPI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $SINGLEAPI_API_KEY" \
-H "X-SingleAPI-Provider-Credential-ID: $SINGLEAPI_PROVIDER_CREDENTIAL_ID" \
-H "Content-Type: application/json" \
-d "{\"model\":\"$SINGLEAPI_MODEL_ID\",\"messages\":[{\"role\":\"user\",\"content\":\"Say hello.\"}],\"max_tokens\":100}"The credential must belong to your account, be active and match the model provider. The usage API records the request outcome and token usage when available, with zero SingleAPI charge. If the provider key fails, SingleAPI does not automatically switch to managed billing.
You can rotate or revoke a stored provider key under BYOK. Rotation keeps its UUID; revocation prevents future requests from selecting it. The stored secret is never returned by the API.