Expected Behavior

The response format "json_schema" can be used. ChatCompletionRequest:

{
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "my_schema",
      "schema": {
        "type" : "object",
        "properties" : {
          "myproperty" : {
            "type" : "string"
          },
          ...
        },
        "required": [ ... ],
      },
      "strict": false
    }
  },
  ...
}

Current Behavior

The additional "json_schema" property cannot be set at ResponseFormat.

Context

This should solve the problem that the LLM does not adhere to the JSON schema provided as "free text" in the prompt.

See https://platform.openai.com/docs/guides/structured-outputs/introduction

Comment From: ThomasVitale

@markusheiden thanks for the feature request. @tzolov has implemented support for OpenAI Structured Output in https://github.com/spring-projects/spring-ai/issues/1196 right after the OpenAI announcement. You can find more information on how to use it in this blog post: https://spring.io/blog/2024/08/09/spring-ai-embraces-openais-structured-outputs-enhancing-json-response

Comment From: markusheiden

Sorry for opening an already stale issue. Thanks for already having implemented it :-)