Authentication
One DirectInference key authenticates every surface. Only the header convention differs, matching what each SDK already sends.
API keys
Section titled “API keys”Authenticate with a key you issue on the API Keys page. The same llm_live_… key works across the OpenAI, Anthropic, and Gemini surfaces — there are no per-surface credentials.
| Surface | Credential header(s) |
|---|---|
| OpenAI-compatible | Authorization: Bearer <key> |
| Anthropic Messages | x-api-key: <key>anthropic-version: 2023-06-01 |
| Gemini | x-goog-api-key: <key>?key=<key>Authorization: Bearer <key> |
Base URLs
Section titled “Base URLs”Every surface lives under the /di prefix — the DirectInference endpoint, where each request is classified, your effort hint is honored, and quality repair runs. Set your client’s base URL and change nothing else:
| Surface | Base URL |
|---|---|
| OpenAI-compatible | https://api.directinference.com/di/v1 |
| Anthropic Messages | https://api.directinference.com/dithe SDK appends /v1/messages |
| Gemini | https://api.directinference.com/dithe SDK appends /v1beta/…; Vercel @ai-sdk/google wants …/di/v1beta |
OpenAI-compatible
Section titled “OpenAI-compatible”Pass the key as api_key; the SDK sends it as a bearer token.
from openai import OpenAI
client = OpenAI( api_key="llm_live_...", # sent as: Authorization: Bearer ... base_url="https://api.directinference.com/di/v1",)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "llm_live_...", // sent as: Authorization: Bearer ... baseURL: "https://api.directinference.com/di/v1",});curl https://api.directinference.com/di/v1/chat/completions \ -H "Authorization: Bearer llm_live_..." \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5-mini", "messages": [{ "role": "user", "content": "ping" }] }'echo '{ "model": "gpt-5.5-mini", "messages": [{ "role": "user", "content": "ping" }] }' \ | https POST api.directinference.com/di/v1/chat/completions \ Authorization:'Bearer llm_live_...' \ Content-Type:application/jsonclient := openai.NewClient( option.WithAPIKey("llm_live_..."), // sent as: Authorization: Bearer ... option.WithBaseURL("https://api.directinference.com/di/v1"),)Anthropic Messages
Section titled “Anthropic Messages”The Anthropic SDK sends x-api-key plus an anthropic-version header. Set the SDK base URL to …/di (it appends /v1/messages for you).
curl https://api.directinference.com/di/v1/messages \ -H "x-api-key: llm_live_..." \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "max_tokens": 64, "messages": [{ "role": "user", "content": "ping" }] }'echo '{ "model": "claude-sonnet-4-6", "max_tokens": 64, "messages": [{ "role": "user", "content": "ping" }] }' \ | https POST api.directinference.com/di/v1/messages \ x-api-key:llm_live_... \ anthropic-version:2023-06-01 \ Content-Type:application/jsonGemini
Section titled “Gemini”Three credential forms are accepted, resolved in this order: x-goog-api-key, then the ?key= query parameter, then Authorization: Bearer. The Google GenAI SDKs use the first.
# x-goog-api-key is what the Google GenAI SDKs sendcurl "https://api.directinference.com/di/v1beta/models/gemini-2.5-flash:generateContent" \ -H "x-goog-api-key: llm_live_..." \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [{ "text": "ping" }] }] }'
# also accepted: ?key=llm_live_... and Authorization: Bearer llm_live_...# x-goog-api-key is what the Google GenAI SDKs sendecho '{ "contents": [{ "parts": [{ "text": "ping" }] }] }' \ | https POST 'api.directinference.com/di/v1beta/models/gemini-2.5-flash:generateContent' \ x-goog-api-key:llm_live_... \ Content-Type:application/json
# also accepted: ?key=llm_live_... and Authorization:'Bearer llm_live_...'