EvalsResource class

Resource for the Evals API.

The Evals API allows you to create and manage evaluations to test your LLM integrations. Define testing criteria (graders) and run evaluations against different data sources.

Access this resource through OpenAIClient.evals.

Example

// Create an evaluation
final eval = await client.evals.create(
  CreateEvalRequest(
    name: 'My Evaluation',
    dataSourceConfig: EvalDataSourceConfig.custom(
      itemSchema: {
        'type': 'object',
        'properties': {
          'prompt': {'type': 'string'},
          'expected': {'type': 'string'},
        },
      },
    ),
    testingCriteria: [
      EvalGrader.stringCheck(
        name: 'matches_expected',
        input: '{{sample.output_text}}',
        operation: StringCheckOperation.ilike,
        reference: '%{{item.expected}}%',
      ),
    ],
  ),
);

// Run the evaluation
final run = await client.evals.runs.create(
  eval.id,
  CreateEvalRunRequest(
    dataSource: EvalRunDataSource.jsonlContent([
      {'prompt': 'Say hello', 'expected': 'hello'},
    ]),
  ),
);
Inheritance

Constructors

EvalsResource({required OpenAIConfig config, required Client httpClient, required InterceptorChain interceptorChain, required RequestBuilder requestBuilder, void ensureNotClosed()?})
Creates an EvalsResource.

Properties

config OpenAIConfig
Client configuration.
finalinherited
ensureNotClosed → void Function()?
Callback to check if the client has been closed.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
httpClient → Client
HTTP client for making requests.
finalinherited
interceptorChain InterceptorChain
Interceptor chain for request/response processing.
finalinherited
requestBuilder → RequestBuilder
Request builder for constructing HTTP requests.
finalinherited
runs EvalRunsResource
Access to evaluation run operations.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
streamClientFactory → Client Function()?
Factory for creating dedicated HTTP clients for streaming requests.
finalinherited

Methods

create(CreateEvalRequest request) Future<Eval>
Creates a new evaluation.
delete(String evalId) Future<DeleteEvalResponse>
Deletes an evaluation.
list({String? after, int? limit, String? order, String? orderBy}) Future<EvalList>
Lists all evaluations.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retrieve(String evalId) Future<Eval>
Retrieves an evaluation by ID.
toString() String
A string representation of this object.
inherited
update(String evalId, UpdateEvalRequest request) Future<Eval>
Updates an evaluation.

Operators

operator ==(Object other) bool
The equality operator.
inherited