Add local Ollama as an AI Hub provider for claude-code

Ollama v0.14+ speaks the Anthropic Messages API natively, so the
registry drives it with a fixed 'ollama' token and runtime-listed
models: static_token skips secret storage everywhere keys resolve,
models_dynamic defers model validation to the live /api/tags list,
and the setup wizard installs the right GPU variant and starts the
service before listing local models. Doctor stops treating the
endpoint port as part of the hostname.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019hLK3wsDuKVAC37GgDqg6H
This commit is contained in:
2026-08-27 15:55:15 -04:00
co-authored by Claude Fable 5
parent 4b280a1767
commit 111b857cda
9 changed files with 73 additions and 11 deletions
+17 -1
View File
@@ -31,6 +31,21 @@ cn_ai_harness_field() {
jq -re --arg h "$1" --arg f "$2" '.harnesses[$h][$f]' "$CN_AI_HARNESSES"
}
# Providers with a fixed token (local servers) need no stored secret.
# `// empty` keeps stdout clean when absent (bare -re would print "null").
cn_ai_static_token() {
jq -re --arg p "$1" '.providers[$p].static_token // empty' "$CN_AI_PROVIDERS"
}
cn_ai_resolve_key() {
cn_ai_static_token "$1" 2>/dev/null || omarchy-cn-ai-secret get "$1"
}
# Dynamic-model providers list models at runtime, not in the registry
cn_ai_models_dynamic() {
jq -e --arg p "$1" '.providers[$p].models_dynamic == true' "$CN_AI_PROVIDERS" > /dev/null
}
cn_ai_combo_level() {
jq -r --arg h "$1" --arg p "$2" '.combos[$h][$p].level // "unsupported"' "$CN_AI_COMPAT"
}
@@ -68,7 +83,8 @@ cn_ai_render_env() {
case "$harness" in
claude-code)
base=$(cn_ai_endpoint "$provider" anthropic)
fast=$(cn_ai_fast_model "$provider")
# Dynamic-model providers have no fast alias: every tier maps to the model
fast=$(cn_ai_fast_model "$provider" 2>/dev/null || printf '%s' "$model")
printf 'export ANTHROPIC_BASE_URL=%q\n' "$base"
# Docs vary between AUTH_TOKEN (deepseek/zai) and API_KEY (kimi): set both
printf 'export ANTHROPIC_AUTH_TOKEN=%q\n' "$key"
+5
View File
@@ -21,6 +21,11 @@
"level": "stable",
"doc": "https://platform.minimax.io/docs/token-plan/claude-code",
"adapter": true
},
"ollama": {
"level": "stable",
"doc": "https://docs.ollama.com/api/anthropic-compatibility",
"adapter": true
}
},
"codex": {
+13 -1
View File
@@ -1,5 +1,5 @@
{
"_verified": "2026-08-25, from official docs (see OmarchyCN PRD §27; minimax: platform.minimax.io/docs/token-plan/claude-code)",
"_verified": "2026-08-27, from official docs (see OmarchyCN PRD §27; minimax: platform.minimax.io/docs/token-plan/claude-code; ollama: docs.ollama.com/api/anthropic-compatibility, fixed token \"ollama\", models are whatever is pulled locally)",
"providers": {
"deepseek": {
"display_name": "DeepSeek",
@@ -124,6 +124,18 @@
}
]
},
"ollama": {
"display_name": "Ollama 本地",
"auth": [
"none"
],
"static_token": "ollama",
"endpoints": {
"anthropic": "http://localhost:11434"
},
"models": [],
"models_dynamic": true
},
"minimax": {
"display_name": "MiniMax",
"auth": [