diff --git a/en/java/resources/chat/index.md b/en/java/resources/chat/index.md new file mode 100644 index 0000000..eda8707 --- /dev/null +++ b/en/java/resources/chat/index.md @@ -0,0 +1,6665 @@ +# Chat + +# Completions + +## Create chat completion + +`ChatCompletion chat().completions().create(ChatCompletionCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())` + +**post** `/chat/completions` + +**Starting a new project?** We recommend trying [Responses](https://platform.openai.com/docs/api-reference/responses) +to take advantage of the latest OpenAI platform features. Compare +[Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses). + +--- + +Creates a model response for the given chat conversation. Learn more in the +[text generation](https://platform.openai.com/docs/guides/text-generation), [vision](https://platform.openai.com/docs/guides/vision), +and [audio](https://platform.openai.com/docs/guides/audio) guides. + +Parameter support can differ depending on the model used to generate the +response, particularly for newer reasoning models. Parameters that are only +supported for reasoning models are noted below. For the current state of +unsupported parameters in reasoning models, +[refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning). + +Returns a chat completion object, or a streamed sequence of chat completion +chunk objects if the request is streamed. + +### Parameters + +- `ChatCompletionCreateParams params` + + - `List messages` + + A list of messages comprising the conversation so far. Depending on the + [model](https://platform.openai.com/docs/models) you use, different message types (modalities) are + supported, like [text](https://platform.openai.com/docs/guides/text-generation), + [images](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio). + + - `class ChatCompletionDeveloperMessageParam:` + + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, `developer` messages + replace the previous `system` messages. + + - `Content content` + + The contents of the developer message. + + - `String` + + - `List` + + - `String text` + + The text content. + + - `JsonValue; type "text"constant` + + The type of the content part. + + - `TEXT("text")` + + - `JsonValue; role "developer"constant` + + The role of the messages author, in this case `developer`. + + - `DEVELOPER("developer")` + + - `Optional name` + + An optional name for the participant. Provides the model information to differentiate between participants of the same role. + + - `class ChatCompletionSystemMessageParam:` + + Developer-provided instructions that the model should follow, regardless of + messages sent by the user. With o1 models and newer, use `developer` messages + for this purpose instead. + + - `Content content` + + The contents of the system message. + + - `String` + + - `List` + + - `String text` + + The text content. + + - `JsonValue; type "text"constant` + + The type of the content part. + + - `JsonValue; role "system"constant` + + The role of the messages author, in this case `system`. + + - `SYSTEM("system")` + + - `Optional name` + + An optional name for the participant. Provides the model information to differentiate between participants of the same role. + + - `class ChatCompletionUserMessageParam:` + + Messages sent by an end user, containing prompts or additional context + information. + + - `Content content` + + The contents of the user message. + + - `String` + + - `List` + + - `class ChatCompletionContentPartText:` + + Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation). + + - `String text` + + The text content. + + - `JsonValue; type "text"constant` + + The type of the content part. + + - `class ChatCompletionContentPartImage:` + + Learn about [image inputs](https://platform.openai.com/docs/guides/vision). + + - `ImageUrl imageUrl` + + - `String url` + + Either a URL of the image or the base64 encoded image data. + + - `Optional detail` + + Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding). + + - `AUTO("auto")` + + - `LOW("low")` + + - `HIGH("high")` + + - `JsonValue; type "image_url"constant` + + The type of the content part. + + - `IMAGE_URL("image_url")` + + - `class ChatCompletionContentPartInputAudio:` + + Learn about [audio inputs](https://platform.openai.com/docs/guides/audio). + + - `InputAudio inputAudio` + + - `String data` + + Base64 encoded audio data. + + - `Format format` + + The format of the encoded audio data. Currently supports "wav" and "mp3". + + - `WAV("wav")` + + - `MP3("mp3")` + + - `JsonValue; type "input_audio"constant` + + The type of the content part. Always `input_audio`. + + - `INPUT_AUDIO("input_audio")` + + - `File` + + - `FileObject file` + + - `Optional fileData` + + The base64 encoded file data, used when passing the file to the model + as a string. + + - `Optional fileId` + + The ID of an uploaded file to use as input. + + - `Optional filename` + + The name of the file, used when passing the file to the model as a + string. + + - `JsonValue; type "file"constant` + + The type of the content part. Always `file`. + + - `FILE("file")` + + - `JsonValue; role "user"constant` + + The role of the messages author, in this case `user`. + + - `USER("user")` + + - `Optional name` + + An optional name for the participant. Provides the model information to differentiate between participants of the same role. + + - `class ChatCompletionAssistantMessageParam:` + + Messages sent by the model in response to user messages. + + - `JsonValue; role "assistant"constant` + + The role of the messages author, in this case `assistant`. + + - `ASSISTANT("assistant")` + + - `Optional