Overview
TheComposo 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
Your Composo API key for authentication. If not provided, will be loaded from the
COMPOSO_API_KEY environment variable.API base URL. Change only if using a custom Composo deployment.
Number of retries on request failure. Each retry uses exponential backoff with jitter. Minimum value is 1 (retries cannot be disabled).
Optional model core identifier for specifying the evaluation model. If not provided, uses the default evaluation model.
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 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: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:Evaluation criterion or list of criteria. Can be a custom criterion string or use pre-built criteria from
composo.criteria.Example:Optional list of tool definitions for evaluating tool calls. Each tool should follow the OpenAI function calling format.
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.If
False, returns a dictionary with task_id instead of blocking for results. Use for async job submission.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)
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.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.Requires composo 0.5.0 or later.Which grounding sources this evaluation may draw on. Every source is enabled by
default; set one to The four keys are
false to exclude it from this request only:memory, annotation, document and uploaded_evaluation.
The sources actually used come back in the response’s sources field.Note: only align-20260109 retrieves sources. Disabling one on any other model
core returns a 400 rather than silently doing nothing.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
- Returns single
EvaluationResponseif one criterion provided - Returns
list[EvaluationResponse]if multiple criteria provided - Returns
dictwithtask_idifblock=False
Response Schema
EvaluationResponseEvaluation score between 0.0 and 1.0. Returns
null if the criterion was deemed not applicable.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.The retrieved context the evaluation was grounded in. Each
Source carries an
id and a type, one of document, memory, annotation or
uploaded_evaluation. Documents are deduplicated, so one retrieved several
times appears once. The list is empty when nothing was retrieved.Examples
Basic Evaluation
Multiple Criteria Evaluation
Tool Call Evaluation
Non-blocking Evaluation
OpenAI Responses API — Built-in Tools
Pass theResponse object returned by openai.responses.create() directly as result. Use input instead of messages to match the Responses API’s input format.
OpenAI Responses API — Remote MCP Server
evaluate_trace()
Evaluate multi-agent traces with full conversation history across multiple agents.Parameters
Multi-agent trace object containing agent interactions, initial input, and final output.
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)
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.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.Requires composo 0.5.0 or later.Which grounding sources this evaluation may draw on —
memory, annotation,
document and uploaded_evaluation. Every source is enabled by default; set one to
false to exclude it from this request only.Note: only align-20260109 retrieves sources. Disabling one on any other model
core returns a 400.Returns
- Returns single
MultiAgentTraceResponseif one criterion provided - Returns
list[MultiAgentTraceResponse]if multiple criteria provided - Returns
dictwithtask_idifblock=False
Response Schema
MultiAgentTraceResponseExample
Context Manager Usage
TheComposo client supports context managers for automatic resource cleanup: