import os

class ApiKeyAuth:
    def __init__(self, provided_key: str):
        self.provided = provided_key
        self.expected = os.getenv("KAFKAGRAPH_API_KEY")

    def assert_valid(self):
        if not self.expected:
            raise RuntimeError("KAFKAGRAPH_API_KEY not set")
        if self.provided != self.expected:
            raise RuntimeError("Invalid API key")
