{"record":{"id":"f4e16adf596afbb0","repo":"BerriAI/litellm","slug":"error-while-creating-new-collection","errorCode":null,"errorMessage":"Error while creating new collection","messagePattern":"Error while creating new collection","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/caching/qdrant_semantic_cache.py","lineNumber":144,"sourceCode":"\n            new_collection_status: Final = self.sync_client.put(\n                url=f\"{self.qdrant_api_base}/collections/{self.collection_name}\",\n                json={\n                    \"vectors\": {\"size\": self.vector_size, \"distance\": \"Cosine\"},\n                    \"quantization_config\": quantization_params,\n                },\n                headers=self.headers,\n            )\n            if new_collection_status.json()[\"result\"]:\n                collection_details = self.sync_client.get(\n                    url=f\"{self.qdrant_api_base}/collections/{self.collection_name}\",\n                    headers=self.headers,\n                )\n                self.collection_info = collection_details.json()\n                print_verbose(f\"New collection created.\\nCollection details:{self.collection_info}\")\n                self._ensure_cache_key_payload_index()\n            else:\n                raise Exception(\"Error while creating new collection\")\n\n    def _get_cache_logic(self, cached_response: Any):\n        if cached_response is None:\n            return cached_response\n        try:\n            cached_response = json.loads(cached_response)  # Convert string to dictionary\n        except Exception:\n            cached_response = ast.literal_eval(cached_response)\n        return cached_response\n\n    def _get_qdrant_cache_key_filter(self, key: str) -> dict:\n        return {\n            \"must\": [\n                {\n                    \"key\": self.CACHE_KEY_FIELD_NAME,\n                    \"match\": {\"value\": str(key)},\n                }\n            ]","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/caching/qdrant_semantic_cache.py#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect Qdrant server logs at the moment of collection creation for the real rejection reason","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","Verify vector_size matches your embedding model's output dimension (e.g. 1536 for ada-002, 3072 for text-embedding-3-large)","Ensure the Qdrant server allows writes and has capacity"],"exampleFix":"# before\ncache = QdrantSemanticCache(collection_name='c', similarity_threshold=0.8,\n                           vector_size=1024)  # but embedding model outputs 1536\n\n# after\ncache = QdrantSemanticCache(collection_name='c', similarity_threshold=0.8,\n                           vector_size=1536)  # matches text-embedding-ada-002","handlingStrategy":"try-catch","validationCode":"if cfg.get('vector_size') is not None:\n    expected = {'text-embedding-ada-002': 1536, 'text-embedding-3-small': 1536, 'text-embedding-3-large': 3072}\n    model = cfg.get('embedding_model', 'text-embedding-ada-002')\n    if model in expected and cfg['vector_size'] != expected[model]:\n        raise ValueError(f'vector_size {cfg[\"vector_size\"]} does not match {model} dim {expected[model]}')","typeGuard":null,"tryCatchPattern":"try:\n    cache = QdrantSemanticCache(**cfg)\nexcept Exception as e:\n    if 'Error while creating new collection' in str(e):\n        logger.error('Qdrant refused collection creation — check server capacity/logs')\n    raise","preventionTips":["Pre-create collections via infrastructure-as-code so app startup never depends on collection creation","Keep vector_size and embedding_model in one config unit so they can't drift"],"tags":["qdrant","collection","semantic-cache","initialization"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}