OpenAI SDK
UberLLM은 OpenAI Chat Completions API를 구현합니다. 공식 openai SDK (또는 호환 가능한 클라이언트)를 사용하는 모든 코드는 두 가지를 설정하면 작동합니다:
base_url/baseURL→https://api.uberllm.dev/v1api_key/apiKey→ 사용자ull_키
그 외 모든 것 — messages, tools, response_format, stream, max_tokens, temperature — 은 변경되지 않습니다.
파이썬
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-v4-flash",
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-v4-flash",
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-v4-flash",
messages: [{ role: "user", content: "Explain rope embeddings briefly." }],
});
console.log(resp.choices[0].message.content);
툴 호출
툴/함수 호출은 그대로 전달됩니다. 툴 지원을 명시한 모델을 사용하세요 ( 모델 및 라우팅 참조; 카탈로그에 supports_tools로 표시되어 있습니다).
resp = client.chat.completions.create(
model="deepseek/deepseek-v4-flash",
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)
툴을 호출하는 응답은 항상 finish_reason: "tool_calls"로 끝납니다 (/v1/messages의 경우 stop_reason: "tool_use"), 스트리밍 여부와 관계없이, 어떤 공급자가 제공했든 상관없이. 각 툴 호출을 받은 그대로 다시 보내세요: 일부에는 모델이 다음 차례에 필요로 하는 extra_content 필드(Gemini의 사고 서명)가 포함되어 있습니다.
응답 형식
어떤 제공자가 응답을 제공하든 모든 응답은 동일한 필드를 가집니다: OpenAI 채팅 완료 필드(id, object, created, model, choices, usage) 그리고 저희의 usage.cost_usd. 제공자가 자체적으로 추가하는 필드(x_groq, service_tier, system_fingerprint, usage.queue_time 등)는 제거됩니다.
추론 모델은 reasoning과 reasoning_content 모두에 동일한 텍스트로 추론을 보냅니다. message(스트리밍 시 delta)에 보내므로, 둘 중 하나를 읽는 클라이언트는 이를 받게 됩니다. 제공자가 OpenRouter 스타일 reasoning_details를 보내는 경우, 이는 변경되지 않고 전달됩니다. 추론이 없는 응답에는 두 필드 모두 없습니다.
제공자가 거부하지만 응답을 조정하기만 하는 요청 필드(reasoning, thinking, verbosity, top_k 등)는 해당 제공자에 대해 삭제되며, 필요한 경우 reasoning: {"effort": "low"}은 reasoning_effort로 전송됩니다. 텍스트 부분 목록으로 전송된 메시지 내용은 문자열만 받는 제공자에게는 하나의 문자열로 전달됩니다. 텍스트만 읽는 모델로 전송된 그림, 오디오 또는 파일은 이를 명시하는 일반적인 400와 함께 거부됩니다: 먼저 GET /v1/models에서 input_modalities을 확인하세요.
모델 목록
curl https://api.uberllm.dev/v1/models \
-H "Authorization: Bearer $UBERLLM_API_KEY"
OpenAI 목록 형식({"object":"list","data":[{"id": "...", ...}]})으로, 지금 호출할 수 있는 채팅 모델을 포함하여 반환합니다. ?type=all는 이미지, 비디오, 음악 및 음성 모델을 추가합니다. 각 채팅 모델에는 context_length, max_output_tokens, input_modalities, supports_tools, supports_reasoning, supports_vision 및 supported_parameters가 포함됩니다 (모델 및 라우팅] 참조). 공개 카탈로그(인증 불필요)는 GET /api/v1/public/models에서도 확인할 수 있으며, 엔드포인트별 가격이 명시되어 있습니다.
스트리밍 사용량
스트리밍 요청의 경우 UberLLM은 자동으로 token usage(stream_options.include_usage)를 요청하므로, 마지막 chunk에는 cost_usd를 포함하는 usage object가 담겨 있으며, 이는 해당 호출에 대해 미국 달러로 청구되는 금액입니다. 스트리밍되지 않은 응답도 usage.cost_usd를 포함하며, X-UberLLM-Cost-USD header도 포함합니다 (이미 keepalive spaces로 시작된 느린 응답의 경우는 제외: 이 경우 body field만 포함됩니다). 귀하의 청구 금액은 marketplace가 해당 호출에 대해 보고하는 비용입니다. 응답은 해당 보고서를 기다리지 않습니다. 아직 보고서가 도착하지 않은 경우, cost_usd는 저희의 예상치이며, 귀하의 잔액과 대시보드 → 활동에서 잠시 후 정확한 청구 금액을 확인할 수 있습니다. usage가 누락된 경우, UberLLM은 tokenizer 예상치로 대체하며, 이러한 행은 대시보드 → 활동에 표시됩니다.
Responses API
client.responses.create 와 client.responses.stream는 모든 챗 모델에서도 작동합니다: text, tool calls (function_call → function_call_output), structured output 및 streaming. UberLLM은 아무것도 저장하지 않으므로, 각 호출 시 previous_response_id 대신 전체 대화를 input로 보내주세요. 자세한 내용은: Responses API.
r = client.responses.create(
model="deepseek/deepseek-v4.1-flash",
instructions="Answer in one short sentence.",
input="What is the capital of France?",
)
print(r.output_text)