ai.FunctionSpec
One unit of model work, bound and unrun. Immutable; getters only.
Reference version
Signature
class ai.FunctionSpec<Out>One unit of model work, bound and unrun. Immutable; getters only.
MyFunc@spec(args) calls the compiler-generated private MyFunc@spec
companion. Streaming calls the separate private MyFunc@stream companion.
Neither companion is public.
Source:<builtin>/ai/spec.bamlbytes 4241–6566
Fields
spec_name
stringargs
map<string, unknown>prompt_template
(ai.OutputFormat) -> ai.Prompt throws ai.errors.PromptRenderErrortoolbox
default_client
Instance methods
function
arguments
(self) -> map<string, unknown> throws neverfunction
build_request
(self,
client: ai.Client | null = …
) -> baml.http.Request throws baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure
Builds the provider HTTP request shape for this spec without invoking
the model. client overrides the spec's default; null uses the default.
function
call
<__effect_param_0>(self,
client: ai.Client | null = …,
on_event: ((ai.events.Event) -> void throws __effect_param_0) | null = …
) -> Out throws baml.errors.InvalidArgument | baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure
Runs this bound spec through the default agent. client overrides the
bound client; null keeps it. on_event observes the same journal
events a direct LLM-function call reports.
function
client_id
(self) -> string throws neverfunction
name
(self) -> string throws neverfunction
output_type
(self) -> reflect.Type throws reflect.errors.CompilationErrorfunction
parse
(self, json: string) -> Out throws baml.errors.ParseErrorParses an existing model reply using this spec's realized output type.
function