Models & roles
bb.WithModel(bb.NewModel().WithName("gpt-4o-mini").WithTemprature(0.5)).WithTag("fast", "cheap")
m := bb.NewModel("fast") // seeded from the registered model
m2 := bb.NewModel("fast").WithTemprature(0.9) // overrides just this use
inline := bb.NewModel().WithName("gpt-4o") // no registry, built inline
demo := bb.FixedModel("canned reply") // no provider — for demos/testsbb.WithModel(m) registers m and returns a handle; .WithTag(…) binds it to lookup tags. bb.NewModel(tags…) is always a builder: with no tags it starts blank, with tags it is seeded from the registered model and stays overridable. Provider credentials come from the environment (BIG_BRAIN_API_KEY, BIG_BRAIN_BASE_URL). Flow code names a role; deployment decides which provider backs it.
Consuming a model through Anthropic's own API
By default a name resolves through the OpenAI-compatible client. To consume a model natively through Anthropic's own API instead:
bb.NewModel().WithName("claude-sonnet-5").WithProvider(bb.AnthropicProvider)WithProvider is the only thing that changes — the same registry, tags, WithTemprature, and inheritance ladder apply either way. WithThink(true) requests extended reasoning mode; only the Anthropic provider honors it (a fixed token budget), OpenAI silently ignores it. This is independent of bb.Serve, which always speaks both the OpenAI and Anthropic wire protocols to callers regardless of which provider a brain consumes.
The resolution ladder
Which model an agent asks is resolved along a ladder, first match wins:
agent.WithModel(m)— the agent's own model.flow.WithModel(m)— the model set on the flow the agent runs in.bb.WithDefaultModel(m)— an explicit process default.- the first
bb.WithModel(…)registered — the implicit default.
So no agent is ever truly model-less; leaving WithModel off just means "use whatever the flow, then the default, provides". A default (no-OnMessage) agent that resolves to no model at any rung is a startup error from bb.Serve — see Serving for the full list of what gets validated at boot.
For a group (Select/All/One/Group), the ladder gains one more rung between an agent and the process default: agent's own → its flow's → nearest enclosing group's → bb.WithDefaultModel → first registered.
One name, several tags
One model can answer to several tags — "fast" and "cheap" can point at the same small model until a real reason emerges to split them:
var register bb.RegisterModel = bb.WithModel(
bb.NewModel().WithName("google/gemma-4-e4b").WithThink(false).WithTemprature(0.3),
)
register = register.WithTag("cheap", "fast")Building models inline (no tag, no registry lookup) is equally valid — tagging is a convenience for reuse across many flows, not a requirement.