Mock LLM API Guide
Create free LLM streaming endpoints that mimic OpenAI, Claude, and other AI providers. Build and test AI features without spending thousands on API calls.
Getting Started
Creating a mock LLM streaming endpoint takes less than 30 seconds. Follow these simple steps:
- 1
Visit the LLM Mock Page
Go to mockapi.dog/llm-mock. A unique 6-character code is automatically generated for your endpoint.
- 2
Choose LLM Provider Profile
Select which provider's response format to emulate:
- • OpenAI - Chat Completions or Responses API format, chosen from the path your SDK calls
- • Anthropic Claude - Messages API streaming format
- • Generic Stream - Provider-agnostic token stream
- • Generic JSON - Simple JSON response (no streaming)
- 3
Select Content Mode
Choose how response content is generated:
- • Generated - Auto-generate LLM-like text (Chat, Technical, or Markdown style)
- • Static - Use your provided text exactly as is
- • Hybrid - Your text followed by generated continuation
- 4
Configure Token Generation (Optional)
For Generated or Hybrid modes, set minimum and maximum tokens (10-2000, default 100-300). Generated text length will be randomly between these values. Not needed for Static mode.
- 5
Complete Verification & Save
Complete the Turnstile verification, then click "Save Mock Endpoint". Your endpoint URL is automatically copied!
https://abc123.mockapi.dog/v1/chat/completions
That's it! Start streaming immediately
Your endpoint is ready to use. Replace your OpenAI/Claude baseURL with your mock endpoint and start testing. No authentication or API keys required.
The Cost Problem
Real LLM APIs are expensive. During development, testing, and prototyping, costs can quickly spiral out of control. Here's what you'd pay with real providers:
OpenAI GPT-4
ExpensiveExample: Testing a chatbot with 1000 conversations (avg 500 tokens each) = $20+
Anthropic Claude
CostlyCI/CD Pipeline: Running tests 100 times per day = $300+/month
With MockAPI Dog: $0
Free streaming responses for development and testing. Save thousands during the development phase. Switch to real APIs only when you're ready for production.
Why Use LLM Mock API?
Save Money
Avoid spending thousands of dollars during development. Test your UI, streaming logic, and error handling without burning through API credits.
- No API keys or billing setup required
- Free requests during development
- Perfect for indie developers and startups
Instant Testing
Test streaming responses, UI animations, and error states instantly, without waiting on real model latency or provider rate limits.
- Configurable response speed and tokens
- Test edge cases and error scenarios
- Inspect the requests your app sends, live
Multiple Providers
Test your app with different LLM providers without managing multiple API keys. Switch between OpenAI, Claude, and generic formats effortlessly.
- OpenAI-compatible endpoints
- Anthropic Claude format support
- Generic SSE streaming format
CI/CD Integration
Run automated tests in your CI/CD pipeline without worrying about API costs or rate limits. Test your AI features on every commit.
- No authentication required
- Consistent, predictable responses
- Fast execution for quick feedback
Supported Providers
MockAPI Dog supports streaming formats for popular LLM providers. Simply set your endpoint as the baseURL in your preferred SDK.
OpenAI Format
Compatible with the official OpenAI SDK. One endpoint answers both Chat Completions and the Responses API, streamed or not. Responses report the model as gpt-5.4, and with Chat Completions, stream_options.include_usage adds a final usage chunk.
Anthropic Format
Compatible with the official Anthropic SDK. Emulates the Messages API, streamed or not, with the same event sequence the SDK expects. Responses report the model as claude-sonnet-5.
Generic SSE Format
Standard Server-Sent Events (SSE). Each event carries {"token": "..."} and the stream ends with {"done": true}. Use with any streaming client or build your own custom integration.
- Custom LLM integrations
- Testing EventSource implementations
- Learning streaming protocols
How Requests Reach Your Endpoint
SDKs append their own path to the baseURL. MockAPI Dog removes those suffixes before matching, so set baseURL to exactly the URL you saved.
POST https://xyz789.mockapi.dog/llm/chat/completions → /llm- Generic profiles match the saved path exactly, so call that URL directly.
- LLM endpoints are saved as POST, the method every SDK uses.
Streaming or JSON?
A response streams when the request body has "stream": true. If the body has no stream field, it streams when the Accept header includes text/event-stream. Otherwise you get a single JSON response.
Content Modes
Choose how your mock LLM endpoint generates response content. Each mode offers different control over the streamed text.
Generated
Auto-generate LLM-like text in different styles. Choose from Chat (conversational tone), Technical (programming focused), or Markdown (formatted with lists and code blocks).
Static
Use your exact provided text as the response. The text streams exactly as written without any generation or modification.
Hybrid
Combines your provided text with auto-generated continuation. Your text streams first, followed by generated LLM-like content.
Text Styles for Generated Content
When using Generated or Hybrid modes, you can choose between Chat (conversational), Technical (programming-focused), or Markdown (includes formatting, lists, code blocks) styles.
Token Generation Settings
Fine-tune how your mock LLM endpoint generates and streams tokens to match your testing needs.
Token Count
Set how many tokens to generate, estimated at about 4 characters per token. Useful for testing different response lengths.
Streaming Speed
Text streams in chunks of 5-20 characters. Set a minimum and maximum delay between chunks (10-500ms) and each delay is picked at random in that range. Left blank, it defaults to 30-120ms.
Pro Tip
Test with different speeds to ensure your UI handles both fast and slow streaming gracefully. Real LLM APIs can vary significantly in response time.
Code Examples
Here's how to use your mock LLM endpoint with popular SDKs and libraries.
OpenAI SDK
Replace the baseURL with your mock endpoint. No API key required!
import OpenAI from 'openai'; const openai = new OpenAI({baseURL: 'https://xyz789.mockapi.dog/llm',apiKey: 'dummy-api-key', // Mock endpoint doesn't check API keys }); async function main() { const stream = await openai.chat.completions.create({ model: 'gpt-5.4', messages: [{ role: 'user', content: 'Hello!' }], stream: true, }); for await (const chunk of stream) { const content = chunk.choices[0]?.delta?.content || ''; process.stdout.write(content); } } main();
OpenAI SDK (Responses API)
The same endpoint also answers the Responses API. Read the text from response.output_text.delta events.
import OpenAI from 'openai'; const openai = new OpenAI({baseURL: 'https://xyz789.mockapi.dog/llm',apiKey: 'dummy-api-key', // Mock endpoint doesn't check API keys }); async function main() { const stream = await openai.responses.create({ model: 'gpt-5.4', input: 'Hello!', stream: true, }); for await (const event of stream) { if (event.type === 'response.output_text.delta') { process.stdout.write(event.delta); } } } main();
Anthropic SDK
Use with the Anthropic SDK by setting a custom baseURL.
import Anthropic from '@anthropic-ai/sdk'; const anthropic = new Anthropic({baseURL: 'https://xyz789.mockapi.dog/claude',apiKey: 'dummy-api-key', // Mock endpoint doesn't check API keys }); async function main() { const stream = await anthropic.messages.stream({ model: 'claude-sonnet-5', max_tokens: 1024, messages: [{ role: 'user', content: 'Hello!' }], }); for await (const chunk of stream) { if (chunk.type === 'content_block_delta' && chunk.delta.type === 'text_delta') { process.stdout.write(chunk.delta.text); } } } main();
Generic Fetch (SSE)
Use with vanilla JavaScript/TypeScript for maximum flexibility.
async function streamResponse() {const response = await fetch('https://xyz789.mockapi.dog/llm/stream', {method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ prompt: 'Hello, world!', stream: true, // without this (or Accept: text/event-stream) you get plain JSON }), }); const reader = response.body?.getReader(); const decoder = new TextDecoder(); while (true) { const { done, value } = await reader.read(); if (done) break; const chunk = decoder.decode(value); const lines = chunk.split('\n'); for (const line of lines) { if (line.startsWith('data: ')) { try { const json = JSON.parse(line.slice(6)); if (json.done) return; console.log(json.token); } catch (e) { // Skip invalid JSON } } } } } streamResponse();
It's that simple!
Just replace the baseURL and you're ready to go. Your existing code will work without modifications.
Real-World Use Cases
Chatbot Development
Build and test chatbot UIs without spending on API calls. Test message threading, streaming animations, and error handling.
- Test streaming message animations
- Verify conversation threading
- Debug UI edge cases
Testing & QA
Run automated tests and manual QA without API costs. Test different response scenarios and edge cases consistently.
- Automated E2E tests in CI/CD
- Consistent test data
- Fast test execution
Learning & Tutorials
Learn AI integration without spending money. Perfect for tutorials, courses, and educational content.
- No API key setup for students
- Free practice
- Safe learning environment
MVPs & Demos
Build proof-of-concepts and demos without upfront costs. Show investors and stakeholders your vision before investing in production APIs.
- Quick prototyping
- Investor demos
- Validate ideas cheaply
Advanced Features
Request Inspector
Turn on logging to watch the prompts, headers, and parameters your app sends, live. Authorization and cookie headers are redacted, but other headers such as x-api-key are stored as sent, so use a dummy API key.
Configurable Delays
Add a fixed delay before the response starts and tune the streaming speed, to test loading states and timeout handling.
Error Simulation
Make a percentage of requests fail, or trigger an error on demand with a request header, using status codes such as 401, 429, or 503. Errors are sent as JSON before any streaming starts, so your SDK raises them as API errors.
No Authentication
Mock endpoints don't require API keys or authentication. Perfect for CI/CD pipelines and public demos.
Troubleshooting
Streaming not working
A response streams only when the request body sets "stream": true, or when there is no stream field and the Accept header includes text/event-stream. Otherwise the endpoint returns a single JSON response. Also check that your client reads the response as a stream.
// Make sure to set stream: true
const stream = await openai.chat.completions.create({
stream: true, // This is required!
// ...
});Response too fast/slow
Open the Delays, Streaming Speed and Error Simulation Settings and change the min and max delay on the Streaming Speed tab. Also check the Delays tab for a fixed delay before the response.
SDK compatibility issues
Make sure the endpoint's provider profile matches your SDK (the OpenAI SDK needs the OpenAI profile, the Anthropic SDK needs the Anthropic profile). Set baseURL to the URL you saved and let the SDK add its own path.
CORS errors in browser
Mock endpoints are configured with permissive CORS headers. If you're still getting CORS errors, check your request headers and ensure you're not sending restricted headers.
SDK gets a 404 Not Found
LLM endpoints only answer POST requests to the saved path plus the SDK's own suffix. The 404 body shows the code, resource, and method the server received, so compare those with your saved endpoint.
Requests return 429 Too Many Requests
Each endpoint has a daily call limit. Once it is reached, calls return 429 with the limit and a resetAt time (midnight server time) in the body. Each IP address is also limited to 100 requests per minute across the service.
Tips & Best Practices
Test with different speeds
Real LLM APIs vary in speed. Test your UI with both fast and slow streaming to ensure smooth user experience in all conditions.
Use environment variables
Store your baseURL in environment variables. Switch between mock and production APIs by changing a single variable.
// .env.development
OPENAI_BASE_URL=https://xyz789.mockapi.dog/llm
// .env.production
OPENAI_BASE_URL=https://api.openai.com/v1Test error scenarios
Don't just test happy paths. Use error simulation to test rate limits (429), auth failures (401), and outages (503), and a fixed delay to test timeouts.
LLM Development Workflow
Follow this workflow for efficient AI development:
- Build UI and streaming logic with mock endpoints
- Test thoroughly with different content modes and speeds
- Run automated tests in CI/CD with mock endpoints
- Switch to real API only for final integration testing
- Deploy with production API keys
Validate before production
Before switching to production APIs, validate your implementation with the real provider's API in a staging environment to catch any differences in behavior.
Glossary
LLM (Large Language Model)
AI models like GPT-4 and Claude that generate human-like text responses. Examples: OpenAI's GPT series, Anthropic's Claude, Google's Gemini.
Streaming API
An API that sends data in chunks rather than waiting for the complete response. Allows for real-time display of AI-generated text as it's being created.
Token
The basic unit of text in LLMs. Roughly equivalent to a word or word fragment. LLM pricing is typically based on token count.
SSE (Server-Sent Events)
A technology that allows servers to push data to clients in real-time. Used by LLM APIs to stream responses.
baseURL
The base address for API requests. Replace this with your mock endpoint URL to redirect requests to MockAPI Dog instead of the real provider.
Provider
Companies that offer LLM APIs, such as OpenAI (GPT), Anthropic (Claude), Google (Gemini), etc.
Ready to Start Building?
Create your first mock LLM streaming endpoint in seconds. No signup, no credit card, no hassle. Start building AI features without spending thousands on API calls.