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.- How Model Routing Works: The first-slash routing rule and model ID preservation.
- Credential & Base URL Resolution: Environment variable regex formula, provider aliases, and resolution precedence.
- Supported Providers Matrix: 13+ provider table with required environment variables and default endpoints.
- Setting Your Default Model: Persisting global models and applying temporary CLI overrides.
- Reasoning Effort Configuration: Configuring thinking budgets with
--effort. - Automatic Fallback Chains: High-availability failover across multiple models.
- Custom & Local Gateways: Connecting to Ollama, vLLM, and enterprise proxies via
compatible/. - Next Steps: Next guides to explore.
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:
- Converts the provider name to uppercase:
.toUpperCase(). - Replaces all non-alphanumeric characters with underscores:
/[^A-Z0-9]/g→_. - Appends
_API_KEYor_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/):gregchecksGEMINI_API_KEYfirst, then falls back toGOOGLE_API_KEY. - NVIDIA (
nvidiaNim/):gregacceptsNVIDIA_API_KEYandNVIDIA_NIM_API_KEYin addition toNVIDIANIM_API_KEY.
API Key Precedence
- CLI Flag Overrides:
--api-key <key>explicitly overrides all environment settings for a single command. - Provider-Specific Variables: Derived via the formula above (e.g.
ANTHROPIC_API_KEY,OPENAI_API_KEY,DEEPSEEK_API_KEY). - Provider Aliases:
- Google: Checks
GEMINI_API_KEYfirst, then falls back toGOOGLE_API_KEY. - NVIDIA: Checks
NVIDIA_API_KEYfirst, then falls back toNVIDIA_NIM_API_KEY.
- Google: Checks
- Generic Fallback: If no provider-specific variable is found,
gregchecks the genericAPI_KEYenvironment variable.
Base URL Precedence & Environment Overrides
Just like API keys, every provider’s base URL is fully configurable via environment variables:- CLI Flag Override:
--base-url <url>overrides the endpoint for a single run. - Provider-Specific Variables: Derived via the formula above (
${NORMALIZED_PROVIDER}_BASE_URL):ANTHROPIC_BASE_URLOPENAI_BASE_URLGOOGLE_BASE_URLDEEPSEEK_BASE_URLGROQ_BASE_URLOPENROUTER_BASE_URLXAI_BASE_URLMISTRAL_BASE_URLCOHERE_BASE_URLTOGETHERAI_BASE_URLALIBABA_BASE_URLNVIDIANIM_BASE_URLCOMPATIBLE_BASE_URL
- Generic Fallback: If no provider-specific variable is set,
gregchecks the globalBASE_URLenvironment variable. - 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 withgreg 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:
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:noneminimallowmediumhighxhighmax
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:
greg automatically initializes the next candidate model in the chain and resumes execution seamlessly.
Custom & Local Gateways
To connectgreg to local models running on Ollama, vLLM, LM Studio, or private corporate proxies, use the compatible/ provider:
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.