import httpx
from openai import OpenAI
client = OpenAI(api_key="<VLMRUN_API_KEY>", base_url="https://gateway.vlm.run/openai")
completion = client.chat.completions.create(
model="qwen/qwen3.5-0.8b",
messages=[{"role": "user", "content": "Say hi"}],
max_tokens=8,
)
response = httpx.get(
f"https://gateway.vlm.run/openai/completions/{completion.id}",
headers={"Authorization": "Bearer <VLMRUN_API_KEY>"},
)
print(response.json())
const completionId = "chatcmpl-d2765c665a9446b6aff13b71f1f";
const response = await fetch(`https://gateway.vlm.run/openai/completions/${completionId}`, {
headers: { Authorization: `Bearer ${process.env.VLMRUN_API_KEY}` },
});
console.log(await response.json());
curl https://gateway.vlm.run/openai/completions/chatcmpl-d2765c665a9446b6aff13b71f1f \
-H "Authorization: Bearer $VLMRUN_API_KEY"
{
"id": "chatcmpl-d2765c665a9446b6aff13b71f1f",
"model": "qwen/qwen3.5-0.8b",
"served_model_id": "qwen/qwen3.5-0.8b",
"backend": "vllm",
"cost": 0.001,
"usage": {
"prompt_tokens": 14,
"total_tokens": 22,
"completion_tokens": 8,
"cost": 0.001
},
"status": null,
"latency_ms": null
}
{
"detail": {
"error": {
"message": "Completion 'chatcmpl-doesnotexist' not found.",
"type": "completion_not_found",
"code": null,
"param": null
}
}
}
OpenAI Compatible API
Get Completion
Cost, usage, and serving details for a prior completion
GET
/
openai
/
completions
/
{completion_id}
import httpx
from openai import OpenAI
client = OpenAI(api_key="<VLMRUN_API_KEY>", base_url="https://gateway.vlm.run/openai")
completion = client.chat.completions.create(
model="qwen/qwen3.5-0.8b",
messages=[{"role": "user", "content": "Say hi"}],
max_tokens=8,
)
response = httpx.get(
f"https://gateway.vlm.run/openai/completions/{completion.id}",
headers={"Authorization": "Bearer <VLMRUN_API_KEY>"},
)
print(response.json())
const completionId = "chatcmpl-d2765c665a9446b6aff13b71f1f";
const response = await fetch(`https://gateway.vlm.run/openai/completions/${completionId}`, {
headers: { Authorization: `Bearer ${process.env.VLMRUN_API_KEY}` },
});
console.log(await response.json());
curl https://gateway.vlm.run/openai/completions/chatcmpl-d2765c665a9446b6aff13b71f1f \
-H "Authorization: Bearer $VLMRUN_API_KEY"
{
"id": "chatcmpl-d2765c665a9446b6aff13b71f1f",
"model": "qwen/qwen3.5-0.8b",
"served_model_id": "qwen/qwen3.5-0.8b",
"backend": "vllm",
"cost": 0.001,
"usage": {
"prompt_tokens": 14,
"total_tokens": 22,
"completion_tokens": 8,
"cost": 0.001
},
"status": null,
"latency_ms": null
}
{
"detail": {
"error": {
"message": "Completion 'chatcmpl-doesnotexist' not found.",
"type": "completion_not_found",
"code": null,
"param": null
}
}
}
Looks up a prior chat completion or transcription by its
See Error Codes for the Gateway-wide envelope.
id. The reply is metadata only: model, backend, cost, and usage. It never holds the request or the reply content.
Send the same Authorization header that made the call. The lookup spends one call from your rate-limit budget. The MCP get_completion tool reads the same records.
| Caller | Record kept for | Readable by |
|---|---|---|
| API key | Durably, in billing | The same user or organization |
| Anonymous | Up to about 15 minutes | The same Authorization value, or no header if the call sent none |
import httpx
from openai import OpenAI
client = OpenAI(api_key="<VLMRUN_API_KEY>", base_url="https://gateway.vlm.run/openai")
completion = client.chat.completions.create(
model="qwen/qwen3.5-0.8b",
messages=[{"role": "user", "content": "Say hi"}],
max_tokens=8,
)
response = httpx.get(
f"https://gateway.vlm.run/openai/completions/{completion.id}",
headers={"Authorization": "Bearer <VLMRUN_API_KEY>"},
)
print(response.json())
const completionId = "chatcmpl-d2765c665a9446b6aff13b71f1f";
const response = await fetch(`https://gateway.vlm.run/openai/completions/${completionId}`, {
headers: { Authorization: `Bearer ${process.env.VLMRUN_API_KEY}` },
});
console.log(await response.json());
curl https://gateway.vlm.run/openai/completions/chatcmpl-d2765c665a9446b6aff13b71f1f \
-H "Authorization: Bearer $VLMRUN_API_KEY"
{
"id": "chatcmpl-d2765c665a9446b6aff13b71f1f",
"model": "qwen/qwen3.5-0.8b",
"served_model_id": "qwen/qwen3.5-0.8b",
"backend": "vllm",
"cost": 0.001,
"usage": {
"prompt_tokens": 14,
"total_tokens": 22,
"completion_tokens": 8,
"cost": 0.001
},
"status": null,
"latency_ms": null
}
{
"detail": {
"error": {
"message": "Completion 'chatcmpl-doesnotexist' not found.",
"type": "completion_not_found",
"code": null,
"param": null
}
}
}
Response
| Field | Type | Description |
|---|---|---|
id | string | The completion id: chatcmpl-… for chat, transcription-… for transcription. |
model | string | The model id the response reported. |
served_model_id | string | The canonical model id. |
backend | string | The inference runtime, such as vllm or paddleocr. |
cost | number | null | The charge in USD. null when the call was not priced. |
usage | object | prompt_tokens, completion_tokens, total_tokens, and cost for chat. input_tokens, output_tokens, total_tokens, input_audio_seconds, and cost for transcription. |
status | string | null | The billing status, completed or failed. |
latency_ms | number | null | End-to-end latency in milliseconds. |
status and latency_ms come from the billing record. A lookup answered from the short-lived cache returns them as null.
Errors
| Status | type | When |
|---|---|---|
404 | completion_not_found | The id is unknown, expired, or belongs to another caller. A retry of the original call mints a new id. It does not resolve the missed one. |
401 | n/a | The API key is invalid. |
429 | rate_limit_exceeded | The rate-limit budget is spent. |
Authorizations
Response
Successful Response
Cost, token usage, and serving metadata for one gateway generation.