Skip to Content

Model Entity

The Model entity stores an LLM configuration on the platform: the provider, model name, and API key. Once saved, a model can be set as a default for generation or evaluation, and converted into a ready-to-use LLM instance.

Note: The Model entity is different from the Models module. The entity stores configurations on the platform; the module provides the LLM clients that make API calls.

Models use the shared entity interface for fetching, filtering, updating, and deleting.

Creating a model

Pass a provider name and the SDK resolves it to the correct provider type on push(). Set model_type="embedding" for embedding models (the default is "language"):

create_model.py
from rhesis.sdk.entities import Model

model = Model(
    name="GPT-4 Production",
    provider="openai",
    model_name="gpt-4",
    key="sk-..."
)
model.push()
print(f"Created model: {model.id}")

Models.list_providers() returns the provider names accepted by provider:

list_providers.py
from rhesis.sdk.entities import Models

providers = Models.list_providers()
print(providers)
# ['openai', 'anthropic', 'gemini', 'mistral', ...]

Fetching models

fetch_models.py
from rhesis.sdk.entities import Models

# All models
for m in Models.all():
    print(f"{m.name}: {m.provider}/{m.model_name}")

# By name (case-insensitive) or ID
model = Models.pull(name="GPT-4 Production")

Setting default models

Mark a saved model as the default for a task. This updates your user settings:

set_defaults.py
model = Models.pull(name="GPT-4 Production")

model.set_default_generation()   # test generation
model.set_default_evaluation()   # evaluation (LLM as judge)
model.set_default_execution()    # multi-turn execution (Penelope)
model.set_default_embedding()    # embedding generation

Converting to an LLM instance

Turn a stored configuration into an LLM (or embedder) client:

to_llm_instance.py
model = Models.pull(name="GPT-4 Production")
llm = model.get_model_instance()

response = llm.generate("What is the capital of France?")
print(response)

Saving an LLM instance

An LLM instance created with get_model can be saved back as a Model entity:

push_llm.py
from rhesis.sdk.models import get_model

llm = get_model("openai", "gpt-4", api_key="sk-...")
model = llm.push(name="My GPT-4 Production")
model.set_default_generation()

Fields

FieldTypeDescription
idstrUnique identifier (set after push)
namestrHuman-readable name
descriptionstrOptional description (auto-generated from the provider if omitted)
providerstrProvider name (e.g. "openai", "anthropic")
model_namestrModel identifier (e.g. "gpt-4", "claude-3-opus-20240229")
model_typestr"language" (default) or "embedding"
keystrAPI key for the provider
provider_type_idstrAuto-resolved from the provider name
status_idstrOptional status reference

Next: use a model with Synthesizers to generate tests, or configure Metrics for evaluation.