本文介绍在java
中如何使用Azure OpenAI
中的DALL·E 3
如果你想看官方的版本,请点击下面的这个链接适用于 Java 的 Azure OpenAI 客户端库 | Microsoft Learn
但是根据他的示例代码我并没有调用成功,如果哪位朋友成功了也可以分享一下。
本文将介绍使用okhttp
的方式调用
调用示例代码
@Value("${dall-e-3.azure-openai-key}")
private String apiKey;
@Value("${dall-e-3.endpoint}")
private String endpoint;
@Value("${dall-e-3.deployment-or-model-id}")
private String modelId;
@Value("${dall-e-3.version}")
private String version;
/**
* @param questionDto 问题参数
* prompt 提示词
* size 尺寸 默认为1024x1024
* n 生成图片数量 默认为1
* quality 选项有“高清hd”和“标准standard”;默认为标准
* style 选项有“自然natural”和“生动vivid”;默认为生动
* @return {@link String}
*/
public String generateImage(QuestionDto questionDto) {
try {
String url = endpoint + "/openai/deployments/" + mo