Fakellm — AI skill for Claude Code
An in-memory, OpenAI/Anthropic-compatible fake LLM API server for tests: scripted replies, virtual clock, request log, fake agent.
How to install Fakellm
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open AkaraChen/fakellm and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Fakellm does
An in-memory, OpenAI/Anthropic-compatible fake LLM API server for tests: scripted replies, virtual clock, request log, fake agent.
Alternatives in AI
- WindsurfAPI — Turn Windsurf / Devin Desktop's 100+ AI models (Claude, GPT, Gemini, DeepSeek, Kimi, GLM, SWE) into OpenAI-, A 3k ★
- Vllm Mlx — High-performance OpenAI and Anthropic compatible LLM inference server for Apple Silicon 1.5k ★
- Free LLM — 79 free LLM API providers & 460+ free models (limits, no-card options) + Free-LLM Router: all of them behind o 1.1k ★
README
fakellm
一个专门给测试用的 LLM API 服务:全内存、不跑模型,启动只要几毫秒。 只复刻协议(请求和响应的格式、SSE 分帧、错误体、状态码),回复来自你写的剧本,或者一个确定性的默认回复。 和 fakes3 之于 S3 是同一个思路。目前实现了三种协议:OpenAI Chat Completions、OpenAI Responses 和 Anthropic Messages(加模型列表、`count_tokens` 和 Embeddings),三者共用同一套剧本、请求日志和虚拟时钟,也能用一条规则回答非标准的 JSON 路径([自定义端点](#自定义端点)),还能扮演 agent 循环里的模型([fake agent](#fake-agent)),也能把真实上游的往返录下来按含义回放([cassette](#cassette上游代理与导入)),或导入 Hugging Face 数据集当夹具,用 Rust 编写。
为什么
调研了九个真实的 agent 和 SDK 项目(见 [docs/research.md](docs/research.md)),没有一家用现成的假服务: paseo 手写了约 5 个 `http.createServer` 假模型,raft 十几个测试文件各自手写假 provider,opencode 自己做了一个进程内的 Chat SSE 假后端。每家都在重复造这个轮子,而且都踩了同样几个坑:
- 启动慢:用真实或本地推理服务做测试,启动和首包延迟以秒计。fakellm 是一个二进制或一个 Rust 库,启动几毫秒,也可以在进程内直接起。
- 时间不好控:延迟用墙钟,abort / steer 的窗口就 flaky;retry 测试要真等 12 秒。fakellm 有服务端虚拟时钟,流式节奏、
created、请求日志时间戳都跟着它走,冻结后一个 chunk 都不会发出,advance一下立刻放行。 - 调用过程不好断言:日志丢字段(想断言
reasoning_effort却发现 mock 没记)。fakellm 记录每个请求的原始 JSON、解析后的结构、请求头和服务端的回复,通过控制面查询。 - 剧本无限重复匹配、旁路请求抢剧本:agent 循环里同一条规则会一直命中(有人在 30 秒里被调用了 1143 次 tool),生成标题的旁路请求会吃掉本该给主流程的回复。剧本支持
times、has_tool_result、last_tool_result、system、no_tools这类有状态条件。
协议与端点
| 协议 | 端点 | 说明 |
|---|---|---|
OpenAI Chat Completions(openai.chat) |
POST /v1/chat/completions |
同步和 SSE,工具调用,n > 1,stream_options.include_usage |
OpenAI Responses(openai.responses) |
POST /v1/responses |
同步和 SSE,工具调用,推理项,previous_response_id;codex 和 ai-sdk 的 openai('...') 默认走这个 |
GET /v1/responses/{id}、DELETE /v1/responses/{id} |
读取、删除保存的响应对象,见 Responses 的状态 | |
Anthropic Messages(anthropic.messages) |
POST /v1/messages |
同步和 SSE,tool_use、thinking(含 signature),anthropic-beta 头只记录不校验 |
POST /v1/messages/count_tokens |
返回 {"input_tokens": n},不消耗剧本 |
|
OpenAI Embeddings(openai.embeddings) |
POST /v1/embeddings |
确定性向量,float / base64,见 Embeddings;剧本里只有带 error 的规则对它生效 |
自定义端点(custom) |
任意 POST ,由带 match.path 和 reply.body 的规则 |
Related Skills
Use Crew Gateway
Route an OpenAI/Anthropic-compatible client through the portable farmd control plane's virtual crew model, for
Use Rota Gateway
Configure any OpenAI- or Anthropic-compatible client to route through the farm gateway's virtual rota model
Forum
Python CLI and library that splits a request across AI agents, runs the tasks on any model (Ollama, OpenAI-com
Flux OS
Send every LLM request to the cheapest model that can handle it. Drop-in OpenAI + Anthropic compatible router
Routsi
OpenAI-compatible endpoint that dynamically routes each request to the right API model or agent (Devin, Codex,
ThinkWatch Lite
Menu-bar app for a local AI API gateway. See what Claude Code, Codex and other OpenAI/Anthropic clients cost,
Related Agents
Grok Agent 01
ONLY job: find free or freemium AI token/API plans (OpenAI-compatible, Anthropic, Google, open routers, studen
AI Recon
Delegates to this agent when the user wants to map the AI attack surface of an authorized web application befo
AI LLM Engineer
Use this agent when the user types /ai or asks for ai/llm engineer work — e.g., build a RAG pipeline over our