Skip to main content

Overview

Model mapping allows you to route API requests for specific models (like GPT-4 or Claude) to your preferred Google AI models.

Configuration

Custom Mapping

custom_mapping
object
default:"{}"
Custom exact model mapping tableMaps incoming model names to target Google AI models.Type: HashMap<String, String>
Location: config.rs:491

Mapping Examples

Basic Mapping

Route GPT-4 requests to Gemini Pro:
{
  "proxy": {
    "custom_mapping": {
      "gpt-4": "gemini-3.1-pro-high",
      "gpt-4o": "gemini-3-flash",
      "gpt-3.5-turbo": "gemini-2.5-flash"
    }
  }
}

Wildcard Mapping

Use wildcards for pattern matching:
{
  "proxy": {
    "custom_mapping": {
      "gpt-4*": "gemini-3.1-pro-high",
      "claude-3-opus-*": "claude-opus-4-6-thinking",
      "claude-3-5-sonnet-*": "claude-sonnet-4-6"
    }
  }
}

Preset Configurations

Antigravity provides built-in presets for common use cases:

Default Preset

Balanced performance and cost:
{
  "gpt-4*": "gemini-3.1-pro-high",
  "gpt-4o*": "gemini-3-flash",
  "gpt-3.5*": "gemini-2.5-flash",
  "o1-*": "gemini-3.1-pro-high",
  "o3-*": "gemini-3.1-pro-high",
  "claude-3-5-sonnet-*": "claude-sonnet-4-6",
  "claude-3-opus-*": "claude-opus-4-6-thinking",
  "claude-haiku-*": "gemini-2.5-flash"
}

Performance Preset

Maximum quality, higher cost:
{
  "gpt-4*": "claude-opus-4-6-thinking",
  "gpt-4o*": "claude-sonnet-4-6",
  "gpt-3.5*": "gemini-3-flash",
  "o1-*": "claude-opus-4-6-thinking",
  "claude-3-5-sonnet-*": "claude-sonnet-4-6",
  "claude-3-opus-*": "claude-opus-4-6-thinking"
}

Cost-Effective Preset

Minimum cost, good performance:
{
  "gpt-4*": "gemini-3-flash",
  "gpt-4o*": "gemini-2.5-flash",
  "gpt-3.5*": "gemini-2.5-flash",
  "o1-*": "gemini-3-flash",
  "claude-3-5-sonnet-*": "gemini-3-flash",
  "claude-3-opus-*": "gemini-3-flash"
}

z.ai Provider Integration

Route Claude requests to z.ai (GLM models):
zai.enabled
boolean
default:"false"
Enable z.ai provider integrationLocation: config.rs:227
zai.base_url
string
default:"https://api.z.ai/api/anthropic"
z.ai API base URLLocation: config.rs:228-229
zai.api_key
string
required
z.ai API keyLocation: config.rs:231
zai.dispatch_mode
enum
default:"off"
How to dispatch requests to z.aiOptions:
  • off: Never use z.ai
  • exclusive: Use z.ai for all Anthropic protocol requests
  • pooled: Treat z.ai as one slot in the shared pool
  • fallback: Use z.ai only when Google pool is unavailable
Location: config.rs:161-175

z.ai Model Mapping

zai.model_mapping
object
default:"{}"
Per-model overrides for z.ai routingMaps Claude model IDs to z.ai model IDs.Type: HashMap<String, String>
Location: config.rs:236-237
zai.models.opus
string
default:"glm-4.7"
Default z.ai model for Opus familyLocation: config.rs:182
zai.models.sonnet
string
default:"glm-4.7"
Default z.ai model for Sonnet familyLocation: config.rs:185
zai.models.haiku
string
default:"glm-4.5-air"
Default z.ai model for Haiku familyLocation: config.rs:188

z.ai Configuration Example

{
  "proxy": {
    "zai": {
      "enabled": true,
      "base_url": "https://api.z.ai/api/anthropic",
      "api_key": "sk-zai-key...",
      "dispatch_mode": "fallback",
      "model_mapping": {
        "claude-3-opus": "glm-4.7",
        "claude-3-sonnet": "glm-4.7"
      },
      "models": {
        "opus": "glm-4.7",
        "sonnet": "glm-4.7",
        "haiku": "glm-4.5-air"
      }
    }
  }
}

Advanced Features

MCP (Model Context Protocol)

Enable advanced capabilities for z.ai models:
zai.mcp.enabled
boolean
default:"false"
Enable MCP featuresLocation: config.rs:203
zai.mcp.web_search_enabled
boolean
default:"false"
Enable web search capabilityLocation: config.rs:205
zai.mcp.web_reader_enabled
boolean
default:"false"
Enable web content readingLocation: config.rs:207
zai.mcp.vision_enabled
boolean
default:"false"
Enable vision/image understandingLocation: config.rs:209

UI Configuration

You can configure model mappings through the Web UI:
  1. Navigate to API Proxy settings
  2. Expand the Model Router section
  3. Select a preset or create custom mappings
  4. Click Apply to activate
Changes take effect immediately without restarting the proxy service.

Best Practices

  • Test mappings with a small request before production use
  • Use wildcards (*) for flexible pattern matching
  • Consider cost vs. performance when choosing target models
  • Save custom mappings as presets for easy switching
  • Monitor token usage after changing mappings

Troubleshooting

Mapping Not Applied

  1. Verify the exact model name from client requests
  2. Check wildcard pattern syntax
  3. Ensure proxy service is running
  4. Review debug logs for routing decisions

Model Not Found

  1. Confirm target model exists in your accounts
  2. Check model availability in your region
  3. Verify account quota hasn’t been exhausted

Build docs developers (and LLMs) love