Z²ᴱ

Model Configuration

Configure LLM providers, models, and gateway settings.

The agent connects to an AI Gateway that routes requests to 250+ models across multiple providers. The gateway client lives in internal/llm/gateway/client.go and the model catalog is in internal/llm/gateway/models.json.

Architecture

z2e-terminal → AI Gateway → Provider API

              SSE Stream

         Text deltas + Tool calls

All communication uses SSE (Server-Sent Events) streaming for real-time output.

Configuration

Environment variables control model selection:

# Required
AI_GATEWAY_API_KEY=sk-...
VERCEL_AI_GATEWAY_API_KEY=sk-...        # Alias

# Optional
AI_GATEWAY_BASE_URL=https://ai-gateway.vercel.sh/v1
AI_GATEWAY_MODEL=openai/gpt-5.2
VERCEL_AI_GATEWAY_MODEL=openai/gpt-5.2  # Alias

Model Catalog

The model catalog (models.json) contains 250+ entries. Models are organized by provider:

ProviderNotable Models
OpenAIo3, gpt-5.2, gpt-4.1, gpt-4o-mini, o1, o1-mini
Anthropicclaude-sonnet-4-20250514, claude-3.7-sonnet, claude-3.5-haiku
Googlegemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash
DeepSeekdeepseek-chat, deepseek-reasoner
Metallama-4-scout, llama-4-maverick, llama-3.3-70b
Mistralmistral-large, codestral, ministral
xAIgrok-3, grok-3-fast, grok-3-mini

Default: openai/gpt-5.2

Runtime Model Switching

Type /model in the TUI composer to open the interactive model picker. This:

  1. Lists all models from the catalog
  2. Highlights the currently active model
  3. Updates the model on selection
  4. Shows the new model name in the status bar

Retry Logic

Gateway calls retry on failure with exponential backoff and jitter:

AttemptDelay
1stImmediate
2ndExponential backoff + jitter
3rdExponential backoff + jitter
4thExponential backoff + jitter

Only transient errors trigger retries: HTTP 429/500/502/503/504, connection resets, refused connections, EOF, broken pipe, DNS failures, and timeouts.

Provider Routing

The AI Gateway handles provider-specific routing:

  • OpenAI: Chat completions API
  • Anthropic: Messages API
  • Google: Gemini API
  • Others: Unified chat completions interface

Model names use the format <provider>/<model-name> (e.g., openai/gpt-4o-mini).

On this page