> ## Documentation Index
> Fetch the complete documentation index at: https://docs.profy.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Offline eval

> Upload a dataset, run an experiment, and read metrics with the creator key

Offline eval sends a dataset to the platform. The platform scores each example with the verifier stored on that example, then returns an experiment summary. Callers cannot submit a score.

The key owner must be that expert's creator. These paths do not require `X-Profy-End-User-Id`. Every JSON response is `{ code, message, data }`.

For the TypeScript client see [TypeScript SDK](https://docs.profy.cn/en/developers/sdk-typescript.md#datasets-and-experiments). To run one turn yourself, bind it with `metadata.profy_eval` on [Invoke an Expert](https://docs.profy.cn/en/developers/api/agents-run.md).

> [!NOTE]
>
> A dataset is a list of examples. Each example has an input, attachments, reference outputs, and its own `tests/test.sh`. After the platform finishes, the experiment leaves `running` and the summary carries the mean reward and pass rates.

## Dataset file

Any `dataset.json` in the uploaded `files` is a dataset root, at any directory depth. When it has `examples`, the platform expands it into one task per example. Paths are relative to the directory that contains that `dataset.json`.

```json theme={null}
{
  "name": "customs-bench",
  "examples": [
    {
      "id": "d526",
      "inputs": { "input": "Review the attachment and write answer.json." },
      "attachments": ["cases/d526/invoice.pdf"],
      "reference_outputs": ["cases/d526/gold/answer.json"],
      "evaluators": ["cases/d526/tests/test.sh"]
    }
  ]
}
```

`id` matches `/^[\w.-]+$/` and is unique in the file. `input` means the same as `inputs`, and `evaluator` means the same as `evaluators`. Every referenced path must be in the same upload. A path that starts with that example's `id/` is stored without that prefix, so the task root is the example and the grader stays at `tests/test.sh`. A missing file, a duplicate id, or an empty `examples` array returns 400.

A `dataset.json` without `examples` that already has the single-task shape is still imported as one task.

## Upload a dataset

```
POST https://api.profy.cn/v1/agents/{identifier}/eval/datasets
```

**suite** `string` (default: seed)

One of `seed`, `online`, `boundary`, `regression`. The platform stamps this onto every task.

**datasetId** `string`

Append into a dataset this expert already owns. Letters, digits, `_`, and `-` only. A foreign id returns 409 with `message` `DATASET_ID_MISMATCH`.

**files** `object[]` *required*

At least one item. Each item has `path`, `content`, and optional `encoding` (`utf8` or `base64`). Use `utf8` for text and `base64` for attachments.

```bash theme={null}
curl -X POST https://api.profy.cn/v1/agents/my-expert/eval/datasets \
  -H "Authorization: Bearer sk-pro-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "suite": "seed",
    "files": [
      {
        "path": "dataset.json",
        "content": "{\"name\":\"customs-bench\",\"examples\":[{\"id\":\"d526\",\"inputs\":{\"input\":\"Review the attachment\"},\"attachments\":[\"cases/d526/invoice.pdf\"],\"reference_outputs\":[],\"evaluators\":[\"cases/d526/tests/test.sh\"]}]}\n"
      },
      { "path": "cases/d526/invoice.pdf", "content": "<base64>", "encoding": "base64" },
      { "path": "cases/d526/tests/test.sh", "content": "#!/bin/sh\nexit 0\n" }
    ]
  }'
```

```json theme={null}
{
  "code": 0,
  "message": "ok",
  "data": { "datasetRef": "upload:customs-bench", "name": "customs-bench" }
}
```

`datasetRef` is what later run and read calls use.

## List tasks

```
GET https://api.profy.cn/v1/agents/{identifier}/eval/tasks
```

**suite** `string`

Return only tasks in this suite.

**dataset** `string`

A `datasetRef`, such as `upload:customs-bench`. Omit it to read the expert's current dataset. An unknown ref returns 404.

Each item in `data.tasks` has `id`, `name`, and `suite`. Reference outputs and the verifier are not included.

Read one task's inputs:

```
GET https://api.profy.cn/v1/agents/{identifier}/eval/tasks/{task}/inputs?dataset=upload:customs-bench
```

`data.files` is a list of `{ path, size }`. `tests/`, `solution/`, and `instruction.md` are omitted. Download one file:

```
GET https://api.profy.cn/v1/agents/{identifier}/eval/tasks/{task}/inputs/file?path=cases/d526/invoice.pdf&dataset=upload:customs-bench
```

The body is the file bytes, with `Content-Type: application/octet-stream`.

## Run the whole dataset

```
POST https://api.profy.cn/v1/agents/{identifier}/eval/experiments/run
```

**datasetRef** `string` *required*

The ref returned by upload. A ref this expert does not own returns 404.

**model** `string` *required*

Text model id. An unavailable model returns 400 with `message` `MODEL_UNAVAILABLE`.

**trials** `integer` *required*

Repeats per example, from 1 to 5. An empty dataset returns 400 with `message` `DATASET_EMPTY`.

```bash theme={null}
curl -X POST https://api.profy.cn/v1/agents/my-expert/eval/experiments/run \
  -H "Authorization: Bearer sk-pro-your-key" \
  -H "Content-Type: application/json" \
  -d '{"datasetRef":"upload:customs-bench","model":"gpt-4","trials":1}'
```

```json theme={null}
{
  "code": 0,
  "message": "ok",
  "data": {
    "experiment": { "id": "exp_123", "status": "running" },
    "started": 12
  }
}
```

The experiment is still running when this returns. Poll the read endpoint below until `experiment.status` is no longer `running`.

## Record an experiment only

When you run each turn yourself through [Invoke an Expert](https://docs.profy.cn/en/developers/api/agents-run.md), create the experiment first, then send `metadata.profy_eval` on every call.

```
POST https://api.profy.cn/v1/agents/{identifier}/eval/experiments
```

**entry** `string` *required*

`open` or `chat`.

**suites** `string[]` *required*

At least one suite name.

**trials** `integer` *required*

From 1 to 10.

**concurrency** `integer`

Optional.

**label** `string`

At most 120 characters.

**changed\_variable** `string`

`code`, `skill`, or `experience`.

**baseline\_experiment\_id** `string`

An existing experiment to compare against.

This call only creates the record. It does not start runs. After a turn finishes:

```
POST https://api.profy.cn/v1/agents/{identifier}/eval/experiments/{experiment_id}/runs/close
```

The body is `{ "task": "d526", "trial": 1 }`. A session that is still generating returns 409.

## Read metrics

```
GET https://api.profy.cn/v1/agents/{identifier}/eval/experiments/{experiment_id}
```

`data.experiment` is the experiment row. `data.summary` is the aggregate. List every experiment with `GET .../eval/experiments`. There, `data` is an array of `{ experiment, summary }`.

| Field | Meaning |
| - | - |
| `runs` | Number of runs |
| `meanReward` | Mean reward of scored runs. `null` when nothing is scored |
| `meanRewardProduced` | Mean reward of runs that produced an output |
| `strictPassRate` | Share of runs whose `reward` is 1 |
| `produceRate` | Share of runs that produced an output |
| `passAtK` | A task passes only when every trial has reward 1 |
| `unscored` | Runs with no score or a failed evaluation. A missing score is not zero |
| `rewardSpread` | Spread of rewards |
| `durationP50` / `durationP90` / `durationP99` | Duration percentiles, in milliseconds |
| `wallClockMs` | Experiment wall clock |
| `throughputPerHour` | Finished runs per hour |
| `peakConcurrency` | Peak concurrent runs |
| `metrics` | Checks reported by the verifier. Numeric values are averaged. Booleans are passed / total |

Per trial:

```
GET https://api.profy.cn/v1/agents/{identifier}/eval/experiments/{experiment_id}/runs
```

Each row has `id`, `task`, `trial`, `status`, `evaluationStatus`, `reward`, `durationMs`, `inputTokens`, `outputTokens`, `credits`, and `sessionId`.

Compare with a baseline:

```
GET https://api.profy.cn/v1/agents/{identifier}/eval/experiments/{experiment_id}/compare?base={baseline_id}
```

`base` is required. `data.summary.current` and `data.summary.baseline` are the two summaries. `data.metrics` is the check delta. `data.tasks` lines runs up by task. Experiments that belong to different experts return 400.

## Next

> [card] [TypeScript SDK](https://docs.profy.cn/en/developers/sdk-typescript.md#datasets-and-experiments)
>
> datasets.create and experiments.evaluate

> [card] [Invoke an Expert](https://docs.profy.cn/en/developers/api/agents-run.md)
>
> metadata.profy\_eval


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.