<\!DOCTYPE html> MockLLM — LLM 与 Agent 应用的本地 Mock 服务器 MockLLM — Local Mock Server for LLM & Agent Apps
🚀 v0.1.0 — Open Source

MockLLM

LLM 与 Agent 应用的本地 Mock 服务器。
改一行 baseURL,用毫秒级响应、零 Token 消耗、可控故障注入的方式调试你的 Agent。

A local mock server for LLM & Agent apps.
Change one line of baseURL and debug your Agent with ms-level latency, zero token cost, and controlled fault injection.

terminal
# Install & start mocking in 60 seconds
$ brew install mockllm
$ mockllm init
$ mockllm serve

# Or via npm:
$ npm i -g mockllm
$ mockllm init
$ mockllm serve

# Point your baseURL and you're done:
$ curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4","messages":[{"role":"user","content":"hello"}]}'

# → "Hello! How can I help you today?"
<15ms
P99 响应延迟
P99 response latency
0
Token 消耗 / 零成本
Zero token cost
100%
OpenAI / Claude 协议兼容
OpenAI / Claude compatible
<150MB
常驻内存,无需 GPU
Memory, no GPU needed

可视化、完全离线的 LLM Mock 工作台

A Visual, Fully-Offline LLM Mock Workbench

编辑规则、即时试算匹配、注入故障、录制回放——全部在桌面端离线完成,对外提供 OpenAI 兼容接口。

Edit rules, dry-run the matcher, inject faults, record and replay — all offline on your desktop, exposing an OpenAI-compatible endpoint.

01

规则编辑器

Rule Editor

可视化编辑规则与多轮编排。匹配条件「任一即触发」(OR),支持关键词、完全匹配与正则;单轮为「匹配 → 响应」,开启「多轮」后按步骤推进工具调用。响应可返回文本与工具调用。

Visually edit rules and multi-turn flows. Conditions are OR'd — any hit fires the rule. Match by keyword, exact, or regex. A single rule is match → response; flip on multi-turn to step through tool calls. Responses can carry text and tool calls.

Core
02

试算器

Playground

即时试算匹配。输入用户消息,实时显示命中的规则、逐策略得分与置信度;一键「发送到引擎」用真实配置验证。

Dry-run the matcher instantly. Type a message and see the matched rule, per-strategy scores, and confidence in real time; one click sends it to the engine for a live check.

Core
03

故障注入

Fault Injection

注入 429 / 503 / 超时 / 坏 JSON / 内容过滤等异常,检验 Agent 的错误处理。固定 seed 让故障序列可确定,可直接写入配置在 CI 中复现(高级故障类型为 Pro)。

Inject 429/503/timeouts/bad JSON/content-filter failures to test your agent's error handling. A fixed seed makes the sequence deterministic and committed to config for CI reproduction (advanced types are Pro).

Core
04

实时日志

Live Log

内嵌引擎的实时请求日志。每条请求都显示命中规则与故障信息,可按状态筛选;仅存内存(500 条环形缓冲),不落盘。

A real-time request log from the embedded engine. Every request shows its matched rule and fault info, filterable by status; kept in memory (500-entry ring buffer), nothing persisted.

Core
05

录制回放

Traces

浏览录制的 JSONL 日志,勾选条目一键蒸馏为规则草稿——exact 原句 + 关键词扩展。透明代理转发真实调用并自动脱敏 API Key。

Browse recorded trace JSONL and distill selected exchanges into rule drafts — exact phrases plus keyword expansion. A transparent proxy forwards real calls and auto-redacts API keys.

Core
06

Pro 高级能力集

Pro Advanced Features

无限规则、解锁全部故障注入类型、无限多轮编排步骤、优先技术支持;后续 Pro 专属特性持续更新。

Unlimited rules, all fault-injection types, unlimited multi-turn steps, and priority support — with ongoing Pro-only updates.

Pro

系统架构

System Architecture

四层架构设计,从协议适配到故障注入,提供完整的 LLM 模拟能力。

Four-layer architecture from protocol adaptation to fault injection, providing complete LLM simulation capabilities.

🌐 协议兼容层Protocol Layer

OpenAI /v1/chat/completions 与 /v1/models 适配,SSE 流式输出,任意 API Key 接受

OpenAI /v1/chat/completions and /v1/models adaptation, SSE streaming, any API key accepted

↓

🎯 混合检索匹配层Hybrid Matching Layer

四级级联匹配器 (Exact / Keyword / BM25 / Fuzzy),阈值配置,变量提取,Vector 增强(Pro)

4-level cascade matcher (Exact / Keyword / BM25 / Fuzzy), threshold config, variable extraction, Vector (Pro)

↓

🤖 Function Call 状态机引擎Function Call State Machine

Tool Schema 校验、多步流程定义、会话识别、前序结果引用

Tool Schema validation, multi-step flow definitions, session identification, prior result references

↓

💥 故障注入 & 录制回放引擎Fault Injection & Record/Replay

HTTP 错误/超时注入、录制代理、精确回放、契约蒸馏(Pro)

HTTP error/timeout injection, recording proxy, exact replay, contract distillation (Pro)

声明式 Mock 配置

Declarative Mock Config

Mock-as-Code,用 YAML 定义你的 LLM 模拟规则。

Mock-as-Code: define your LLM simulation rules in YAML.

# .mockspec.yaml — 基础聊天示例
version: "1"
server:
  port: 8080
  models:
    - id: gpt-4
    - id: gpt-3.5-turbo
rules:
  - id: greeting
    match: { any: [{ exact: "hello" }, { exact: "你好" }] }
    respond: { text: "Hello! How can I help you today?" }
  - id: weather
    match: { any: [{ keywords: ["weather","天气"] }] }
    respond: { text: "Today's weather is sunny, 24°C." }
# .mockspec.yaml — 流式响应
version: "1"
server: { port: 8080 }
defaults:
  stream:
    ttft_ms: 100       # 首字延迟 100ms
    tpot_ms: 30        # 字间间隔 30ms
    jitter: 0.2        # 20% 抖动
rules:
  - id: stream-story
    match: { any: [{ keywords: ["story","故事"] }] }
    respond: { text: "Once upon a time, in a digital world..." }
# .mockspec.yaml — 多步状态机
version: "1"
rules:
  - id: get-weather
    match: { any: [{ keywords: ["weather","天气"] }] }
    respond:
      text: ""
      tool_calls:
        - name: get_weather
          arguments: { location: "{{user.location}}", unit: "celsius" }
  - id: email-flow
    match: { any: [{ keywords: ["send email"] }] }
    flows:
      - step: confirm
        respond:
          tool_calls:
            - name: ask_confirmation
              arguments: { message: "Send email to user@example.com?" }
      - step: send
        respond:
          text: "Email sent successfully!"
# .mockspec.yaml — 故障注入
version: "1"
faults:
  - id: rate-limit
    type: http_error
    status_code: 429
    probability: 0.05
    seed: 42
  - id: timeout
    type: hang
    duration_ms: 5000
    probability: 0.1
    seed: 42

专为独立开发者打造

Built for Solo Developers

无需注册、无需 API Key、零遥测、完全离线可用。改一行 baseURL 即刻开始调试。

No registration, no API key, zero telemetry, fully offline. Change one line of baseURL and start debugging.

🧑‍💻 独立开发者Solo Devs

编码阶段快速验证 LLM API 集成逻辑,无需等待真实 API 响应。零成本调试,不打断编码心流。配置文件随项目提交 git,实现 Mock-as-Code。

Rapidly validate LLM API integration during coding without waiting for real API responses. Zero-cost debugging that never breaks your flow. Check configs into git for Mock-as-Code.

⚡ 日均节省 $5-20 API 费用
⚡ Save $5-20/day on API costs

🔧 故障演练Fault Injection

通过配置或命令行注入延迟、HTTP 错误、坏 JSON、字段漂移、安全拒答、超长截断,验证 Agent 的容错分支。真实 API 上无法稳定复现这些情况。

