High severity intermediate · Fix: 2-5 min

ValueError

qdrant_client.http.exceptions.ValueError

What this error means
Qdrant rejects vector inserts when the vector dimension does not match the collection's configured dimension.

Stack trace

traceback
ValueError: Vector dimension mismatch: expected 1536, got 512
  File "/usr/local/lib/python3.9/site-packages/qdrant_client/http/api/points_api.py", line 123, in upsert
    raise ValueError(f"Vector dimension mismatch: expected {expected_dim}, got {actual_dim}")
QUICK FIX
Verify and match your vector embedding dimension exactly to the Qdrant collection's dimension before inserting.

Why it happens

Qdrant collections are created with a fixed vector dimension. When inserting points, the vector length must exactly match this dimension. If the inserted vector's dimension differs, Qdrant raises a ValueError to prevent inconsistent data storage.

Detection

Check vector length before insertion by asserting len(vector) == collection_vector_size or catch ValueError on insert and log the vector dimensions for debugging.

Causes & fixes

1

The vector being inserted has a different dimension than the Qdrant collection's configured dimension.

✓ Fix

Ensure the vector embedding generation matches the collection's dimension or recreate the collection with the correct dimension.

2

Using multiple embedding models with different output sizes but inserting into the same Qdrant collection.

✓ Fix

Use separate collections for each embedding dimension or unify embedding models to produce vectors of the same size.

3

The collection was created with a default or incorrect dimension setting not matching the actual vectors.

✓ Fix

Delete and recreate the collection with the correct vector size parameter before inserting data.

Code: broken vs fixed

Broken - triggers the error
python
from qdrant_client import QdrantClient

client = QdrantClient()
collection_name = "my_collection"
vector = [0.1] * 512  # Vector dimension 512

# This line raises ValueError due to dimension mismatch
client.upsert(collection_name=collection_name, points=[{'id': 1, 'vector': vector}])
Fixed - works correctly
python
import os
from qdrant_client import QdrantClient

client = QdrantClient(api_key=os.environ.get('QDRANT_API_KEY'))
collection_name = "my_collection"
vector = [0.1] * 1536  # Fixed vector dimension to match collection

# Fixed: vector dimension matches collection dimension
client.upsert(collection_name=collection_name, points=[{'id': 1, 'vector': vector}])
print("Insert succeeded with matching vector dimension.")
Adjusted the vector length to exactly match the Qdrant collection's configured dimension, preventing the ValueError on insert.

Workaround

Catch the ValueError on insert, log the vector dimension mismatch, and programmatically resize or regenerate vectors to the correct dimension before retrying insertion.

Prevention

Always create Qdrant collections with a known fixed vector dimension and ensure all embedding vectors conform to this dimension before insertion, ideally by standardizing embedding model usage.

Python 3.9+ · qdrant-client >=1.0.0 · tested on 1.2.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.