No one wants to see
output = client.chat.completions.create(...).choices[0].message.content.heavenbase.llm.default_provider chooses where that model is served. Explicit provider= arguments and provider pins on a preset still override the default provider.
1. Set an API Key
HeavenBase ships with built-in configs for these providers. Set the relevant environment variables or usehb cfg set:
default_provider can take effect:
hb cfg set heavenbase.llm.providers.<provider>.base_url for any OpenAI-compatible provider, and hb cfg set heavenbase.llm.providers.<provider>.api_key if the provider doesn’t use the standard environment variable. Local providers (ollama, lmstudio, omlx, and vllm) accept provider-specific model IDs too; the curated qwen3.6-flash entry maps to each local provider’s configured name. For provider-pinned local defaults, use preset="local" or preset="worker-local" for LM Studio qwen3.6-flash, preset="imagen-local" for Ollama x/z-image-turbo, and preset="ocr-local" for Ollama glm-ocr.
Any LiteLLM-compatible provider can be added via config. See the LLM overview for the complete provider and model catalog.
2. CLI Chat
Send a message. By default this uses thechat preset with deepseek-v4-flash on your configured default_provider (openrouter out of the box):
--preset:
--preset/-p: use a named preset (system,chat,reason,coder,local,worker-local,embed,embed-local,imagen-local,ocr-local, …)--model/-m: override the model (ds-flash,sonnet,gpt, … support canonical model names or defined aliases)--provider/-b: override the provider (openrouter,openai,anthropic, …)--verbose/-v: show the resolved LLM spec including model, provider, gateway, args, etc.--input/-i: read the prompt from a file
The
chat preset is used by hb llm chat and hb llm session. The default hb.LLM() (no preset) uses system, a lightweight preset for short orchestration calls. The embed preset controls hb llm embed and uses text-embedding-3-small; set heavenbase.llm.presets.embed.provider when your default provider does not serve embeddings.3. CLI Embeddings
The embed preset defaults totext-embedding-3-small (1536 dimensions). It uses your default_provider unless you pin an embedding provider.
Configuring an embedding provider is similar to chat, just set the embed preset’s provider and model.
--preview when you only want a compact inspection view. Preview mode shows the first 4 and last 2 values, rounded to 6 decimals:
--json for the full response object including usage. --json --preview keeps the same keys but replaces embeddings with the abbreviated string:
--copy / -cp on hb llm chat or hb llm embed when you want the emitted response copied to the clipboard.
4. Interactive Session
Start a multi-turn session:chat preset. Type messages at the >>> prompt. Example:
/help, /save <path>, /load <path>, /clear, /regen <seed>, /back, /tools, /mcp, /exit.
For attaching MCP tools in sessions, see the First MCP chapter in the quickstart.
5. Python API
5.1. The LLM Class
hb.LLM is the Python API behind the hb llm CLI. Construct one with no arguments to use the system preset, or pass a preset, model, provider, gateway, or request defaults:
The
LLM constructor accepts preset, model, provider, gateway, and extra keyword arguments such as temperature, max_tokens, or seed. Extra keyword arguments become provider request defaults. For normal chat presets, the model comes from heavenbase.llm.presets.<name>.model, while the provider comes from heavenbase.llm.default_provider unless the preset explicitly pins a provider.5.2. LLM Gateways
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 supports six gateway keys:heavenbase.llm.default_gateway defaults to openai. It is used only when the call, preset, or provider does not pin a gateway. Set it globally with hb cfg set heavenbase.llm.default_gateway <gateway>, or override it for one instance with hb.LLM(..., gateway="...").
The chat preset resolves to deepseek-v4-flash through the openrouter provider unless you change the preset’s model or provider. Because OpenRouter exposes an OpenAI-compatible API, the default openai gateway can use hb.LLM(preset="chat") directly.
5.3. Exporting Clients
An OpenAI-compatibleLLM instance can export a raw openai.OpenAI or openai.AsyncOpenAI client. The exported client carries the resolved client construction settings: API key, base URL, headers, timeout, and retry policy. It does not go through HeavenBase’s chat, stream, embedding, or image helpers.
Use to_client() or to_aclient() for the SDK client. Use to_args() for the resolved request arguments, including the provider-facing model name and request defaults. This split is useful when an external SDK owns the call loop but you still want HeavenBase to own model, provider, gateway, and credential resolution.
to_client(), to_aclient(), and to_args() are for OpenAI-compatible client exports: openai, portkey, or bifrost. They raise ValueError for litellm, anthropic, and mock gateways. The OpenAI Agents SDK tab is an integration pattern; install openai-agents before running it.anthropic.Anthropic or anthropic.AsyncAnthropic client instead:
OpenAI-compatible chat completions use
POST /v1/chat/completions, request fields such as model and messages, and responses shaped around choices[0].message.content plus token usage fields. Anthropic-compatible chat uses POST /v1/messages, request fields such as model, max_tokens, messages, and optional top-level system, and responses shaped around typed content blocks, stop_reason, and usage.input_tokens / usage.output_tokens.
