OpenAI-compatible provider #138

Merged
hermes merged 1 commits from openai-compat-provider into main 2026-10-07 08:29:25 +00:00
Collaborator

Adds a generic OpenAI-compatible provider (/chat/completions + /models): Ollama, vLLM, LM Studio, llama.cpp, OpenRouter.

  • Kind::Custom (--provider custom), enabled when [openai_compat] exists in config.toml: base_url, optional api_key_env (env var name, key never in config), optional models list, optional context_window (default 128k; /models fields context_length/max_model_len win).
  • New hx-ai/src/openai_compat.rs: request mapping (system, tool_calls/tool role, images as data URIs, thinking dropped), SSE assembler (chunked tool args, usage incl. cached tokens, reasoning_content/reasoning as thinking), reasoning_effort with one retry without it on 400. Invalid tool-call JSON is passed as {"_invalid_arguments": raw} so the model gets an error and retries.
  • No login, no quota, no pricing; subagents use the main model (no cheap tier). Model list for Custom is never served from cache.
  • Tests: request mapping, stream assembly, /models parsing, real HTTP round trip against a local server, config parse.
Adds a generic OpenAI-compatible provider (`/chat/completions` + `/models`): Ollama, vLLM, LM Studio, llama.cpp, OpenRouter. - `Kind::Custom` (`--provider custom`), enabled when `[openai_compat]` exists in config.toml: `base_url`, optional `api_key_env` (env var name, key never in config), optional `models` list, optional `context_window` (default 128k; `/models` fields `context_length`/`max_model_len` win). - New `hx-ai/src/openai_compat.rs`: request mapping (system, tool_calls/tool role, images as data URIs, thinking dropped), SSE assembler (chunked tool args, usage incl. cached tokens, `reasoning_content`/`reasoning` as thinking), `reasoning_effort` with one retry without it on 400. Invalid tool-call JSON is passed as `{"_invalid_arguments": raw}` so the model gets an error and retries. - No login, no quota, no pricing; subagents use the main model (no cheap tier). Model list for Custom is never served from cache. - Tests: request mapping, stream assembly, `/models` parsing, real HTTP round trip against a local server, config parse.
hermes added 1 commit 2026-10-07 08:17:54 +00:00
hermes merged commit 1952cb41c3 into main 2026-10-07 08:29:25 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#138