Skip to main content

Prerequisites

Before you begin, please ensure:
  1. Cursor is installed
    Download and install the version suitable for your operating system from Cursor Official Website
  2. APIMart API Key obtained
    Log in to APIMart Console to get your API key (starts with sk-)
Tip: If you don’t have an APIMart account yet, please register at APIMart and obtain an API key first.

Step 1: Open Cursor Settings

After launching Cursor, navigate to the settings page:
  1. Click the ⚙️ Settings icon (gear icon) in the top right corner
  2. Or use keyboard shortcuts:
    • Windows/Linux: Ctrl+Shift+J
    • macOS: Cmd+Shift+J

Step 2: Configure Model Settings

2.1 Access Model Settings

In the settings page:
  1. Find the Models option in the left menu
  2. Click to enter model settings page

2.2 Select OpenAI API Key

On the model settings page:
  1. Find the OpenAI API Key configuration area
  2. Click Add new or Override OpenAI Base URL option
Important: Cursor supports OpenAI-compatible APIs, so we can configure APIMart as a custom API provider.

2.3 Configure APIMart API Information

Fill in the following configuration:
FieldValue
API KeyYour APIMart API key (sk-xxxxxxxxxxxx)
Base URLhttps://api.apimart.ai/v1
Important:
  • Base URL must include the /v1 suffix: https://api.apimart.ai/v1
  • API Key must be obtained from APIMart console and start with sk-
  • After configuration, Cursor will use APIMart’s models for code completion and chat

Step 3: Select Models to Use

3.1 Model Selection

In model settings, you can select the models to use: Available Model Types:
  • GPT-4/5 Series - Suitable for complex code generation and problem-solving
    • gpt-5 - Latest GPT-5 model
    • gpt-4o - GPT-4o model
    • gpt-4o-mini - Faster and more economical version
  • Claude Series - Suitable for code understanding and refactoring
    • claude-sonnet-4-5-20250929 - Claude Sonnet 4.5
    • claude-haiku-4-5-20251001 - Claude Haiku 4.5
  • Other Models
    • gemini-2.0-flash-exp - Google Gemini 2.0 Flash
Recommended Models:
  • 💰 Code Completion (Cost-effective): gpt-4o-mini
  • 🚀 Complex Tasks (High-performance): gpt-5, gpt-4o, claude-sonnet-4-5-20250929
  • Quick Response: gpt-4o-mini, gemini-2.0-flash-exp

3.2 Configure Models for Specific Features

Cursor allows configuring different models for different features:
  • Chat - For conversing with AI
  • Autocomplete - For code auto-completion suggestions
  • Cmd+K (Quick Edit) - For quick code editing and generation
You can select the most suitable model for each feature based on your needs.

Step 4: Start Using

After configuration, you can start using Cursor’s AI features:

4.1 AI Chat (Cmd+L / Ctrl+L)

  1. Press Cmd+L (macOS) or Ctrl+L (Windows/Linux) to open AI chat panel
  2. Enter your question or request, for example:
    • “How to implement a quicksort algorithm?”
    • “Help me optimize this code’s performance”
    • “Explain how this function works”

4.2 Code Completion

  1. Write code normally in the editor
  2. Cursor will automatically provide code completion suggestions
  3. Press Tab to accept suggestions

4.3 Quick Edit (Cmd+K / Ctrl+K)

  1. Select the code you want to edit
  2. Press Cmd+K (macOS) or Ctrl+K (Windows/Linux)
  3. Enter editing instructions, for example:
    • “Add error handling”
    • “Refactor this function”
    • “Add type annotations”

4.4 Code Explanation

  1. Select the code you want to understand
  2. Right-click and select “Explain with AI” or use shortcut
  3. AI will explain the code’s functionality and logic in detail

FAQ

Q1: Cannot connect to APIMart service?

Solution:
  1. Check Base URL:
    • Ensure Base URL is https://api.apimart.ai/v1 (note the /v1 suffix)
    • Don’t omit or add extra paths
  2. Verify API Key:
    • Confirm API Key is correct and starts with sk-
    • Check if the key is valid in APIMart Console
  3. Check Network Connection:
    • Ensure you can access https://api.apimart.ai
    • You may need to configure a proxy if in China

Q2: AI response is slow?

Solution:
  1. Switch to a faster model:
    • Use gpt-4o-mini instead of gpt-4o
    • Use gemini-2.0-flash-exp for faster responses
  2. Reduce context length:
    • Limit the code context sent to AI
    • Use more precise question descriptions
  3. Check network conditions:
    • Test network latency
    • Consider using a proxy to optimize connection

Q3: API call fails or returns errors?

Common errors and solutions:
Error MessageCauseSolution
401 UnauthorizedInvalid or expired API KeyRe-obtain API Key and update configuration
429 Too Many RequestsRequest rate limit exceededWait a moment and retry
500 Internal Server ErrorTemporary server issueWait a few minutes and retry
insufficient_quotaInsufficient account balanceTop up in the console

Q4: How to view API usage and costs?

Log in to APIMart Console to view:
  • 📊 API call statistics
  • 💰 Cost details
  • 📈 Usage trend charts
  • 🔍 Detailed request logs

Usage Tips

1. Leverage Context

Cursor automatically includes relevant code context. You can:
  • Open related files to let AI understand project structure
  • Use @filename to reference specific files
  • Use @folder to reference entire folders

2. Write Clear Prompts

Good prompts lead to better results: ❌ Poor Prompt:
Optimize this
✅ Good Prompt:
Optimize this function's performance, focusing on:
1. Reduce loop nesting
2. Use more efficient data structures
3. Add caching mechanism

3. Iterative Development

When collaborating with AI:
  1. Start with simple requirements
  2. Gradually refine and optimize
  3. Test and validate promptly
  4. Adjust prompts based on results

4. Utilize Project Standards

Create a .cursorrules file to define:
  • Code style guidelines
  • Naming conventions
  • Architecture patterns
  • Testing requirements

Features

Using Cursor + APIMart, you can:
  • 💬 Intelligent Chat - Ask programming questions anytime, get detailed answers
  • Code Completion - Real-time intelligent code suggestions and completion
  • ✏️ Quick Edit - Quickly modify code through natural language
  • 🔍 Code Understanding - Deeply understand how complex code works
  • 🐛 Debugging Assistant - Help find and fix code bugs
  • 📝 Documentation Generation - Automatically generate code comments and documentation
  • 🔄 Code Refactoring - Intelligently refactor and optimize code structure
  • 🧪 Test Generation - Automatically generate unit tests and test cases

Support & Help

If you encounter any issues:

Start Using APIMart

Register for APIMart now, get your API key, and boost your programming efficiency!