Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/onenot8/issueLoop/llms.txt

Use this file to discover all available pages before exploring further.

IssueLoop logs every LLM call — provider, model, prompt tokens, and completion tokens — to data/logs/llm_usage.jsonl. These functions read that log so you can audit token spend, detect runaway usage, and debug provider configuration without digging through raw files. All four functions are read-only; they do not trigger any LLM calls themselves.

get_token_consumption

Returns aggregated token usage totals, optionally filtered to a single provider.
# All providers combined
totals = issueloop.get_token_consumption()

# Only Anthropic usage
anthropic_totals = issueloop.get_token_consumption(provider="anthropic")
provider
str
Optional provider filter. One of "ollama", "anthropic", or "openai". Pass None or omit to aggregate across all providers.
Returns a dict with the following fields:
prompt_tokens
int
Total prompt (input) tokens consumed.
completion_tokens
int
Total completion (output) tokens consumed.
total_tokens
int
Sum of prompt and completion tokens.
calls
int
Number of individual LLM calls that contributed to these totals.
Returns all zeros with calls: 0 if the usage log does not yet exist.

get_token_consumption_by_provider

Returns per-provider token usage, with each provider’s totals in a nested dict. Useful for comparing cost across providers when using a fallback chain.
by_provider = issueloop.get_token_consumption_by_provider()
# {
#   "anthropic": {"prompt_tokens": 4200, "completion_tokens": 800, "total_tokens": 5000, "calls": 10},
#   "ollama":    {"prompt_tokens": 1500, "completion_tokens": 300, "total_tokens": 1800, "calls": 4},
# }
Returns a dict mapping provider name (str) to a consumption dict containing prompt_tokens, completion_tokens, total_tokens, and calls. Returns an empty dict if the usage log does not yet exist.
Use get_token_consumption_by_provider() to see how often your primary provider is actually being used versus the fallback. A high ollama call count when Anthropic is configured as primary usually means the Anthropic provider is encountering errors and falling back.

get_llm_call_history

Returns the most recent LLM call records in chronological order (oldest first within the returned slice).
history = issueloop.get_llm_call_history(limit=10)
limit
int
default:"50"
Maximum number of call records to return. Returns the last limit entries from the log.
Returns a list of call entry dicts:
ts
str
ISO 8601 UTC timestamp of the call.
provider
str
Provider that handled the call: "ollama", "anthropic", or "openai".
model
str
Model name used for the call (e.g. "claude-sonnet-4-6", "qwen2.5-coder:7b").
prompt_tokens
int
Number of prompt tokens in this call.
completion_tokens
int
Number of completion tokens in this call.
total_tokens
int
Sum of prompt and completion tokens for this call.
Returns an empty list if the usage log does not yet exist.

get_llm_provider_status

Returns a snapshot of the configured LLM providers and their priority order, derived from the current Config object rather than from the usage log.
status = issueloop.get_llm_provider_status()
# {
#   "priority_order": [
#     {"provider": "anthropic", "model": "claude-sonnet-4-6", "has_api_key": True},
#     {"provider": "ollama", "model": "qwen2.5-coder:7b", "has_api_key": False},
#   ],
#   "primary": "anthropic",
#   "fallback_count": 1,
# }
Returns a dict with:
priority_order
list
List of provider dicts in fallback priority order. Each entry has provider (str), model (str), and has_api_key (bool).
primary
str
The name of the first (highest-priority) provider, or None if no providers are configured.
fallback_count
int
Number of additional fallback providers beyond the primary. 0 means no fallback is configured.

Usage log format

Each line in data/logs/llm_usage.jsonl is a JSON object. This is the raw format that all four functions above read from:
{
  "ts": "2024-01-15T10:30:00+00:00",
  "provider": "anthropic",
  "model": "claude-sonnet-4-6",
  "prompt_tokens": 420,
  "completion_tokens": 85,
  "total_tokens": 505
}
The file is append-only and is never rotated automatically. Use rotate_logs() from the Database API if you need to manage its size over time.

Build docs developers (and LLMs) love