Create Embeddings
curl --request POST \
--url https://api.mor.org/api/v1/embeddings \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"model": "<string>",
"encoding_format": "<string>",
"user": "<string>"
}
'import requests
url = "https://api.mor.org/api/v1/embeddings"
payload = {
"input": "<string>",
"model": "<string>",
"encoding_format": "<string>",
"user": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: '<string>',
model: '<string>',
encoding_format: '<string>',
user: '<string>'
})
};
fetch('https://api.mor.org/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://api.mor.org/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([
'input' => '<string>',
'model' => '<string>',
'encoding_format' => '<string>',
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.mor.org/api/v1/embeddings"
payload := strings.NewReader("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"encoding_format\": \"<string>\",\n \"user\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.mor.org/api/v1/embeddings")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"encoding_format\": \"<string>\",\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mor.org/api/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"encoding_format\": \"<string>\",\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"object": "<string>",
"data": [
{
"object": "<string>",
"embedding": [
{}
],
"index": 123
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
}
}Embeddings
Create Embeddings
Generate vector embeddings for input text using AI models
POST
/
api
/
v1
/
embeddings
Create Embeddings
curl --request POST \
--url https://api.mor.org/api/v1/embeddings \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"model": "<string>",
"encoding_format": "<string>",
"user": "<string>"
}
'import requests
url = "https://api.mor.org/api/v1/embeddings"
payload = {
"input": "<string>",
"model": "<string>",
"encoding_format": "<string>",
"user": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: '<string>',
model: '<string>',
encoding_format: '<string>',
user: '<string>'
})
};
fetch('https://api.mor.org/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://api.mor.org/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([
'input' => '<string>',
'model' => '<string>',
'encoding_format' => '<string>',
'user' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.mor.org/api/v1/embeddings"
payload := strings.NewReader("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"encoding_format\": \"<string>\",\n \"user\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.mor.org/api/v1/embeddings")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"encoding_format\": \"<string>\",\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mor.org/api/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": \"<string>\",\n \"model\": \"<string>\",\n \"encoding_format\": \"<string>\",\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"object": "<string>",
"data": [
{
"object": "<string>",
"embedding": [
{}
],
"index": 123
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
}
}Create embeddings for the given input text(s).
This endpoint creates vector embeddings, typically for the purpose of “RAG” (Retrieval Augemented Generation) storage. It automatically manages sessions and routes requests to the appropriate embedding model.
Headers
string
required
API key in format:
Bearer sk-xxxxxxBody
string
required
Input text to generate embeddings for. Can be a single string or an array of strings.Single text example:Multiple texts example (batch processing):
"input": "The quick brown fox jumps over the lazy dog"
"input": ["First text", "Second text", "Third text"]
When using the interactive playground, it may show
"input": {} - ignore this and manually edit the generated cURL command to use either a string "text" or array ["text1", "text2"] format.string
required
Model ID to use for embedding generation (blockchain hex address or name)
Use the List Models endpoint to see available embedding models.
string
default:"float"
Format for the embedding vectors. Options:
float or base64string
Unique identifier representing your end-user for monitoring and abuse detection
Response
string
Always returns
"list"array
string
Model used for generating the embeddings
object
Example Request
import openai
client = openai.OpenAI(
api_key="sk-xxxxxx",
base_url="https://api.mor.org/api/v1"
)
response = client.embeddings.create(
model="text-embedding-model",
input="The quick brown fox jumps over the lazy dog"
)
print(response.data[0].embedding)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-xxxxxx',
baseURL: 'https://api.mor.org/api/v1'
});
const response = await client.embeddings.create({
model: 'text-embedding-model',
input: 'The quick brown fox jumps over the lazy dog'
});
console.log(response.data[0].embedding);
curl -X POST https://api.mor.org/api/v1/embeddings \
-H "Authorization: Bearer sk-xxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-model",
"input": "The quick brown fox jumps over the lazy dog"
}'
Use Cases
Semantic Search
Generate embeddings for documents and queries to enable similarity-based search
Clustering
Group similar texts together by comparing embedding vectors
Recommendations
Build recommendation systems by finding similar items based on embeddings
Classification
Use embeddings as features for text classification models
The API is fully compatible with the OpenAI SDK. Simply change the
base_url to point to the Morpheus Gateway.Embedding dimensions vary by model. Ensure your application can handle different vector sizes when switching models.

