按标价估算,启用缓存后通常更便宜。
https://api.xah.io/v1/embeddings
curl 'https://api.xah.io/v1/embeddings' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}'
// Node.js / Browser
const res = await fetch('https://api.xah.io/v1/embeddings', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
})
});
const data = await res.json();
console.log(data);
import requests
url = 'https://api.xah.io/v1/embeddings'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
}
payload = {
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}
res = requests.post(url, headers=headers, json=payload, timeout=120)
print(res.status_code, res.json())
{
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}