private static Map<String, String> collectHttpHeaders(ProxyContext context) {
        if (!context.getApiKeyData().getHttpHeaders().isEmpty()) {
            return context.getApiKeyData().getHttpHeaders();
        }
        Map<String, String> headers = new HashMap<>();
        MultiMap requestHeaders = context.getRequest().headers();
        for (String header : HTTP_HEADERS_TO_STORE) {
            if (requestHeaders.contains(header)) {
                headers.put(header, requestHeaders.get(header));
            }
        }
        return headers;
    }
The container keeps data associated with API key.
<p>
    There are two types of API keys:
    <ul>
        <li>Project key is supplied from the Core config</li>
        <li>Per request key is generated in runtime and valid during the request</li>
    </ul>
</p>
server/src/main/java/com/epam/aidial/core/server/data/ApiKeyData.java