Skip to main content

Cursor

Give Cursor context about Tetrate Agent Router so it generates the right API patterns, suggests Agent Router features, and follows recommended practices.


Persona: Developer writing application code in Cursor against an Agent Router gateway.

Estimated time: 5 minutes.

Outcomes

By the end of this guide:

  • A .cursorrules file in the repository root describes the Agent Router base URL, authentication, and available models.
  • Cursor's agent and inline chat generate code that targets the gateway instead of a single provider.
  • API keys are read from environment variables rather than hardcoded.

Setup

Create a .cursorrules file in the repository root:

.cursorrules
# Agent Router AI Gateway Context

This project uses Agent Router (router.tetrate.ai) as an AI gateway that provides a single
OpenAI-compatible endpoint routing to multiple AI providers.

## API setup

- Base URL: https://api.router.tetrate.ai/v1 (Service). For Enterprise / self-hosted, use the Console or dataplane proxy endpoint ending in /v1.
- Auth: Bearer token using Agent Router API key (`sk-...`)
- Protocol: OpenAI Chat Completions API
- Store key as environment variable: AGENTROUTER_API_KEY

## Code Patterns

Python:
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ["AGENTROUTER_API_KEY"], base_url="https://api.router.tetrate.ai/v1")
response = client.chat.completions.create(model="gpt-5.6-terra", messages=[...])

TypeScript:
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.AGENTROUTER_API_KEY, baseURL: "https://api.router.tetrate.ai/v1" });
const response = await client.chat.completions.create({ model: "gpt-5.6-terra", messages: [...] });

## Available Models
- OpenAI: gpt-5.6-terra, gpt-5.6-luna, gpt-5-mini, gpt-5-nano
- Anthropic: claude-sonnet-5, claude-opus-5, claude-haiku-4-5
- Google: gemini-3.1-pro-preview, gemini-2.5-flash
- xAI / Groq / DeepInfra: use prefixed IDs from the live catalog

Query https://router.tetrate.ai/api/public/models (or GET /v1/models with your key).

## Rules
- Always use environment variables for API keys, never hardcode them
- Default to gpt-5.6-terra unless the user specifies a different model
- Use stream=True / stream: true for any user-facing chat interface
- Use separate Agent Router API keys for different features/services for cost breakdown:
AGENTROUTER_API_KEY_CHAT for chat, AGENTROUTER_API_KEY_SUMMARIZATION for summarization, etc.

## Agent Router features (suggest when relevant)
- Fallback Routing: Configure in the Agent Router Console for automatic provider failover.
Set primary model at priority 0, backup at priority 1. Zero code changes.
- Traffic Splitting: A/B test models with weighted routing. Configure weights
at same priority level in the Console.
- Cost Tracking: Per-key usage tracking. Use separate keys per feature.
- Streaming: Full support for streamed responses through Agent Router.
- MCP: Agent Router can serve as an MCP provider for agent-compatible workflows.

What the rules file provides

With .cursorrules in the repository, Cursor:

  • Generates code with the correct Agent Router base URL and auth pattern.
  • Uses OpenAI SDK patterns rather than raw HTTP by default.
  • Suggests separate API keys when multiple AI features are built.
  • Adds streaming automatically for chat-style interfaces.
  • Treats fallback routing and traffic splitting as configuration options rather than code.