curl --request POST \
--url https://openrouter.ai/api/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"dimensions": 1536,
"input": "The quick brown fox jumps over the lazy dog",
"model": "openai/text-embedding-3-small"
}
'import requests
url = "https://openrouter.ai/api/v1/embeddings"
payload = {
"dimensions": 1536,
"input": "The quick brown fox jumps over the lazy dog",
"model": "openai/text-embedding-3-small"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
dimensions: 1536,
input: 'The quick brown fox jumps over the lazy dog',
model: 'openai/text-embedding-3-small'
})
};
fetch('https://openrouter.ai/api/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://openrouter.ai/api/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([
'dimensions' => 1536,
'input' => 'The quick brown fox jumps over the lazy dog',
'model' => 'openai/text-embedding-3-small'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://openrouter.ai/api/v1/embeddings"
payload := strings.NewReader("{\n \"dimensions\": 1536,\n \"input\": \"The quick brown fox jumps over the lazy dog\",\n \"model\": \"openai/text-embedding-3-small\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://openrouter.ai/api/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"dimensions\": 1536,\n \"input\": \"The quick brown fox jumps over the lazy dog\",\n \"model\": \"openai/text-embedding-3-small\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://openrouter.ai/api/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"dimensions\": 1536,\n \"input\": \"The quick brown fox jumps over the lazy dog\",\n \"model\": \"openai/text-embedding-3-small\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"embedding": [
0.0023064255,
-0.009327292,
0.015797347
],
"index": 0,
"object": "embedding"
}
],
"model": "openai/text-embedding-3-small",
"object": "list",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}{
"error": {
"code": 400,
"message": "Invalid request parameters"
}
}{
"error": {
"code": 401,
"message": "Missing Authentication header"
}
}{
"error": {
"code": 402,
"message": "Insufficient credits. Add more using https://openrouter.ai/credits"
}
}{
"error": {
"code": 404,
"message": "Resource not found"
}
}{
"error": {
"code": 429,
"message": "Rate limit exceeded"
}
}{
"error": {
"code": 500,
"message": "Internal Server Error"
}
}{
"error": {
"code": 502,
"message": "Provider returned error"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable"
}
}{
"error": {
"code": 524,
"message": "Request timed out. Please try again later."
}
}{
"error": {
"code": 529,
"message": "Provider returned error"
}
}Submit an embedding request
Submits an embedding request to the embeddings router
curl --request POST \
--url https://openrouter.ai/api/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"dimensions": 1536,
"input": "The quick brown fox jumps over the lazy dog",
"model": "openai/text-embedding-3-small"
}
'import requests
url = "https://openrouter.ai/api/v1/embeddings"
payload = {
"dimensions": 1536,
"input": "The quick brown fox jumps over the lazy dog",
"model": "openai/text-embedding-3-small"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
dimensions: 1536,
input: 'The quick brown fox jumps over the lazy dog',
model: 'openai/text-embedding-3-small'
})
};
fetch('https://openrouter.ai/api/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://openrouter.ai/api/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([
'dimensions' => 1536,
'input' => 'The quick brown fox jumps over the lazy dog',
'model' => 'openai/text-embedding-3-small'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://openrouter.ai/api/v1/embeddings"
payload := strings.NewReader("{\n \"dimensions\": 1536,\n \"input\": \"The quick brown fox jumps over the lazy dog\",\n \"model\": \"openai/text-embedding-3-small\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://openrouter.ai/api/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"dimensions\": 1536,\n \"input\": \"The quick brown fox jumps over the lazy dog\",\n \"model\": \"openai/text-embedding-3-small\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://openrouter.ai/api/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"dimensions\": 1536,\n \"input\": \"The quick brown fox jumps over the lazy dog\",\n \"model\": \"openai/text-embedding-3-small\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"embedding": [
0.0023064255,
-0.009327292,
0.015797347
],
"index": 0,
"object": "embedding"
}
],
"model": "openai/text-embedding-3-small",
"object": "list",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}{
"error": {
"code": 400,
"message": "Invalid request parameters"
}
}{
"error": {
"code": 401,
"message": "Missing Authentication header"
}
}{
"error": {
"code": 402,
"message": "Insufficient credits. Add more using https://openrouter.ai/credits"
}
}{
"error": {
"code": 404,
"message": "Resource not found"
}
}{
"error": {
"code": 429,
"message": "Rate limit exceeded"
}
}{
"error": {
"code": 500,
"message": "Internal Server Error"
}
}{
"error": {
"code": 502,
"message": "Provider returned error"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable"
}
}{
"error": {
"code": 524,
"message": "Request timed out. Please try again later."
}
}{
"error": {
"code": 529,
"message": "Provider returned error"
}
}Authorizations
API key as bearer token in Authorization header
Body
Embeddings request input
Text, token, or multimodal input(s) to embed
"The quick brown fox jumps over the lazy dog"
The model to use for embeddings
"openai/text-embedding-3-small"
The number of dimensions for the output embeddings
x >= 11536
The format of the output embeddings
float, base64 "float"
The type of input (e.g. search_query, search_document)
"search_query"
Provider routing preferences for the request.
Show child attributes
Show child attributes
{ "allow_fallbacks": true }
A unique identifier for the end-user
"user-1234"
Response
Embedding response
Embeddings response containing embedding vectors
List of embedding objects
Show child attributes
Show child attributes
[ { "embedding": [0.0023064255, -0.009327292, 0.015797347], "index": 0, "object": "embedding" } ]
The model used for embeddings
"openai/text-embedding-3-small"
list Unique identifier for the embeddings response
"embd-1234567890"
Token usage statistics
Show child attributes
Show child attributes
{ "prompt_tokens": 8, "total_tokens": 8 }