Skip to content

Python: .Net: OpenAI - Support response_format type of json_schema (Structured Outputs) #7946

Closed

Description

@jonnermut

The latest OpenAI models allow passing json_schema as the response_format type property, and supplying the schema itself under the schema property. This enforces conformance to the schema by validating output tokens, rather than best LLM effort.

Announced here: https://openai.com/index/introducing-structured-outputs-in-the-api/

This is obviously massively useful to any application using json output, especially when deserialising the json to C# types.
Please consider adding support for these properties through the SemanticKernel abstractions and .Net client in the short term.

Activity

  1. changed the title [-]Support response_format type of json_schema [/-] [+].Net: Support response_format type of json_schema [/+] on Aug 7, 2024
  2. rogerbarreto commented on Aug 7, 2024

    @rogerbarreto
    Member

    Update with more context.

    Created issue in OpenAI SDK .Net to keep track.

    POST /v1/chat/completions
    {
      "model": "gpt-4o-2024-08-06",
      "messages": [
        {
          "role": "system",
          "content": "You are a helpful math tutor."
        },
        {
          "role": "user",
          "content": "solve 8x + 31 = 2"
        }
      ],
      "response_format": {
        "type": "json_schema",
        "json_schema": {
          "name": "math_response",
          "strict": true,
          "schema": {
            "type": "object",
            "properties": {
              "steps": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "explanation": {
                      "type": "string"
                    },
                    "output": {
                      "type": "string"
                    }
                  },
                  "required": ["explanation", "output"],
                  "additionalProperties": false
                }
              },
              "final_answer": {
                "type": "string"
              }
            },
            "required": ["steps", "final_answer"],
            "additionalProperties": false
          }
        }
      }
    }
  3. changed the title [-].Net: Support response_format type of json_schema [/-] [+].Net: OpenAI - Support response_format type of json_schema [/+] on Aug 7, 2024
  4. changed the title [-].Net: OpenAI - Support response_format type of json_schema [/-] [+]Java: .Net: OpenAI - Support response_format type of json_schema [/+] on Aug 13, 2024
  5. changed the title [-].Net: OpenAI - Support response_format type of json_schema [/-] [+]Python: .Net: OpenAI - Support response_format type of json_schema [/+] on Aug 13, 2024
  6. papa-pep commented on Aug 27, 2024

    @papa-pep

    It looks like OpenAI SDK work has been completed! Looking forward to having this in SK soon!

  7. changed the title [-]Python: .Net: OpenAI - Support response_format type of json_schema [/-] [+]Python: .Net: OpenAI - Support response_format type of json_schema (Structured Outputs)[/+] on Sep 4, 2024
  8. moonbox3 commented on Oct 31, 2024

    @moonbox3
    Collaborator

    This is complete in Python as of #8958.

  9. github-actions commented on Apr 29, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no activity.

  10. added
    staleIssue is stale because it has been open for a while and has no activity
    on Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codeai connectorAnything related to AI connectorsjavaIssue or PR regarding Java codestaleIssue is stale because it has been open for a while and has no activity

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions