你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Azure OpenAI in Microsoft Foundry Models REST API 预览参考

本文详细介绍了 Azure OpenAI 的推理 REST API 端点。

API specs

管理和交互 Azure OpenAI 模型及资源分为三个主要的 API 表面:

  • Control plane
  • 数据平面 - 创作
  • 数据平面 - 推理

每个API表面/规范都封装了一套不同的Azure OpenAI能力。 每个 API 都有其独特的预览版和稳定/普遍可用(GA)API 版本。 预览版目前通常按月发布。

Important

现在有一个新的预览推理API。 在我们的 API生命周期指南中了解更多。

API 最新预览发布 最新GA发布 Specifications Description
Control plane 2025-07-01-preview 2025-06-01 Spec files 控制平面 API 用于 创建资源模型部署及其他高级资源管理任务等操作。 控制平面还管理了像 Azure 资源管理器、Bicep、Terraform 和 Azure CLI 等功能所能做的事情。
Data plane v1 preview v1 Spec files 数据平面 API 控制推理和创作操作。

Authentication

Azure OpenAI 提供两种认证方法。 你可以使用API密钥或Microsoft Entra ID。

  • API 密钥认证:对于这种类型的认证,所有 API 请求必须在 api-key HTTP 头部包含 API 密钥。 快速入门指南提供了如何使用此类认证拨打电话的指导。

  • Microsoft Entra ID 认证:你可以用Microsoft Entra令牌来认证API调用。 认证令牌作为请求的头部包含在请求 Authorization 中。 所提供的标记必须前加 Bearer,例如 Bearer YOUR_AUTH_TOKEN。 你可以阅读我们关于认证的Microsoft Entra ID操作指南。

REST API 版本管理

服务API通过 api-version 查询参数进行版本控制。 所有版本均遵循YYYY-MM-DD 日期结构。 For example:

POST https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=2024-06-01

数据平面推断

文章其余部分将介绍Azure OpenAI数据平面推断规范的2025-04-01-preview预览版本。

如果你想查找最新GA API版本的文档,请参考 最新的GA数据平面推理API

完成 - 创建

POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2025-04-01-preview

为所提供的提示词、参数和所选模型创建补全。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
best_of 整数 best_of 服务器端生成完成任务,并返回“最佳”(每个代币日志概率最高的那个)。 结果无法直播。

当与 n一起使用时, best_of 控制候选补全数,并 n 指定返回 best_of 的候选完成数必须大于 n

注: 由于该参数会产生大量完成任务,它可能迅速消耗你的代币配额。 谨慎使用,并确保你对和stop的设置max_tokens合理。
No 1
echo boolean 除了完成,还要回应提示 No False
frequency_penalty number 数字介于-2.0到2.0之间。 正值会根据新标记在文本中已有的频率进行惩罚,降低模型逐字重复同一行的可能性。 No 0
logit_bias 对象 修改完成中出现指定标记的可能性。

接受一个 JSON 对象,将 GPT 分词器中由令牌 ID 指定的令牌映射到从 -100 到 100 的偏置值。 数学上,偏差会在模型抽样前生成的对数中加入。 具体效果因模型而异,但 -1 到1之间的数值应降低或增加选择的可能性;像 -100 或100这样的数值应导致封禁或对相关代币的独占选择。

举个例子,你可以通过 来 {"50256": -100} 阻止 <|endoftext|> 令牌的生成。
No None
logprobs 整数 包括最可能输出代币的对数概 logprobs 率,以及所选代币。 例如,如果 logprobs 是 5,API 返回了 5 个最可能的标记列表。 API 总是返回 logprob 被采样的标记,因此响应中可能包含最多的 logprobs+1 元素。

最大 logprobs 值为5。
No None
max_tokens 整数 完成过程中最多可生成的代币数。

你的提示 max_tokens 词的token数不能超过模型的上下文长度。
No 16
n 整数 每个提示需要生成多少个完成任务。

注: 由于该参数会产生大量完成任务,它可能迅速消耗你的代币配额。 谨慎使用,并确保你对和stop的设置max_tokens合理。
No 1
presence_penalty number 数字介于-2.0到2.0之间。 正值会根据新代币是否出现在文本中来惩罚它们,从而提高模型讨论新话题的可能性。 No 0
提示 字符串或数组 生成补全的提示,编码为字符串、字符串数组、令牌数组或令牌数组数组。

注意, <|endoftext|> 是模型在训练时看到的文档分隔符,所以如果没有指定提示,模型会像从新文档的开头一样生成。
Yes
seed 整数 如果指定,我们的系统会尽最大努力采样确定性采样,使得重复请求且参数相同 seed 时应返回相同结果。

确定性并不保证,你应该参考 system_fingerprint 响应参数来监控后端的变化。
No
stop 字符串或数组 最多四个序列,API 停止生成更多令牌。 返回的文本不会包含停止序列。 No
数据流 boolean 是否要回溯部分进度。 如果设置为令牌,代币会作为仅数据 服务器发送的事件 发送,当事件可用时发送,流以 data: [DONE] 消息终止。 示例Python代码
No False
suffix 字符串 插入文本完成后出现的后缀。

该参数仅支持。gpt-3.5-turbo-instruct
No None
temperature number 采样温度应该在0到2之间。 像0.8这样的高值使输出更随机,而低值如0.2则使输出更聚焦且确定性强。

我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。
No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json createCompletionResponse

状态代码: 默认

描述:服务不可用

Content-Type Type Description
application/json errorResponse

Examples

Example

为所提供的提示词、参数和所选模型创建补全。

POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2025-04-01-preview

{
 "prompt": [
  "tell me a joke about mango"
 ],
 "max_tokens": 32,
 "temperature": 1.0,
 "n": 1
}

回复:状态代码:200

{
  "body": {
    "id": "cmpl-7QmVI15qgYVllxK0FtxVGG6ywfzaq",
    "created": 1686617332,
    "choices": [
      {
        "text": "es\n\nWhat do you call a mango who's in charge?\n\nThe head mango.",
        "index": 0,
        "finish_reason": "stop",
        "logprobs": null
      }
    ],
    "usage": {
      "completion_tokens": 20,
      "prompt_tokens": 6,
      "total_tokens": 26
    }
  }
}

嵌入 - 创建

POST https://{endpoint}/openai/deployments/{deployment-id}/embeddings?api-version=2025-04-01-preview

获得一个能够被机器学习模型和算法轻松利用的给定输入的向量表示。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串 部署型号的部署ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
dimensions 整数 输出嵌入应有的维数。 仅支持及 text-embedding-3 后续型号。 No
encoding_format 字符串 格式是如何返回嵌入的。 可以是 floatbase64。 默认为 float No
输入 字符串或数组 输入文本嵌入,编码为字符串或数组标记。 要在单一请求中嵌入多个输入,可以传递字符串数组或令牌数组。 输入不得超过模型的最大输入标记数(8,192个标记 text-embedding-ada-002),不能是空字符串,且任何数组的维度必须不超过2,048维或更小。 Yes
input_type 字符串 输入嵌入搜索类型 No
用户 字符串 代表终端用户的唯一标识符,有助于监控和检测滥用行为。 No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json 对象

Examples

Example

返回给定提示词的嵌入。

POST https://{endpoint}/openai/deployments/{deployment-id}/embeddings?api-version=2025-04-01-preview

{
 "input": [
  "this is a test"
 ]
}

回复:状态代码:200

{
  "body": {
    "data": [
      {
        "index": 0,
        "embedding": [
          -0.012838088,
          -0.007421397,
          -0.017617522,
          -0.028278312,
          -0.018666342,
          0.01737855,
          -0.01821495,
          -0.006950092,
          -0.009937238,
          -0.038580645,
          0.010674067,
          0.02412286,
          -0.013647936,
          0.013189907,
          0.0021125758,
          0.012406612,
          0.020790534,
          0.00074595667,
          0.008397198,
          -0.00535031,
          0.008968075,
          0.014351576,
          -0.014086051,
          0.015055214,
          -0.022211088,
          -0.025198232,
          0.0065186154,
          -0.036350243,
          0.009180495,
          -0.009698266,
          0.009446018,
          -0.008463579,
          -0.0020113448
        ]
      }
    ],
    "usage": {
      "prompt_tokens": 4,
      "total_tokens": 4
    }
  }
}

聊天完成 - 创建

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

为聊天消息创建一个补全

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
audio 对象 音频输出参数。 当音频输出请求时 modalities: ["audio"],必须使用 。 No
└─ format 枚举 指定输出音频格式。 必须是 wavmp3flacopuspcm16之一。

可能的值:wavmp3flacopuspcm16
No
└─ voice 枚举 指定声音类型。 支持的语态有 alloyechonovafableonyxshimmer和 。

可能的值:alloyechofableonyxnovashimmer
No
data_sources 数组 使用它们的 Azure OpenAI 聊天扩展的配置条目。
这个额外规范仅兼容 Azure OpenAI。
No
frequency_penalty number 数字介于-2.0到2.0之间。 正值会根据新标记在文本中已有的频率进行惩罚,降低模型逐字重复同一行的可能性。
No 0
function_call 字符串或 chatCompletionFunctionCallOption 已被弃用,取而代之。tool_choice

控制模型调用的函数(如果有的话)。
none 意味着模型不会调用函数,而是生成消息。
auto 意味着模型可以在生成消息或调用函数之间选择。
指定某个特定函数 会 {"name": "my_function"} 强制模型调用该函数。

none 当没有函数存在时,是默认的。 auto 如果函数存在,则是默认的。
No
functions 数组 已被弃用,取而代之。tools

模型可能生成的 JSON 输入函数列表。
No
logit_bias 对象 修改完成中出现指定标记的可能性。

接受一个 JSON 对象,将令牌(通过分词器中由令牌 ID 指定)映射到从 -100 到 100 的对应偏置值。 数学上,偏差会在模型抽样前生成的对数中加入。 具体效果因模型而异,但 -1 到1之间的数值应降低或增加选择的可能性;像 -100 或100这样的数值应导致封禁或对相关代币的独占选择。
No None
logprobs boolean 是否返回输出令牌的对数概率。 如果为真,返回每个输出令牌contentmessage的对数概率。 No False
max_completion_tokens 整数 完成化可生成的代币数量的上限,包括可见的输出代币和推理代币。 No
max_tokens 整数 聊天完成时能生成的最大代币数。

输入标记和生成标记的总长度受模型上下文长度限制。
No
messages 数组 这是迄今为止对话内容的列表。 示例Python代码 Yes
元数据 对象 开发者自定义的标签和值,用于在存储的完成仪表盘中过滤完成内容。 No
modalities ChatCompletionModalities 你希望模型为本次请求生成的输出类型。
大多数模型能够生成文本,这是默认的:

["text"]

gpt-4o-audio-preview 模型也可用于生成音频。 要请求该模型同时生成文本和音频响应,您可以使用:

["text", "audio"]
No
n 整数 每个输入消息需要生成多少聊天完成选项。 你将根据所有选项中生成的代币数量收费。 保持 n 最低 1 成本。 No 1
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
预测 PredictionContent 预测输出配置,当模型响应的大部分内容提前已知时,可以大幅提升响应时间。 这种情况最常见于你重新生成文件时,内容大部分内容只做了些微小的修改。 No
presence_penalty number 数字介于-2.0到2.0之间。 正值会根据新代币是否出现在文本中来惩罚它们,从而提高模型讨论新话题的可能性。
No 0
reasoning_effort 枚举 仅限O1模型

限制推理模型的推理工作。

目前支持的值有 lowmediumhigh。 减少推理努力可以加快响应速度,减少回应中用于推理的标记。
可能的值: lowmediumhigh
No
response_format ResponseFormatTextResponseFormatJsonObjectResponseFormatJsonSchema 一个对象,指定模型必须输出的格式。 兼容GPT-4oGPT-4o miniGPT-4 Turbo及所有更新于gpt-3.5-turbo-1106此之前的GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,保证模型与你提供的JSON模式匹配。

设置启用 { "type": "json_object" } JSON模式,保证模型生成的消息是有效的JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
seed 整数 此功能目前处于测试阶段。
如果指定,我们的系统会尽最大努力采样确定性采样,使得重复请求且参数相同 seed 时应返回相同结果。
确定性并不保证,你应该参考 system_fingerprint 响应参数来监控后端的变化。
No
stop 字符串或数组 最多有4个序列,API停止生成更多令牌。
No
存储 boolean 是否将本次聊天完成请求的输出存储在我们的模型蒸馏或评估产品中。 No
数据流 boolean 如果设置为,会发送部分消息delta,就像ChatGPT一样。 令牌作为仅数据服务器 发送的事件 在可用时发送,流以 data: [DONE] 消息结束。 示例Python代码
No False
stream_options chatCompletionStreamOptions 流式响应选项。 只有在你设置 stream: true时才会设置这个。
No None
temperature number 采样温度应该在0到2之间。 像0.8这样的高值使输出更随机,而低值如0.2则使输出更聚焦且确定性强。

我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
tool_choice chatCompletionToolChoiceOption 控制模型调用的(如果有)工具。 none 意味着模型不会调用任何工具,而是生成一条消息。 auto 这意味着模型可以选择生成消息或调用一个或多个工具。 required 意味着模型必须调用一个或多个工具。 通过指定特定工具 {"type": "function", "function": {"name": "my_function"}} 会强制模型调用该工具。 none 当没有工具时,是默认的。 auto 如果有工具,则是默认设置。 No
tools 数组 模型可能调用的工具列表。 目前,仅支持函数作为工具。 利用该列表提供模型可能生成 JSON 输入的函数列表。 最多支持128个功能。
No
top_logprobs 整数 一个介于0到20之间的整数,表示每个标记位置最可能返回的标记数量,每个标记对应对数概率。 logprobs 如果使用该参数,必须设置为 true No
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。
No
user_security_context userSecurityContext 用户安全上下文包含多个参数,描述 AI 应用本身以及与 AI 应用交互的终端用户。 这些领域通过提供全面的方法来保护您的人工智能应用,帮助您的安全运营团队调查并缓解安全事件。 了解更多关于利用Microsoft Defender for Cloud保护人工智能应用的信息。 No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json 对象

状态代码: 默认

描述:服务不可用

Content-Type Type Description
application/json errorResponse

Examples

Example

为所提供的提示词、参数和所选模型创建补全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "system",
   "content": "you are a helpful assistant that talks like a pirate"
  },
  {
   "role": "user",
   "content": "can you tell me how to care for a parrot?"
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Ahoy matey! So ye be wantin' to care for a fine squawkin' parrot, eh? Well, shiver me timbers, let ol' Cap'n Assistant share some wisdom with ye! Here be the steps to keepin' yer parrot happy 'n healthy:\n\n1. Secure a sturdy cage: Yer parrot be needin' a comfortable place to lay anchor! Be sure ye get a sturdy cage, at least double the size of the bird's wingspan, with enough space to spread their wings, yarrrr!\n\n2. Perches 'n toys: Aye, parrots need perches of different sizes, shapes, 'n textures to keep their feet healthy. Also, a few toys be helpin' to keep them entertained 'n their minds stimulated, arrrh!\n\n3. Proper grub: Feed yer feathered friend a balanced diet of high-quality pellets, fruits, 'n veggies to keep 'em strong 'n healthy. Give 'em fresh water every day, or ye\u00e2\u20ac\u2122ll have a scurvy bird on yer hands!\n\n4. Cleanliness: Swab their cage deck! Clean their cage on a regular basis: fresh water 'n food daily, the floor every couple of days, 'n a thorough scrubbing ev'ry few weeks, so the bird be livin' in a tidy haven, arrhh!\n\n5. Socialize 'n train: Parrots be a sociable lot, arrr! Exercise 'n interact with 'em daily to create a bond 'n maintain their mental 'n physical health. Train 'em with positive reinforcement, treat 'em kindly, yarrr!\n\n6. Proper rest: Yer parrot be needin' \u00e2\u20ac\u2122bout 10-12 hours o' sleep each night. Cover their cage 'n let them slumber in a dim, quiet quarter for a proper night's rest, ye scallywag!\n\n7. Keep a weather eye open for illness: Birds be hidin' their ailments, arrr! Be watchful for signs of sickness, such as lethargy, loss of appetite, puffin' up, or change in droppings, and make haste to a vet if need be.\n\n8. Provide fresh air 'n avoid toxins: Parrots be sensitive to draft and pollutants. Keep yer quarters well ventilated, but no drafts, arrr! Be mindful of toxins like Teflon fumes, candles, or air fresheners.\n\nSo there ye have it, me hearty! With proper care 'n commitment, yer parrot will be squawkin' \"Yo-ho-ho\" for many years to come! Good luck, sailor, and may the wind be at yer back!"
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

基于 Azure 搜索数据和系统分配的托管身份创建完成文件。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_search",
   "parameters": {
    "endpoint": "https://your-search-endpoint.search.windows.net/",
    "index_name": "{index name}",
    "authentication": {
     "type": "system_assigned_managed_identity"
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

基于 Azure 搜索图像矢量数据创建完成图。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_search",
   "parameters": {
    "endpoint": "https://your-search-endpoint.search.windows.net/",
    "index_name": "{index name}",
    "query_type": "vector",
    "fields_mapping": {
     "image_vector_fields": [
      "image_vector"
     ]
    },
    "authentication": {
     "type": "api_key",
     "key": "{api key}"
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion."
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

基于 Azure 搜索向量数据、之前的助手消息和用户指定的管理身份创建完成文件。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a cat?"
  },
  {
   "role": "assistant",
   "content": "Content of the completion [doc1].",
   "context": {
    "intent": "cat care"
   }
  },
  {
   "role": "user",
   "content": "how about dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_search",
   "parameters": {
    "endpoint": "https://your-search-endpoint.search.windows.net/",
    "authentication": {
     "type": "user_assigned_managed_identity",
     "managed_identity_resource_id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{resource-name}"
    },
    "index_name": "{index name}",
    "query_type": "vector",
    "embedding_dependency": {
     "type": "deployment_name",
     "deployment_name": "{embedding deployment name}"
    },
    "in_scope": true,
    "top_n_documents": 5,
    "strictness": 3,
    "role_information": "You are an AI assistant that helps people find information.",
    "fields_mapping": {
     "content_fields_separator": "\\n",
     "content_fields": [
      "content"
     ],
     "filepath_field": "filepath",
     "title_field": "title",
     "url_field": "url",
     "vector_fields": [
      "contentvector"
     ]
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content 2.",
                "title": "Citation Title 2",
                "filepath": "contoso2.txt",
                "url": "https://contoso.blob.windows.net/container/contoso2.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

为提供的 Azure Cosmos DB 创建一个补全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "azure_cosmos_db",
   "parameters": {
    "authentication": {
     "type": "connection_string",
     "connection_string": "mongodb+srv://rawantest:{password}$@{cluster-name}.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000"
    },
    "database_name": "vectordb",
    "container_name": "azuredocs",
    "index_name": "azuredocindex",
    "embedding_dependency": {
     "type": "deployment_name",
     "deployment_name": "{embedding deployment name}"
    },
    "fields_mapping": {
     "content_fields": [
      "content"
     ],
     "vector_fields": [
      "contentvector"
     ]
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

为所提供的 Mongo 数据库创建一个补全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "mongo_db",
   "parameters": {
    "authentication": {
     "type": "username_and_password",
     "username": "<username>",
     "password": "<password>"
    },
    "endpoint": "<endpoint_name>",
    "app_name": "<application name>",
    "database_name": "sampledb",
    "collection_name": "samplecollection",
    "index_name": "sampleindex",
    "embedding_dependency": {
     "type": "deployment_name",
     "deployment_name": "{embedding deployment name}"
    },
    "fields_mapping": {
     "content_fields": [
      "content"
     ],
     "vector_fields": [
      "contentvector"
     ]
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

为提供的 Elasticsearch 创建一个补全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "elasticsearch",
   "parameters": {
    "endpoint": "https://your-elasticsearch-endpoint.eastus.azurecontainer.io",
    "index_name": "{index name}",
    "authentication": {
     "type": "key_and_key_id",
     "key": "{key}",
     "key_id": "{key id}"
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Example

为所提供的松果资源创建一个补全。

POST https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2025-04-01-preview

{
 "messages": [
  {
   "role": "user",
   "content": "can you tell me how to care for a dog?"
  }
 ],
 "data_sources": [
  {
   "type": "pinecone",
   "parameters": {
    "authentication": {
     "type": "api_key",
     "key": "{api key}"
    },
    "environment": "{environment name}",
    "index_name": "{index name}",
    "embedding_dependency": {
     "type": "deployment_name",
     "deployment_name": "{embedding deployment name}"
    },
    "fields_mapping": {
     "title_field": "title",
     "url_field": "url",
     "filepath_field": "filepath",
     "content_fields": [
      "content"
     ],
     "content_fields_separator": "\n"
    }
   }
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

转录 - 创建

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/transcriptions?api-version=2025-04-01-preview

将音频转录成输入语言。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: multipart/form-data

Name 类型 Description Required Default
模型 字符串 型号的识别码。 选项包括 gpt-4o-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1gpt-4o-transcribe-diarize和 。 Yes
文件 字符串 音频文件对象要转录。 Yes
语言 字符串 输入音频的语言。 以 ISO-639-1 格式提供输入语言可以提高准确性和延迟。 No
提示 字符串 可选文本,用于指导模型风格或延续之前的音频片段。 提示应与音频语言相匹配。 No
response_format audioResponseFormat 定义输出格式。 No
temperature number 采样温度在0到1之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。 如果设置为0,模型会使用对数概率自动升温,直到达到某些阈值。 No 0
timestamp_granularities[] 数组 本次转录的时间戳细粒度。 response_format 必须设置为 verbose_json 使用时间戳的粒度。 支持 word以下选项中的一个或两个:,或 segment。 注意:段时间戳不会有额外延迟,但生成字时间戳会产生额外的延迟。 No ['segment']

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json 对象
text/plain 字符串 输出格式的转录文本(当response_format为 textvttsrt之一时)。

Examples

Example

从提供的语音音频数据中获取转录文本及相关元数据。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/transcriptions?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "text": "A structured object when requesting json or verbose_json"
  }
}

Example

从提供的语音音频数据中获取转录文本及相关元数据。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/transcriptions?api-version=2025-04-01-preview

"---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--"

回复:状态代码:200

{
  "type": "string",
  "example": "plain text when requesting text, srt, or vtt"
}

翻译 - 创作

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/translations?api-version=2025-04-01-preview

将输入音频转录并翻译成英文文本。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: multipart/form-data

Name 类型 Description Required Default
文件 字符串 音频文件需要翻译。 Yes
提示 字符串 可选文本,用于指导模型风格或延续之前的音频片段。 提示应为英文。 No
response_format audioResponseFormat 定义输出格式。 No
temperature number 采样温度在0到1之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。 如果设置为0,模型会使用对数概率自动升温,直到达到某些阈值。 No 0

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json 对象
text/plain 字符串 以输出格式转录文本(当response_format为文本、vtt或srt时)。

Examples

Example

从提供的语音音频数据中获取英文转录文本及相关元数据。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/translations?api-version=2025-04-01-preview

"---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--"

回复:状态代码:200

{
  "body": {
    "text": "A structured object when requesting json or verbose_json"
  }
}

Example

从提供的语音音频数据中获取英文转录文本及相关元数据。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/translations?api-version=2025-04-01-preview

"---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--"

回复:状态代码:200

{
  "type": "string",
  "example": "plain text when requesting text, srt, or vtt"
}

语音 - 创作

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/speech?api-version=2025-04-01-preview

从输入文本生成音频。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: multipart/form-data

Name 类型 Description Required Default
输入 字符串 合成音频的文本。 最大长度为4,096字符。 Yes
response_format 枚举 合成音频的格式。
可能的值:mp3opusaacflacwavpcm
No
speed number 合成音频的速度。 从中0.25选择一个值。4.0 1.0 是默认。 No 1.0
voice 枚举 用于语音合成的声音。
可能的值:alloyechofableonyxnovashimmer
Yes

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/octet-stream 字符串

Examples

Example

从提供的文本中合成音频。

POST https://{endpoint}/openai/deployments/{deployment-id}/audio/speech?api-version=2025-04-01-preview

{
 "input": "Hi! What are you going to make?",
 "voice": "fable",
 "response_format": "mp3"
}

回复:状态代码:200

{
  "body": "101010101"
}

图像生成 - 创建

POST https://{endpoint}/openai/deployments/{deployment-id}/images/generations?api-version=2025-04-01-preview

根据给定图像生成模型部署,从文本说明生成一批图像

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
后台的 imageBackground 允许设置生成图像背景的透明度。 该参数仅支持GPT-image-1系列模型。 No auto
n 整数 需要生成的图片数量。 对于 dall-e-3,仅支持 n=1。 No 1
output_compression 整数 生成图像的压缩级别(0-100%)。 该参数仅支持带有jpeg输出格式的gpt-image-1系列模型。 No 100
output_format imagesOutputFormat 生成图像返回的文件格式。 仅支持 gpt-image-1 系列型号。 No png
提示 字符串 对所需图片的文字描述。 GPT-image-1 系列的最大长度为 32000 字符,dall-e-3 的最大长度为 4000 字符 Yes
partial_images 整数 需要生成的部分图像数量。 该参数用于返回部分图像的流式响应。 值必须在0到3之间。 设置为0时,响应将是一次流媒体事件中发送的单张图片。 请注意,如果完整图像生成速度更快,最终图像可能会在部分图像数量生成之前发送。 0
数据流 boolean 在流媒体模式下编辑图片。 no false
quality imageQuality 生成图像的质量。 No auto
response_format imagesResponseFormat 生成图像返回的格式。 该参数不支持 gpt-image-1系列模型,因为它们总是返回base64编码图像。
可能的值: urlb64_json
No url
size imageSize 生成图像的大小。 No auto
样式 imageStyle 生成图像的风格。 仅支持DALL-E-3。 No vivid
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。 No

Responses

状态代码: 200

Description: Ok

Content-Type Type Description
application/json generateImagesResponse

状态代码: 默认

描述:发生了错误。

Content-Type Type Description
application/json dalleErrorResponse

Examples

Example

根据提示生成图片。

POST https://{endpoint}/openai/deployments/{deployment-id}/images/generations?api-version=2025-04-01-preview

{
 "prompt": "In the style of WordArt, Microsoft Clippy wearing a cowboy hat.",
 "n": 1,
 "style": "natural",
 "quality": "standard"
}

回复:状态代码:200

{
  "body": {
    "created": 1698342300,
    "data": [
      {
        "revised_prompt": "A vivid, natural representation of Microsoft Clippy wearing a cowboy hat.",
        "prompt_filter_results": {
          "sexual": {
            "severity": "safe",
            "filtered": false
          },
          "violence": {
            "severity": "safe",
            "filtered": false
          },
          "hate": {
            "severity": "safe",
            "filtered": false
          },
          "self_harm": {
            "severity": "safe",
            "filtered": false
          },
          "profanity": {
            "detected": false,
            "filtered": false
          },
          "custom_blocklists": {
            "filtered": false,
            "details": []
          }
        },
        "url": "https://dalletipusw2.blob.core.windows.net/private/images/e5451cc6-b1ad-4747-bd46-b89a3a3b8bc3/generated_00.png?se=2023-10-27T17%3A45%3A09Z&...",
        "content_filter_results": {
          "sexual": {
            "severity": "safe",
            "filtered": false
          },
          "violence": {
            "severity": "safe",
            "filtered": false
          },
          "hate": {
            "severity": "safe",
            "filtered": false
          },
          "self_harm": {
            "severity": "safe",
            "filtered": false
          }
        }
      }
    ]
  }
}

图像生成 - 编辑

POST https://{endpoint}/openai/deployments/{deployment-id}/images/edits?api-version=2025-04-01-preview

在给定的GPT-image-1模型部署中,编辑文本说明中的图片

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
deployment-id 路径 Yes 字符串
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: multipart/form-data

Name 类型 Description Required Default
图像 字符串或数组 需要编辑的图片。 必须是支持的图片文件或图像数组。 每张图片应该是png或jpg文件,大小于50MB。 Yes
input_fidelity 字符串 控制模型为匹配输入图像的风格和特征,尤其是面部特征所投入的努力。 该参数仅支持GPT-image-1系列模型。 支持和highlow no low.
过滤 字符串 另一张图像的完全透明区域(例如alpha为零)指示图像应编辑的位置。 如果提供多张图像,遮罩将应用到第一张图像上。 必须是有效的PNG文件,大小小于4MB,且尺寸与图片相同。 No
n 整数 需要生成的图片数量。 必须在1到10之间。 No 1
提示 字符串 对所需图片的文字描述。 最大长度为32000字符。 Yes
quality imageQuality 生成图像的质量。 No auto
partial_images 需要生成的部分图像数量。 该参数用于返回部分图像的流式响应。 值必须在0到3之间。 设置为0时,响应将是一次流媒体事件中发送的单张图片。 请注意,如果完整图像生成速度更快,最终图像可能会在部分图像数量生成之前发送。
数据流 boolean 在流媒体模式下编辑图片。 no false
response_format imagesResponseFormat 生成图像返回的格式。 No url
size imageSize 生成图像的大小。 No auto
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。 No

Responses

状态代码: 200

Description: Ok

Content-Type Type Description
application/json generateImagesResponse

状态代码: 默认

描述:发生了错误。

Content-Type Type Description
application/json dalleErrorResponse

名单 - 助理教练

Note

助理API已被弃用,将于2026年8月26日退役。 使用普遍可用的Microsoft铸造代理服务。 按照 迁移指南 更新你的工作负载。 Learn more.

GET https://{endpoint}/openai/assistants?api-version=2025-04-01-preview

返回助理名单。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listAssistantsResponse

Examples

Example

返回助理名单。

GET https://{endpoint}/openai/assistants?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "asst_abc123",
        "object": "assistant",
        "created_at": 1707257477,
        "name": "Stock Analyst",
        "description": null,
        "model": "gpt-4-1106-preview",
        "instructions": "You are a financial analyst that analyzes stock market prices and other financial data present on user uploaded files or by calling external APIs.",
        "tools": [
          {
            "type": "code_interpreter"
          }
        ],
        "tool_resources": {},
        "metadata": {},
        "top_p": 1.0,
        "temperature": 1.0,
        "response_format": "auto"
      },
      {
        "id": "asst_abc456",
        "object": "assistant",
        "created_at": 1698982718,
        "name": "My Assistant",
        "description": null,
        "model": "gpt-4-turbo",
        "instructions": "You are a helpful assistant designed to make me better at coding!",
        "tools": [],
        "tool_resources": {},
        "metadata": {},
        "top_p": 1.0,
        "temperature": 1.0,
        "response_format": "auto"
      },
      {
        "id": "asst_abc789",
        "object": "assistant",
        "created_at": 1698982643,
        "name": null,
        "description": null,
        "model": "gpt-4-turbo",
        "instructions": null,
        "tools": [],
        "tool_resources": {},
        "metadata": {},
        "top_p": 1.0,
        "temperature": 1.0,
        "response_format": "auto"
      }
    ],
    "first_id": "asst_abc123",
    "last_id": "asst_abc789",
    "has_more": false
  }
}

创建 - 助理

POST https://{endpoint}/openai/assistants?api-version=2025-04-01-preview

创建一个带有模型和说明的助手。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
description 字符串 助理的描述。 最大长度为512个字符。
No
instructions 字符串 助理使用的系统指令。 最大长度为256,000字符。
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 Yes
name 字符串 助理的名字。 最大长度为256个字符。
No
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 这个助手附着的矢量存储器。 助手最多只能连接一个向量存储。
No
└─ vector_stores 数组 一个帮助创建向量存储的 Vector Store,并file_ids并附加到这个助手上。 助手最多只能连接一个向量存储。
No
tools 数组 助手中启用的工具列表。 每位助手最多可使用128个工具。 工具可以是类型 code_interpreter、、 retrievalfunction
No []
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json assistantObject

Examples

Example

创建一个带有模型和说明的助手。

POST https://{endpoint}/openai/assistants?api-version=2025-04-01-preview

{
 "name": "Math Tutor",
 "instructions": "When a customer asks about a specific math problem, use Python to evaluate their query.",
 "tools": [
  {
   "type": "code_interpreter"
  }
 ],
 "model": "gpt-4-1106-preview"
}

回复:状态代码:200

{
  "body": {
    "id": "asst_4nsG2qgNzimRPE7MazXTXbU7",
    "object": "assistant",
    "created_at": 1707295707,
    "name": "Math Tutor",
    "description": null,
    "model": "gpt-4-1106-preview",
    "instructions": "When a customer asks about a specific math problem, use Python to evaluate their query.",
    "tools": [
      {
        "type": "code_interpreter"
      }
    ],
    "metadata": {},
    "top_p": 1.0,
    "temperature": 1.0,
    "response_format": "auto"
  }
}

获取 - 助理

GET https://{endpoint}/openai/assistants/{assistant_id}?api-version=2025-04-01-preview

叫来一名助手。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
assistant_id 路径 Yes 字符串 需要取回助理的身份证。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json assistantObject

Examples

Example

叫来一名助手。

GET https://{endpoint}/openai/assistants/{assistant_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "asst_abc123",
    "object": "assistant",
    "created_at": 1699009709,
    "name": "HR Helper",
    "description": null,
    "model": "gpt-4-turbo",
    "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",
    "tools": [
      {
        "type": "file_search"
      }
    ],
    "metadata": {},
    "top_p": 1.0,
    "temperature": 1.0,
    "response_format": "auto"
  }
}

修改 - 助理

POST https://{endpoint}/openai/assistants/{assistant_id}?api-version=2025-04-01-preview

修改助手。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
assistant_id 路径 Yes 字符串 助理的身份证可以修改。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
description 字符串 助理的描述。 最大长度为512个字符。
No
instructions 字符串 助理使用的系统指令。 最大长度为32768字符。
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 No
name 字符串 助理的名字。 最大长度为256个字符。
No
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 覆盖工具 code_interpreter 可用的文件 ID 列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 覆盖连接到该助手的矢量存储。 助手最多只能连接一个向量存储。
No
tools 数组 助手中启用的工具列表。 每位助手最多可使用128个工具。 工具可以是类型 code_interpreter、、 retrievalfunction
No []
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json assistantObject

Examples

Example

修改助手。

POST https://{endpoint}/openai/assistants/{assistant_id}?api-version=2025-04-01-preview

{
 "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
 "tools": [
  {
   "type": "file_search"
  }
 ],
 "model": "gpt-4-turbo"
}

回复:状态代码:200

{
  "body": {
    "id": "asst_123",
    "object": "assistant",
    "created_at": 1699009709,
    "name": "HR Helper",
    "description": null,
    "model": "gpt-4-turbo",
    "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.",
    "tools": [
      {
        "type": "file_search"
      }
    ],
    "tool_resources": {
      "file_search": {
        "vector_store_ids": []
      }
    },
    "metadata": {},
    "top_p": 1.0,
    "temperature": 1.0,
    "response_format": "auto"
  }
}

删除 - 助手

DELETE https://{endpoint}/openai/assistants/{assistant_id}?api-version=2025-04-01-preview

删除一个助手。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
assistant_id 路径 Yes 字符串 需要删除助理的ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json deleteAssistantResponse

Examples

Example

删除了一个助理。

DELETE https://{endpoint}/openai/assistants/{assistant_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "asst_4nsG2qgNzimRPE7MazXTXbU7",
    "object": "assistant.deleted",
    "deleted": true
  }
}

创建 - 讨论串

Note

助理API已被弃用,将于2026年8月26日退役。 使用普遍可用的Microsoft铸造代理服务。 按照 迁移指南 更新你的工作负载。 Learn more.

POST https://{endpoint}/openai/threads?api-version=2025-04-01-preview

开个帖子。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
messages 数组 一份用于开启讨论的消息列表。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
tool_resources 对象 这是一组在本帖中为助理工具提供的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 向量存储链接到本帖。 线程上最多只能连接1个向量存储。
No
└─ vector_stores 数组 一个帮助创建向量存储并附加到file_ids的辅助工具。 线程上最多只能连接1个向量存储。
No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json threadObject

Examples

Example

这样可以创建一个线程。

POST https://{endpoint}/openai/threads?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "thread_v7V4csrNOxtNmgcwGg496Smx",
    "object": "thread",
    "created_at": 1707297136,
    "metadata": {}
  }
}

获取 - Thread

GET https://{endpoint}/openai/threads/{thread_id}?api-version=2025-04-01-preview

检索一个线程。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 要检索的线程ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json threadObject

Examples

Example

检索一个线程。

GET https://{endpoint}/openai/threads/{thread_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "thread_v7V4csrNOxtNmgcwGg496Smx",
    "object": "thread",
    "created_at": 1707297136,
    "metadata": {},
    "tool_resources": {
      "code_interpreter": {
        "file_ids": []
      }
    }
  }
}

修改 - 线程

POST https://{endpoint}/openai/threads/{thread_id}?api-version=2025-04-01-preview

修改线程。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 要修改的帖子ID。 只有 可以 metadata 修改。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
tool_resources 对象 这是一组在本帖中为助理工具提供的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具可用的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 向量存储链接到本帖。 线程上最多只能连接1个向量存储。
No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json threadObject

Examples

Example

修改线程。

POST https://{endpoint}/openai/threads/{thread_id}?api-version=2025-04-01-preview

{
 "metadata": {
  "modified": "true",
  "user": "abc123"
 }
}

回复:状态代码:200

{
  "body": {
    "id": "thread_v7V4csrNOxtNmgcwGg496Smx",
    "object": "thread",
    "created_at": 1707297136,
    "metadata": {
      "modified": "true",
      "user": "abc123"
    },
    "tool_resources": {}
  }
}

删除 - 讨论串

DELETE https://{endpoint}/openai/threads/{thread_id}?api-version=2025-04-01-preview

删除一个帖子。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 要删除的帖子ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json deleteThreadResponse

Examples

Example

删除了一个帖子。

DELETE https://{endpoint}/openai/threads/{thread_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "thread_v7V4csrNOxtNmgcwGg496Smx",
    "object": "thread.deleted",
    "deleted": true
  }
}

