Skip to Content

Model Entity

The Model entity represents an LLM configuration stored in the Rhesis platform. Models contain the provider, model name, and API key needed to connect to LLM services. Once saved, models can be set as defaults for test generation or evaluation, and can be converted to ready-to-use LLM instances.

Note: The Model entity is different from the Models module. The entity stores configurations in the platform, while the module provides LLM client implementations for making API calls.

Creating a Model

Create a model configuration using a provider name (the SDK automatically resolves it to the correct provider type):

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}")

Supported Providers

ProviderDescription
openaiOpenAI models (GPT-4, GPT-3.5, etc.)
anthropicAnthropic Claude models
geminiGoogle Gemini models
mistralMistral AI models
cohereCohere models
groqGroq inference
vertex_aiGoogle Vertex AI
together_aiTogether AI models
replicateReplicate hosted models
perplexityPerplexity AI
ollamaLocal Ollama models
vllmSelf-hosted vLLM

List all available providers:

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

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

# Get by ID
model = Models.pull(id="abc123")

# Get by name (case-insensitive)
model = Models.pull(name="GPT-4 Production")

Setting Default Models

Set a model as the default for test generation or evaluation tasks. This updates your user settings.

set_defaults.py
from rhesis.sdk.entities import Models

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

# Set as default for test generation
model.set_default_generation()

# Set as default for evaluation (LLM as Judge)
model.set_default_evaluation()

Converting to LLM Instance

Convert a Model entity to a ready-to-use LLM instance for making API calls:

to_llm_instance.py
from rhesis.sdk.entities import Models

# Pull model configuration from platform
model = Models.pull(name="GPT-4 Production")

# Convert to LLM instance
llm = model.get_model_instance()

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

This is useful when you want to store model configurations centrally and retrieve them for use in different scripts or applications.

Saving LLM Configurations

You can also save an existing LLM instance to the platform:

push_llm.py
from rhesis.sdk.models import get_model

# Create an LLM instance
llm = get_model("openai", "gpt-4", api_key="sk-...")

# Save to platform as a Model entity
model = llm.push(name="My GPT-4 Production")

# Now you can use entity features
model.set_default_generation()

Complete Workflow Example

complete_workflow.py
from rhesis.sdk.entities import Model, Models

# Create and save a model configuration
model = Model(
    name="Claude for Evaluation",
    provider="anthropic",
    model_name="claude-3-opus-20240229",
    key="sk-ant-..."
)
model.push()

# Set as default for evaluation
model.set_default_evaluation()

# Later, retrieve and use the model
model = Models.pull(name="Claude for Evaluation")
llm = model.get_model_instance()

# Use with metrics or synthesizers
from rhesis.sdk.synthesizers import PromptSynthesizer

synthesizer = PromptSynthesizer(
    prompt="Generate test cases for a customer support chatbot",
    model=llm
)
test_set = synthesizer.generate()

Model Fields

FieldTypeDescription
idstrUnique identifier (set after push)
namestrHuman-readable name
descriptionstrOptional description (auto-generated if not provided)
providerstrProvider name (e.g., “openai”, “anthropic”)
model_namestrModel identifier (e.g., “gpt-4”, “claude-3-opus-20240229”)
keystrAPI key for the provider
provider_type_idstrAuto-resolved from provider name
status_idstrOptional status reference

Next Steps