ai.wire.resolve_credential
Collapse a client's `ai.Credential?` option to the value to put on the wire, reading the environment at REQUEST time (never at construction).
Signature
Collapse a client's ai.Credential? option to the value to put on the
wire, reading the environment at REQUEST time (never at construction).
- a literal string resolves to itself, unless it is blank — a whitespace-only credential is treated as "not configured" so the rest of the chain can supply one;
- a
baml.env.Refresolves toref.get()—nullwhen the named variable is unset, which lets the caller continue down its own chain (or raise the same error it raises for an unconfigured option); nullfalls back toenv_fallback, the provider's canonical variable name, looked up withbaml.env.get. Anullenv_fallbackmeans the provider has no canonical variable and the result isnull.
A BLANK value is "not configured" at EVERY rung, not just the literal one:
export OPENAI_API_KEY= otherwise resolved to "" and every client built
Authorization: Bearer — a provider 401 in place of the local "no
credential configured" error the same client raises when the variable is
absent entirely. The two spellings of "I did not set this" now behave alike.
This IS the whole chain a client needs: explicit credential (a literal or an
env.NAME ref) → the provider's canonical variable (env_fallback).
Source:<builtin>/ai/ns_wire/wire.bamlbytes 1538–2045