Inject latency, HTTP errors, bad JSON, field drift, content filters, and truncation via config or CLI. These edge cases are impossible to reproduce reliably on real APIs.

💥 确定性序列,可复现于回归测试
💥 Seed-driven deterministic sequences for regression

🎬 录制 → 回放 → 蒸馏Record → Replay → Distill

透明代理真实 API 调用,自动脱敏。精确回放请求。Pro 版一键蒸馏 Trace 为语义匹配规则,解决冷启动时"懒得手写配置"的最大上手阻力。

Transparent proxy for real API calls with auto-redaction. Exact replay by content hash. Pro edition distills traces into matching rules — solving the cold-start friction of "I don't want to write configs."

🎯 冷启动到 Mock 规则生成只需一条命令
🎯 One command from cold start to mock rules

开发者友好的定价

Developer-Friendly Pricing

免费版足够日常使用。Pro 一次性买断,无需订阅。无需注册,无需信用卡。

Free edition covers daily needs. Pro is a one-time purchase — no subscription required. No sign-up, no credit card needed.

Free
独立开发者 & 开源项目
Solo devs & open source
$0
永久免费,无需注册
Free forever, no sign-up
  • 无限 Mock 请求,无并发限制
  • Unlimited requests, no concurrency limit
  • OpenAI 协议兼容 & SSE 流式
  • OpenAI protocol & SSE streaming
  • 精确 & 关键词匹配
  • Exact & keyword matching
  • 基础故障注入(429 / 503 / 超时)
  • Basic fault injection (429 / 503 / timeout)
  • 规则上限 50 条
  • 50-rule limit
开始使用Get Started
Cloud
托管 endpoint,即将推出
Managed endpoint, coming soon
$12 / 月/mo
按需订阅
Pay as you go
  • 全部 Pro 能力
  • Everything in Pro
  • 托管 Mock endpoint
  • Managed mock endpoint
  • 场景库分发
  • Scenario library distribution
  • 跨设备配置同步
  • Cross-device config sync
了解详情Learn More

来自开发者的声音

What Developers Say

MockLLM 正在帮助全球独立开发者加速 LLM 应用开发。

MockLLM is helping solo developers around the world accelerate LLM app development.

★★★★★

"改一行 baseURL 就能用,太爽了。之前用真实的 GPT-4 API 调试 Function Call,每次都要花钱等响应。MockLLM 让我在本地秒级验证,开发效率翻倍。"

"Changed one line of baseURL and it just worked. I used to pay for GPT-4 API debugging Function Calls — now I validate locally in milliseconds. 2x dev speed."

🧑‍💻
Alex Chen
独立开发者 · Agent 构建工具
Solo Dev · Agent Building Tools
★★★★★

"故障注入能力是刚需!真实 API 上几乎不可能复现 429 和超时,MockLLM 的确定性 seed 让我能写测试覆盖所有异常分支。"

"Fault injection is a must-have! Reproducing 429s and timeouts on real APIs is nearly impossible. Deterministic seeds let me cover every error branch in tests."

👩‍💻
Sarah Kim
全栈工程师 · AI 测试基础设施
Full-Stack Engineer · AI Test Infra
★★★★★

"Mock-as-Code 的理念太对了。配置文件直接提交 git,CI 里跑 Mock 测试,再也不依赖外部 API。零遥测、完全离线,这才是开发者该用的工具。"

"Mock-as-Code is the right philosophy. Configs in git, CI runs against mock, no external API dependency. Zero telemetry, fully offline — this is how dev tools should be."

🧑‍💻
Marcus Rivera
开源贡献者 · LLM 工具链
Open Source Contributor · LLM Tooling
2.8k+ GitHub StarsGitHub Stars
500+ 日活跃开发者Daily Active Devs
99% 满意率Satisfaction Rate
100% 开源Open Source

改一行 baseURL,开始调试

Change One Line of baseURL, Start Debugging

无需注册、无需 API Key、零遥测。安装即用,完全离线可用。

No registration, no API key, zero telemetry. Install and go — fully offline capable.