You can easily filter out scenes that are too cloudy, for example using the maxCloudCoverage parameter in your payload.
If you want to filter out cloudy pixels you can utilise this by using the SCL bands for Sentinel-2 or the BQA bands for Landsat satellites. An example of how to create a cloudless mosaic was written by Max Kampen, and the evalscript used in that post maybe useful to you.
You can do something similar with Landsat I think, check out the docs related to this here.