Learn R Programming

aisdk (version 1.1.0)

check_api: Connect and Diagnose API Reachability

Description

Tests connectivity to a specific LLM, provider, or URL. This is helpful for diagnosing network issues, DNS failures, or SSL problems.

Usage

check_api(model = NULL, url = NULL, registry = NULL)

Value

A list containing diagnostic results (invisible).

Arguments

model

Optional. A LanguageModelV1 object, or a provider name string (e.g., "openai", "gemini"). If provided, the base URL for that provider will be tested.

url

Optional. A specific URL to test.

registry

Optional ProviderRegistry to use if model is a character string.

Examples

Run this code
# \donttest{
if (interactive()) {
    # Test by passing a URL directly
    check_api(url = "https://api.openai.com/v1")

    # Test a model directly
    model <- create_openai()$language_model("gpt-4o")
    check_api(model)
}
# }

Run the code above in your browser using DataLab