Use your Betopia API key to call LLM models directly. The API is OpenAI-compatible — swap the base URL and key and existing integrations work immediately.
https://api.betopia.aiSend a list of messages and receive a completion. Supports system, user, and assistant roles. Add "stream": true for SSE — see . Set "model": "auto" to let the router pick the best eligible model — see .
import requests
API_KEY = "sk_your_api_key_here"
BASE_URL = "https://api.betopia.ai"
response = requests.post(
f"{BASE_URL}/v1/chat/completions",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"model": "gpt-5.4-mini",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."},
],
"max_completion_tokens": 512,
"temperature": 0.7,
},
)
data = response.json()
print(data["choices"][0]["message"]["content"])
print(f"Tokens: {data['usage']['prompt_tokens']} in / {data['usage']['completion_tokens']} out"){
"object": "chat.completion",
"model": "gpt-5.4-mini",
"choices": [{
"message": {
"role": "assistant",
"content": "Quantum computing uses quantum bits (qubits) that can exist in multiple states at once..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 187,
"total_tokens": 211
}
}objectstringAlways "chat.completion"modelstringModel that processed the requestchoices[].message.contentstringGenerated text responsechoices[].finish_reasonstring"stop", or "tool_calls" — see Tool Callingusage.prompt_tokensintegerTokens consumed by your promptusage.completion_tokensintegerTokens in the generated responseusage.total_tokensintegerSum of prompt + completion tokens