所有AI工具AI开发框架AI编程工具
Structured Outputs官网 – 确保API输出严格遵循JSON Schema
Structured Outputs 是 OpenAI API 中的一项新功能,主要用于 Chat Completions API 和 Assistants API。它通过 constrained decoding 技术动态约束模型输出,确保输出严格遵循开...
标签:AI开发框架 AI编程工具Assistants API Chat Completions API constrained decoding JSON Schema OpenAI APIAI交流(进群备注:Structured Outputs)

Structured Outputs 是 OpenAI API 中的一项新功能,主要用于 Chat Completions API 和 Assistants API。它通过 constrained decoding 技术动态约束模型输出,确保输出严格遵循开发者提供的 JSON Schema。这一功能特别适用于需要精确数据格式的任务,如数据录入、信息检索和多步骤工作流。
Structured Outputs的特点:
- 1. 确保输出完全匹配 JSON Schema
- 2. 使用 constrained decoding 动态约束输出,仅允许符合 schema 的 token
- 3. 支持通过 Pydantic 在 Python 中定义 schema
- 4. 在 function calling 时,设置 strict: true 可确保输出匹配精确 schema
Structured Outputs的功能:
- 1. 在 API 调用中设置 strict: true 并定义 response format 或 function definitions 来启用
- 2. 使用 response_format 参数指定 JSON schema
- 3. 需要使用如 gpt-4o-2024-08-06 等为 structured outputs 优化的模型
相关导航
暂无评论...