How to configure AI models on Cursor
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
Step-by-Step Instructions
Open Cursor Settings
Ctrl+, (Windows/Linux) or Cmd+, (Mac). Alternatively, click the gear icon in the bottom left corner and select Settings from the menu.Navigate to AI Models Section
Add API Keys for AI Providers
sk-.... For Anthropic, use your Claude API key format sk-ant-....Select Your Primary Model
- GPT-4 Turbo for advanced reasoning
- GPT-3.5 Turbo for faster responses
- Claude 3 for balanced performance
- Codestral for specialized coding tasks
Configure Chat vs Autocomplete Models
- Chat Model: For conversational coding help
- Autocomplete Model: For inline code suggestions
- Command Model: For specific code generation commands
Adjust Model Parameters
- 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
Test and Verify Configuration
- 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
Common Issues & 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.