BerriAI/litellm · error · Exception

Error while creating new collection

Error message

Error while creating new collection

What it means

After PUTting a new collection, the cache checks the JSON response's 'result' field; a falsy result means Qdrant acknowledged the request but did not report success, and the constructor raises this generic exception. Unlike error 183, the HTTP status was not necessarily an error — Qdrant can return 200 with a result indicating failure, or the response body may lack the expected shape.

Source

Thrown at litellm/caching/qdrant_semantic_cache.py:144

            new_collection_status: Final = self.sync_client.put(
                url=f"{self.qdrant_api_base}/collections/{self.collection_name}",
                json={
                    "vectors": {"size": self.vector_size, "distance": "Cosine"},
                    "quantization_config": quantization_params,
                },
                headers=self.headers,
            )
            if new_collection_status.json()["result"]:
                collection_details = self.sync_client.get(
                    url=f"{self.qdrant_api_base}/collections/{self.collection_name}",
                    headers=self.headers,
                )
                self.collection_info = collection_details.json()
                print_verbose(f"New collection created.\nCollection details:{self.collection_info}")
                self._ensure_cache_key_payload_index()
            else:
                raise Exception("Error while creating new collection")

    def _get_cache_logic(self, cached_response: Any):
        if cached_response is None:
            return cached_response
        try:
            cached_response = json.loads(cached_response)  # Convert string to dictionary
        except Exception:
            cached_response = ast.literal_eval(cached_response)
        return cached_response

    def _get_qdrant_cache_key_filter(self, key: str) -> dict:
        return {
            "must": [
                {
                    "key": self.CACHE_KEY_FIELD_NAME,
                    "match": {"value": str(key)},
                }
            ]

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect Qdrant server logs at the moment of collection creation for the real rejection reason
  2. Create the collection manually with curl -X PUT $QDRANT_URL/collections/<name> -H 'api-key: ...' -d '{"vectors":{"size":1536,"distance":"Cosine"}}' to see the exact error
  3. Verify vector_size matches your embedding model's output dimension (e.g. 1536 for ada-002, 3072 for text-embedding-3-large)
  4. Ensure the Qdrant server allows writes and has capacity

Example fix

# before
cache = QdrantSemanticCache(collection_name='c', similarity_threshold=0.8,
                           vector_size=1024)  # but embedding model outputs 1536

# after
cache = QdrantSemanticCache(collection_name='c', similarity_threshold=0.8,
                           vector_size=1536)  # matches text-embedding-ada-002
Defensive patterns

Strategy: try-catch

Validate before calling

if cfg.get('vector_size') is not None:
    expected = {'text-embedding-ada-002': 1536, 'text-embedding-3-small': 1536, 'text-embedding-3-large': 3072}
    model = cfg.get('embedding_model', 'text-embedding-ada-002')
    if model in expected and cfg['vector_size'] != expected[model]:
        raise ValueError(f'vector_size {cfg["vector_size"]} does not match {model} dim {expected[model]}')

Try / catch

try:
    cache = QdrantSemanticCache(**cfg)
except Exception as e:
    if 'Error while creating new collection' in str(e):
        logger.error('Qdrant refused collection creation — check server capacity/logs')
    raise

Prevention

When it happens

Trigger: First-use creation of the collection on a Qdrant server that rejects the create (e.g. resource limits, invalid vector size config, read-only mode) while still returning HTTP 200; or a proxy returning a JSON body without a truthy 'result' key.

Common situations: Self-hosted Qdrant in read-only mode or out of disk/memory; vector_size set inconsistently with the embedding model used later; Qdrant version returning an unexpected payload shape.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/f4e16adf596afbb0. Report an issue: GitHub.