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.
Sub-millisecond
Instant responses for rapid development
100% Free
No API costs for testing
Drop-in
Change one line, no other code changes
flash_onQuick Start
Get your first mock response in under 2 minutes:
Get your API key
Sign up at mockllm.io/signup and generate an API key from your dashboard.
Make your first request
Replace your OpenAI base URL with MockLLM:
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)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.
Keep your API key secure
Never expose your API key in client-side code or public repositories.
Header Format
Authorization: Bearer YOUR_API_KEY
Getting an API Key
- Sign up for a free account at mockllm.io
- Navigate to your Dashboard
- Go to Settings → API Keys
- Click "Generate New Key"
- 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
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.
/v1/chat/completionsRequest Body
| Parameter | Type | Description |
|---|---|---|
| model* | string | Model identifier (e.g., 'gpt-5.3', 'claude-sonnet-4.5') |
| messages* | array | Array of message objects with role and content |
| temperature | float | Sampling temperature (0-2). Default: 0.7 |
| max_tokens | integer | Maximum tokens in response. Default: 100 |
Example Request
{
"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
{
"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.
/fixturesList all fixtures for the authenticated user.
Example Response
{
"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
}/fixturesCreate a new fixture (legacy endpoint - use dashboard for new fixtures).
Request Body
| Parameter | Type | Description |
|---|---|---|
| pattern* | object | Pattern to match (e.g., {"model": "gpt-5.3"}) |
| response* | object | Response object to return when pattern matches |
/fixtures/{id}Delete a fixture (legacy endpoint - use dashboard for deletion).
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| id* | string | Unique identifier of the fixture to delete |
analyticsAnalytics
Track your API usage with detailed analytics endpoints.
/analytics/usageGet usage analytics with date range filtering.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| start_date | string | ISO format date (e.g., '2024-01-01') |
| end_date | string | ISO format date (e.g., '2024-01-31') |
| granularity | string | "day" or "hour". Default: "day" |
Example Response
{
"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
}/analytics/summaryGet summary statistics for dashboard display.
Response Fields
| Parameter | Type | Description |
|---|---|---|
| total_calls_this_month | integer | Total API calls this month |
| total_calls_today | integer | Total API calls today |
| avg_response_time_ms | float | Average response time in milliseconds |
| most_used_model | string | Most frequently used model |
| calls_by_endpoint | object | Breakdown of calls by endpoint |
Example Response
{
"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
/healthCheck API health and PocketBase connectivity. No authentication required.
Example Response
{
"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
pip install openai
Basic Usage
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
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
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
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 -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 https://api.mockllm.io/fixtures \ -H "Authorization: Bearer YOUR_API_KEY"
Health Check
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 createdinvoice.payment_failedPayment failedcustomer.subscription.deletedSubscription canceledcustomer.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.
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request successful |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid request parameters |
| 401 | Unauthorized | Missing API key |
| 403 | Forbidden | Invalid API key |
| 404 | Not Found | Resource not found |
| 429 | Rate Limited | Monthly request limit exceeded |
| 500 | Server Error | Internal server error |
Error Response Format
{
"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:
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
Initial Release
- • OpenAI-compatible chat completions API
- • Fixture management system
- • Analytics and usage tracking
- • Free and Pro pricing tiers
- • Python and JavaScript SDK support
Beta Release
- • Closed beta with select users
- • Core mocking functionality
- • Basic analytics dashboard
Follow us on Twitter for the latest updates and feature announcements.