# createEval

```graphql
mutation CreateEval($projectReference: String!, $input: CreateEvalInput!) {
  createEval(projectReference: $projectReference, input: $input) {
    id
    name
    description
    targetKind
    target
    sourcePath
    exportName
    source
    dataset {
      kind
      path
      editable
      dynamic
    }
    metrics {
      name
      family
      severity
      config
      editable
      dynamic
    }
    repetitions
    tags
    metadata
    editableFields
    dynamicFields
    capabilities
    editMode
    sourceOnlyReasons
  }
}
```

Create an eval source file in the project source or a preview branch to test an agent against a dataset and metrics; returns the eval source document. Requires project.evals.write.

## Arguments

| Name                     | Type                | Required | Description                                                               |
| ------------------------ | ------------------- | -------- | ------------------------------------------------------------------------- |
| `projectReference`       | String!             | Yes      |                                                                           |
| `input`                  | CreateEvalInput!    | Yes      |                                                                           |
| `input.name`             | String!             | Yes      | The eval id is derived from the name.                                     |
| `input.description`      | String              |          |                                                                           |
| `input.target`           | String!             | Yes      | The identifier of the agent the eval runs against.                        |
| `input.dataset`          | EvalDatasetInput!   | Yes      |                                                                           |
| `input.metrics`          | \[EvalMetricInput!] |          | Default none.                                                             |
| `input.repetitions`      | Int                 |          | How often each example runs; default 1.                                   |
| `input.tags`             | \[String!]          |          |                                                                           |
| `input.metadata`         | JSONObject          |          |                                                                           |
| `input.sourceTargetKind` | WriteTargetKind     |          | The source to write; default project. One of `project`, `preview_branch`. |
| `input.targetBranchId`   | ID                  |          | Required with the kind preview\_branch.                                   |

## Variables

```json
{
  "projectReference": "string",
  "input": {
    "name": "string",
    "target": "string",
    "dataset": {
      "kind": "inline",
      "editable": false,
      "dynamic": false
    }
  }
}
```

## Responses

| Status | Description                         |
| ------ | ----------------------------------- |
| 200    | The EvalSource! in data.createEval. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation CreateEval($projectReference: String!, $input: CreateEvalInput!) {\n  createEval(projectReference: $projectReference, input: $input) {\n    id\n    name\n    description\n    targetKind\n    target\n    sourcePath\n    exportName\n    source\n    dataset {\n      kind\n      path\n      editable\n      dynamic\n    }\n    metrics {\n      name\n      family\n      severity\n      config\n      editable\n      dynamic\n    }\n    repetitions\n    tags\n    metadata\n    editableFields\n    dynamicFields\n    capabilities\n    editMode\n    sourceOnlyReasons\n  }\n}",
  "variables": {
    "projectReference": "string",
    "input": {
      "name": "string",
      "target": "string",
      "dataset": {
        "kind": "inline",
        "editable": false,
        "dynamic": false
      }
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createEval": {
      "id": "string",
      "name": "string",
      "description": "string",
      "targetKind": "agent",
      "target": "string",
      "sourcePath": "string",
      "exportName": "string",
      "source": "string",
      "dataset": {
        "kind": "inline",
        "path": "string",
        "editable": false,
        "dynamic": false
      },
      "metrics": [
        {
          "name": "string",
          "family": "answer",
          "severity": "gate",
          "config": {},
          "editable": false,
          "dynamic": false
        }
      ],
      "repetitions": 0,
      "tags": [
        "string"
      ],
      "metadata": {},
      "editableFields": [
        "name"
      ],
      "dynamicFields": [
        "name"
      ],
      "capabilities": [
        "string"
      ],
      "editMode": "structured",
      "sourceOnlyReasons": [
        "string"
      ]
    }
  }
}
```
