OpenAI Introduces Structured Output, GPT-4o Significantly Reduced in Price

2024-08-07

OpenAI recently launched an innovative API feature called "Structured Output," which aims to ensure that the response of AI models strictly adheres to the JSON schema defined by developers. This update directly addresses the pain point of inconsistent output formats, which often hinder smooth integration with existing systems. By introducing dynamic constraint decoding technology, OpenAI's new feature securely locks the model's output within the predetermined JSON schema framework, ensuring that the generated tokens are both valid and compliant. This technique cleverly transforms the JSON schema into a context-free grammar, enabling the handling of more complex and recursive data structures, representing a qualitative leap compared to previous methods. The Structured Output feature is presented to developers in two flexible ways: 1. Function call method: Developers can set strict schema compliance for the tool, which is fully compatible with GPT-3.5-turbo-0613 and later versions, as well as GPT-4-0613 and later versions of the model. 2. Response format options: The newly added json_schema parameter allows structured responses beyond function calls. The latest GPT-4o model supports this feature, providing developers with more choices. To simplify the development process, OpenAI has also updated the Python and Node SDKs to provide native support for structured output, making it easier for developers using these languages to implement the new feature. In addition, Structured Output incorporates built-in security mechanisms, allowing the model to programmatically detect and handle unsafe requests. When the model rejects such requests, the API response will explicitly include the rejection information, helping developers quickly identify and manage potential security risks. It is worth mentioning that OpenAI has simultaneously released the GPT-4o-2024-08-06 model, which has performed exceptionally well in tests adhering to complex JSON schemas, receiving a perfect score. What's even more exciting is that this model comes with significant price discounts: - Input costs reduced by 50%, with a fee of only $2.50 per million tokens. - Output costs reduced by 33%, with a fee of $10.00 per million tokens. - Overall costs reduced by 50% compared to the previous GPT-4o model. The introduction of Structured Output allows developers to build seamless and robust applications that seamlessly integrate with existing systems. For example, it can play a crucial role in the following scenarios: - Dynamically generating user interfaces based on specific user needs. - Clearly separating the final answer from supporting reasons or comments to enhance response transparency and readability. - Efficiently extracting structured information from unstructured input data, such as automatically organizing to-do items and deadlines from meeting records. Of course, OpenAI also candidly acknowledges some limitations of Structured Output, such as currently supporting only a subset of JSON Schema and potential additional latency due to preprocessing when using the new architecture for the first time (subsequent requests will be faster). This information provides comprehensive references for developers, helping them better evaluate and apply this new feature.