How can i get sum of squared errors from k means algorithm?

I Have a data frame. First I have to run a K-means algorithm with different k values. For each time I run a different k value I have to calculate the SSE.
How could I get the SSE (sum of squared errors) from this k-means function?