Cursor is an AI-powered code editor that enhances developer productivity with intelligent code completion, generation, and debugging capabilities. TrueFoundry’s AI Gateway integrates with Cursor, providing access to multiple AI models through a unified, secure interface.

Prerequisites

Before integrating Cursor with TrueFoundry, ensure you have:
  1. TrueFoundry Account: Create a Truefoundry account with atleast one model provider and generate a Personal Access Token by following the instructions in Generating Tokens. For a quick setup guide, see our Gateway Quick Start
  2. Cursor Installation: Download and install Cursor from the official website
  3. Load Balance Configuration: Setup load balancing configuration for your desired models (see Setup Process section below)

Important Network Requirements

Gateway URL Public Exposure Required: Your TrueFoundry Gateway URL must be exposed to public internet for Cursor integration to work properly. If your gateway is behind a VPN, the request flow is: Cursor → Cursor Server → Service Provider Server. This means Cursor’s servers need to be able to reach your TrueFoundry Gateway endpoint. For more information about Cursor’s security practices, visit Cursor’s security page.

Why Load Balancing Configuration is Necessary

Cursor has internal logic that works optimally with standard OpenAI model names (like gpt-4o, claude-3-sonnet), but may experience compatibility issues with TrueFoundry’s model names (like openai-main/gpt-4o or azure-openai/gpt-4o). When Cursor encounters these model names directly, it may not function as expected due to internal processing differences. The Solution: Load balancing configuration allows you to:
  1. Use standard model names in your Cursor configuration (e.g., gpt-4o)
  2. Have TrueFoundry Gateway automatically route the request to the target model (e.g., openai-main/gpt-4o)
This approach ensures seamless compatibility while still routing all requests through the TrueFoundry Gateway.

Integration Guide

Step 1: Setup Load Balance Configuration

Before configuring Cursor, create a load balancing configuration to route your requests to specific model providers. This ensures compatibility with Cursor’s internal model handling. Create a load balancing configuration like this:
name: cursor-load-balancing-config
type: gateway-load-balancing-config
rules:
  - id: cursor-gpt4o-routing
    type: weight-based-routing
    when:
      models:
        - gpt-4o
    load_balance_targets:
      - target: openai-main/gpt-4o
        weight: 100
This configuration ensures that when you use gpt-4o in Cursor, your requests will be properly routed to the target model names through the TrueFoundry Gateway.

Step 2: Get TrueFoundry Gateway Configuration

Before configuring Cursor, gather your TrueFoundry Gateway details:
  1. Navigate to AI Gateway Playground: Go to your TrueFoundry AI Gateway playground
  2. Access Unified Code Snippet: Use the unified code snippet
  3. Copy Base URL and Model Name: You will get both the base URL and model name from the unified code snippet (ensure you use the same model name as written)

Get Base URL and Model Name from Unified Code Snippet

Step 3: Configure Cursor with TrueFoundry Gateway

  1. Open Cursor Settings: Open Cursor Settings
  2. Navigate to Models Section: Look for Models > API section
  3. OpenAI API Keys: Your API key is the Personal Access Token (PAT) generated in the prerequisites, and the base URL is the unified URL obtained from Step 2

Cursor AI Settings

  1. Configure TrueFoundry Settings:
    • Base URL: Enter your TrueFoundry Gateway URL from the unified code snippet
    • API Key: Paste your TrueFoundry authentication token
    • Model Name: Use the standard model name from your load balancing configuration (e.g., gpt-4o)

TrueFoundry Configuration in Cursor

Step 4: Complete Configuration

Configure Model: Use the standard model name from your load balancing configuration and send any request(e.g., gpt-4o instead of openai-main/gpt-4o) All your calls from Cursor will now go through the TrueFoundry Gateway, with automatic routing based on your load balancing configuration.