Skip to content

Add support for custom JSON payload in ChatCompletionContentPart#704

Open
FanYaning wants to merge 1 commit intoopenai:mainfrom
FanYaning:main
Open

Add support for custom JSON payload in ChatCompletionContentPart#704
FanYaning wants to merge 1 commit intoopenai:mainfrom
FanYaning:main

Conversation

@FanYaning
Copy link
Contributor

Fix: #700

        ChatCompletionContentPart textPart = ChatCompletionContentPart.ofText(ChatCompletionContentPartText.builder()
                .text(promptMessage)
                .build());

        String type = visionMessage.startsWith("data:image/") ? "image_url" : "video_url";
        Map<String, JsonValue> part = Map.of(
                "type", JsonValue.from(type),
                type, JsonValue.from(Map.of("url", visionMessage)));

        ChatCompletionContentPart visionPart = ChatCompletionContentPart.ofJson(JsonValue.from(part));

        ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
                .addUserMessageOfArrayOfContentParts(List.of(visionPart, textPart))
                .model(config.getModelV())
                .temperature(config.getTemperatureV())
                .putAllAdditionalBodyProperties(customProps)
                .build();

@FanYaning FanYaning requested a review from a team as a code owner March 17, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

how to upload Video Input with openai-java

1 participant