Chat Completions API

OpenAI-compatible chat completions with built-in reasoning, tool use, and streaming.

Overview

The Chat Completions API is the primary interface for interacting with MiroMind models. It follows the OpenAI Chat Completions format, so you can use the OpenAI SDK or any compatible client. The API is served by the frontier gateway.

Base URL:https://api.miromind.ai
Auth:Bearer API Key
Format:OpenAI-compatible
List Models

Retrieve the list of available models. Use the model id in the model parameter when creating a chat completion.

GET/v1/models

Response

{
  "object": "list",
  "data": [
    {
      "id": "mirothinker-1-7-deepresearch-mini",
      "object": "model",
      "created": 1700000000,
      "owned_by": "miromind"
    },
    {
      "id": "mirothinker-1-7-deepresearch",
      "object": "model",
      "created": 1700000000,
      "owned_by": "miromind"
    }
  ]
}

Example

curl https://api.miromind.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"
POST/v1/chat/completions
Create Chat Completion

Send a conversation to the model and receive a completion. Supports streaming (SSE) and non-streaming modes.

Headers

AuthorizationRequired

Your MiroMind API key

Bearer YOUR_API_KEY
Content-TypeRequired

Must be application/json

application/json

Parameters

modelstringRequired

Model ID to use, e.g. "mirothinker-1-7-deepresearch-mini"

messagesarrayRequired

Array of message objects with "role" (system/user/assistant) and "content" fields

streamboolean

Whether to stream the response via SSE. Defaults to true.

max_tokensinteger

Maximum number of tokens to generate in the completion

mcp_serversarray

Array of MCP server configs ({name, url, headers?, access_token?, oauth?}) for external tool access

Request

curl -X POST https://api.miromind.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mirothinker-1-7-deepresearch-mini",
    "messages": [
      {
        "role": "user",
        "content": "What are the latest trends in AI?"
      }
    ],
    "stream": true
  }'

Response

Non-Streaming
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "mirothinker-1-7-deepresearch-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here are the latest trends in AI..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 256,
    "total_tokens": 268
  }
}
Streaming Response

When stream: true (the default), the response is delivered as Server-Sent Events (SSE). Each line is prefixed with data: followed by a JSON chunk. The stream ends with data: [DONE]. The stream has two phases:

Phase 1: Reasoning

The model emits reasoning steps via delta.reasoning_steps. Each step has a type (e.g. thinking, web_search) and a content field with the step details.

Phase 2: Final Answer

After reasoning completes, the final answer streams via delta.content, token by token, just like standard OpenAI streaming.

SSE Stream Example

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_steps":[{"type":"thinking","thought":"Let me analyze this question..."}]}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_steps":[{"type":"web_search","web_search":{"search_keywords":["latest AI trends 2026"]}}]}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Here are"}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" the latest"}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" trends..."}}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":256,"total_tokens":268,"reasoning_tokens":45,"num_search_queries":1}}

data: [DONE]
Non-Streaming Response

Set stream: false to receive the full response as a single JSON object. The response waits until the model finishes generating before returning.

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "mirothinker-1-7-deepresearch-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here are the latest trends in AI...",
        "reasoning_steps": [
          {
            "type": "thinking",
            "thought": "Let me analyze this question..."
          },
          {
            "type": "web_search",
            "web_search": {
              "search_keywords": ["latest AI trends 2026"],
              "search_results": [{"title": "...", "url": "...", "snippet": "..."}]
            }
          }
        ]
      },
      "finish_reason": "stop"
    }
  ],
  "search_results": [{"title": "...", "url": "...", "snippet": "..."}],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 256,
    "total_tokens": 268,
    "reasoning_tokens": 45,
    "num_search_queries": 1
  }
}
Finish Reason & Usage

The final chunk (streaming) or the response (non-streaming) includes a finish_reason and a usage object.

finish_reasonDescription
stopThe model completed normally
errorThe workflow failed due to an internal error. An error object is included in the chunk.
cancelledThe request was cancelled (client disconnect or explicit cancel)
usage fieldDescription
prompt_tokensTokens in the input prompt
completion_tokensTokens generated in the completion
total_tokensSum of prompt + completion tokens
reasoning_tokensTokens spent on reasoning (subset of completion_tokens)
num_search_queriesNumber of web searches performed
Reasoning Step Types

During the reasoning phase, the model can emit the following step types:

TypeDescription
thinkingInternal reasoning and analysis
web_searchSearching the web for information
fetch_url_contentFetching and reading content from a URL
execute_pythonExecuting Python code in a sandboxed environment
execute_commandRunning a shell command
tool_callCalling an MCP tool or external function
OpenAI SDK Compatibility

Point any OpenAI SDK at the MiroMind base URL and use your MiroMind API key. The API is fully compatible with the OpenAI Chat Completions format.

Python (openai SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://api.miromind.ai/v1",
    api_key="YOUR_API_KEY",
)

stream = client.chat.completions.create(
    model="mirothinker-1-7-deepresearch-mini",
    messages=[
        {"role": "user", "content": "What are the latest trends in AI?"}
    ],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta
    if delta.content:
        print(delta.content, end="", flush=True)

Node.js (openai SDK)

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.miromind.ai/v1',
  apiKey: 'YOUR_API_KEY',
});

const stream = await client.chat.completions.create({
  model: 'mirothinker-1-7-deepresearch-mini',
  messages: [
    { role: 'user', content: 'What are the latest trends in AI?' }
  ],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) process.stdout.write(content);
}
Error Responses

The API returns standard HTTP error codes with a JSON error body.

StatusCodeDescription
400bad_requestInvalid request body or missing required fields
401unauthorizedMissing or invalid API key
402insufficient_balanceAccount balance is too low to process the request
429rate_limitedToo many requests. Retry after the Retry-After header value.
503service_unavailableThe service is temporarily overloaded or down for maintenance

Error Response Format

{
  "error": {
    "code": "unauthorized",
    "message": "Invalid API key provided.",
    "type": "authentication_error"
  }
}
Next Steps

For long-running tasks that should survive disconnects, use the Async API.

MiroMindAI Platform - Build Together. Evolve Forever.