Skip to main content
POST
/
v1
/
embeddings
Embeddings
curl --request POST \
  --url https://openp.ai/v1/embeddings
import requests

url = "https://openp.ai/v1/embeddings"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://openp.ai/v1/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://openp.ai/v1/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://openp.ai/v1/embeddings"

req, _ := http.NewRequest("POST", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openp.ai/v1/embeddings")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/v1/embeddings")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
Convert text into high-dimensional vectors for semantic retrieval, clustering, recommendation and more.

Request

curl https://openp.ai/v1/embeddings \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": ["hello world", "你好世界"]
  }'

Parameters

FieldTypeRequiredDescription
modelstringEmbedding model ID
inputstring | arrayA single string or an array
encoding_formatstringfloat (default) or base64
dimensionsintegerTruncate to a specified dimension (text-embedding-3-* only)
userstringEnd-user identifier
Model IDDimensionsNotes
text-embedding-3-small1536 (reducible ≥ 512)Default recommendation
text-embedding-3-large3072 (reducible ≥ 256)High quality
text-embedding-ada-0021536Older
text-embedding-004768Google
bge-m31024Multilingual open-source
text-embedding-v31024Tongyi Qianwen

Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.018, ...]
    },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [0.0021, -0.015, ...]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {"prompt_tokens": 5, "total_tokens": 5}
}

Python example

from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://openp.ai/v1")

resp = client.embeddings.create(
    model="text-embedding-3-small",
    input=["hello", "world"],
)
import numpy as np
vecs = np.array([e.embedding for e in resp.data])
# cosine similarity
sim = vecs @ vecs.T / (np.linalg.norm(vecs, axis=1)[:, None] * np.linalg.norm(vecs, axis=1)[None, :])

Dimension truncation

{
  "model": "text-embedding-3-large",
  "input": "hello",
  "dimensions": 256
}
Truncated vectors preserve semantics while using less memory / compute.

Billing

Charged by prompt_tokens only — no output tokens. See Billing.