Skip to content

Authentication

One DirectInference key authenticates every surface. Only the header convention differs, matching what each SDK already sends.

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.

SurfaceCredential header(s)
OpenAI-compatibleAuthorization: Bearer <key>
Anthropic Messagesx-api-key: <key>
anthropic-version: 2023-06-01
Geminix-goog-api-key: <key>
?key=<key>
Authorization: Bearer <key>

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://app.directinference.com/di/v1",
)

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).

Terminal window
curl https://app.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" }]
}'

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.

Terminal window
# x-goog-api-key is what the Google GenAI SDKs send
curl "https://app.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_...