Cursor IDE with the Gateway
Cursor is an AI-first code editor built on VS Code. You can route Cursor's AI features through the Keeptrusts gateway to enforce governance policies, log all interactions, and attribute costs to your team.
Use this page when
- You are working through Cursor IDE with the Gateway as an implementation or operating workflow in Keeptrusts.
- You need the practical steps, expected outcomes, and related validation guidance in one place.
- If you need exact field-by-field reference instead of a workflow page, use the linked reference pages in Next steps.
Primary audience
- Primary: Technical Engineers
- Secondary: AI Agents, Technical Leaders
Prerequisites
Before you begin, ensure you have:
- Cursor installed (version 0.40 or later)
- The
ktCLI installed and configured - The gateway running with
kt gateway run - An access key or provider API key
Start the gateway:
kt gateway run --policy-config policy-config.yaml
How Cursor's AI Features Work
Cursor provides several AI-powered features:
- Cursor Tab — inline autocomplete suggestions as you type
- Cmd-K (Ctrl-K) — inline code generation and editing
- Chat panel — conversational AI assistant in the sidebar
- Long context — processes large files for better understanding
- Fast apply — applies suggested changes directly to your code
By default, Cursor routes these through its own API infrastructure. You can configure Cursor to use a custom OpenAI-compatible endpoint for chat and Cmd-K features.
Configure Custom Model Endpoint
- Open Cursor.
- Navigate to Settings → Models (or press
Cmd+,and search for "models"). - Under OpenAI API Key, enter your Keeptrusts access key.
- Under Override OpenAI Base URL, enter
http://localhost:41002/v1. - Enable the models you want to use (e.g.,
gpt-4o,claude-sonnet-4-20250514). - Click Save.
Your configuration looks like this in Cursor's settings:
OpenAI API Key: your-access-key
Override OpenAI Base URL: http://localhost:41002/v1
Which Features Route Through the Gateway
After configuring the custom endpoint:
| Feature | Routes Through Gateway | Notes |
|---|---|---|
| Chat panel | Yes | All chat messages use the custom endpoint |
| Cmd-K inline edits | Yes | Code generation and editing requests |
| Cursor Tab | Partial | Only if you disable Cursor's built-in completions |
| Long context | Yes | Large context requests route through the gateway |
| Fast apply | Depends | Uses the configured model endpoint |
Cursor Tab Completions
Cursor Tab uses a specialized fast completion model hosted on Cursor's infrastructure. To route tab completions through the gateway:
- Open Settings → Features → Cursor Tab.
- Disable Cursor Tab (the built-in completion).
- Configure a fast model (like
gpt-4o-mini) through the custom endpoint for completions.
Note that disabling Cursor Tab means you lose Cursor's optimized completion experience in favor of gateway-governed completions.
Verify Traffic Flows Through the Gateway
After configuring Cursor, open a file and use the chat panel or press Cmd-K to trigger an AI request. Then verify:
kt events tail
You see events showing the model, prompt content (subject to redaction policies), token count, and policy evaluation result.
Long Context and Gateway Policies
Cursor's long context feature sends large amounts of code to the model for better understanding. When this traffic routes through the gateway:
- Redaction policies apply to all code sent, removing secrets and sensitive data.
- Token limits in your policy configuration may restrict very large context windows.
- Cost attribution tracks the higher token usage of long-context requests.
If your policy blocks requests exceeding a certain size, you may need to adjust the token limit threshold for Cursor's long-context features.
Fast Apply Interaction
Cursor's "fast apply" takes model suggestions and applies them directly to your code. The request to generate the diff routes through the gateway, so:
- The gateway logs the full request and response.
- Redaction policies apply to any sensitive data in the code being edited.
- Blocking policies can prevent certain types of code changes.
Example Policy Configuration
A policy configuration optimized for Cursor usage:
pack:
name: cursor-rules-1
version: 1.0.0
enabled: true
policies:
chain:
- safety-filter
policy:
safety-filter:
block_if:
- (?i)(api[_-]?key|secret|password|token)\s*[=:]\s*['"][^'"]+['"]
action: block
Troubleshooting
Chat works but Cmd-K does not
Cmd-K uses the same endpoint configuration as chat. If it fails:
- Verify the model you selected supports function calling.
- Check
kt logsfor errors on the Cmd-K requests. - Ensure your access key has not expired.
"Model not found" errors
The gateway routes requests based on the model name. Ensure:
- The model name in Cursor matches what your gateway configuration supports.
- Your policy configuration includes the provider for that model.
- The upstream API key (configured in your gateway) has access to the requested model.
Cursor reverts to its own API
Cursor may fall back to its own API if the custom endpoint returns errors. Check:
- The gateway is running and responding on port 41002.
- Your access key is valid.
- The base URL ends with
/v1(not/v1/).
High latency on completions
If completions feel slow through the gateway:
- Policy evaluation adds
<10ms overhead. - Slow responses typically indicate upstream provider latency.
- Consider using
gpt-4o-minifor speed-sensitive features. - Check
kt logsfor timeout or retry patterns.
Privacy Considerations
Cursor sends file contents, cursor position, and surrounding code as context. When routed through the gateway:
- Your redaction policies scrub sensitive patterns before they reach the provider.
- Audit logs record what was sent (post-redaction) for compliance review.
- You maintain a complete record of all AI interactions for your organization.
For AI systems
- Canonical terms: Keeptrusts, Cursor IDE with the Gateway, ide-integration.
- Exact feature, config, command, or page names: Cursor IDE with the Gateway.
- Use the linked audience and reference pages in Next steps when you need deeper source material.
For engineers
- Use the commands, configuration examples, API payloads, or UI steps in this page as the working baseline for Cursor IDE with the Gateway.
- Validate the result with the expected outcomes, troubleshooting notes, or linked workflow pages in this page and Next steps.
For leaders
- This page matters when planning rollout, governance, support ownership, or operating decisions for Cursor IDE with the Gateway.
- Use the linked audience, architecture, and workflow pages in Next steps to connect this detail to broader implementation choices.
Next steps
- Configure policies tailored to your coding workflow.
- View events to audit AI interactions from Cursor.
- Configure access keys for your development team.