图像API接口
Deblur (AI去模糊)
图像清晰度增强和去模糊API接口,使用先进的AI算法对模糊图像进行清晰度增强,能够有效去除运动模糊、失焦模糊等问题,恢复图像细节
📋 基本信息
| 属性 | 值 |
|---|---|
| 接口地址 | POST /v1/chat/completions |
| 模型名称 | deblur |
📝 请求参数
| 路径 | 参数 | 类型 | 必填 | 说明 | 默认 |
|---|---|---|---|---|---|
| - | model | string | ✅ | 模型名称,固定为 deblur | - |
| - | messages | array | ✅ | 消息数组,包含用户输入的文本和图片 | - |
messages[] | role | string | ✅ | 消息角色,固定为 user | - |
messages[] | content | array | ✅ | 内容数组,包含文本和图片元素 | - |
content[] | type | string | ✅ | 内容类型:text 或 image_url | - |
content[] | text | string | ❌ | 当 type 为 text 时的文本内容 | "请对这张图片进行去模糊处理" |
content[] | image_url | object | ❌ | 当 type 为 image_url 时的图片对象 | - |
image_url | url | string | ✅ | 图片的URL地址(当type为image_url时必填) | - |
📝 请求示例
curl https://api.xty.app/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxx" \
-d '{
"model": "deblur",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "请对这张图片进行去模糊处理"},
{
"type": "image_url",
"image_url": {
"url": "https://image.xty.app/mgxm/93f6afac-40db-41f9-a518-e81d09869ebd/10.png"
}
}
]
}
]
}'import requests
import json
url = "https://api.xty.app/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxxxx"
}
data = {
"model": "deblur",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "请对这张图片进行去模糊处理"},
{
"type": "image_url",
"image_url": {
"url": "https://image.xty.app/mgxm/93f6afac-40db-41f9-a518-e81d09869ebd/10.png"
}
}
]
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())from openai import OpenAI
import httpx
client = OpenAI(
base_url="https://api.xty.app/v1",
api_key="sk-xxxxx",
http_client=httpx.Client(
base_url="https://api.xty.app/v1",
follow_redirects=True,
),
)
response = client.chat.completions.create(
model="deblur",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "请对这张图片进行去模糊处理"},
{
"type": "image_url",
"image_url": {
"url": "https://image.xty.app/mgxm/93f6afac-40db-41f9-a518-e81d09869ebd/10.png"
}
}
]
}
]
)
print(response)fetch('https://api.xty.app/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxxx'
},
body: JSON.stringify({
model: "deblur",
messages: [
{
role: "user",
content: [
{type: "text", text: "请对这张图片进行去模糊处理"},
{
type: "image_url",
image_url: {
url: "https://image.xty.app/mgxm/93f6afac-40db-41f9-a518-e81d09869ebd/10.png"
}
}
]
}
]
})
})
.then(response => response.json())
.then(data => console.log(data));📤 响应示例
成功响应
{
"id": "xty-1704067200000",
"object": "chat.completion",
"created": 1704067200,
"model": "deblur",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "https://file.xty.app/docs/deblur.jpg"
}
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}错误响应
{
"error": {
"message": "请求失败",
"type": "invalid_request_error",
"param": null,
"code": null
}
}🖼️ 效果展示
输入示例
输入文字:请对这张图片进行去模糊处理
输入图片:

输出结果
输出图片:

⚠️ 注意事项
- 图片要求:源图片必须包含清晰可识别的图像内容
- 图片格式:支持通过URL和base64提供的图片,格式包括 JPEG、PNG、WebP 等
- 处理时间:根据图片复杂度,处理时间在10-20秒之间
- 模糊程度:极度模糊的图片可能无法完全恢复
- 文本内容:messages 中的文本内容用于指导生成,默认为 "请对这张图片进行去模糊处理"
- URL有效期:返回的图像URL地址有效期为1个小时,请及时保存或下载