OpenAI 获取评测运行输出条目接口

2026-11-10 18:32 更新

编者时效说明(2026-11-03):官方评测指南说明,Evals于2026年10月31日对现有用户转为只读,计划于2026年11月30日关闭。下文为保存的接口文档译文,创建、修改及运行示例不代表当前仍可使用。参见官方说明。

获取评测运行的输出条目

get /evals/{eval_id}/runs/{run_id}/output_items/{output_item_id}

按ID获取评测运行输出条目。

路径参数

  • eval_id: string

评测 ID。

  • run_id: string

评测运行 ID。

  • output_item_id: string

评测运行输出条目 ID。

返回值

  • id: string

评测运行输出条目的唯一标识符。

  • created_at: integer

时间格式为 Unix 时间戳。

评测运行创建时的Unix时间戳,单位为秒。

  • datasource_item: map[unknown]

输入数据源条目的详情。

  • datasource_item_id: integer

数据源条目的标识符。

  • eval_id: string

评测组的标识符。

  • object: "eval.run.output_item" (default: "eval.run.output_item")

对象类型,固定为"eval.run.output_item"。

  • "eval.run.output_item"

  • results: array of object { name, passed, score, 2 more }

此输出条目的评分器结果列表。

  • name: string

评分器名称。

  • passed: boolean

评分器是否判定此输出通过。

  • score: number

评分器生成的数值分数。

  • sample: optional map[unknown] or null

评分器生成的可选样本或中间数据。

  • type: optional string

评分器类型,例如"string-check-grader"。

  • run_id: string

此输出条目关联的评测运行标识符。

  • sample: object { error, finish_reason, input, 7 more }

包含评测运行输入和输出的样本。

  • error: EvalAPIError or null

表示Eval API错误响应的对象。

  • code: string

错误代码。

  • message: string

错误消息。

  • finish_reason: string

样本生成结束的原因。

  • input: array of object { content, role }

输入消息数组。

  • content: string

消息内容。

  • role: string

消息发送者角色,例如system、user或developer。

  • max_completion_tokens: integer

补全允许的最大词元数。

  • model: string

用于生成样本的模型。

  • output: array of object { content, role }

输出消息数组。

  • content: optional string

消息内容。

  • role: optional string

消息角色,例如"system"、"assistant"或"user"。

  • seed: integer

生成样本使用的种子值。

  • temperature: number

使用的采样温度。

  • top_p: number

采样使用的top_p值。

  • usage: object { cached_tokens, completion_tokens, prompt_tokens, total_tokens }

样本的词元用量详情。

  • cached_tokens: integer

从缓存中读取的词元数。

  • completion_tokens: integer

生成的补全词元数。

  • prompt_tokens: integer

使用的提示词词元数。

  • total_tokens: integer

使用的词元总数。

  • status: string

评测运行状态。

示例

## [中文] 发送GET请求;将示例API凭证及资源标识替换为应用使用的值。
curl https://api.openai.com/v1/evals/$EVAL_ID/runs/$RUN_ID/output_items/$OUTPUT_ITEM_ID \
    -H "Authorization: Bearer $OPENAI_API_KEY"

响应

中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。

{
  "id": "id",
  "created_at": 0,
  "datasource_item": {
    "foo": "bar"
  },
  "datasource_item_id": 0,
  "eval_id": "eval_id",
  "object": "eval.run.output_item",
  "results": [
    {
      "name": "name",
      "passed": true,
      "score": 0,
      "sample": {
        "foo": "bar"
      },
      "type": "type"
    }
  ],
  "run_id": "run_id",
  "sample": {
    "error": {
      "code": "code",
      "message": "message"
    },
    "finish_reason": "finish_reason",
    "input": [
      {
        "content": "content",
        "role": "role"
      }
    ],
    "max_completion_tokens": 0,
    "model": "model",
    "output": [
      {
        "content": "content",
        "role": "role"
      }
    ],
    "seed": 0,
    "temperature": 0,
    "top_p": 0,
    "usage": {
      "cached_tokens": 0,
      "completion_tokens": 0,
      "prompt_tokens": 0,
      "total_tokens": 0
    }
  },
  "status": "status"
}

示例

## [中文] 发送GET请求;将示例API凭证及资源标识替换为应用使用的值。
curl https://api.openai.com/v1/evals/eval_67abd54d9b0081909a86353f6fb9317a/runs/evalrun_67abd54d60ec8190832b46859da808f7/output_items/outputitem_67abd55eb6548190bb580745d5644a33 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json"

