> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elkapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using ElkAPI in Cursor

> Detailed guide on how to configure and use ElkAPI API service in Cursor AI code editor. This guide will help you configure ElkAPI API in Cursor to access rich AI model resources for code development.

## Prerequisites

Before you begin, please ensure:

1. **Cursor is installed**\
   Download and install the version suitable for your operating system from [Cursor Official Website](https://cursor.sh/)

2. **ElkAPI API Key obtained**\
   Log in to [ElkAPI Console](https://api.elkapi.com/keys) to get your API key (starts with `sk-`)

<Note>
  **Tip:** If you don't have an ElkAPI account yet, please register at [ElkAPI](https://api.elkapi.com) and obtain an API key first.
</Note>

## 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

<Note>
  **Important:** Cursor supports OpenAI-compatible APIs, so we can configure ElkAPI as a custom API provider.
</Note>

### 2.3 Configure ElkAPI API Information

Fill in the following configuration:

| Field        | Value                                   |
| ------------ | --------------------------------------- |
| **API Key**  | Your ElkAPI API key (`sk-xxxxxxxxxxxx`) |
| **Base URL** | `https://api.elkapi.com/v1`             |

<Note>
  **Important:**

  * Base URL must include the `/v1` suffix: `https://api.elkapi.com/v1`
  * API Key must be obtained from ElkAPI console and start with `sk-`
  * After configuration, Cursor will use ElkAPI's models for code completion and chat
</Note>

## 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.5` - Latest GPT-5 model
  * `gpt-5.5` - GPT-5.5 model
  * `gpt-5.4-mini` - Faster and more economical version

* **Claude Series** - Suitable for code understanding and refactoring
  * `claude-sonnet-4-6` - Claude Sonnet 4.6
  * `claude-sonnet-4-6` - Claude Opus 4.7

* **Other Models**
  * `gemini-3.1-flash-lite-preview` - Google Gemini 3.1 Flash Lite

<Tip>
  **Recommended Models:**

  * 💰 **Code Completion (Cost-effective):** `gpt-5.4-mini`
  * 🚀 **Complex Tasks (High-performance):** `gpt-5.5`, `gpt-5.5-pro`, `claude-sonnet-4-6`
  * ⚡ **Quick Response:** `gpt-5.4-mini`, `gemini-3.1-flash-lite-preview`
</Tip>

### 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 ElkAPI service?

**Solution:**

1. **Check Base URL**:
   * Ensure Base URL is `https://api.elkapi.com/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 [ElkAPI Console](https://api.elkapi.com/keys)

3. **Check Network Connection**:
   * Ensure you can access `https://api.elkapi.com`
   * You may need to configure a proxy if in China

### Q2: AI response is slow?

**Solution:**

1. **Switch to a faster model**:
   * Use `gpt-5.4-mini` instead of `gpt-5.5`
   * Use `gemini-3.1-flash-lite-preview` 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 Message               | Cause                        | Solution                                   |
| --------------------------- | ---------------------------- | ------------------------------------------ |
| `401 Unauthorized`          | Invalid or expired API Key   | Re-obtain API Key and update configuration |
| `429 Too Many Requests`     | Request rate limit exceeded  | Wait a moment and retry                    |
| `500 Internal Server Error` | Temporary server issue       | Wait a few minutes and retry               |
| `insufficient_quota`        | Insufficient account balance | Top up in the console                      |

### Q4: How to view API usage and costs?

Log in to [ElkAPI Console](https://api.elkapi.com) 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 + ElkAPI, 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:

* 📚 [ElkAPI Documentation](https://docs.elkapi.com)
* 📧 Technical Support: [support@elkapi.com](mailto:support@elkapi.com)

***

<Card title="Start Using ElkAPI" icon="rocket" href="https://api.elkapi.com">
  Register for ElkAPI now, get your API key, and boost your programming efficiency!
</Card>
