Skip to main content
The RolloutEngine provides an abstraction for model inference across different backends (OpenAI, vLLM, etc.).

RolloutEngine

Base class for all rollout engines.

Methods

get_model_response

Generate a model response for the given messages.
messages
list[dict]
List of chat messages in OpenAI format.
application_id
str
Unique identifier for tracking requests.
**kwargs
dict
Additional sampling parameters (temperature, top_p, max_tokens, etc.).
output
ModelOutput
Model output containing text, tokens, and metadata.

wake_up

Initialize or warm up the engine (implementation-specific).

sleep

Shutdown or clean up the engine (implementation-specific).

ModelOutput

Dataclass containing model generation output.

Fields

text
str | None
Complete generated text (may include reasoning).
content
str | None
Content portion of the response (excluding reasoning).
reasoning
str | None
Reasoning or thought process (if model supports it).
tool_calls
list[ToolCall] | None
List of tool calls made by the model.
prompt_ids
list[int] | None
Token IDs for the input prompt.
completion_ids
list[int] | None
Token IDs for the completion.
multi_modal_inputs
dict[str, list] | None
Multimodal inputs (e.g., images).
logprobs
list[float] | None
Log probabilities for completion tokens.
prompt_logprobs
list[float] | None
Log probabilities for prompt tokens (aligned to prompt_ids).
prompt_length
int
default:"0"
Length of prompt in tokens.
completion_length
int
default:"0"
Length of completion in tokens.
finish_reason
str | None
Reason generation stopped (“stop”, “length”, etc.).

Methods


OpenAIEngine

Rollout engine using OpenAI-compatible APIs.

Constructor

base_url
str
Base URL for the API endpoint.
api_key
str
API key for authentication.
model
str
Model identifier.

Example: Basic Usage


Example: Batch Generation