Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/openai/resources/chat/mod.ts>ChatCompletionCreateParams.ResponseFormat

Deno build of the official Typescript library for the OpenAI API.
Extremely Popular
Go to Latest
interface ChatCompletionCreateParams.ResponseFormat
import { type ChatCompletionCreateParams } from "https://deno.land/x/openai@v4.24.3/resources/chat/mod.ts";
const { ResponseFormat } = ChatCompletionCreateParams;

An object specifying the format that the model must output. Compatible with gpt-4-1106-preview and gpt-3.5-turbo-1106.

Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.

Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.

Properties

optional
type: "text" | "json_object"

Must be one of text or json_object.