Skip to main content

Overview

Cursor IDE is an AI-powered code editor that supports OpenAI-compatible API endpoints. You can configure Cursor to use CLI Proxy API as a custom model provider, giving you access to Google/ChatGPT/Claude OAuth subscriptions through Cursor’s interface.

Configuration

1

Start CLI Proxy API

Ensure CLI Proxy API is running:
The server will listen on http://localhost:8317 by default.
2

Open Cursor Settings

In Cursor IDE:
  1. Open Settings (Cmd+, on macOS, Ctrl+, on Windows/Linux)
  2. Navigate to ModelsOpenAI API Key
3

Configure API Endpoint

Set up the custom API endpoint:
  • API Key: Use any key from your api-keys list in config.yaml
  • Base URL: http://localhost:8317/v1
Example:
4

Select Models

In the Cursor chat interface, you can now select models from your CLI Proxy API providers:
  • Gemini models: gemini-2.5-pro, gemini-2.5-flash, etc.
  • Claude models: claude-sonnet-4, claude-opus-4, etc.
  • OpenAI models: gpt-5, gpt-5-mini, etc.
  • Custom models: Any models from your OpenAI-compatible providers

Configuration Examples

Using Gemini OAuth

If you have Gemini CLI OAuth configured:
config.yaml

Using Claude OAuth

If you have Claude Code OAuth configured:
config.yaml

Using Multiple Providers

You can switch between different providers by changing the model selection in Cursor:
config.yaml

Advanced Configuration

Model Prefixes

If you have multiple credentials with prefixes:
config.yaml
Use the prefix in your model selection:

Custom Endpoints

For HTTPS or custom ports:
config.yaml
Then in Cursor:

Features

Streaming Responses

Cursor supports streaming responses, which work seamlessly with CLI Proxy API:
  • Real-time code generation
  • Progressive responses for chat
  • Instant feedback on AI suggestions

Function Calling

If your selected model supports function calling (e.g., Gemini, OpenAI), Cursor can leverage this for:
  • Code analysis
  • File operations
  • Terminal commands

Multimodal Input

For models that support images (e.g., Gemini, Claude):
  • Attach screenshots to chat
  • Analyze UI designs
  • Debug visual issues

Troubleshooting

Connection Refused

If Cursor shows “Connection refused”:
  1. Verify CLI Proxy API is running: curl http://localhost:8317/v1/models
  2. Check the port in your config matches the Base URL
  3. Ensure no firewall is blocking localhost connections

Invalid API Key

If you see “Invalid API key”:
  1. Verify the API key exists in your config.yaml under api-keys
  2. Check for leading/trailing whitespace
  3. Restart CLI Proxy API after config changes

Model Not Available

If a model doesn’t appear in Cursor:
  1. Authenticate with the provider first (e.g., cliproxyapi gemini login)
  2. Verify the provider is configured correctly
  3. Check /v1/models endpoint to see available models:

Rate Limiting

If you hit rate limits:
  1. Configure multiple accounts for round-robin load balancing
  2. Use the routing.strategy option in config.yaml:
    config.yaml

Best Practices

  1. Use OAuth providers when possible for better quota limits
  2. Configure multiple accounts for load balancing
  3. Enable debug logging during initial setup: debug: true
  4. Use HTTPS in production environments with TLS certificates
  5. Restrict API keys by using different keys for different projects

Example Workflow

1

Authenticate Providers

2

Verify Models

3

Configure Cursor

  • Base URL: http://localhost:8317/v1
  • API Key: your-api-key-1
  • Model: gemini-2.5-pro (or any available model)
4

Start Coding

Use Cursor’s AI features:
  • Cmd+K: Inline code generation
  • Cmd+L: Chat with AI
  • Cmd+I: AI-powered autocomplete

See Also