Skip to content

.Net: ResponseSchema not working with ForJsonSchema in GeminiPromptExecutionSettings #12313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RogerBarreto opened this issue May 29, 2025 · 0 comments
Labels
.NET Issue or Pull requests regarding .NET code triage

Comments

@RogerBarreto
Copy link
Member

Discussed in #12234

Originally posted by VladyslavLishchyna May 22, 2025
Hi community! I try to get response from Gemini as JSON object and use like this

GeminiPromptExecutionSettings executionSettings = new()
{
    FunctionChoiceBehavior = FunctionChoiceBehavior.None(),
    ResponseMimeType = "application/json",
    ResponseSchema = ChatResponseFormat.ForJsonSchema(jsonSchema)
};

And have 400 status code

Exception while start application - Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 400 (Bad Request).
 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()

Schema looks like:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Response",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "FirstProperty": {
      "type": "integer",
      "format": "int32"
    },
    "Summary": {
      "type": "string"
    }
  }
}

If I run without ResponseSchema parameter I receive response successfully

@RogerBarreto RogerBarreto added the .NET Issue or Pull requests regarding .NET code label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code triage
Projects
None yet
Development

No branches or pull requests

2 participants