Skip to content
Milly Lab
Sign up

Developers

Milly Lab API

The Milly Lab API is an OpenAI-compatible REST API at https://api.m-lab.app/v1. One key reaches 13 chat models from OpenAI, Anthropic, Google, DeepSeek and xAI, 4 image models and an embeddings model. It comes with the Max plan ($42 a month) and higher. Each model has a listed price per million input and output tokens.

Last updated:

Milly Lab API at a glance

ItemValue
Base URLhttps://api.m-lab.app/v1
ProtocolOpenAI wire format for chat completions, embeddings and images; streaming over server-sent events
AuthenticationBearer key that starts with mk_, shown once when you create it
Plans with API accessMax, Advanced and Enterprise
PriceA listed price per 1M input and output tokens for each model; image models per image (see the model list below)
Beyond the plan allowancePaid from the top-up balance at pay-as-you-go rates shown in the app
Rate limitUp to 120 requests per minute per key
Keys per accountUp to 5 active keys, each with its own spend cap and model list
Live price listGET /v1/models, no key required

How do I make my first request?

Create a key under API keys in your Milly Lab account, then point any OpenAI SDK at https://api.m-lab.app/v1. Each example below sends the same chat request.

  1. Create a key. It starts with mk_ and is shown only once, so store it in an environment variable such as MILLY_API_KEY.
  2. Set the base URL to https://api.m-lab.app/v1. Nothing else changes in OpenAI-compatible code.
  3. Pick a model id from GET /v1/models, for example claude-sonnet-5.

curl

curl https://api.m-lab.app/v1/chat/completions \
  -H "Authorization: Bearer $MILLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-sonnet-5", "messages": [{"role": "user", "content": "Hello"}]}'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.m-lab.app/v1", api_key=os.environ["MILLY_API_KEY"])
r = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.m-lab.app/v1", apiKey: process.env.MILLY_API_KEY });
const r = await client.chat.completions.create({
  model: "claude-sonnet-5",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);

The response is a standard chat.completion object, and its usage field shows the tokens you were billed for. Send stream: true to receive the answer as server-sent events instead.

Which endpoints does the API have?

All 5 API endpoints live under https://api.m-lab.app/v1.

EndpointWhat it does
GET /v1/modelsLists every API model with live prices, context window and output limit. Works without a key.
POST /v1/chat/completionsChat completion, streamed over server-sent events or returned in one response.
POST /v1/embeddingsEmbeddings with text-embedding-3-small (1,536 dimensions).
POST /v1/images/generationsGenerates 1–4 images per call with 4 image models. Synchronous, up to 180 seconds.
GET /v1/usageRequests, tokens and billed dollars per key and per model, for up to 92 days per query.

Which plans include API access?

API access is included in the Max, Advanced and Enterprise plans. On Free, Starter and Pro you cannot create API keys. If your plan drops below Max, existing keys stop working until you upgrade, but you can still see and revoke them.

PlanPrice per monthAPI access
Free$0No
Starter$12No
Pro$25No
Max$42Yes
Advanced$72Yes
EnterpriseCustomYes

The Free plan gives 10 chat messages per model every 4 hours in the web app, without API access.

Compare all plans

How much does an API call cost?

Each model has a listed price per million input and output tokens; image models have a listed price per image. The listed price is what a call costs when it is paid from your balance, and both are in the model list below and in GET /v1/models. Your plan's monthly allowance for the model covers calls first.

  • Plan allowance first: a request to a model your plan includes is covered by that model's monthly allowance.
  • Then the top-up balance: other models, and usage after the allowance runs out, are paid from it at the listed price.
  • Checked before the call: if allowance and balance cannot cover a request, the API answers 402 before any provider is called, so nothing is billed.
  • Partial output is billed: if your client disconnects mid-stream, generation finishes and the tokens produced are charged.

Worked example

A Claude Sonnet 5.5 request with 10,000 input tokens and 1,000 output tokens costs $0.082 from your balance at the listed prices (10,000 × $6.00 + 1,000 × $22.00 per million tokens).

Prices are in US dollars. You pay by bank card (Visa, Mastercard and others) or a Tajik e-wallet on a secure payment page. The charge is made in somoni at the day's exchange rate; if your card is in another currency, your bank converts it.

Which models can I call, and at what price?

These are the models GET /v1/models listed on 2026-11-08: chat models, image models and one embeddings model. Prices are listed per million tokens (per image for image models); the endpoint itself is always the current source.

Chat models

ModelAPI idInput, $ per 1M tokensOutput, $ per 1M tokensContext window, tokensPlan allowance
Luna · GPT-6gpt-5.4-nano$2.20$3.001,050,000Max, Advanced
Terra · GPT-6.1gpt-5.4$4.00$12.001,050,000Max, Advanced
Sol · GPT-6.1gpt-5.5$6.00$22.001,050,000Max, Advanced
Sol · GPT-6gpt-5.3-codex$6.00$22.001,050,000Advanced
Claude Haiku 5.5claude-haiku-5-5$2.20$3.001,000,000Max, Advanced
Claude Sonnet 5.5claude-sonnet-5$6.00$22.001,000,000Max, Advanced
Claude Opus 5.5claude-opus-4-8$10.00$42.001,000,000Advanced
DeepSeek Flashdeepseek-v4-flash$2.60$4.401,000,000Balance only
DeepSeek Flash · Prodeepseek-v4$2.60$4.401,000,000Balance only
DeepSeek V4 Prodeepseek-v4-pro$4.64$9.921,000,000Max, Advanced
Gemini 3.8 Flash 200Kgemini-3.6-flash-200k$3.50$9.50200,000Balance only
Gemini 3.8 Flashgemini-3.6-flash$3.50$9.501,048,576Max, Advanced
Grok 4.7grok-4.3$6.00$14.00500,000Balance only

Some models have a second price for long prompts: a request whose prompt, cached tokens included, is longer than the model's threshold is billed entirely at its long-prompt prices (the table below). Claude Haiku 5.5, for example, costs $3.00 per million input tokens and $7.00 per million output tokens once a prompt exceeds 100,000 tokens. Claude models also price prompt-cache writes and reads at their own rates, and each web search the model runs costs $0.02. GET /v1/models lists every rate.

Long prompts

ModelPrompt longer than, tokensInput, $ per 1M tokensOutput, $ per 1M tokens
Luna · GPT-6272,000$2.40$3.50
Terra · GPT-6.1272,000$6.00$17.00
Sol · GPT-6.1272,000$10.00$32.00
Sol · GPT-6272,000$10.00$32.00
Claude Haiku 5.5100,000$3.00$7.00
Grok 4.7199,999$10.00$26.00

Image models

ModelAPI idPrice per image, standard qualityPlan allowance
Gemini Nano Banana 2.1gemini-nano-banana$0.0872Max, Advanced
GPT Image 2.5 Flaregpt-image-2$0.1254Max, Advanced
Flux 3 Imagefal-ai/flux-pro$0.116Max
Stable Diffusion 3.5 Largefal-ai/stable-diffusion-xl$0.15Advanced

Embeddings

text-embedding-3-small returns 1,536-dimension vectors and has a listed price of $2.04 per million input tokens. No plan includes embeddings, so they are always paid from the top-up balance at that price.

The Plan allowance column names the plans that include a monthly allowance for the model. Models marked “Balance only”, such as Grok 4.7, have no plan allowance and are paid from the top-up balance at pay-as-you-go rates shown in the app. Enterprise allowances are agreed per contract. Other image quality levels change the per-image price.

What are the rate limits?

Each API key can make up to 120 requests per minute, and an account can hold up to 5 active keys. A request over the limit gets HTTP 429 with a Retry-After header that says how many seconds to wait.

LimitValue
Requests per keyUp to 120 per minute
Active keys per account5
Messages per chat request200
Characters per chat request400,000
Embedding inputs per call256, up to 12,000 characters each
Images per call1–4, prompt up to 4,000 characters
Time limit per image request180 seconds
Usage report rangeUp to 92 days

Every /v1 response carries an x-request-id header; quote it when you contact support. Responses to a request with a valid key also carry x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-window.

How do spend caps and allowed models work?

Each key can have a monthly spend cap in US dollars and a list of allowed models. A call after the cap is reached returns 402 spend_cap_reached; a call to a model outside the list returns 403 model_not_allowed. Both checks run before anything is charged.

ControlHow it works
Monthly spend capWhole cents, up to $100,000. It counts the billed spend on that key since the 1st of the month (UTC) and resets on the 1st. The request that crosses the cap still completes, so the overshoot is at most one request.
Allowed modelsUp to 64 model ids; an empty list means every API model. Older aliases are resolved to the current id.
RevokingA revoked key fails from its next request. You can list and revoke keys on any plan.

CORS is open on /v1, so browser code can call the API directly, but a key in a web page is visible to every visitor. Give such a key a tight spend cap and an allowed-model list, or call the API from your own server.

What error codes does the API return?

Errors use the OpenAI error format shown below, so SDK error handling works unchanged. Branch on the code field, not on the message text.

{"error": {"message": "…", "type": "…", "code": "…"}}
HTTPcodeMeaning
400invalid_body · invalid_messages · invalid_input · input_too_long · unsupported_encoding · invalid_rangeMalformed body, no user text, invalid embedding input or an invalid usage date range
401missing_api_key · invalid_api_keyNo bearer key, or an unknown or revoked key
402insufficient_for_request · insufficient_balancePlan allowance plus balance cannot cover the request
402spend_cap_reachedThe key reached its monthly spend cap
403api_access_requiredThe account's plan has no API access
403model_not_allowedThe model is not on the key's allowed list
403account_disabledThe account is disabled
404model_not_found · key_not_foundUnknown or retired model, or a key id that is not on this account
429rate_limit_exceededMore than 120 requests per minute on this key; wait for the Retry-After time
502upstream_errorThe provider failed before producing output; nothing is billed
503provider_unavailableThe model's provider is currently unavailable; nothing is billed

Questions developers ask

Does the Milly Lab API work with the OpenAI SDKs?

Yes. Chat completions, embeddings and image generation use the OpenAI wire format, so the official openai packages for Python and Node.js, and other OpenAI-compatible tools, work once you set the base URL to https://api.m-lab.app/v1 and use a Milly Lab key.

Does the API support tool calling and image input?

Image input, yes: chat messages take text, plus image_url parts on models whose capabilities.vision is true (PNG, JPEG, GIF or WebP, up to 5 MB each, at most 8 per request); other models refuse images. Tool calling, not yet: the tools and tool_choice fields are accepted so SDK defaults do not fail, but they are not executed.

Can I generate video or 3D through the API?

No. The API covers chat completions, embeddings and image generation. Video and 3D generation are not available through /v1.

Can I call a model my plan does not include?

Yes. On the Max plan and higher you can call any model that GET /v1/models lists. A model without a monthly allowance on your plan, such as Grok 4.7, is paid from your top-up balance at pay-as-you-go rates shown in the app.

Is there a free API tier?

No. Creating API keys requires the Max plan or higher. The Free plan gives 10 chat messages per model every 4 hours in the web app, without API access.

How do I pay for API usage?

API usage is paid from your plan's monthly allowance first and then from your top-up balance; prices are in US dollars. You pay by bank card (Visa, Mastercard and others) or a Tajik e-wallet on a secure payment page. The charge is made in somoni at the day's exchange rate; if your card is in another currency, your bank converts it.

Where is the full API reference?

The API guide covers streaming, embeddings, images, the usage endpoint and best practices in detail.