API Reference
Complete reference for the osmosis-ai Python SDK.Decorators
@osmosis_reward
Decorator for local reward functions that compute scores without API calls. Signature:solution_str(str, required) - Text to evaluateground_truth(str, required) - Reference answerextra_info(dict, optional) - Additional context
float - Score value
Example:
@osmosis_rubric
Decorator for LLM-based evaluation functions. Signature:solution_str(str, required) - Text to evaluateground_truth(str | None, required) - Reference answer (can be None)extra_info(dict, required) - Configuration and context
float - Score value
Example:
Core Functions
evaluate_rubric()
Evaluate text using an LLM-based rubric. Signature:| Parameter | Type | Required | Description |
|---|---|---|---|
rubric | str | Yes | Natural language evaluation criteria |
solution_str | str | Yes | Text to evaluate |
model_info | dict | Yes | LLM provider configuration |
ground_truth | str | No | Reference answer |
original_input | str | No | Original user query |
metadata | dict | No | Additional context |
score_min | float | No | Minimum score (default: 0.0) |
score_max | float | No | Maximum score (default: 1.0) |
timeout | int | No | Request timeout in seconds |
return_details | bool | No | Return full response (default: False) |
float- Score (whenreturn_details=False)dict- Full response with score, explanation, raw payload (whenreturn_details=True)
Exceptions
MissingAPIKeyError
Raised when an API key is not found for a provider.ProviderRequestError
Raised when a provider request fails.ModelNotFoundError
Raised when a specified model is not available (subclass ofProviderRequestError).
Supported Providers
| Provider | ID | Default API Key Env | Example Models |
|---|---|---|---|
| OpenAI | openai | OPENAI_API_KEY | gpt-5 |
| Anthropic | anthropic | ANTHROPIC_API_KEY | claude-sonnet-4-5 |
| Google Gemini | gemini | GOOGLE_API_KEY | gemini-2.5-flash |
| xAI | xai | XAI_API_KEY | grok-4 |
| OpenRouter | openrouter | OPENROUTER_API_KEY | 100+ models |
| Cerebras | cerebras | CEREBRAS_API_KEY | llama3.1-405b |
Type Definitions
ModelInfo (TypedDict)
RewardRubricRunResult (TypedDict)
Returned whenreturn_details=True: