Skip to main content

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:
Parameters:
  • solution_str (str, required) - Text to evaluate
  • ground_truth (str, required) - Reference answer
  • extra_info (dict, optional) - Additional context
  • **kwargs (required) - Future compatibility (see warning below)
Returns: float - Score value Example:

@osmosis_rubric

Decorator for LLM-based evaluation functions. Signature:
Parameters:
  • solution_str (str, required) - Text to evaluate
  • ground_truth (str | None, required) - Reference answer (can be None)
  • extra_info (dict, required) - Configuration and context
  • **kwargs (required) - Future compatibility (see warning below)
Returns: float - Score value Example:

Core Functions

evaluate_rubric()

Evaluate text using an LLM-based rubric. Signature:
Parameters: model_info Structure:
Returns:
  • float - Score (when return_details=False)
  • dict - Full response with score, explanation, raw payload (when return_details=True)
Example:

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 of ProviderRequestError).


Type Definitions

ModelInfo (TypedDict)


RewardRubricRunResult (TypedDict)

Returned when return_details=True:

Complete Example


Next Steps

Quick Start

Learn with examples

Decorators & API Guide

Advanced patterns

CLI Reference

Batch evaluations