ProviderAdapter
Category: Providers
Source: provider_adapter.dart
The single interface every LLM provider lives behind.
A [ProviderAdapter] answers three questions:
- Can this provider talk to anything? (
validate) - Give me a streaming client for this model. (
createClient) - Optionally: what models does this endpoint advertise? (
discoverModels)
[discoverModels] is explicitly opt-in — never invoked during startup. Glue prefers a curated, bundled catalog over live provider discovery.
Enums
ProviderHealth
| Value | Description |
|---|---|
ok | |
missingCredential | |
unknownAdapter |
Classes
DiscoveredModel
Constructor
dart
const DiscoveredModel({required this.id, required this.name})Properties
| Property | Type | Description |
|---|---|---|
id | String | |
name | String |
abstract ProviderAdapter
Properties
| Property | Type | Description |
|---|---|---|
adapterId | String get | |
adapterId | String get |
Methods
ProviderHealth validate(ResolvedProvider provider)
`LlmClient createClient({
required ResolvedProvider provider,
required ResolvedModel model,
required String systemPrompt,
})`
`Future<List<DiscoveredModel>> discoverModels(
ResolvedProvider provider,
)`
Only invoked by explicit user commands (e.g. /models refresh). Must never run during startup — Glue ships a curated catalog instead.
`Future<AuthFlow?> beginInteractiveAuth({
required ProviderDef provider,
required CredentialStore store,
})`
Produce the interactive flow the /provider add UI should display.
Default implementation:
- [AuthKind.none] → returns null (nothing to do).
- [AuthKind.apiKey] → returns an [ApiKeyFlow] pre-filled from env.
- [AuthKind.oauth] → throws [UnimplementedError]; OAuth adapters must override to drive a device-code or PKCE flow.
bool isConnected(ProviderDef provider, CredentialStore store)
Is this provider connected (has usable credentials)?
Default covers [AuthKind.none] (always true) and [AuthKind.apiKey] (env or stored api_key resolves). OAuth adapters must override.
AdapterRegistry
Constructor
dart
AdapterRegistry(Iterable<ProviderAdapter> adapters)Properties
| Property | Type | Description |
|---|---|---|
registered | Iterable<String> get | |
registered | Iterable<String> get |