Intermediate
How to configure AI models on Cursor
Quick Answer
Configure AI models in Cursor by accessing Settings, navigating to AI Models, adding your API keys for providers like OpenAI or Anthropic, and selecting your preferred model. You can customize model parameters and set different models for chat vs autocomplete features.
Prerequisites
- Cursor IDE installed
- Valid API key for your preferred AI provider
- Basic understanding of AI coding assistants
- Active internet connection
1
Open Cursor Settings
Launch Cursor IDE and access settings by pressing
Ctrl+, (Windows/Linux) or Cmd+, (Mac). Alternatively, click the gear icon in the bottom left corner and select Settings from the menu.Tip
You can also access settings through the top menu: File > Preferences > Settings
2
Navigate to AI Models Section
In the settings panel, look for the AI Models or Copilot++ section in the left sidebar. Click on it to expand the AI configuration options. This section contains all model-related settings including provider configuration and model selection.
3
Add API Keys for AI Providers
Click Add API Key and select your preferred provider from the dropdown menu (OpenAI, Anthropic, Google AI, etc.). Paste your API key in the text field and click Save. For OpenAI, enter your key in format
sk-.... For Anthropic, use your Claude API key format sk-ant-....Tip
Store API keys securely and never share them. Generate keys from your provider's dashboard.
4
Select Your Primary Model
In the Model Selection dropdown, choose your preferred model for code completion. Options typically include:
- GPT-4 Turbo for advanced reasoning
- GPT-3.5 Turbo for faster responses
- Claude 3 for balanced performance
- Codestral for specialized coding tasks
Tip
Different models excel at different tasks - experiment to find what works best for your coding style
5
Configure Chat vs Autocomplete Models
Set separate models for different features by expanding Advanced Settings. Configure:
- Chat Model: For conversational coding help
- Autocomplete Model: For inline code suggestions
- Command Model: For specific code generation commands
Tip
Use faster models for autocomplete and more powerful models for complex chat interactions
6
Adjust Model Parameters
Fine-tune model behavior in the Parameters section:
- Temperature: Set between 0-1 for creativity vs consistency
- Max Tokens: Limit response length (typically 1000-4000)
- Context Length: Adjust how much code context to include
Tip
Lower temperature (0.2-0.4) works better for code generation, higher values for creative tasks
7
Test and Verify Configuration
Test your setup by opening a code file and trying:
- Type
Ctrl+K(Cmd+K on Mac) to open the AI command palette - Press
Tabto accept autocomplete suggestions - Use
Ctrl+L(Cmd+L on Mac) to start an AI chat session
Tip
Check the status bar at the bottom of Cursor to see which model is currently active
Troubleshooting
API key authentication failed
Verify your API key is correct and has sufficient credits/quota. Check the key format matches your provider's requirements and ensure it has the necessary permissions for code generation.
Model responses are too slow
Switch to a faster model like GPT-3.5 Turbo for autocomplete, reduce the context length in parameters, or check your internet connection speed. Consider using local models if available.
Autocomplete suggestions not appearing
Check that autocomplete is enabled in Settings > AI Models > Autocomplete. Verify your model selection and ensure the file type is supported. Try restarting Cursor if the issue persists.
Model configuration not saving
Ensure Cursor has write permissions to its configuration directory. Try running Cursor as administrator (Windows) or with appropriate permissions. Clear Cursor cache and restart the application.
Ready to get started with Cursor?
Put this tutorial into practice. Visit Cursor and follow the steps above.
Visit Cursor →