"""LLM usage routes"""

from fastapi import APIRouter, Request

router = APIRouter(tags=["llm"])


@router.get("/llm/usage")
async def get_usage(agent_name: str | None = None, req: Request = None):
    """Get LLM usage statistics"""
    llm_gateway = req.app.state.llm_gateway
    summary = llm_gateway.get_usage(agent_name=agent_name)
    return {
        "total_tokens": summary.total_tokens,
        "total_cost": summary.total_cost,
        "by_model": summary.by_model,
    }
