Docs OpenAI-compatible assistant API

OpenAI-compatible assistant API

Mockarty exposes a small, versioned compatibility subset for clients that already
speak the OpenAI threads/runs shape. It projects the same native assistant
sessions and tasks
used by the web UI; it is not a second agent runtime and
does not keep a separate history.

Base URL: http://127.0.0.1:5770/v1 on a local server. Authenticate with an API
token (Authorization: Bearer <token> or X-API-Key). The actor and the
workspace come from the token only — a request body can never set either. If the
token is pinned to a workspace, that workspace wins and the caller’s current
membership is still re-checked on every request.

Projection version: mockarty-openai-compat/v1.

Endpoints

Endpoint Method Purpose
/v1/threads POST Create a thread, or replay an existing one by id
/v1/threads/{threadId} GET Read the thread and its messages
/v1/threads/{threadId}/messages POST Append a message (role, content)
/v1/threads/{threadId}/runs POST Start a run (id, input)
/v1/threads/{threadId}/runs/{runId} GET Read the exact durable run result
/v1/threads/{threadId}/runs/{runId}/cancel POST Durably cancel the run
/v1/threads/{threadId}/runs/{runId}/events GET SSE snapshot and live updates

Accepted request fields are closed: thread {id?}, message
{role: "user"|"assistant", content}, run {id, input}. Any other field returns
400 — a body-supplied actor, namespace or model is never silently ignored.

A run id is the reconnect identity. Posting the same id with the same input
returns the same run (replayed: true); reusing it with different input returns
409. Reconnecting to the result or event stream never creates or resumes a
run. A thread or run outside the caller’s user/workspace scope is a uniform
404.

Run result

A run object carries its compatibility id, the native row id as native_id,
status, stop_reason, result, token counts and projectionVersion. steps
report tool activity (tool name, timing, status) but never tool arguments or
tool results, so a compatibility client cannot read private tool payloads.

GET .../events returns text/event-stream:

  • run.snapshot — the durable row and every persisted step already recorded;
  • run.step — a new step;
  • run.updated — a status/progress change;
  • run.completed — the terminal frame, followed by close;
  • run.unavailable — the durable row could not be re-read; the stream closes.

Example

TOKEN="$MOCKARTY_API_KEY"
curl -s -X POST http://localhost:5770/v1/threads \
  -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"id":"thread-demo"}'

curl -s -X POST http://localhost:5770/v1/threads/thread-demo/runs \
  -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{"id":"run-1","input":"How many mocks exist? Reply with the number."}'

curl -s http://localhost:5770/v1/threads/thread-demo/runs/run-1 \
  -H "Authorization: Bearer $TOKEN"

Errors and limits

400 unknown/malformed fields, oversized input or content; 401
authentication required; 403 the workspace is not accessible to this caller;
404 foreign/absent thread or run; 409 a run id reused with different input,
or a cancellation that cannot be applied; 503 namespace authority or the
native task executor is unavailable. Request bodies are capped at 1 MiB, input
at 50,000 characters, message content at 100,000 characters, and at most 200
messages are returned by a thread read.

This is a deliberately small subset, not full OpenAI API parity. Resources,
prompts, model selection on the request and SDK wrappers are not provided; use
the HTTP endpoints above. See A2A protocol
for the agent-to-agent surface.