Files
hermes-agent/tools/openrouter_client.py
Teknium d4cec15b47 refactor(tools): first-wave simplification of tools/ (file ops split, lazy_deps, code_exec, approval, browser, delegate, mcp, skills, terminal, voice, media)
Behavior-neutral structural pass over tools/*: god-file extractions into
sibling modules (file_operations_common/lint/search, file_tools_paths/
read_tracking/write, code_execution_env/rpc, tool_search_catalog/names/
validation, tts_command_provider, ...), duplicate helper unification,
if/elif -> dispatch tables, dead-code removal, docstring compaction.
Tool schemas (get_tool_definitions) verified byte-identical to base.
2026-09-02 14:43:45 -07:00

22 lines
590 B
Python

"""OpenRouter API key probe shared by Hermes tools."""
import os
def check_api_key() -> bool:
"""Return True if OPENROUTER_API_KEY is present.
Scope-aware: an installed profile secret scope is authoritative under
multiplex; unscoped CLI probes fall back to the plain env read.
"""
try:
from agent.secret_scope import UnscopedSecretError, get_secret
try:
return bool(get_secret("OPENROUTER_API_KEY"))
except UnscopedSecretError:
pass
except Exception:
pass
return bool(os.getenv("OPENROUTER_API_KEY"))