Skip to content
Docs menu

llm

The model gateway. One interface to AI models from Anthropic, OpenAI, Google Gemini and OpenRouter. Each call is metered and billed to the workspace, or made with the workspace's own key for that vendor.

2 operations · 9 schemas

GET /v1/llm/models

The AI models the hub offers, with their prices

listLlmModels · scope none

Lists every AI model the hub can call, grouped by vendor. Each model carries its vendor's list price per million tokens and the price the hub charges for it.

The charged price is the list price plus the hub's markup when this hub takes payments. It is the list price when it does not. A call made with a workspace's own key for that vendor is not charged for the model.

served says whether this hub holds its own key for the vendor. A vendor the hub does not serve still works with a workspace's own key. Every price names the page it was read from and the date it was read.

Responses

listLlmModels responses
StatusDescriptionBody
200

The catalogue.

LlmCatalogue
401

Missing or invalid credentials.

Problemapplication/problem+json

POST /v1/llm/messages

One AI model call for a MouseMouse agent

createLlmMessage · scope key:train

Sends one turn of an agent's conversation to a catalogue model and returns the model's answer. This serves MouseMouse's own agents only: the desktop app, the CLI and the hub's web agent. It is not a general model API, and the terms of use say so.

A request names its client in X-MouseMouse-Client and carries the agent's tool definitions. A request without both is 403 (llm.internal_only). Calls are limited per credential per minute.

Messages use MouseMouse's message format: text, images, tool calls and tool results as content blocks. The hub rebuilds every block from the fields the format documents, and refuses any other field with 422. Images are base64 PNG, JPEG, GIF or WebP only, at most 5 MiB and 8000 pixels a side. No URL or file reference is passed to a vendor, and the hub sets its own prompt caching. The hub translates the blocks for the model's vendor and translates the answer back. With stream: true the answer is server-sent events: message_start, then content_block_start, content_block_delta and content_block_stop for each block, then message_stop carrying the whole message and its cost, or error.

Every call is billed to a workspace, yours by default. With the workspace's own key for the vendor the model costs nothing here. Without one, the hub's key answers and the call counts toward the plan. Before the call its most possible cost is held. After it the cost is settled on the vendor's reported usage. The hold counts each image by the vendor's own rule, text at one token per byte, and the full max_tokens. A call the vendor bills past its hold is charged in full. Until that excess fits the workspace's balance, the credential's next call is 402 (llm.overshoot_unsettled). A usage field the hub cannot price bills the whole hold. 402 also means there is no key the hub may use, or the workspace's limit or the key's cap would be passed. A vendor that keeps refusing or failing after the retries is 502 or 503, naming the vendor.

Parameters

createLlmMessage parameters
NameInTypeDescription
X-MouseMouse-Clientrequiredheaderstring

length ≤ 64

The MouseMouse client making the call and its version, such as mousemouse-ide/0.1.0, mousemouse-cli/0.4.2 or mousemouse-web/1.

Request body

application/json · required · LlmMessageCreate

createLlmMessage request body
FieldTypeDescription
modelrequiredstring

length ≤ 128

A catalogue id, such as openai/gpt-6.1-sol. A bare Anthropic id also works.

systemstring

length ≤ 400000

messagesrequiredarray of object

items 1–4000

The conversation, oldest first. Each item is {role: user | assistant, content}. content is a string or a list of blocks: text, image, tool_use, tool_result, thinking, redacted_thinking and vendor_state. Send back every block a previous answer returned, unchanged.

toolsrequiredarray of LlmTool

items 1–256

max_tokensinteger | null

≥ 1 · ≤ 1000000

The most output tokens. Capped at the model's own limit.

streamboolean

default false

ownerHandle | null

The workspace the call is billed to: your own (the default) or an organization you belong to.

Responses

createLlmMessage responses
StatusDescriptionBody
200

The model's answer. With stream: true this is text/event-stream, and the last message_stop event carries the same object.

LlmMessage
401

Missing or invalid credentials.

Problemapplication/problem+json
402

No key the hub may use for this vendor, or the call would pass a limit: the workspace's own key's monthly cap, or the workspace's balance. type and errors[].type say which: model_key_required, model_cap_reached, billing.cap_reached or llm.overshoot_unsettled. settings_url is where a person fixes it. Nothing was spent.

Problemapplication/problem+json
403

Authenticated but not allowed (visibility, membership or scope).

Problemapplication/problem+json
422

Request failed validation.

Problemapplication/problem+json
502

The model's vendor failed the call after the hub's retries, or did not answer in time. The detail names the vendor.

Problemapplication/problem+json
503

A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

Problemapplication/problem+json
504

