使用 Embedding API
Stima API 提供 Embedding API 讓開發者可以將文字轉換為向量,並且可以透過向量搜尋的方式找到相似的文字。
OpenAI Embedding Model 使用方式 (以 Python 為例)
import http.client
import json
conn = http.client.HTTPSConnection("api.stima.tech")
payload = json.dumps({
"model": "text-embedding-3-large",
"input": "The food was delicious and the waiter..."
})
headers = {
'Authorization': 'Bearer <STIMA_API_KEY>',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/embeddings", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))