Repository navigation
API
Status: Partial
Last Updated: 2026-11-13
Audience: Developers and people who connect apps to a Martlet host
Last verified: 2026-11-13 against 5f40af2d9; token format, key-list limits, bearer validation, scope enforcement and GET /version identity checked. UI flow, sync timing and other endpoint contracts remain unchecked.
Code: src/Martlet.Core/Access/ApiKeys.cs, src/Martlet.Gateway/, src/Martlet.Gateway.Host.Linux/, src/Martlet.Gateway.Persistence/, src/Martlet.HostClient/HostApiKeys.cs, src/Martlet.Desktop/MainWindow.ApiKeys.cs, src/Martlet.Desktop/ApiKeyDialogs.cs, src/Martlet.Mcp.Protocol/, src/Martlet.NodeLinkCheck/ApiRehearsal.cs
The desktop creates and synchronizes API keys. A separate Gateway host executable serves the host API; the desktop itself does not open this API. The host executable is a candidate, not an installed service. See the host executable guide.
Your own computers use paired, signed connections (Martlet network). An external app uses an API key when it connects to a configured Gateway host.
Share › Apps and API keys › Create API key: name the key after the app that uses it, choose what it may do and when it expires (never, 30 days, 90 days or a year). The key is shown once, with your hosts' addresses, their key pins and an example request; copy it into the app's secret settings. Martlet keeps no copy and can't show it again. Revoke sends a revocation to paired hosts; an offline host receives it when it syncs again. Each key row shows its scopes, the computer that made it, its last use on each host, and the first characters of its ID.
A key looks like martlet_<22-character ID>.<43-character secret>. The fixed
martlet_ prefix lets secret scanners spot a leaked key.
| What | Value |
|---|---|
| Address | The HTTPS origin shown on Devices; :9443 is the host default |
| Key |
Authorization: Bearer martlet_... on every request; never in a URL |
| Bodies |
Content-Type: application/json (exactly, or with ; charset=utf-8) |
| Role (optional) |
X-Martlet-Role: voice, perception or memory filters role-scoped capabilities and status, and selects the role for cancel requests; the default is voice
|
| Errors | JSON {code, summary, remedy, trace_id} with a 4xx/5xx status |
Pin the SHA-256 fingerprint of the host certificate's public key (SPKI). Gateway renewal keeps the same key; do not assume a fixed renewal interval. The create dialog shows each host's pin in curl's form:
curl -k --pinnedpubkey "sha256//<pin>" \
-H "Authorization: Bearer $MARTLET_API_KEY" \
https://192.168.1.20:9443/martlet/v1/version-k disables normal certificate validation. --pinnedpubkey still rejects a
different public key, but does not check the certificate name or validity.
Prefer a client that supports public-key pinning without disabling those checks.
GET /martlet/v1/version answers any valid key with the host, its Martlet
version and the key's own api_key (id, name, scopes, expires_at),
so an app can check its key.
| Scope (in the dialog) | Endpoints |
|---|---|
| any key |
GET /martlet/v1/version, GET /martlet/v1/capabilities
|
read (See status and logs) |
GET /martlet/v1/status, GET /martlet/v1/machine (hardware), GET /martlet/v1/cluster (who does what), GET /martlet/v1/logs?after=N[&limit=L], GET /martlet/v1/commands, GET /martlet/v1/commands/{id}
|
voice (Use thinking, listening, speaking and lip-sync) |
POST to each route returned by capabilities whose required_role is voice, and POST /martlet/v1/inference/cancel for its own requests |
perception (Use screen understanding) |
POST to each perception route returned by capabilities, and POST /martlet/v1/inference/cancel for its own requests |
openai (Use your hosts' language models) |
GET /v1/models, GET /v1/models/{id}, POST /v1/chat/completions, /v1/completions and /v1/embeddings: the OpenAI-compatible endpoint, on the models the hosts run themselves. With equal-priority too, its requests rank with your own background work instead of below all of your work |
manage (Update hosts and change their roles) |
POST /martlet/v1/commands (martlet.update, host.status, host.describe-role, host.add-role, host.remove-role, host.exposure), POST /martlet/v1/commands/{id}/cancel, and reading commands |
A key can never pair devices, read or change your Martlet network, read
the voice list (it holds voiceprints), change who does what, upload logs, take
a host's commands as its agent, or read or change API keys; those answer
key.scope (403). The gateway contract
lists each request body and bound. The key scope controls access; the role
header does not add permission.
| Code | Status | Meaning |
|---|---|---|
auth.missing |
401 | No key (or signed request) |
key.invalid |
401 | Unknown key or wrong secret, or the host hasn't heard of the key yet |
key.revoked / key.expired
|
401 | Revoked or past its expiry |
key.scope |
403 | The key doesn't allow this request |
Engine routes take the host's exact route identity, so a reply always comes from the model the host advertises:
-
GET /martlet/v1/capabilitiesand pick the route (for exampleroute_idmartlet.gateway.ollama-chat.v1). -
POSTto itspathwith itsroute_id,contract_id,contract_version,destination_id,worker_id,adapter_version,model_id,model_revision,model_sha256andartifact_identity_sha256copied in, plusprotocol_version{"major":2,"minor":0}, freshsession_id,turn_idandrequest_id(UUIDs),epoch0, adeadline_utcwithin the route'smaximum_duration_milliseconds, and the route'spayload. For a chat:{"input": "...", "temperature": 0.7, "maximum_output_tokens": 256, "maximum_context_tokens": 4096}(optionalsystemand up to 16historymessages{role, text},thinkfalseto answer without thinking first, andcontext_tokens, the context window the host's Ollama loads: larger thanmaximum_output_tokensand not larger thanmaximum_context_tokens, elserequest.invalid; a chat takes up to 15 minutes (a Deep thinking think, which has no time limit of its own, asks for all of it), 32,768 output tokens and 32,768 context tokens, so long thinking fits). For transcription:{"sample_rate": 16000, "pcm_base64": "..."}(mono 16-bit, at most 30 s). - Read the
application/x-ndjsonreply:started,text_deltaevents withtext(or audio/face frames), thencompleted,failed(withcode) orcanceled.
The route's maximum_concurrency is in capabilities. Most routes allow one
request at a time. A Deep thinking route can allow up to four. When all slots
are in use, another request gets job.busy. API-key and paired-device requests
share these slots.
curl -k --pinnedpubkey "sha256//<pin>" -H "Authorization: Bearer $MARTLET_API_KEY" \
-H "Content-Type: application/json" -d '{"kind":"martlet.update","arguments":{"version":"<release-version>"}}' \
https://192.168.1.20:9443/martlet/v1/commandsReplace <release-version> with a release available to that host. The answer
(202) holds the command's id; follow it with
GET /martlet/v1/commands/{id}. It runs once Martlet runs on that host, as
commands between your computers
describe; requested_by shows api-key-<key ID>.
Keys belong to your Martlet network, like the shared who does what:
- Each desktop keeps the list in
api-keys.jsonin Martlet's data folder; each host keeps it inapi-keys.jsonbesidehost.json(0600, service owner). It holds names, scopes, expiry, who made each key and the SHA-256 of each secret; never a usable key. - Every 30 seconds while Martlet runs (and right after you make or revoke a key, or pair a host) each desktop merges its copy with every paired host and gives each host whose copy differs the merged list. A key works on a host a moment after it reaches it; a host that was off gets it on its next sync.
- One entry per key, newest stamp wins, except that a revoked key always wins: an older copy can never bring it back. Revoking also stops a reply the key is streaming on a host that already heard about it.
- Only paired computers read or change the list (
GET/POST /martlet/v1/api-keys, signed). Each host reports when each key was last used there since it started. - At most 32 non-revoked keys and 64 entries total. Expired keys still count toward the 32-key limit. Update hosts to a version with API-key support.
- Keys are bearer secrets: whoever has one can use it until you revoke it. Give each app its own key with only the scopes it needs, and an expiry if it is temporary.
- The Gateway accepts loopback or private-IP origins, not public addresses. To reach a private host from outside your home, use a VPN. Do not forward the port to the internet.
- The engines a
voicekey uses run on your hosts, but what the app sends them (text, audio) is processed there and shows in the host's logs only as activity, never content. - Your own computers keep using signed requests (HMAC with nonce and clock window over a pinned connection); keys add no way into pairing, the network or other computers.
| Option | Verdict |
|---|---|
| Scoped API keys (bearer, over TLS with a pinned host key) | Chosen: HTTP clients and scripts can send a header; keys are revocable per app; hosts store verifiers, not usable secrets |
| Martlet's signed requests (HMAC, what your computers use) | Kept for your computers; too much code for most integrations (canonical request, nonce, clock) |
| OAuth 2.0 | Needs an authorization server and token refresh in every app; no benefit for keys you hand out yourself |
| Client certificates (mutual TLS) | Strong, but few integrations can install one, and rotating or revoking them is harder for owners |
| Piece | Location |
|---|---|
| Key list, format and merge rules | src/Martlet.Core/Access/ApiKeys.cs |
| Host routes and bearer checks |
src/Martlet.Gateway/GatewayApiKeys.cs and src/Martlet.Gateway/
|
| Linux host storage |
src/Martlet.Gateway.Host.Linux/ and src/Martlet.Gateway.Persistence/
|
| Desktop client | src/Martlet.HostClient/HostApiKeys.cs |
| Desktop UI and sync |
src/Martlet.Desktop/MainWindow.ApiKeys.cs and src/Martlet.Desktop/ApiKeyDialogs.cs
|
| MCP |
api_keys_status and api_selftest in src/Martlet.Mcp.Protocol/; the local rehearsal is in src/Martlet.NodeLinkCheck/ApiRehearsal.cs. See MCP for tool behavior. |
This evidence predates later Gateway changes. Do not treat it as current
qualification. At that time, api_selftest checked
(two real gateways on 127.0.0.1 with the real Ollama relay route over a
fixture Ollama, NOT AI: keys made and synced through the desktop client, hosts
keeping verifiers only, refusals without a key, with a wrong key and on every
endpoint keys may never use, read, voice and manage scopes, the documented
curl -k --pinnedpubkey request with Windows' own curl (and a wrong pin
refused), a chat through the native route with a bearer key, the same key on a
second host and after its restart, last-used reports, revoking mid-reply, a
stale copy and expiry), and
the desktop's Devices card on a disposable data folder (create with name,
scopes and expiry; the key shown once and never returned to MCP; revoke with
confirmation; api_keys_status). NOT RUN: a desktop syncing keys with real
paired hosts (it needs a real pairing secret in Windows Credential Manager),
api-keys.json on a native or Docker Linux host, a real model, Home Assistant
or another real integration, and two physical PCs on a real LAN.
The OpenAI-compatible endpoint over the same keys has its own page:
Share your language models (MCP openai_selftest).
A direct API on the desktop (for example, asking the companion to speak) is not implemented.
Martlet: download · repository · changelog · issues
These pages come from docs/wiki in the repository. To suggest a change, open an issue or a pull request there.
- Home
- Accounts and households
- Accounts and Household
- Android phones and tablets: what it takes, and the plan
- Martlet's API for other apps and scripts
- App Guides
- App Settings and Updates
- App guides: game and app knowledge from the web
- Architecture
- Bounded PCM playback
- Audio dependency inventory and notices
- Avatar guide: Live2D, VRM and speech animation
- V01a explicit microphone capture
- Chatterbox voice engines
- Cleaning up disk space
- One Martlet on all your computers
- Companion controls and behavior requirements
- Components, jobs and placement (design)
- Live conversation
- Creations
- Decision map: which file owns each decision
- Deep research: web search and long research jobs
- The desktop app: updates, notification area, exiting and appearance
- Linux and macOS desktop companion: research, decision and plan
- Developer Guide
- Dia voice engine
- Diagnostics
- Discord
- Architecture and provider contracts
- Discord
- Memory (P03a/P03b/P03c)
- Singing
- Desktop troubleshooting and local support
- Recognizing people by voice, and Parakeet
- Echo cancellation
- ElevenLabs voice: your cloned voice with tones
- F5 worker and reference-voice foundation
- FAQ
- First Steps
- Game state plan: implementation history
- Glossary: one name for each concept
- GPT-SoVITS voice
- Hosted Thinking: cloud models when Thinking can't run on this PC
- Installation and support
- Installing Martlet
- iOS and iPadOS: what it takes, and the plan
- Repository instructions for coding agents
- Repository knowledge base
- Knowledge base maintenance
- GitHub Wiki mirror
- Linux and Mac
- Listening and Voice ID
- Local model apps
- Lorebooks
- macOS: what it takes, and the plan
- Martlet MCP Server
- MCP in Martlet
- MCP: The app's window
- MCP: Apps, home and memory
- MCP: Characters
- MCP: Diagnostics and logs
- MCP: Computers, network and accounts
- MCP: Other
- MCP: Tool permissions
- MCP pages
- MCP: Server and protocol internals
- MCP: Settings
- MCP: Start here
- MCP: Thinking and models
- MCP: Voice and listening
- Memory
- Messaging apps
- Model catalog: sources, conflicts and design
- Motion host role
- Multiple Computers
- Your Martlet network
- OCR host role
- Share your language models: the OpenAI-compatible endpoint
- Packaging
- Perception worker contracts
- Personality and Characters
- Picture making
- Pictures and Creations
- Picture making host role
- Platforms: what each device can do
- Prerequisites: what Martlet bundles, installs for you, or needs from you
- Privacy and Safety
- Reading the text on your screen
- Wiki source
- Recommendation design: ask three questions, plan for three situations
- Recommended setups: one machine to unlimited budget
- Releasing
- Repository Layout
- Research and provenance ledger
- Resource footprints
- Roadmap
- Watch my screen: screen-aware commentary
- Search engine
- Image and audio models: who sees, who hears, who answers
- Setting Up a Host
- Setup, Windows credentials and local audio
- Sharing with Friends
- Singing
- Smart Home
- Smart home and cameras
- Source Projects
- Talking to Martlet
- Telegram and WhatsApp
- The Character
- Thinking
- Tools and MCP
- Troubleshooting
- Martlet desktop UI design
- User stories and target flows
- Voice activity detection
- Validating changes
- Validation and Testing
- Vision
- Voice latency: from you stopping talking to Martlet's voice
- Voice recognition host role
- Multi-engine voice setup and comparison
- Voices
- The welcome wizard
- XTTS-v2 voice engine