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
ImportModelOption from mellea.backends. The enum provides cross-backend names
for the most common parameters:
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:- A
ModelOptionkey always takes precedence over its backend-native equivalent. - 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:System prompts
Set a system prompt withModelOption.SYSTEM_PROMPT. At session level it applies to all
subsequent calls; at call level it applies only to that call.
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.