BerriAI/litellm · error · Exception
Missing keys={missing_keys} in environment.
Error message
Missing keys={missing_keys} in environment. What it means
OpenMeterLogger.__init__ checks that OPENMETER_API_KEY exists in the environment (the docstring mentions OPENMETER_API_ENDPOINT too, but only the key is enforced) and raises with the list of missing keys. Events are CloudEvents POSTed to OpenMeter's /api/v1/events with a Bearer token, so without the key the logger cannot authenticate.
Source
Thrown at litellm/integrations/openmeter.py:49
super().__init__()
self.validate_environment()
self.async_http_handler = get_async_httpx_client(llm_provider=httpxSpecialProvider.LoggingCallback)
self.sync_http_handler = HTTPHandler()
def validate_environment(self):
"""
Expects
OPENMETER_API_ENDPOINT,
OPENMETER_API_KEY,
in the environment
"""
missing_keys: Final = []
if os.getenv("OPENMETER_API_KEY", None) is None:
missing_keys.append("OPENMETER_API_KEY")
if len(missing_keys) > 0:
raise Exception(f"Missing keys={missing_keys} in environment.")
def _common_logic(self, kwargs: dict, response_obj):
call_id: Final = response_obj.get("id", kwargs.get("litellm_call_id"))
dt: Final = get_utc_datetime().isoformat()
cost: Final = kwargs.get("response_cost", None)
model: Final = kwargs.get("model")
usage = {}
if (
isinstance(response_obj, litellm.ModelResponse) or isinstance(response_obj, litellm.EmbeddingResponse)
) and hasattr(response_obj, "usage"):
usage = {
"prompt_tokens": response_obj["usage"].get("prompt_tokens", 0),
"completion_tokens": response_obj["usage"].get("completion_tokens", 0),
"total_tokens": response_obj["usage"].get("total_tokens"),
}
# OPENMETER_TRUST_REQUEST_USER (default "true"): when set to "false",
# the request-supplied `user` field is ignored and the subject isView on GitHub (pinned to 6c2dcb801b)
Solutions
- export OPENMETER_API_KEY=<OpenMeter key> in the litellm process environment
- Optionally set OPENMETER_API_ENDPOINT if not using the default https://openmeter.cloud
- Verify inside the container: 'env | grep OPENMETER'
- Drop the openmeter callback if usage metering to OpenMeter is not intended
Example fix
# before litellm.success_callback = ["openmeter"] # Exception: Missing keys=['OPENMETER_API_KEY'] # after import os os.environ["OPENMETER_API_KEY"] = "om-..." litellm.success_callback = ["openmeter"]
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv("OPENMETER_API_KEY"):
raise RuntimeError("OPENMETER_API_KEY required before enabling the openmeter callback") Prevention
- Validate env vars in a startup gate for every enabled callback
- Keep callback list and required secrets in the same config unit
When it happens
Trigger: Adding 'openmeter' to success callbacks without exporting OPENMETER_API_KEY; key defined in a .env file not loaded by the process; key set to an empty string.
Common situations: Proxy deployments enabling OpenMeter usage metering while secrets live in a vault not wired to env vars; local dev copying config from docs without the secrets block.
Related errors
- LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for
- LEVOAI_API_KEY environment variable is required for Levo int
- LEVOAI_ORG_ID environment variable is required for Levo inte
- LEVOAI_WORKSPACE_ID environment variable is required for Lev
- LEVOAI_COLLECTOR_URL environment variable is required for Le
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/4f911ab131487ed8.
Report an issue: GitHub.