How to pasted the node of port key changing

I copied / pasted the node. The port of the copied node is the same as the port key of the pasted node. I want to change all the keys of the corresponding node ports to be unique. Can I programmatically change the key of an already created port?

Are you asking about changing the GraphObject.portId of some objects in some pasted Nodes?

Yes, I think you can, but you need to be careful about updating any Links that are connected with those ports. It’s management that you’ll need to perform (or decide not to perform) for all of the ways that nodes might be copied.