响应

中文说明:以下为原文配置、命令或事件示例,字段名、枚举、标识符及数值保留。

代码内文字译释:

  • 积极经济数据发布后,股票市场上涨。
  • Markets:市场。
  • 字符串检查,标识后缀a2486074-d803-4445-b431-ad2262e85d47。
  • 将给定新闻标题分类为Technology、Markets、World、Business或Sports之一。步骤:1.分析标题内容,理解主要关注点;2.提取主题,识别关键线索或关键词;3.根据这些线索,在上述五个选项中选择最适合的类别;4.确保每个标题只选择一个类别。输出格式:仅返回所选类别的一个英文单词,例如Technology、Markets、World、Business或Sports。示例:输入“苹果推出搭载先进AI功能的新款iPhone”,输出Technology;输入“投资者等待央行决策,全球股市涨跌互现”,输出Markets;输入“乌克兰战争:谈判进展最新消息”,输出World;输入“微软洽谈以20亿美元收购游戏公司”,输出Business;输入“曼联在英超足球比赛中获胜”,输出Sports。注意:若标题适合多个类别,选择最主要的主题;stocks(股票)、company acquisition(公司收购)、match(比赛)等词语或科技品牌可作为分类线索。

{
  "object": "eval.run.output_item",
  "id": "outputitem_67e5796c28e081909917bf79f6e6214d",
  "created_at": 1743092076,
  "run_id": "evalrun_67abd54d60ec8190832b46859da808f7",
  "eval_id": "eval_67abd54d9b0081909a86353f6fb9317a",
  "status": "pass",
  "datasource_item_id": 5,
  "datasource_item": {
    "input": "Stock Markets Rally After Positive Economic Data Released",
    "ground_truth": "Markets"
  },
  "results": [
    {
      "name": "String check-a2486074-d803-4445-b431-ad2262e85d47",
      "sample": null,
      "passed": true,
      "score": 1.0
    }
  ],
  "sample": {
    "input": [
      {
        "role": "developer",
        "content": "Categorize a given news headline into one of the following topics: Technology, Markets, World, Business, or Sports.\n\n# Steps\n\n1. Analyze the content of the news headline to understand its primary focus.\n2. Extract the subject matter, identifying any key indicators or keywords.\n3. Use the identified indicators to determine the most suitable category out of the five options: Technology, Markets, World, Business, or Sports.\n4. Ensure only one category is selected per headline.\n\n# Output Format\n\nRespond with the chosen category as a single word. For instance: \"Technology\", \"Markets\", \"World\", \"Business\", or \"Sports\".\n\n# Examples\n\n**Input**: \"Apple Unveils New iPhone Model, Featuring Advanced AI Features\"  \n**Output**: \"Technology\"\n\n**Input**: \"Global Stocks Mixed as Investors Await Central Bank Decisions\"  \n**Output**: \"Markets\"\n\n**Input**: \"War in Ukraine: Latest Updates on Negotiation Status\"  \n**Output**: \"World\"\n\n**Input**: \"Microsoft in Talks to Acquire Gaming Company for $2 Billion\"  \n**Output**: \"Business\"\n\n**Input**: \"Manchester United Secures Win in Premier League Football Match\"  \n**Output**: \"Sports\" \n\n# Notes\n\n- If the headline appears to fit into more than one category, choose the most dominant theme.\n- Keywords or phrases such as \"stocks\", \"company acquisition\", \"match\", or technological brands can be good indicators for classification.\n",
        "tool_call_id": null,
        "tool_calls": null,
        "function_call": null
      },
      {
        "role": "user",
        "content": "Stock Markets Rally After Positive Economic Data Released",
        "tool_call_id": null,
        "tool_calls": null,
        "function_call": null
      }
    ],
    "output": [
      {
        "role": "assistant",
        "content": "Markets",
        "tool_call_id": null,
        "tool_calls": null,
        "function_call": null
      }
    ],
    "finish_reason": "stop",
    "model": "gpt-6-astra",
    "usage": {
      "total_tokens": 325,
      "completion_tokens": 2,
      "prompt_tokens": 323,
      "cached_tokens": 0
    },
    "error": null,
    "temperature": 1.0,
    "max_completion_tokens": 2048,
    "top_p": 1.0,
    "seed": 42
  }
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号