Create Embeddings
curl --request POST \
--url https://api.example.com/v1/embeddings \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": [
"<string>"
],
"encoding_format": "<string>",
"dimensions": 123
}
'import requests
url = "https://api.example.com/v1/embeddings"
payload = {
"model": "<string>",
"input": ["<string>"],
"encoding_format": "<string>",
"dimensions": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
input: ['<string>'],
encoding_format: '<string>',
dimensions: 123
})
};
fetch('https://api.example.com/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://api.example.com/v1/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'input' => [
'<string>'
],
'encoding_format' => '<string>',
'dimensions' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": [\n \"<string>\"\n ],\n \"encoding_format\": \"<string>\",\n \"dimensions\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/embeddings")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": [\n \"<string>\"\n ],\n \"encoding_format\": \"<string>\",\n \"dimensions\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"input\": [\n \"<string>\"\n ],\n \"encoding_format\": \"<string>\",\n \"dimensions\": 123\n}"
response = http.request(request)
puts response.read_bodyEmbeddings и rerank
Create Embeddings
Convert text into vector representations
POST
/
v1
/
embeddings
Create Embeddings
curl --request POST \
--url https://api.example.com/v1/embeddings \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": [
"<string>"
],
"encoding_format": "<string>",
"dimensions": 123
}
'import requests
url = "https://api.example.com/v1/embeddings"
payload = {
"model": "<string>",
"input": ["<string>"],
"encoding_format": "<string>",
"dimensions": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
input: ['<string>'],
encoding_format: '<string>',
dimensions: 123
})
};
fetch('https://api.example.com/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://api.example.com/v1/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'input' => [
'<string>'
],
'encoding_format' => '<string>',
'dimensions' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": [\n \"<string>\"\n ],\n \"encoding_format\": \"<string>\",\n \"dimensions\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/embeddings")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": [\n \"<string>\"\n ],\n \"encoding_format\": \"<string>\",\n \"dimensions\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"input\": [\n \"<string>\"\n ],\n \"encoding_format\": \"<string>\",\n \"dimensions\": 123\n}"
response = http.request(request)
puts response.read_bodyДата обновления: 2026-06-06
Overview
Convert input text into high-dimensional vectors for use in semantic search, clustering, recommendations, and more. Fully compatible with the OpenAI Embeddings API format.Supported Models
| Model | Dimensions | Description |
|---|---|---|
text-embedding-3-large | 3072 | High accuracy, recommended for production |
text-embedding-3-small | 1536 | Cost-effective |
text-embedding-ada-002 | 1536 | Classic model |
Request Parameters
Embedding model name, e.g.
text-embedding-3-largeText to embed. Supports a single string or an array of strings
Return format:
float or base64Output vector dimensions (only supported by
text-embedding-3-* models)Response Format
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023064255, -0.009327292, ...]
}
],
"model": "text-embedding-3-large",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}
Code Examples
from openai import OpenAI
client = OpenAI(
api_key="sk-xxx",
base_url="https://api.crazyrouter.com/v1"
)
response = client.embeddings.create(
model="text-embedding-3-large",
input="Crazyrouter is an AI model gateway"
)
embedding = response.data[0].embedding
print(f"Vector dimensions: {len(embedding)}")
print(f"First 5 values: {embedding[:5]}")
response = client.embeddings.create(
model="text-embedding-3-large",
input=[
"First text",
"Second text",
"Third text"
]
)
for item in response.data:
print(f"Index {item.index}: dimensions {len(item.embedding)}")
curl -X POST https://api.crazyrouter.com/v1/embeddings \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-large",
"input": "Crazyrouter is an AI model gateway"
}'
Batch requests support up to 2048 texts per call. Each text should not exceed 8191 tokens.
⌘I