Generating entity id with easily distinguished types/groups
UUID version 4 is basically 122 random bits + 4 bits for UUID version + 2 bits reserved. Its uniqueness relies on low probability of generating the same 122 bits.
UUID version 5 is basically 122 hash bits + 4 bits for UUID version + 2 bits reserved. Its uniquess relies on low probability of collision for 122-bit truncated SHA1 hash.
When you replace N bits of UUID (as long as they are not "version" or "reserved" bits), you make a tradeoff: probability of collision becomes higher 2^N times.
For example, if you use UUID4, probability of collision is neglectible, namely 2^122. In the same time, if you have up to 8 entity types and use UUID4 with 8 bits replaced, probability of collision becomes 2^194, which is bigger, though still neglectible.
So probably using UUID4 with N bits replaced may be a safe option without taking extra care to guarantee uniquess.
I need to generate unique id in distributed environment. Catch is that each id has to have a group/type information that can be examined by simple script.
Details:
I have some, fixed, number of entity types (lets call them: message, resource, user, session, etc). I need to generate unique id in form:  so i can know where to direct request based only on id - without db, list, or anything. 
I have considered uuid in version 3 or 5 but as far as I can see it is impossible to know "namespace" provided for generating id. 
I have also considered just replacing first x characters of uuid with fixed values but then i will lose uniqueness. 
I have also considered Twitter snowflake or Instagram way of generating id's but I don't know the number of nodes in each group and I cannot assume anything.
I will be using them in JS, Python, Redis and Postgresql so portability of code (and representation - big integer representation is full of bugs in JavaScript) is required. So either pure "number" or string that can be formatted as uuid (binary representation) for database.
edit:
I will generate them in Python or in Postgresql and only pass them in JavaScript and Redis.