3

微调模型 API 参考

鉴权、Python 示例与常见误用

接口文档:模型部署 API id=1865。 本站在线验证器由服务端转发请求,凭据不会保存;页面不会生成包含密钥的 curl 命令。

text
POST https://api-ai.vivo.com.cn/sft/chat/completions
Authorization: Bearer sk-xuanji-{app_id}-{base64.b64encode(app_key).decode()}
Content-Type: application/json
python
import base64
import requests

APP_ID = "your_app_id"
APP_KEY = "your_app_key"   # 原文,勿预先 Base64
URL = "https://api-ai.vivo.com.cn/sft/chat/completions"

def get_auth_headers():
    b64 = base64.b64encode(APP_KEY.encode("utf-8")).decode()
    return {
        "Authorization": f"Bearer sk-xuanji-{APP_ID}-{b64}",
        "Content-Type": "application/json",
    }

payload = {
    "messages": [{"role": "user", "contentType": "text", "content": "请解释什么是 LoRA"}],
    "temperature": 0.1,
    "max_tokens": 512,
}
resp = requests.post(URL, json=payload, headers=get_auth_headers(), timeout=120)
print(resp.json()["choices"][0]["message"]["content"])
⚠️

常见误用:对 APP_KEY 重复 Base64;使用模块一 AppKey;使用平台打码截断的 KEY。