ai-sdk-ping
v0.1.1
Published
Ping an AI SDK LanguageModel to verify it is reachable and correctly configured.
Readme
ai-sdk-ping
Ping a AI SDK LanguageModel to verify it is reachable and correctly configured.
Why
Before committing a model instance to a long-running task or application startup, you may want to confirm that credentials, endpoint, and model ID are all valid.
ping sends the smallest possible request, aborts the stream the moment the provider responds, and returns a plain boolean — keeping latency and cost to a minimum.
Installation
npm install ai-sdk-pingUsage
import { openai } from "@ai-sdk/openai";
import { ping } from "ai-sdk-ping";
const model = openai("gpt-5.2-chat");
const reachable = await ping(model);
if (reachable) {
// `model` is verified reachable — reuse it with confidence.
}Works with any AI SDK-compatible provider:
import { anthropic } from "@ai-sdk/anthropic";
import { ping } from "ai-sdk-ping";
const reachable = await ping(anthropic("claude-opus-4-6"));