Skip to main content
greg is completely model-agnostic. Powered by the @amaranthic/hernex engine, it connects to every major frontier AI provider, open-source inference router, and local gateway using a unified single-string identifier format. Whether you are executing tasks with Anthropic Claude Sonnet, Google Gemini Flash, OpenAI GPT-5, DeepSeek-V4 Pro, or private enterprise endpoints, greg normalizes model communication, reasoning effort levels, and tool calling behind a deterministic interface.
New to greg? See the Quickstart for setting up your first provider, or explore Common Workflows for everyday prompt recipes.
This page covers:

How Model Routing Works

greg uses Hernex’s first-slash routing rule to determine which provider adapter to invoke:
  • Before the first slash: The provider identifier (e.g., anthropic, google, openai, deepseek, groq, openrouter).
  • After the first slash: The model identifier passed directly to that provider. Any subsequent slashes are preserved as part of the model name (essential for multi-tenant routers like OpenRouter).

Routing Examples


Credential & Base URL Resolution

When connecting to a provider, greg resolves your credentials and API endpoints using a deterministic order of precedence.

Environment Variable Compilation Formula

To determine the exact environment variable name for any provider prefix, greg normalizes the provider segment (the text before the first /) using this exact regex logic:
  1. Converts the provider name to uppercase: .toUpperCase().
  2. Replaces all non-alphanumeric characters with underscores: /[^A-Z0-9]/g → _.
  3. Appends _API_KEY or _BASE_URL.
Provider Aliases: Certain providers feature built-in aliases in src/settings/resolve.ts that are evaluated in addition to the standard formula:
  • Google (google/): greg checks GEMINI_API_KEY first, then falls back to GOOGLE_API_KEY.
  • NVIDIA (nvidiaNim/): greg accepts NVIDIA_API_KEY and NVIDIA_NIM_API_KEY in addition to NVIDIANIM_API_KEY.

API Key Precedence

  1. CLI Flag Overrides: --api-key <key> explicitly overrides all environment settings for a single command.
  2. Provider-Specific Variables: Derived via the formula above (e.g. ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY).
  3. Provider Aliases:
    • Google: Checks GEMINI_API_KEY first, then falls back to GOOGLE_API_KEY.
    • NVIDIA: Checks NVIDIA_API_KEY first, then falls back to NVIDIA_NIM_API_KEY.
  4. Generic Fallback: If no provider-specific variable is found, greg checks the generic API_KEY environment variable.

Base URL Precedence & Environment Overrides

Just like API keys, every provider’s base URL is fully configurable via environment variables:
  1. CLI Flag Override: --base-url <url> overrides the endpoint for a single run.
  2. Provider-Specific Variables: Derived via the formula above (${NORMALIZED_PROVIDER}_BASE_URL):
    • ANTHROPIC_BASE_URL
    • OPENAI_BASE_URL
    • GOOGLE_BASE_URL
    • DEEPSEEK_BASE_URL
    • GROQ_BASE_URL
    • OPENROUTER_BASE_URL
    • XAI_BASE_URL
    • MISTRAL_BASE_URL
    • COHERE_BASE_URL
    • TOGETHERAI_BASE_URL
    • ALIBABA_BASE_URL
    • NVIDIANIM_BASE_URL
    • COMPATIBLE_BASE_URL
  3. Generic Fallback: If no provider-specific variable is set, greg checks the global BASE_URL environment variable.
  4. Built-in Default: If unset, Hernex uses the provider’s official default endpoint.

Example: Routing Through Proxies or AI Gateways

You can direct traffic through corporate proxies, LiteLLM, Portkey, or Cloudflare AI Gateway without changing CLI commands:

Supported Providers Matrix

Below is the complete matrix of built-in providers bundled with greg and Hernex:

Setting Your Default Model

You can persist your default model globally so you don’t need to specify -m or --model on every run:
To run a task with a temporary model override:

Reasoning Effort Configuration

Frontier reasoning models (such as Claude Sonnet 4.6 thinking mode, OpenAI o3 / o4-mini, or Gemini thinking) support configurable reasoning effort. You can specify the reasoning budget per command or configure it persistently:
Supported effort values:
  • none
  • minimal
  • low
  • medium
  • high
  • xhigh
  • max
You can also set a default reasoning effort level in your settings:

Automatic Fallback Chains

In production environments, rate limits (HTTP 429) or transient provider outages can interrupt tasks. greg supports ordered fallback chains that automatically fail over from left to right if your primary model fails:
You can also configure permanent fallback models in your settings:
If the primary model exhausts its retry budget or encounters a non-recoverable error, greg automatically initializes the next candidate model in the chain and resumes execution seamlessly.

Custom & Local Gateways

To connect greg to local models running on Ollama, vLLM, LM Studio, or private corporate proxies, use the compatible/ provider:
Or connect to an internal enterprise gateway:

Next Steps

Now that you have configured your model providers and endpoints:
  • Common Workflows: Explore real-world developer recipes and piping patterns.
  • Managing Threads: Master session persistence, branching, and checkpoint rollback workflows.
  • Quickstart: Return to the quickstart to practice everyday agent commands.