OpenAI 現在可以輸出定義的 JSON 了

OpenAI 在「Introducing Structured Outputs in the API」這邊提到目前的 JSON mode 不能保證 schema 的正確性:

While JSON mode improves model reliability for generating valid JSON outputs, it does not guarantee that the model’s response will conform to a particular schema.

而現在新的 model 可以了:

Today we’re introducing Structured Outputs in the API, a new feature designed to ensure model-generated outputs will exactly match JSON Schemas provided by developers.

新的 model 代碼是 gpt-4o-2024-08-06 這組,而且又降價了:

By switching to the new gpt-4o-2024-08-06, developers save 50% on inputs ($2.50/1M input tokens) and 33% on outputs ($10.00/1M output tokens) compared to gpt-4o-2024-05-13.

這個功能可以解掉不少 workaround...

Leave a Reply

Your email address will not be published. Required fields are marked *