Skip to main content
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>",
  "dimensions": 123,
  "user": "<string>"
}'
{
  "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

Authorization
string
required
API key in format: Bearer sk-xxxxxx

Body

input
string
required
Input text to generate embeddings for. Can be a single string or an array of strings.Single text example:
"input": "The quick brown fox jumps over the lazy dog"
Multiple texts example (batch processing):
"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.
model
string
required
Model ID to use for embedding generation (blockchain hex address or name)
Use the List Models endpoint to see available embedding models.
encoding_format
string
default:"float"
Format for the embedding vectors. Options: float or base64
dimensions
integer
Number of dimensions for the output embeddings. Only supported by certain models.
user
string
Unique identifier representing your end-user for monitoring and abuse detection

Response

object
string
Always returns "list"
data
array
Array of embedding objects
model
string
Model used for generating the embeddings
usage
object
Token usage statistics

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)

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.