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 are mghp_ followed by 48 hex characters. The full key is shown only once — afterwards the dashboard displays just the mghp_… prefix to identify it.
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. |
Example response
A non-streamed call returns a standard chat.completion object. The model field echoes the resolved model id, and usage reflects what you were billed (see credits).
{
"id": "chatcmpl-9f3a1c7b8e2d4a6f0b1c2d3e",
"object": "chat.completion",
"created": 1782819600,
"model": "google/gemini-2.5-flash-lite",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help you today?"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 9, "completion_tokens": 9, "total_tokens": 18}
}
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 every id you can pass in the model field. Use a MUHGPT model id for a specific model, or an OpenAI-style alias for drop-in compatibility — both are accepted.
MUHGPT models
| Model | model id | Best for |
|---|---|---|
| MUH Lite | google/gemini-2.5-flash-lite | Default. Fast, economical, everyday chat & vision. |
| MUH Mini | google/gemini-3.1-flash-lite | Newer lightweight model; strong multimodal / vision. |
| MUH Coder | qwen/qwen3-coder:free | Code generation and tool use. |
| MUH Pro | google/gemini-3.5-flash | Highest-quality reasoning and longer answers. |
OpenAI-compatible aliases
These aliases are accepted and routed to MUH Lite (the default), so existing OpenAI code runs unchanged. Pass a MUHGPT model id above when you need a specific model.
| Alias | Routes to |
|---|---|
muh-chat | MUH Lite (default) |
gpt-4o | MUH Lite |
gpt-4o-mini | MUH Lite |
gpt-3.5-turbo | MUH Lite |
An unrecognized model returns 404 model_not_found. Call GET /v1/models to fetch the live list programmatically — it returns these ids in OpenAI's { "object": "list", "data": [...] } shape.
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:
Worked example
A request with 1,000 prompt tokens and 500 completion tokens:
The same weights apply to streaming. A few reference points:
| Prompt tokens | Completion tokens | Credits charged |
|---|---|---|
| 100 | 100 | 520 |
| 500 | 0 | 650 |
| 1,000 | 500 | 3,250 |
| 2,000 | 1,000 | 6,500 |
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 |
|---|---|---|
| 400 | invalid_request_error | Malformed JSON, or messages missing/empty. |
| 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. |
| 404 | model_not_found | The model value is not a known id or alias. |
| 413 | invalid_request_error | Request body too large. |
| 429 | rate_limit | More than 60 requests/minute. |
| 502 | upstream_error | Model provider unavailable — retry. |
OpenAI compatibility
The API implements the parts of the OpenAI REST surface that most apps actually use. If your SDK only touches the endpoints below, it works unchanged against https://api.muhgpt.com/v1.
Supported
| Endpoint | Notes |
|---|---|
POST/v1/chat/completions | Incl. streaming, function calling, vision and response_format JSON mode. |
GET/v1/models | Lists the model ids you can call. |
GET/v1/usage | Credit balance and consumption — a MUHGPT extension. |
Not supported yet
These endpoints respond 404 — design around them for now:
| Endpoint | Note |
|---|---|
/v1/embeddings | No embeddings endpoint. |
/v1/images/generations | Image generation lives in the app, not the API. |
/v1/audio/* | No speech-to-text or text-to-speech. |
/v1/completions (legacy) | Use /v1/chat/completions instead. |
| Other | /v1/files, /v1/assistants, /v1/moderations, fine-tuning and batches are not available. |
Behavior to know
| Topic | Detail |
|---|---|
| System prompt | A MUHGPT system prompt is always applied; custom system messages in your request are currently ignored. |
| Extra params | Only the fields listed under Chat completions are forwarded. Others (n, logit_bias, logprobs, user…) are ignored, not rejected. |
| Choices | Each response returns exactly one choice — n > 1 is not supported. |
| Resolved model | The model in the response is the underlying provider id (e.g. google/gemini-2.5-flash-lite), not the alias you sent. |