BerriAI/litellm · error · HTTPException

Vector store with ID {vector_store.get('vector_store_id')} a

Error message

Vector store with ID {vector_store.get('vector_store_id')} already exists

What it means

HTTPException 400 raised by the create-vector-store endpoint when a row with the same vector_store_id already exists in litellm_managedvectorstorestable (checked via find_unique before insert). It is a duplicate-ID conflict guard so retries don't silently overwrite an existing managed vector store.

Source

Thrown at enterprise/litellm_enterprise/proxy/vector_stores/endpoints.py:74

    - vector_store_name: Optional[str] - Name of the vector store
    - vector_store_description: Optional[str] - Description of the vector store
    - vector_store_metadata: Optional[Dict] - Additional metadata for the vector store
    """
    from litellm.proxy.proxy_server import prisma_client
    from litellm.types.router import GenericLiteLLMParams

    if prisma_client is None:
        raise HTTPException(status_code=500, detail="Database not connected")

    try:
        # Check if vector store already exists
        existing_vector_store = (
            await prisma_client.db.litellm_managedvectorstorestable.find_unique(
                where={"vector_store_id": vector_store.get("vector_store_id")}
            )
        )
        if existing_vector_store is not None:
            raise HTTPException(
                status_code=400,
                detail=f"Vector store with ID {vector_store.get('vector_store_id')} already exists",
            )

        if vector_store.get("vector_store_metadata") is not None:
            vector_store["vector_store_metadata"] = safe_dumps(
                vector_store.get("vector_store_metadata")
            )

        # Safely handle JSON serialization of litellm_params
        litellm_params_json: Optional[str] = None
        _input_litellm_params: dict = vector_store.get("litellm_params", {}) or {}
        if _input_litellm_params is not None:
            litellm_params_dict = GenericLiteLLMParams(
                **_input_litellm_params
            ).model_dump(exclude_none=True)
            litellm_params_json = safe_dumps(litellm_params_dict)
            del vector_store["litellm_params"]

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a unique vector_store_id (or regenerate one) for the new store
  2. If the existing store is stale, DELETE the old vector store first, then create
  3. Treat the 400 as idempotent success in retry logic: GET the store info and continue if it matches what you wanted
  4. Namespace IDs per environment/team (e.g. 'prod-openai-docs') to avoid collisions

Example fix

# before
POST /vector_store/create
{"vector_store_id": "my-store", "custom_llm_provider": "openai"}  # 2nd call -> 400 already exists

# after
# delete then recreate
DELETE /vector_store/delete {"vector_store_id": "my-store"}
POST /vector_store/create {"vector_store_id": "my-store", "custom_llm_provider": "openai"}
Defensive patterns

Strategy: try-catch

Validate before calling

import httpx

def vector_store_exists(client: httpx.Client, vector_store_id: str) -> bool:
    r = client.post("/vector_store/info", json={"vector_store_id": vector_store_id})
    return r.status_code == 200  # 404 = free to create

Try / catch

try:
    resp = client.post("/vector_store/create", json=payload)
    resp.raise_for_status()
except httpx.HTTPStatusError as e:
    if e.response.status_code == 400 and "already exists" in e.response.text:
        existing = client.post("/vector_store/info", json={"vector_store_id": sid}).json()
        # idempotent path: verify it matches expectations, then continue
    else:
        raise

Prevention

When it happens

Trigger: POST /vector_store/create with a vector_store_id that was already created previously; re-running an install/provisioning script; retrying a create request that partially succeeded client-side; copy-pasting an example payload twice.

Common situations: Idempotent provisioning scripts that don't check existence first; CI pipelines re-registering vector stores; teams reusing IDs like 'default' or the provider's store name across environments.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/27bd75c1beaa0009. Report an issue: GitHub.