How to put a Key Value for CID in IPFS

There is a very cool way to avoid paying gas in the TokenUris registry for NFTs.

In this famous self-generated NFTs contract, we verify that it does not have an associated tokenURI. If use the geter function will return the baseURI with the id Token:

This is so because the tokenuri function concatenates the token id if it doesn't find a record:

    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
       // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
      return string(abi.encodePacked(base, tokenId.toString()));

With Pinata I know how to do this by associating a key value to the CID.
In the following example we have the key 5 which would be the association with the id token 5:

But my question is...
How can we do the same with IPFS?