org.devlive.sdk.openai.utils.MultipartBodyUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openai-java-sdk Show documentation
Show all versions of openai-java-sdk Show documentation
Provides an easy-to-use SDK for Java developers to interact with the APIs of open AI models.
package org.devlive.sdk.openai.utils;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import java.io.File;
public class MultipartBodyUtils
{
public static final MediaType TYPE = MediaType.parse("multipart/form-data");
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private MultipartBodyUtils()
{
}
public static MultipartBody.Part getPart(File image, String name)
{
RequestBody body = RequestBody.create(TYPE, image);
return MultipartBody.Part.createFormData(name, image.getName(), body);
}
}