```python:inference/core/roboflow_api.py
import hashlib
from functools import lru_cache
from typing import Optional

from inference.core.entities.types import WorkspaceID


@lru_cache(maxsize=2048)
def _cached_api_key_hash(api_key: Optional[str]) -> str:
    if api_key is None:
        return "None"
    return hashlib.md5(api_key.encode("utf-8")).hexdigest()

def _prepare_workflow_response_cache_key(
    api_key: Optional[str],
    workspace_id: WorkspaceID,
    workflow_id: str,
    workflow_version_id: Optional[str] = None,
) -> str:
    api_key_hash = _cached_api_key_hash(api_key)
    workflow_version_suffix = (
        f":workflow_version={workflow_version_id}" if workflow_version_id else ""
    )
    return f"workflow_definition:{workspace_id}:{workflow_id}{workflow_version_suffix}:{api_key_hash}"
```