agentsclimarketplace

Run1 llm token tracking

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-gemini-3.1-pro-preview/enterprise-information-search/run1_llm-token-tracking

Extracts and tracks the consumed token usage from an LLM API response to monitor API cost and utilization.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_llm-token-tracking

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.0 KB, 182 tokens by cl100k_base, as published. Nobody here has run it

When querying a Large Language Model (LLM) such as OpenAI, you often need to log the consumed tokens for the request and response. Standard LLM APIs return a usage object in their response payload containing this information.

# Example of making a request and tracking token usage (OpenAI API structure)
def get_answer_and_tokens(client, prompt, context):
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[
            {"role": "system", "content": f"Context: {context}"},
            {"role": "user", "content": prompt}
        ]
    )
    
    # Extract the text answer
    answer_text = response.choices[0].message.content
    
    # Extract total consumed tokens as a positive integer
    consumed_tokens = response.usage.total_tokens
    
    return answer_text, consumed_tokens

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.