litellm - ✅(Solved) Fix [Feature]: AgentCOGS integration — per-customer gross margin for LLM SaaS [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#28254Fetched 2026-05-20 03:40:29
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Community integration request: add an AgentCOGS callback (same pattern as Lago / OpenMeter) so LiteLLM proxy users can send per-completion cost to AgentCOGS for per-customer margin (LLM cost + revenue), aimed at B2B SaaS.

Root Cause

Community integration request: add an AgentCOGS callback (same pattern as Lago / OpenMeter) so LiteLLM proxy users can send per-completion cost to AgentCOGS for per-customer margin (LLM cost + revenue), aimed at B2B SaaS.

Fix Action

Fixed

PR fix notes

PR #28255: feat(integrations): AgentCOGS per-customer margin callback

Description (problem / solution / changelog)

Summary

Adds AgentCOGS as a community billing callback (Lago / OpenMeter pattern) for B2B SaaS teams using LiteLLM who need per-customer LLM cost and gross margin tracking.

Closes / relates to #28254

Changes

  • litellm/integrations/agentcogs.pyAgentCOGSLoggerPOST /v1/ingest
  • Registry + _custom_logger_compatible_callbacks_literal: agentcogs
  • tests/test_litellm/integrations/test_agentcogs.py — payload, idempotency, proxy attribution, non-blocking errors

Docs: Per repo policy, documentation is not in this PR. A draft for BerriAI/litellm-docs is maintained at https://github.com/vaibhav11123/agentcogs/blob/main/docs/internal/litellm-docs-agentcogs.md (separate docs PR to follow).

Usage

litellm.success_callback = ["agentcogs"]
litellm.completion(..., user="your_customer_id")
litellm_settings:
  callbacks: ["agentcogs"]

Env: AGENTCOGS_API_KEY, AGENTCOGS_WORKSPACE_ID, optional AGENTCOGS_ENDPOINT, optional AGENTCOGS_CHARGE_BY (end_user_id | user_id | team_id).

Review feedback addressed

  • Removed in-repo docs/my-website/docs/observability/agentcogs.md (litellm-docs repo)
  • run_id uses litellm_call_id for idempotent ingest dedup
  • Proxy attribution mirrors Lago (AGENTCOGS_CHARGE_BY); client metadata.agentcogs_customer_id ignored on proxy requests
  • HTTP errors logged at warning (not swallowed at debug-only)

Testing

pytest tests/test_litellm/integrations/test_agentcogs.py -q

Notes

Changed files

  • litellm/__init__.py (modified, +1/-0)
  • litellm/integrations/agentcogs.py (added, +237/-0)
  • litellm/litellm_core_utils/custom_logger_registry.py (modified, +2/-0)
  • tests/test_litellm/integrations/test_agentcogs.py (added, +199/-0)
RAW_BUFFERClick to expand / collapse

Summary

Community integration request: add an AgentCOGS callback (same pattern as Lago / OpenMeter) so LiteLLM proxy users can send per-completion cost to AgentCOGS for per-customer margin (LLM cost + revenue), aimed at B2B SaaS.

Proposed changes

  • litellm/integrations/agentcogs.pyAgentCOGSLoggerPOST /v1/ingest
  • Registry entry: callbacks: ["agentcogs"]
  • Docs page: observability quickstart (env vars, user= attribution)
  • Unit tests under tests/test_litellm/integrations/

PR

Incoming from: https://github.com/vaibhav11123/litellm/tree/feat/agentcogs-integration

AgentCOGS links

Attribution

Pass user= on completions (same as Lago) → AgentCOGS customer_id.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING