HTTP_ variables come from HTTP headers, so you can print them using server-side scripts, like most other variables. For special variables, you can write their values to RewriteCond and add them to the query string.
RewriteCond RF=%{REQUEST_FILENAME}&API=%{API_VERSION} (.*)
RewriteRule ... ...?%1 [QSA]
, .