One reason your fish might be gasping for air at the top of the tank is a sudden spike in ammonia or nitrates. This can happen if you have an excess amount of fish waste, which will cause the water to become toxic and low on oxygen. It’s especially apparent if all your fish swim to the top of the tank.