Skip to main content

Overview

The Composo class provides a synchronous client for evaluating chat messages against custom criteria. Suitable for single evaluations or small batch scenarios with automatic retry mechanisms.

Constructor

Parameters

string
Your Composo API key for authentication. If not provided, will be loaded from the COMPOSO_API_KEY environment variable.
string
default:"https://platform.composo.ai"
API base URL. Change only if using a custom Composo deployment.
integer
default:"1"
Number of retries on request failure. Each retry uses exponential backoff with jitter. Minimum value is 1 (retries cannot be disabled).
string
Optional model core identifier for specifying the evaluation model. If not provided, uses the default evaluation model.
float
default:"60.0"
Request timeout in seconds. Total time to wait for a single request (including retries).

Example


evaluate()

Evaluate messages against one or more evaluation criteria.

Parameters

list[dict]
required
List of chat messages to evaluate. Each message should be a dictionary with role and content keys. Mutually exclusive with input.Supported roles: system, user, assistant, toolExample:
string | list
Raw OpenAI Responses API input — the value passed as input to openai.responses.create(). Mutually exclusive with messages. Use this when evaluating responses from the OpenAI Responses API alongside the result parameter.Example:
string | list[string]
Evaluation criterion or list of criteria. Can be a custom criterion string or use pre-built criteria from composo.criteria.Example:
string
Optional system message to set AI behavior and context for the evaluation.
list[dict]
Optional list of tool definitions for evaluating tool calls. Each tool should follow the OpenAI function calling format.
dict | openai.types.responses.Response
Optional LLM result to append to the conversation for evaluation. Accepts a standard dict or an openai.types.responses.Response object returned by openai.responses.create() — Composo auto-detects the type and adapts it automatically.
boolean
default:"True"
If False, returns a dictionary with task_id instead of blocking for results. Use for async job submission.
dict[str, Any]
Optional key-value pairs to tag and categorize the request. Tags are useful for organizing, filtering, and analyzing evaluations in analytics tools.Constraints:
  • Keys must be strings, maximum 64 characters
  • Values must be strings, numbers, or bools (converted to strings), maximum 64 characters
  • No nested structures (dictionaries, lists, tuples, or sets)
Example:
boolean
Whether to evaluate only the latest assistant response (True) or all assistant responses (False). If not provided, defaults to True for chat evaluations.Note: Lightning model cores (align-lightning-*) only support True.
string
default:"standard"
Requires composo 0.4.0 or later.How long Composo may keep the content of this request. "standard" stores it as normal. "none" evaluates and returns the score without storing anything but the usage record: no trace, no evaluation record, and a redacted request payload.Note: requests sent with "none" do not appear in Insights — there is no stored evaluation for them to aggregate.Resolved against your account-level retention setting by most-restrictive-wins, so this can only ever tighten retention for a request, never loosen it.
string
When set to "end_user", the response will include a cleaned_explanation field that rewrites the explanation to only reference content visible in user and assistant messages.

Returns

EvaluationResponse | list[EvaluationResponse]
  • Returns single EvaluationResponse if one criterion provided
  • Returns list[EvaluationResponse] if multiple criteria provided
  • Returns dict with task_id if block=False

Response Schema

EvaluationResponse
float | null
Evaluation score between 0.0 and 1.0. Returns null if the criterion was deemed not applicable.
string
Detailed explanation of the evaluation score and reasoning.
string | null
A rewrite of explanation that only references content visible in user and assistant messages. Only present when explanation_cleaning="end_user" is set in the request.

Examples

Basic Evaluation

Multiple Criteria Evaluation

Tool Call Evaluation

Non-blocking Evaluation

OpenAI Responses API — Built-in Tools

Pass the Response object returned by openai.responses.create() directly as result. Use input instead of messages to match the Responses API’s input format.
Known limitation: Composo evaluates only the context provided in the current call — it cannot follow the previous_response_id chain to reconstruct prior turns. If your workflow uses multi-turn Responses API conversations (i.e. passing previous_response_id to link responses), make sure to pass the full conversation history explicitly via messages rather than relying on input + result alone.

OpenAI Responses API — Remote MCP Server


evaluate_trace()

Evaluate multi-agent traces with full conversation history across multiple agents.

Parameters

MultiAgentTrace
required
Multi-agent trace object containing agent interactions, initial input, and final output.
string | list[string]
required
Evaluation criterion or list of criteria for trace evaluation.
ModelCore
Optional model core identifier for trace evaluation.
boolean
default:"True"
If False, returns a dictionary with task_id instead of blocking for results.
dict[str, Any]
Optional key-value pairs to tag and categorize the request. Tags are useful for organizing, filtering, and analyzing trace evaluations in analytics tools.Constraints:
  • Keys must be strings, maximum 64 characters
  • Values must be strings, numbers, or bools (converted to strings), maximum 64 characters
  • No nested structures (dictionaries, lists, tuples, or sets)
Example:
boolean
Whether to evaluate only the latest response (True) or all responses (False). If not provided, defaults to False for trace evaluations.Note: Must be False for trace evaluations.
string
default:"standard"
Requires composo 0.4.0 or later.How long Composo may keep the content of this trace. "standard" stores it as normal. "none" evaluates and returns the score without storing the trace, the evaluation record, or an unredacted request payload — such requests do not appear in Insights.Resolved against your account-level retention setting by most-restrictive-wins.

Returns

MultiAgentTraceResponse | list[MultiAgentTraceResponse]
  • Returns single MultiAgentTraceResponse if one criterion provided
  • Returns list[MultiAgentTraceResponse] if multiple criteria provided
  • Returns dict with task_id if block=False

Response Schema

MultiAgentTraceResponse
dict
Per-agent evaluation scores mapping agent IDs to their individual scores.
float
Overall trace score aggregated across all agents.
string
Detailed explanation of the trace evaluation.
string
The criterion that was evaluated.

Example


Context Manager Usage

The Composo client supports context managers for automatic resource cleanup: