Skip to main content
Local and hosted providers, six gateways, one client. The resolution model does the remembering for you.
hb.LLM is the HeavenBase Python client for chat, streaming, embeddings, image generation, mocks, and gateway routing. It resolves a preset, model, provider, and gateway from the shared heavenbase.llm config, then materializes the request format selected by the gateway. The default is preset="system", default_provider="openrouter", and gateway="openai". One API key covers most major models out of the box.

1. Resolution Model

HeavenBase never asks you to hardcode a provider SDK call. Instead, four config-backed concepts resolve every request:
  • preset: a named shortcut such as system, chat, reason, coder, embed, imagen, mock, or custom.
  • model: a canonical model key or alias such as ds-flash, sonnet, gpt, or gpt-image-mini.
  • provider: where the model is served. Normal presets inherit heavenbase.llm.default_provider; explicit provider= and preset-level provider pins override it.
  • gateway: how the request is transported. The default openai gateway uses the OpenAI Python SDK against OpenAI-compatible endpoints; anthropic uses the official Anthropic SDK and native Messages payloads.
The resolution path is preset -> model -> provider -> gateway. The final URL comes from provider.base_url, gateway.base_url, or a call-time base_url=... override.
Unknown keyword arguments become provider request defaults, so tuning lives in the call, not in a wrapper:

2. Presets

Presets use persistable model aliases so user configs stay compact and readable. Most production presets do not pin a provider; changing heavenbase.llm.default_provider switches them together. Local and special presets such as local, worker-local, embed-local, imagen-local, ocr-local, mock, and custom keep their own provider because they require a dedicated setup. Preset thinking defaults use the canonical think option. HeavenBase applies gateway-level control through extra_body.reasoning for both think=True and think=False on the OpenAI-compatible gateways (openai, portkey, bifrost, and litellm). The anthropic gateway maps think=True to Claude Messages adaptive thinking with summarized display, maps reasoning_effort to Anthropic effort, and normalizes native thinking blocks back to the think include field. See LLM Chat for the per-call thinking controls.

3. Curated Model Catalog

Online bundled models include OpenRouter identifiers and direct-provider identifiers where available. The root default_provider chooses which identifier is used unless a call or preset pins another provider. Local-only entries, such as embeddinggemma, z-image-turbo, and glm-ocr, list only local providers. mock and custom are utility model entries for offline tests and caller-supplied OpenAI-compatible providers. embed-v4.0 and voyage-4-lite are embedding-only catalog entries served by their own providers (not OpenRouter). z-image-turbo is an Ollama-only local entry, while glm-ocr can resolve through Ollama or oMLX. For the full provider list and per-provider setup, see LLM providers.

4. Gateways at a Glance

A gateway is the transport adapter HeavenBase uses after it resolves the preset, model, and provider. The provider decides where the model is served; the gateway decides how the request is sent. heavenbase.llm.default_gateway defaults to openai and is used only when the call, preset, or provider does not pin a gateway. If a non-default gateway cannot be imported by the active environment, hb.LLM falls back to the openai gateway so a missing optional dependency never breaks resolution. See Advanced LLM for gateway materialization, thinking control, client exports, and the temporary upstream limitations per gateway.

5. What Lives Where

The LLM section is organized so each page adds one layer of capability:
  • LLM Chatchat, stream, message inputs, multimodal images, response projection, and reasoning controls.
  • Embeddingsembed, batching, deduplication, cache, and local embedding providers.
  • Tool Use — schema-only and executable tools, MCP Toolkits, structured output, and CLI tool loops.
  • Sessions — the stateless design, LLMSession, CLI sessions, and resolved-spec inspection.
  • Advanced LLM — gateways, response caching, client exports, image generation, LLMImage, tool-call repair, and async APIs.

Further Exploration

Related resources:
  • First LLM - install, set an API key, and run your first chat, embed, and session from the CLI.
  • LLM providers - the full provider catalog and per-provider configuration.
  • Configuration - the heavenbase.llm config tree behind presets, providers, and gateways.