'Encodes a NXAPI JSON request message'

def _request_builder(self, commands, output, version='1.0', chunk='0', sid=None):

    try:
        command_type = self.OUTPUT_TO_COMMAND_TYPE[output]
    except KeyError:
        msg = ('invalid    format,    received    %s,    expected    one    of    %s' % (output, ','.join(self.OUTPUT_TO_COMMAND_TYPE.keys())))
        self._error(msg=msg)
    if isinstance(commands, (list, set, tuple)):
        commands = '    ;'.join(commands)
    msg = {'version': version, 'type': command_type, 'chunk': chunk, 'sid': sid, 'input': commands, 'output_format': 'json'}
    return dict(ins_api=msg)
