Baidu ERNIE

Ernie Embedding v1 API

CN Baidu ERNIE | 发布 2023-05
嵌入文档 → 获取API密钥

Ernie Embedding v1 是百度以中文优先的 embedding 模型,生成针对简体中文文本优化的 384 维向量。在短查询为主的场景中,它是中文语义搜索和推荐用例的高性价比默认选择。

嵌入

定价 (官方,每百万token)

输入
$0.04/M
输出
$0.00/M

规格

上下文窗口4.096K token 输入模态文本 流式 APIOpenAI兼容

如何使用Ernie Embedding v1

直接替换OpenAI。只需改base_url和模型。

# Python - pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://meshtok.com/v1",
    api_key="sk-your-MeshTok-key",
)

resp = client.chat.completions.create(
    model="baidu/embedding-v1",
    messages=[{"role":"user","content":"Hello!"}],
)
print(resp.choices[0].message.content)
# cURL
curl https://meshtok.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-MeshTok-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"baidu/embedding-v1","messages":[{"role":"user","content":"Hello!"}]}'

相关模型

你可能考虑的其他模型。