Expand description
Standalone MockAI HTTP API Standalone MockAI HTTP API.
MockAI exists in the codebase but until now was only invoked from the OpenAPI route generator — i.e., a hosted mock with a spec got AI-augmented responses on its existing routes. There was no way to reach MockAI directly without a spec, which made it impossible to prototype an “AI persona” mock or hand-craft a one-off intelligent response without a full OpenAPI document.
This module exposes the engine over HTTP. Same functional contract the internal callers use: a Request goes in (method/path/body/etc) and a Response comes out (status_code/body/headers).
§Endpoints
POST /__mockforge/api/mockai/generate— generate one responseGET /__mockforge/api/mockai/status— config / availability probe
§Auth / cost
MockAI typically calls an LLM provider, so an API key needs to be configured at server start. The endpoint returns 503 with a clear reason if the engine isn’t available — same surface the OpenAPI handler treats absence with.
Structs§
- Generate
Request - JSON body accepted by
POST /__mockforge/api/mockai/generate. - Generate
Response Body - JSON body returned from
POST /__mockforge/api/mockai/generate. - Mock
AiApi State - Cheap-to-clone shared state. Holds the existing MockAI instance built at server startup; the API handler reads through the RwLock so a future hot-reload of the model config (e.g., re-uploading a spec) doesn’t require a router rebuild.
Functions§
- mockai_
api_ router - Build the MockAI standalone API router. Mount under
/__mockforge/api/mockai.