列表 - 消息

Note

助理API已被弃用,将于2026年8月26日退役。 使用普遍可用的Microsoft铸造代理服务。 按照 迁移指南 更新你的工作负载。 Learn more.

GET https://{endpoint}/openai/threads/{thread_id}/messages?api-version=2025-04-01-preview

返回给定线程的消息列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 消息所属线程的ID。
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
run_id 查询 No 字符串 通过生成消息的运行ID来过滤。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listMessagesResponse

Examples

Example

List Messages

GET https://{endpoint}/openai/threads/{thread_id}/messages?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "msg_abc123",
        "object": "thread.message",
        "created_at": 1699016383,
        "assistant_id": null,
        "thread_id": "thread_abc123",
        "run_id": null,
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": {
              "value": "How does AI work? Explain it in simple terms.",
              "annotations": []
            }
          }
        ],
        "attachments": [],
        "metadata": {}
      },
      {
        "id": "msg_abc456",
        "object": "thread.message",
        "created_at": 1699016383,
        "assistant_id": null,
        "thread_id": "thread_abc123",
        "run_id": null,
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": {
              "value": "Hello, what is AI?",
              "annotations": []
            }
          }
        ],
        "attachments": [],
        "metadata": {}
      }
    ],
    "first_id": "msg_abc123",
    "last_id": "msg_abc456",
    "has_more": false
  }
}

创建 - 信息

POST https://{endpoint}/openai/threads/{thread_id}/messages?api-version=2025-04-01-preview

创建一条信息。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 创建消息的线程ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
attachments 数组 附带文件列表,以及应添加的工具。 No
内容 字符串 信息内容。 Yes
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
角色 字符串 创建消息的实体的角色。 允许的数值包括:
- user表示消息由实际用户发送,通常用于表示用户生成的消息。
- assistant表示消息由助手生成。 利用该值将助手的消息插入对话中。
Yes

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json messageObject

Examples

Example

创建一条信息。

POST https://{endpoint}/openai/threads/{thread_id}/messages?api-version=2025-04-01-preview

{
 "role": "user",
 "content": "What is the cube root of the sum of 12, 14, 1234, 4321, 90000, 123213541223, 443123123124, 5423324234, 234324324234, 653434534545, 200000000, 98237432984, 99999999, 99999999999, 220000000000, 3309587702? Give me the answer rounded to the nearest integer without commas or spaces."
}

回复:状态代码:200

{
  "body": {
    "id": "msg_as3XIk1tpVP3hdHjWBGg3uG4",
    "object": "thread.message",
    "created_at": 1707298421,
    "assistant_id": null,
    "thread_id": "thread_v7V4csrNOxtNmgcwGg496Smx",
    "run_id": null,
    "role": "user",
    "content": [
      {
        "type": "text",
        "text": {
          "value": "What is the cube root of the sum of 12, 14, 1234, 4321, 90000, 123213541223, 443123123124, 5423324234, 234324324234, 653434534545, 200000000, 98237432984, 99999999, 99999999999, 220000000000, 3309587702? Give me the answer rounded to the nearest integer without commas or spaces.",
          "annotations": []
        }
      }
    ],
    "attachments": [],
    "metadata": {}
  }
}

获取 - 留言

GET https://{endpoint}/openai/threads/{thread_id}/messages/{message_id}?api-version=2025-04-01-preview

获取一条信息。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 该消息所属的线程ID。
message_id 路径 Yes 字符串 要取回消息的ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json messageObject

Examples

Example

获取一条信息。

GET https://{endpoint}/openai/threads/{thread_id}/messages/{message_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "msg_as3XIk1tpVP3hdHjWBGg3uG4",
    "object": "thread.message",
    "created_at": 1707298421,
    "thread_id": "thread_v7V4csrNOxtNmgcwGg496Smx",
    "role": "user",
    "content": [
      {
        "type": "text",
        "text": {
          "value": "What is the cube root of the sum of 12, 14, 1234, 4321, 90000, 123213541223, 443123123124, 5423324234, 234324324234, 653434534545, 200000000, 98237432984, 99999999, 99999999999, 220000000000, 3309587702? Give me the answer rounded to the nearest integer without commas or spaces.",
          "annotations": []
        }
      }
    ],
    "file_ids": [],
    "assistant_id": null,
    "run_id": null,
    "metadata": {}
  }
}

修改 - 信息

POST https://{endpoint}/openai/threads/{thread_id}/messages/{message_id}?api-version=2025-04-01-preview

修改消息。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 该消息所属的线程ID。
message_id 路径 Yes 字符串 要修改消息的ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json messageObject

Examples

Example

修改一条消息。

POST https://{endpoint}/openai/threads/{thread_id}/messages/{message_id}?api-version=2025-04-01-preview

{
 "metadata": {
  "modified": "true",
  "user": "abc123"
 }
}

回复:状态代码:200

{
  "body": {
    "id": "msg_abc123",
    "object": "thread.message",
    "created_at": 1699017614,
    "assistant_id": null,
    "thread_id": "thread_abc123",
    "run_id": null,
    "role": "user",
    "content": [
      {
        "type": "text",
        "text": {
          "value": "How does AI work? Explain it in simple terms.",
          "annotations": []
        }
      }
    ],
    "file_ids": [],
    "metadata": {
      "modified": "true",
      "user": "abc123"
    }
  }
}

创建 - 线程与运行

Note

助理API已被弃用,将于2026年8月26日退役。 使用普遍可用的Microsoft铸造代理服务。 按照 迁移指南 更新你的工作负载。 Learn more.

POST https://{endpoint}/openai/threads/runs?api-version=2025-04-01-preview

创建一个线程,一次性运行。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
assistant_id 字符串 执行本次运行时使用的助手ID。 Yes
instructions 字符串 覆盖助理的默认系统消息。 这对于每次运行修改行为非常有用。 No
max_completion_tokens 整数 在本次运行过程中可使用的最大完成代币数量。 该跑法尽力只使用指定数量的完成标记,分多个回合进行。 如果运行超过指定完成标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
max_prompt_tokens 整数 在整个游戏过程中,最多可使用提示代币数。 该游戏尽力在多个回合中只使用指定的提示标记数量。 如果运行超过指定提示标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 用于执行本次运行的模型ID。 如果这里提供了某个值,它会覆盖与助手关联的模型。 如果没有,则使用与助手关联的模型。 No
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
数据流 boolean 如果 true,则返回运行期间发生的事件流,作为服务器发送的事件,运行进入终端状态并发送 data: [DONE] 消息时终止。
No
stream_options chatCompletionStreamOptions 流式响应选项。 只有在你设置 stream: true时才会设置这个。
No None
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
会话 createThreadRequest No
tool_choice assistantsApiToolChoiceOption 控制模型调用的(如果有)工具。
none 这意味着模型不会调用任何工具,而是生成一条消息。
auto 是默认值,意味着模型可以选择生成消息或调用工具。
指定某个特定工具,比如 {"type": "file_search"}{"type": "function", "function": {"name": "my_function"}} ,强制模型调用该工具。
No
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 这个助手附着的向量存储ID。 助手最多只能连接一个向量存储。
No
tools 数组 覆盖助理本次运行时可用的工具。 这对于每次运行修改行为非常有用。 No
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1
truncation_strategy truncationObject 控制线程在运行前如何截断。 用它来控制运行的初始上下文窗口。 No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runObject

Examples

Example

创建一个线程,一次性运行。

POST https://{endpoint}/openai/threads/runs?api-version=2025-04-01-preview

{
 "assistant_id": "asst_abc123",
 "thread": {
  "messages": [
   {
    "role": "user",
    "content": "Explain deep learning to a 5 year old."
   }
  ]
 }
}

回复:状态代码:200

{
  "body": {
    "id": "run_abc123",
    "object": "thread.run",
    "created_at": 1699076792,
    "assistant_id": "asst_abc123",
    "thread_id": "thread_abc123",
    "status": "queued",
    "started_at": null,
    "expires_at": 1699077392,
    "cancelled_at": null,
    "failed_at": null,
    "completed_at": null,
    "required_action": null,
    "last_error": null,
    "model": "gpt-4-turbo",
    "instructions": "You are a helpful assistant.",
    "tools": [],
    "tool_resources": {},
    "metadata": {},
    "temperature": 1.0,
    "top_p": 1.0,
    "max_completion_tokens": null,
    "max_prompt_tokens": null,
    "truncation_strategy": {
      "type": "auto",
      "last_messages": null
    },
    "incomplete_details": null,
    "usage": null,
    "response_format": "auto",
    "tool_choice": "auto"
  }
}

列表- 得分

GET https://{endpoint}/openai/threads/{thread_id}/runs?api-version=2025-04-01-preview

返回属于某个线程的运行列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 运行所属的线程ID。
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listRunsResponse

Examples

Example

返回属于某个线程的运行列表。

GET https://{endpoint}/openai/threads/{thread_id}/runs?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "run_abc123",
        "object": "thread.run",
        "created_at": 1699075072,
        "assistant_id": "asst_abc123",
        "thread_id": "thread_abc123",
        "status": "completed",
        "started_at": 1699075072,
        "expires_at": null,
        "cancelled_at": null,
        "failed_at": null,
        "completed_at": 1699075073,
        "last_error": null,
        "model": "gpt-4-turbo",
        "instructions": null,
        "incomplete_details": null,
        "tools": [
          {
            "type": "code_interpreter"
          }
        ],
        "tool_resources": {
          "code_interpreter": {
            "file_ids": [
              "file-abc123",
              "file-abc456"
            ]
          }
        },
        "metadata": {},
        "usage": {
          "prompt_tokens": 123,
          "completion_tokens": 456,
          "total_tokens": 579
        },
        "temperature": 1.0,
        "top_p": 1.0,
        "max_prompt_tokens": 1000,
        "max_completion_tokens": 1000,
        "truncation_strategy": {
          "type": "auto",
          "last_messages": null
        },
        "response_format": "auto",
        "tool_choice": "auto"
      },
      {
        "id": "run_abc456",
        "object": "thread.run",
        "created_at": 1699063290,
        "assistant_id": "asst_abc123",
        "thread_id": "thread_abc123",
        "status": "completed",
        "started_at": 1699063290,
        "expires_at": null,
        "cancelled_at": null,
        "failed_at": null,
        "completed_at": 1699063291,
        "last_error": null,
        "model": "gpt-4-turbo",
        "instructions": null,
        "incomplete_details": null,
        "tools": [
          {
            "type": "code_interpreter"
          }
        ],
        "tool_resources": {
          "code_interpreter": {
            "file_ids": [
              "file-abc123",
              "file-abc456"
            ]
          }
        },
        "metadata": {},
        "usage": {
          "prompt_tokens": 123,
          "completion_tokens": 456,
          "total_tokens": 579
        },
        "temperature": 1.0,
        "top_p": 1.0,
        "max_prompt_tokens": 1000,
        "max_completion_tokens": 1000,
        "truncation_strategy": {
          "type": "auto",
          "last_messages": null
        },
        "response_format": "auto",
        "tool_choice": "auto"
      }
    ],
    "first_id": "run_abc123",
    "last_id": "run_abc456",
    "has_more": false
  }
}

创作 - 运行

POST https://{endpoint}/openai/threads/{thread_id}/runs?api-version=2025-04-01-preview

创建一次跑动。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 要运行的线程ID。
include[] 查询 No 数组 回答中需要包含的额外字段列表。 目前唯一支持的值是 step_details.tool_calls[*].file_search.results[*].content 获取文件搜索结果内容。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
additional_instructions 字符串 在运行指令的结尾附加额外指令。 这对于每次运行修改行为而不会覆盖其他指令非常有用。 No
additional_messages 数组 在创建运行前向线程添加额外消息。 No
assistant_id 字符串 执行本次运行时使用的助手ID。 Yes
instructions 字符串 覆盖助理的默认系统消息。 这对于每次运行修改行为非常有用。 No
max_completion_tokens 整数 在本次运行过程中可使用的最大完成代币数量。 该跑法尽力只使用指定数量的完成标记,分多个回合进行。 如果运行超过指定完成标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
max_prompt_tokens 整数 在整个游戏过程中,最多可使用提示代币数。 该游戏尽力在多个回合中只使用指定的提示标记数量。 如果运行超过指定提示标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 用于执行本次运行的模型ID。 如果这里提供了某个值,它会覆盖与助手关联的模型。 如果没有,则使用与助手关联的模型。 No
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
数据流 boolean 如果 true,则返回运行期间发生的事件流,作为服务器发送的事件,运行进入终端状态并发送 data: [DONE] 消息时终止。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_choice assistantsApiToolChoiceOption 控制模型调用的(如果有)工具。
none 这意味着模型不会调用任何工具,而是生成一条消息。
auto 是默认值,意味着模型可以选择生成消息或调用工具。
指定某个特定工具,比如 {"type": "file_search"}{"type": "function", "function": {"name": "my_function"}} ,强制模型调用该工具。
No
tools 数组 覆盖助理本次运行时可用的工具。 这对于每次运行修改行为非常有用。 No
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1
truncation_strategy truncationObject 控制线程在运行前如何截断。 用它来控制运行的初始上下文窗口。 No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runObject

Examples

Example

创建一次跑动。

POST https://{endpoint}/openai/threads/{thread_id}/runs?api-version=2025-04-01-preview

{
 "assistant_id": "asst_abc123"
}

回复:状态代码:200

{
  "body": {
    "id": "run_abc123",
    "object": "thread.run",
    "created_at": 1699063290,
    "assistant_id": "asst_abc123",
    "thread_id": "thread_abc123",
    "status": "queued",
    "started_at": 1699063290,
    "expires_at": null,
    "cancelled_at": null,
    "failed_at": null,
    "completed_at": 1699063291,
    "last_error": null,
    "model": "gpt-4-turbo",
    "instructions": null,
    "incomplete_details": null,
    "tools": [
      {
        "type": "code_interpreter"
      }
    ],
    "metadata": {},
    "usage": null,
    "temperature": 1.0,
    "top_p": 1.0,
    "max_prompt_tokens": 1000,
    "max_completion_tokens": 1000,
    "truncation_strategy": {
      "type": "auto",
      "last_messages": null
    },
    "response_format": "auto",
    "tool_choice": "auto"
  }
}

跑 - 跑

GET https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}?api-version=2025-04-01-preview

抢回一分。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 被运行的线程的ID。
run_id 路径 Yes 字符串 要取回的任务编号。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runObject

Examples

Example

跑了一圈。

GET https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "run_HsO8tYM4K5AAMAHgK0J3om8Q",
    "object": "thread.run",
    "created_at": 1707303196,
    "assistant_id": "asst_JtTwHk28cIocgFXZPCBxhOzl",
    "thread_id": "thread_eRNwflE3ncDYak1np6MdMHJh",
    "status": "completed",
    "started_at": 1707303197,
    "expires_at": null,
    "cancelled_at": null,
    "failed_at": null,
    "completed_at": 1707303201,
    "last_error": null,
    "model": "gpt-4-1106-preview",
    "instructions": "You are an AI model that empowers every person and every organization on the planet to achieve more.",
    "tools": [],
    "file_ids": [],
    "metadata": {}
  }
}

修改 - 运行

POST https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}?api-version=2025-04-01-preview

修改跑动。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 被运行的线程的ID。
run_id 路径 Yes 字符串 修改的运行ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runObject

Examples

Example

修改跑动。

POST https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}?api-version=2025-04-01-preview

{
 "metadata": {
  "user_id": "user_abc123"
 }
}

回复:状态代码:200

{
  "body": {
    "id": "run_abc123",
    "object": "thread.run",
    "created_at": 1699075072,
    "assistant_id": "asst_abc123",
    "thread_id": "thread_abc123",
    "status": "completed",
    "started_at": 1699075072,
    "expires_at": null,
    "cancelled_at": null,
    "failed_at": null,
    "completed_at": 1699075073,
    "last_error": null,
    "model": "gpt-4-turbo",
    "instructions": null,
    "incomplete_details": null,
    "tools": [
      {
        "type": "code_interpreter"
      }
    ],
    "tool_resources": {
      "code_interpreter": {
        "file_ids": [
          "file-abc123",
          "file-abc456"
        ]
      }
    },
    "metadata": {
      "user_id": "user_abc123"
    },
    "usage": {
      "prompt_tokens": 123,
      "completion_tokens": 456,
      "total_tokens": 579
    },
    "temperature": 1.0,
    "top_p": 1.0,
    "max_prompt_tokens": 1000,
    "max_completion_tokens": 1000,
    "truncation_strategy": {
      "type": "auto",
      "last_messages": null
    },
    "response_format": "auto",
    "tool_choice": "auto"
  }
}

提交 - 工具输出

POST https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/submit_tool_outputs?api-version=2025-04-01-preview

当一次运行中 和 status: "requires_action"required_action.typesubmit_tool_outputs时,这个端点可以用来提交工具调用的输出,一旦它们全部完成。 所有输出必须一次性提交。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 本运行所属线程的ID。
run_id 路径 Yes 字符串 需要提交工具输出的运行ID。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
数据流 boolean 如果 true,则返回运行期间发生的事件流,作为服务器发送的事件,运行进入终端状态并发送 data: [DONE] 消息时终止。
No
tool_outputs 数组 一份提交输出的工具列表。 Yes

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runObject

Examples

Example

当一次运行中 和 status: "requires_action"required_action.typesubmit_tool_outputs时,这个端点可以用来提交工具调用的输出,一旦它们全部完成。 所有输出必须一次性提交。

POST https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/submit_tool_outputs?api-version=2025-04-01-preview

{
 "tool_outputs": [
  {
   "tool_call_id": "call_001",
   "output": "70 degrees and sunny."
  }
 ]
}

回复:状态代码:200

{
  "body": {
    "id": "run_123",
    "object": "thread.run",
    "created_at": 1699075592,
    "assistant_id": "asst_123",
    "thread_id": "thread_123",
    "status": "queued",
    "started_at": 1699075592,
    "expires_at": 1699076192,
    "cancelled_at": null,
    "failed_at": null,
    "completed_at": null,
    "last_error": null,
    "model": "gpt-4-turbo",
    "instructions": null,
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_current_weather",
          "description": "Get the current weather in a given location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA"
              },
              "unit": {
                "type": "string",
                "enum": [
                  "celsius",
                  "fahrenheit"
                ]
              }
            },
            "required": [
              "location"
            ]
          }
        }
      }
    ],
    "metadata": {},
    "usage": null,
    "temperature": 1.0,
    "top_p": 1.0,
    "max_prompt_tokens": 1000,
    "max_completion_tokens": 1000,
    "truncation_strategy": {
      "type": "auto",
      "last_messages": null
    },
    "response_format": "auto",
    "tool_choice": "auto"
  }
}

取消 - 逃跑

POST https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/cancel?api-version=2025-04-01-preview

取消了运行, in_progress即 。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 本运行所属的线程ID。
run_id 路径 Yes 字符串 取消的订单编号。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runObject

Examples

Example

取消了运行, in_progress即 。

POST https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/cancel?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "run_abc123",
    "object": "thread.run",
    "created_at": 1699076126,
    "assistant_id": "asst_abc123",
    "thread_id": "thread_abc123",
    "status": "cancelling",
    "started_at": 1699076126,
    "expires_at": 1699076726,
    "cancelled_at": null,
    "failed_at": null,
    "completed_at": null,
    "last_error": null,
    "model": "gpt-4-turbo",
    "instructions": "You summarize books.",
    "tools": [
      {
        "type": "file_search"
      }
    ],
    "tool_resources": {
      "file_search": {
        "vector_store_ids": [
          "vs_123"
        ]
      }
    },
    "metadata": {},
    "usage": null,
    "temperature": 1.0,
    "top_p": 1.0,
    "response_format": "auto"
  }
}

列表 - 跑步步伐

GET https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/steps?api-version=2025-04-01-preview

返回属于某次运行的运行步骤列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 运行和运行步骤所属的线程ID。
run_id 路径 Yes 字符串 跑步所属的跑动ID。
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
api-version 查询 Yes 字符串
include[] 查询 No 数组 回答中需要包含的额外字段列表。 目前唯一支持的值是 step_details.tool_calls[*].file_search.results[*].content 获取文件搜索结果内容。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listRunStepsResponse

Examples

Example

返回属于某次运行的运行步骤列表。

GET https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/steps?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "step_abc123",
        "object": "thread.run.step",
        "created_at": 1699063291,
        "run_id": "run_abc123",
        "assistant_id": "asst_abc123",
        "thread_id": "thread_abc123",
        "type": "message_creation",
        "status": "completed",
        "cancelled_at": null,
        "completed_at": 1699063291,
        "expired_at": null,
        "failed_at": null,
        "last_error": null,
        "step_details": {
          "type": "message_creation",
          "message_creation": {
            "message_id": "msg_abc123"
          }
        },
        "usage": {
          "prompt_tokens": 123,
          "completion_tokens": 456,
          "total_tokens": 579
        }
      }
    ],
    "first_id": "step_abc123",
    "last_id": "step_abc456",
    "has_more": false
  }
}

获取 - 跑步

GET https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/steps/{step_id}?api-version=2025-04-01-preview

取回跑步。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
thread_id 路径 Yes 字符串 运行和运行步骤所属的线程ID。
run_id 路径 Yes 字符串 运行步所属的跑道ID。
step_id 路径 Yes 字符串 要取回的执行步骤的ID。
include[] 查询 No 数组 回答中需要包含的额外字段列表。 目前唯一支持的值是 step_details.tool_calls[*].file_search.results[*].content 获取文件搜索结果内容。
api-version 查询 Yes 字符串

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json runStepObject

Examples

Example

取回跑步。

GET https://{endpoint}/openai/threads/{thread_id}/runs/{run_id}/steps/{step_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "step_abc123",
    "object": "thread.run.step",
    "created_at": 1699063291,
    "run_id": "run_abc123",
    "assistant_id": "asst_abc123",
    "thread_id": "thread_abc123",
    "type": "message_creation",
    "status": "completed",
    "cancelled_at": null,
    "completed_at": 1699063291,
    "expired_at": null,
    "failed_at": null,
    "last_error": null,
    "step_details": {
      "type": "message_creation",
      "message_creation": {
        "message_id": "msg_abc123"
      }
    },
    "usage": {
      "prompt_tokens": 123,
      "completion_tokens": 456,
      "total_tokens": 579
    }
  }
}

列表 - 向量存储

GET https://{endpoint}/openai/vector_stores?api-version=2025-04-01-preview

返回向量存储列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listVectorStoresResponse

Examples

Example

返回向量存储列表。

GET https://{endpoint}/openai/vector_stores?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "vs_abc123",
        "object": "vector_store",
        "created_at": 1699061776,
        "name": "Support FAQ",
        "bytes": 139920,
        "file_counts": {
          "in_progress": 0,
          "completed": 3,
          "failed": 0,
          "cancelled": 0,
          "total": 3
        }
      },
      {
        "id": "vs_abc456",
        "object": "vector_store",
        "created_at": 1699061776,
        "name": "Support FAQ v2",
        "bytes": 139920,
        "file_counts": {
          "in_progress": 0,
          "completed": 3,
          "failed": 0,
          "cancelled": 0,
          "total": 3
        }
      }
    ],
    "first_id": "vs_abc123",
    "last_id": "vs_abc456",
    "has_more": false
  }
}

创建 - 向量存储

POST https://{endpoint}/openai/vector_stores?api-version=2025-04-01-preview

创建一个矢量存储。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
chunking_strategy autoChunkingStrategyRequestParamstaticChunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 仅当 file_ids 非空时 才适用。 No
expires_after vectorStoreExpirationAfter 向量存储的过期政策。 No
file_ids 数组 一份向量存储应使用的文件ID列表。 对于这类工具 file_search 来说,它能访问文件非常有用。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
name 字符串 向量存储器的名字。 No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreObject

Examples

Example

创建向量存储。

POST https://{endpoint}/openai/vector_stores?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "vs_abc123",
    "object": "vector_store",
    "created_at": 1699061776,
    "name": "Support FAQ",
    "bytes": 139920,
    "file_counts": {
      "in_progress": 0,
      "completed": 3,
      "failed": 0,
      "cancelled": 0,
      "total": 3
    }
  }
}

获取 - 向量商店

GET https://{endpoint}/openai/vector_stores/{vector_store_id}?api-version=2025-04-01-preview

检索向量存储器。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 要检索的向量存储的ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreObject

Examples

Example

检索向量存储器。

GET https://{endpoint}/openai/vector_stores/{vector_store_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "vs_abc123",
    "object": "vector_store",
    "created_at": 1699061776
  }
}

修改 - 向量存储

POST https://{endpoint}/openai/vector_stores/{vector_store_id}?api-version=2025-04-01-preview

修改向量存储。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 要修改的向量存储ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
expires_after vectorStoreExpirationAfter 向量存储的过期政策。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
name 字符串 向量存储器的名字。 No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreObject

Examples

Example

修改向量存储。

POST https://{endpoint}/openai/vector_stores/{vector_store_id}?api-version=2025-04-01-preview

{
 "name": "Support FAQ"
}

回复:状态代码:200

{
  "body": {
    "id": "vs_abc123",
    "object": "vector_store",
    "created_at": 1699061776,
    "name": "Support FAQ",
    "bytes": 139920,
    "file_counts": {
      "in_progress": 0,
      "completed": 3,
      "failed": 0,
      "cancelled": 0,
      "total": 3
    }
  }
}

删除 - 向量存储

DELETE https://{endpoint}/openai/vector_stores/{vector_store_id}?api-version=2025-04-01-preview

删除向量存储。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 要删除的向量存储的ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json deleteVectorStoreResponse

Examples

Example

删除了一个向量存储器。

DELETE https://{endpoint}/openai/vector_stores/{vector_store_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "vs_abc123",
    "object": "vector_store.deleted",
    "deleted": true
  }
}

列表 - 向量存储文件

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/files?api-version=2025-04-01-preview

返回一份矢量存储文件列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件所属的向量存储的ID。
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
筛选器 查询 No 字符串
可能的值: in_progresscompletedfailedcancelled
按文件状态筛选。 其中一个,completed,,failedcancelledin_progress
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listVectorStoreFilesResponse

