Cursor Custom API Endpoint Setup: Protect Code, Keys, and Tool Actions Cursor / Cline 自定义 API 端点:保护代码、密钥与工具动作
A coding assistant may send source code, context and tool requests through the configured endpoint. Verify the operator, data path and capabilities before trusting it with a repository.
编程助手可能通过已配置端点发送源码、上下文与工具请求。在让它接触代码库前,应验证运营者、数据路径与能力。
TL;DR
Source, prompts, paths, errors and tool arguments may leave the machine.
Use separate credentials with limited models, lifetime and budget.
Verify streams, context, tools, errors and rate limits in the actual client.
Keep a known-good config and revoke compromised keys.
源码、提示词、路径、错误与工具参数可能离开本机。
使用限制模型、生命周期与预算的独立凭证。
在真实客户端验证流、上下文、工具、错误与限流。
保留已知可用配置,并撤销泄露密钥。
What the coding assistant sends 编程助手会发送什么
Depending on enabled features, requests can contain selected code, repository context, terminal output, diagnostics, tool schemas and generated actions. The endpoint and any proxy become part of the repository trust boundary.
根据启用功能,请求可能包含所选代码、仓库上下文、终端输出、诊断、工具结构定义与生成动作。端点与任何代理都会成为代码库信任边界的一部分。
Use an approved HTTPS host, document retention and training terms, redact sensitive files and test capability behavior before enabling tools or broad workspace access.
使用批准 HTTPS 主机地址、记录保留与训练条款、脱敏敏感文件,并在启用工具或广泛 Workspace 访问前测试能力行为。
Setup decisions 设置决策
| Area 领域 | Best fit 最适合 | Verify before choosing 选择前验证 |
|---|---|---|
| Host 主机地址 | Approved HTTPS base URL or trusted gateway. 批准 HTTPS 基础地址(Base URL)或可信网关。 | Validate certificate, redirects, operator and data region. 验证证书、重定向、运营者与数据区域。 |
| Credential 凭证 | Dedicated scoped key for the coding client. 面向编程客户端的独立受限密钥。 | Set budget, model allowlist, rotation and revocation. 设置预算、模型 Allowlist、轮换与撤销。 |
| Capabilities 能力 | Context, streams, tools, models and error handling. 上下文、流、工具、模型与错误处理。 | Test the exact client workflow; compatibility claims are insufficient. 测试准确客户端工作流;兼容声明不足。 |
| Data and logs 数据与日志 | Repository context, prompts, outputs and telemetry. 仓库上下文、提示词、输出与遥测。 | Exclude secrets, define retention and redact safe logs. 排除上游密钥、定义保留并脱敏安全日志。 |
Preflight checklist 预检清单
Define allowed projects, file classes and data handling.
Require confirmation, sandboxing and idempotency for actions.
Bound timeouts and retries; surface rate-limit errors clearly.
Version non-secret settings across environments.
定义允许项目、文件类别与数据处理。
为动作要求确认、沙箱与幂等。
限制超时与重试;清晰呈现限流错误。
跨环境版本化非上游密钥设置。
Test before broad workspace access 广泛访问 Workspace 前测试
- Use a disposable repository with representative files and exclusions.
- Test long context, streaming, tool calls, cancellation and rate limits.
- Inspect endpoint logs and confirm sensitive content is redacted or absent.
- Exercise config rollback and key revocation.
- 使用包含代表文件与排除项的一次性仓库。
- 测试长上下文、流、工具调用、取消与限流。
- 检查端点日志,确认敏感内容被脱敏或不存在。
- 演练配置回滚与密钥撤销。
Put a trusted gateway between client and model 在客户端与模型间设置可信网关
The coding client reads a versioned base URL and model alias, then authenticates with a scoped key. A trusted gateway validates identity, policy and allowed capabilities before reaching the compatible model endpoint. Safe logs retain route evidence without repository secrets.
编程客户端读取版本化基础地址(Base URL)与模型别名,并用受限密钥认证;可信网关在到达兼容模型端点前验证身份、策略与允许能力;安全日志保留路由证据但不包含仓库上游密钥。
Production rule: never grant an unverified endpoint broad code and tool access at the same time.
生产规则:绝不能同时向未验证端点授予广泛代码与工具访问。
Separate coding tools from the model endpoint 把编程工具与模型端点分离
QVeris can provide governed external APIs, tools, services and live data. Treat those calls as separate capabilities with scoped credentials and action evidence instead of hiding them inside the model endpoint.
QVeris 可提供治理化外部 API、工具、服务与实时数据。把这些调用视为拥有受限凭证与动作证据的独立能力,而不是隐藏在模型端点内。
Verify the Cursor path before trusting the model picker 在信任模型 Picker 前验证 Cursor 路径
Cursor documents BYOK for standard chat models and an --endpoint flag for Cursor CLI. Treat IDE BYOK, Cursor CLI, Tab Completion, and background agents as different products: a custom endpoint working in one path does not prove it powers the others.
Cursor 文档说明 BYOK 适用于标准 Chat 模型,Cursor CLI 另提供 --endpoint。应把 IDE BYOK、Cursor CLI、Tab Completion 与 Background 智能体视为不同产品;某一路径成功并不能证明其他路径也使用该端点。
# Keep the key out of shell history where your platform supports a secret store.
export CURSOR_API_KEY="<cursor-api-key>"
cursor-agent status
cursor-agent --endpoint "https://approved-cursor-endpoint.example" "Return exactly CURSOR_ENDPOINT_OK"
# Record the endpoint shown by status, request time, and resulting model path.
- In Cursor Settings > Models, enter the supported provider key and click Verify.
- Confirm which features still use Cursor-hosted models before making compliance claims.
- Test certificate validation, model ID mapping, rate limits, and secret rotation on managed devices.
- 在 Cursor Settings > 模型中输入受支持供应商密钥并点击 Verify。
- 在做合规声明前确认哪些功能仍使用 Cursor 托管模型。
- 在受管设备上测试证书、模型 ID 映射、限流与上游密钥轮换。
Verified implementation reference: Cursor API keys.
实施参考已根据官方资料核验:Cursor API keys。
Production Acceptance Checklist for Cursor custom API endpointCursor 自定义 API 端点生产验收清单
For Cursor / Cline Custom Endpoint, a successful hello-world call proves connectivity only. Production acceptance must prove that the framework contract, model behavior, failures, evidence, and rollback remain predictable under the application’s real workflows.
针对“Cursor / Cline 自定义端点”,Hello World 调用成功只能证明连接。生产验收还必须证明,在应用真实工作流中,框架契约、模型行为、失败处理、证据和回滚都保持可预测。
Version base URL resolution, authentication headers, model identifiers, chat and streaming compatibility, tool behavior, usage reporting, and editor-specific timeouts. Keep environment-specific secrets outside code, use stable internal model aliases, and document which layer owns transformations, retries, fallbacks, and timeout policy.
版本化基础地址解析、认证头、模型标识、聊天与流式兼容、工具行为、用量报告和编辑器专属超时。把环境专属密钥放在代码之外,使用稳定内部模型别名,并记录转换、重试、故障切换和超时策略分别由哪一层负责。
To validate Cursor / Cline Custom Endpoint, cover system and user messages, long context, Unicode, streaming, structured output, tools, refusals, usage, cancellation, and provider errors. Store expected event order and required fields instead of checking text equality alone.
验证“Cursor / Cline 自定义端点”时,覆盖系统与用户消息、长上下文、Unicode、流式、结构化输出、工具、拒绝、用量、取消和供应商错误,保存预期事件顺序与必需字段,而不只比较文本是否相同。
To validate Cursor / Cline Custom Endpoint, test invalid credentials, unknown models, rate limits, slow first token, broken streams, malformed tool arguments, partial output, network loss, duplicate retries, and a provider outage. Confirm errors stay structured and side effects stay bounded.
验证“Cursor / Cline 自定义端点”时,测试无效凭证、未知模型、限流、首 Token 过慢、流中断、工具参数畸形、部分输出、网络丢失、重复重试和供应商中断,确认错误保持结构化且副作用范围受控。
Before rolling out Cursor / Cline Custom Endpoint, start with a reversible workflow, compare completion quality, latency, cost, and trace coverage, then expand by task class. Define rollback signals, preserve the previous configuration, and assign an owner for drift and incident review.
上线“Cursor / Cline 自定义端点”前,先选择可逆工作流,比较完成质量、延迟、成本和追踪覆盖,再按任务类别扩大。定义回滚信号,保留原配置,并明确负责漂移与事故复盘的人员。
FAQ
Only after operator, data handling, host security and logging are approved.
No. Use a dedicated scoped credential with a limited lifetime and budget.
Restore known-good settings, stop tool access and revoke the custom key.
只有运营者、数据处理、主机地址安全与日志获批后才适合。
不应。使用限制生命周期与预算的独立受限凭证。
恢复已知可用设置、停止工具访问并撤销自定义密钥。