Is there a way to save all requests and responses to a file without adding console.log inside the script?

For now, I am only able to save requests and responses to a file by manually adding console.log(req or response body) for each of api test in script. Is there any env flag to do this automatically? This will be very useful for functional test.

You can use –http-debug. Though bear in mind that, because of some low-level implementation details that are not easy to fix, there are some issues with it: https://github.com/loadimpact/k6/issues/1042, https://github.com/loadimpact/k6/issues/986