curl --request POST \
--url https://api.example.com/v3/evals/datasets/{dataset_id}/items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"inputs": {
"question": "What is the capital of France?",
"context": [
"Paris is the capital."
]
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expected_outputs": {
"answer": "Paris",
"rationale": "Common knowledge."
},
"metadata": {
"reviewer": "Alice",
"status": "approved"
},
"extras": {},
"source_name": "<string>",
"source_id": "<string>"
}
]
}
'import requests
url = "https://api.example.com/v3/evals/datasets/{dataset_id}/items"
payload = { "items": [
{
"inputs": {
"question": "What is the capital of France?",
"context": ["Paris is the capital."]
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expected_outputs": {
"answer": "Paris",
"rationale": "Common knowledge."
},
"metadata": {
"reviewer": "Alice",
"status": "approved"
},
"extras": {},
"source_name": "<string>",
"source_id": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
inputs: {question: 'What is the capital of France?', context: ['Paris is the capital.']},
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
expected_outputs: {answer: 'Paris', rationale: 'Common knowledge.'},
metadata: {reviewer: 'Alice', status: 'approved'},
extras: {},
source_name: '<string>',
source_id: '<string>'
}
]
})
};
fetch('https://api.example.com/v3/evals/datasets/{dataset_id}/items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v3/evals/datasets/{dataset_id}/items",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'inputs' => [
'question' => 'What is the capital of France?',
'context' => [
'Paris is the capital.'
]
],
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'expected_outputs' => [
'answer' => 'Paris',
'rationale' => 'Common knowledge.'
],
'metadata' => [
'reviewer' => 'Alice',
'status' => 'approved'
],
'extras' => [
],
'source_name' => '<string>',
'source_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v3/evals/datasets/{dataset_id}/items"
payload := strings.NewReader("{\n \"items\": [\n {\n \"inputs\": {\n \"question\": \"What is the capital of France?\",\n \"context\": [\n \"Paris is the capital.\"\n ]\n },\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expected_outputs\": {\n \"answer\": \"Paris\",\n \"rationale\": \"Common knowledge.\"\n },\n \"metadata\": {\n \"reviewer\": \"Alice\",\n \"status\": \"approved\"\n },\n \"extras\": {},\n \"source_name\": \"<string>\",\n \"source_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v3/evals/datasets/{dataset_id}/items")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"inputs\": {\n \"question\": \"What is the capital of France?\",\n \"context\": [\n \"Paris is the capital.\"\n ]\n },\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expected_outputs\": {\n \"answer\": \"Paris\",\n \"rationale\": \"Common knowledge.\"\n },\n \"metadata\": {\n \"reviewer\": \"Alice\",\n \"status\": \"approved\"\n },\n \"extras\": {},\n \"source_name\": \"<string>\",\n \"source_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v3/evals/datasets/{dataset_id}/items")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"inputs\": {\n \"question\": \"What is the capital of France?\",\n \"context\": [\n \"Paris is the capital.\"\n ]\n },\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expected_outputs\": {\n \"answer\": \"Paris\",\n \"rationale\": \"Common knowledge.\"\n },\n \"metadata\": {\n \"reviewer\": \"Alice\",\n \"status\": \"approved\"\n },\n \"extras\": {},\n \"source_name\": \"<string>\",\n \"source_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"api_version": "3.0",
"kind": "NORMAL",
"data": {
"ids": [
"<string>"
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}Add new Evals dataset items
Add new items to a dataset, in a single committed version.
This endpoint adds items; it never updates one. It is an idempotent create:
- an entry with no
idis a new item; the server mints its id; - an entry whose
idis unknown, or whose last revision was a delete, is a new item. Re-posting a deleted id begins a new lifetime for it; - an entry whose
idis live with identical content writes nothing, mints no version, and still answers201with that id, so a request whose response was lost is safe to replay once the original has finished; - an entry whose
idis live with different content, or was written while this request was in flight (including by an earlier attempt of this same request), is a409with reasonDatasetItemCreateCollision, anderrors[]has one entry per colliding id. Do not retry it unchanged: re-read the items, which may already hold this content.
Content is compared on inputs, expected_outputs, metadata, extras, source_name and source_id, with absent, null and empty treated alike, exactly as the bulk PATCH compares it.
An item id may appear at most once in items. A repeated id is a 400, with the same message the bulk PATCH gives.
The whole batch lands under exactly one version, so every pinned read sees all of it or none of it, and a rejected batch writes nothing. The dataset’s item cap counts only the items this request creates. The ids in the response positionally match items, including the ones that were already stored.
curl --request POST \
--url https://api.example.com/v3/evals/datasets/{dataset_id}/items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"inputs": {
"question": "What is the capital of France?",
"context": [
"Paris is the capital."
]
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expected_outputs": {
"answer": "Paris",
"rationale": "Common knowledge."
},
"metadata": {
"reviewer": "Alice",
"status": "approved"
},
"extras": {},
"source_name": "<string>",
"source_id": "<string>"
}
]
}
'import requests
url = "https://api.example.com/v3/evals/datasets/{dataset_id}/items"
payload = { "items": [
{
"inputs": {
"question": "What is the capital of France?",
"context": ["Paris is the capital."]
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expected_outputs": {
"answer": "Paris",
"rationale": "Common knowledge."
},
"metadata": {
"reviewer": "Alice",
"status": "approved"
},
"extras": {},
"source_name": "<string>",
"source_id": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
inputs: {question: 'What is the capital of France?', context: ['Paris is the capital.']},
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
expected_outputs: {answer: 'Paris', rationale: 'Common knowledge.'},
metadata: {reviewer: 'Alice', status: 'approved'},
extras: {},
source_name: '<string>',
source_id: '<string>'
}
]
})
};
fetch('https://api.example.com/v3/evals/datasets/{dataset_id}/items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v3/evals/datasets/{dataset_id}/items",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'inputs' => [
'question' => 'What is the capital of France?',
'context' => [
'Paris is the capital.'
]
],
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'expected_outputs' => [
'answer' => 'Paris',
'rationale' => 'Common knowledge.'
],
'metadata' => [
'reviewer' => 'Alice',
'status' => 'approved'
],
'extras' => [
],
'source_name' => '<string>',
'source_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v3/evals/datasets/{dataset_id}/items"
payload := strings.NewReader("{\n \"items\": [\n {\n \"inputs\": {\n \"question\": \"What is the capital of France?\",\n \"context\": [\n \"Paris is the capital.\"\n ]\n },\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expected_outputs\": {\n \"answer\": \"Paris\",\n \"rationale\": \"Common knowledge.\"\n },\n \"metadata\": {\n \"reviewer\": \"Alice\",\n \"status\": \"approved\"\n },\n \"extras\": {},\n \"source_name\": \"<string>\",\n \"source_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v3/evals/datasets/{dataset_id}/items")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"inputs\": {\n \"question\": \"What is the capital of France?\",\n \"context\": [\n \"Paris is the capital.\"\n ]\n },\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expected_outputs\": {\n \"answer\": \"Paris\",\n \"rationale\": \"Common knowledge.\"\n },\n \"metadata\": {\n \"reviewer\": \"Alice\",\n \"status\": \"approved\"\n },\n \"extras\": {},\n \"source_name\": \"<string>\",\n \"source_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v3/evals/datasets/{dataset_id}/items")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"inputs\": {\n \"question\": \"What is the capital of France?\",\n \"context\": [\n \"Paris is the capital.\"\n ]\n },\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expected_outputs\": {\n \"answer\": \"Paris\",\n \"rationale\": \"Common knowledge.\"\n },\n \"metadata\": {\n \"reviewer\": \"Alice\",\n \"status\": \"approved\"\n },\n \"extras\": {},\n \"source_name\": \"<string>\",\n \"source_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"api_version": "3.0",
"kind": "NORMAL",
"data": {
"ids": [
"<string>"
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}{
"api_version": "3.0",
"kind": "ERROR",
"error": {
"code": 400,
"message": "Resource Not Found",
"errors": [
{
"reason": "ResourceNotFoundException",
"message": "Resource Not Found",
"help": "<string>"
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Dataset UUID
Body
Request body to create a new dataset items
Show child attributes
Show child attributes
Response
Evals dataset items added successfully.
Was this page helpful?