The PS5 was sold at a slight loss at launch, Sony got production costs down enough to be profitable about a year later (https://www.bloomberg.com/news/articles/2021-08-04/sony-rais...).
I'm less sure about Microsoft, my understanding is that the Series X is profitable and the Series S is a loss leader. However, both of them can be put into a developer mode and you can run your own (or other people's) code.
The PS5 was sold at a slight loss at launch, Sony got production costs down enough to be profitable about a year later (https://www.bloomberg.com/news/articles/2021-08-04/sony-rais...).
I'm less sure about Microsoft, my understanding is that the Series X is profitable and the Series S is a loss leader. However, both of them can be put into a developer mode and you can run your own (or other people's) code.