◆ Documentation
Get started in minutes
OpenAI-compatible REST API. Drop your existing client in by changing the base URL. Works with any tool that speaks OpenAI protocol.
Quickstart
1. Get your API key from the Telegram bot → /buat-key
2. Set the base URL and start making requests:
curl https://api.opengate.host/v1/chat/completions \
-H "Authorization: Bearer ogt-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'Authentication
All requests require a Bearer token in the Authorization header. Your API key starts with ogt-.
⚠️ Keep your key secret. Do not expose it in client-side code or public repos.
Base URL
Set this as the base URL in any OpenAI-compatible client:
Available Models
Pass the model name as a string. Switch models by changing one parameter — no SDK swap needed.
deepseek-v4-flashfast$0.17$0.34deepseek-v4-proflagship$0.66$2.63glm-5.1flagship$0.60$2.40glm-5standard$0.36$1.44minimax-2.7flagship$1.44$5.76minimax-2.5standard$0.72$2.88claude-opus-4.7flagship$18.00$90.00claude-sonnet-4.6flagship$3.60$18.00claude-haiku-4.5fast$0.96$4.80gpt-5.5flagship$9.60$38.40gpt-5.4flagship$5.40$21.60gpt-5.3-codexflagship$6.00$24.00mimo-v2.5fast$0.10$0.20Full list with filters: /models
Basic Request
Send a chat completion request. The response is fully OpenAI-compatible.
curl https://api.opengate.host/v1/chat/completions \
-H "Authorization: Bearer ogt-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'Streaming
Set "stream": true to receive tokens as they are generated. Works with SSE (Server-Sent Events).
curl https://api.opengate.host/v1/chat/completions \
-H "Authorization: Bearer ogt-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Tell me a joke"}],
"stream": true
}'Tool Calling
Supported on models marked with tools capability (Claude, GLM, GPT). Define functions and let the model decide when to call them.
curl https://api.opengate.host/v1/chat/completions \
-H "Authorization: Bearer ogt-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4.7",
"messages": [{"role": "user", "content": "What is the weather in Jakarta?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
},
"required": ["city"]
}
}
}]
}'Model Switching
Switch between models by changing the model string. Same SDK, same code — just a different model name.
from openai import OpenAI
client = OpenAI(
base_url="https://api.opengate.host/v1",
api_key="ogt-xxx"
)
# Switch models with a single string change
models = ["deepseek-v4-flash", "glm-5.1", "minimax-2.7"]
for model in models:
res = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": f"Say hi using {model}"}]
)
print(f"{model}: {res.choices[0].message.content}")Endpoints
Available routes — fully OpenAI-compatible:
Request Parameters
Standard OpenAI parameters you can pass in the request body:
modelstringModel ID (required). See available models above.messagesarrayConversation messages (required).streambooleanEnable streaming responses. Default: false.max_tokensintegerMaximum tokens to generate.temperaturefloatSampling temperature (0-2). Default: 1.top_pfloatNucleus sampling (0-1). Default: 1.toolsarrayFunction tools for tool calling.Response Format
Responses follow the OpenAI chat completion format:
{
"id": "gen-xxx",
"object": "chat.completion",
"model": "deepseek-v4-flash",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 8,
"total_tokens": 28
}
}Error Handling
Errors return standard HTTP status codes with an OpenAI-compatible error body:
{
"error": {
"message": "Rate limit 200/min exceeded",
"type": "rpm_exceeded",
"code": "rpm_exceeded"
}
}Rate Limits
Default: 200 requests per minute per API key. Check the response headers for your current limits:
X-RateLimit-Remaining: 195
X-RateLimit-Reset: 1723000000
Billing
Usage is metered per token. Each model has different input and output pricing. Check your balance anytime via the Telegram bot /cek.
Response headers include billing info:
X-OpenGate-Cost-MicroCents: 5628
1 USD = 1,000,000 micro-cents. Top up via Telegram bot → /topup.
Python
Use the official OpenAI SDK with a custom base URL:
from openai import OpenAI
client = OpenAI(
base_url="https://api.opengate.host/v1",
api_key="ogt-xxx"
)
response = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)With streaming:
from openai import OpenAI
client = OpenAI(
base_url="https://api.opengate.host/v1",
api_key="ogt-xxx"
)
stream = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Tell me a joke"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Node.js
Same drop-in approach with the JavaScript SDK:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.opengate.host/v1",
apiKey: "ogt-xxx"
});
const res = await client.chat.completions.create({
model: "deepseek-v4-flash",
messages: [{ role: "user", content: "Hello" }]
});
console.log(res.choices[0].message.content);With streaming:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.opengate.host/v1",
apiKey: "ogt-xxx"
});
const stream = await client.chat.completions.create({
model: "deepseek-v4-flash",
messages: [{ role: "user", content: "Tell me a joke" }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}cURL
Send requests directly from your terminal:
curl https://api.opengate.host/v1/chat/completions \
-H "Authorization: Bearer ogt-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'List available models:
curl https://api.opengate.host/v1/models \ -H "Authorization: Bearer ogt-xxx"