mirascope.llm.call | Mirascope
MirascopeLilypad

mirascope.llm.call

Alias call

A decorator for making provider-agnostic LLM API calls with a typed function.

Usage

This decorator enables writing provider-agnostic code by wrapping a typed function that can call any supported LLM provider's API. It parses the prompt template of the wrapped function as messages and templates the input arguments into each message's template.

Example:

from ..llm import call


@call(provider="openai", model="gpt-4o-mini")
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"


response = recommend_book("fantasy")
print(response.content)

Parameters

NameTypeDescription
providerProvider | LocalProviderThe LLM provider to use (e.g., "openai", "anthropic").
modelstrThe model to use for the specified provider (e.g., "gpt-4o-mini").
streamboolWhether to stream the response from the API call.
toolslist[BaseTool | Callable]The tools available for the LLM to use.
response_modelBaseModel | BaseTypeThe response model into which the response should be structured.
output_parser(CallResponse | ResponseModelT) => AnyA function for parsing the call response whose value will be returned in place of the original call response.
json_modeboolWhether to use JSON Mode.
clientobjectAn optional custom client to use in place of the default client.
call_paramsCommonCallParamsProvider-specific parameters to use in the API call.

Returns

TypeDescription
CallableA decorator that transforms a typed function into a provider-agnostic LLM API call that returns standardized response types regardless of the underlying provider used.

Alias to: mirascope.llm._call.call