curl https://mifr-gateway-production.up.railway.app/v1/chat/completions \
-H "Authorization: Bearer $MIFR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-4b",
"messages": [{"role": "user", "content": "Reply with the single word pong."}]
}'
from openai import OpenAI
client = OpenAI(
base_url="https://mifr-gateway-production.up.railway.app/v1",
api_key="YOUR_MIFR_API_KEY",
)
r = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "Reply with the single word pong."}],
)
print(r.choices[0].message.content)
const res = await fetch(
"https://mifr-gateway-production.up.railway.app/v1/chat/completions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MIFR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "qwen3-4b",
messages: [{ role: "user", content: "Reply with the single word pong." }],
}),
},
);
const json = await res.json();
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "qwen3-4b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "pong" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 1,
"total_tokens": 13
},
"mifr_receipt": {
"trust_level": "hardware",
"model_id": "qwen3-4b"
}
}
{
"error": {
"message": "missing or invalid API key (Authorization: Bearer <key>)",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null,
"mifr_action": "fix_key"
}
}
API reference
Create chat completion
OpenAI-compatible Chat Completions, including streaming and the signed receipt.
POST
https://mifr-gateway-production.up.railway.app
/
v1
/
chat
/
completions
curl https://mifr-gateway-production.up.railway.app/v1/chat/completions \
-H "Authorization: Bearer $MIFR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-4b",
"messages": [{"role": "user", "content": "Reply with the single word pong."}]
}'
from openai import OpenAI
client = OpenAI(
base_url="https://mifr-gateway-production.up.railway.app/v1",
api_key="YOUR_MIFR_API_KEY",
)
r = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "Reply with the single word pong."}],
)
print(r.choices[0].message.content)
const res = await fetch(
"https://mifr-gateway-production.up.railway.app/v1/chat/completions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MIFR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "qwen3-4b",
messages: [{ role: "user", content: "Reply with the single word pong." }],
}),
},
);
const json = await res.json();
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "qwen3-4b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "pong" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 1,
"total_tokens": 13
},
"mifr_receipt": {
"trust_level": "hardware",
"model_id": "qwen3-4b"
}
}
{
"error": {
"message": "missing or invalid API key (Authorization: Bearer <key>)",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null,
"mifr_action": "fix_key"
}
}
This is the OpenAI-compatible Chat Completions endpoint, for both stream and non-stream calls. A non-stream 200 is a
Failure after the first streamed token puts the same error object in
chat.completion with usage and mifr_receipt. Stream is SSE (text/event-stream): a role chunk, content deltas, keepalives every 10 seconds (: keepalive), a stop chunk, then data: [DONE].
The JSON model field echoes the request. The alias actually served is x-mifr-model / mifr_receipt.model_id.
string
required
Bearer product key. Format:
Bearer sk-mifr_…. See Authentication.string
required
Catalog alias or Hugging Face id. An empty value is 400. An unknown name is 404
model_not_found. Default alias: qwen3-4b.object[]
required
Non-empty. Each item needs
role. Max 100 messages, 256 KiB total content chars.number
default:"512"
Integer. Fractional values are rejected. Qwen3 is a thinking model, so a tiny cap often fills with
<think>… and never reaches a visible answer.number
Alias for
max_tokens. max_tokens wins if both are set.number
default:"0.7"
Number. Bools and string numbers are rejected.
boolean
default:"false"
If true, respond as SSE. The receipt and
x_mifr_* verdicts are on the final chunk, not on the SSE HTTP head.string
Pin one Mac: exact provider id, or a unique prefix of at least 8 characters. A pin does not hop or hedge. If that Mac is offline or below the floor, the call returns 503
provider_unavailable.string
Alias for
provider.object
Extra keys are ignored.
include_usage still appears on the stop chunk.Response
string
Completion id.
string
chat.completion (non-stream) or chat.completion.chunk (stream).string
Echo of the request
model field.object[]
Standard OpenAI choices. A stream sends a role chunk, then content deltas, then a stop chunk.
object
Token counts from the verified receipt. Present on non-stream 200 and on the terminal SSE chunk.
object
Signed, request-bound receipt. This is the proof; HTTP
x-mifr-* headers are the gateway’s report of the same facts.data: and omits [DONE]. Do not splice a retry onto those bytes. If the caller hangs up, the gateway aborts the seal (aborted) and sends no body.
See Errors and headers for the full mifr_action table and verdict header list.
curl https://mifr-gateway-production.up.railway.app/v1/chat/completions \
-H "Authorization: Bearer $MIFR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-4b",
"messages": [{"role": "user", "content": "Reply with the single word pong."}]
}'
from openai import OpenAI
client = OpenAI(
base_url="https://mifr-gateway-production.up.railway.app/v1",
api_key="YOUR_MIFR_API_KEY",
)
r = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "Reply with the single word pong."}],
)
print(r.choices[0].message.content)
const res = await fetch(
"https://mifr-gateway-production.up.railway.app/v1/chat/completions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MIFR_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "qwen3-4b",
messages: [{ role: "user", content: "Reply with the single word pong." }],
}),
},
);
const json = await res.json();
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "qwen3-4b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "pong" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 1,
"total_tokens": 13
},
"mifr_receipt": {
"trust_level": "hardware",
"model_id": "qwen3-4b"
}
}
{
"error": {
"message": "missing or invalid API key (Authorization: Bearer <key>)",
"type": "invalid_request_error",
"code": "invalid_api_key",
"param": null,
"mifr_action": "fix_key"
}
}