OpenAI SDK drop-in
UberLLM implements the OpenAI Chat Completions API. Any code that uses the
official openai SDK (or a compatible client) works by setting two things:
base_url/baseURL→https://api.uberllm.dev/v1api_key/apiKey→ yourull_key
Everything else — messages, tools, response_format, stream,
max_tokens, temperature — is unchanged.
Python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.uberllm.dev/v1",
api_key=os.environ["UBERLLM_API_KEY"],
)
# Non-streaming
resp = client.chat.completions.create(
model="deepseek/deepseek-v3.1",
messages=[{"role": "user", "content": "Explain rope embeddings briefly."}],
)
print(resp.choices[0].message.content)
print(resp.usage) # prompt_tokens / completion_tokens are returned per request
# Streaming
stream = client.chat.completions.create(
model="deepseek/deepseek-v3.1",
messages=[{"role": "user", "content": "Count to five."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
TypeScript / JavaScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uberllm.dev/v1",
apiKey: process.env.UBERLLM_API_KEY,
});
const resp = await client.chat.completions.create({
model: "deepseek/deepseek-v3.1",
messages: [{ role: "user", content: "Explain rope embeddings briefly." }],
});
console.log(resp.choices[0].message.content);
Tool calling
Tool/function calling passes through unchanged. Use models that advertise tool
support (see Models & routing; the catalog marks
supports_tools).
resp = client.chat.completions.create(
model="deepseek/deepseek-v3.1",
messages=[{"role": "user", "content": "What is the weather in Paris?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}],
)
print(resp.choices[0].message.tool_calls)
Listing models
curl https://api.uberllm.dev/v1/models \
-H "Authorization: Bearer $UBERLLM_API_KEY"
Returns the OpenAI list shape ({"object":"list","data":[{"id": "...", ...}]}).
The public catalog (no auth) is also at GET /api/v1/public/models with
per-endpoint pricing.
Streaming usage
For streaming requests UberLLM automatically requests token usage from the
upstream (stream_options.include_usage) and reconciles your bill from the
provider's reported counts. If an upstream omits usage, UberLLM falls back to a
tokenizer estimate — such rows are flagged in Dashboard → Activity.
Notes
- The trailing
/v1is required in the base URL. - Requests are billed at the exact provider price for the endpoint that served them, with no inference markup. See Pricing.
- For routing control (cheapest vs fastest, pinning a provider, disabling fallbacks) see Models & routing.