npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mock-ollama

v0.1.3

Published

模拟ollama接口,来监控数据

Downloads

34

Readme

mock-ollama

把第三方大模型接口伪装成 Ollama 服务,方便本地插件或脚本继续按 http://localhost:11434 这一套接入。

当前主要用途:

  • 代理 OpenAI 兼容聊天接口
  • 暴露 Ollama 风格的 api/versionapi/tagsapi/show
  • 兼容部分 Anthropic 风格请求
  • 打印请求和响应,便于查看token消耗

安装

全局安装

npm install -g mock-ollama
mock-ollama -h

直接用 npx

npm install mock-ollama
npx mock-ollama -h

本地开发

npm install
npm run dev

快速开始

最常见的是把它指到一个 OpenAI 兼容上游,比如 GLM:

export MOCK_OLLAMA_BASE_URL="open.bigmodel.cn/api/paas/v4"
export MOCK_OLLAMA_API_KEY="your-api-key"
mock-ollama

启动后默认监听:

http://localhost:11434

可以先测2个接口:

curl http://localhost:11434/api/version
curl http://localhost:11434/api/tags

聊天请求示例:

curl -X POST http://localhost:11434/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-4.6",
    "messages": [
      { "role": "user", "content": "你好" }
    ]
  }'

参数

mock-ollama --url <上游地址> --apikey <上游密钥>

常用参数:

  • --host:监听地址,默认 localhost
  • --port:监听端口,默认 11434
  • --url:上游服务地址
  • --apikey:上游服务密钥
  • --provider-preset:额外 provider JSON 配置
  • --quiet:安静模式,只关闭 ObjectDump 日志

环境变量

  • MOCK_OLLAMA_BASE_URL
  • MOCK_OLLAMA_API_KEY
  • MOCK_OLLAMA_PROVIDER_PRESET

示例:

export MOCK_OLLAMA_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
export MOCK_OLLAMA_API_KEY="your-api-key"
export MOCK_OLLAMA_PROVIDER_PRESET='{
  "my-glm": {
    "matchStr": "bigmodel.cn",
    "apiPath": {
      "chat": "/chat/completions",
      "tags": "/models"
    }
  }
}'
mock-ollama

Provider 预设

内置会根据 baseUrl 自动匹配 provider。

当前内置示例:

  • api.anthropic.com
  • api.deepseek.com
  • bigmodel.cn

如果内置不够,就自己传一段 JSON merge 进去:

{
  "my-provider": {
    "matchStr": "example.com",
    "apiPath": {
      "chat": "/chat/completions",
      "tags": "/models"
    }
  }
}

路由接口

  • GET /
  • GET /api/version
  • GET /api/tags
  • POST /api/show
  • POST /chat/completions
  • POST /v1/chat/completions
  • POST /v1/messages

许可证

ISC