Existing "fair use" clauses in many countries, notably the US, permit some uses of copyrighted material for training algorithms, but this permission is not clear cut.
Rightsholder advocates are fighting this case convincingly. The outcome remains far from clear though, and could yet upend the practices of leading Generative AI companies like OpenAI and Stability AI.