MINARA

Set preferred provider (hot-swap)

PUT /v1/auth/preferred-provider — Set or clear the preferred provider override. Live-probes the selected credential before persisting; returns 400 `reauth

PUT /v1/auth/preferred-provider

Set or clear the preferred provider override. Live-probes the selected credential before persisting; returns 400 reauth_required when the profile is configured but the credential is stale.

On success, ALSO performs an in-process hot-swap: rebuilds the LLM client for the new provider via selectProvider + createLLMClient and atomically updates LLMRouter (the single source of truth). Long-lived consumers (AgentLoop, ScenarioClassifier, ChartBuilder, …) receive a live Proxy and pick up the new client on next createMessage. AgentLoop snapshots the client at turn entry, so a turn in flight when the swap lands finishes on the OLD provider (no split conversation); the NEXT turn uses the new provider.

Model: auto-picks defaultModelForProvider(newKind) since model ids are provider-scoped (grok-4 only works on xAI, gpt-5 only on OpenAI). The new model is persisted under the defaultModel slot keyed by the new provider, so the next boot starts on the same pair.

Response: { ok, preferredProvider, activeModel, swapped, inflightOnOldProvider }. swapped: false indicates the preference was persisted but the in-process rebuild failed (e.g. credentials disappeared between probe and rebuild); the next gateway boot still picks up the persisted preference.

MethodPUT
Path/v1/auth/preferred-provider
AuthAuthorization: Bearer <token> required
Categoryauth

Request body

{ "provider": ProviderKind | null }

On this page