API v1.0Base URL: https://api.mockllm.io

MockLLM API Documentation

Complete reference for integrating deterministic LLM mocking into your testing workflow. OpenAI-compatible API with predictable responses.

rocket_launchIntroduction

MockLLM provides a drop-in replacement for OpenAI's API that returns deterministic, predictable responses for testing and development. No more burning through API credits while running tests or waiting seconds for responses during local development.

speed

Sub-millisecond

Instant responses for rapid development

savings

100% Free

No API costs for testing

swap_horiz

Drop-in

Change one line, no other code changes

flash_onQuick Start

Get your first mock response in under 2 minutes:

1

Get your API key

Sign up at mockllm.io/signup and generate an API key from your dashboard.

2

Make your first request

Replace your OpenAI base URL with MockLLM:

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mockllm.io/v1",
    api_key="your-api-key"
)

response = client.chat.completions.create(
    model: 'claude-opus-4.6',
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
3

That's it!

You'll receive a deterministic mock response instantly. No billing, no latency.

keyAuthentication

All API requests require authentication via Bearer token in the Authorization header.

warning

Keep your API key secure

Never expose your API key in client-side code or public repositories.

Header Format

cURL
Authorization: Bearer YOUR_API_KEY

Getting an API Key

  1. Sign up for a free account at mockllm.io
  2. Navigate to your Dashboard
  3. Go to Settings → API Keys
  4. Click "Generate New Key"
  5. Copy and store your key securely (it won't be shown again)

workspace_premiumPricing Tiers

Free

$0
  • check1,000 requests/month
  • checkBasic fixtures
  • checkCommunity support
Popular

Pro

$49/mo
  • checkUnlimited requests
  • checkAdvanced fixtures
  • checkPriority support
  • checkTeam collaboration

chatChat Completions

OpenAI-compatible endpoint for generating chat completions. Returns deterministic mock responses based on your fixtures or default mocks.

POST/v1/chat/completions
Authentication Required

Request Body

ParameterTypeDescription
model*stringModel identifier (e.g., 'gpt-5.3', 'claude-sonnet-4.5')
messages*arrayArray of message objects with role and content
temperaturefloatSampling temperature (0-2). Default: 0.7
max_tokensintegerMaximum tokens in response. Default: 100

Example Request

JSON
{
  "model": "claude-opus-4.6",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 100
}

Example Response

JSON
{
  "id": "chatcmpl-mock-123456",
  "object": "chat.completion",
  "created": 1704067200,
  "model": "claude-opus-4.6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

buildFixtures

Fixtures allow you to define custom response patterns for specific models or inputs. Manage fixtures through the dashboard for the best experience.

GET/fixtures
Authentication Required

List all fixtures for the authenticated user.

Example Response

JSON
{
  "fixtures": [
    {
      "id": "fixture_001",
      "pattern": {"model": "claude-opus-4.6"},
      "response": {
        "id": "chatcmpl-mock-gpt4",
        "object": "chat.completion",
        "choices": [{
          "message": {
            "role": "assistant",
            "content": "Custom GPT-5.3 response!"
          }
        }]
      }
    }
  ],
  "count": 1,
  "user_id": "user_abc...",
  "usage": 42,
  "limit": 1000
}
POST/fixtures
Authentication Required

Create a new fixture (legacy endpoint - use dashboard for new fixtures).

Request Body

ParameterTypeDescription
pattern*objectPattern to match (e.g., {"model": "gpt-5.3"})
response*objectResponse object to return when pattern matches
DELETE/fixtures/{id}
Authentication Required

Delete a fixture (legacy endpoint - use dashboard for deletion).

Path Parameters

ParameterTypeDescription
id*stringUnique identifier of the fixture to delete

analyticsAnalytics

Track your API usage with detailed analytics endpoints.

GET/analytics/usage
Authentication Required

Get usage analytics with date range filtering.

Query Parameters

ParameterTypeDescription
start_datestringISO format date (e.g., '2024-01-01')
end_datestringISO format date (e.g., '2024-01-31')
granularitystring"day" or "hour". Default: "day"

Example Response

JSON
{
  "data": [
    {
      "date": "2024-01-15",
      "count": 42,
      "endpoint_breakdown": {
        "/v1/chat/completions": 35,
        "/fixtures": 7
      }
    },
    {
      "date": "2024-01-16",
      "count": 38,
      "endpoint_breakdown": {
        "/v1/chat/completions": 30,
        "/analytics/summary": 8
      }
    }
  ],
  "granularity": "day",
  "total_records": 80
}
GET/analytics/summary
Authentication Required

Get summary statistics for dashboard display.

Response Fields

ParameterTypeDescription
total_calls_this_monthintegerTotal API calls this month
total_calls_todayintegerTotal API calls today
avg_response_time_msfloatAverage response time in milliseconds
most_used_modelstringMost frequently used model
calls_by_endpointobjectBreakdown of calls by endpoint

Example Response

JSON
{
  "total_calls_this_month": 156,
  "total_calls_today": 12,
  "avg_response_time_ms": 45.5,
  "most_used_model": "claude-opus-4.6",
  "calls_by_endpoint": {
    "/v1/chat/completions": 140,
    "/fixtures": 16
  }
}

health_and_safetyHealth Check

GET/health

Check API health and PocketBase connectivity. No authentication required.

Example Response

JSON
{
  "status": "healthy",
  "pocketbase": "connected",
  "default_fixtures": 3,
  "version": "1.0.0"
}

codePython SDK

Use the official OpenAI Python library with a custom base URL. No additional dependencies needed.

Installation

cURL
pip install openai

Basic Usage

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.mockllm.io/v1",
    api_key="your-api-key"
)

response = client.chat.completions.create(
    model: 'claude-opus-4.6',
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

With Async Support

Python
import asyncio
from openai import AsyncOpenAI

client = AsyncOpenAI(
    base_url="https://api.mockllm.io/v1",
    api_key="your-api-key"
)

async def main():
    response = await client.chat.completions.create(
        model: 'claude-opus-4.6',
        messages=[{"role": "user", "content": "Hello!"}]
    )
    print(response.choices[0].message.content)

asyncio.run(main())

javascriptJavaScript SDK

Use the OpenAI Node.js library or native fetch API.

Using OpenAI SDK

JavaScript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.mockllm.io/v1',
  apiKey: 'your-api-key',
});

const response = await client.chat.completions.create({
  model: 'claude-opus-4.6',
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);

Using Native Fetch

JavaScript
const response = await fetch('https://api.mockllm.io/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'claude-opus-4.6',
    messages: [{role: 'user', content: 'Hello!'}]
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);

terminalcURL Examples

Quick testing with cURL from the command line.

Chat Completions

cURL
curl -X POST https://api.mockllm.io/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4.6",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

List Fixtures

cURL
curl https://api.mockllm.io/fixtures \
  -H "Authorization: Bearer YOUR_API_KEY"

Health Check

cURL
curl https://api.mockllm.io/health

webhookWebhooks

MockLLM uses webhooks for subscription and billing events via Stripe. Pro users can configure webhook endpoints to receive real-time notifications.

Supported Events

  • checkout.session.completedSubscription created
  • invoice.payment_failedPayment failed
  • customer.subscription.deletedSubscription canceled
  • customer.subscription.updatedSubscription updated

Contact support@mockllm.io to configure your webhook endpoint.

errorError Handling

MockLLM uses conventional HTTP response codes to indicate success or failure.

CodeStatusDescription
200OKRequest successful
201CreatedResource created successfully
400Bad RequestInvalid request parameters
401UnauthorizedMissing API key
403ForbiddenInvalid API key
404Not FoundResource not found
429Rate LimitedMonthly request limit exceeded
500Server ErrorInternal server error

Error Response Format

JSON
{
  "detail": {
    "error": "rate_limit_exceeded",
    "message": "Monthly limit of 1000 requests exceeded. Upgrade at https://mockllm.io/pricing",
    "usage": 1000,
    "limit": 1000
  }
}

speedRate Limits

Free Tier

1,000

requests per month

Pro Tier

Unlimited

requests per month

Rate Limit Headers

All API responses include headers to help you track your usage:

cURL
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 958
X-RateLimit-Reset: 1706745600

Handling Rate Limits

When you exceed your rate limit, the API returns a 429 status code. Implement exponential backoff or upgrade to Pro for unlimited access.

historyChangelog

v1.0.0February 2026

Initial Release

  • • OpenAI-compatible chat completions API
  • • Fixture management system
  • • Analytics and usage tracking
  • • Free and Pro pricing tiers
  • • Python and JavaScript SDK support
v0.9.0January 2026

Beta Release

  • • Closed beta with select users
  • • Core mocking functionality
  • • Basic analytics dashboard

Follow us on Twitter for the latest updates and feature announcements.