You can get this from the model package using java, but this only works when running on premise.
You can use the GetRuntimeVersion function from the community commons module. From Mendix 6.8.0 the version is also available in the client API by using mx.version https://world.mendix.com/display/ReleaseNotes/6.8.0