Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI Shell Team Aish check connectivity for provider

From Leeroopedia
Knowledge Sources
Domains Configuration, API_Integration, Verification
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tool for verifying LLM provider connectivity and tool-calling support provided by the aish-shell wizard module.

Description

The check_connectivity_for_provider and check_tool_support_for_provider functions perform two-layer verification during setup. Layer 1 sends a minimal chat completion request to confirm the endpoint is reachable, the API key is valid, and the model exists. Layer 2 sends a request with tool definitions to confirm the model supports function calling.

Both functions route to provider-specific implementations based on the provider key: Anthropic uses the messages API, Codex with no API key uses OAuth, Codex with an API key uses the responses API, and all others use the OpenAI-compatible completions API. Results include latency measurement and clear error messages.

Usage

Call these functions during the setup wizard's verification step, after the user has selected a provider, entered credentials, and chosen a model. The connectivity check should pass before the tool support check is attempted.

Code Reference

Source Location

  • Repository: aish
  • File: crates/aish-shell/src/wizard/verification.rs

Signature

pub fn check_connectivity_for_provider(
    provider_key: &str,
    api_base: &str,
    api_key: &str,
    model: &str,
    timeout_s: u64,
    codex_auth_path: Option<&std::path::Path>,
) -> ConnectivityResult

pub fn check_tool_support_for_provider(
    provider_key: &str,
    api_base: &str,
    api_key: &str,
    model: &str,
    timeout_s: u64,
    codex_auth_path: Option<&std::path::Path>,
) -> ToolSupportResult

pub struct ConnectivityResult {
    pub ok: bool,
    pub error: Option<String>,
    pub latency_ms: Option<u64>,
}

pub struct ToolSupportResult {
    pub supports: bool,
    pub error: Option<String>,
}

Import

use crate::wizard::verification::{
    check_connectivity_for_provider, check_tool_support_for_provider,
    ConnectivityResult, ToolSupportResult,
};

I/O Contract

Inputs

Name Type Required Description
provider_key &str Yes Provider identifier for dialect routing
api_base &str Yes API endpoint URL
api_key &str Yes Auth token
model &str Yes Model name to test
timeout_s u64 Yes Request timeout in seconds
codex_auth_path Option<&Path> No OAuth token path for Codex

Outputs

Name Type Description
connectivity ConnectivityResult ok flag, error message, latency in ms
tool_support ToolSupportResult supports flag (model supports tool calling), error message

Usage Examples

Full Verification

use crate::wizard::verification;

let conn = verification::check_connectivity_for_provider(
    &provider.key, &api_base, &api_key, &model, 15, None,
);

if conn.ok {
    println!("Connected in {}ms", conn.latency_ms.unwrap_or(0));
    let tools = verification::check_tool_support_for_provider(
        &provider.key, &api_base, &api_key, &model, 30, None,
    );
    if tools.supports {
        println!("Model supports tool calling");
    }
} else {
    eprintln!("Connection failed: {:?}", conn.error);
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment