Implementation:0xNyk Council of high intelligence detect providers sh
| Knowledge Sources | |
|---|---|
| Domains | CLI_Integration, Provider_Detection, Scripting |
| Last Updated | 2026-10-20 00:00 GMT |
Overview
Concrete bash script for detecting available LLM providers and emitting a structured JSON manifest to stdout, provided by the Council of High Intelligence project.
Description
detect-providers.sh is a POSIX-compatible bash script that probes the system for available LLM providers (Anthropic, OpenAI/Codex, Google/Gemini, Ollama, Cursor, NVIDIA NIM) and outputs a JSON manifest with each provider's availability, exec method, binary path, and available models. The coordinator consumes this JSON in STEP 1 to decide routing.
The script uses a perl-based timeout implementation (`run_with_timeout`) for macOS compatibility (no coreutils `timeout` required). Provider detection ranges from simple `--version` checks (codex, gemini, cursor) to API key + endpoint reachability checks (NIM) to model list parsing (ollama). Anthropic is always available (host runtime).
Usage
Run this script when:
- The coordinator needs to detect available providers for auto-routing (STEP 1, Path B)
- The simulation checklist verifies JSON output validity
- Testing provider availability in CI
Code Reference
Source Location
- Repository: Council of High Intelligence
- File: scripts/detect-providers.sh
- Lines: L1-147 (full script)
Signature
# Helper functions:
json_provider(name: str, available: bool, exec_method: str, binary: str, models: str) -> JSON string
check_command(cmd: str) -> str # returns binary path or empty
run_with_timeout(timeout: int, cmd: str...) -> int # perl-based, macOS-compatible
# Provider probes:
# anthropic: always available (subagent)
# openai: codex --version check (codex_exec)
# google: gemini --version check (gemini_cli)
# ollama: ollama list + model parsing (ollama_run)
# cursor_cli: cursor-agent --version check (cursor_cli)
# nvidia_nim: NVIDIA_API_KEY env + nvapi- prefix + optional curl (openai_compatible_api)
# Output JSON shape:
# {"providers":[...], "provider_count":N, "multi_provider":bool}
Import
# Run directly:
bash ~/.claude/skills/council/scripts/detect-providers.sh
# Or from the repo:
bash scripts/detect-providers.sh
# Output to stdout (JSON):
# {"providers":[{"name":"anthropic","available":true,"exec_method":"subagent","binary":"native","models":["opus","sonnet","haiku"]},...],"provider_count":3,"multi_provider":true}
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| NVIDIA_API_KEY | env var | No | NVIDIA NIM API key (must start with `nvapi-`) |
| CURSOR_API_KEY | env var | No | Cursor CLI auth (handled by cursor-agent itself) |
| PATH | env | Yes | System PATH for binary discovery |
Outputs
| Name | Type | Description |
|---|---|---|
| JSON manifest | str (stdout) | Provider availability manifest |
| providers | array | Each: {name, available, exec_method, binary, models[]} |
| provider_count | int | Number of available providers |
| multi_provider | bool | true if provider_count >= 2 |
Usage Examples
Basic Run
$ bash scripts/detect-providers.sh
{"providers":[
{"name":"anthropic","available":true,"exec_method":"subagent","binary":"native","models":["opus","sonnet","haiku"]},
{"name":"openai","available":true,"exec_method":"codex_exec","binary":"/usr/local/bin/codex","models":["gpt-5.4"]},
{"name":"google","available":false,"exec_method":"gemini_cli","binary":"not_found","models":[]},
{"name":"ollama","available":true,"exec_method":"ollama_run","binary":"/usr/local/bin/ollama","models":["llama3","qwen2.5"]},
{"name":"cursor_cli","available":false,"exec_method":"cursor_cli","binary":"not_found","models":[]},
{"name":"nvidia_nim","available":false,"exec_method":"openai_compatible_api","binary":"https://integrate.api.nvidia.com/v1","models":[]}
],"provider_count":3,"multi_provider":true}
Consuming in the Coordinator
# The coordinator runs this via Bash tool in STEP 1:
detect_json=$(bash ~/.claude/skills/council/scripts/detect-providers.sh)
provider_count=$(echo "$detect_json" | jq -r '.provider_count')
if [ "$provider_count" -ge 2 ]; then
# Apply auto-routing algorithm
echo "Multi-provider detected, routing seats..."
else
# Single provider (Claude-only), skip routing
echo "Single provider, using frontmatter defaults."
fi
With NVIDIA NIM Available
# Set the env var first:
export NVIDIA_API_KEY="nvapi-xxxxx"
bash scripts/detect-providers.sh | jq '.providers[] | select(.name == "nvidia_nim")'
# {
# "name": "nvidia_nim",
# "available": true,
# "exec_method": "openai_compatible_api",
# "binary": "https://integrate.api.nvidia.com/v1",
# "models": ["deepseek-ai/deepseek-v4-pro","moonshotai/kimi-k2.6",...]
# }