mem0ai/mem0 · error · ValueError

Either 'api_key' or 'client' must be provided, or PINECONE_A

Error message

Either 'api_key' or 'client' must be provided, or PINECONE_API_KEY environment variable must be set.

What it means

Error "Either 'api_key' or 'client' must be provided, or PINECONE_API_KEY environment variable must be set." thrown in mem0ai/mem0.

Source

Thrown at mem0/configs/vector_stores/pinecone.py:28

    collection_name: str = Field("mem0", description="Name of the index/collection")
    embedding_model_dims: int = Field(1536, description="Dimensions of the embedding model")
    client: Optional[Any] = Field(None, description="Existing Pinecone client instance")
    api_key: Optional[str] = Field(None, description="API key for Pinecone")
    environment: Optional[str] = Field(None, description="Pinecone environment")
    serverless_config: Optional[Dict[str, Any]] = Field(None, description="Configuration for serverless deployment")
    pod_config: Optional[Dict[str, Any]] = Field(None, description="Configuration for pod-based deployment")
    hybrid_search: bool = Field(False, description="Whether to enable hybrid search")
    metric: str = Field("cosine", description="Distance metric for vector similarity")
    batch_size: int = Field(100, description="Batch size for operations")
    extra_params: Optional[Dict[str, Any]] = Field(None, description="Additional parameters for Pinecone client")
    namespace: Optional[str] = Field(None, description="Namespace for the collection")

    @model_validator(mode="before")
    @classmethod
    def check_api_key_or_client(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        api_key, client = values.get("api_key"), values.get("client")
        if not api_key and not client and "PINECONE_API_KEY" not in os.environ:
            raise ValueError(
                "Either 'api_key' or 'client' must be provided, or PINECONE_API_KEY environment variable must be set."
            )
        return values

    @model_validator(mode="before")
    @classmethod
    def check_pod_or_serverless(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        pod_config, serverless_config = values.get("pod_config"), values.get("serverless_config")
        if pod_config and serverless_config:
            raise ValueError(
                "Both 'pod_config' and 'serverless_config' cannot be specified. Choose one deployment option."
            )
        return values

    @model_validator(mode="before")
    @classmethod
    def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        allowed_fields = set(cls.model_fields.keys())

View on GitHub (pinned to 001c235229)

Solutions

  1. Pass api_key or client in the Pinecone config, or set the PINECONE_API_KEY environment variable.

When it happens

Trigger: Thrown at mem0/configs/vector_stores/pinecone.py:28 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/f767e27013481f81. Report an issue: GitHub.