MUHGPT API
A drop-in OpenAI-compatible REST API. Point any OpenAI SDK at our base URL, use your mghp_ key, and you are done — chat, streaming, function calling and vision all work out of the box.
Base URL
Streaming
Server-sent events, token by token.
Function calling
Full tools / tool_choice support.
Vision
Multimodal messages with images.
Usage API
Track spend per day and model.
Authentication
All requests are authenticated with a Bearer token. Create one in the app under Settings → API Keys. Keys start with mghp_ and are shown only once.
Authorization: Bearer mghp_your_key_here
Keep your key secret. Anyone with it can spend your credits. Revoke a leaked key in Settings → API Keys and create a new one.
Quickstart
Because the API is OpenAI-compatible, the official SDKs work by overriding base_url.
curl https://api.muhgpt.com/v1/chat/completions \
-H "Authorization: Bearer $MUHGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "muh-chat",
"messages": [{"role": "user", "content": "Hello!"}]
}'
from openai import OpenAI
client = OpenAI(
base_url="https://api.muhgpt.com/v1",
api_key="mghp_your_key_here",
)
resp = client.chat.completions.create(
model="muh-chat",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.muhgpt.com/v1",
apiKey: "mghp_your_key_here",
});
const resp = await client.chat.completions.create({
model: "muh-chat",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
Chat completions
The main endpoint. Accepts the standard OpenAI body. Supported parameters:
| Field | Type | Notes |
|---|---|---|
model | string | See models. Defaults to muh-chat. |
messages | array | Required. Roles: system, user, assistant, tool. |
stream | bool | Server-sent events when true. |
max_tokens | int | Capped by your balance and key limit. |
temperature | number | 0–2. |
top_p | number | 0–1. |
stop | string/array | Stop sequences. |
frequency_penalty | number | -2–2. |
presence_penalty | number | -2–2. |
response_format | object | e.g. {"type":"json_object"}. |
seed | int | Best-effort determinism. |
tools, tool_choice | array/— | See function calling. |
Streaming
Set "stream": true to receive chat.completion.chunk events terminated by data: [DONE]. The final chunk carries usage.
stream = client.chat.completions.create(
model="muh-chat",
messages=[{"role": "user", "content": "Write a haiku"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Function calling
Pass JSON-schema tools. The model replies with tool_calls and finish_reason: "tool_calls". Works in streaming too.
{
"model": "muh-chat",
"messages": [{"role": "user", "content": "Weather in Lisbon?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto"
}
Vision
Send an array content mixing text and images. Use a vision-capable model.
{
"model": "muh-chat",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}}
]
}]
}
List models
Returns the available model aliases.
| Alias | Notes |
|---|---|
muh-chat | Default. Recommended. |
gpt-3.5-turbo | Compatibility alias. |
gpt-4o-mini | Compatibility alias. |
gpt-4o | Compatibility alias. |
Usage
Returns your credit balance plus consumption totals, a daily breakdown and a per-model breakdown. Defaults to the last 30 days.
{
"object": "usage",
"balance": 13997015,
"totals": {"credits": 2985, "tokens": 2985, "requests": 10},
"daily": [{"day": "2026-06-10", "credits": 2933, "requests": 8}],
"by_model": [{"model": "muh-chat", "credits": 2933}]
}
Credits & pricing
Each request costs credits drawn from your balance. The cost weights output tokens more than input, like most providers:
Top up your balance in the app under Settings → API Keys → Buy credits (card or crypto). Check your remaining balance any time with GET /v1/usage.
Rate & key limits
| Limit | Value |
|---|---|
| Rate limit | 60 requests / minute per account |
| Active keys | Up to 10 per account |
| Monthly key cap | Optional credit ceiling per key |
| Model allow-list | Optional per key — restrict which models a key may call |
Set a monthly limit and an allowed-model list per key when you create it, to safely hand a key to a third party.
Errors
Errors use the OpenAI shape: { "error": { "message", "type" } }.
| Status | Type | Meaning |
|---|---|---|
| 401 | invalid_request_error | Missing or invalid API key. |
| 402 | insufficient_quota | No credits, or key monthly limit reached. |
| 403 | model_not_allowed | Model not in this key's allow-list. |
| 413 | invalid_request_error | Request body too large. |
| 429 | rate_limit | More than 60 requests/minute. |
| 502 | upstream_error | Model provider unavailable — retry. |