Pain is the electrical signals sent through nerves to our brain. I suspect that the concept of pain will work much the same way with AI, although I will concede the concept of what pain is would be different.
For instance, a network of nano tubes,
or radio waves could be used to "sense pain".
I don't believe that AI will be without some type of environmental pressure. Radioactivity, heat from stars, freezing temperatures of space, etc.
There could even be competing AI. Having a way to quantify the damage any one of these effects makes on the AI's "body" could be considered pain.
Let me know what you think! Thanks for the response.