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

cursor-agent-api-proxy

v1.5.2

Published

Use your Cursor subscription with any OpenAI-compatible client. Wraps Cursor CLI (agent) as an OpenAI-compatible API server.

Readme

cursor-agent-api-proxy

npm version npm downloads license

English

Cursor CLI 的 OpenAI 兼容 API 代理。让任何 OpenAI 兼容客户端直接使用你的 Cursor 订阅。

前置条件

  • Node.js 20+
  • 有效的 Cursor 订阅(Pro / Business)

安装

1. 安装 Cursor CLI 并登录:

# macOS / Linux
curl https://cursor.com/install -fsS | bash

# Windows PowerShell
irm 'https://cursor.com/install?win32=true' | iex
agent login          # 打开浏览器,用 Cursor 账号登录
agent --list-models  # 确认 CLI 可用

无头环境? 跳过 agent login,到 cursor.com/settings 生成 API Key,然后 export CURSOR_API_KEY=<key>

2. 安装并启动代理:

npm install -g cursor-agent-api-proxy
cursor-agent-api          # 后台启动,默认 http://localhost:4646
cursor-agent-api status   # 查看运行状态

3. 验证:

curl http://localhost:4646/health

其他命令:

cursor-agent-api stop           # 停止
cursor-agent-api restart        # 重启
cursor-agent-api start 8080     # 指定端口启动
cursor-agent-api run            # 前台运行(调试用)

日志:~/.cursor-agent-api/server.log

配合 OpenClaw 使用

首次安装(onboard 向导)

如果还没装过 OpenClaw,运行引导向导:

openclaw onboard

向导进行到 Model/Auth 步骤时:

  1. Provider 类型 → 选 Custom Provider(OpenAI-compatible)
  2. Base URL → http://localhost:4646/v1
  3. API Key → 输入 not-needed(已 agent login 就不需要 key)
  4. Default model → auto(或 agent --list-models 中的任意模型)

已有配置(编辑配置文件)

OpenClaw 已经在用了?直接改配置文件:

{
  env: {
    // "not-needed" = 已通过 agent login 登录,不需要 key
    // 或填你的 Cursor API Key,代理会按请求转发
    OPENAI_API_KEY: "not-needed",
    OPENAI_BASE_URL: "http://localhost:4646/v1",
  },
  agents: {
    defaults: {
      model: { primary: "openai/auto" },
    },
  },
}

模型

模型 ID 和 agent --list-models 输出一致,直接填:

auto                  # 自动选择
gpt-5.2               # GPT-5.2
gpt-5.3-codex         # GPT-5.3 Codex
opus-4.6-thinking     # Claude Opus 4.6 (thinking)
sonnet-4.5-thinking   # Claude Sonnet 4.5 (thinking)
gemini-3-pro          # Gemini 3 Pro

完整列表:curl http://localhost:4646/v1/modelsagent --list-models

API

| 端点 | 方法 | 说明 | |------|------|------| | /health | GET | 健康检查 | | /v1/models | GET | 模型列表 | | /v1/chat/completions | POST | 聊天补全(支持 stream: true) |

配置

| 环境变量 | 默认值 | 说明 | |---------|--------|------| | PORT | 4646 | 监听端口(或 cursor-agent-api start 8080) | | CURSOR_API_KEY | - | agent login 的替代方案 |

开机自启

开机自动启动代理:

cursor-agent-api install    # 注册为系统服务
cursor-agent-api uninstall  # 移除
  • macOS → LaunchAgent
  • Windows → Task Scheduler
  • Linux → systemd user service

其他客户端

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:4646/v1",
    api_key="not-needed",
)

resp = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
{
  "models": [{
    "title": "Cursor",
    "provider": "openai",
    "model": "auto",
    "apiBase": "http://localhost:4646/v1",
    "apiKey": "not-needed"
  }]
}
curl -X POST http://localhost:4646/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"auto","messages":[{"role":"user","content":"Hello!"}]}'

原理

客户端  →  POST /v1/chat/completions (OpenAI 格式)
        →  cursor-agent-api-proxy
        →  spawn agent CLI (stream-json)
        →  Cursor 订阅
        →  AI 响应 → OpenAI 格式 → 客户端

参与开发

git clone https://github.com/tageecc/cursor-agent-api-proxy.git
cd cursor-agent-api-proxy
pnpm install && pnpm run build
pnpm start

License

MIT