Skip to main content
Most LLM APIs accept parameters such as temperature, max tokens, and seed. Mellea exposes these through the ModelOption enum, which works uniformly across all backends, and also lets you pass backend-native keys directly. Prerequisites: pip install mellea complete, a backend available (see Installation).

The ModelOption enum

Import ModelOption from mellea.backends. The enum provides cross-backend names for the most common parameters:
Options set on the backend apply to every call on that session. Options passed to a specific m.* call apply only to that call and take precedence over the session-level values. You can also pass backend-native key names directly — Mellea forwards any key it does not recognize to the underlying API unchanged. This means you can copy model option dicts from existing codebases without translation:

Precedence rules

When the same option is set in multiple places, the following rules apply:
  1. A ModelOption key always takes precedence over its backend-native equivalent.
  2. Options passed to a m.* call override the corresponding session-level options for that call only.

Pushing and popping model state

Sessions support temporarily overriding model options for a series of calls, then restoring the original state:
This is useful when you need deterministic output for a batch of calls within a larger, non-deterministic session.

System prompts

Set a system prompt with ModelOption.SYSTEM_PROMPT. At session level it applies to all subsequent calls; at call level it applies only to that call.
Using ModelOption.SYSTEM_PROMPT is recommended over constructing a system-role message manually. Some backend APIs do not serialize system-role messages correctly and expect the system prompt as a separate parameter — ModelOption.SYSTEM_PROMPT handles this correctly across all backends.