For the complete documentation index, see llms.txt. This page is also available as Markdown.

REST API Quickstart

Integrate AI Evals into any tool or CI/CD pipeline using direct HTTP requests.

Integrate AI Evals into any tool or CI/CD pipeline using raw HTTP. Best for non-Harness environments, custom tooling, and language flexibility.


The four-resource model

Every eval boils down to four resources plus a run.

  • Target: what to test. An HTTP agent endpoint, a prompt with a system message, or precomputed outputs.

  • Dataset: the test cases. Each row has an input, and depending on scoring, optional expected_output, expected_tools, or context.

  • Metric Set: how to score. A list of metrics with thresholds and weights.

  • Evaluation: the wiring. Ties the three together plus run-time settings.

  • Eval Run: the execution. Per-item scoring and aggregate results.


Authentication

  1. Get API token: Harness > Account Settings > Personal Access Tokens > New Token

  2. Base URL: https://app.harness.io/gateway/ai-evals/api/v1/orgs/{org}/projects/{project}/

  3. Required headers:

    • x-api-key: {your-token}

    • Harness-Account: {your-account-id}

    • Content-Type: application/json

Test authentication:

If you get JSON with { "data": [...], "page": 0, "total_elements": N }, authentication works.


Build your first evaluation

The example evaluates a flight support agent. Substitute your own endpoint everywhere it appears below.

1. Create the target

Response:

2. Create the dataset

3. Add dataset items

Response:

Add more items:

4. List available metrics

Note the metric UUIDs from the response.

5. Create the metric set

6. Create the evaluation

7. Run it

Response:

8. Poll for completion

9. Fetch results


What success looks like

A completed run returns aggregate scores plus per-item results:

Open the Evaluations tab in the AI Evals UI to see the same run with the full trace side by side.


Troubleshooting

Agent target returns HTTP 400 error with message about unexpected input structure

Without request_template on an agent target, the runner double-nests row input. Your agent receives {input: {input: ...}} instead of the expected structure and rejects with HTTP 400. Always specify the outgoing body shape explicitly on type: agent targets using the request_template field.

API returns 401 Unauthorized even with valid token

Verify both x-api-key and Harness-Account headers are set. The token format is pat.ACCOUNT_ID.TOKEN_STRING. Also check that the token has not expired in Harness Account Settings.

Dataset item creation fails with "input must be a JSON object" error

The input field must always be a JSON object, not a string. Use {"content": "your-text-here"} instead of passing the text directly. For example: {"input": {"content": "What is 2+2?"}} not {"input": "What is 2+2?"}.

Last updated

Was this helpful?