LiteLLMChatModel

class opik.evaluation.models.LiteLLMChatModel(model_name: str = 'gpt-5-nano', must_support_arguments: List[str] | None = None, track: bool = True, **completion_kwargs: Any)

Bases: OpikBaseModel

__init__(model_name: str = 'gpt-5-nano', must_support_arguments: List[str] | None = None, track: bool = True, **completion_kwargs: Any) None

Initializes the base model with a given model name.

Parameters:

model_name – The name of the LLM to be used.

property supported_params: Set[str]
generate_string(input: str, response_format: Type[BaseModel] | None = None, **kwargs: Any) str

Simplified interface to generate a string output from the model. You can find all possible completion_kwargs parameters here: https://docs.litellm.ai/docs/completion/input

Parameters:
  • input – The input string based on which the model will generate the output.

  • response_format – pydantic model specifying the expected output string format.

  • kwargs – Additional arguments that may be used by the model for string generation.

Returns:

The generated string output.

Return type:

str

generate_chat_completion(messages: List[ConversationDict], response_format: Type[BaseModel] | None = None, **kwargs: Any) ConversationDict

Generate the assistant turn from a list of chat messages forwarded to the provider verbatim.

Use this when you want a stable system prefix across calls so that provider-side prompt caching can take effect (judge metrics, suite evaluators).

Parameters:
  • messages – A list of {"role": ..., "content": ...} dictionaries.

  • response_format – Optional Pydantic model specifying the expected output format.

  • kwargs – Additional arguments forwarded to litellm.completion.

Returns:

{"role": "assistant", "content": ...}.

generate_provider_response(messages: List[Dict[str, Any]], **kwargs: Any) ModelResponse

Do not use this method directly. It is intended to be used within base_model.get_provider_response() method.

Generate a provider-specific response. Can be used to interface with the underlying model provider (e.g., OpenAI, Anthropic) and get raw output. You can find all possible input parameters here: https://docs.litellm.ai/docs/completion/input

Parameters:
  • messages – A list of messages to be sent to the model, should be a list of dictionaries with the keys “content” and “role”.

  • kwargs – arguments required by the provider to generate a response.

Returns:

The response from the model provider, which can be of any type depending on the use case and LLM.

Return type:

Any

async agenerate_string(input: str, response_format: Type[BaseModel] | None = None, **kwargs: Any) str

Simplified interface to generate a string output from the model. Async version. You can find all possible input parameters here: https://docs.litellm.ai/docs/completion/input

Parameters:
  • input – The input string based on which the model will generate the output.

  • response_format – pydantic model specifying the expected output string format.

  • kwargs – Additional arguments that may be used by the model for string generation.

Returns:

The generated string output.

Return type:

str

async agenerate_chat_completion(messages: List[ConversationDict], response_format: Type[BaseModel] | None = None, **kwargs: Any) ConversationDict

Async counterpart of generate_chat_completion().

async agenerate_provider_response(messages: List[Dict[str, Any]], **kwargs: Any) ModelResponse

Do not use this method directly. It is intended to be used within base_model.aget_provider_response() method.

Generate a provider-specific response. Can be used to interface with the underlying model provider (e.g., OpenAI, Anthropic) and get raw output. Async version. You can find all possible input parameters here: https://docs.litellm.ai/docs/completion/input

Parameters:
  • messages – A list of messages to be sent to the model, should be a list of dictionaries with the keys “content” and “role”.

  • kwargs – arguments required by the provider to generate a response.

Returns:

The response from the model provider, which can be of any type depending on the use case and LLM.

Return type:

Any