Retrieval
Cosine similarity of vectors API
Returns cosine similarity, distance, and angle between two embedding vectors plus a similarity interpretation. Answers 'How similar are these two embeddings?', 'What is the cosine distance between vector a and b?'.
Price$0.01per request
MethodPOST
Route/v1/retrieval/cosine-similarity
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
cosinesimilarityembeddingvectorretrievalsemanticdistancerag
API URL
Integration docshttps://x402.hexl.dev/v1/retrieval/cosine-similarityExample request
{
"a": [
0.2,
0.5,
0.8
],
"b": [
0.1,
0.6,
0.7
]
}Example response
{
"cosineSimilarity": 0.98399292,
"cosineDistance": 0.01600708,
"angleDegrees": 10.2654,
"dimensions": 3,
"interpretation": "near-duplicate",
"formula": "cos = dot(a,b) / (|a|*|b|)"
}Input schema
{
"type": "object",
"required": [
"a",
"b"
],
"properties": {
"a": {
"type": "array",
"items": {
"type": "number"
},
"description": "first vector"
},
"b": {
"type": "array",
"items": {
"type": "number"
},
"description": "second vector"
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}