Mira, inside your product
Bring an assistant into your application with your business knowledge, customer tools and support workflow
Use the Chat Completions endpoint for messages, streaming and tool calls
Your server controls access to live customer records and any actions
The fastest way: a Chat Completions endpoint
Point any Chat Completions client library (for example the openai package) at https://api.mirroapi.cloud/v1/mira with your AI-only token (below) and model mira, or mira-deep where it is enabled. Use messages, stream: true, tools, tool_choice and response_format in the documented request format
Check the API reference for supported options and limits
import OpenAI from 'openai';
const mira = new OpenAI({ apiKey: process.env.MIRA_API_KEY, baseURL: 'https://api.mirroapi.cloud/v1/mira' });
const stream = await mira.chat.completions.create({
model: 'mira', stream: true,
messages: [{ role: 'user', content: 'What do you offer, and how do I get started?' }]
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
from openai import OpenAI
mira = OpenAI(api_key=MIRA_API_KEY, base_url="https://api.mirroapi.cloud/v1/mira")
reply = mira.chat.completions.create(model="mira", messages=[{"role": "user", "content": "What is your refund policy?"}])
Inside one request Mira can search your knowledge, check prop-firm rules with the same arithmetic MIRRO's challenge engine uses, size positions, split payouts and calculate before returning an answer. Those steps stay on our side; the reply also carries a mira field with the steps, the sources used and a cost estimate
Mira Search & Fetch adds public web research when the search service is enabled, with dated sources and page text.
Teach Mira your business
Add a business profile and approved knowledge, then update them when your products or policies change
Firms that run challenges on MIRRO can also use their published program information
The example below shows a prop-firm profile; replace it with your own business facts
// Who Mira works for
await fetch('https://api.mirroapi.cloud/v1/mira/profile', { method: 'PUT', headers, body: JSON.stringify({
name: 'Apex Funding', industry: 'prop_firm', voice: 'Warm and exact',
support: { email: 'help@apex.example', escalation: 'Open a ticket in the dashboard' },
facts: [{ label: 'Payout cycle', value: 'Every 14 days after the first payout' }],
rules: { never: ['Invent company policies or promise unverified refunds'] }
}) });
// What Mira should know: rulebooks, FAQs, policies (plain text or Markdown)
await fetch('https://api.mirroapi.cloud/v1/mira/knowledge', { method: 'POST', headers, body: JSON.stringify({
title: 'Trading rules', externalId: 'help/rules', text: rulesMarkdown
}) });
Posting the same externalId again replaces that document. POST /v1/mira/knowledge/search previews saved passages that match a question. Never put passwords or keys in knowledge: it is quoted to your customers
Give Mira your live data
Declare tools in the request. When Mira requests a tool, it returns a standard tool_calls message; your server checks the signed-in customer may see that data, runs it and sends the result as a tool message. Tool runners in Chat Completions client libraries and agent frameworks drive this unchanged
tools: [{ type: 'function', function: {
name: 'get_trader_account',
description: 'Live figures and program for an account the signed-in trader owns',
parameters: { type: 'object', properties: { login: { type: 'string' } }, required: ['login'] }
} }]
Use a chat-completions client: with an agents library choose its chat-completions model class (for example OpenAIChatCompletionsModel), with Vercel's AI library openai.chat('mira'). stop, strict tools, parallel_tool_calls: false and tool_choice: "none" are honoured
Limits: about 120 KB of conversation per request, 32 tools, two images (base64 data URLs) per conversation on models with vision. 429 MIRA_ALLOWANCE means the daily or monthly allowance is used; 503 MIRA_BUSY means wait and retry. Once a model call may have been paid, a failure says x-should-retry: false, so client libraries do not pay for the same run twice. Usage is a provider-cost estimate, not an invoice
1 · Create an AI-only token
In a self-service business workspace, open API keys and create a key for your server
In an approved firm workspace, open API access → Generate token → Mira API only
Keep keys on your server; existing admin tokens do not automatically include AI access
Install the typed JavaScript / TypeScript client 0.7.1, then read the configured modes
import { MirroClient } from '@mirroapi/client';
const mira = new MirroClient({ apiKey: process.env.MIRA_API_KEY });
const availability = await mira.miraModels();
// Check the mode and vision support before sending screenshots
2 · Or: send once, recover by ID
Save the request in your database before submitting it. This lets you recover the same generation if your connection drops
const request = {
requestId: crypto.randomUUID(),
input: 'Add a small scrolling announcement above my website menu'
};
await saveRequest(request); // your application database
const accepted = await mira.createMiraResponse(request);
const response = await mira.miraResponse(accepted.id);
A new request usually returns HTTP 202 with status running. Poll every 1–2 seconds until that changes. completed contains the answer. requires_action asks your application to run a tool. Neither status proves a website was changed or deployed
If the acceptance response was lost, look up the original requestId or submit the identical saved body again. Do not generate a new ID to recover the same work
3 · Connect your application tools
Send named tools with descriptions and object JSON schemas. Start with a read-only support or website tool. MIRRO does not execute these tools or connect to your database automatically
tools: [{
name: 'read_page',
description: 'Read a page the signed-in user can access',
parameters: {
type: 'object',
properties: { pageId: { type: 'string' } },
required: ['pageId'],
additionalProperties: false
}
}]
For each returned tool call, validate the arguments and check the user's permissions. Save the execution result by response ID and tool-call ID so a retry cannot run it twice. Return errors and refusals honestly
const next = {
requestId: crypto.randomUUID(),
previousResponseId: response.id,
mode: 'balanced',
toolResults: [{ callId: response.toolCalls[0].id, result: savedResult }]
};
await saveRequest(next);
await mira.createMiraResponse(next);
Return one result for every requested tool call. Keep the same mode and API key. Instructions and tool definitions carry forward automatically
For screenshot input, add images: [{name, mime, base64}]. Supported models accept up to two PNG, JPEG or WebP images, each at most 1 MB and 2048 pixels per side
Recovery you can account for
- Uncertain response — the provider outcome could not be confirmed; its reserved estimate stays held. Do not blindly resubmit with a new ID
- Incomplete response — the model stopped before completion; do not execute partial instructions
- Usage — token counts and provider-cost estimates, not a customer invoice. AI requests and polls do not enter trading API billing
- Retention — response access expires after 24 hours. Expired payloads are removed on later workspace access; identity and usage records remain
- Capacity — two concurrent responses per workspace, a three-minute provider timeout and explicit input/context limits. Daily and shared monthly AI budgets apply
On the recoverable requests API, client cancellation stops waiting, not a saved generation; it uses polling and has no cancellation endpoint. For streaming, use the Chat Completions endpoint above. Your application remains responsible for tool authorization, execution and deployment checks