Base URL
# Public gateway
https://mgpt.continualmi.com/api/mgpt
# Local development (backend-api)
http://127.0.0.1:8090/api/mgptAll examples on this page use the public gateway. The local backend accepts the same bodies under the /api/mgpt prefix.
Authentication
All endpoints require a bearer token issued from the MGPT API console. Keys have the shape cmi_live_<public>.<secret> and are stored hashed in core.api_keys.
Authorization: Bearer cmi_live_<public>.<secret>Headers
| Header | Required | Notes |
|---|---|---|
Authorization | yes | Bearer <api-key> |
Content-Type | yes (POST) | application/json |
X-Request-Id | no | Optional caller correlation id for logs and diagnostics. |
/api/mgpt/chat/completionsCreate chat completion
OpenAI-compatible text generation through the MGPT model gateway. MGPT resolves the public model id, routes the request to the configured execution backend, records diagnostics, and returns a chat completion response or SSE stream.
Required scope: mgpt.responses:create.
Request body
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | yes | Model id from the Models page, for example deepseek-v4-pro or deepseek-v4-flash. |
messages | array | yes | OpenAI-compatible chat messages. |
stream | boolean | no | When true, returns server-sent events. |
tools | array | no | Function-calling tool definitions forwarded to compatible providers. |
tool_choice | string | object | no | OpenAI-compatible tool selection. |
stream_options | object | no | Set { "include_usage": true } to include usage in streamed responses when supported. |
Response body
{
"id": "chatcmpl_...",
"object": "chat.completion",
"created": 1770280000,
"model": "deepseek-v4-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello from MGPT."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 5,
"total_tokens": 17
}
}Examples
curl https://mgpt.continualmi.com/api/mgpt/chat/completions \
-H "Authorization: Bearer $CONTINUAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{ "role": "user", "content": "Say hello in one sentence." }
]
}'/api/mgpt/imagesGenerate image
Image generation endpoint for platform and MDL media workflows. MGPT assembles the provider image message from the system prompt, description, optional references, and image configuration.
Required scope: mgpt.images:create.
| Field | Type | Required | Notes |
|---|---|---|---|
systemPrompt | string | yes | Image-generation system prompt. |
description | string | yes | Main scene or asset description. |
additionalPrompt | string | no | Short addendum appended last. |
referenceImages | array | no | Interleaved text/image parts for references. |
imageConfig | object | no | imageSize: 1K | 2K | 4K; aspectRatio defaults to 16:9. |
model | string | no | Defaults to the public image alias when omitted. |
/api/mgpt/logsList logs
List recent generation logs, or fetch a single log when identifier is provided. Required scope: mgpt.logs:read.
| Query parameter | Type | Required | Notes |
|---|---|---|---|
ownerUserId | string | yes | Owning user; required for scoping. |
kind | text | image | no | Restrict by log kind. |
identifier | string | no | Fetch a single log by id. |
requestId | string | no | Filter by caller correlation id. |
page | integer >= 1 | no | 1-indexed page number. |
pageSize | integer 1-100 | no | Items per page. |
curl "https://mgpt.continualmi.com/api/mgpt/logs?ownerUserId=$USER_ID&kind=text&pageSize=20" \
-H "Authorization: Bearer $CONTINUAL_API_KEY"Errors
Errors return JSON with a detail field and an HTTP status.
{ "detail": "Unsupported model: example-model" }| Status | Meaning | Notes |
|---|---|---|
400 | Validation error | Missing field, invalid messages, or unsupported model. |
401 | Unauthorized | Missing or invalid bearer token. |
403 | Forbidden | Token lacks the required scope. |
5xx | Provider / storage failure | Retry according to your client policy. |
Scopes
| Scope | Endpoints |
|---|---|
mgpt.responses:create | POST /chat/completions |
mgpt.images:create | POST /images |
mgpt.logs:read | GET /logs |