🤖Reddit r/MachineLearning•較早收集於 44m
OpenAI API 體現 Conway 定律
#conways-law#api-design#developer-quirksopenai-apisopenaigemini
💡OpenAI API 怪癖暴露組織混亂——開發者應讀,了解不一致問題 (28字)
⚡ 30-Second TL;DR
有什麼變化
OpenAI chat/completions 使用 'response_format' 進行 JSON schema
為什麼重要
凸顯快速 AI 公司在 API 不一致造成的開發者摩擦,遷移複雜化並延長入門時間。
下一步行動
測試 OpenAI chat/completions 和 responses API 的結構化 JSON 輸出相容性。
誰應關注:Developers & AI Engineers
關鍵要點
- •OpenAI chat/completions 使用 'response_format' 進行 JSON schema
- •responses API 需使用 'text.format' 結構
- •文件範例有誤,開發者須閱讀 Python 套件原始碼
- •Google Gemini 拒絕某些有效 JSON schema,客戶端庫已修復
🧠 深度解析
背景與延伸:來自公開資料,非原文內容。引用 9 個來源。
🔑 增強重點摘要
- •OpenAI 於 2024 年推出 Responses API,標誌著從 Chat Completions API 的重大架構轉變,結構化輸出參數從 response_format 改為 text.format,反映內部組織對 API 設計的不同願景[5][8]
- •Responses API 中的結構化輸出預設採用嚴格模式(strict: true),而 Chat Completions 中的函數呼叫預設為非嚴格,顯示 OpenAI 在不同 API 版本間對資料驗證策略的演進[5]
- •TGI(Text Generation Inference)與 OpenAI 的 response_format 實現存在根本差異:TGI 使用 regex 和 json_object(需要 value 欄位),而 OpenAI 提供 text、json_object 和 json_schema 三種類型,導致跨平台整合複雜性[1]
📊 競品分析▸ Show
| 功能 | OpenAI Chat Completions | OpenAI Responses API | TGI (Text Generation Inference) |
|---|---|---|---|
| 結構化輸出參數 | response_format | text.format | json、json_object、regex |
| JSON Schema 支援 | json_schema(含嵌套結構) | json_schema(含嵌套結構) | json_object(需 value 欄位) |
| 預設嚴格模式 | 函數呼叫非嚴格 | 函數呼叫嚴格 | 不適用 |
| 拒絕處理 | refusal 欄位 | refusal 欄位 | 不適用 |
| 使用場景 | 聊天完成、函數呼叫 | 結構化輸出、工具使用 | 本地推理、開源模型 |
🛠️ 技術深入
- Responses API 結構化輸出實現:使用 text.format 參數,內含 type(json_object)和 json_schema 物件,json_schema 包含 name、strict 布林值和 schema 定義[2][5]
- Chat Completions response_format 格式:支援三種類型 — text(純文本)、json_object(自由形式 JSON)、json_schema(驗證型 JSON),json_schema 包含嵌套的 json_schema 屬性[1]
- TGI 的 response_format 差異:json 和 json_object 視為相同,均需 value 欄位包含 JSON schema,類似於 grammar 參數的處理方式[1]
- 拒絕處理機制:Responses API 在安全拒絕時返回 refusal 欄位,因為拒絕可能不符合提供的 schema[2]
- 函數呼叫差異:Chat Completions 使用外部標籤多態性,Responses 使用內部標籤;Responses 預設嚴格模式強制遵守 schema[5]
🔮 前景展望AI analysis grounded in cited sources
⏳ 時間線
2023-06
OpenAI 推出 Chat Completions API,採用 response_format 參數進行結構化輸出
2024-09
OpenAI 發布 Responses API 測試版,引入 text.format 參數替代 response_format
2025-02
GitHub issue #3058 提出 TGI 與 OpenAI response_format 的根本差異,促進跨平台相容性討論
2025-03
OpenAI 發布 Responses API 遷移指南,正式文件化 Chat Completions 與 Responses 的 API 差異
📎 來源 (9)
Factual claims are grounded in the sources below. Forward-looking analysis is AI-generated interpretation.
📰
AI 週報
閱讀本週精選 AI 大事摘要 →
👉相關動態
AI 策展新聞聚合。所有內容版權歸原始發布者所有。
原始來源: Reddit r/MachineLearning ↗
每週 AI 簡報
每週一封,可隨時退訂。