Models, Providers & Auth
Hya is not locked to any single AI company. You can connect Anthropic, OpenAI, Google Gemini, xAI Grok, OpenRouter, or a local server like Ollama, vLLM, or LM Studio—and switch between them mid-chat.
If you haven’t set up any provider yet, Hya uses its built-in hya/offline model, which echoes your messages back locally so you can test the app offline.
Option 1: Set up inside Hya with /key (Easiest)
Open hya, type /key, and press Enter.
- Press
ato add a new provider (give it an ID likeanthropic, pick its protocol, enter the base URL, and paste your API key). - Press
kon an existing provider to set or replace its API key. - Press
rto pull the latest list of models from that provider. - Open a provider with Enter and press
ton any model to send a tiny"hi"test ping—you’ll see in under a second whether your key and URL work!
Changes you make in /key take effect immediately—no restart needed.
Which protocol should I pick?
Protocol (kind) |
Use it for | Typical base_url |
|---|---|---|
anthropic |
Anthropic Claude API (and Anthropic-compatible gateways) | https://api.anthropic.com/v1 |
openai-response |
OpenAI’s modern Responses API (gpt-5, reasoning models, native compaction) |
https://api.openai.com/v1 |
openai |
Standard OpenAI Chat Completions (OpenRouter, DeepSeek, Ollama, vLLM, LiteLLM) | https://openrouter.ai/api/v1 or http://127.0.0.1:11434/v1 |
google |
Google Gemini API | https://generativelanguage.googleapis.com/v1beta |
Option 2: Sign in with a subscription (OAuth)
If you use a ChatGPT / Codex subscription or xAI Grok Build, you can sign in through your browser instead of managing raw API keys:
# ChatGPT / OpenAI Codex (prints a URL and one-time code—works great over SSH or WSL!)hya auth login codex --oauth openai-codex
# xAI SuperGrok / Grok Buildhya auth login grok --oauth grok-build
# Check login status anytimehya auth statusAdd --browser if you want Hya to open the login URL in your default browser automatically.
Configure providers in models.toml
Put provider declarations beside the active config.toml, or set a path
through models_file or HYA_MODELS_CONFIG. For example, with Ollama running
locally, save this as models.toml and run hya models ollama.
#:schema https://hya.ed-aisys.com/schema/v3/models.jsonschema_version = 1
[providers.ollama]These provider IDs supply preset defaults. Set kind, base_url or
api_key to override the corresponding defaults where applicable.
| Preset ID | Kind | Default base URL | Key environment fallback |
|---|---|---|---|
anthropic |
anthropic |
https://api.anthropic.com/v1 |
ANTHROPIC_API_KEY |
openai |
openai |
https://api.openai.com/v1 |
OPENAI_API_KEY |
google |
google |
https://generativelanguage.googleapis.com/v1beta |
GEMINI_API_KEY, then GOOGLE_API_KEY |
openrouter |
openai |
https://openrouter.ai/api/v1 |
OPENROUTER_API_KEY |
grok |
openai |
https://api.x.ai/v1 |
XAI_API_KEY |
ollama |
openai |
http://127.0.0.1:11434/v1 |
— |
lmstudio |
openai |
http://127.0.0.1:1234/v1 |
— |
printf '%s\n' "$ANTHROPIC_API_KEY" | hya auth login anthropic --api-key-stdinSaved API keys and OAuth credentials from hya auth login or /key live in data-root auth.json
(normally $XDG_DATA_HOME/hya/auth.json, mode 0600 on Unix) and always take
precedence over api_key in models.toml. A configured key can be a literal,
"{env:VAR}", or "{file:/path/to/key}".
How Hya builds the model catalog
- The embedded models.dev snapshot supplies baseline model metadata. With
catalog.models_dev = true, the remote registry refresh uses the cache-rootmodels-registry.jsonandcatalog.refresh_ttl_hours. With a configured cloud provider, startup uses the cached metadata and refreshes a missing or expired cache in the background. The embedded snapshot supplies metadata while the cache is absent. Startup with only the local Ollama and LM Studio presets skips the synced registry. Runhya model list --refreshto update the registry and provider catalogs synchronously. - Provider discovery contributes model IDs and metadata. Hya caches it in
models-discovered/<provider>.jsonunder the cache root. Setcatalog.discover_local = falseto disable automatic local discovery. - Explicit
models.tomlentries override fields on matching models and can add IDs. Providerincludeandexcludeglobs filter discovered model rows while keeping explicitmodelsentries intact. An explicitcostsets input, output, and optional cache pricing in USD per million tokens. [roles]and[categories]inconfig.tomlselect ordered candidates from the resulting routes.
Opening /model without arguments refreshes the model list from the
attached backend, which reloads the active model declarations and cached
catalog. Edits to models.toml can appear without restarting hya server
(or run hya server restart after hand-editing config.toml).
Use hya model list --refresh to request fresh discovery.
Compatibility for Chat Completions gateways
A provider compat table can adjust request fields for an OpenAI-compatible
endpoint. For a gateway that requires DeepSeek-style reasoning replay, add
the following to an existing [providers.gateway] declaration.
[providers.gateway.compat]reasoning_field = "reasoning_content"require_reasoning_replay = trueA model-level compat table can override provider defaults. See the
configuration reference
for all fields.
Where provider kinds come from
Hya registers provider kinds at startup. The core always registers openai (aliases openai-compatible and openai-completion). Every other kind, with its OAuth login and its model-list adapter, lives in an official provider bundle from the providers and default registry profiles (run hya bundle install --profile providers -y to install them) and loads when bundles.builtin in config.toml enables it:
| Bundle id | Kinds | OAuth type |
|---|---|---|
hya/provider-anthropic |
anthropic |
|
hya/provider-google |
google |
|
hya/provider-openai |
openai-response, openai-codex |
openai-codex |
hya/provider-grok |
grok-build |
grok-build |
profile = "full" (the default) enables every installed provider bundle. hya --bare and profile = "bare" enable none, so only openai (and the offline hya/offline model) routes; list an id under enable to add its kinds back:
[bundles.builtin]profile = "bare"enable = ["hya/provider-anthropic"]The hya --bare flag replaces the whole built-in selection, including
enable. Changes to the enabled provider bundles apply on the next start.
Saved OAuth credentials refresh through the bundle that registers their type.
Unsupported providers
A provider is unsupported when its kind is unregistered or its saved OAuth
credential has an unsupported type. An unregistered per-model kind skips
the affected model while other servable models can still route. That happens when its provider bundle is disabled or its library is missing from the install. An unsupported provider gets no route and no models, but every other provider still works. Startup prints the reason on stderr and names the provider bundles that did not load, for example:
hya: provider claude: kind `anthropic` is not provided by any enabled bundle (enabled kinds: openai, openai-compatible, openai-completion; provider bundles not loaded: hya/provider-anthropic (disabled), hya/provider-google (disabled), hya/provider-openai (disabled), hya/provider-grok (disabled))hya model list does not list its models, and the /v2 provider summary reports result: unavailable with that reason as its error. Enable the bundle that provides the kind (or reinstall, for a missing library), or change the kind, and restart.
Adding or editing a provider (/key, hya provider add, PUT /v2/providers/{id}) checks only the kind it writes: an unregistered kind is rejected, and other providers with unregistered kinds do not block the edit.
Switching models and thinking effort
Inside a chat:
/modelopens a searchable model picker showing every provider and context window size. Press Enter to switch./effort(or/think) adjusts how hard reasoning models think before answering (none,low,medium,high,xhigh,max, ordefault).
Hya remembers both choices! When you pick a model for hya-main, future hya-main chats start on that model automatically, and each model remembers your preferred thinking effort across sessions.
Want to assign different models to different built-in agents (for instance, a big reasoning model for planning and a fast model for file scouting)? Open /agent, highlight hya-scout, and press m to set its model and t to set its thinking effort.
You can also pass a one-time thinking suffix anywhere a model name is accepted, like openai/gpt-5#high.
Automatic failover with model roles
Define an ordered list of candidates in config.toml to let Hya select a
working route and fall back when an eligible provider error occurs. For
example, with both providers configured, pin the main agent to @smart.
[roles]smart = ["anthropic/claude-opus-4-6", "openai/gpt-5"]
[agents.hya-main]model = "@smart"Existing [categories] entries also supply candidates. A role with the same
name takes precedence. See the configuration reference
for role aliases, model fields, and retry settings.