CogsLayer
Know the true cost of every feature you ship.
CogsLayer tracks the direct costs of delivering your software — starting with AI. Attribute spend to features, teams, and models. Cut what's wasted.
Start free at cogslayer.com.
Two ways in
1. Python SDK (2 lines of code)
pip install cogslayer
import cogslayer
from cogslayer.openai import OpenAI
cogslayer.init(api_key="cl_live_xxx", service="my-api")
client = OpenAI()
@cogslayer.track(feature="chat", team="growth")
def ask(prompt: str) -> str:
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}],
)
return resp.choices[0].message.content
Drop-in replacement clients for OpenAI, Anthropic, and Gemini. Every call is automatically tracked with cost, tokens, latency, and attribution context.
2. Provider integration (60 seconds, zero code)
Paste your OpenAI org key or Anthropic admin key. CogsLayer pulls actual billed costs — not token-based estimates — and syncs automatically.
Supported: OpenAI, Anthropic, Cursor, Claude Code.
Track. Understand. Save.
| What you get | |
|---|---|
| Track | Every call tracked with cost, tokens, and latency. Attribute spend to features, teams, models, and services with @cogslayer.track. Agent sessions grouped automatically. |
| Understand | Dashboard with spend by team, feature, model, provider. Actual billed costs from provider APIs. Estimate vs. billed drift detection. Budget alerts and forecasting. |
| Save | Waste detection flags duplicates, retry bloat, and oversized models. Optimization rules with one-click apply. Realized savings ledger proves ROI. |
Wrapped clients
OpenAI
from cogslayer.openai import OpenAI, AsyncOpenAI
client = OpenAI() # exact same API as openai.OpenAI
async_client = AsyncOpenAI() # exact same API as openai.AsyncOpenAI
Tracks chat.completions.create(), chat.completions.parse(), chat.completions.stream(), and responses.create().
OpenAI-compatible providers
from cogslayer.openai import OpenAI
groq = OpenAI(
base_url="https://api.groq.com/openai/v1",
api_key="gsk_...",
provider="groq",
)
Works with Groq, Together, Fireworks, Ollama, or any OpenAI-compatible API.
Anthropic
from cogslayer.anthropic import Anthropic, AsyncAnthropic
client = Anthropic()
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
Tracks messages.create() and messages.stream(). Captures cache tokens.
Google Gemini
from cogslayer.gemini import Client
client = Client(api_key="...")
response = client.models.generate_content(
model="gemini-2.0-flash",
contents="Hello",
)
Tracks models.generate_content() (sync and async). Streaming supported.
What gets tracked
| Metric | Description |
|---|---|
prompt_tokens |
Input tokens |
completion_tokens |
Output tokens |
reasoning_tokens |
Thinking tokens (o1, o3, o4-mini) |
cached_tokens |
Prompt tokens served from cache |
cost_usd |
Estimated cost from pricing registry |
latency_ms |
Round-trip time |
has_tool_calls |
Whether the response included tool calls |
api_type |
chat / responses / messages / generate |
Attribution
Every call is tagged with context from @cogslayer.track():
| Field | Description |
|---|---|
feature |
Product feature (e.g. "chat", "code-review") |
team |
Owning team (e.g. "engineering", "support") |
user_id |
End-user identifier |
service |
Service name (set in init()) |
environment |
"production" / "staging" / etc. |
Streaming
Fully supported across all providers. CogsLayer injects stream_options for OpenAI and captures token counts from the final chunk automatically.
stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Custom pricing
cogslayer.register_model(
"my-fine-tuned-gpt4",
prompt_price_per_1k=0.006,
completion_price_per_1k=0.012,
)
Running locally
python -m pip install -e ".[openai,dev]"
python -m pytest tests/ -q
Build the PyPI artifacts with:
python -m build
python -m twine check dist/*
Supported providers
| Provider | SDK wrapper | Integration (billed costs) |
|---|---|---|
| OpenAI | from cogslayer.openai import OpenAI |
Yes |
| Anthropic | from cogslayer.anthropic import Anthropic |
Yes |
| Google Gemini | from cogslayer.gemini import Client |
— |
| Cursor | — | Yes |
| Claude Code | — | Yes |
| Any OpenAI-compatible | OpenAI(base_url=..., provider="groq") |
— |
Metadata
Release files for cogslayer 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cogslayer-0.2.0.tar.gz | 32.5 kB | Without provenance | Details for cogslayer-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cogslayer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for cogslayer-0.2.0-py3-none-any.whl |
Total release size: 81.4 kB
Release files / cogslayer-0.2.0.tar.gz
| Download URL | cogslayer-0.2.0.tar.gz |
|---|---|
| Size | 32.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc78bc6c1d2d13fb1c9fdfdf6bfab7baa952c77691b5bf276b920e6c3d386ca6
|
|
BLAKE2b-256 checksum How to use checksums |
03959bfe1366cc49dfafa130d85b75f82623fddf335e55a837a189aad776ff87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Release files / cogslayer-0.2.0-py3-none-any.whl
| Download URL | cogslayer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 48.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff3920a5372c1a365b41da682d442158c5b3b044f4ff761d00f3edbcd68d633d
|
|
BLAKE2b-256 checksum How to use checksums |
0591e5d0170efad646c293f674838a64acbe2f14646ea54da5efe0357ed1a351
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Security for cogslayer 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.