LogoAICore Docs
图像API接口

Face-to-many (人像照片风格化)

将人像照片转换为多种艺术风格的API接口,可以将普通人像照片转换为多种艺术风格,包括3D渲染、表情符号、像素艺术等多种创意效果

📋 基本信息

属性
接口地址POST /v1/chat/completions
模型名称face-to-many

📝 请求参数

路径参数类型必填说明默认
-modelstring模型名称,固定为 face-to-many-
-messagesarray消息数组,包含用户输入的文本和图片-
-extra_bodyobject额外参数对象{}
messages[]rolestring消息角色,固定为 user-
messages[]contentarray内容数组,包含文本和图片元素-
content[]typestring内容类型:textimage_url-
content[]textstring当 type 为 text 时的文本内容"a person"
content[]image_urlobject当 type 为 image_url 时的图片对象-
image_urlurlstring图片的URL地址(当type为image_url时必填)-
extra_bodystylestring风格选择,见下方支持的风格"3D"
extra_bodynegative_promptstring不想出现在图片中的元素描述""

🎨 支持的风格

style 可选值:

  • 3D: 3D渲染效果
  • Emoji: 表情符号风格
  • Video game: 电子游戏角色风格
  • Pixels: 像素艺术风格
  • Clay: 粘土动画风格
  • Toy: 玩具模型风格

📝 请求示例

curl https://api.xty.app/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxx" \
  -d '{
    "model": "face-to-many",
    "extra_body": {
      "style": "Clay",
      "negative_prompt": ""
    },
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "a person"},
          {
            "type": "image_url",
            "image_url": {
              "url": "https://file.xty.app/docs/msk.jpg"
            }
          }
        ]
      }
    ]
  }'
import requests
import json

url = "https://api.xty.app/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk-xxxxx"
}
data = {
    "model": "face-to-many",
    "extra_body": {
        "style": "Clay",
        "negative_prompt": ""
    },
    "messages": [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "a person"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://file.xty.app/docs/msk.jpg"
                    }
                }
            ]
        }
    ]
}

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="face-to-many",
    extra_body={
      "extra_body":{
          "style":"Clay",
          "negative_prompt":""
       },
   },
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "a person"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://file.xty.app/docs/msk.jpg"
                    }
                }
            ]
        }
    ]
)

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: "face-to-many",
    extra_body: {
      style: "3D",
      negative_prompt: ""
    },
    messages: [
      {
        role: "user",
        content: [
          {type: "text", text: "a person"},
          {
            type: "image_url",
            image_url: {
              url: "https://file.xty.app/docs/msk.jpg"
            }
          }
        ]
      }
    ]
  })
})
.then(response => response.json())
.then(data => console.log(data));

📤 响应示例

成功响应

{
  "id": "xty-1704067200000",
  "object": "chat.completion",
  "created": 1704067200,
  "model": "face-to-many",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "https://file.xty.app/docs/msk-3d.png"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}

错误响应

{
  "error": {
    "message": "不支持的样式:InvalidStyle,允许的样式为:[3D, Emoji, Video game, Pixels, Clay, Toy]",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

🖼️ 效果展示

输入示例

输入文字:a person

输入图片输入图片 - 人像照片

风格参数:3d(3D渲染效果)

输出结果

输出图片输出图片 - 3D渲染效果人像

⚠️ 注意事项

  1. 图片要求:源图片必须包含清晰可识别的人脸
  2. 图片格式:支持通过URL和base64提供的图片,格式包括 JPEG、PNG、WebP 等
  3. 处理时间:根据图片复杂度,处理时间在5-15秒之间
  4. 风格限制:style 参数必须是支持的6种风格之一,否则会返回错误
  5. 文本内容:messages 中的文本内容用于指导生成,默认为 "a person"
  6. URL有效期:返回的图像URL地址有效期为1个小时,请及时保存或下载

🔗 相关链接