The model's vendor failed the call after the hub's retries, or did not answer in time. The detail names the vendor.

Problemapplication/problem+json

Schemas (9)

The schemas these operations reach before any other tag’s do. A type that links elsewhere is rendered on that tag’s page.

LlmCatalogue

object

LlmCatalogue fields
FieldTypeDescription
markup_pctrequirednumber

The percentage the hub adds to a vendor's list price. It applies only where charged is true.

chargedrequiredboolean

True when this hub takes payments, so price includes the markup. False when price equals list_price.

default_modelstring | null

The catalogue id the hub's agent starts on.

vendorsrequiredarray of LlmVendor

LlmMessageCreate

object

LlmMessageCreate fields
FieldTypeDescription
modelrequiredstring

length ≤ 128

A catalogue id, such as openai/gpt-6.1-sol. A bare Anthropic id also works.

systemstring

length ≤ 400000

messagesrequiredarray of object

items 1–4000

The conversation, oldest first. Each item is {role: user | assistant, content}. content is a string or a list of blocks: text, image, tool_use, tool_result, thinking, redacted_thinking and vendor_state. Send back every block a previous answer returned, unchanged.

toolsrequiredarray of LlmTool

items 1–256

max_tokensinteger | null

≥ 1 · ≤ 1000000

The most output tokens. Capped at the model's own limit.

streamboolean

default false

ownerHandle | null

The workspace the call is billed to: your own (the default) or an organization you belong to.

LlmMessage

object

LlmMessage fields
FieldTypeDescription
idrequiredstring

The call's id, llm_….

modelrequiredstring
vendorrequiredLlmVendorId
vendor_modelstring | null

The model the vendor reports it ran.

contentrequiredarray of object

The answer's blocks, in MouseMouse's message format.

stop_reasonrequiredstring

one of end_turn · tool_use · max_tokens · refusal

usagerequiredLlmUsage
costrequiredLlmCost

LlmVendor

object

LlmVendor fields
FieldTypeDescription
idrequiredLlmVendorId
namerequiredstring
servedrequiredboolean

Whether this hub holds its own key for the vendor.

keys_urlstring | null

Where a person makes a key for this vendor.

terms_urlstring | null

The vendor's commercial terms.

modelsrequiredarray of LlmModel

LlmTool

object

LlmTool fields
FieldTypeDescription
namerequiredstring

pattern ^[A-Za-z0-9_-]{1,64}$

descriptionstring

length ≤ 4000

input_schemaobject

The tool's arguments, as a JSON Schema object.

LlmUsage

object

LlmUsage fields
FieldTypeDescription
input_tokensrequiredinteger

Input tokens read at the full price.

output_tokensrequiredinteger

Output tokens, the model's reasoning included.

cache_read_tokensrequiredinteger
cache_write_tokensrequiredinteger

LlmCost

object

LlmCost fields
FieldTypeDescription
list_usdrequirednumber

The call at the vendor's list price.

charged_usdrequirednumber

What the workspace was charged. Zero on its own key.

reserved_usdrequirednumber

What was held before the call.

billed_torequiredstring

one of hub · workspace

workspace: the workspace's own key paid. hub: the hub's key, billed to the plan.

markup_pctrequirednumber

LlmModel

object

LlmModel fields
FieldTypeDescription
idrequiredstring

The catalogue's id, the vendor and the vendor's model id joined by a slash. Pass it as model where a model is chosen.

vendorrequiredLlmVendorId
modelrequiredstring

The model id exactly as the vendor names it.

namerequiredstring

The model's display name.

context_windowrequiredinteger

The most tokens one call may read, input and output together.

max_output_tokensinteger | null
toolsrequiredboolean

Whether the model calls tools.

visionrequiredboolean

Whether the model reads images.

cachingrequiredstring

one of explicit · automatic · none

How the vendor caches a repeated prompt. explicit caches what the hub marks. automatic caches on the vendor's side with no mark.

list_pricerequiredLlmPrice
pricerequiredLlmPrice
source_urlrequiredstring

The vendor's page the list price was read from.

read_onrequiredstring (date)

When the list price was read.

servedrequiredboolean

Whether this hub holds its own key for the model's vendor.

recommendedboolean

The model the hub's agent starts on.

notestring | null

Why the hub offers this model, in one line.

LlmPrice

object

US dollars per million tokens. A null field means the vendor has no such price for the model.

LlmPrice fields
FieldTypeDescription
inputrequirednumber
outputrequirednumber
cache_readrequirednumber | null

A cached input token, when the vendor caches.

cache_writerequirednumber | null

Writing an input token to the cache, when the vendor bills it apart.