OriginChainDB
Vector

Store one embedding

← Vector examples

The language tabs use earlier client interfaces. Check SDK versions and connection setup before running them.

An embedding is a list of numbers that represents an item for similarity search. Give it the source record’s ID so results can be matched back to the record.

Before you run it: Later vectors must match the dimension count. A separate source row is not updated automatically.

Choose an unused collection for a first trial. The array below is shortened: replace the comment and ellipsis with all 768 numeric values, or change dim to the length of a real test vector consistently in both write and query. JSON comments are not valid request data. This call stores an embedding you provide; it does not call an embedding model.

Store a supplied embedding under its source IDThis write does not call an embedding model or update a separate source row.
  1. Generate the full vectorUse your chosen embedding model outside this request.
  2. Choose ID and dimensionsUse the source ID and the vector's actual length.
  3. Write the embeddingKeep the collection's first dimension and metric settings consistent.
  4. Query in the same spaceUse a query from the same model and preprocessing.

Follow the example

  1. Generate an embedding with your chosen model.
  2. Choose its table, ID and distance metric.
  3. Send the write.
  4. Query with an embedding from the same model.

For a first API check without an embedding model, run the complete three-value example. The longer example below shows how the same request is shaped for model-generated embeddings.

Run the request

curl -X POST "https://$OC_HOST/v1/tenants/$OC_TENANT/vector/shop.products/put" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id":        "sku-9281",
    "embedding": [0.0124, -0.0883, 0.0451, /* ... 768 floats ... */],
    "dim":       768,
    "metric":    "cosine"
  }'

Check the result

The first write establishes dimensions and metric. Writing the same ID replaces that vector.

{ "ok": true }

Re-putting the same id overwrites the previous vector.

Request options

FieldRequiredNotes
idyesString. Usually the row's primary key.
embeddingyesArray of floats. Length must equal dim.
dimyesLocked at the first put.
metricnoDefault "cosine". Locked at the first put.

Important limits and checks

  • dim mismatch. If you switch models partway through, all puts after the first model fail with 400 dim_mismatch. Use a fresh table for the new model.
  • Float precision. Doubles convert to f32 on the wire. ~7 decimal digits of precision is plenty for similarity but not for exact equality.

Continue

Continue to find similar vector directions.

© 2026 Silicoyn Technologies Pvt Ltd

On this page