ai.clients.resolve

Resolve a `Selector` to the client to call, at CALL time.

Reference version

Signature

function ai.clients.resolve(
) -> ai.Client throws ai.errors.InvalidRequest | baml.errors.Io | baml.errors.ParseError

Resolve a Selector to the client to call, at CALL time.

  • a ai.Client is returned unchanged (identity);
  • a string is the "provider/model" shorthand, constructed here — the runtime twin of the compiler's literal-client: lowering. An unknown prefix throws ai.errors.InvalidRequest listing the valid ones;
  • a baml.env.Ref is read now and its value takes the string path. An UNSET variable is a typed ai.errors.InvalidRequest naming it — not a panic, so a catch_all at the call boundary can still fall back.

This is what makes client: env.MODEL.get() ?? "openai/gpt-4o-mini" work: nothing about the selection is decided until the call happens.

Source:<builtin>/ai/ns_clients/clients.bamlbytes 1552–2412