import requests
# 基本参数配置
apiUrl = 'http://gpt.juhe.cn/image_edit/edit' # 接口请求URL
apiKey = 'your_api_key' # 在`个人中心-->数据中心-->我的API`中查看,获取当前接口的访问密钥。
# 接口请求入参配置
requestParams = {
'key': apiKey,
'text': '将图片风格转为油画风格。由颜料雕刻的立体油画,流体油画,清晰的雕刻线条,极致的细节',
'image1': 'http://xxx.jpeg', #图像格式支持 JPEG、JPG、PNG、BMP、WEBP,base64数据格式:data:{MIME_type};base64,{base64_data}
'image2': '',
'image3': '', #最多可支持3张图片
'size': '', #若不设置,输出图像保持与原图相似的长宽比
}
# 发起接口网络请求
response = requests.post(apiUrl, requestParams)
# 解析响应结果
if response.status_code == 200:
responseResult = response.json()
# 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
print(responseResult)
else:
# 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
print('请求异常')