Repository Public
1> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.23## Create eval45**post** `/evals`67Create the structure of an evaluation that can be used to test a model's performance.8An evaluation is a set of testing criteria and the config for a data source, which dictates the schema of the data used in the evaluation. After creating an evaluation, you can run it on different models and model parameters. We support several types of graders and datasources.9For more information, see the [Evals guide](/api/docs/guides/evals).1011### Body Parameters1213- `data_source_config: object { item_schema, type, include_sample_schema } or object { type, metadata } or object { type, metadata }`1415 The configuration for the data source used for the evaluation runs. Dictates the schema of the data used in the evaluation.1617 - `CustomDataSourceConfig object { item_schema, type, include_sample_schema }`1819 A CustomDataSourceConfig object that defines the schema for the data source used for the evaluation runs.20 This schema is used to define the shape of the data that will be:2122 - Used to define your testing criteria and23 - What data is required when creating a run2425 - `item_schema: map[unknown]`2627 The json schema for each row in the data source.2829 - `type: "custom"`3031 The type of data source. Always `custom`.3233 - `"custom"`3435 - `include_sample_schema: optional boolean`3637 Whether the eval should expect you to populate the sample namespace (ie, by generating responses off of your data source)3839 - `LogsDataSourceConfig object { type, metadata }`4041 A data source config which specifies the metadata property of your logs query.42 This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.4344 - `type: "logs"`4546 The type of data source. Always `logs`.4748 - `"logs"`4950 - `metadata: optional map[unknown]`5152 Metadata filters for the logs data source.5354 - `StoredCompletionsDataSourceConfig object { type, metadata }`5556 Deprecated in favor of LogsDataSourceConfig.5758 - `type: "stored_completions"`5960 The type of data source. Always `stored_completions`.6162 - `"stored_completions"`6364 - `metadata: optional map[unknown]`6566 Metadata filters for the stored completions data source.6768- `testing_criteria: array of object { input, labels, model, 3 more } or StringCheckGrader or TextSimilarityGrader or 2 more`6970 A list of graders for all eval runs in this group. Graders can reference variables in the data source using double curly braces notation, like `{{item.variable_name}}`. To reference the model's output, use the `sample` namespace (ie, `{{sample.output_text}}`).7172 - `LabelModelGrader object { input, labels, model, 3 more }`7374 A LabelModelGrader object which uses a model to assign labels to each item75 in the evaluation.7677 - `input: array of object { content, role } or object { content, role, type }`7879 A list of chat messages forming the prompt or context. May include variable references to the `item` namespace, ie {{item.name}}.8081 - `SimpleInputMessage object { content, role }`8283 - `content: string`8485 The content of the message.8687 - `role: string`8889 The role of the message (e.g. "system", "assistant", "user").9091 - `EvalMessageObject object { content, role, type }`9293 A message input to the model with a role indicating instruction following94 hierarchy. Instructions given with the `developer` or `system` role take95 precedence over instructions given with the `user` role. Messages with the96 `assistant` role are presumed to have been generated by the model in previous97 interactions.9899 - `content: string or ResponseInputText or object { text, type } or 3 more`100101 Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.102103 - `TextInput = string`104105 A text input to the model.106107 - `ResponseInputText object { text, type, prompt_cache_breakpoint }`108109 A text input to the model.110111 - `text: string`112113 The text input to the model.114115 - `type: "input_text"`116117 The type of the input item. Always `input_text`.118119 - `"input_text"`120121 - `prompt_cache_breakpoint: optional object { mode }`122123 Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.124125 - `mode: "explicit"`126127 The breakpoint mode. Always `explicit`.128129 - `"explicit"`130131 - `OutputText object { text, type }`132133 A text output from the model.134135 - `text: string`136137 The text output from the model.138139 - `type: "output_text"`140141 The type of the output text. Always `output_text`.142143 - `"output_text"`144145 - `InputImage object { image_url, type, detail }`146147 An image input block used within EvalItem content arrays.148149 - `image_url: string`150151 The URL of the image input.152153 - `type: "input_image"`154155 The type of the image input. Always `input_image`.156157 - `"input_image"`158159 - `detail: optional string`160161 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.162163 - `ResponseInputAudio object { input_audio, type }`164165 An audio input to the model.166167 - `input_audio: object { data, format }`168169 - `data: string`170171 Base64-encoded audio data.172173 - `format: "mp3" or "wav"`174175 The format of the audio data. Currently supported formats are `mp3` and176 `wav`.177178 - `"mp3"`179180 - `"wav"`181182 - `type: "input_audio"`183184 The type of the input item. Always `input_audio`.185186 - `"input_audio"`187188 - `GraderInputs = array of string or ResponseInputText or object { text, type } or 2 more`189190 A list of inputs, each of which may be either an input text, output text, input191 image, or input audio object.192193 - `TextInput = string`194195 A text input to the model.196197 - `ResponseInputText object { text, type, prompt_cache_breakpoint }`198199 A text input to the model.200201 - `OutputText object { text, type }`202203 A text output from the model.204205 - `text: string`206207 The text output from the model.208209 - `type: "output_text"`210211 The type of the output text. Always `output_text`.212213 - `"output_text"`214215 - `InputImage object { image_url, type, detail }`216217 An image input block used within EvalItem content arrays.218219 - `image_url: string`220221 The URL of the image input.222223 - `type: "input_image"`224225 The type of the image input. Always `input_image`.226227 - `"input_image"`228229 - `detail: optional string`230231 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.232233 - `ResponseInputAudio object { input_audio, type }`234235 An audio input to the model.236237 - `role: "user" or "assistant" or "system" or "developer"`238239 The role of the message input. One of `user`, `assistant`, `system`, or240 `developer`.241242 - `"user"`243244 - `"assistant"`245246 - `"system"`247248 - `"developer"`249250 - `type: optional "message"`251252 The type of the message input. Always `message`.253254 - `"message"`255256 - `labels: array of string`257258 The labels to classify to each item in the evaluation.259260 - `model: string`261262 The model to use for the evaluation. Must support structured outputs.263264 - `name: string`265266 The name of the grader.267268 - `passing_labels: array of string`269270 The labels that indicate a passing result. Must be a subset of labels.271272 - `type: "label_model"`273274 The object type, which is always `label_model`.275276 - `"label_model"`277278 - `StringCheckGrader object { input, name, operation, 2 more }`279280 A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.281282 - `input: string`283284 The input text. This may include template strings.285286 - `name: string`287288 The name of the grader.289290 - `operation: "eq" or "ne" or "like" or "ilike"`291292 The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.293294 - `"eq"`295296 - `"ne"`297298 - `"like"`299300 - `"ilike"`301302 - `reference: string`303304 The reference text. This may include template strings.305306 - `type: "string_check"`307308 The object type, which is always `string_check`.309310 - `"string_check"`311312 - `TextSimilarity = TextSimilarityGrader`313314 A TextSimilarityGrader object which grades text based on similarity metrics.315316 - `pass_threshold: number`317318 The threshold for the score.319320 - `Python = PythonGrader`321322 A PythonGrader object that runs a python script on the input.323324 - `pass_threshold: optional number`325326 The threshold for the score.327328 - `ScoreModel = ScoreModelGrader`329330 A ScoreModelGrader object that uses a model to assign a score to the input.331332 - `pass_threshold: optional number`333334 The threshold for the score.335336- `metadata: optional Metadata or null`337338 Set of 16 key-value pairs that can be attached to an object. This can be339 useful for storing additional information about the object in a structured340 format, and querying for objects via API or the dashboard.341342 Keys are strings with a maximum length of 64 characters. Values are strings343 with a maximum length of 512 characters.344345- `name: optional string`346347 The name of the evaluation.348349### Returns350351- `id: string`352353 Unique identifier for the evaluation.354355- `created_at: number`356357 The Unix timestamp (in seconds) for when the eval was created.358359- `data_source_config: EvalCustomDataSourceConfig or object { schema, type, metadata } or EvalStoredCompletionsDataSourceConfig`360361 Configuration of data sources used in runs of the evaluation.362363 - `EvalCustomDataSourceConfig object { schema, type }`364365 A CustomDataSourceConfig which specifies the schema of your `item` and optionally `sample` namespaces.366 The response schema defines the shape of the data that will be:367368 - Used to define your testing criteria and369 - What data is required when creating a run370371 - `schema: map[unknown]`372373 The json schema for the run data source items.374 Learn how to build JSON schemas [here](https://json-schema.org/).375376 - `type: "custom"`377378 The type of data source. Always `custom`.379380 - `"custom"`381382 - `LogsDataSourceConfig object { schema, type, metadata }`383384 A LogsDataSourceConfig which specifies the metadata property of your logs query.385 This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.386 The schema returned by this data source config is used to defined what variables are available in your evals.387 `item` and `sample` are both defined when using this data source config.388389 - `schema: map[unknown]`390391 The json schema for the run data source items.392 Learn how to build JSON schemas [here](https://json-schema.org/).393394 - `type: "logs"`395396 The type of data source. Always `logs`.397398 - `"logs"`399400 - `metadata: optional Metadata or null`401402 Set of 16 key-value pairs that can be attached to an object. This can be403 useful for storing additional information about the object in a structured404 format, and querying for objects via API or the dashboard.405406 Keys are strings with a maximum length of 64 characters. Values are strings407 with a maximum length of 512 characters.408409 - `EvalStoredCompletionsDataSourceConfig object { schema, type, metadata }`410411 Deprecated in favor of LogsDataSourceConfig.412413 - `schema: map[unknown]`414415 The json schema for the run data source items.416 Learn how to build JSON schemas [here](https://json-schema.org/).417418 - `type: "stored_completions"`419420 The type of data source. Always `stored_completions`.421422 - `"stored_completions"`423424 - `metadata: optional Metadata or null`425426 Set of 16 key-value pairs that can be attached to an object. This can be427 useful for storing additional information about the object in a structured428 format, and querying for objects via API or the dashboard.429430 Keys are strings with a maximum length of 64 characters. Values are strings431 with a maximum length of 512 characters.432433- `metadata: Metadata or null`434435 Set of 16 key-value pairs that can be attached to an object. This can be436 useful for storing additional information about the object in a structured437 format, and querying for objects via API or the dashboard.438439 Keys are strings with a maximum length of 64 characters. Values are strings440 with a maximum length of 512 characters.441442- `name: string`443444 The name of the evaluation.445446- `object: "eval"`447448 The object type.449450 - `"eval"`451452- `testing_criteria: array of LabelModelGrader or StringCheckGrader or TextSimilarityGrader or 2 more`453454 A list of testing criteria.455456 - `LabelModelGrader object { input, labels, model, 3 more }`457458 A LabelModelGrader object which uses a model to assign labels to each item459 in the evaluation.460461 - `input: array of object { content, role, type }`462463 - `content: string or ResponseInputText or object { text, type } or 3 more`464465 Inputs to the model - can contain template strings. Supports text, output text, input images, and input audio, either as a single item or an array of items.466467 - `TextInput = string`468469 A text input to the model.470471 - `ResponseInputText object { text, type, prompt_cache_breakpoint }`472473 A text input to the model.474475 - `text: string`476477 The text input to the model.478479 - `type: "input_text"`480481 The type of the input item. Always `input_text`.482483 - `"input_text"`484485 - `prompt_cache_breakpoint: optional object { mode }`486487 Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.488489 - `mode: "explicit"`490491 The breakpoint mode. Always `explicit`.492493 - `"explicit"`494495 - `OutputText object { text, type }`496497 A text output from the model.498499 - `text: string`500501 The text output from the model.502503 - `type: "output_text"`504505 The type of the output text. Always `output_text`.506507 - `"output_text"`508509 - `InputImage object { image_url, type, detail }`510511 An image input block used within EvalItem content arrays.512513 - `image_url: string`514515 The URL of the image input.516517 - `type: "input_image"`518519 The type of the image input. Always `input_image`.520521 - `"input_image"`522523 - `detail: optional string`524525 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.526527 - `ResponseInputAudio object { input_audio, type }`528529 An audio input to the model.530531 - `input_audio: object { data, format }`532533 - `data: string`534535 Base64-encoded audio data.536537 - `format: "mp3" or "wav"`538539 The format of the audio data. Currently supported formats are `mp3` and540 `wav`.541542 - `"mp3"`543544 - `"wav"`545546 - `type: "input_audio"`547548 The type of the input item. Always `input_audio`.549550 - `"input_audio"`551552 - `GraderInputs = array of string or ResponseInputText or object { text, type } or 2 more`553554 A list of inputs, each of which may be either an input text, output text, input555 image, or input audio object.556557 - `TextInput = string`558559 A text input to the model.560561 - `ResponseInputText object { text, type, prompt_cache_breakpoint }`562563 A text input to the model.564565 - `OutputText object { text, type }`566567 A text output from the model.568569 - `text: string`570571 The text output from the model.572573 - `type: "output_text"`574575 The type of the output text. Always `output_text`.576577 - `"output_text"`578579 - `InputImage object { image_url, type, detail }`580581 An image input block used within EvalItem content arrays.582583 - `image_url: string`584585 The URL of the image input.586587 - `type: "input_image"`588589 The type of the image input. Always `input_image`.590591 - `"input_image"`592593 - `detail: optional string`594595 The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.596597 - `ResponseInputAudio object { input_audio, type }`598599 An audio input to the model.600601 - `role: "user" or "assistant" or "system" or "developer"`602603 The role of the message input. One of `user`, `assistant`, `system`, or604 `developer`.605606 - `"user"`607608 - `"assistant"`609610 - `"system"`611612 - `"developer"`613614 - `type: optional "message"`615616 The type of the message input. Always `message`.617618 - `"message"`619620 - `labels: array of string`621622 The labels to assign to each item in the evaluation.623624 - `model: string`625626 The model to use for the evaluation. Must support structured outputs.627628 - `name: string`629630 The name of the grader.631632 - `passing_labels: array of string`633634 The labels that indicate a passing result. Must be a subset of labels.635636 - `type: "label_model"`637638 The object type, which is always `label_model`.639640 - `"label_model"`641642 - `StringCheckGrader object { input, name, operation, 2 more }`643644 A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.645646 - `input: string`647648 The input text. This may include template strings.649650 - `name: string`651652 The name of the grader.653654 - `operation: "eq" or "ne" or "like" or "ilike"`655656 The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.657658 - `"eq"`659660 - `"ne"`661662 - `"like"`663664 - `"ilike"`665666 - `reference: string`667668 The reference text. This may include template strings.669670 - `type: "string_check"`671672 The object type, which is always `string_check`.673674 - `"string_check"`675676 - `TextSimilarityGrader = TextSimilarityGrader`677678 A TextSimilarityGrader object which grades text based on similarity metrics.679680 - `pass_threshold: number`681682 The threshold for the score.683684 - `PythonGrader = PythonGrader`685686 A PythonGrader object that runs a python script on the input.687688 - `pass_threshold: optional number`689690 The threshold for the score.691692 - `ScoreModelGrader = ScoreModelGrader`693694 A ScoreModelGrader object that uses a model to assign a score to the input.695696 - `pass_threshold: optional number`697698 The threshold for the score.699700### Example701702```http703curl https://api.openai.com/v1/evals \704 -H 'Content-Type: application/json' \705 -H "Authorization: Bearer $OPENAI_API_KEY" \706 -d '{707 "data_source_config": {708 "item_schema": {709 "foo": "bar"710 },711 "type": "custom"712 },713 "testing_criteria": [714 {715 "input": [716 {717 "content": "content",718 "role": "role"719 }720 ],721 "labels": [722 "string"723 ],724 "model": "model",725 "name": "name",726 "passing_labels": [727 "string"728 ],729 "type": "label_model"730 }731 ]732 }'733```734735#### Response736737```json738{739 "id": "id",740 "created_at": 0,741 "data_source_config": {742 "schema": {743 "foo": "bar"744 },745 "type": "custom"746 },747 "metadata": {748 "foo": "string"749 },750 "name": "Chatbot effectiveness Evaluation",751 "object": "eval",752 "testing_criteria": [753 {754 "input": [755 {756 "content": "string",757 "role": "user",758 "type": "message"759 }760 ],761 "labels": [762 "string"763 ],764 "model": "model",765 "name": "name",766 "passing_labels": [767 "string"768 ],769 "type": "label_model"770 }771 ]772}773```774775### Example776777```http778curl https://api.openai.com/v1/evals \779 -H "Authorization: Bearer $OPENAI_API_KEY" \780 -H "Content-Type: application/json" \781 -d '{782 "name": "Sentiment",783 "data_source_config": {784 "type": "stored_completions",785 "metadata": {786 "usecase": "chatbot"787 }788 },789 "testing_criteria": [790 {791 "type": "label_model",792 "model": "o3-mini",793 "input": [794 {795 "role": "developer",796 "content": "Classify the sentiment of the following statement as one of 'positive', 'neutral', or 'negative'"797 },798 {799 "role": "user",800 "content": "Statement: {{item.input}}"801 }802 ],803 "passing_labels": [804 "positive"805 ],806 "labels": [807 "positive",808 "neutral",809 "negative"810 ],811 "name": "Example label grader"812 }813 ]814 }'815```816817#### Response818819```json820{821 "object": "eval",822 "id": "eval_67b7fa9a81a88190ab4aa417e397ea21",823 "data_source_config": {824 "type": "stored_completions",825 "metadata": {826 "usecase": "chatbot"827 },828 "schema": {829 "type": "object",830 "properties": {831 "item": {832 "type": "object"833 },834 "sample": {835 "type": "object"836 }837 },838 "required": [839 "item",840 "sample"841 ]842 },843 "testing_criteria": [844 {845 "name": "Example label grader",846 "type": "label_model",847 "model": "o3-mini",848 "input": [849 {850 "type": "message",851 "role": "developer",852 "content": {853 "type": "input_text",854 "text": "Classify the sentiment of the following statement as one of positive, neutral, or negative"855 }856 },857 {858 "type": "message",859 "role": "user",860 "content": {861 "type": "input_text",862 "text": "Statement: {{item.input}}"863 }864 }865 ],866 "passing_labels": [867 "positive"868 ],869 "labels": [870 "positive",871 "neutral",872 "negative"873 ]874 }875 ],876 "name": "Sentiment",877 "created_at": 1740110490,878 "metadata": {879 "description": "An eval for sentiment analysis"880 }881}882```883