Base URL

# Public gateway
https://mgpt.continualmi.com/api/mgpt

# Local development (backend-api)
http://127.0.0.1:8090/api/mgpt

All 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

HeaderRequiredNotes
AuthorizationyesBearer <api-key>
Content-Typeyes (POST)application/json
X-Request-IdnoOptional caller correlation id for logs and diagnostics.
POST/api/mgpt/chat/completions

Create 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

FieldTypeRequiredNotes
modelstringyesModel id from the Models page, for example deepseek-v4-pro or deepseek-v4-flash.
messagesarrayyesOpenAI-compatible chat messages.
streambooleannoWhen true, returns server-sent events.
toolsarraynoFunction-calling tool definitions forwarded to compatible providers.
tool_choicestring | objectnoOpenAI-compatible tool selection.
stream_optionsobjectnoSet { "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." }
    ]
  }'
POST/api/mgpt/images

Generate 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.

FieldTypeRequiredNotes
systemPromptstringyesImage-generation system prompt.
descriptionstringyesMain scene or asset description.
additionalPromptstringnoShort addendum appended last.
referenceImagesarraynoInterleaved text/image parts for references.
imageConfigobjectnoimageSize: 1K | 2K | 4K; aspectRatio defaults to 16:9.
modelstringnoDefaults to the public image alias when omitted.
GET/api/mgpt/logs

List logs

List recent generation logs, or fetch a single log when identifier is provided. Required scope: mgpt.logs:read.

Query parameterTypeRequiredNotes
ownerUserIdstringyesOwning user; required for scoping.
kindtext | imagenoRestrict by log kind.
identifierstringnoFetch a single log by id.
requestIdstringnoFilter by caller correlation id.
pageinteger >= 1no1-indexed page number.
pageSizeinteger 1-100noItems 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" }
StatusMeaningNotes
400Validation errorMissing field, invalid messages, or unsupported model.
401UnauthorizedMissing or invalid bearer token.
403ForbiddenToken lacks the required scope.
5xxProvider / storage failureRetry according to your client policy.

Scopes

ScopeEndpoints
mgpt.responses:createPOST /chat/completions
mgpt.images:createPOST /images
mgpt.logs:readGET /logs