All templates

AI

Mock the OpenAI API

Chat completions and embeddings that cost nothing and answer instantly.

4 routes · live immediately · no account needed

Every test run against a real LLM API costs tokens and takes seconds. These routes return the same chat.completion and embedding envelopes with the same usage accounting, so the code around your model calls — parsing, retries, streaming fallbacks, error handling — can be developed and tested for free. A conditional route returns a 429 when you ask for it, which is the case most retry logic is never actually tested against.

What you get

POST/v1/chat/completionstemplated200 OK
POST/v1/chat/completionsconditional429 Too Many Requests
POST/v1/embeddingstemplated200 OK
GET/v1/models200 OK

Response template

POST /v1/chat/completions

Values in double braces are rendered per request.

{
  "id": "chatcmpl-{{ uuid4() }}",
  "object": "chat.completion",
  "created": "{{ random_int(1700000000, 1760000000) }}",
  "model": "{{ request.body.model }}",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This is a mocked completion from MockBase."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 12,
    "total_tokens": 31
  }
}

Good for

  • Develop against an LLM API without spending tokens on every reload
  • Test rate-limit and retry handling deterministically
  • Keep CI fast and offline, with no API key in the pipeline

Response payloads are representative examples using this API's real field names and object shapes, not an exhaustive replica of its schema. MockBase is an independent tool and is not affiliated with, endorsed by, or sponsored by OpenAI.