|
|
@@ -378,9 +378,10 @@ public class MiniPopularizeFrontServiceImpl implements MiniPopularizeFrontServic
|
|
|
if (type == 1) {
|
|
|
//出图数量 1-10 默认4张
|
|
|
JSONObject json = new JSONObject();
|
|
|
- json.putOpt("model", "gpt-image-1");
|
|
|
+ json.putOpt("model", "sora_image");
|
|
|
json.putOpt("n", 4);
|
|
|
json.putOpt("size", "1024x1024");
|
|
|
+ json.putOpt("response_format", "b64_json");
|
|
|
json.putOpt("prompt", tips);
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
String requestBody = mapper.writeValueAsString(json);
|
|
|
@@ -396,8 +397,10 @@ public class MiniPopularizeFrontServiceImpl implements MiniPopularizeFrontServic
|
|
|
// 创建 MultipartBody.Builder 来处理多个文件上传
|
|
|
MultipartBody.Builder builder = new MultipartBody.Builder()
|
|
|
.setType(MultipartBody.FORM)
|
|
|
- .addFormDataPart("model", "gpt-image-1")
|
|
|
+ .addFormDataPart("model", "sora_image")
|
|
|
.addFormDataPart("n", "4")
|
|
|
+ .addFormDataPart("response_format", "b64_json")
|
|
|
+ .addFormDataPart("size", "1024x1024")
|
|
|
.addFormDataPart("prompt", tips);
|
|
|
//垫图
|
|
|
imgs.forEach(mg -> {
|
|
|
@@ -442,6 +445,8 @@ public class MiniPopularizeFrontServiceImpl implements MiniPopularizeFrontServic
|
|
|
for (Object data : jsonObject.getJSONArray("data")) {
|
|
|
JSONObject b64Json = Jsons.parseObject(data, JSONObject.class);
|
|
|
String base64Image = b64Json.getStr("b64_json");
|
|
|
+ //去掉前缀
|
|
|
+ base64Image = base64Image.split(",")[1];
|
|
|
// 解码 Base64 字符串
|
|
|
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
|
|
String fileName = new StringBuilder().append("mgpt").append(RandomUtil.randomString(9)).append(".png").toString();
|