Skip to main content
POST
/
v1
/
vectors
/
query_binary
Query Vectors (Binary)
curl --request POST \
  --url https://api.example.com/v1/vectors/query_binary
Search for nearest neighbors in the encrypted index using binary-encoded query vectors for more efficient transfer of large batch queries.

Authentication

Required - API key via X-API-Key header:
X-API-Key: cyborg_your_api_key_here
You can get an API key from the CyborgDB Admin Dashboard. For more info, follow this guide.

Request Body

{
  "index_name": "my_index",
  "index_key": "64_character_hex_string_representing_32_bytes",
  "batch": {
    "vectors_b64": "BASE64_ENCODED_FLOAT32_ARRAY",
    "dimension": 384
  },
  "top_k": 10,
  "n_probes": 5,
  "greedy": false,
  "rerank_mult": 10,
  "filters": {"category": "research"},
  "include": ["distance", "metadata"]
}

Response

The response format is the same as the standard query endpoint:
{
  "results": [
    [
      {"id": "doc1", "distance": 0.125, "metadata": {"category": "research"}},
      {"id": "doc2", "distance": 0.234, "metadata": {"category": "research"}}
    ],
    [
      {"id": "doc3", "distance": 0.156, "metadata": {"category": "research"}},
      {"id": "doc4", "distance": 0.278, "metadata": {"category": "research"}}
    ]
  ]
}

Exceptions

  • 401: Authentication failed (invalid API key) or wrong index_key on SDK-supplied indexes — see error model
  • 404: Index not found
  • 422: Invalid request parameters or vector dimensions
  • 500: Internal server error

Example Usage

# Encode query vectors as base64 float32 array (example using Python)
# query_vectors = np.array([[0.1, 0.2, 0.3, 0.4]], dtype=np.float32)
# vectors_b64 = base64.b64encode(query_vectors.tobytes()).decode()

curl -X POST "http://localhost:8000/v1/vectors/query_binary" \
     -H "X-API-Key: cyborg_your_api_key_here" \
     -H "Content-Type: application/json" \
     -d '{
       "index_name": "my_index",
       "index_key": "your_64_character_hex_key_here",
       "batch": {
         "vectors_b64": "zczMPc3MTD6amZk+zczMPg==",
         "dimension": 4
       },
       "top_k": 5
     }'
The binary format is more efficient than the standard JSON query for large batch queries, as it avoids the overhead of encoding each float as a JSON number. The SDK clients automatically use this format when query vectors are passed as typed arrays (e.g., np.ndarray in Python, Float32Array in JS/TS).