MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / _save_usage_data

Function _save_usage_data

api_utils/utils_ext/usage_tracker.py:25–33  ·  view source on GitHub ↗

Internal function to save usage data to disk.

(data: Dict[str, int])

Source from the content-addressed store, hash-verified

23
24
25def _save_usage_data(data: Dict[str, int]) -> None:
26 """Internal function to save usage data to disk."""
27 try:
28 # Ensure directory exists
29 os.makedirs(os.path.dirname(USAGE_FILE), exist_ok=True)
30 with open(USAGE_FILE, "w", encoding="utf-8") as f:
31 json.dump(data, f, indent=2)
32 except IOError as e:
33 logger.error(f"Failed to save profile usage data: {e}")
34
35
36async def increment_profile_usage(profile_path: str, tokens: int) -> None:

Callers 1

increment_profile_usageFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected