Skip to content

Instantly share code, notes, and snippets.

@warrenkc
Created October 24, 2024 08:00
Show Gist options
  • Save warrenkc/50049a04bec9452aecd918895414d1f9 to your computer and use it in GitHub Desktop.
Save warrenkc/50049a04bec9452aecd918895414d1f9 to your computer and use it in GitHub Desktop.
To turn on JSON mode with the Chat Completions or Assistants API you can set the response_format to { "type": "json_object" }.
Dictionary < string, string > responseFormat = new Dictionary < string, string > {
{
"type",
"json_object"
}
};
var payload = new {
model = "gpt-4o-mini",
messages = messages,
max_tokens = 300,
response_format = responseFormat
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment