Skip to main content

Crate yapi_ai

Crate yapi_ai 

Source
Expand description

LLM wire APIs, model catalog and registry, cost tracking, credentials and OAuth. An internal library of yapi, with no stable API.

Modules§

api
Wire API implementations, one per API id, and dispatch by model.
auth
Provider authentication: the auth.json credential store, OAuth sign-in and refresh, and the interaction a sign-in uses to talk to the user.
aws
AWS credentials, request signing and event streams for Amazon Bedrock.
catalog
The built-in model catalog, generated from pi-ai’s data by cargo xtask models.
cost
Request cost from token usage.
credentials
Credential values: $VAR and ${VAR} templates, !command output, and the environment variables each provider reads.
errors
Classifying failed responses: context overflow, recoverable truncation, and transient errors worth retrying.
faux
A scripted provider for tests: replays canned responses as streams.
hash
pi’s shortHash, used to derive stable ids from longer ones.
http
HTTP transport shared by the wire APIs: client, retries, cancellation, errors.
json_parse
Lenient JSON parsing for model output: tool-call arguments and server-sent event payloads.
key_auth
API-key credentials of the providers whose setup is more than one key in one environment variable: Amazon Bedrock, Google Vertex AI, the two Cloudflare providers, llama.cpp, and Anthropic’s workload identity federation.
llama
llama.cpp: a local llama-server in router mode as a provider. Its loaded models are chat models over the OpenAI-compatible API and classifiers over llama-cpp-classify.
model_catalog
Model catalogs that change after a release: pi.dev’s catalog overlay for built-in providers, and the catalogs of Radius gateways. Refreshed catalogs persist in models-store.json, so later startups have them offline.
providers
Built-in provider names and the authentication methods each declares.
registry
The models yapi can use and the credentials to use them.
schema
Constrained sampling for tools: strict JSON-schema parameters, and OpenAI grammar-constrained custom tools.
sse
Server-sent events decoding, as the provider SDKs pi uses decode them.
stream
Streaming one assistant message from a provider.
thinking
Thinking levels and output token budgets.
transcript
The transcript a provider receives: messages in which system messages hold the prompt and tool declarations.
validation
Tool argument validation: coerce what models commonly get wrong, then check the JSON schema with TypeBox’s error messages.