Examples

Example

返回一份矢量存储文件列表。

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/files?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "file-abc123",
        "object": "vector_store.file",
        "created_at": 1699061776,
        "vector_store_id": "vs_abc123"
      },
      {
        "id": "file-abc456",
        "object": "vector_store.file",
        "created_at": 1699061776,
        "vector_store_id": "vs_abc123"
      }
    ],
    "first_id": "file-abc123",
    "last_id": "file-abc456",
    "has_more": false
  }
}

创建 - 向量存储文件

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/files?api-version=2025-04-01-preview

通过将文件附加到矢量存储中来创建矢量存储文件。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 用于创建文件的向量存储的ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
chunking_strategy chunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 No
file_id 字符串 向量存储应该使用的文件ID。 对于这类工具 file_search 来说,它能访问文件非常有用。 Yes

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreFileObject

Examples

Example

通过将文件附加到矢量存储中来创建矢量存储文件。

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/files?api-version=2025-04-01-preview

{
 "file_id": "file-abc123"
}

回复:状态代码:200

{
  "body": {
    "id": "file-abc123",
    "object": "vector_store.file",
    "created_at": 1699061776,
    "usage_bytes": 1234,
    "vector_store_id": "vs_abcd",
    "status": "completed",
    "last_error": null
  }
}

获取 - 矢量存储文件

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/files/{file_id}?api-version=2025-04-01-preview

检索向量存储文件。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件所属的向量存储的ID。
file_id 路径 Yes 字符串 被检索文件的ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreFileObject

Examples

Example

检索向量存储文件。

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/files/{file_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "file-abc123",
    "object": "vector_store.file",
    "created_at": 1699061776,
    "vector_store_id": "vs_abcd",
    "status": "completed",
    "last_error": null
  }
}

删除 - 向量存储文件

DELETE https://{endpoint}/openai/vector_stores/{vector_store_id}/files/{file_id}?api-version=2025-04-01-preview

删除一个矢量存储文件。 这会把文件从矢量存储中移除,但文件本身不会被删除。 要删除文件,请使用删除文件端点。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件所属的向量存储的ID。
file_id 路径 Yes 字符串 要删除的文件ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json deleteVectorStoreFileResponse

Examples

Example

删除一个矢量存储文件。 这会把文件从矢量存储中移除,但文件本身不会被删除。 要删除文件,请使用删除文件端点。

DELETE https://{endpoint}/openai/vector_stores/{vector_store_id}/files/{file_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "file_abc123",
    "object": "vector_store.file.deleted",
    "deleted": true
  }
}

Updatevectorstorefileattributes

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/files/{file_id}?api-version=2025-04-01-preview

更新向量存储文件的属性。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件所属的矢量存储的ID。
file_id 路径 Yes 字符串 文件的ID用于更新属性。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
attributes VectorStoreFileAttributes 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。 键是最大长度为64个字符的字符串。 值是最大长度为512个字符的字符串、布尔数或数字。
Yes

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreFileObject

检索向量存储文件内容

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/files/{file_id}/content?api-version=2025-04-01-preview

检索向量存储文件的解析内容。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 向量存储器的ID。
file_id 路径 Yes 字符串 向量存储中文件的ID。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json VectorStoreFileContentResponse

搜索向量存储

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/search?api-version=2025-04-01-preview

通过查询和文件属性筛选,在矢量存储中搜索相关区块。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 用于搜索的向量存储ID。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
filters 比较滤波器复合滤波器 基于文件属性应用过滤器。 No
max_num_results 整数 最多可返回的结果数。 这个数字应在1到50之间(含)。 No 10
查询 字符串或数组 用于搜索的查询字符串 Yes
ranking_options 对象 搜索排名选项。 No
└─ ranker 枚举
可能的值: autodefault-2024-11-15
No
└─ score_threshold number No 0
rewrite_query boolean 是否重写向量搜索的自然语言查询。 No False

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json VectorStoreSearchResultsPage

创建 - 向量存储文件批量处理

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches?api-version=2025-04-01-preview

创建一个向量存储文件批处理。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 创建文件批处理的向量存储ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Request Body

Content-Type: application/json

Name 类型 Description Required Default
chunking_strategy chunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 No
file_ids 数组 一份向量存储应该使用的文件ID列表。 对于这类工具 file_search 来说,它能访问文件非常有用。 Yes

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreFileBatchObject

Examples

Example

创建一个向量存储文件批处理。

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches?api-version=2025-04-01-preview

{
 "file_ids": [
  "file-abc123",
  "file-abc456"
 ]
}

回复:状态代码:200

{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "in_progress",
  "file_counts": {
    "in_progress": 1,
    "completed": 1,
    "failed": 0,
    "cancelled": 0,
    "total": 0
  }
}

获取 - 向量存储文件批处理

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches/{batch_id}?api-version=2025-04-01-preview

检索向量存储批处理文件。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件批处理所属的向量存储的ID。
batch_id 路径 Yes 字符串 被检索批处理文件的ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreFileBatchObject

Examples

Example

检索向量存储批处理文件。

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches/{batch_id}?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "vsfb_abc123",
    "object": "vector_store.file_batch",
    "created_at": 1699061776,
    "vector_store_id": "vs_abc123",
    "status": "in_progress",
    "file_counts": {
      "in_progress": 1,
      "completed": 1,
      "failed": 0,
      "cancelled": 0,
      "total": 0
    }
  }
}

取消 - 向量存储文件批处理

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel?api-version=2025-04-01-preview

取消向量存储文件批处理。 这会尽快取消该批次文件的处理。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件批处理所属的向量存储的ID。
batch_id 路径 Yes 字符串 要取消的文件批次的ID。
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json vectorStoreFileBatchObject

Examples

Example

取消向量存储文件批处理。 这会尽快取消该批次文件的处理。

POST https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "id": "vsfb_abc123",
    "object": "vector_store.file_batch",
    "created_at": 1699061776,
    "vector_store_id": "vs_abc123",
    "status": "cancelling",
    "file_counts": {
      "in_progress": 12,
      "completed": 3,
      "failed": 0,
      "cancelled": 0,
      "total": 15
    }
  }
}

列表 - 矢量存储文件批处理文件

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches/{batch_id}/files?api-version=2025-04-01-preview

批量返回一份向量存储文件列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
vector_store_id 路径 Yes 字符串 文件所属的向量存储的ID。
batch_id 路径 Yes 字符串 文件所属批处理的 ID。
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
按对象的时间戳排序 created_at 顺序。 asc 分别表示升序和 desc 降序。
after 查询 No 字符串 用于分页的光标。 after 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个以obj_foo结尾的对象,你的后续调用可以包含 after =obj_foo,以便获取列表中的下一页。
before 查询 No 字符串 用于分页的光标。 before 是定义你在列表中位置的对象ID。 例如,如果你发起列表请求并收到100个对象,从obj_foo开始,你的后续调用可以包含before=obj_foo,以获取列表中的上一页。
筛选器 查询 No 字符串
可能的值: in_progresscompletedfailedcancelled
按文件状态筛选。 其中一个,completed,,failedcancelledin_progress
api-version 查询 Yes 字符串 api version

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json listVectorStoreFilesResponse

Examples

Example

返回一份矢量存储文件列表。

GET https://{endpoint}/openai/vector_stores/{vector_store_id}/file_batches/{batch_id}/files?api-version=2025-04-01-preview

回复:状态代码:200

{
  "body": {
    "object": "list",
    "data": [
      {
        "id": "file-abc123",
        "object": "vector_store.file",
        "created_at": 1699061776,
        "vector_store_id": "vs_abc123"
      },
      {
        "id": "file-abc456",
        "object": "vector_store.file",
        "created_at": 1699061776,
        "vector_store_id": "vs_abc123"
      }
    ],
    "first_id": "file-abc123",
    "last_id": "file-abc456",
    "has_more": false
  }
}

Create - Realtimesession

POST https://{endpoint}/openai/realtimeapi/sessions?api-version=2025-04-01-preview

创建一个临时的API令牌,用于客户端应用,使用Realtime API。 可以配置与客户端事件相同的会话参数 session.update 。 它响应一个会话对象,以及 client_secret 一个包含可用临时API令牌的密钥,可用于验证实时API的浏览器客户端。

Request Body

Content-Type: application/json

Name 类型 Description Required Default
input_audio_format 枚举 输入音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
对于 pcm16,输入音频必须是16位PCM,采样率为24kHz,单声道(单声道),字节序为小端。

可能的值: pcm16g711_ulawg711_alaw
No
input_audio_noise_reduction 对象 输入音频降噪配置。 可以设置为 null 关闭。
降噪滤波器会在音频添加到输入音频缓冲区前,先将其发送到VAD和模型。
过滤音频可以提高VAD和转向检测的准确性(减少误报),并通过改善输入音频的感知来提升模型性能。
No
└─ type 枚举 降噪类型。 near_field 是用于近距离通话麦克风(如耳机 far_field ),是用于远场麦克风(如笔记本电脑或会议室麦克风)。

可能的值: near_fieldfar_field
No
input_audio_transcription 对象 输入音频转录的配置默认为关闭,开启后可设置为 null 关闭。 输入音频转录并非模型本身,因为模型直接接收音频。 转录通过转 录端 点异步运行,应视为输入音频内容的指导,而非模型听到的具体内容。 客户可以选择设置转录的语言和提示,这些为转录服务提供了额外的指导。
No
└─ language 字符串 输入音频的语言。 以 ISO-639-1 (例如 en)格式提供输入语言可以提高准确性和延迟。
No
└─ model 字符串 用于转录的模型,目前的选项有 gpt-4o-transcribegpt-4o-transcribe-diarizegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1、 和 。
No
└─ prompt 字符串 可选文本,用于指导模型风格或延续之前的音频片段。
对于 whisper-1,提示词是关键词列表。
对于 gpt-4o-transcribe 模型,提示词是自由文本字符串,例如“expect words with technology”(期待与技术相关的词)。
No
instructions 字符串 默认系统指令(即系统消息)会在模型调用之前添加。 该字段允许客户引导模型制定期望的响应。 模型可以指导回答内容和格式(例如“极简明快”、“表现友好”、“这里有良好回应的例子”)以及音频行为(例如“快速说话”、“在声音中注入情感”、“频繁笑”)。 这些指令不保证模型一定遵循,但它们为模型提供了期望行为的指导。

注意服务器设置默认指令,如果该字段未设置,会在会话开始时的事件中可见 session.created
No
max_response_output_tokens 整数或字符串 单个助手响应的最大输出令牌数,包括工具调用。 提供介于1到4096之间的整数以限制输出令牌数,或 inf 表示给定模型的最大可用令牌数。 默认为 inf
No
modalities 模型能够回应的一组模态。 要禁用音频,请设置为[“text”]。
No
模型 字符串 本次会话使用的部署名称。
No
output_audio_format 枚举 输出音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
对于 pcm16,输出音频以24kHz的采样率进行采样。

可能的值: pcm16g711_ulawg711_alaw
No
temperature number 模型采样温度,限制在[0.6, 1.2]。 对于音频型号,强烈建议温度为0.8以获得最佳性能。
No 0.8
tool_choice 字符串 模型如何选择工具。 选项为 autononerequired或 指定函数。
No auto
tools 数组 模型可用的工具(功能)。 No
turn_detection 对象 回合检测配置,服务器VAD或语义VAD。 可以设置为 null 关闭,此时客户端必须手动触发模型响应。
服务器VAD意味着模型会根据音频音量检测语音的开始和结束,并在用户语音结束时作出响应。
语义VAD更为先进,使用转弯检测模型(结合VAD)语义估计用户是否已说完话,然后基于该概率动态设置超时。 例如,如果用户音频在 uhhm中渐渐消失,模型会得分较低的转折概率,并等待用户继续说话的时间更长。 这对更自然的对话很有用,但可能延迟较高。
No
└─ create_response boolean 当VAD停止事件发生时,是否会自动生成响应。
No True
└─ eagerness 枚举 仅用于 semantic_vad 模式。 模型的急切反应。 low 会等待更长时间让用户继续说话,并且 high 会更快回应。 auto 是默认值,等价于 medium

可能的值: lowmediumhighauto
No
└─ interrupt_response boolean 当VAD启动事件发生时,是否自动中断任何正在进行的响应并输出到默认对话(即 conversationauto)。
No True
└─ prefix_padding_ms 整数 仅用于 server_vad 模式。 VAD检测语音前需要包含的音频量(以毫秒计)。 默认为300毫秒。
No
└─ silence_duration_ms 整数 仅用于 server_vad 模式。 用来检测语音停止的静默持续时间(以毫秒计)。 默认为500毫秒。 值越短,模型响应越快,但可能会在用户短暂停顿时介入。
No
└─ threshold number 仅用于 server_vad 模式。 VAD的激活阈值(0.0到1.0),默认是0.5。 更高的阈值需要更响亮的声音来激活模型,因此在嘈杂环境中表现可能更好。
No
└─ type 枚举 转向检测类型。

可能的值: server_vadsemantic_vad
No
voice VoiceIdsShared No

Responses

状态代码: 200

描述:会话已成功创建。

Content-Type Type Description
application/json RealtimeSessionCreateResponse

创建 - 转录实时会话

POST https://{endpoint}/openai/realtimeapi/transcription_sessions?api-version=2025-04-01-preview

创建一个临时API令牌用于客户端应用,使用专门用于实时转录的Realtime API。 可以配置与客户端事件相同的会话参数 transcription_session.update 。 它响应一个会话对象,以及 client_secret 一个包含可用临时API令牌的密钥,可用于验证实时API的浏览器客户端。

Request Body

Content-Type: application/json

Name 类型 Description Required Default
include 数组 转录中应包含的项目集合。 目前可用的物品有:
- item.input_audio_transcription.logprobs
No
input_audio_format 枚举 输入音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
对于 pcm16,输入音频必须是16位PCM,采样率为24kHz,单声道(单声道),字节序为小端。

可能的值: pcm16g711_ulawg711_alaw
No
input_audio_noise_reduction 对象 输入音频降噪配置。 可以设置为 null 关闭。
降噪滤波器会在音频添加到输入音频缓冲区前,先将其发送到VAD和模型。
过滤音频可以提高VAD和转向检测的准确性(减少误报),并通过改善输入音频的感知来提升模型性能。
No
└─ type 枚举 降噪类型。 near_field 是用于近距离通话麦克风(如耳机 far_field ),是用于远场麦克风(如笔记本电脑或会议室麦克风)。

可能的值: near_fieldfar_field
No
input_audio_transcription 对象 输入音频转录配置。 客户可以选择设置转录的语言和提示,这些为转录服务提供了额外的指导。
No
└─ language 字符串 输入音频的语言。 以 ISO-639-1 (例如 en)格式提供输入语言可以提高准确性和延迟。
No
└─ model 枚举 用于转录的模型,目前的选项有 gpt-4o-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1

可能的值: gpt-4o-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1
No
└─ prompt 字符串 可选文本,用于指导模型风格或延续之前的音频片段。
对于 whisper-1,提示词是关键词列表。
对于 gpt-4o-transcribe 模型,提示词是自由文本字符串,例如“expect words with technology”(期待与技术相关的词)。
No
modalities 模型能够回应的一组模态。 要禁用音频,请设置为[“text”]。
No
turn_detection 对象 回合检测配置,服务器VAD或语义VAD。 可以设置为 null 关闭,此时客户端必须手动触发模型响应。
服务器VAD意味着模型会根据音频音量检测语音的开始和结束,并在用户语音结束时作出响应。
语义VAD更为先进,使用转弯检测模型(结合VAD)语义估计用户是否已说完话,然后基于该概率动态设置超时。 例如,如果用户音频在 uhhm中渐渐消失,模型会得分较低的转折概率,并等待用户继续说话的时间更长。 这对更自然的对话很有用,但可能延迟较高。
No
└─ create_response boolean 当VAD停止事件发生时,是否会自动生成响应。 不提供转录环节。
No True
└─ eagerness 枚举 仅用于 semantic_vad 模式。 模型的急切反应。 low 会等待更长时间让用户继续说话,并且 high 会更快回应。 auto 是默认值,等价于 medium

可能的值: lowmediumhighauto
No
└─ interrupt_response boolean 当VAD启动事件发生时,是否自动中断任何正在进行的响应并输出到默认对话(即 conversationauto)。 不提供转录环节。
No True
└─ prefix_padding_ms 整数 仅用于 server_vad 模式。 VAD检测语音前需要包含的音频量(以毫秒计)。 默认为300毫秒。
No
└─ silence_duration_ms 整数 仅用于 server_vad 模式。 用来检测语音停止的静默持续时间(以毫秒计)。 默认为500毫秒。 值越短,模型响应越快,但可能会在用户短暂停顿时介入。
No
└─ threshold number 仅用于 server_vad 模式。 VAD的激活阈值(0.0到1.0),默认是0.5。 更高的阈值需要更响亮的声音来激活模型,因此在嘈杂环境中表现可能更好。
No
└─ type 枚举 转向检测类型。

可能的值: server_vadsemantic_vad
No

Responses

状态代码: 200

描述:会话已成功创建。

Content-Type Type Description
application/json RealtimeTranscriptionSessionCreateResponse

Responses

POST https://{endpoint}/openai/responses?api-version=2025-04-01-preview

创建模型反应。

Request Body

Content-Type: application/json

Name 类型 Description Required Default
include 数组 No
输入 字符串或数组 Model inputs Yes
instructions 字符串 在模型上下文中插入系统(或开发者)消息作为首项。

当使用与 previous_response_id时,之前的响应指令不会被传递到下一个响应。 这使得在新回复中替换系统(或开发者)消息变得简单。
No
max_output_tokens 整数 这是响应中可生成的令牌数量的上限,包括可见的输出令牌和对话状态。
No
parallel_tool_calls boolean 是否允许模型并行运行工具调用。
No True
previous_response_id 字符串 之前对模型的回复的唯一ID。 利用这一点来创造多回合的对话。 了解更多关于会话状态的信息。
No
reasoning Reasoning 推理模型的配置选项。 No
存储 boolean 是否存储生成的模型响应以便通过API稍后检索。
No True
数据流 boolean 如果设置为 true,模型响应数据将在通过 服务器发送事件生成时流式传输到客户端。
更多信息请参见下方的流媒体部分。
No False
文本消息 对象 模型文本响应的配置选项。 可以是纯文本,也可以是结构化的JSON数据。 Learn more:
- 文本输入和输出
- 结构化输出
No
└─ format TextResponseFormatConfiguration 一个对象,指定模型必须输出的格式。

配置 { "type": "json_schema" } 可以启用结构化输出,确保模型与你提供的JSON模式匹配。

默认格式没有 { "type": "text" } 额外选项。

不推荐用于GPT-4o及更新型号:

设置启用 { "type": "json_object" } 旧的JSON模式,确保模型生成的消息是有效的JSON。 支持它的模型更倾向于使用 json_schema
No
tool_choice 工具选择选项(ToolChoiceOptions)、工具选择类型(ToolChoiceTypes)或工具选择函数(ToolChoiceFunction 模型在生成响应时应选择使用哪种工具。 请参见参数 tools ,了解如何指定模型可以调用哪些工具。
No
tools 数组 模型在生成响应时可能调用的一系列工具。 你可以通过设置 tool_choice 参数来指定使用哪个工具。

你可以为模型提供两类工具:

- 内置工具:由OpenAI提供的扩展工具
model's capabilities
No
truncation 枚举 用于模型响应的截断策略。
- auto:如果该回答和之前的上下文超过模型的上下文窗口大小,模型会通过在对话中间丢弃输入项来截断回答以适应上下文窗口。
- disabled (默认):如果模型响应超过模型的上下文窗口大小,请求将以400错误失败。

可能的值: autodisabled
No

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json response
text/event-stream responseStreamEvent

状态代码: 默认

描述:服务不可用

Content-Type Type Description
application/json errorResponse

响应 API - 输入项

GET https://{endpoint}/openai/responses/{response_id}?api-version=2025-04-01-preview

检索具有给定ID的模型响应。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
response_id 路径 Yes 字符串 要检索的响应ID。
include 查询 No 数组 回答中需要包含额外字段。 更多信息请参见 include 上方的响应创建参数。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json response

状态代码: 默认

描述:服务不可用

Content-Type Type Description
application/json errorResponse

Delete response

DELETE https://{endpoint}/openai/responses/{response_id}?api-version=2025-04-01-preview

删除带有指定ID的模型响应。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
response_id 路径 Yes 字符串 删除回复的ID。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

状态代码: 404

描述:未找到

Content-Type Type Description
application/json error

状态代码: 默认

描述:服务不可用

Content-Type Type Description
application/json errorResponse

Responses API - 响应项列表

GET https://{endpoint}/openai/responses/{response_id}/input_items?api-version=2025-04-01-preview

返回给定响应的输入项列表。

URI Parameters

Name In Required 类型 Description
终结点 路径 Yes string url 支持Azure OpenAI 端点(协议和主机名,例如:https://aoairesource.openai.azure.com。将“aoairesource”替换为你的Azure OpenAI资源名称)。 https://{your-resource-name}.openai.azure.com
response_id 路径 Yes 字符串 用于检索输入项的响应ID。
limit 查询 No 整数 限制了可归还的物品数量。 限制范围在1到100之间,默认是20。
顺序 查询 No 字符串
可能的值: ascdesc
归还输入项的顺序。 默认是 asc
- asc: 按升序返回输入项。
- desc: 按降序返回输入项。
after 查询 No 字符串 用于分页的项目ID,用于列表。
before 查询 No 字符串 用于分页的项目ID,用于之前的列表。

Request Header

使用基于令牌的认证或API密钥。 建议使用基于令牌的认证,且更安全。

Name Required 类型 Description
Authorization True 字符串 Example:Authorization: Bearer {Azure_OpenAI_Auth_Token}

使用 Azure CLI 生成认证令牌:az account get-access-token --resource https://cognitiveservices.azure.com

Type: oauth2
授权网址: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
范围: https://ai.azure.com/.default
api-key True 字符串 Provide Azure OpenAI API key here

Responses

状态代码: 200

Description: OK

Content-Type Type Description
application/json responseItemList

Components

errorResponse

Name 类型 Description Required Default
错误 error No

errorBase

Name 类型 Description Required Default
代码 字符串 No
消息 字符串 No

错误

Name 类型 Description Required Default
inner_error innerError 内部错误,附加细节。 No
param 字符串 No
类型 字符串 No

innerError

内部错误,附加细节。

Name 类型 Description Required Default
代码 innerErrorCode 内部错误对象的错误代码。 No
content_filter_results contentFilterPromptResults 关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于越狱内容和脏话的信息,是否被检测到,以及是否经过过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。 No

innerErrorCode

内部错误对象的错误代码。

Property Value
Description 内部错误对象的错误代码。
Type 字符串
Values ResponsibleAIPolicyViolation

dalleErrorResponse

Name 类型 Description Required Default
错误 dalleError No

dalleError

Name 类型 Description Required Default
inner_error dalleInnerError 内部错误,附加细节。 No
param 字符串 No
类型 字符串 No

dalleInnerError

内部错误,附加细节。

Name 类型 Description Required Default
代码 innerErrorCode 内部错误对象的错误代码。 No
content_filter_results dalleFilterResults 关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于越狱内容和脏话的信息,是否被检测到,以及是否经过过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。 No
revised_prompt 字符串 如果提示词有任何修改,那就是用来生成图片的提示词。 No

contentFilterCompletionTextSpan

描述生成完备文本中的一个跨度。 偏移 0 是补全文本的第一个 UTF32 码点。

Name 类型 Description Required Default
completion_end_offset 整数 偏移量为第一个UTF32码点,该码点被排除在该段之外。 对于空跨,该域始终等于completion_start_offset。 对于非空跨,该场总是大于completion_start_offset。 Yes
completion_start_offset 整数 UTF32码点的偏移量,该码点是该区间的起始。 Yes

contentFilterResultBase

Name 类型 Description Required Default
filtered boolean Yes

contentFilterSeverityResult

Name 类型 Description Required Default
filtered boolean Yes
severity 字符串 No

contentFilterDetectedResult

Name 类型 Description Required Default
detected boolean No
filtered boolean Yes

contentFilterDetectedWithCitationResult

Name 类型 Description Required Default
citation 对象 No
└─ URL 字符串 No
└─ license 字符串 No

contentFilterDetectedWithCompletionTextSpansResult

Name 类型 Description Required Default
details 数组 No

contentFilterIdResult

Name 类型 Description Required Default
filtered boolean Yes
id 字符串 No

contentFilterResultsBase

关于内容过滤结果的信息。

Name 类型 Description Required Default
custom_blocklists contentFilterDetailedResults 内容过滤结果会显示被过滤片段的内容过滤ID详细信息。 No
错误 errorBase No
hate contentFilterSeverityResult No
profanity contentFilterDetectedResult No
self_harm contentFilterSeverityResult No
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No

contentFilterPromptResults

关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于越狱内容和脏话的信息,是否被检测到,以及是否经过过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。

Name 类型 Description Required Default
custom_blocklists contentFilterDetailedResults 内容过滤结果会显示被过滤片段的内容过滤ID详细信息。 No
错误 errorBase No
hate contentFilterSeverityResult No
indirect_attack contentFilterDetectedResult No
jailbreak contentFilterDetectedResult No
profanity contentFilterDetectedResult No
self_harm contentFilterSeverityResult No
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No

contentFilterChoiceResults

关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于第三方文本和脏话的信息,是否检测到,以及是否被过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。

Name 类型 Description Required Default
custom_blocklists contentFilterDetailedResults 内容过滤结果会显示被过滤片段的内容过滤ID详细信息。 No
错误 errorBase No
hate contentFilterSeverityResult No
profanity contentFilterDetectedResult No
protected_material_code contentFilterDetectedWithCitationResult No
protected_material_text contentFilterDetectedResult No
self_harm contentFilterSeverityResult No
sexual contentFilterSeverityResult No
ungrounded_material contentFilterDetectedWithCompletionTextSpansResult No
violence contentFilterSeverityResult No

contentFilterDetailedResults

内容过滤结果会显示被过滤片段的内容过滤ID详细信息。

Name 类型 Description Required Default
details 数组 No
filtered boolean Yes

promptFilterResult

请求中单个提示的内容过滤结果。

Name 类型 Description Required Default
content_filter_results contentFilterPromptResults 关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于越狱内容和脏话的信息,是否被检测到,以及是否经过过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。 No
prompt_index 整数 No

promptFilterResults

请求中零个或多个提示的内容过滤结果。 在流媒体请求中,不同提示的结果可能在不同时间或顺序出现。

该组件没有定义属性。

dalleContentFilterResults

关于内容过滤结果的信息。

Name 类型 Description Required Default
hate contentFilterSeverityResult No
self_harm contentFilterSeverityResult No
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No

dalleFilterResults

关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于越狱内容和脏话的信息,是否被检测到,以及是否经过过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。

Name 类型 Description Required Default
custom_blocklists contentFilterDetailedResults 内容过滤结果会显示被过滤片段的内容过滤ID详细信息。 No
hate contentFilterSeverityResult No
jailbreak contentFilterDetectedResult No
profanity contentFilterDetectedResult No
self_harm contentFilterSeverityResult No
sexual contentFilterSeverityResult No
violence contentFilterSeverityResult No

chatCompletionsRequestCommon

Name 类型 Description Required Default
frequency_penalty number 数字介于-2.0到2.0之间。 正值会根据新标记在文本中已有的频率进行惩罚,降低模型逐字重复同一行的可能性。 No 0
logit_bias 对象 修改完成中出现指定标记的可能性。 接受一个json对象,将令牌(由分词器中其令牌ID指定)映射到从 -100 到100的相关偏置值。 数学上,偏差会在抽样前加到模型生成的对数中。 具体效果因模型而异,但 -1 到1之间的数值应降低或增加选择的可能性;像 -100 或100这样的数值应导致封禁或对相关代币的独占选择。 No
max_completion_tokens 整数 完成化可生成的代币数量的上限,包括可见的输出代币和推理代币。 No
max_tokens 整数 生成答案允许的最大代币数。 默认情况下,模型可返回的标记数量为(4096 - 提示令牌)。 这和O1系列型号不兼容。 No 4096
元数据 对象 开发者自定义的标签和值,用于在存储的完成仪表盘中过滤完成内容。 No
presence_penalty number 数字介于-2.0到2.0之间。 正值会根据新代币是否出现在文本中来惩罚它们,从而提高模型讨论新话题的可能性。 No 0
stop 字符串或数组 最多有4个序列,API停止生成更多令牌。 No
存储 boolean 是否将本次聊天完成请求的输出存储在我们的模型蒸馏或评估产品中。 No
数据流 boolean 如果设置为,会发送部分消息delta,就像ChatGPT一样。 令牌作为仅数据服务器发送的事件在可用时发送,流以 data: [DONE] 消息结束。 No False
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。
我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,可以帮助 Azure OpenAI 监控和检测滥用行为。 No

createCompletionRequest

Name 类型 Description Required Default
best_of 整数 best_of 服务器端生成完成任务,并返回“最佳”(每个代币日志概率最高的那个)。 结果无法直播。

当与 一起使用 n时, best_of 控制候选完成数,并 n 指定返回的候选完成数。 best_of 必须大于 n

注: 由于该参数会产生大量完成任务,它可能迅速消耗你的代币配额。 谨慎使用,并确保你对和stop的设置max_tokens合理。
No 1
echo boolean 除了完成,还要回应提示
No False
frequency_penalty number 数字介于-2.0到2.0之间。 正值会根据新标记在文本中已有的频率进行惩罚,降低模型逐字重复同一行的可能性。
No 0
logit_bias 对象 修改完成中出现指定标记的可能性。

接受一个 JSON 对象,将 GPT 分词器中由令牌 ID 指定的令牌映射到从 -100 到 100 的偏置值。 数学上,偏差会在抽样前加到模型生成的对数中。 具体效果因模型而异,但 -1 到1之间的数值应降低或增加选择的可能性;像 -100 或100这样的数值应导致封禁或对相关代币的独占选择。

举个例子,你可以通过 来 {"50256": -100} 阻止 <|endoftext|> 令牌的生成。
No None
logprobs 整数 包括最可能输出代币的对数概 logprobs 率,以及所选代币。 例如,如果 logprobs 是5,API会返回5个最可能的标记列表。 API 始终返回 logprob 被采样的标记,因此响应中可能包含多达 logprobs+1 多个元素。

最大 logprobs 值为5。
No None
max_tokens 整数 完成过程中能生成的最大代币数。

你的提示 max_tokens 词的token数不能超过模型的上下文长度。
No 16
n 整数 每个提示需要生成多少个完成任务。

注: 由于该参数会产生大量完成任务,它可能迅速消耗你的代币配额。 谨慎使用,并确保你对和stop的设置max_tokens合理。
No 1
presence_penalty number 数字介于-2.0到2.0之间。 正值会根据新代币是否出现在文本中来惩罚它们,从而提高模型讨论新话题的可能性。
No 0
提示 字符串或数组 生成完备的提示,编码为字符串、字符串数组、token数组或token数组数组。

注意, <|endoftext|> 是模型在训练时看到的文档分隔符,因此如果没有指定提示,模型会像从新文档开头一样生成。
Yes
seed 整数 如果指定,我们的系统会尽最大努力采样确定性采样,使得重复请求且参数相同 seed 时应返回相同结果。

确定性并不保证,你应该参考 system_fingerprint 响应参数来监控后端的变化。
No
stop 字符串或数组 最多有4个序列,API停止生成更多令牌。 返回的文本不会包含停止序列。
No
数据流 boolean 是否要回溯部分进度。 如果设置为令牌,代币会作为仅数据 服务器发送的事件 发送,当事件可用时发送,流以 data: [DONE] 消息终止。 示例Python代码
No False
suffix 字符串 插入文本完成后出现的后缀。

该参数仅支持。gpt-3.5-turbo-instruct
No None
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。

我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。
No

createCompletionResponse

表示API的补全响应。 注意:流式和非流式响应对象的形状相同(与聊天端点不同)。

Name 类型 Description Required Default
choices 数组 模型为输入提示生成的完成选项列表。 Yes
created 整数 完成文件创建时间的Unix时间戳(以秒计)。 Yes
id 字符串 完成的唯一标识符。 Yes
模型 字符串 用于完成的模型。 Yes
对象 枚举 对象类型,始终为“text_completion”
可能的数值: text_completion
Yes
prompt_filter_results promptFilterResults 请求中零个或多个提示的内容过滤结果。 在流媒体请求中,不同提示的结果可能在不同时间或顺序出现。 No
system_fingerprint 字符串 该指纹代表模型运行的后端配置。

可以与 seed 请求参数结合使用,以了解何时后端发生了可能影响确定性的更改。
No
使用情况 completionUsage 完成请求的使用统计数据。 No

createChatCompletionRequest

Name 类型 Description Required Default
audio 对象 音频输出参数。 当音频输出请求时 modalities: ["audio"],必须使用 。 No
└─ format 枚举 指定输出音频格式。 必须是 wavmp3flacopuspcm16之一。

可能的值:wavmp3flacopuspcm16
No
└─ voice 枚举 指定声音类型。 支持的语态有 alloyechonovafableonyxshimmer和 。

可能的值:alloyechofableonyxnovashimmer
No
data_sources 数组 使用它们的 Azure OpenAI 聊天扩展的配置条目。
该附加规范仅兼容 Azure OpenAI。
No
frequency_penalty number 数字介于-2.0到2.0之间。 正值会根据新标记在文本中已有的频率进行惩罚,降低模型逐字重复同一行的可能性。
No 0
function_call 字符串或 chatCompletionFunctionCallOption 已被弃用,取而代之。tool_choice

控制模型调用的函数(如果有的话)。
none 意味着模型不会调用函数,而是生成消息。
auto 意味着模型可以在生成消息或调用函数之间选择。
指定某个特定函数 会 {"name": "my_function"} 强制模型调用该函数。

none 当没有函数存在时,是默认的。 auto 如果函数存在,则是默认的。
No
functions 数组 已被弃用,取而代之。tools

模型可能生成的 JSON 输入函数列表。
No
logit_bias 对象 修改完成中出现指定标记的可能性。

接受一个 JSON 对象,将令牌(通过分词器中由令牌 ID 指定)映射到从 -100 到 100 的对应偏置值。 数学上,偏差会在抽样前加到模型生成的对数中。 具体效果因模型而异,但 -1 到1之间的数值应降低或增加选择的可能性;像 -100 或100这样的数值应导致封禁或对相关代币的独占选择。
No None
logprobs boolean 是否返回输出令牌的对数概率。 如果为真,返回每个输出令牌contentmessage的对数概率。 No False
max_completion_tokens 整数 完成化可生成的代币数量的上限,包括可见的输出代币和推理代币。 No
max_tokens 整数 聊天完成时能生成的最大代币数。

输入标记和生成标记的总长度受模型上下文长度限制。
No
messages 数组 这是迄今为止对话内容的列表。 示例Python代码 Yes
元数据 对象 开发者自定义的标签和值,用于在存储的完成仪表盘中过滤完成内容。 No
modalities ChatCompletionModalities 你希望模型为本次请求生成的输出类型。
大多数模型能够生成文本,这是默认的:

["text"]

gpt-4o-audio-preview 模型也可用于生成音频。 要请求该模型同时生成文本和音频响应,您可以使用:

["text", "audio"]
No
n 整数 每个输入消息需要生成多少聊天完成选项。 请注意,你将根据所有选项中生成的代币数量收费。 保持 n 最低 1 成本。 No 1
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
预测 PredictionContent 预测输出配置,当模型响应的大部分内容提前已知时,可以大幅提升响应时间。 这种情况最常见于你重新生成文件时,内容大部分内容只做了些微小的修改。 No
presence_penalty number 数字介于-2.0到2.0之间。 正值会根据新代币是否出现在文本中来惩罚它们,从而提高模型讨论新话题的可能性。
No 0
reasoning_effort 枚举 仅限O1模型

限制推理模型的推理工作。

目前支持的值有 lowmediumhigh。 减少推理努力可以加快响应速度,减少回应中用于推理的标记。
可能的值: lowmediumhigh
No
response_format ResponseFormatTextResponseFormatJsonObjectResponseFormatJsonSchema 一个对象,指定模型必须输出的格式。 兼容GPT-4oGPT-4o miniGPT-4 Turbo及所有更新于gpt-3.5-turbo-1106此之前的GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,保证模型与你提供的JSON模式匹配。

设置启用 { "type": "json_object" } JSON模式,保证模型生成的消息是有效的JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
seed 整数 此功能目前处于测试阶段。
如果指定,我们的系统会尽最大努力采样确定性采样,使得重复请求且参数相同 seed 时应返回相同结果。
确定性并不保证,你应该参考 system_fingerprint 响应参数来监控后端的变化。
No
stop 字符串或数组 最多有4个序列,API停止生成更多令牌。
No
存储 boolean 是否将本次聊天完成请求的输出存储在我们的模型蒸馏或评估产品中。 No
数据流 boolean 如果设置为,会发送部分消息delta,就像ChatGPT一样。 令牌作为仅数据服务器 发送的事件 在可用时发送,流以 data: [DONE] 消息结束。 示例Python代码
No False
stream_options chatCompletionStreamOptions 流式响应选项。 只有在你设置 stream: true时才会设置这个。
No None
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。

我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
tool_choice chatCompletionToolChoiceOption 控制模型调用的(如果有)工具。 none 这意味着模型不会调用任何工具,而是生成一条消息。 auto 这意味着模型可以选择生成消息或调用一个或多个工具。 required 意味着模型必须调用一个或多个工具。 通过指定特定工具 {"type": "function", "function": {"name": "my_function"}} 会强制模型调用该工具。 none 当没有工具时,是默认的。 auto 如果有工具,则是默认设置。 No
tools 数组 模型可能调用的工具列表。 目前,仅支持函数作为工具。 利用该列表提供模型可能生成 JSON 输入的函数列表。 最多支持128个功能。
No
top_logprobs 整数 一个介于0到20之间的整数,表示每个标记位置最可能返回的标记数量,每个标记对应对数概率。 logprobs 如果使用该参数,必须设置为 true No
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。
No
user_security_context userSecurityContext 用户安全上下文包含多个参数,描述 AI 应用本身以及与 AI 应用交互的终端用户。 这些领域通过提供全面的方法来保护您的人工智能应用,帮助您的安全运营团队调查并缓解安全事件。 了解更多关于利用Microsoft Defender for Cloud保护人工智能应用的信息。 No

userSecurityContext

用户安全上下文包含多个参数,描述 AI 应用本身以及与 AI 应用交互的终端用户。 这些领域通过提供全面的方法来保护您的人工智能应用,帮助您的安全运营团队调查并缓解安全事件。 了解更多关于利用Microsoft Defender for Cloud保护人工智能应用的信息。

Name 类型 Description Required Default
application_name 字符串 申请名称。 敏感个人信息不应包含在本领域。 No
end_user_id 字符串 该标识符是 Microsoft Entra ID(前称 Azure Active Directory)用户对象 ID,用于生成式 AI 应用内对终端用户进行认证。 敏感个人信息不应包含在本领域。 No
end_user_tenant_id 字符串 终端用户所属的Microsoft 365租户ID。 当生成式AI应用是多租户时,必须这样做。 No
source_ip 字符串 捕获原始客户端的IP地址,兼容IPv4和IPv6格式。 No

chatCompletionFunctions

Name 类型 Description Required Default
description 字符串 函数的功能描述,模型用来决定何时以及如何调用该函数。 No
name 字符串 要调用的函数名称。 必须为 a-z、A-Z、0-9,或包含划线和破折号,长度最多为 64。 Yes
parameters FunctionParameters 函数接受的参数,描述为 JSON Schema 对象。 示例请参见指南 ,以及关于格式的文档参考 JSON Schema

省略 parameters 定义了一个参数列表为空的函数。
No

chatCompletionFunctionCallOption

指定某个特定函数 会 {"name": "my_function"} 强制模型调用该函数。

Name 类型 Description Required Default
name 字符串 调用函数的名称。 Yes

chatCompletionFunctionParameters

函数接受的参数,描述为 JSON Schema 对象。 关于格式的文档请参见 指南/JSON Schema 参考文献

该组件没有定义属性。

chatCompletionRequestMessage

该组成部分可以是以下之一:

ChatCompletionRequestDeveloperMessage

开发者提供的指令,模型应遵循,无论用户发送了什么消息。 在 O1 及以后型号中,消息会 developer 取代之前 system 的消息。

Name 类型 Description Required Default
内容 字符串或数组 开发者消息的内容。 Yes
name 字符串 参与者的可选名称。 提供模型信息,以区分同一角色的参与者。 No
角色 枚举 消息作者的角色,在这里 developer
可能的数值: developer
Yes

chatCompletionRequestSystemMessage

Name 类型 Description Required Default
内容 字符串或数组 系统消息的内容。 Yes
name 字符串 参与者的可选名称。 提供模型信息,以区分同一角色的参与者。 No
角色 枚举 消息作者的角色,在这里 system
可能的数值: system
Yes

chatCompletionRequestUserMessage

Name 类型 Description Required Default
内容 字符串或数组 用户消息的内容。
Yes
name 字符串 参与者的可选名称。 提供模型信息,以区分同一角色的参与者。 No
角色 枚举 消息作者的角色,在这里 user
可能的数值: user
Yes

chatCompletionRequestAssistantMessage

Name 类型 Description Required Default
内容 字符串或数组 助理信息的内容。 除非 tool_callsfunction_call 另有说明,否则为必需。
No
function_call 对象 已被弃用并被 tool_calls取代。 应调用的函数名称和参数,由模型生成。 No
└─ arguments 字符串 调用函数的参数,由模型以 JSON 格式生成。 请注意,模型并不总是生成有效的JSON,而且可能会出现函数模式中未定义的参数。 在调用函数之前,先验证代码中的参数。 No
└─ name 字符串 调用函数的名称。 No
name 字符串 参与者的可选名称。 提供模型信息,以区分同一角色的参与者。 No
refusal 字符串 助理的拒绝信息。 No
角色 枚举 消息作者的角色,在这里 assistant
可能的数值: assistant
Yes
tool_calls chatCompletionMessageToolCalls 模型生成的工具调用,如函数调用。 No

chatCompletionRequestToolMessage

Name 类型 Description Required Default
内容 字符串或数组 工具信息的内容。 Yes
角色 枚举 消息作者的角色,在这里 tool
可能的数值: tool
Yes
tool_call_id 字符串 该消息响应的工具调用。 Yes

chatCompletionRequestFunctionMessage

Name 类型 Description Required Default
内容 字符串 函数消息的内容。 Yes
name 字符串 调用函数的名称。 Yes
角色 枚举 消息作者的角色,在这里 function
可能的数值: function
Yes

chatCompletionRequestDeveloperMessageContentPart

该组成部分可以是以下之一:

chatCompletionRequestSystemMessageContentPart

该组成部分可以是以下之一:

chatCompletionRequestUserMessageContentPart

该组成部分可以是以下之一:

chatCompletionRequestAssistantMessageContentPart

该组成部分可以是以下之一:

chatCompletionRequestToolMessageContentPart

该组成部分可以是以下之一:

chatCompletionRequestMessageContentPartText

Name 类型 Description Required Default
文本消息 字符串 文本内容。 Yes
类型 枚举 内容的类型。
可能的数值: text
Yes

chatCompletionRequestMessageContentPartAudio

Name 类型 Description Required Default
input_audio 对象 Yes
└─ data 字符串 Base64编码音频数据。 No
└─ format 枚举 编码音频数据的格式。 目前支持“wav”和“mp3”。

可能的值: wavmp3
No
类型 枚举 内容的类型。 总是。input_audio
可能的数值: input_audio
Yes

chatCompletionRequestMessageContentPartImage

Name 类型 Description Required Default
image_url 对象 Yes
└─ detail 枚举 指定图像的细节级别。 更多信息请参阅 愿景指南
可能的值: autolowhigh
No
└─ url 字符串 要么是图片的URL,要么是base64编码的图像数据。 No
类型 枚举 内容的类型。
可能的数值: image_url
Yes

chatCompletionRequestMessageContentPartRefusal

Name 类型 Description Required Default
refusal 字符串 模型生成的拒绝信息。 Yes
类型 枚举 内容的类型。
可能的数值: refusal
Yes

azureChatExtensionConfiguration

一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。 该配置仅兼容 Azure OpenAI。

###Discriminator for azureChatExtensionConfiguration

该组件利用该性质 type 区分不同类型:

Type Value Schema
azure_search azureSearchChatExtensionConfiguration
azure_cosmos_db azureCosmosDBChatExtensionConfiguration
elasticsearch elasticsearchChatExtensionConfiguration
mongo_db mongoDBChatExtensionConfiguration
pinecone pineconeChatExtensionConfiguration
Name 类型 Description Required Default
类型 azureChatExtensionType 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Yes

azureChatExtensionType

一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。 该配置仅兼容 Azure OpenAI。

Property Value
Description 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Type 字符串
Values azure_search
azure_cosmos_db
elasticsearch
mongo_db
pinecone

azureSearchChatExtensionConfiguration

这是使用 Azure 搜索作为 Azure OpenAI 聊天扩展时可配置选项的具体表示。

Name 类型 Description Required Default
parameters azureSearchChatExtensionParameters 作为 Azure OpenAI 聊天扩展使用时的 Azure 搜索参数。 No
类型 azureChatExtensionType 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Yes

azureSearchChatExtensionParameters

作为 Azure OpenAI 聊天扩展使用时的 Azure 搜索参数。

Name 类型 Description Required Default
allow_partial_result boolean 如果被指定为真,系统将允许使用部分搜索结果,如果所有查询都失败,则请求失败。 如果未指定或指定为false,任何搜索查询失败时请求将失败。 No False
身份验证 on yourDataApiKeyAuthenticationOptionson yourDataSystemAssignedManagedIdentity 认证 选项 或 onYourDataUserAssignedManagedIdentity 认证选项on yourData访问令牌认证选项 Yes
embedding_dependency onYourDataEndpointVectorizationSourceonYourDataDeploymentNameVectorizationSourceonYourDataIntegratedVectorizationSource No
终结点 字符串 Azure 搜索资源的绝对端点路径。 Yes
fields_mapping azureSearchIndexFieldMappingOptions 可选设置用于控制使用配置Azure搜索资源时字段的处理方式。 No
筛选器 字符串 Search filter. No
in_scope boolean 查询是否应限制使用索引数据。 No
include_contexts 数组 输出上下文中包含的属性。 如果未指定,默认值为 citationsintent No
index_name 字符串 在参考的Azure搜索资源中,使用该索引的名称。 Yes
max_search_queries 整数 重写查询的最大数量应发送给搜索提供商,针对一条用户消息。 如果未指定,系统将决定发送多少查询。 No
query_type azureSearchQueryType 当它作为 Azure OpenAI 聊天扩展使用时,应该执行的 Azure 搜索检索查询类型。 No
semantic_configuration 字符串 查询的额外语义配置。 No
strictness 整数 搜索相关性过滤的配置严格性。 严格度越高,答案的准确度越高但回忆力越低。 No
top_n_documents 整数 配置的最高文档数量以供查询。 No

azureSearchIndexFieldMappingOptions

可选设置用于控制使用配置Azure搜索资源时字段的处理方式。

Name 类型 Description Required Default
content_fields 数组 应当被视为内容的索引字段名称。 No
content_fields_separator 字符串 内容字段应使用的分隔符模式。 No
filepath_field 字符串 用于文件路径的索引字段名称。 No
image_vector_fields 数组 表示图像矢量数据的字段名称。 No
title_field 字符串 用作标题的索引字段名称。 No
url_field 字符串 用作URL的索引字段名称。 No
vector_fields 数组 表示向量数据的字段名称。 No

azureSearchQueryType

当它作为 Azure OpenAI 聊天扩展使用时,应该执行的 Azure 搜索检索查询类型。

Property Value
Description 当它作为 Azure OpenAI 聊天扩展使用时,应该执行的 Azure 搜索检索查询类型。
Type 字符串
Values simple
semantic
vector
vector_simple_hybrid
vector_semantic_hybrid

azureCosmosDBChatExtensionConfiguration

这是使用 Azure Cosmos DB 作为 Azure OpenAI 聊天扩展时可配置选项的具体表示。

Name 类型 Description Required Default
parameters azureCosmosDBChatExtensionParameters 配置 Azure OpenAI On Your Data 聊天扩展时使用的参数,使用 Azure Cosmos DB for MongoDB vCore。 No
类型 azureChatExtensionType 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Yes

azureCosmosDBChatExtensionParameters

配置 Azure OpenAI On Your Data 聊天扩展时使用的参数,使用 Azure Cosmos DB for MongoDB vCore。

Name 类型 Description Required Default
allow_partial_result boolean 如果被指定为真,系统将允许使用部分搜索结果,如果所有查询都失败,则请求失败。 如果未指定或指定为false,任何搜索查询失败时请求将失败。 No False
身份验证 onYourDataConnectionStringAuthenticationOptions 使用 连接字符串 时,Azure OpenAI On Your Data 的认证选项。 Yes
container_name 字符串 Azure Cosmos DB 资源容器的名称。 Yes
database_name 字符串 MongoDB vCore 数据库名称,用于 Azure Cosmos DB。 Yes
embedding_dependency onYourDataEndpointVectorizationSourceonYourDataDeploymentNameVectorizationSource Yes
fields_mapping azureCosmosDBFieldMappingOptions 可选设置用于控制使用配置好的 Azure Cosmos DB 资源时字段的处理方式。 Yes
in_scope boolean 查询是否应限制使用索引数据。 No
include_contexts 数组 输出上下文中包含的属性。 如果未指定,默认值为 citationsintent No
index_name 字符串 MongoDB vCore 索引名称,用于 Azure Cosmos DB。 Yes
max_search_queries 整数 重写查询的最大数量应发送给搜索提供商,针对一条用户消息。 如果未指定,系统将决定发送多少查询。 No
strictness 整数 搜索相关性过滤的配置严格性。 严格度越高,答案的准确度越高但回忆力越低。 No
top_n_documents 整数 配置的最高文档数量以供查询。 No

azureCosmosDBFieldMappingOptions

可选设置用于控制使用配置好的 Azure Cosmos DB 资源时字段的处理方式。

Name 类型 Description Required Default
content_fields 数组 应当被视为内容的索引字段名称。 Yes
content_fields_separator 字符串 内容字段应使用的分隔符模式。 No
filepath_field 字符串 用于文件路径的索引字段名称。 No
title_field 字符串 用作标题的索引字段名称。 No
url_field 字符串 用作URL的索引字段名称。 No
vector_fields 数组 表示向量数据的字段名称。 Yes

elasticsearchChatExtensionConfiguration

这是将 Elasticsearch 作为 Azure OpenAI 聊天扩展时可配置选项的具体表示。

Name 类型 Description Required Default
parameters elasticsearchChatExtensionParameters 配置 Elasticsearch® 作为 Azure OpenAI 聊天扩展时使用的参数。 No
类型 azureChatExtensionType 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Yes

elasticsearchChatExtensionParameters

配置 Elasticsearch® 作为 Azure OpenAI 聊天扩展时使用的参数。

Name 类型 Description Required Default
allow_partial_result boolean 如果被指定为真,系统将允许使用部分搜索结果,如果所有查询都失败,则请求失败。 如果未指定或指定为false,任何搜索查询失败时请求将失败。 No False
身份验证 在 yourDataKeyAndKeyIdAuthenticationOptionson yourDataEncodedApiKeyAuthenticationOptions Yes
embedding_dependency 在 yourDataEndpointVectorizationSourceonYourDataDeploymentNameVectorizationSourceOnYourDataModelIdVectorizationSource No
终结点 字符串 Elasticsearch®的终点。 Yes
fields_mapping elasticsearchIndexFieldMappingOptions 可选设置用于控制使用配置好的 Elasticsearch® 资源时字段的处理方式。 No
in_scope boolean 查询是否应限制使用索引数据。 No
include_contexts 数组 输出上下文中包含的属性。 如果未指定,默认值为 citationsintent No
index_name 字符串 Elasticsearch® 的索引名称。 Yes
max_search_queries 整数 重写查询的最大数量应发送给搜索提供商,针对一条用户消息。 如果未指定,系统将决定发送多少查询。 No
query_type elasticsearchQueryType 当它作为 Azure OpenAI 聊天扩展使用时,应该执行的 Elasticsearch® 检索查询类型。 No
strictness 整数 搜索相关性过滤的配置严格性。 严格度越高,答案的准确度越高但回忆力越低。 No
top_n_documents 整数 配置的最高文档数量以供查询。 No

elasticsearchIndexFieldMappingOptions

可选设置用于控制使用配置好的 Elasticsearch® 资源时字段的处理方式。

Name 类型 Description Required Default
content_fields 数组 应当被视为内容的索引字段名称。 No
content_fields_separator 字符串 内容字段应使用的分隔符模式。 No
filepath_field 字符串 用于文件路径的索引字段名称。 No
title_field 字符串 用作标题的索引字段名称。 No
url_field 字符串 用作URL的索引字段名称。 No
vector_fields 数组 表示向量数据的字段名称。 No

elasticsearchQueryType

当它作为 Azure OpenAI 聊天扩展使用时,应该执行的 Elasticsearch® 检索查询类型。

Property Value
Description 当它作为 Azure OpenAI 聊天扩展使用时,应该执行的 Elasticsearch® 检索查询类型。
Type 字符串
Values simple
vector

mongoDBChatExtensionConfiguration

这是Mongo DB作为Azure OpenAI聊天扩展时可配置选项的具体表示。

Name 类型 Description Required Default
parameters mongoDBChatExtensionParameters 在使用 Mongo DB 配置 Azure OpenAI On Your Data 聊天扩展时需要使用的参数。 No
类型 azureChatExtensionType 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Yes

mongoDBChatExtensionParameters

在使用 Mongo DB 配置 Azure OpenAI On Your Data 聊天扩展时需要使用的参数。

Name 类型 Description Required Default
allow_partial_result boolean 如果被指定为真,系统将允许使用部分搜索结果,如果所有查询都失败,则请求失败。 如果未指定或指定为false,任何搜索查询失败时请求将失败。 No False
app_name 字符串 Mongo数据库应用的名称。 Yes
身份验证 onYourDataUsernameAndPasswordAuthenticationOptions 使用用户名和密码时,Azure OpenAI On Your Data 的认证选项。 Yes
collection_name 字符串 Mongo数据库收藏的名称。 Yes
database_name 字符串 Mongo数据库的名称。 Yes
embedding_dependency onYourDataEndpointVectorizationSourceonYourDataDeploymentNameVectorizationSource Yes
终结点 字符串 Mongo DB集群端点的名称。 Yes
fields_mapping mongoDBFieldMappingOptions 可选设置用于控制使用配置好的 Mongo 数据库资源时字段的处理方式。 Yes
in_scope boolean 查询是否应限制使用索引数据。 No
include_contexts 数组 输出上下文中包含的属性。 如果未指定,默认值为 citationsintent No
index_name 字符串 Mongo数据库指数的名称。 Yes
max_search_queries 整数 重写查询的最大数量应发送给搜索提供商,针对一条用户消息。 如果未指定,系统将决定发送多少查询。 No
strictness 整数 搜索相关性过滤的配置严格性。 严格度越高,答案的准确度越高但回忆力越低。 No
top_n_documents 整数 配置的最高文档数量以供查询。 No

mongoDBFieldMappingOptions

可选设置用于控制使用配置好的 Mongo 数据库资源时字段的处理方式。

Name 类型 Description Required Default
content_fields 数组 应当被视为内容的索引字段名称。 Yes
content_fields_separator 字符串 内容字段应使用的分隔符模式。 No
filepath_field 字符串 用于文件路径的索引字段名称。 No
title_field 字符串 用作标题的索引字段名称。 No
url_field 字符串 用作URL的索引字段名称。 No
vector_fields 数组 表示向量数据的字段名称。 Yes

pineconeChatExtensionConfiguration

这是 Pinecone 作为 Azure OpenAI 聊天扩展时可配置选项的具体表示。

Name 类型 Description Required Default
parameters pineconeChatExtensionParameters 配置 Azure OpenAI Pinecone 聊天扩展的参数。 No
类型 azureChatExtensionType 一个针对单个 Azure OpenAI 聊天扩展的配置数据表示。 这将被聊天完成请求使用,该请求应通过 Azure OpenAI 聊天扩展来增强响应行为。
该配置仅兼容 Azure OpenAI。
Yes

pineconeChatExtensionParameters

配置 Azure OpenAI Pinecone 聊天扩展的参数。

Name 类型 Description Required Default
allow_partial_result boolean 如果被指定为真,系统将允许使用部分搜索结果,如果所有查询都失败,则请求失败。 如果未指定或指定为false,任何搜索查询失败时请求将失败。 No False
身份验证 onYourDataApiKeyAuthenticationOptions 使用 API 密钥时,Azure OpenAI 在你的数据上的认证选项。 Yes
embedding_dependency onYourDataDeploymentNameVectorizationSource Azure OpenAI 在应用向量搜索时使用的矢量化源的详细信息,基于同一 Azure OpenAI 资源中的内部嵌入模型部署名称。 Yes
环境 字符串 环境名称松果。 Yes
fields_mapping pineconeFieldMappingOptions 可选设置用于控制使用配置松果资源时字段的处理方式。 Yes
in_scope boolean 查询是否应限制使用索引数据。 No
include_contexts 数组 输出上下文中包含的属性。 如果未指定,默认值为 citationsintent No
index_name 字符串 松果数据库索引的名称。 Yes
max_search_queries 整数 重写查询的最大数量应发送给搜索提供商,针对一条用户消息。 如果未指定,系统将决定发送多少查询。 No
strictness 整数 搜索相关性过滤的配置严格性。 严格度越高,答案的准确度越高但回忆力越低。 No
top_n_documents 整数 配置的最高文档数量以供查询。 No

pineconeFieldMappingOptions

可选设置用于控制使用配置松果资源时字段的处理方式。

Name 类型 Description Required Default
content_fields 数组 应当被视为内容的索引字段名称。 Yes
content_fields_separator 字符串 内容字段应使用的分隔符模式。 No
filepath_field 字符串 用于文件路径的索引字段名称。 No
title_field 字符串 用作标题的索引字段名称。 No
url_field 字符串 用作URL的索引字段名称。 No

onYourDataAuthenticationOptions

关于Azure OpenAI在你数据上的认证选项。

onYourData认证选项的判别器

该组件利用该性质 type 区分不同类型:

Type Value Schema
api_key onYourDataApiKeyAuthenticationOptions
connection_string onYourDataConnectionStringAuthenticationOptions
key_and_key_id onYourDataKeyAndKeyIdAuthenticationOptions
encoded_api_key onYourDataEncodedApiKeyAuthenticationOptions
access_token onYourDataAccessTokenAuthenticationOptions
system_assigned_managed_identity onYourDataSystemAssignedManagedIdentityAuthenticationOptions
user_assigned_managed_identity onYourDataUserAssignedManagedIdentityAuthenticationOptions
username_and_password onYourDataUsernameAndPasswordAuthenticationOptions
Name 类型 Description Required Default
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataContextProperty

上下文属性。

Property Value
Description 上下文属性。
Type 字符串
Values citations
intent
all_retrieved_documents

onYourDataAuthenticationType

Azure OpenAI 在你的数据上支持的认证类型。

Property Value
Description Azure OpenAI 在你的数据上支持的认证类型。
Type 字符串
Values api_key
connection_string
key_and_key_id
encoded_api_key
access_token
system_assigned_managed_identity
user_assigned_managed_identity
username_and_password

onYourDataApiKeyAuthenticationOptions

使用 API 密钥时,Azure OpenAI 在你的数据上的认证选项。

Name 类型 Description Required Default
关键值 字符串 用于认证的API密钥。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataConnectionStringAuthenticationOptions

使用 连接字符串 时,Azure OpenAI On Your Data 的认证选项。

Name 类型 Description Required Default
connection_string 字符串 用于认证的连接字符串。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataKeyAndKeyIdAuthenticationOptions

使用 Elasticsearch 密钥和密钥 ID 配对时,Azure OpenAI On Your Data 的认证选项。

Name 类型 Description Required Default
关键值 字符串 用于身份验证的Elasticsearch密钥。 No
key_id 字符串 用于认证的 Elasticsearch 密钥 ID。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataEncodedApiKeyAuthenticationOptions

使用 Elasticsearch 编码的 API 密钥时,Azure OpenAI 对你的数据的认证选项。

Name 类型 Description Required Default
encoded_api_key 字符串 用于认证的 Elasticsearch 编码 API 密钥。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataAccessTokenAuthenticationOptions

使用访问令牌时,Azure OpenAI On Your Data 的认证选项。

Name 类型 Description Required Default
access_token 字符串 用于认证的访问令牌。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataSystemAssignedManagedIdentityAuthenticationOptions

使用系统分配的管理身份时,针对 Azure OpenAI On Your Data 的认证选项。

Name 类型 Description Required Default
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataUserAssignedManagedIdentityAuthenticationOptions

使用用户分配的管理身份时,Azure OpenAI 对你的数据的认证选项。

Name 类型 Description Required Default
managed_identity_resource_id 字符串 用户分配的托管身份用于认证的资源ID。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes

onYourDataUsernameAndPasswordAuthenticationOptions

使用用户名和密码时,Azure OpenAI On Your Data 的认证选项。

Name 类型 Description Required Default
密码 字符串 The password. 用于身份验证。 No
类型 onYourDataAuthenticationType Azure OpenAI 在你的数据上支持的认证类型。 Yes
用户名 字符串 用于身份验证的用户名。 No

onYourDataVectorizationSource

Azure OpenAI 在你的数据上提供向量搜索的向量化源的抽象表示。

该组件利用该性质 type 区分不同类型:

Type Value Schema
endpoint onYourDataEndpointVectorizationSource
deployment_name onYourDataDeploymentNameVectorizationSource
integrated onYourDataIntegratedVectorizationSource
model_id onYourDataModelIdVectorizationSource
Name 类型 Description Required Default
类型 onYourDataVectorizationSourceType 代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。 Yes

onYourDataVectorizationSourceType

代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。

Property Value
Description 代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。
Type 字符串
Values endpoint
deployment_name
integrated
model_id

onYourDataEndpointVectorizationSource

Azure OpenAI 在应用向量搜索时使用的矢量化源的详细信息,基于公开的 Azure OpenAI 端点嵌入调用。

Name 类型 Description Required Default
身份验证 onYourDataApiKeyAuthenticationOptionsonYourDataAccessTokenAuthenticationOptions No
dimensions 整数 嵌入应有的维数。 仅支持及 text-embedding-3 后续型号。 No
终结点 字符串 指定应从中检索嵌入的资源端点URL。 它应采用格式为 https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings。 API 版本查询参数不被允许。 No
类型 onYourDataVectorizationSourceType 代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。 Yes

onYourDataDeploymentNameVectorizationSource

Azure OpenAI 在应用向量搜索时使用的矢量化源的详细信息,基于同一 Azure OpenAI 资源中的内部嵌入模型部署名称。

Name 类型 Description Required Default
deployment_name 字符串 指定用于向量化的模型部署名称。 该模型部署必须在同一Azure OpenAI资源中,但“你的数据”将通过内部调用而非公开调用使用该模型部署,从而即使在私有网络中也能实现向量搜索。 No
dimensions 整数 嵌入应有的维数。 仅支持及 text-embedding-3 后续型号。 No
类型 onYourDataVectorizationSourceType 代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。 Yes

onYourDataIntegratedVectorizationSource

表示在搜索资源中定义的集成矢量器。

Name 类型 Description Required Default
类型 onYourDataVectorizationSourceType 代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。 Yes

onYourDataModelIdVectorizationSource

Azure OpenAI On Your Data 在应用向量搜索时使用的矢量化源的详细信息,基于搜索服务模型 ID。 目前仅由Elasticsearch®支持。

Name 类型 Description Required Default
model_id 字符串 指定用于矢量化的模型ID。 该模型ID必须在搜索服务中定义。 No
类型 onYourDataVectorizationSourceType 代表 Azure OpenAI On Your Data 可用来配置数据矢量化以配合矢量搜索的来源。 Yes

azureChatExtensionsMessageContext

这是当Azure OpenAI聊天扩展参与生成对应聊天完成响应时,可用额外上下文信息的表示。 这些上下文信息只有在使用 Azure OpenAI 请求并配置为匹配扩展时才会被填充。

Name 类型 Description Required Default
all_retrieved_documents 数组 所有检索到的文件。 No
citations 数组 数据源检索结果,用于生成响应中的助手消息。 No
意向 字符串 从聊天历史中检测到的意图,会传递到下一回合以传递上下文。 No

citation

聊天完成回复消息的引用信息。

Name 类型 Description Required Default
chunk_id 字符串 引用的块编号。 No
内容 字符串 引用内容。 Yes
filepath 字符串 引用的文件路径。 No
rerank_score number 检索文档的重新排序分数。 No
title 字符串 表彰词标题。 No
url 字符串 引用的网址。 No

retrievedDocument

检索到的文件。

Name 类型 Description Required Default
chunk_id 字符串 引用的块编号。 No
内容 字符串 引用内容。 Yes
data_source_index 整数 数据源的索引。 No
filepath 字符串 引用的文件路径。 No
filter_reason filterReason 检索文档的过滤原因。 No
original_search_score number 检索文档的原始检索分数。 No
rerank_score number 检索文档的重新排序分数。 No
search_queries 数组 用于检索文档的搜索查询。 No
title 字符串 表彰词标题。 No
url 字符串 引用的网址。 No

filterReason

检索文档的过滤原因。

Property Value
Description 检索文档的过滤原因。
Type 字符串
Values score
rerank

chatCompletionMessageToolCall

Name 类型 Description Required Default
函数 对象 模型调用的函数。 Yes
└─ arguments 字符串 调用函数的参数,由模型以 JSON 格式生成。 请注意,模型并不总是生成有效的JSON,而且可能会出现函数模式中未定义的参数。 在调用函数之前,先验证代码中的参数。 No
└─ name 字符串 调用函数的名称。 No
id 字符串 工具调用的ID。 Yes
类型 toolCallType 工具调用的类型,在此例 function中为 。 Yes

toolCallType

工具调用的类型,在此例 function中为 。

Property Value
Description 工具调用的类型,在此例 function中为 。
Type 字符串
Values function

chatCompletionRequestMessageTool

Name 类型 Description Required Default
内容 字符串 信息内容。 No
tool_call_id 字符串 该消息响应的工具调用。 No

chatCompletionRequestMessageFunction

Name 类型 Description Required Default
内容 字符串 信息内容。 No
name 字符串 信息内容。 No
角色 枚举 消息作者的角色,在这里 function
可能的数值: function
No

createChatCompletionResponse

表示模型基于所提供输入返回的聊天完成响应。

Name 类型 Description Required Default
choices 数组 聊天完成选项列表。 如果 大于 1, n 则可以多于 1。 Yes
created 整数 Unix 时间戳(以秒计)显示聊天完成的时间。 Yes
id 字符串 聊天完成的唯一标识符。 Yes
模型 字符串 用于聊天完成的模型。 Yes
对象 枚举 对象类型,始终 chat.completion为 。
可能的数值: chat.completion
Yes
prompt_filter_results promptFilterResults 请求中零个或多个提示的内容过滤结果。 在流媒体请求中,不同提示的结果可能在不同时间或顺序出现。 No
system_fingerprint 字符串 该指纹代表模型运行的后端配置。

可以与 seed 请求参数结合使用,以了解何时后端发生了可能影响确定性的更改。
No
使用情况 completionUsage 完成请求的使用统计数据。 No

createChatCompletionStreamResponse

表示模型根据提供的输入返回的聊天完成响应的流式片段。

Name 类型 Description Required Default
choices 数组 聊天完成选项列表。 如果 大于 1, n 则可以包含多个元素。
Yes
created 整数 Unix 时间戳(以秒计)显示聊天完成的时间。 每个区块的时间戳相同。 Yes
id 字符串 聊天完成的唯一标识符。 每个区块的ID相同。 Yes
模型 字符串 生成完备化的模型。 Yes
对象 枚举 对象类型,始终 chat.completion.chunk为 。
可能的数值: chat.completion.chunk
Yes
system_fingerprint 字符串 该指纹代表模型运行的后端配置。
可以与 seed 请求参数结合使用,以了解何时后端发生了可能影响确定性的更改。
No

chatCompletionStreamResponseDelta

由流式模型响应生成的聊天完成差异。

Name 类型 Description Required Default
内容 字符串 区块消息的内容。 No
function_call 对象 已被弃用并被 tool_calls取代。 应调用的函数名称和参数,由模型生成。 No
└─ arguments 字符串 调用函数的参数,由模型以 JSON 格式生成。 请注意,模型并不总是生成有效的JSON,而且可能会出现函数模式中未定义的参数。 在调用函数之前,先验证代码中的参数。 No
└─ name 字符串 调用函数的名称。 No
refusal 字符串 模型生成的拒绝信息。 No
角色 枚举 这条信息的作者的角色。
可能的值: systemuserassistanttool
No
tool_calls 数组 No

chatCompletionMessageToolCallChunk

Name 类型 Description Required Default
函数 对象 No
└─ arguments 字符串 调用函数的参数,由模型以 JSON 格式生成。 请注意,模型并不总是生成有效的JSON,而且可能会出现函数模式中未定义的参数。 在调用函数之前,先验证代码中的参数。 No
└─ name 字符串 调用函数的名称。 No
id 字符串 工具调用的ID。 No
索引 整数 Yes
类型 枚举 工具的类型。 目前,只有 function 支持。
可能的数值: function
No

chatCompletionStreamOptions

流式响应选项。 只有在你设置 stream: true时才会设置这个。

Name 类型 Description Required Default
include_usage boolean 如果设置为,消息发出前 data: [DONE] 会再流一个额外的区块。 usage该块上的字段显示整个请求的令牌使用统计数据,字段choices始终为空数组。 所有其他区块也会包含 usage 字段,但字段为空值。
No

chatCompletionChoiceLogProbs

记录选择的概率信息。

Name 类型 Description Required Default
内容 数组 一份包含日志概率信息的消息内容令牌列表。 Yes
refusal 数组 一份带有日志概率信息的消息拒绝令牌列表。 No

chatCompletionTokenLogprob

Name 类型 Description Required Default
bytes 数组 一组整数表示 UTF-8 字节的令牌表示。 在字符由多个标记表示且必须组合其字节表示以生成正确文本表示的情况下非常有用。 如果该令牌没有字节表示,则可能是 null Yes
logprob number 该标记的对数概率。 Yes
代币 字符串 The token. Yes
top_logprobs 数组 该标记位置上最可能出现的标记及其对数概率列表。 极少数情况下,退回的数量可能少于请求 top_logprobs 的数量。 Yes

chatCompletionResponseMessage

模型生成的聊天完成消息。

Name 类型 Description Required Default
audio 对象 如果请求音频输出模态,该对象包含模型关于音频响应的数据。 No
└─ data 字符串 Base64编码的音频字节由模型生成,格式为请求中指定的格式。
No
└─ expires_at 整数 Unix时间戳(秒数)表示该音频响应在服务器上不再可访问,用于多回合对话。
No
└─ id 字符串 此音频响应的唯一标识符。 No
└─ transcript 字符串 模型生成的音频文字稿。 No
内容 字符串 信息内容。 Yes
上下文 azureChatExtensionsMessageContext 这是当Azure OpenAI聊天扩展参与生成对应聊天完成响应时,可用额外上下文信息的表示。 这些上下文信息只有在使用 Azure OpenAI 请求并配置为匹配扩展时才会被填充。 No
function_call chatCompletionFunctionCall 已被弃用并被 tool_calls取代。 应调用的函数名称和参数,由模型生成。 No
refusal 字符串 模型生成的拒绝信息。 Yes
角色 chatCompletionResponseMessageRole 回复信息作者的角色。 Yes
tool_calls 数组 模型生成的工具调用,如函数调用。 No

chatCompletionResponseMessageRole

回复信息作者的角色。

Property Value
Description 回复信息作者的角色。
Type 字符串
Values assistant

chatCompletionToolChoiceOption

控制模型调用的(如果有)工具。 none 这意味着模型不会调用任何工具,而是生成一条消息。 auto 这意味着模型可以选择生成消息或调用一个或多个工具。 required 意味着模型必须调用一个或多个工具。 通过指定特定工具 {"type": "function", "function": {"name": "my_function"}} 会强制模型调用该工具。 none 当没有工具时,是默认的。 auto 如果有工具,则是默认设置。

该组成部分可以是以下之一:

chatCompletionNamedToolChoice

指定模型应使用的工具。 用于强制模型调用特定函数。

Name 类型 Description Required Default
函数 对象 Yes
└─ name 字符串 调用函数的名称。 No
类型 枚举 工具的类型。 目前,只有 function 支持。
可能的数值: function
Yes

ParallelToolCalls

是否在工具使用时启用并行函数调用。

该组件没有定义属性。

PredictionContent

静态预测输出内容,例如正在再生的文本文件内容。

Name 类型 Description Required Default
内容 字符串或数组 生成模型响应时应匹配的内容。 如果生成的代币与该内容匹配,整个模型响应可以更快地返回。 Yes
类型 枚举 你想提供的预测内容类型。 该类型目前总是 content为 。
可能的数值: content
Yes

chatCompletionMessageToolCalls

模型生成的工具调用,如函数调用。

该组件没有定义属性。

ChatCompletionModalities

你希望模型为本次请求生成的输出类型。 大多数模型能够生成文本,这是默认的:

["text"]

gpt-4o-audio-preview 模型也可用于生成音频。 要请求该模型同时生成文本和音频响应,您可以使用:

["text", "audio"]

该组件没有定义属性。

chatCompletionFunctionCall

已被弃用并被 tool_calls取代。 应调用的函数名称和参数,由模型生成。

Name 类型 Description Required Default
arguments 字符串 调用函数的参数,由模型以 JSON 格式生成。 请注意,模型并不总是生成有效的JSON,而且可能会出现函数模式中未定义的参数。 在调用函数之前,先验证代码中的参数。 Yes
name 字符串 调用函数的名称。 Yes

completionUsage

完成请求的使用统计数据。

Name 类型 Description Required Default
completion_tokens 整数 生成完备中的标记数量。 Yes
completion_tokens_details 对象 完成过程中使用的代币分解。 No
└─ accepted_prediction_tokens 整数 使用预测输出时,预测中出现在补全中的符号数。 No
└─ audio_tokens 整数 模型生成的音频输入标记。 No
└─ reasoning_tokens 整数 模型为推理生成的代币。 No
└─ rejected_prediction_tokens 整数 使用预测输出时,预测中未出现在补全化中的标记数。 然而,与推理代币一样,这些代币仍计入总完成代币,用于计费、输出和上下文窗口限制。 No
prompt_tokens 整数 提示词中的代币数量。 Yes
prompt_tokens_details 对象 提示令牌的详细信息。 No
└─ audio_tokens 整数 提示中出现了音频输入标记。 No
└─ cached_tokens 整数 缓存的提示令牌数量。 No
total_tokens 整数 请求中使用的总令牌数(提示 + 完成)。 Yes

chatCompletionTool

Name 类型 Description Required Default
函数 FunctionObject Yes
类型 枚举 工具的类型。 目前,只有 function 支持。
可能的数值: function
Yes

FunctionParameters

函数接受的参数,描述为 JSON Schema 对象。 示例请参见指南 ,以及关于格式的文档参考 JSON Schema

省略 parameters 定义了一个参数列表为空的函数。

该组件没有定义属性。

FunctionObject

Name 类型 Description Required Default
description 字符串 函数的功能描述,模型用来决定何时以及如何调用该函数。 No
name 字符串 要调用的函数名称。 必须为 a-z、A-Z、0-9,或包含划线和破折号,长度最多为 64。 Yes
parameters FunctionParameters 函数接受的参数,描述为 JSON Schema 对象。 示例请参见指南 ,以及关于格式的文档参考 JSON Schema

省略 parameters 定义了一个参数列表为空的函数。
No
strict boolean 在生成函数调用时是否启用严格的模式遵循。 如果设置为 true,模型将遵循字段中 parameters 定义的完全模式。 当 stricttrue时,仅支持部分 JSON 模式。 No False

ResponseFormatText

Name 类型 Description Required Default
类型 枚举 定义的响应格式类型: text
可能的数值: text
Yes

ResponseFormatJsonObject

Name 类型 Description Required Default
类型 枚举 定义的响应格式类型: json_object
可能的数值: json_object
Yes

ResponseFormatJsonSchemaSchema

响应格式的模式,描述为 JSON 模式对象。

该组件没有定义属性。

ResponseFormatJsonSchema

Name 类型 Description Required Default
json_schema 对象 Yes
└─ description 字符串 对响应格式的描述,模型用以确定该格式的响应方式。 No
└─ name 字符串 回答格式的名称。 必须为 a-z、A-Z、0-9,或包含划线和破折号,长度最多为 64。 No
└─ schema ResponseFormatJsonSchemaSchema 响应格式的模式,描述为 JSON 模式对象。 No
└─ strict boolean 在生成输出时是否启用严格的模式遵循。 如果设置为 true,模型始终遵循字段中 schema 定义的完全模式。 当 stricttrue时,仅支持部分 JSON 模式。 No False
类型 枚举 定义的响应格式类型: json_schema
可能的数值: json_schema
Yes

chatCompletionChoiceCommon

Name 类型 Description Required Default
finish_reason 字符串 No
索引 整数 No

createTranslationRequest

Translation request.

Name 类型 Description Required Default
文件 字符串 音频文件需要翻译。 Yes
提示 字符串 可选文本,用于指导模型风格或延续之前的音频片段。 提示应为英文。 No
response_format audioResponseFormat 定义输出格式。 No
temperature number 采样温度在0到1之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。 如果设置为0,模型会使用对数概率自动升温,直到达到某些阈值。 No 0

audioResponse

当response_format为json时,翻译或转录响应

Name 类型 Description Required Default
文本消息 字符串 翻译或转录文本。 Yes

audioVerboseResponse

response_format verbose_json翻译或转录反应

Name 类型 Description Required Default
duration number Duration. No
语言 字符串 Language. No
segments 数组 No
任务 字符串 音频任务类型。 No
文本消息 字符串 翻译或转录文本。 Yes
words 数组 No

audioResponseFormat

定义输出格式。

Property Value
Description 定义输出格式。
Type 字符串
Values json
text
srt
verbose_json
vtt

createTranscriptionRequest

Transcription request.

Name 类型 Description Required Default
文件 字符串 音频文件对象要转录。 Yes
语言 字符串 输入音频的语言。 以 ISO-639-1 格式提供输入语言可以提高准确性和延迟。 No
提示 字符串 可选文本,用于指导模型风格或延续之前的音频片段。 提示应与音频语言相匹配。 No
response_format audioResponseFormat 定义输出格式。 No
temperature number 采样温度在0到1之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。 如果设置为0,模型会使用对数概率自动升温,直到达到某些阈值。 No 0
timestamp_granularities[] 数组 本次转录的时间戳细粒度。 response_format 必须设置为 verbose_json 使用时间戳的粒度。 支持 word以下选项中的一个或两个:,或 segment。 注意:段时间戳不会有额外延迟,但生成字时间戳会产生额外的延迟。 No ['segment']

audioSegment

转录或翻译片段。

Name 类型 Description Required Default
avg_logprob number 平均对数概率。 No
compression_ratio number Compression ratio. No
end number 段端偏移。 No
id 整数 Segment identifier. No
no_speech_prob number “无言语”的概率。 No
seek number 偏移分段。 No
start number 分段起始偏移。 No
temperature number Temperature. No
文本消息 字符串 Segment text. No
tokens 数组 文本的标记。 No

audioWord

转录词或翻译词。

Name 类型 Description Required Default
end number Word 端偏移。 No
start number Word 起始偏移。 No
字符串 Word No

createSpeechRequest

Speech request.

Name 类型 Description Required Default
输入 字符串 合成音频的文本。 最大长度为4,096字符。 Yes
response_format 枚举 合成音频的格式。
可能的值:mp3opusaacflacwavpcm
No
speed number 合成音频的速度。 从中0.25选择一个值。4.0 1.0 是默认。 No 1.0
voice 枚举 用于语音合成的声音。
可能的值:alloyechofableonyxnovashimmer
Yes

imageQuality

生成图像的质量。

Property Value
Description 生成图像的质量。
Type 字符串
Default auto
Values auto
high
medium
low
hd
standard

imagesResponseFormat

生成图像返回的格式。

Property Value
Description 生成图像返回的格式。
Type 字符串
Default url
Values url
b64_json

imagesOutputFormat

生成图像返回的文件格式。 仅支持系列机型。

Property Value
Description 生成图像返回的文件格式。 仅支持 gpt-image-1 系列型号。
Type 字符串
Default png
Values png
jpeg

imageSize

生成图像的大小。

Property Value
Description 生成图像的大小。
Type 字符串
Default auto
Values auto
1792x1024
1024x1792
1024x1024
1024x1536
1536x1024

imageStyle

生成图像的风格。 仅支持DALL-E-3。

Property Value
Description 生成图像的风格。 仅支持DALL-E-3。
Type 字符串
Default vivid
Values vivid
natural

imageBackground

允许设置生成图像背景的透明度。 该参数仅支持GPT-image-1系列模型。

Property Value
Description 允许设置生成图像背景的透明度。 该参数仅支持GPT-image-1系列模型。
Type 字符串
Default auto
Values transparent
opaque
auto

imageGenerationsRequest

Name 类型 Description Required Default
后台的 imageBackground 允许设置生成图像背景的透明度。 该参数仅支持GPT-image-1系列模型。 No auto
n 整数 需要生成的图片数量。 对于 dall-e-3,仅支持 n=1。 No 1
output_compression 整数 生成图像的压缩级别(0-100%)。 该参数仅支持带有jpeg输出格式的gpt-image-1系列模型。 No 100
output_format imagesOutputFormat 生成图像返回的文件格式。 仅支持 gpt-image-1 系列型号。 No png
提示 字符串 对所需图片的文字描述。 GPT-image-1系列最大长度为32000字符,dall-e-3最大字符为4000字符 Yes
quality imageQuality 生成图像的质量。 No auto
response_format imagesResponseFormat 生成图像返回的格式。 仅支持DALL-E-3。 No url
size imageSize 生成图像的大小。 No auto
样式 imageStyle 生成图像的风格。 仅支持DALL-E-3。 No vivid
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。 No

imageEditsRequest

Name 类型 Description Required Default
图像 字符串或数组 需要编辑的图片。 必须是支持的图片文件或图像数组。 每张图片应该是小于 25MB 的 png 或 jpg 文件。 Yes
过滤 字符串 另一张图像的完全透明区域(例如alpha为零)指示图像应编辑的位置。 如果提供多张图像,遮罩将应用到第一张图像上。 必须是有效的PNG文件,大小小于4MB,且尺寸与图片相同。 No
n 整数 需要生成的图片数量。 No 1
提示 字符串 对所需图片的文字描述。 最大长度为32000字符。 Yes
quality imageQuality 生成图像的质量。 No auto
response_format imagesResponseFormat 生成图像返回的格式。 No url
size imageSize 生成图像的大小。 No auto
用户 字符串 一个代表终端用户的唯一标识符,有助于监控和检测滥用行为。 No

generateImagesResponse

Name 类型 Description Required Default
created 整数 操作创建时的Unix时间戳。 Yes
数据 数组 如果操作成功,则为该操作的结果数据 Yes
使用情况 imageGenerationsUsage 表示图像生成请求的令牌使用详情。 仅适用于GPT-image-1系列型号。 No

imageResult

如果成功,则显示图片网址或编码图像,否则为错误。

Name 类型 Description Required Default
b64_json 字符串 base64编码图像 No
content_filter_results dalleContentFilterResults 关于内容过滤结果的信息。 No
prompt_filter_results dalleFilterResults 关于内容过滤类别(仇恨、性、暴力、self_harm)、是否检测到,以及严重程度(very_low、低、中、高,决定有害内容的强度和风险等级),以及是否被过滤。 关于越狱内容和脏话的信息,是否被检测到,以及是否经过过滤。 还有客户黑名单的信息(如果被过滤过的话)以及它的ID。 No
revised_prompt 字符串 如果提示词有任何修改,那就是用来生成图片的提示词。 No
url 字符串 图片网址。 No

imageGenerationsUsage

表示图像生成请求的令牌使用详情。 仅适用于GPT-image-1系列型号。

Name 类型 Description Required Default
input_tokens 整数 输入标记的数量。 No
input_tokens_details 对象 输入标记的详细分解。 No
└─ image_tokens 整数 图像标记的数量。 No
└─ text_tokens 整数 文字标记的数量。 No
output_tokens 整数 输出标记的数量。 No
total_tokens 整数 总使用的代币数量。 No

线

内容行对象由相邻的内容元素序列组成,如单词和选择标记。

Name 类型 Description Required Default
spans 数组 一组表示检测到物体及其边界盒信息的跨度。 Yes
文本消息 字符串 Yes

span

表示检测对象及其边界盒信息的span对象。

Name 类型 Description Required Default
length 整数 以字符为单位的跨度长度,以Unicode码点为单位。 Yes
偏移 整数 文本中字符偏移,即跨度起始处。 该偏移量定义为跨度第一个字符的位置,从文本开头计入Unicode码点。 Yes
多边形 数组 一组表示包围被检测对象的多边形中的点的对象。 Yes
文本消息 字符串 表示检测对象的跨度文本内容。 Yes

runCompletionUsage

与本次比赛相关的使用统计数据。 如果运行不是终端状态(即 in_progressqueued,等),则该值为 null

Name 类型 Description Required Default
completion_tokens 整数 在本次游戏过程中使用的完成代币数量。 Yes
prompt_tokens 整数 在游戏过程中使用的提示标记数量。 Yes
total_tokens 整数 总使用代币数(提示+完成)。 Yes

runStepCompletionUsage

与跑步相关的使用统计数据。 当运行步的状态为 in_progress时,这个值将是 null

Name 类型 Description Required Default
completion_tokens 整数 在运行步骤中使用了多少完成代币。 Yes
prompt_tokens 整数 在运行步骤中使用的提示标记数量。 Yes
total_tokens 整数 总使用代币数(提示+完成)。 Yes

assistantsApiResponseFormatOption

指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。

该组成部分可以是以下之一:

assistantsApiResponseFormat

描述模型预期输出的对象。 如果 json_objectfunction 允许将类型 tools 传递到运行中。 模型是否 text 能返回文本或所需的任何值。

Name 类型 Description Required Default
类型 字符串 必须是其中 text 之一或 json_object No 文本消息

类型 Enum: AssistantsApiResponseFormat

Value Description
文本消息
json_object

assistantObject

表示一个 assistant 可以调用模型并使用工具的。

Name 类型 Description Required Default
created_at 整数 Unix 时间戳(以秒计)表示助手创建的时间。 Yes
description 字符串 助理的描述。 最大长度为512个字符。
Yes
id 字符串 标识符,可以在 API 端点中引用。 Yes
instructions 字符串 助理使用的系统指令。 最大长度为256,000字符。
Yes
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
Yes
模型 字符串 型号的识别码。 Yes
name 字符串 助理的名字。 最大长度为256个字符。
Yes
对象 字符串 对象类型,始终 assistant为 。 Yes
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 这个助手附着的向量存储ID。 助手最多只能连接一个向量存储。
No
tools 数组 助手中启用的工具列表。 每位助手最多可使用128个工具。 工具可以是类型 code_interpreter、、 file_searchfunction
Yes []
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1

对象枚举:AssistantObjectType

Value Description
助手 对象类型,始终是助手

createAssistantRequest

Name 类型 Description Required Default
description 字符串 助理的描述。 最大长度为512个字符。
No
instructions 字符串 助理使用的系统指令。 最大长度为256,000字符。
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 Yes
name 字符串 助理的名字。 最大长度为256个字符。
No
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 这个助手附着的矢量存储器。 助手最多只能连接一个向量存储。
No
└─ vector_stores 数组 一个帮助创建向量存储的 Vector Store,并file_ids并附加到这个助手上。 助手最多只能连接一个向量存储。
No
tools 数组 助手中启用的工具列表。 每位助手最多可使用128个工具。 工具可以是类型 code_interpreter、、 retrievalfunction
No []
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1

modifyAssistantRequest

Name 类型 Description Required Default
description 字符串 助理的描述。 最大长度为512个字符。
No
instructions 字符串 助理使用的系统指令。 最大长度为32768字符。
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 No
name 字符串 助理的名字。 最大长度为256个字符。
No
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 覆盖工具 code_interpreter 可用的文件 ID 列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 覆盖连接到该助手的矢量存储。 助手最多只能连接一个向量存储。
No
tools 数组 助手中启用的工具列表。 每位助手最多可使用128个工具。 工具可以是类型 code_interpreter、、 retrievalfunction
No []
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1

deleteAssistantResponse

Name 类型 Description Required Default
deleted boolean Yes
id 字符串 Yes
对象 字符串 Yes

对象枚举:DeleteAssistantResponseState

Value Description
assistant.deleted

listAssistantsResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

assistantToolsCode

Name 类型 Description Required Default
类型 字符串 所定义的工具类型: code_interpreter Yes

类型 Enum: assistantToolsCodeType

Value Description
code_interpreter

assistantToolsFileSearch

Name 类型 Description Required Default
file_search 对象 文件搜索工具的覆盖。 No
└─ max_num_results 整数 文件搜索工具应输出的最大结果数。 默认是GPT-4*车型的20,GPT-3.5涡轮增压的5。 这个数字应在1到50之间(含)。

请注意,文件搜索工具可能输出的结果少 max_num_results 于结果。
No
类型 字符串 所定义的工具类型: file_search Yes

类型枚举:assistantToolsFileSearchType

Value Description
file_search

assistantToolsFileSearchTypeOnly

Name 类型 Description Required Default
类型 字符串 所定义的工具类型: file_search Yes

类型枚举:assistantToolsFileSearchType

Value Description
file_search

assistantToolsFunction

Name 类型 Description Required Default
函数 对象 函数定义。 Yes
└─ description 字符串 函数的功能描述,模型用来决定何时以及如何调用该函数。 No
└─ name 字符串 要调用的函数名称。 必须为 a-z、A-Z、0-9,或包含划线和破折号,长度最多为 64。 No
└─ parameters chatCompletionFunctionParameters 函数接受的参数,描述为 JSON Schema 对象。 关于格式的文档请参见 指南/JSON Schema 参考文献 No
类型 字符串 所定义的工具类型: function Yes

类型 Enum: assistantToolsFunction

Value Description
函数

truncationObject

控制线程在运行前如何截断。 用它来控制运行的初始上下文窗口。

Name 类型 Description Required Default
last_messages 整数 构建运行上下文时,线程中最近消息的数量。 No
类型 字符串 线程的截断策略。 默认值为 auto. 如果设置为 last_messages,线程将被截断为线程中最近n条消息。 当设置为 auto时,线程中间的消息将被丢弃以适应模型的上下文长度。 max_prompt_tokens Yes

类型枚举:截断类型

Value Description
auto
last_messages

assistantsApiToolChoiceOption

控制模型调用的(如果有)工具。 none 意味着模型不会调用任何工具,而是生成一条消息。 auto 是默认值,意味着模型可以选择生成消息或调用工具。 指定某个特定工具,比如 {"type": "file_search"}{"type": "function", "function": {"name": "my_function"}} ,强制模型调用该工具。

该组成部分可以是以下之一:

assistantsNamedToolChoice

指定模型应使用的工具。 用来强制模型调用特定工具。

Name 类型 Description Required Default
函数 对象 No
└─ name 字符串 调用函数的名称。 No
类型 字符串 工具的类型。 如果类型为 function,函数名必须被设置 Yes

类型枚举:AssistantsNamedToolChoiceType

Value Description
函数
code_interpreter
file_search

runObject

表示线程上的执行运行。

Name 类型 Description Required Default
assistant_id 字符串 执行本次行动的助理身份证。 Yes
cancelled_at 整数 Unix 时间戳(以秒为单位)表示运行被取消的时间。 Yes
completed_at 整数 Unix 时间戳(以秒计)表示运行完成时间。 Yes
created_at 整数 Unix 时间戳(以秒计)表示运行创建时间。 Yes
expires_at 整数 Unix 时间戳(以秒计)表示运行结束的时间。 Yes
failed_at 整数 Unix 时间戳(以秒计)表示运行失败的时间。 Yes
id 字符串 标识符,可以在 API 端点中引用。 Yes
incomplete_details 对象 关于为什么这次连载不完整的原因。 如果这次连载不算不完整,那就没 null 问题了。 Yes
└─ reason 字符串 导致这次连载不完整的原因。 这将指示在运行过程中达到的具体代币上限。 No
instructions 字符串 助理用来执行这次任务的指令。 Yes
last_error 对象 这是这次跑动的最后一个错误。 如果没有错误,那就是 null Yes
└─ code 字符串 server_errorrate_limit_exceeded No
└─ message 字符串 一个人类易读的错误描述。 No
max_completion_tokens 整数 指定在整个运行过程中已使用的最大完成代币数量。
Yes
max_prompt_tokens 整数 指定在整个运行过程中使用了最多提示令牌数量。
Yes
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
Yes
模型 字符串 助理这次用的模型。 Yes
对象 字符串 对象类型,始终 thread.run为 。 Yes
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
required_action 对象 关于继续运行所需的动作细节。 如果不需要采取任何行动,那会是的 null Yes
└─ submit_tool_outputs 对象 关于本次运行所需的工具输出详情。 No
└─ tool_calls 数组 相关工具调用列表。 No
└─ type 枚举 目前,这总是 submit_tool_outputs
可能的数值: submit_tool_outputs
No
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
Yes
started_at 整数 Unix 时间戳(以秒为单位)表示运行开始的时间。 Yes
状态 字符串 运行状态可以是 queuedin_progresscancelledcancellingfailedrequires_action, , completed, 或 。expired Yes
temperature number 本次运行使用的采样温度。 如果未设置,默认为1。 No
thread_id 字符串 这是本次运行中执行的线程的ID。 Yes
tool_choice assistantsApiToolChoiceOption 控制模型调用的(如果有)工具。
none 意味着模型不会调用任何工具,而是生成一条消息。
auto 是默认值,意味着模型可以选择生成消息或调用工具。
指定某个特定工具,比如 {"type": "file_search"}{"type": "function", "function": {"name": "my_function"}} ,强制模型调用该工具。
Yes
tools 数组 助理这次跑用的工具清单。 Yes []
top_p number 本次运行所用的核采样值。 如果未设置,默认为1。 No
truncation_strategy truncationObject 控制线程在运行前如何截断。 用它来控制运行的初始上下文窗口。 Yes
使用情况 runCompletionUsage 与本次比赛相关的使用统计数据。 如果运行不是终端状态(即 in_progressqueued,等),则该值为 null Yes

object Enum: runObjectType

Value Description
thread.run run 对象类型始终是 thread.run

status Enum: RunObjectStatus

Value Description
queued 队列状态
in_progress in_progress状态
requires_action required_action状态
cancelling 取消状态
cancelled 被取消的国家
failed 失败的国家
completed 完工的国家
expired 过期状态

createRunRequest

Name 类型 Description Required Default
additional_instructions 字符串 在运行指令的结尾附加额外指令。 这对于每次运行修改行为而不会覆盖其他指令非常有用。 No
additional_messages 数组 在创建运行前向线程添加额外消息。 No
assistant_id 字符串 执行本次运行时使用的助手ID。 Yes
instructions 字符串 覆盖助理的默认系统消息。 这对于每次运行修改行为非常有用。 No
max_completion_tokens 整数 在本次运行过程中可使用的最大完成代币数量。 该跑法尽力只使用指定数量的完成标记,分多个回合进行。 如果运行超过指定完成标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
max_prompt_tokens 整数 在整个游戏过程中,最多可使用提示代币数。 该游戏尽力在多个回合中只使用指定的提示标记数量。 如果运行超过指定提示标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 用于执行本次运行的模型ID。 如果这里提供了某个值,它会覆盖与助手关联的模型。 如果没有,则使用与助手关联的模型。 No
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
数据流 boolean 如果 true,则返回运行期间发生的事件流,作为服务器发送的事件,运行进入终端状态并发送 data: [DONE] 消息时终止。
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
tool_choice assistantsApiToolChoiceOption 控制模型调用的(如果有)工具。
none 意味着模型不会调用任何工具,而是生成一条消息。
auto 是默认值,意味着模型可以选择生成消息或调用工具。
指定某个特定工具,比如 {"type": "file_search"}{"type": "function", "function": {"name": "my_function"}} ,强制模型调用该工具。
No
tools 数组 覆盖助理本次运行时可用的工具。 这对于每次运行修改行为非常有用。 No
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1
truncation_strategy truncationObject 控制线程在运行前如何截断。 用它来控制运行的初始上下文窗口。 No

listRunsResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

modifyRunRequest

Name 类型 Description Required Default
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No

submitToolOutputsRunRequest

Name 类型 Description Required Default
数据流 boolean 如果 true,则返回运行期间发生的事件流,作为服务器发送的事件,运行进入终端状态并发送 data: [DONE] 消息时终止。
No
tool_outputs 数组 一份提交输出的工具列表。 Yes

runToolCallObject

工具调用对象

Name 类型 Description Required Default
函数 对象 函数定义。 Yes
└─ arguments 字符串 模型期望你传递给函数的参数。 No
└─ name 字符串 函数名称。 No
id 字符串 工具调用的ID。 当你提交工具输出时,必须引用这个 ID,使用提交工具输出来运行 endpointendpoint。 Yes
类型 字符串 输出所需的工具调用类型。 目前,这总是 function Yes

类型枚举:RunToolCallObjectType

Value Description
函数

createThreadAndRunRequest

Name 类型 Description Required Default
assistant_id 字符串 执行本次运行时使用的助手ID。 Yes
instructions 字符串 覆盖助理的默认系统消息。 这对于每次运行修改行为非常有用。 No
max_completion_tokens 整数 在本次运行过程中可使用的最大完成代币数量。 该跑法尽力只使用指定数量的完成标记,分多个回合进行。 如果运行超过指定完成标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
max_prompt_tokens 整数 在整个游戏过程中,最多可使用提示代币数。 该游戏尽力在多个回合中只使用指定的提示标记数量。 如果运行超过指定提示标记数,运行将以状态 incomplete结束。 更多信息请参见 incomplete_details
No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
模型 字符串 用于执行本次运行的模型ID。 如果这里提供了某个值,它会覆盖与助手关联的模型。 如果没有,则使用与助手关联的模型。 No
parallel_tool_calls ParallelToolCalls 是否在工具使用时启用并行函数调用。 No True
response_format assistantsApiResponseFormatOption 指定模型必须输出的格式。 兼容GPT-4o、GPT-4 Turbo及自始 gpt-3.5-turbo-1106至终的所有GPT-3.5 Turbo模型。

设置为 { "type": "json_schema", "json_schema": {...} } 启用结构化输出,确保模型与你提供的JSON模式匹配。 更多信息请参阅结构化输出指南。

设置启用 { "type": "json_object" } JSON 模式,确保模型生成的消息是有效的 JSON。

重要提示: 使用JSON模式时, 你还必须 通过系统或用户消息指示模型自行生成JSON。 如果没有这一点,模型可能会不断生成空白流,直到生成达到令牌上限,导致请求运行时间长且看似“卡住”。 还需注意,如果 finish_reason="length",消息内容可能部分中断,表示生成次数或 max_tokens 对话超过了最大上下文长度。
No
数据流 boolean 如果 true,则返回运行期间发生的事件流,作为服务器发送的事件,运行进入终端状态并发送 data: [DONE] 消息时终止。
No
stream_options chatCompletionStreamOptions 流式响应选项。 只有在你设置 stream: true时才会设置这个。
No None
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
No 1
会话 createThreadRequest No
tool_choice assistantsApiToolChoiceOption 控制模型调用的(如果有)工具。
none 意味着模型不会调用任何工具,而是生成一条消息。
auto 是默认值,意味着模型可以选择生成消息或调用工具。
指定某个特定工具,比如 {"type": "file_search"}{"type": "function", "function": {"name": "my_function"}} ,强制模型调用该工具。
No
tool_resources 对象 一组由助手工具使用的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 这个助手附着的向量存储ID。 助手最多只能连接一个向量存储。
No
tools 数组 覆盖助理本次运行时可用的工具。 这对于每次运行修改行为非常有用。 No
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们一般建议调整温度,但不要两者兼顾。
No 1
truncation_strategy truncationObject 控制线程在运行前如何截断。 用它来控制运行的初始上下文窗口。 No

threadObject

表示包含消息的线程。

Name 类型 Description Required Default
created_at 整数 Unix 时间戳(以秒为单位)表示线程创建的时间。 Yes
id 字符串 标识符,可以在 API 端点中引用。 Yes
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
Yes
对象 字符串 对象类型,始终 thread为 。 Yes
tool_resources 对象 这是一组在本帖中为助理工具提供的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
Yes
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 向量存储链接到本帖。 线程上最多只能连接1个向量存储。
No

对象枚举:ThreadObjectType

Value Description
会话 线程对象类型,总是 thread

createThreadRequest

Name 类型 Description Required Default
messages 数组 一份用于开启讨论的消息列表。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
tool_resources 对象 这是一组在本帖中为助理工具提供的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具提供的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 向量存储链接到本帖。 线程上最多只能连接1个向量存储。
No
└─ vector_stores 数组 一个帮助创建向量存储并附加到file_ids的辅助工具。 线程上最多只能连接1个向量存储。
No

modifyThreadRequest

Name 类型 Description Required Default
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
tool_resources 对象 这是一组在本帖中为助理工具提供的资源。 这些资源是针对工具类型而定的。 例如,该 code_interpreter 工具需要文件 ID 列表,而工具则 file_search 需要向量存储 ID 列表。
No
└─ code_interpreter 对象 No
└─ file_ids 数组 工具可用的 code_interpreter 文件ID列表。 该工具最多可关联20个文件。
No []
└─ file_search 对象 No
└─ vector_store_ids 数组 向量存储链接到本帖。 线程上最多只能连接1个向量存储。
No

deleteThreadResponse

Name 类型 Description Required Default
deleted boolean Yes
id 字符串 Yes
对象 字符串 Yes

对象枚举:DeleteThreadResponseObjectState

Value Description
thread.deleted 删除线程响应对象状态为 thread.deleted

listThreadsResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

messageObject

表示线程中的一条信息。

Name 类型 Description Required Default
assistant_id 字符串 如适用,请提供该信息作者的ID。 Yes
attachments 数组 附带的文件列表,以及它们被添加到的工具。 Yes
completed_at 整数 Unix 时间戳(以秒计)表示消息完成的时间。 Yes
内容 数组 消息内容以文本和/或图片阵列表示。 Yes
created_at 整数 Unix时间戳(以秒计)表示消息创建的时间。 Yes
id 字符串 标识符,可以在 API 端点中引用。 Yes
incomplete_at 整数 Unix 时间戳(以秒计)表示消息被标记为不完整的时间。 Yes
incomplete_details 对象 对于不完整的消息,请详细说明该消息不完整的原因。 Yes
└─ reason 字符串 信息不完整的原因。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
Yes
对象 字符串 对象类型,始终 thread.message为 。 Yes
角色 字符串 那个产生信息的实体。 或 userassistant Yes
run_id 字符串 如果适用,请标注与该消息创作相关的运行ID。 Yes
状态 字符串 消息状态可以是 in_progressincompletecompleted Yes
thread_id 字符串 该消息所属的主题串。 Yes

对象枚举:MessageObjectType

Value Description
thread.message 消息对象类型为 thread.message

status 枚举:MessageObjectStatus

Value Description
in_progress
incomplete
completed

role 枚举:MessageObjectRole

Value Description
用户
助手

messageDeltaObject

表示消息的 delta,即在流式传输过程中消息中的任何字段发生变化。

Name 类型 Description Required Default
delta 对象 包含消息中发生变化字段的delta。 Yes
└─ content 数组 消息内容以文本和/或图片阵列表示。 No
└─ role 字符串 那个产生信息的实体。 或 userassistant No
id 字符串 消息的标识符,可以在 API 端点中引用。 Yes
对象 字符串 对象类型,始终 thread.message.delta为 。 Yes

object 枚举:MessageDeltaObjectType

Value Description
thread.message.delta

createMessageRequest

Name 类型 Description Required Default
attachments 数组 附带文件列表,以及应添加的工具。 No
内容 字符串 信息内容。 Yes
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
角色 字符串 创建消息的实体的角色。 允许的数值包括:
- user表示消息由实际用户发送,通常用于表示用户生成的消息。
- assistant表示消息由助手生成。 利用该值将助手的消息插入对话中。
Yes

role Enum: CreateMessageRequestRole

Value Description
用户
助手

modifyMessageRequest

Name 类型 Description Required Default
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No

deleteMessageResponse

Name 类型 Description Required Default
deleted boolean Yes
id 字符串 Yes
对象 字符串 Yes

对象枚举:DeleteMessageResponseObject

Value Description
thread.message.deleted 删除消息响应对象状态

listMessagesResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

messageContentImageFileObject

在消息内容中引用图像文件。

Name 类型 Description Required Default
image_file 对象 Yes
└─ file_id 字符串 消息内容中图片的文件ID。 No
类型 字符串 总是。image_file Yes

类型枚举:MessageContentImageFileObjectType

Value Description
image_file 消息内容图像文件类型

messageContentTextObject

是信息中包含的文本内容。

Name 类型 Description Required Default
文本消息 对象 Yes
└─ annotations 数组 No
└─ value 字符串 构成文本的数据。 No
类型 字符串 总是。text Yes

类型枚举:messageContentTextObjectType

Value Description
文本消息 消息内容文本对象类型

messageContentTextAnnotationsFileCitationObject

消息中引用的引用指向与助理或该信息相关的特定文件中的具体引用。 助手使用“检索”工具搜索文件时生成。

Name 类型 Description Required Default
end_index 整数 Yes
file_citation 对象 Yes
└─ file_id 字符串 引用所属具体文件的编号。 No
start_index 整数 Yes
文本消息 字符串 消息内容中需要替换的文本。 Yes
类型 字符串 总是。file_citation Yes

类型枚举:FileCitationObjectType

Value Description
file_citation 文件引用对象类型

messageContentTextAnnotationsFilePathObject

一个助理用 code_interpreter 工具生成文件时生成的文件URL。

Name 类型 Description Required Default
end_index 整数 Yes
file_path 对象 Yes
└─ file_id 字符串 生成的文件ID。 No
start_index 整数 Yes
文本消息 字符串 消息内容中需要替换的文本。 Yes
类型 字符串 总是。file_path Yes

类型枚举:FilePathObjectType

Value Description
file_path 文件路径对象类型

messageDeltaContentImageFileObject

在消息内容中引用图像文件。

Name 类型 Description Required Default
image_file 对象 No
└─ file_id 字符串 消息内容中图片的文件ID。 No
索引 整数 信息中内容的索引部分。 Yes
类型 字符串 总是。image_file Yes

类型枚举:MessageDeltaContentImageFileObjectType

Value Description
image_file

messageDeltaContentTextObject

是信息中包含的文本内容。

Name 类型 Description Required Default
索引 整数 信息中内容的索引部分。 Yes
文本消息 对象 No
└─ annotations 数组 No
└─ value 字符串 构成文本的数据。 No
类型 字符串 总是。text Yes

类型枚举:MessageDeltaContentTextObjectType

Value Description
文本消息

messageDeltaContentTextAnnotationsFileCitationObject

消息中引用的引用指向与助理或该信息相关的特定文件中的具体引用。 助手使用“file_search”工具搜索文件时生成。

Name 类型 Description Required Default
end_index 整数 No
file_citation 对象 No
└─ file_id 字符串 引用所属具体文件的编号。 No
└─ quote 字符串 文件中的具体报价。 No
索引 整数 文本内容部分注释的索引。 Yes
start_index 整数 No
文本消息 字符串 消息内容中需要替换的文本。 No
类型 字符串 总是。file_citation Yes

类型枚举:MessageDeltaContentTextAnnotationsFileCitationObjectType

Value Description
file_citation

messageDeltaContentTextAnnotationsFilePathObject

一个助理用 code_interpreter 工具生成文件时生成的文件URL。

Name 类型 Description Required Default
end_index 整数 No
file_path 对象 No
└─ file_id 字符串 生成的文件ID。 No
索引 整数 文本内容部分注释的索引。 Yes
start_index 整数 No
文本消息 字符串 消息内容中需要替换的文本。 No
类型 字符串 总是。file_path Yes

类型枚举:MessageDeltaContentTextAnnotationsFilePathObjectType

Value Description
file_path

runStepObject

代表执行跑动中的一步。

Name 类型 Description Required Default
assistant_id 字符串 与跑步关联的助理ID。 Yes
cancelled_at 整数 Unix 时间戳(以秒为单位)表示执行步被取消的时间。 Yes
completed_at 整数 Unix 时间戳(以秒计)表示运行步骤完成的时间。 Yes
created_at 整数 Unix 时间戳(以秒计)表示执行步骤创建的时间。 Yes
expired_at 整数 Unix 时间戳(以秒计)表示运行步骤过期的时间。 如果父运行已过期,则该步骤被视为已过期。 Yes
failed_at 整数 Unix 时间戳(以秒为单位)表示执行步骤失败的时间。 Yes
id 字符串 运行步骤的标识符,可以在 API 端点中引用。 Yes
last_error 对象 与此运行步骤相关的最后一个错误。 如果没有错误,那就是 null Yes
└─ code 字符串 server_errorrate_limit_exceeded No
└─ message 字符串 一个人类易读的错误描述。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
Yes
对象 字符串 对象类型,始终 assistant.run.step为 。 Yes
run_id 字符串 这个运行步骤所包含的运行的ID。 Yes
状态 字符串 运行状态可以是 in_progresscancelledfailedcompleted、 或 expired Yes
step_details runStepDetailsMessageCreationObjectrunStepDetailsToolCallsObject 跑步的细节。 Yes
thread_id 字符串 被运行的线程的ID。 Yes
类型 字符串 跑步类型,可以是 message_creationtool_calls Yes

对象枚举:RunStepObjectType

Value Description
assistant.run.step 对象类型,总是 assistant.run.step

类型枚举:RunStepObjectType

Value Description
message_creation message_creation跑步
tool_calls tool_calls跑步

status Enum: RunStepObjectStatus

Value Description
in_progress in_progress运行状态
cancelled 取消的演出状态
failed 取消的演出状态
completed 取消的演出状态
expired 取消的演出状态

runStepDeltaObject

表示运行步骤的差值,即在流式传输过程中运行步骤中任何字段发生变化。

Name 类型 Description Required Default
delta 对象 包含运行步中发生变化的字段的delta。 Yes
└─ step_details runStepDeltaStepDetailsMessageCreationObjectrunStepDeltaStepDetailsToolCallsObject 跑步的细节。 No
id 字符串 运行步骤的标识符,可以在 API 端点中引用。 Yes
对象 字符串 对象类型,始终 thread.run.step.delta为 。 Yes

object 枚举:RunStepDeltaObjectType

Value Description
thread.run.step.delta

listRunStepsResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

runStepDetailsMessageCreationObject

按运行步创建消息的详细信息。

Name 类型 Description Required Default
message_creation 对象 Yes
└─ message_id 字符串 由该运行步骤创建的消息的ID。 No
类型 字符串 总是。message_creation Yes

类型枚举类型:RunStepDetailsMessageCreationObjectType(运行步骤详细信息MessageCreationObjectType)

Value Description
message_creation

runStepDeltaStepDetailsMessageCreationObject

按运行步创建消息的详细信息。

Name 类型 Description Required Default
message_creation 对象 No
└─ message_id 字符串 由该运行步骤创建的消息的ID。 No
类型 字符串 总是。message_creation Yes

类型枚举:RunStepDeltaStepDetailsMessageCreationObjectType

Value Description
message_creation

runStepDetailsToolCallsObject

工具调用的详细信息。

Name 类型 Description Required Default
tool_calls 数组 运行步涉及一系列工具调用。 这些工具可以与三种工具类型之一关联: code_interpreterretrievalfunction
Yes
类型 字符串 总是。tool_calls Yes

类型枚举:RunStepDetailsToolCallsObjectType

Value Description
tool_calls

runStepDeltaStepDetailsToolCallsObject

工具调用的详细信息。

Name 类型 Description Required Default
tool_calls 数组 运行步涉及一系列工具调用。 这些工具可以与三种工具类型之一关联: code_interpreterfile_searchfunction
No
类型 字符串 总是。tool_calls Yes

类型枚举:RunStepDeltaStepDetailsToolCallsObjectType

Value Description
tool_calls

runStepDetailsToolCallsCodeObject

涉及执行步骤的代码解释器工具调用的详细信息。

Name 类型 Description Required Default
code_interpreter 对象 代码解释器工具调用定义。 Yes
└─ input 字符串 代码解释器工具调用的输入。 No
└─ outputs 数组 代码解释器工具调用的输出。 代码解释器可以输出一个或多个项目,包括文本(logs)或图片(image)。 每个对象类型都不同。 No
id 字符串 工具调用的ID。 Yes
类型 字符串 工具调用的类型。 这总是针对 code_interpreter 这类工具调用。 Yes

类型枚举:RunStepDetailsToolCallsCodeObjectType

Value Description
code_interpreter

runStepDeltaStepDetailsToolCallsCodeObject

涉及执行步骤的代码解释器工具调用的详细信息。

Name 类型 Description Required Default
code_interpreter 对象 代码解释器工具调用定义。 No
└─ input 字符串 代码解释器工具调用的输入。 No
└─ outputs 数组 代码解释器工具调用的输出。 代码解释器可以输出一个或多个项目,包括文本(logs)或图片(image)。 每个对象类型都不同。 No
id 字符串 工具调用的ID。 No
索引 整数 工具调用数组中的索引。 Yes
类型 字符串 工具调用的类型。 这总是针对 code_interpreter 这类工具调用。 Yes

类型枚举:RunStepDeltaStepDetailsToolCallsCodeObjectType

Value Description
code_interpreter

runStepDetailsToolCallsCodeOutputLogsObject

代码解释器工具调用的文本输出,作为运行步骤的一部分。

Name 类型 Description Required Default
日志 字符串 代码解释器工具调用的文本输出。 Yes
类型 字符串 总是。logs Yes

类型枚举:RunStepDetailsToolCallsCodeOutputLogsObjectType

Value Description
日志

runStepDeltaStepDetailsToolCallsCodeOutputLogsObject

代码解释器工具调用的文本输出,作为运行步骤的一部分。

Name 类型 Description Required Default
索引 整数 输出数组中的输出索引。 Yes
日志 字符串 代码解释器工具调用的文本输出。 No
类型 字符串 总是。logs Yes

类型枚举:RunStepDeltaStepDetailsToolCallsCodeOutputLogsObjectType

Value Description
日志

runStepDetailsToolCallsCodeOutputImageObject

Name 类型 Description Required Default
图像 对象 Yes
└─ file_id 字符串 图片的文件ID。 No
类型 字符串 总是。image Yes

类型枚举:RunStepDetailsToolCallsCodeOutputImageObjectType

Value Description
图像

runStepDeltaStepDetailsToolCallsCodeOutputImageObject

Name 类型 Description Required Default
图像 对象 No
└─ file_id 字符串 图片的文件ID。 No
索引 整数 输出数组中的输出索引。 Yes
类型 字符串 总是。image Yes

类型枚举:RunStepDeltaStepDetailsToolCallsCodeOutputImageObject

Value Description
图像

runStepDetailsToolCallsFileSearchObject

Name 类型 Description Required Default
file_search 对象 目前,这永远是一个空物。 Yes
└─ results 数组 文件搜索结果。 No
id 字符串 工具调用对象的ID。 Yes
类型 字符串 工具调用的类型。 这总是针对 file_search 这类工具调用。 Yes

类型枚举:RunStepDetailsToolCallsFileSearchObjectType

Value Description
file_search

runStepDetailsToolCallsFileSearchResultObject

文件搜索的结果实例。

Name 类型 Description Required Default
内容 数组 发现的结果内容。 只有通过包含查询参数请求时,才会包含内容。 No
file_id 字符串 结果所在的文件ID。 Yes
file_name 字符串 结果所在的文件名称。 Yes
分数 number 结果比分。 所有值必须是浮点数,介于0到1之间。 Yes

runStepDeltaStepDetailsToolCallsFileSearchObject

Name 类型 Description Required Default
file_search 对象 目前,这永远是一个空物。 Yes
id 字符串 工具调用对象的ID。 No
索引 整数 工具调用数组中的索引。 Yes
类型 字符串 工具调用的类型。 这总是针对 retrieval 这类工具调用。 Yes

类型枚举:RunStepDeltaStepDetailsToolCallsFileSearchObjectType

Value Description
file_search

runStepDetailsToolCallsFunctionObject

Name 类型 Description Required Default
函数 对象 被调用的函数定义。 Yes
└─ arguments 字符串 参数传递给函数。 No
└─ name 字符串 函数名称。 No
└─ output 字符串 函数的输出。 如果输出尚未提交,这将是前提 null No
id 字符串 工具调用对象的ID。 Yes
类型 字符串 工具调用的类型。 这总是针对 function 这类工具调用。 Yes

类型枚举:RunStepDetailsToolCallsFunctionObjectType

Value Description
函数

runStepDeltaStepDetailsToolCallsFunctionObject

Name 类型 Description Required Default
函数 对象 被调用的函数定义。 No
└─ arguments 字符串 参数传递给函数。 No
└─ name 字符串 函数名称。 No
└─ output 字符串 函数的输出。 如果输出尚未提交,这将是前提 null No
id 字符串 工具调用对象的ID。 No
索引 整数 工具调用数组中的索引。 Yes
类型 字符串 工具调用的类型。 这总是针对 function 这类工具调用。 Yes

类型枚举:RunStepDetailsToolCallsFunctionObjectType

Value Description
函数

vectorStoreExpirationAfter

向量存储的过期政策。

Name 类型 Description Required Default
定位标记 字符串 锚定时间戳,之后生效策略。 支撑锚点: last_active_at Yes
days 整数 锚定时间后向量存储到期的天数。 Yes

锚点枚举:向量存储到期锚点后

Value Description
last_active_at 锚点时间戳,之后该政策生效。

vectorStoreObject

矢量存储是工具可使用 file_search 处理过的文件集合。

Name 类型 Description Required Default
created_at 整数 Unix 时间戳(以秒计)表示向量存储创建的时间。 Yes
expires_after vectorStoreExpirationAfter 向量存储的过期政策。 No
expires_at 整数 Unix的时间戳(以秒为单位)表示向量存储器何时过期。 No
file_counts 对象 Yes
└─ cancelled 整数 被取消的文件数量。 No
└─ completed 整数 已成功处理的文件数量。 No
└─ failed 整数 未能处理的文件数量。 No
└─ in_progress 整数 目前正在处理的文件数量。 No
└─ total 整数 文件总数。 No
id 字符串 标识符,可以在 API 端点中引用。 Yes
last_active_at 整数 Unix 时间戳(以秒为单位)表示向量存储器最后一次激活的时间。 Yes
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
Yes
name 字符串 向量存储器的名字。 Yes
对象 枚举 对象类型,始终 vector_store为 。
可能的数值: vector_store
Yes
状态 字符串 向量存储状态可以是 expired,也可以completed是 。 in_progress 状态 表示 completed 向量存储器已准备好使用。 Yes
usage_bytes 整数 向量存储中文件使用的总字节数。 Yes

status Enum: VectorStoreObjectStatus

Value Description
expired
in_progress
completed

createVectorStoreRequest

Name 类型 Description Required Default
chunking_strategy autoChunkingStrategyRequestParamstaticChunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 仅当 file_ids 非空时 才适用。 No
expires_after vectorStoreExpirationAfter 向量存储的过期政策。 No
file_ids 数组 一份向量存储应使用的文件ID列表。 对于这类工具 file_search 来说,它能访问文件非常有用。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
name 字符串 向量存储器的名字。 No

updateVectorStoreRequest

Name 类型 Description Required Default
expires_after vectorStoreExpirationAfter 向量存储的过期政策。 No
元数据 对象 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息非常有用。 键长最多可为64个字符,值最多可达512个字符。
No
name 字符串 向量存储器的名字。 No

listVectorStoresResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

deleteVectorStoreResponse

Name 类型 Description Required Default
deleted boolean Yes
id 字符串 Yes
对象 字符串 Yes

对象枚举:DeleteVectorStoreResponseObject

Value Description
vector_store.deleted 删除向量存储响应对象状态

vectorStoreFileObject

一个附着在矢量存储的文件列表。

Name 类型 Description Required Default
chunking_strategy autoChunkingStrategyRequestParamstaticChunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 仅当 file_ids 非空时 才适用。 No
created_at 整数 Unix 时间戳(以秒计)表示向量存储文件创建的时间。 Yes
id 字符串 标识符,可以在 API 端点中引用。 Yes
last_error 对象 与该向量存储文件相关的最后一个错误。 如果没有错误,那就是 null Yes
└─ code 字符串 或为 server_errorinvalid_fileunsupported_file或 。 No
└─ message 字符串 一个人类易读的错误描述。 No
对象 字符串 对象类型,始终 vector_store.file为 。 Yes
状态 字符串 向量存储文件的状态可以是 in_progress、 、 completedcancelled、 或 failed。 状态 completed 表示矢量存储文件已准备好使用。 Yes
usage_bytes 整数 向量存储的总使用量以字节为单位。 请注意,这可能与原始文件大小不同。 Yes
vector_store_id 字符串 文件所附着的向量存储的ID。 Yes

对象枚举:VectorStoreFileObjectType

Value Description
vector_store.file

status Enum: VectorStoreFileObjectStatus

Value Description
in_progress
completed
cancelled
failed

otherChunkingStrategyResponseParam

当分块策略未知时,该值返回。 通常,这是因为文件在API引入概念之前 chunking_strategy 就已被索引。

Name 类型 Description Required Default
类型 字符串 总是。other Yes

类型枚举:OtherChunkingStrategyResponseParamType

Value Description
other

staticChunkingStrategyResponseParam

Name 类型 Description Required Default
静态的 staticChunkingStrategy Yes
类型 字符串 总是。static Yes

类型枚举:StaticChunkingStrategyResponseParamType

Value Description
静态的

staticChunkingStrategy

Name 类型 Description Required Default
chunk_overlap_tokens 整数 区块之间重叠的代币数量。 默认值为 400

注意,重叠值不得超过的一半 max_chunk_size_tokens
Yes
max_chunk_size_tokens 整数 每个区块中最多的标记数。 默认值为 800。 最小值为 100 ,最大值为 4096 Yes

autoChunkingStrategyRequestParam

默认策略。 该策略目前使用一个 max_chunk_size_tokens800chunk_overlap_tokens400

Name 类型 Description Required Default
类型 枚举 总是。auto
可能的数值: auto
Yes

staticChunkingStrategyRequestParam

Name 类型 Description Required Default
静态的 staticChunkingStrategy Yes
类型 枚举 总是。static
可能的数值: static
Yes

chunkingStrategyRequestParam

用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。

该组成部分可以是以下之一:

createVectorStoreFileRequest

Name 类型 Description Required Default
chunking_strategy chunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 No
file_id 字符串 向量存储应该使用的文件ID。 对于这类工具 file_search 来说,它能访问文件非常有用。 Yes

listVectorStoreFilesResponse

Name 类型 Description Required Default
数据 数组 Yes
first_id 字符串 Yes
has_more boolean Yes
last_id 字符串 Yes
对象 字符串 Yes

deleteVectorStoreFileResponse

Name 类型 Description Required Default
deleted boolean Yes
id 字符串 Yes
对象 字符串 Yes

对象枚举:DeleteVectorStoreFileResponseObject

Value Description
vector_store.file.deleted

vectorStoreFileBatchObject

一组文件绑定在矢量存储上。

Name 类型 Description Required Default
created_at 整数 Unix 时间戳(以秒计)表示向量存储文件批量创建的时间。 Yes
file_counts 对象 Yes
└─ cancelled 整数 被取消的文件数量。 No
└─ completed 整数 已经处理的文件数量。 No
└─ failed 整数 未能处理的文件数量。 No
└─ in_progress 整数 目前正在处理的文件数量。 No
└─ total 整数 文件总数。 No
id 字符串 标识符,可以在 API 端点中引用。 Yes
对象 字符串 对象类型,始终 vector_store.file_batch为 。 Yes
状态 字符串 向量存储文件批量状态,可以是 in_progresscompletedcancelledfailed Yes
vector_store_id 字符串 文件所附着的向量存储的ID。 Yes

对象枚举:VectorStoreFileBatchObjectType

Value Description
vector_store.files_batch

status Enum: VectorStoreFileBatchObjectStatus

Value Description
in_progress
completed
cancelled
failed

createVectorStoreFileBatchRequest

Name 类型 Description Required Default
chunking_strategy chunkingStrategyRequestParam 用于分块文件的分块策略。 如果没有设置,我会用这个 auto 策略。 No
file_ids 数组 一份向量存储应该使用的文件ID列表。 对于这类工具 file_search 来说,它能访问文件非常有用。 Yes

assistantStreamEvent

表示在流媒体运行时发出的事件。

服务器发送事件流中的每个事件都有 event 一个 and data 属性:

event: thread.created
data: {"id": "thread_123", "object": "thread", ...}

每当新对象被创建、切换到新状态或分段流(delta)时,我们都会发出事件。 例如,创建新运行thread.run.completed、完成运行等,我们会发出。thread.run.created 当助理选择在运行中创建消息时,我们会发出一个 thread.message.created event,一个 thread.message.in_progress 事件,多个 thread.message.delta 事件,最后 thread.message.completed 一个事件。

我们可能会随着时间推移添加更多事件,因此建议你在代码中优雅地处理未知事件。

该组成部分可以是以下之一:

threadStreamEvent

该组成部分可以是以下之一:

thread.created

当新线程创建时会发生。

Name 类型 Description Required Default
数据 threadObject 表示包含消息的线程。 Yes
事件 字符串 Yes

Data: threadObject

事件枚举:ThreadStreamEventEnum

Value Description
thread.created 线程创建事件

runStreamEvent

该组成部分可以是以下之一:

thread.run.created

当新运行发生时。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventCreated

Value Description
thread.run.created

thread.run.queued

当跑动进入某个 queued 状态时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventQueued

Value Description
thread.run.queued

thread.run.in_progress

当跑动进入状态 in_progress 时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventInProgress

Value Description
thread.run.in_progress

thread.run.requires_action

当跑动进入某个 requires_action 状态时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

Event Enum: RunStreamEventRequiresAction

Value Description
thread.run.requires_action

thread.run.completed

当一次运行完成时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventCompleted(已完成)

Value Description
thread.run.completed

thread.run.failed

当一次运行失败时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventFailed

Value Description
thread.run.failed

thread.run.cancelling

当跑动进入某个 cancelling 状态时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventCancelling

Value Description
thread.run.cancelling

thread.run.cancelled

当一次运行被取消时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventCancelled

Value Description
thread.run.cancelled

thread.run.expired

当连跑结束时发生。

Name 类型 Description Required Default
数据 runObject 表示线程上的执行运行。 Yes
事件 字符串 Yes

Data: runObject

事件枚举:RunStreamEventExpired

Value Description
thread.run.expired

runStepStreamEvent

该组成部分可以是以下之一:

thread.run.step.created

当创建运行步骤时发生。

Name 类型 Description Required Default
数据 runStepObject 代表执行跑动中的一步。
Yes
事件 字符串 Yes

Data: runStepObject

事件枚举:RunStepStreamEventCreated

Value Description
thread.run.step.created

thread.run.step.in_progress

当一个运行步移动到某个 in_progress 状态时,会发生这种情况。

Name 类型 Description Required Default
数据 runStepObject 代表执行跑动中的一步。
Yes
事件 字符串 Yes

Data: runStepObject

事件枚举:RunStepStreamEventInProgress(运行步流EventInProgress)

Value Description
thread.run.step.in_progress

thread.run.step.delta

当运行步的部分被流式传输时,就会发生这种情况。

Name 类型 Description Required Default
数据 runStepDeltaObject 表示运行步骤的差值,即在流式传输过程中运行步骤中任何字段发生变化。
Yes
事件 字符串 Yes

Data: runStepDeltaObject

Event Enum: RunStepStreamEventDelta

Value Description
thread.run.step.delta

thread.run.step.completed

当一个运行步骤完成时发生。

Name 类型 Description Required Default
数据 runStepObject 代表执行跑动中的一步。
Yes
事件 字符串 Yes

Data: runStepObject

事件枚举:RunStepStreamEventCompleted(已完成)

Value Description
thread.run.step.completed

thread.run.step.failed

当运行步骤失败时发生。

Name 类型 Description Required Default
数据 runStepObject 代表执行跑动中的一步。
Yes
事件 字符串 Yes

Data: runStepObject

Event Enum: RunStepStreamEventFailed

Value Description
thread.run.step.failed

thread.run.step.cancelled

当一个运行步被取消时,就会发生这种情况。

Name 类型 Description Required Default
数据 runStepObject 代表执行跑动中的一步。
Yes
事件 字符串 Yes

Data: runStepObject

事件枚举:RunStepStreamEventCancelled

Value Description
thread.run.step.cancelled

thread.run.step.expired

当一个跑步结束时发生。

Name 类型 Description Required Default
数据 runStepObject 代表执行跑动中的一步。
Yes
事件 字符串 Yes

Data: runStepObject

Event Enum: RunStepStreamEventExpired

Value Description
thread.run.step.expired

messageStreamEvent

该组成部分可以是以下之一:

thread.message.created

当消息被创建时发生。

Name 类型 Description Required Default
数据 messageObject 表示线程中的一条信息。 Yes
事件 字符串 Yes

Data: messageObject

事件枚举:MessageStreamEventCreated

Value Description
thread.message.created

thread.message.in_progress

当消息移动到某个 in_progress 状态时发生。

Name 类型 Description Required Default
数据 messageObject 表示线程中的一条信息。 Yes
事件 字符串 Yes

Data: messageObject

事件枚举:MessageStreamEventInProgress(事件进行中)

Value Description
thread.message.in_progress

thread.message.delta

当消息的部分内容正在被流式传输时,就会发生这种情况。

Name 类型 Description Required Default
数据 messageDeltaObject 表示消息的 delta,即在流式传输过程中消息中的任何字段发生变化。
Yes
事件 字符串 Yes

Data: messageDeltaObject

事件枚举:MessageStreamEventDelta

Value Description
thread.message.delta

thread.message.completed

当消息完成时发生。

Name 类型 Description Required Default
数据 messageObject 表示线程中的一条信息。 Yes
事件 字符串 Yes

Data: messageObject

事件枚举:MessageStreamEventCompleted(事件流事件已完成)

Value Description
thread.message.completed

thread.message.incomplete

当消息在完成前结束时发生。

Name 类型 Description Required Default
数据 messageObject 表示线程中的一条信息。 Yes
事件 字符串 Yes

Data: messageObject

事件枚举:MessageStreamEventIncomplete(事件不完整)

Value Description
thread.message.incomplete

Annotation

该组成部分可以是以下之一:

Click

点击动作。

Name 类型 Description Required Default
button 枚举 显示点击时按下的鼠标按钮。 其中一个 leftrightwheelbackforward或 。

可能的值:leftrightwheelbackforward
Yes
类型 枚举 指定事件类型。 对于点击动作,该属性总是设置为 click

可能的数值: click
Yes
x 整数 咔嗒发生的X坐标。
Yes
y 整数 点击发生的y坐标。
Yes

CodeInterpreterFileOutput

代码解释器工具调用的输出是一个文件。

Name 类型 Description Required Default
files 数组 Yes
类型 枚举 代码解释器文件输出的类型。 总是。files

可能的数值: files
Yes

CodeInterpreterTextOutput

代码解释器工具调用的输出是文本。

Name 类型 Description Required Default
日志 字符串 代码解释器工具调用的日志。
Yes
类型 枚举 代码解释器文本输出的类型。 总是。logs

可能的数值: logs
Yes

CodeInterpreterTool

一个运行代码的工具。

Name 类型 Description Required Default
file_ids 数组 用来运行代码的文件ID。
Yes
类型 枚举 代码解释器工具的类型。 总是。code_interpreter

可能的数值: code_interpreter
Yes

CodeInterpreterToolCall

一个工具调用来运行代码。

Name 类型 Description Required Default
代码 字符串 运行代码。
Yes
id 字符串 代码解释器工具调用的唯一ID。
Yes
results 数组 代码解释器工具调用的结果。
Yes
状态 枚举 代码解释器工具调用的状态。

可能的值: in_progressinterpretingcompleted
Yes
类型 枚举 代码解释器工具调用的类型。 总是。code_interpreter_call

可能的数值: code_interpreter_call
Yes

CodeInterpreterToolOutput

该组成部分可以是以下之一:

ComparisonFilter

一种用于通过定义的比较操作将指定属性键与给定值进行比较的过滤器。

Name 类型 Description Required Default
关键值 字符串 关键是与价值进行比较。 Yes
类型 枚举 指定比较算符:eq, , negtgtelt, , lte
- eq:相等
- ne:不等于
- gt:大于
- gte:大于或等
- lt:少于
- lte:小于或等

可能的值:eqnegtgteltlte
Yes
value 字符串、数字或布尔值 与属性键比较的值;支持字符串类型、数字类型或布尔类型。 Yes

CompoundFilter

使用 andor组合多个滤波器。

Name 类型 Description Required Default
filters 数组 需要组合多种滤波器。 项可以是 ComparisonFilterCompoundFilter Yes
类型 枚举 操作类型: andor
可能的值: andor
Yes

ComputerAction

该组成部分可以是以下之一:

ComputerScreenshotImage

这是电脑使用工具时使用的电脑截图图像。

Name 类型 Description Required Default
file_id 字符串 包含截图的上传文件的标识符。 No
image_url 字符串 截图图片的网址。 No
类型 枚举 指定事件类型。 对于计算机截图,该属性总是设置为 computer_screenshot

可能的数值: computer_screenshot
Yes

ComputerTool

一个控制虚拟计算机的工具。

Name 类型 Description Required Default
display_height number 电脑显示屏的高度。
Yes
display_width number 电脑显示屏的宽度。
Yes
环境 枚举 需要控制的计算机环境类型。

可能的值: macwindowsubuntubrowser
Yes
类型 枚举 计算机使用工具的类型。 总是。computer_use_preview

可能的数值: computer-use-preview
Yes

ComputerToolCall

工具调用电脑使用工具。

Name 类型 Description Required Default
操作 ComputerAction Yes
call_id 字符串 响应工具调用输出时使用的标识符。
Yes
id 字符串 电脑通话的唯一ID。 Yes
pending_safety_checks 数组 电脑通话的待定安全检查。
Yes
状态 枚举 物品的状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
Yes
类型 枚举 电脑通话的类型。 总是。computer_call
可能的数值: computer_call
Yes

ComputerToolCallOutput

计算机工具调用的输出。

Name 类型 Description Required Default
acknowledged_safety_checks 数组 API报告的安全检查已被开发者认可。
No
call_id 字符串 产生输出的计算机工具调用的ID。
Yes
id 字符串 计算机工具调用输出的ID。
No
输出 ComputerScreenshotImage 这是电脑使用工具时使用的电脑截图图像。
Yes
状态 枚举 消息输入状态。 其中in_progress一个、或completedincomplete。 当输入项通过API返回时填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 计算机工具调用输出的类型。 总是。computer_call_output

可能的数值: computer_call_output
Yes

ComputerToolCallOutputResource

Name 类型 Description Required Default
acknowledged_safety_checks 数组 API报告的安全检查已被开发者认可。
No
call_id 字符串 产生输出的计算机工具调用的ID。
Yes
id 字符串 计算机调用工具输出的唯一ID。
Yes
输出 ComputerScreenshotImage 这是电脑使用工具时使用的电脑截图图像。
Yes
状态 枚举 消息输入状态。 其中in_progress一个、或completedincomplete。 当输入项通过API返回时填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 计算机工具调用输出的类型。 总是。computer_call_output

可能的数值: computer_call_output
Yes

ComputerToolCallSafetyCheck

电脑通话的安全检查正在进行中。

Name 类型 Description Required Default
代码 字符串 待进行的安全检查类型。 Yes
id 字符串 待进行的安全检查身份证。 Yes
消息 字符串 关于即将进行的安全检查详情。 Yes

Content

多模态输入和输出内容。

该组成部分可以是以下之一:

Coordinate

x/y 坐标对,例如 { x: 100, y: 200 }

Name 类型 Description Required Default
x 整数 The x-coordinate.
Yes
y 整数 The y-coordinate.
Yes

CreateModelResponseProperties

Name 类型 Description Required Default
元数据 Metadata 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。

键是最大长度为64个字符的字符串。 值是最大长度为512字符的字符串。
No
模型 字符串 用于生成回答的模型。 No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,可以帮助OpenAI监控和检测滥用行为。 .
No

createResponse

Name 类型 Description Required Default
include 数组 {"$ref": "#/components/schemas/includable/description"} No
输入 字符串或数组 用于生成响应的文本、图片或文件输入模型。 Yes
instructions 字符串 在模型上下文中插入系统(或开发者)消息作为首项。

当使用与 previous_response_id时,之前的响应指令不会被传递到下一个响应。 这使得在新回复中替换系统(或开发者)消息变得简单。
No
max_output_tokens 整数 一个为响应生成的代币数量的上限,包括可见的输出代币和推理代币。
No
parallel_tool_calls boolean 是否允许模型并行运行工具调用。
No True
previous_response_id 字符串 之前对模型的回复的唯一ID。 利用这一点来创造多回合的对话。 No
reasoning Reasoning 推理模型的配置选项。 No
存储 boolean 是否存储生成的模型响应以便通过API稍后检索。
No True
数据流 boolean 如果设置为 true,模型响应数据将在通过 服务器发送事件生成时流式传输到客户端。 No False
文本消息 对象 模型文本响应的配置选项。 可以是纯文本,也可以是结构化的JSON数据。 Learn more:
- 文本输入和输出
- 结构化输出
No
└─ format TextResponseFormatConfiguration 一个对象,指定模型必须输出的格式。

配置 { "type": "json_schema" } 可以启用结构化输出,确保模型与你提供的JSON模式匹配。 默认格式没有 { "type": "text" } 额外选项。

不推荐用于GPT-4o及更新型号:

设置启用 { "type": "json_object" } 旧的JSON模式,确保模型生成的消息是有效的JSON。 支持它的模型更倾向于使用 json_schema
No
tool_choice 工具选择选项(ToolChoiceOptions)、工具选择类型(ToolChoiceTypes)或工具选择函数(ToolChoiceFunction 模型在生成响应时应选择使用哪种工具。 请参见参数 tools ,了解如何指定模型可以调用哪些工具。
No
tools 数组 模型在生成响应时可能调用的一系列工具。 你可以通过设置 tool_choice 参数来指定使用哪个工具。

你可以为模型提供两类工具:

- 内置工具
No
truncation 枚举 用于模型响应的截断策略。
- auto:如果该响应及之前响应的上下文大于模型的上下文窗口大小,模型将截断
通过在对话中途插入输入项来适应上下文窗口。
- disabled (默认):如果模型响应超过模型的上下文窗口大小,请求将以400错误失败。

可能的值: autodisabled
No

DoubleClick

双击操作。

Name 类型 Description Required Default
类型 枚举 指定事件类型。 对于双击操作,该属性总是设置为 double_click

可能的数值: double_click
Yes
x 整数 双击发生的X坐标。
Yes
y 整数 双击发生的Y坐标。
Yes

Drag

拖拽动作。

Name 类型 Description Required Default
路径 数组 一组坐标表示阻力作用路径。 坐标会以一组对象的形式出现,例如[{ x: 100, y: 200 }, { x: 200, y: 300 }] Yes
类型 枚举 指定事件类型。 对于拖曳作用,该性质总是设置为 drag

可能的数值: drag
Yes

EasyInputMessage

一个带有指令、指示层级的消息输入。 与 developer or system 角色一起给出的指令优先于与 user role 一起给出的指令。 带有该 assistant 角色的消息被假定为模型在之前的交互中生成的。

Name 类型 Description Required Default
内容 string 或 InputMessageContentList 文本、图像或音频输入到模型,用于生成响应。
也可以包含之前的助理回复。
Yes
角色 枚举 消息输入的作用。 其中 user一个、 assistant、、 systemdeveloper

可能的值: userassistantsystemdeveloper
Yes
类型 枚举 消息输入的类型。 总是。message

可能的数值: message
No

FileCitation

一份文件引用。

Name 类型 Description Required Default
file_id 字符串 文件的ID。
Yes
索引 整数 文件列表中的索引。
Yes
类型 枚举 文件引用的类型。 总是。file_citation

可能的数值: file_citation
Yes

FilePath

一条通往文件的路径。

Name 类型 Description Required Default
file_id 字符串 文件的ID。
Yes
索引 整数 文件列表中的索引。
Yes
类型 枚举 文件路径的类型。 总是。file_path

可能的数值: file_path
Yes

FileSearchRanker

用于文件搜索的排名器。 如果没特别说明,我会用 auto 排名器。

Property Value
Description 用于文件搜索的排名器。 如果没特别说明,我会用 auto 排名器。
Type 字符串
Values auto
default_2024_08_21

FileSearchTool

一个可以从上传文件中搜索相关内容的工具。

Name 类型 Description Required Default
filters 比较滤波器复合滤波器 基于文件属性应用过滤器。 No
max_num_results 整数 最多可返回的结果数。 这个数字应在1到50之间(含)。
No
ranking_options 对象 搜索排名选项。 No
└─ ranker 枚举 用于文件搜索的排名器。
可能的值: autodefault-2024-11-15
No
└─ score_threshold number 文件搜索的分数阈值,介于0到1之间。
接近1的数字会尝试只返回最相关的结果,但可能返回较少的结果。
No 0
类型 枚举 文件搜索工具的类型。 总是。file_search

可能的数值: file_search
Yes
vector_store_ids 数组 向量存储的ID用于搜索。
Yes

FileSearchToolCall

文件搜索工具调用的结果。

Name 类型 Description Required Default
id 字符串 文件搜索工具的唯一ID调用。
Yes
queries 数组 用于搜索文件的查询。
Yes
results 数组 文件搜索工具的结果调用。
No
状态 枚举 文件搜索工具调用状态。 其中 in_progress一个, searchingincompletefailed

可能的值:in_progresssearchingcompletedincompletefailed
Yes
类型 枚举 文件搜索工具调用的类型。 总是。file_search_call

可能的数值: file_search_call
Yes

FunctionTool

在你自己的代码中定义了一个函数,模型可以选择调用。

Name 类型 Description Required Default
description 字符串 功能描述。 模型用它来决定是否调用该函数。
No
name 字符串 调用函数的名称。
Yes
parameters 对象 一个描述函数参数的JSON模式对象。
Yes
strict boolean 是否强制执行严格参数验证。 默认。true
Yes
类型 枚举 函数工具的类型。 总是。function

可能的数值: function
Yes

FunctionToolCall

一个工具调用来运行函数。

Name 类型 Description Required Default
arguments 字符串 一个用来传递给函数的参数的JSON字符串。
Yes
call_id 字符串 模型生成的函数工具调用的唯一ID。
Yes
id 字符串 函数工具调用的唯一ID。
Yes
name 字符串 要运行的函数名称。
Yes
状态 枚举 物品的状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 函数工具调用的类型。 总是。function_call

可能的数值: function_call
Yes

FunctionToolCallOutput

函数工具调用的输出。

Name 类型 Description Required Default
call_id 字符串 模型生成的函数工具调用的唯一ID。
Yes
id 字符串 函数工具的唯一ID调用输出。 当该项目通过API返回时填充。
No
输出 字符串 函数工具调用输出的 JSON 字符串。
Yes
状态 枚举 物品的状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 函数工具调用输出的类型。 总是。function_call_output

可能的数值: function_call_output
Yes

FunctionToolCallOutputResource

Name 类型 Description Required Default
call_id 字符串 模型生成的函数工具调用的唯一ID。
Yes
id 字符串 函数调用工具输出的唯一ID。
Yes
输出 字符串 函数工具调用输出的 JSON 字符串。
Yes
状态 枚举 物品的状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 函数工具调用输出的类型。 总是。function_call_output

可能的数值: function_call_output
Yes

includable

指定更多输出数据以纳入模型响应。 目前支持的数值有:

  • file_search_call.results:包含文件搜索工具调用的搜索结果。
  • message.input_image.image_url:包含输入消息中的图片网址。
  • computer_call_output.output.image_url:包含来自计算机调用输出的图像URL。
Property Value
Description 指定更多输出数据以纳入模型响应。 目前支持的数值有:
- file_search_call.results:包含文件搜索工具调用的搜索结果。
- message.input_image.image_url:包含输入消息中的图片网址。
- computer_call_output.output.image_url:包含来自计算机调用输出的图像URL。
Type 字符串
Values file_search_call.results
message.input_image.image_url
computer_call_output.output.image_url

InputAudio

给模型输入音频。

Name 类型 Description Required Default
数据 字符串 Base64编码的音频数据。
Yes
format 枚举 音频数据的格式。 目前支持的格式有 mp3wav

可能的值: mp3wav
Yes
类型 枚举 输入项的类型。 总是。input_audio

可能的数值: input_audio
Yes

InputContent

该组成部分可以是以下之一:

InputFile

模型的文件输入。

Name 类型 Description Required Default
file_data 字符串 要发送给模型的文件内容。
No
file_id 字符串 要发送给模型的文件ID。
No
filename 字符串 要发送给模型的文件名称。
No
类型 枚举 输入项的类型。 总是。input_file

可能的数值: input_file
Yes

InputImage

模型中的图像输入。

Name 类型 Description Required Default
detail 枚举 要发送给模型的图像细节级别。 其中high一个、或lowauto。 默认为 auto

可能的值: highlowauto
Yes
file_id 字符串 要发送给模型的文件ID。
No
image_url 字符串 要发送给模型的图片网址。 在数据URL中使用完全限定的URL或base64编码的图像。
No
类型 枚举 输入项的类型。 总是。input_image

可能的数值: input_image
Yes

InputItem

该组成部分可以是以下之一:

InputMessage

一个带有指令、指示层级的消息输入。 与 developer or system 角色一起给出的指令优先于与 user role 一起给出的指令。

Name 类型 Description Required Default
内容 InputMessageContentList 包含一个或多个输入项目的模型列表,包含不同内容
types.
Yes
角色 枚举 消息输入的作用。 其中user一个、或systemdeveloper

可能的值: usersystemdeveloper
Yes
状态 枚举 物品状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 消息输入的类型。 总是设置为 message

可能的数值: message
No

InputMessageContentList

包含一个或多个输入项目的模型列表,包含不同内容类型。

该组件没有定义属性。

InputMessageResource

Name 类型 Description Required Default
内容 InputMessageContentList 包含一个或多个输入项目的模型列表,包含不同内容
types.
Yes
id 字符串 消息输入的唯一ID。
Yes
角色 枚举 消息输入的作用。 其中user一个、或systemdeveloper

可能的值: usersystemdeveloper
Yes
状态 枚举 物品状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 消息输入的类型。 总是设置为 message

可能的数值: message
No

InputText

向模型输入文本。

Name 类型 Description Required Default
文本消息 字符串 文本输入到模型。
Yes
类型 枚举 输入项的类型。 总是。input_text

可能的数值: input_text
Yes

Item

用于生成回复的内容。

该组成部分可以是以下之一:

ItemReference

一个用于引用的项目的内部标识符。

Name 类型 Description Required Default
id 字符串 要参考的物品编号。
Yes
类型 枚举 要参考的物品类型。 总是。item_reference

可能的数值: item_reference
Yes

ItemResource

用于生成回复的内容。

该组成部分可以是以下之一:

KeyPress

模型想要执行的一组按键。

Name 类型 Description Required Default
keys 数组 模型请求按下的按键组合。 这是一个字符串数组,每个字符串代表一个键。
Yes
类型 枚举 指定事件类型。 对于按键操作,该属性总是设置为 keypress

可能的数值: keypress
Yes

Metadata

可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。

键是最大长度为64个字符的字符串。 值是最大长度为512字符的字符串。

该组件没有定义属性。

ModelResponseProperties

Name 类型 Description Required Default
元数据 Metadata 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。

键是最大长度为64个字符的字符串。 值是最大长度为512字符的字符串。
No
模型 字符串 用于生成回答的模型。 No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
我们通常建议修改这一点,但 top_p 不要两者兼做。
No 1
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
No 1
用户 字符串 一个代表终端用户的唯一标识符,可以帮助OpenAI监控和检测滥用行为。 .
No

Move

鼠标移动动作。

Name 类型 Description Required Default
类型 枚举 指定事件类型。 对于移动动作,该属性总是设置为 move

可能的数值: move
Yes
x 整数 移动到的x坐标。
Yes
y 整数 要移动的Y坐标。
Yes

OutputAudio

模型的音频输出。

Name 类型 Description Required Default
数据 字符串 模型中的Base64编码音频数据。
Yes
脚本 字符串 模型音频数据的转录。
Yes
类型 枚举 输出音频的类型。 总是。output_audio

可能的数值: output_audio
Yes

OutputContent

该组成部分可以是以下之一:

OutputItem

Name 类型 Description Required Default
操作 ComputerAction Yes
arguments 字符串 一个用来传递给函数的参数的JSON字符串。
Yes
call_id 字符串 响应工具调用输出时使用的标识符。
Yes
内容 数组 推理文本内容。
Yes
id 字符串 推理内容的唯一标识符。
Yes
name 字符串 要运行的函数名称。
Yes
pending_safety_checks 数组 电脑通话的待定安全检查。
Yes
queries 数组 用于搜索文件的查询。
Yes
results 数组 文件搜索工具的结果调用。
No
角色 枚举 输出消息的作用。 总是。assistant

可能的数值: assistant
Yes
状态 枚举 物品的状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
Yes
类型 枚举 物体的类型。 总是。reasoning

可能的数值: reasoning
Yes

OutputMessage

模型的输出消息。

Name 类型 Description Required Default
内容 数组 输出消息的内容。
Yes
id 字符串 输出消息的唯一ID。
Yes
角色 枚举 输出消息的作用。 总是。assistant

可能的数值: assistant
Yes
状态 枚举 消息输入状态。 其中in_progress一个、或completedincomplete。 当输入项通过API返回时填充。

可能的值: in_progresscompletedincomplete
Yes
类型 枚举 输出消息的类型。 总是。message

可能的数值: message
Yes

OutputText

模型输出的文本。

Name 类型 Description Required Default
annotations 数组 文本输出的注释。
Yes
文本消息 字符串 模型输出的文本。
Yes
类型 枚举 输出文本的类型。 总是。output_text

可能的数值: output_text
Yes

RealtimeSessionCreateRequest

实时会话对象配置。

Name 类型 Description Required Default
input_audio_format 枚举 输入音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
对于 pcm16,输入音频必须是16位PCM,采样率为24kHz,单声道(单声道),字节序为小端。

可能的值: pcm16g711_ulawg711_alaw
No
input_audio_noise_reduction 对象 输入音频降噪配置。 可以设置为 null 关闭。
降噪滤波器会在音频添加到输入音频缓冲区前,先将其发送到VAD和模型。
过滤音频可以提高VAD和转向检测的准确性(减少误报),并通过改善输入音频的感知来提升模型性能。
No
└─ type 枚举 降噪类型。 near_field 是用于近距离通话麦克风(如耳机 far_field ),是用于远场麦克风(如笔记本电脑或会议室麦克风)。

可能的值: near_fieldfar_field
No
input_audio_transcription 对象 输入音频转录的配置默认为关闭,开启后可设置为 null 关闭。 输入音频转录并非模型本身,因为模型直接接收音频。 转录通过转 录端 点异步运行,应视为输入音频内容的指导,而非模型听到的具体内容。 客户可以选择设置转录的语言和提示,这些为转录服务提供了额外的指导。
No
└─ language 字符串 输入音频的语言。 以 ISO-639-1 (例如 en)格式提供输入语言可以提高准确性和延迟。
No
└─ model 字符串 用于转录的模型,目前的选项有 gpt-4o-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1
No
└─ prompt 字符串 可选文本,用于指导模型风格或延续之前的音频片段。
对于 whisper-1,提示词是关键词列表。
对于 gpt-4o-transcribe 模型,提示词是自由文本字符串,例如“expect words with technology”(期待与技术相关的词)。
No
instructions 字符串 默认系统指令(即系统消息)会在模型调用之前添加。 该字段允许客户引导模型制定期望的响应。 模型可以指导回答内容和格式(例如“极简明快”、“表现友好”、“这里有良好回应的例子”)以及音频行为(例如“快速说话”、“在声音中注入情感”、“频繁笑”)。 这些指令不保证模型一定遵循,但它们为模型提供了期望行为的指导。

注意服务器设置默认指令,如果该字段未设置,会在会话开始时的事件中可见 session.created
No
max_response_output_tokens 整数或字符串 单个助手响应的最大输出令牌数,包括工具调用。 提供介于1到4096之间的整数以限制输出令牌数,或 inf 表示给定模型的最大可用令牌数。 默认为 inf
No
modalities 模型能够回应的一组模态。 要禁用音频,请设置为[“text”]。
No
模型 字符串 本次会话使用的部署名称。
No
output_audio_format 枚举 输出音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
对于 pcm16,输出音频以24kHz的采样率进行采样。

可能的值: pcm16g711_ulawg711_alaw
No
temperature number 模型采样温度,限制在[0.6, 1.2]。 对于音频型号,强烈建议温度为0.8以获得最佳性能。
No 0.8
tool_choice 字符串 模型如何选择工具。 选项为 autononerequired或 指定函数。
No auto
tools 数组 模型可用的工具(功能)。 No
turn_detection 对象 回合检测配置,服务器VAD或语义VAD。 可以设置为 null 关闭,此时客户端必须手动触发模型响应。
服务器VAD意味着模型会根据音频音量检测语音的开始和结束,并在用户语音结束时作出响应。
语义VAD更为先进,使用转弯检测模型(结合VAD)语义估计用户是否已说完话,然后基于该概率动态设置超时。 例如,如果用户音频在 uhhm中渐渐消失,模型会得分较低的转折概率,并等待用户继续说话的时间更长。 这对更自然的对话很有用,但可能延迟较高。
No
└─ create_response boolean 当VAD停止事件发生时,是否会自动生成响应。
No True
└─ eagerness 枚举 仅用于 semantic_vad 模式。 模型的急切反应。 low 会等待更长时间让用户继续说话,并且 high 会更快回应。 auto 是默认值,等价于 medium

可能的值: lowmediumhighauto
No
└─ interrupt_response boolean 当VAD启动事件发生时,是否自动中断任何正在进行的响应并输出到默认对话(即 conversationauto)。
No True
└─ prefix_padding_ms 整数 仅用于 server_vad 模式。 VAD检测语音前需要包含的音频量(以毫秒计)。 默认为300毫秒。
No
└─ silence_duration_ms 整数 仅用于 server_vad 模式。 用来检测语音停止的静默持续时间(以毫秒计)。 默认为500毫秒。 值越短,模型响应越快,但可能会在用户短暂停顿时介入。
No
└─ threshold number 仅用于 server_vad 模式。 VAD的激活阈值(0.0到1.0),默认是0.5。 更高的阈值需要更响亮的声音来激活模型,因此在嘈杂环境中表现可能更好。
No
└─ type 枚举 转向检测类型。

可能的值: server_vadsemantic_vad
No
voice VoiceIdsShared No

RealtimeSessionCreateResponse

一种新的实时会话配置,带有临时密钥。 键盘默认TTL是1分钟。

Name 类型 Description Required Default
client_secret 对象 API返回的临时密钥。 Yes
└─ expires_at 整数 标记代币到期的时间戳。 目前,所有代币在一分钟后失效。
No
└─ value 字符串 在客户端环境中用于认证与实时API连接的临时密钥。 在客户端环境中使用它,而不是标准的 API 令牌,后者应仅在服务器端使用。
No
input_audio_format 字符串 输入音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
No
input_audio_transcription 对象 输入音频转录的配置默认为关闭,开启后可设置为 null 关闭。 输入音频转录并非模型本身,因为模型直接接收音频。 转录通过 Whisper 异步运行,应被视为粗略指导,而非模型理解的表示。
No
└─ model 字符串 用于转录的模型是 whisper-1 目前唯一被支持的模型。
No
instructions 字符串 默认系统指令(即系统消息)会在模型调用之前添加。 该字段允许客户引导模型制定期望的响应。 模型可以指导回答内容和格式(例如“极简明扼要”、“表现友好”、“这里有好回答的例子”)以及音频行为(例如“说话快”、“声音中注入情感”、“经常笑”)。 这些指令不保证模型一定遵循,但它们为模型提供了期望行为的指导。
注意服务器设置默认指令,如果该字段未设置,会在会话开始时的事件中可见 session.created
No
max_response_output_tokens 整数或字符串 单个助手响应的最大输出令牌数,包括工具调用。 提供介于1到4096之间的整数以限制输出令牌数,或 inf 表示给定模型的最大可用令牌数。 默认为 inf
No
modalities 模型能够回应的一组模态。 要禁用音频,请设置为[“text”]。
No
output_audio_format 字符串 输出音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
No
temperature number 模型采样温度,限制在[0.6, 1.2]。 默认为0.8。
No
tool_choice 字符串 模型如何选择工具。 选项为 autononerequired或 指定函数。
No
tools 数组 模型可用的工具(功能)。 No
turn_detection 对象 转向检测配置。 可以设置为 null 关闭。 服务器VAD意味着模型会根据音频音量检测语音的开始和结束,并在用户语音结束时作出响应。
No
└─ prefix_padding_ms 整数 VAD检测语音前需要包含的音频量(以毫秒计)。 默认为300毫秒。
No
└─ silence_duration_ms 整数 用来检测语音停止的静默持续时间(以毫秒计)。 默认为500毫秒。 值越短,模型响应越快,但可能会在用户短暂停顿时介入。
No
└─ threshold number VAD的激活阈值(0.0到1.0),默认是0.5。 更高的阈值需要更响亮的声音来激活模型,因此在嘈杂环境中表现可能更好。
No
└─ type 字符串 目前仅 server_vad 支持这种类型的转弯检测。
No
voice VoiceIdsShared No

RealtimeTranscriptionSessionCreateRequest

实时转录会话对象配置。

Name 类型 Description Required Default
include 数组 转录中应包含的项目集合。 目前可用的物品有:
- item.input_audio_transcription.logprobs
No
input_audio_format 枚举 输入音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
对于 pcm16,输入音频必须是16位PCM,采样率为24kHz,单声道(单声道),字节序为小端。

可能的值: pcm16g711_ulawg711_alaw
No
input_audio_noise_reduction 对象 输入音频降噪配置。 可以设置为 null 关闭。
降噪滤波器会在音频添加到输入音频缓冲区前,先将其发送到VAD和模型。
过滤音频可以提高VAD和转向检测的准确性(减少误报),并通过改善输入音频的感知来提升模型性能。
No
└─ type 枚举 降噪类型。 near_field 是用于近距离通话麦克风(如耳机 far_field ),是用于远场麦克风(如笔记本电脑或会议室麦克风)。

可能的值: near_fieldfar_field
No
input_audio_transcription 对象 输入音频转录配置。 客户可以选择设置转录的语言和提示,这些为转录服务提供了额外的指导。
No
└─ language 字符串 输入音频的语言。 以 ISO-639-1 (例如 en)格式提供输入语言可以提高准确性和延迟。
No
└─ model 枚举 用于转录的模型,目前的选项有 gpt-4o-transcribegpt-4o-transcribe-diarizegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1、 和 。

可能的值:gpt-4o-transcribegpt-4o-transcribe-diarizegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1
No
└─ prompt 字符串 可选文本,用于指导模型风格或延续之前的音频片段。
对于 whisper-1,提示词是关键词列表。
对于 gpt-4o-transcribe 模型,提示词是自由文本字符串,例如“expect words with technology”(期待与技术相关的词)。
No
modalities 模型能够回应的一组模态。 要禁用音频,请设置为[“text”]。
No
turn_detection 对象 回合检测配置,服务器VAD或语义VAD。 可以设置为 null 关闭,此时客户端必须手动触发模型响应。
服务器VAD意味着模型会根据音频音量检测语音的开始和结束,并在用户语音结束时作出响应。
语义VAD更为先进,使用转弯检测模型(结合VAD)语义估计用户是否已说完话,然后基于该概率动态设置超时。 例如,如果用户音频在 uhhm中渐渐消失,模型会得分较低的转折概率,并等待用户继续说话的时间更长。 这对更自然的对话很有用,但可能延迟较高。
No
└─ create_response boolean 当VAD停止事件发生时,是否会自动生成响应。 不提供转录环节。
No True
└─ eagerness 枚举 仅用于 semantic_vad 模式。 模型的急切反应。 low 会等待更长时间让用户继续说话,并且 high 会更快回应。 auto 是默认值,等价于 medium

可能的值: lowmediumhighauto
No
└─ interrupt_response boolean 当VAD启动事件发生时,是否自动中断任何正在进行的响应并输出到默认对话(即 conversationauto)。 不提供转录环节。
No True
└─ prefix_padding_ms 整数 仅用于 server_vad 模式。 VAD检测语音前需要包含的音频量(以毫秒计)。 默认为300毫秒。
No
└─ silence_duration_ms 整数 仅用于 server_vad 模式。 用来检测语音停止的静默持续时间(以毫秒计)。 默认为500毫秒。 值越短,模型响应越快,但可能会在用户短暂停顿时介入。
No
└─ threshold number 仅用于 server_vad 模式。 VAD的激活阈值(0.0到1.0),默认是0.5。 更高的阈值需要更响亮的声音来激活模型,因此在嘈杂环境中表现可能更好。
No
└─ type 枚举 转向检测类型。

可能的值: server_vadsemantic_vad
No

RealtimeTranscriptionSessionCreateResponse

一种新的实时转录会话配置。

当通过REST API在服务器上创建会话时,会话对象还包含一个临时密钥。 键盘默认TTL是1分钟。 通过 WebSocket API 更新会话时,该属性不存在。

Name 类型 Description Required Default
client_secret 对象 API返回的临时密钥。 只有在服务器上通过REST API创建会话时才会显示。
Yes
└─ expires_at 整数 标记代币到期的时间戳。 目前,所有代币在一分钟后失效。
No
└─ value 字符串 在客户端环境中用于认证与实时API连接的临时密钥。 在客户端环境中使用它,而不是标准的 API 令牌,后者应仅在服务器端使用。
No
input_audio_format 字符串 输入音频的格式。 选项为 pcm16g711_ulaw、 或 g711_alaw
No
input_audio_transcription 对象 转录模型的配置。
No
└─ language 字符串 输入音频的语言。 以 ISO-639-1 (例如 en)格式提供输入语言可以提高准确性和延迟。
No
└─ model 枚举 用于转录的模型。 可以是 gpt-4o-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1

可能的值: gpt-4o-transcribegpt-4o-mini-transcribegpt-4o-mini-transcribe-2025-12-15whisper-1
No
└─ prompt 字符串 可选文本,用于指导模型风格或延续之前的音频片段。 提示应与音频语言相匹配。
No
modalities 模型能够回应的一组模态。 要禁用音频,请设置为[“text”]。
No
turn_detection 对象 转向检测配置。 可以设置为 null 关闭。 服务器VAD意味着模型会根据音频音量检测语音的开始和结束,并在用户语音结束时作出响应。
No
└─ prefix_padding_ms 整数 VAD检测语音前需要包含的音频量(以毫秒计)。 默认为300毫秒。
No
└─ silence_duration_ms 整数 用来检测语音停止的静默持续时间(以毫秒计)。 默认为500毫秒。 值越短,模型响应越快,但可能会在用户短暂停顿时介入。
No
└─ threshold number VAD的激活阈值(0.0到1.0),默认是0.5。 更高的阈值需要更响亮的声音来激活模型,因此在嘈杂环境中表现可能更好。
No
└─ type 字符串 目前仅 server_vad 支持这种类型的转弯检测。
No

Reasoning

推理模型的配置选项。

Name 类型 Description Required Default
工作量 ReasoningEffort 限制推理模型的推理工作。
目前支持的值有 lowmediumhigh。 减少推理努力可以加快响应速度,减少回应中用于推理的标记。
Yes
摘要 枚举 模型执行的推理总结。 这对于调试和理解模型的推理过程非常有用。
concisedetailed

可能的值: concisedetailed
No

ReasoningItem

描述推理模型在生成反应时所使用的思维链。

Name 类型 Description Required Default
内容 数组 推理文本内容。
Yes
id 字符串 推理内容的唯一标识符。
Yes
状态 枚举 物品的状态。 其中in_progress一个、或completedincomplete。 当通过API返回物品时会被填充。

可能的值: in_progresscompletedincomplete
No
类型 枚举 物体的类型。 总是。reasoning

可能的数值: reasoning
Yes

Refusal

模特拒绝了。

Name 类型 Description Required Default
refusal 字符串 模型中的拒绝解释。
Yes
类型 枚举 拒绝的类型。 总是。refusal

可能的数值: refusal
Yes

response

Name 类型 Description Required Default
created_at number Unix 时间戳(以秒计)表示该响应的创建时间。
Yes
错误 ResponseError 当模型未能生成响应时,返回一个错误对象。
Yes
id 字符串 此回应的唯一标识符。
Yes
incomplete_details 对象 关于为什么回复不完整。
Yes
└─ reason 枚举 回答不完整的原因。
可能的值: max_output_tokenscontent_filter
No
instructions 字符串 在模型上下文中插入系统(或开发者)消息作为首项。

当使用与 previous_response_id时,之前的响应指令不会被传递到下一个响应。 这使得在新回复中替换系统(或开发者)消息变得简单。
Yes
max_output_tokens 整数 这是响应中可生成的令牌数量的上限,包括可见的输出令牌和对话状态。
No
元数据 Metadata 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。

键是最大长度为64个字符的字符串。 值是最大长度为512字符的字符串。
Yes
模型 字符串 用于生成回答的模型。 Yes
对象 枚举 该资源的对象类型——始终设置为 response

可能的数值: response
Yes
输出 数组 模型生成的一系列内容。

- 数组中 output 项的长度和顺序取决于模型的响应。
- 与其访问数组中的 output 第一个项目并假设它是包含模型生成内容的 assistant 消息,不如考虑在SDK支持的情况下使用该 output_text 属性。
Yes
output_text 字符串 仅限SDK的便利性质,包含数组中所有 output_text 项目 output 的聚合文本输出(如果存在的话)。
支持在 Python 和 JavaScript SDK 中。
No
parallel_tool_calls boolean 是否允许模型并行运行工具调用。
Yes True
previous_response_id 字符串 之前对模型的回复的唯一ID。 利用这一点来创造多回合的对话。 No
reasoning Reasoning 推理模型的配置选项。
No
状态 枚举 响应生成的状态。 其中 completed一个、 failed、、 in_progressincomplete

可能的值: completedfailedin_progressincomplete
No
temperature number 采样温度应该在0到2之间。 像0.8这样的高值会让输出更随机,而像0.2这样的低值则会让输出更聚焦和确定性强。
我们通常建议修改这一点,但 top_p 不要两者兼做。
Yes 1
文本消息 对象 模型文本响应的配置选项。 可以是纯文本,也可以是结构化的JSON数据。 Learn more:
- 文本输入和输出
- 结构化输出
No
└─ format TextResponseFormatConfiguration 一个对象,指定模型必须输出的格式。

配置 { "type": "json_schema" } 可以启用结构化输出,确保模型与你提供的JSON模式匹配。 默认格式没有 { "type": "text" } 额外选项。

不推荐用于GPT-4o及更新型号:

设置启用 { "type": "json_object" } 旧的JSON模式,确保模型生成的消息是有效的JSON。 支持它的模型更倾向于使用 json_schema
No
tool_choice 工具选择选项(ToolChoiceOptions)、工具选择类型(ToolChoiceTypes)或工具选择函数(ToolChoiceFunction 模型在生成响应时应选择使用哪种工具。 请参见参数 tools ,了解如何指定模型可以调用哪些工具。
Yes
tools 数组 模型在生成响应时可能调用的一系列工具。 你可以通过设置 tool_choice 参数来指定使用哪个工具。

你可以为模型提供两类工具:

- 内置工具
Yes
top_p number 一种与温度抽样不同的替代方案,称为核抽样,模型考虑以top_p概率质量计算的符号结果。 因此,0.1 意味着只考虑构成前10个概率质量的代币%。

我们通常建议修改这一点,但 temperature 不要两者兼做。
Yes 1
truncation 枚举 用于模型响应的截断策略。
- auto:如果该回答和之前的上下文超过模型的上下文窗口大小,模型会通过在对话中间丢弃输入项来截断回答以适应上下文窗口。
- disabled (默认):如果模型响应超过模型的上下文窗口大小,请求将以400错误失败。

可能的值: autodisabled
No
使用情况 ResponseUsage 表示代币使用细节,包括输入代币、输出代币、输出代币的分解以及总代币使用量。
No
用户 字符串 一个代表终端用户的唯一标识符,可以帮助OpenAI监控和检测滥用行为。 .
No

ResponseAudioDeltaEvent

当有部分音频响应时会发出。

Name 类型 Description Required Default
delta 字符串 一块 Base64 编码的响应音频字节。
Yes
类型 枚举 活动的类型。 总是。response.audio.delta

可能的数值: response.audio.delta
Yes

ResponseAudioDoneEvent

当音频响应完成时发出。

Name 类型 Description Required Default
类型 枚举 活动的类型。 总是。response.audio.done

可能的数值: response.audio.done
Yes

ResponseAudioTranscriptDeltaEvent

当有部分音频转录时会发出。

Name 类型 Description Required Default
delta 字符串 音频回复的部分文字记录。
Yes
类型 枚举 活动的类型。 总是。response.audio.transcript.delta

可能的数值: response.audio.transcript.delta
Yes

ResponseAudioTranscriptDoneEvent

完整音频记录完成后发布。

Name 类型 Description Required Default
类型 枚举 活动的类型。 总是。response.audio.transcript.done

可能的数值: response.audio.transcript.done
Yes

ResponseCodeInterpreterCallCodeDeltaEvent

当代码解释器添加部分代码片段时会发出。

Name 类型 Description Required Default
delta 字符串 代码解释器添加的部分代码片段。
Yes
output_index 整数 代码解释器调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.code_interpreter_call.code.delta

可能的数值: response.code_interpreter_call.code.delta
Yes

ResponseCodeInterpreterCallCodeDoneEvent

当代码片段输出被代码解释器最终确定时发出。

Name 类型 Description Required Default
代码 字符串 代码解释器输出的最终代码片段。
Yes
output_index 整数 代码解释器调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.code_interpreter_call.code.done

可能的数值: response.code_interpreter_call.code.done
Yes

ResponseCodeInterpreterCallCompletedEvent

当代码解释器调用完成时发出。

Name 类型 Description Required Default
code_interpreter_call CodeInterpreterToolCall 一个工具调用来运行代码。
Yes
output_index 整数 代码解释器调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.code_interpreter_call.completed

可能的数值: response.code_interpreter_call.completed
Yes

ResponseCodeInterpreterCallInProgressEvent

当代码解释器调用正在进行时发出。

Name 类型 Description Required Default
code_interpreter_call CodeInterpreterToolCall 一个工具调用来运行代码。
Yes
output_index 整数 代码解释器调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.code_interpreter_call.in_progress

可能的数值: response.code_interpreter_call.in_progress
Yes

ResponseCodeInterpreterCallInterpretingEvent

当代码解释器正在主动解释代码片段时会发出。

Name 类型 Description Required Default
code_interpreter_call CodeInterpreterToolCall 一个工具调用来运行代码。
Yes
output_index 整数 代码解释器调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.code_interpreter_call.interpreting

可能的数值: response.code_interpreter_call.interpreting
Yes

ResponseCompletedEvent

当模型响应完成时发射。

Name 类型 Description Required Default
response response Yes
类型 枚举 活动的类型。 总是。response.completed

可能的数值: response.completed
Yes

ResponseContentPartAddedEvent

当新增内容部分时会发出。

Name 类型 Description Required Default
content_index 整数 新增内容部分的索引。
Yes
item_id 字符串 内容部分被添加到输出项的ID。
Yes
output_index 整数 内容部分被添加到输出项的索引。
Yes
部件 OutputContent Yes
类型 枚举 活动的类型。 总是。response.content_part.added

可能的数值: response.content_part.added
Yes

ResponseContentPartDoneEvent

当内容部分完成时会发出。

Name 类型 Description Required Default
content_index 整数 内容部分的索引已经完成。
Yes
item_id 字符串 内容部分被添加到输出项的ID。
Yes
output_index 整数 内容部分被添加到输出项的索引。
Yes
部件 OutputContent Yes
类型 枚举 活动的类型。 总是。response.content_part.done

可能的数值: response.content_part.done
Yes

ResponseCreatedEvent

当响应被创建时,会发出一个事件。

Name 类型 Description Required Default
response response Yes
类型 枚举 活动的类型。 总是。response.created

可能的数值: response.created
Yes

ResponseError

当模型未能生成响应时,返回一个错误对象。

Name 类型 Description Required Default
代码 ResponseErrorCode 响应的错误代码。
Yes
消息 字符串 一个人类易读的错误描述。
Yes

ResponseErrorCode

响应的错误代码。

Property Value
Description 响应的错误代码。
Type 字符串
Values server_error
rate_limit_exceeded
invalid_prompt
vector_store_timeout
invalid_image
invalid_image_format
invalid_base64_image
invalid_image_url
image_too_large
image_too_small
image_parse_error
image_content_policy_violation
invalid_image_mode
image_file_too_large
unsupported_image_media_type
empty_image_file
failed_to_download_image
image_file_not_found

ResponseErrorEvent

发生错误时会发出。

Name 类型 Description Required Default
代码 字符串 错误代码。
Yes
消息 字符串 错误提示。
Yes
param 字符串 误差参数。
Yes
类型 枚举 活动的类型。 总是。error

可能的数值: error
Yes

ResponseFailedEvent

当响应失败时发出的事件。

Name 类型 Description Required Default
response response Yes
类型 枚举 活动的类型。 总是。response.failed

可能的数值: response.failed
Yes

ResponseFileSearchCallCompletedEvent

当文件搜索调用完成(找到结果)时发出。

Name 类型 Description Required Default
item_id 字符串 文件搜索调用的输出项的ID。
Yes
output_index 整数 文件搜索调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.file_search_call.completed

可能的数值: response.file_search_call.completed
Yes

ResponseFileSearchCallInProgressEvent

当文件搜索调用被启动时发出。

Name 类型 Description Required Default
item_id 字符串 文件搜索调用的输出项的ID。
Yes
output_index 整数 文件搜索调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.file_search_call.in_progress

可能的数值: response.file_search_call.in_progress
Yes

ResponseFileSearchCallSearchingEvent

当文件搜索正在进行时发出。

Name 类型 Description Required Default
item_id 字符串 文件搜索调用的输出项的ID。
Yes
output_index 整数 文件搜索调用的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.file_search_call.searching

可能的数值: response.file_search_call.searching
Yes

ResponseFunctionCallArgumentsDeltaEvent

当存在部分函数调用参数 delta 时,会发出。

Name 类型 Description Required Default
delta 字符串 添加的函数调用参数 delta。
Yes
item_id 字符串 函数调用参数 delta 所添加的输出项的 ID。
Yes
output_index 整数 函数调用参数 delta 所加入的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.function_call_arguments.delta

可能的数值: response.function_call_arguments.delta
Yes

ResponseFunctionCallArgumentsDoneEvent

当函数调用参数最终确定时会发出。

Name 类型 Description Required Default
arguments 字符串 函数调用参数。 Yes
item_id 字符串 物品的身份证。 Yes
output_index 整数 输出项的索引。 Yes
类型 枚举
可能的数值: response.function_call_arguments.done
Yes

ResponseInProgressEvent

响应进行时发出。

Name 类型 Description Required Default
response response Yes
类型 枚举 活动的类型。 总是。response.in_progress

可能的数值: response.in_progress
Yes

ResponseIncompleteEvent

当响应结束为未完成时,会发出一个事件。

Name 类型 Description Required Default
response response Yes
类型 枚举 活动的类型。 总是。response.incomplete

可能的数值: response.incomplete
Yes

responseItemList

一份回应项目列表。

Name 类型 Description Required Default
数据 数组 用于生成此回复的项目列表。 Yes
first_id 字符串 列表中第一个项目的ID。 Yes
has_more boolean 是否有更多商品可用。 Yes
last_id 字符串 列表中最后一项的ID。 Yes
对象 枚举 返回的对象类型必须是 list
可能的数值: list
Yes

ResponseModalities

你希望模型生成的输出类型。 大多数模型能够生成文本,这是默认的:

["text"]

gpt-4o-audio-preview 模型也可用于生成音频。 要请求该模型同时生成文本和音频响应,您可以使用:

["text", "audio"]

该组件没有定义属性。

ResponseModalitiesTextOnly

你希望模型生成的输出类型。 大多数模型能够生成文本,这是默认的:

["text"]

该 API 很快将支持其他输出模式,包括音频和图像。

该组件没有定义属性。

ResponseOutputItemAddedEvent

当新增输出项时会发出。

Name 类型 Description Required Default
OutputItem Yes
output_index 整数 新增输出项的索引。
Yes
类型 枚举 活动的类型。 总是。response.output_item.added

可能的数值: response.output_item.added
Yes

ResponseOutputItemDoneEvent

当输出项目标记为完成时发出。

Name 类型 Description Required Default
OutputItem Yes
output_index 整数 标记为完成的输出项的索引。
Yes
类型 枚举 活动的类型。 总是。response.output_item.done

可能的数值: response.output_item.done
Yes

ResponseProperties

Name 类型 Description Required Default
instructions 字符串 在模型上下文中插入系统(或开发者)消息作为首项。

当使用与 previous_response_id时,之前的响应指令不会被传递到下一个响应。 这使得在新回复中替换系统(或开发者)消息变得简单。
No
max_output_tokens 整数 这是响应中可生成的令牌数量的上限,包括可见的输出令牌和对话状态。
No
previous_response_id 字符串 之前对模型的回复的唯一ID。 利用这一点来创造多回合的对话。 No
reasoning Reasoning 推理模型的配置选项。
No
文本消息 对象 模型文本响应的配置选项。 可以是纯文本,也可以是结构化的JSON数据。 Learn more:
- 文本输入和输出
- 结构化输出
No
└─ format TextResponseFormatConfiguration 一个对象,指定模型必须输出的格式。

配置 { "type": "json_schema" } 可以启用结构化输出,确保模型与你提供的JSON模式匹配。 默认格式没有 { "type": "text" } 额外选项。

不推荐用于GPT-4o及更新型号:

设置启用 { "type": "json_object" } 旧的JSON模式,确保模型生成的消息是有效的JSON。 支持它的模型更倾向于使用 json_schema
No
tool_choice 工具选择选项(ToolChoiceOptions)、工具选择类型(ToolChoiceTypes)或工具选择函数(ToolChoiceFunction 模型在生成响应时应选择使用哪种工具。 请参见参数 tools ,了解如何指定模型可以调用哪些工具。
No
tools 数组 模型在生成响应时可能调用的一系列工具。 你可以通过设置 tool_choice 参数来指定使用哪个工具。

你可以为模型提供两类工具:

- 内置工具
No
truncation 枚举 用于模型响应的截断策略。
- auto:如果该回答和之前的上下文超过模型的上下文窗口大小,模型会通过在对话中间丢弃输入项来截断回答以适应上下文窗口。
- disabled (默认):如果模型响应超过模型的上下文窗口大小,请求将以400错误失败。

可能的值: autodisabled
No

ResponseRefusalDeltaEvent

当存在部分拒绝文本时发出。

Name 类型 Description Required Default
content_index 整数 拒绝文本被添加的内容部分的索引。
Yes
delta 字符串 被添加的拒绝文本。
Yes
item_id 字符串 拒绝文本被添加的输出项的ID。
Yes
output_index 整数 拒绝文本被添加的输出项的索引。
Yes
类型 枚举 活动的类型。 总是。response.refusal.delta

可能的数值: response.refusal.delta
Yes

ResponseRefusalDoneEvent

拒绝文本最终确定时发出。

Name 类型 Description Required Default
content_index 整数 内容索引部分的拒绝文本最终确定。
Yes
item_id 字符串 拒绝文本最终确定的输出项目的ID。
Yes
output_index 整数 拒绝文本最终确定的输出项目索引。
Yes
refusal 字符串 拒绝文本最终确定。
Yes
类型 枚举 活动的类型。 总是。response.refusal.done

可能的数值: response.refusal.done
Yes

responseStreamEvent

Name 类型 Description Required Default
注释 Annotation Yes
annotation_index 整数 新增注释的索引。
Yes
arguments 字符串 函数调用参数。 Yes
代码 字符串 错误代码。
Yes
code_interpreter_call CodeInterpreterToolCall 一个工具调用来运行代码。
Yes
content_index 整数 内容索引部分表示文本内容已最终确定。
Yes
delta 字符串 新增的文本差异。
Yes
OutputItem 标记为完成的输出项目。
Yes
item_id 字符串 文本内容最终确定的输出项的ID。
Yes
消息 字符串 错误提示。
Yes
output_index 整数 文本内容最终确定的输出项索引。
Yes
param 字符串 误差参数。
Yes
部件 OutputContent 内容部分已经完成。
Yes
refusal 字符串 拒绝文本最终确定。
Yes
response response 那个不完整的回答。
Yes
文本消息 字符串 文本内容最终确定。
Yes
类型 枚举 活动的类型。 总是。response.output_text.done

可能的数值: response.output_text.done
Yes

ResponseTextAnnotationDeltaEvent

当添加文本注释时会发出。

Name 类型 Description Required Default
注释 Annotation Yes
annotation_index 整数 新增注释的索引。
Yes
content_index 整数 就是添加文本注释的内容部分的索引。
Yes
item_id 字符串 文本注释被添加到输出项的ID。
Yes
output_index 整数 添加文本注释的输出项索引。
Yes
类型 枚举 活动的类型。 总是。response.output_text.annotation.added

可能的数值: response.output_text.annotation.added
Yes

ResponseTextDeltaEvent

当存在额外的文本差异时会发出。

Name 类型 Description Required Default
content_index 整数 就是文本delta被添加到内容部分的索引。
Yes
delta 字符串 新增的文本差异。
Yes
item_id 字符串 文本 delta 被添加到输出项的 ID。
Yes
output_index 整数 即添加文本delta的输出项的索引。
Yes
类型 枚举 活动的类型。 总是。response.output_text.delta

可能的数值: response.output_text.delta
Yes

ResponseTextDoneEvent

文本内容最终确定时会发出。

Name 类型 Description Required Default
content_index 整数 内容索引部分表示文本内容已最终确定。
Yes
item_id 字符串 文本内容最终确定的输出项的ID。
Yes
output_index 整数 文本内容最终确定的输出项索引。
Yes
文本消息 字符串 文本内容最终确定。
Yes
类型 枚举 活动的类型。 总是。response.output_text.done

可能的数值: response.output_text.done
Yes

ResponseUsage

表示代币使用细节,包括输入代币、输出代币、输出代币的分解以及总代币使用量。

Name 类型 Description Required Default
input_tokens 整数 输入标记的数量。 Yes
output_tokens 整数 输出标记的数量。 Yes
output_tokens_details 对象 输出代币的详细分解。 Yes
└─ reasoning_tokens 整数 推理标记的数量。 No
total_tokens 整数 总使用的代币数量。 Yes

Screenshot

截图操作。

Name 类型 Description Required Default
类型 枚举 指定事件类型。 对于截图操作,该属性始终设置为 screenshot

可能的数值: screenshot
Yes

Scroll

一个滚动动作。

Name 类型 Description Required Default
scroll_x 整数 横向卷轴的距离。
Yes
scroll_y 整数 垂直卷轴距离。
Yes
类型 枚举 指定事件类型。 对于滚动动作,该性质始终设置为 scroll

可能的数值: scroll
Yes
x 整数 卷轴发生的X坐标。
Yes
y 整数 卷轴发生的Y坐标。
Yes

StopConfiguration

最多有4个序列,API停止生成更多令牌。 返回的文本不会包含停止音序列。

该组成部分可以是以下之一:

TextResponseFormatConfiguration

一个对象,指定模型必须输出的格式。

配置 { "type": "json_schema" } 可以启用结构化输出,确保模型与你提供的JSON模式匹配。

默认格式没有 { "type": "text" } 额外选项。

不推荐用于GPT-4o及更新型号:

设置启用 { "type": "json_object" } 旧的JSON模式,确保模型生成的消息是有效的JSON。 支持它的模型更倾向于使用 json_schema

该组成部分可以是以下之一:

TextResponseFormatJsonSchema

JSON 模式响应格式。 用于生成结构化JSON响应。 了解更多关于结构化输出的信息。

Name 类型 Description Required Default
description 字符串 对响应格式的描述,模型用以确定该格式的响应方式。
No
name 字符串 回答格式的名称。 必须为 a-z、A-Z、0-9,或包含划线和破折号,长度最多为 64。
No
架构 ResponseFormatJsonSchemaSchema 响应格式的模式,描述为 JSON 模式对象。 Yes
strict boolean 在生成输出时是否启用严格的模式遵循。
如果设置为 true,模型始终遵循字段中 schema 定义的完全模式。 当 stricttrue时,仅支持部分 JSON 模式。
No False
类型 枚举 定义的响应格式类型。 总是。json_schema
可能的数值: json_schema
Yes

Tool

该组成部分可以是以下之一:

ToolChoiceFunction

使用这个选项强制模型调用特定函数。

Name 类型 Description Required Default
name 字符串 调用函数的名称。 Yes
类型 枚举 对于函数调用,类型总是 function
可能的数值: function
Yes

ToolChoiceOptions

控制模型调用的(如果有)工具。

none 这意味着模型不会调用任何工具,而是生成一条消息。

auto 这意味着模型可以选择生成消息或调用一个或多个工具。

required 意味着模型必须调用一个或多个工具。

Property Value
Description 控制模型调用的(如果有)工具。

none 这意味着模型不会调用任何工具,而是生成一条消息。

auto 这意味着模型可以选择生成消息或调用一个或多个工具。

required 意味着模型必须调用一个或多个工具。
Type 字符串
Values none
auto
required

ToolChoiceTypes

表示模型应使用内置工具生成响应。

Name 类型 Description Required Default
类型 枚举 模型应使用的托管工具类型。 允许的值有:
- file_search
- computer_use_preview

可能的值: file_searchcomputer_use_preview
Yes

类型

一个输入文本的动作。

Name 类型 Description Required Default
文本消息 字符串 要打字的文本。
Yes
类型 枚举 指定事件类型。 对于类型动作,该属性总是设置为 type

可能的数值: type
Yes

UpdateVectorStoreFileAttributesRequest

Name 类型 Description Required Default
attributes VectorStoreFileAttributes 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。 键是最大长度为64个字符的字符串。 值是最大长度为512个字符的字符串、布尔数或数字。
Yes

UrlCitation

引用用于生成模型响应的网络资源。

Name 类型 Description Required Default
end_index 整数 邮件中URL引用最后一个字符的索引。
Yes
start_index 整数 消息中URL引用首字母的索引。
Yes
title 字符串 网络资源的标题。
Yes
类型 枚举 引用的URL类型。 总是。url_citation

可能的数值: url_citation
Yes
url 字符串 网络资源的网址。
Yes

VectorStoreFileAttributes

可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。 键是最大长度为64个字符的字符串。 值是最大长度为512个字符的字符串、布尔数或数字。

该组件没有定义属性。

VectorStoreFileContentResponse

表示向量存储文件的解析内容。

Name 类型 Description Required Default
数据 数组 解析文件内容。 Yes
has_more boolean 提示是否有更多内容页可供获取。 Yes
next_page 字符串 如果有的话,下一页的代币。 Yes
对象 枚举 对象类型,总是 vector_store.file_content.page
可能的数值: vector_store.file_content.page
Yes

VectorStoreSearchRequest

Name 类型 Description Required Default
filters 比较滤波器复合滤波器 基于文件属性应用过滤器。 No
max_num_results 整数 最多可返回的结果数。 这个数字应在1到50之间(含)。 No 10
查询 字符串或数组 用于搜索的查询字符串 Yes
ranking_options 对象 搜索排名选项。 No
└─ ranker 枚举 可能的值: autodefault-2024-11-15 No
└─ score_threshold number No 0
rewrite_query boolean 是否重写向量搜索的自然语言查询。 No False

VectorStoreSearchResultContentObject

Name 类型 Description Required Default
文本消息 字符串 文本内容从搜索中返回。 Yes
类型 枚举 内容类型。
可能的数值: text
Yes

VectorStoreSearchResultItem

Name 类型 Description Required Default
attributes VectorStoreFileAttributes 可附加于对象的16对键值对。 这对于以结构化格式存储关于对象的额外信息,以及通过 API 或仪表盘查询对象非常有用。 键是最大长度为64个字符的字符串。 值是最大长度为512个字符的字符串、布尔数或数字。
Yes
内容 数组 文件中的内容块。 Yes
file_id 字符串 向量存储文件的ID。 Yes
filename 字符串 是向量存储文件的名称。 Yes
分数 number 结果的相似度评分。 Yes

VectorStoreSearchResultsPage

Name 类型 Description Required Default
数据 数组 搜索结果项目列表。 Yes
has_more boolean 提示是否还有更多结果需要检索。 Yes
next_page 字符串 如果有的话,下一页的代币。 Yes
对象 枚举 对象类型,总是 vector_store.search_results.page
可能的数值: vector_store.search_results.page
Yes
search_query 数组 Yes

VoiceIdsShared

该组件没有定义属性。

Wait

等待动作。

Name 类型 Description Required Default
类型 枚举 指定事件类型。 对于等待动作,该属性总是设置为 wait

可能的数值: wait
Yes

ReasoningEffort

限制推理模型的推理工作。 目前支持的值有 lowmediumhigh。 减少推理努力可以加快响应速度,减少回应中用于推理的标记。

Property Value
Description 限制推理模型的推理工作。
目前支持的值有 lowmediumhigh。 减少推理努力可以加快响应速度,减少回应中用于推理的标记。
Type 字符串
Default
Values low
medium
high

errorEvent

发生错误时发生。 这可能是由于内部服务器错误或超时造成的。

Name 类型 Description Required Default
数据 error Yes
事件 字符串 Yes

event Enum: ErrorEventEnum

Value Description
错误

doneEvent

当溪流结束时发生。

Name 类型 Description Required Default
数据 字符串 Yes
事件 字符串 Yes

event Enum: DoneEventEnum

Value Description
done

data Enum: DoneEventDataEnum

Value Description
[DONE]

Next steps

学习模型 知识,以及用REST API进行微调。 详细了解支持 OpenAI 的Azure模型