Перейти к основному содержанию
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

ModelDimensionsDescription
text-embedding-3-large3072High accuracy, recommended for production
text-embedding-3-small1536Cost-effective
text-embedding-ada-0021536Classic model

Request Parameters

model
string
обязательно
Embedding model name, e.g. text-embedding-3-large
input
string | string[]
обязательно
Text to embed. Supports a single string or an array of strings
encoding_format
string
по умолчанию:"float"
Return format: float or base64
dimensions
integer
Output 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.