Skip to main content

llm_ping_impl

Function llm_ping_impl 

Source
pub fn llm_ping_impl(lua: &Lua, opts: Option<Table>) -> Result<Table>
Expand description

Executes a lightweight connectivity check against the LLM provider.

Sends a single HTTP GET to the provider’s health endpoint and measures round-trip latency. Does not consume tokens or create sessions.

§Arguments (from Lua)

  • opts - Optional table:
    • provider - “ollama” (default), “openai”, “anthropic”
    • base_url - Provider base URL (default per provider)
    • api_key - API key (falls back to env var)
    • timeout - Timeout in seconds (default: 5)

§Returns (Lua table)

  • ok - boolean (true if HTTP response received, even non-2xx)
  • provider - Provider name string
  • base_url - Resolved base URL
  • latency_ms - Round-trip time in milliseconds
  • status - HTTP status code (when response received)
  • error - Error message (when ok=false)
  • error_kind - Error classification (when ok=false)