providerping

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package providerping does the minimum possible real check of whether a configured provider account is actually reachable and authorized right now — a "list models" call (the same convention nearly every one of these APIs supports), never a real completion request. It exists so the CLI's accounts screen can show a real, current status instead of just "a key is set" — a key can be present and still be rate-limited, revoked, or pointed at a provider having an outage, and a chat request is the only way to actually find that out before this existed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Status  Status
	Latency time.Duration
	// Detail is a short, human-readable explanation — empty for a clean
	// StatusOK, set for anything else ("429 sem cota", "401 chave
	// inválida", "latência alta", ...).
	Detail string
}

Result is one provider's current, real status.

func Ping

func Ping(ctx context.Context, kind, baseURL, apiKey string) Result

Ping makes one minimal request against kind's API (anthropic, gemini, openai-compat, or openai-responses) using apiKey, and classifies the result. baseURL, if empty, uses each kind's public default — the same convention internal/provider's adapters already use. Every kind here has exactly one real auth shape (see internal/oauthflow/anthropic.go's doc comment for why an Anthropic account connected via browser login still ends up with a plain, permanent API key rather than needing a second auth mode here).

type Status

type Status int

Status is a ping's outcome, coarse enough to map directly to a colored dot in the UI.

const (
	StatusUnknown  Status = iota // never pinged yet
	StatusOK                     // responded quickly and successfully
	StatusDegraded               // responded, but slowly, or with a soft issue
	StatusDown                   // auth failure, rate-limited, unreachable, or a server error
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL