Self-Hosted OpenAI-Compatible Entry
Self-hosted unified OpenAI-compatible entry
Section titled “Self-hosted unified OpenAI-compatible entry”When enabled, OmniRoute’s existing /v1/chat/completions (and the OpenAI-compatible
contract it serves) becomes a self-hosted gateway: one OpenAI-compatible request
in, auto-routed to the provider of your choice through the provider adapters, with a
standard OpenAI error shape out. Client code does not change.
This is the D4 (接入即用) differentiator from the RIC-697 design: the same /v1 path
the OpenAI SDK already targets, backed by your own providers instead of a single
vendored catalog.
Enable
Section titled “Enable”Set either env var (see .env.example for both):
OMNIROUTE_SELF_HOSTED_PROVIDERS— inline YAML document (runtime-only, not logged).OMNIROUTE_SELF_HOSTED_PROVIDERS_FILE— path to a YAML file.
providers: - id: local kind: openai # openai | anthropic | local baseUrl: http://127.0.0.1:11434/v1 model: llama3 # apiKey: sk-... # optional, runtime-only - id: claude kind: anthropic baseUrl: http://127.0.0.1:8080 model: claude-sonnetWhen either var is set, the unified entry is active for every request to
/v1/chat/completions. Config present but unparseable returns 500 (it never
silently falls through to cloud routing). When neither is set, the route behaves
exactly as before.
Provider auto-route
Section titled “Provider auto-route”Precedence (deterministic, no predictive model):
x-omniroute-provider: <id>header — exact provider id.modelprefix:provider/model(slash) orprovider::model(double colon).- First configured provider.
The routing prefix is stripped before forwarding — upstream receives the bare model
(claude-sonnet, not claude/claude-sonnet).
# via headercurl http://localhost:20128/v1/chat/completions \ -H "x-omniroute-provider: claude" \ -H "content-type: application/json" \ -d '{"model":"claude-sonnet","messages":[{"role":"user","content":"hi"}]}'
# or via model prefixcurl ... -d '{"model":"claude/claude-sonnet","messages":[...]}'Auth scaffold (D5 reserved)
Section titled “Auth scaffold (D5 reserved)”Optional OMNIROUTE_SELF_HOSTED_API_KEY. When set, requests must carry
Authorization: Bearer <key>. Unset = open route (loopback / trusted network),
mirroring how OmniRoute’s existing local providers work. The D5 quota/quota-自治
key system is expected to take over this header.
Failure contract
Section titled “Failure contract”- Upstream non-2xx body is normalized through
parseUpstreamError+buildErrorBodyinto the standard OpenAIerrorshape (Hard Rule #12 — never raw upstream text). - Network-level failures (connection refused / DNS / TLS) return a normalized
502witherror.message: "Upstream provider unreachable: …". - Credential / session headers echoed upstream are stripped from every response.
tests/unit/self-hosted-entry.test.ts covers provider selection, model-prefix
forwarding, header hygiene, auth, upstream-error normalization, SSE streaming
passthrough, and the fall-through / misconfig paths — all over real HTTP against a
local upstream.
- Self-hosted models bypass the cloud-only retirement / alias machinery by design:
the divert happens before those cloud checks, so ids like
local/llama3never trip cloud-peer 410s or alias rewrites. - Deterministic routing strategies (fallback / cooldown / cost / latency / blacklist)
are M2’s scope (
RIC-740) and inject into the gateway layer here. Configure them with astrategy:block — see DETERMINISTIC_ROUTING.md.
HagiCode
HagiCode はエージェント型コーディングワークスペースです。豊富で便利な UI インタラクションにより、計画・エージェント実行・プロジェクト作業を始めやすく、進めやすくし、開発をより魅力的な体験にします。
豊富で便利な UI インタラクションで、計画からプロジェクト作業までを分かりやすく進められます。
- スマートOpenSpec ワークフローが意図を、提案・設計・タスクから変更のリリースまで実行可能な道筋にします。
- 効率的マルチエージェント実行で調査・実装・レビューを並行して進め、複数リポジトリや使い慣れた Agent CLI にも対応します。
- 興味深い豊富で便利な UI インタラクションにより、計画・エージェント実行・プロジェクト作業を始めやすく、進めやすくします。
Windows 版をダウンロード
HagiCode を共有
アイデアを、出荷できるソフトウェアへ。
HagiCode はエージェント型コーディングワークスペースです。OpenSpec ワークフローで変更を計画し、マルチエージェント実行で進め、Hero Scenario で長い作業の進み具合を見える化して、アイデアを出荷できるソフトウェアにします。
- スマート
- OpenSpec ワークフローが、意図を提案からリリースまでの実行可能な道筋にします。
- 効率的
- マルチエージェント実行で、調査・実装・レビューを並行して進めます。
- 楽しい
- 使いやすい UI で、計画・Agent 実行・プロジェクト作業を進めやすくします。
© 2026 HagiCode | Powered By hagilight-starlight@0.21.0 | Branch: main | Commit: de60bcd | Built:

