Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add PostHog/posthog-foss --skill calling-the-ai-gatewaygit clone --depth 1 https://github.com/PostHog/posthog-fossWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/posthog/posthog-foss/calling-the-ai-gateway)<a href="https://agentmods.dev/skills/posthog/posthog-foss/calling-the-ai-gateway"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/calling-the-ai-gateway/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/posthog/posthog-foss/calling-the-ai-gateway"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/calling-the-ai-gateway.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00161 | $0.01084 |
| Opus 5.5 | $0.00064 | $0.00434 |
| Sonnet 5.5 | $0.00032 | $0.00217 |
| Haiku 4.5 | $0.00016 | $0.00108 |
Grade A, and why
calling-the-ai-gateway scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 62 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Calling the AI gateway
Gateway behavior (auth, billing, routing, providers, models) lives in PostHog/ai-gateway.
A change to what the gateway does lands there. This monorepo only calls it.
Inventory the caller
Find the call site, client construction, settings, deployment wiring, and tests. Record:
- the use case and the
ai_productit reports as - the credential source and the team whose wallet pays
- API shape (OpenAI or Anthropic), model, streaming, and tool or structured-output needs
- distinct ID, trace ID, session ID, and custom property attribution
- timeout, retry, and error handling
Build the client
- For Django and worker code, use a builder from
posthog/llm/gateway_client.py.build_openai_client,build_async_openai_client,build_anthropic_clientandbuild_async_anthropic_clientauthenticate with theAI_GATEWAY_API_KEYproject secret.build_ai_gateway_openai_clientsends the caller's ownpha_orphe_bearer;build_anthropic_clientalso takesprivacy_mode. Each raisesGatewayNotConfiguredErrorwhen the gateway is not configured; handle it where the caller can degrade. - Use the slugless base URL from
AI_GATEWAY_URL(it ends in/v1). The Anthropic builders strip/v1because the SDK appends/v1/messages. - Authenticate with a
phs_orpha_credential that carriesllm_gateway:read. Do not expose a shared secret to an untrusted runtime. - Send event labels in one
X-PostHog-PropertiesJSON object, through the builder'spropertiesargument orai_gateway_headers. Use the dedicated distinct ID and trace ID arguments where the caller has them. - Treat
ai_productas telemetry. It does not grant product auth or billing policy. - Check the model and API shape against the gateway's
/v1/modelscatalog.
If the process has no gateway credential, enable the ai-gateway feature flag for the paying team, create a phs_ project secret with llm_gateway:read, and wire it through the existing deployment secret mechanism.
Check with the AI gateway team before adding deployment variables or secrets, so existing shared configuration can be reused.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago First seen · 62 lines · 161 tokens per session scan A a408aa4f95cf
calling-the-ai-gateway is a skill published in the GitHub repository PostHog/posthog-foss (736 stars, last pushed today), licensed MIT. It adds 161 tokens to every session and 1,084 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-28.
calling-the-ai-gateway compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| calling-the-ai-gatewayPostHog/posthog-foss | Skill | 736 | today | MIT | A | 161 | Claude Code, Codex |
| open-sourcebrowser-use/browser-use | Skill | 123k | today | MIT | A | 101 | Claude Code |
| gemini-api-agent-platformdavila7/claude-code-templates | Skill | 35k | today | MIT | A | 61 | Claude Code, Codex |
| prowler-mcpprowler-cloud/prowler | Skill | 15k | today | Apache-2.0 | A | 67 | Claude Code |
| gemini-api-devgoogle-gemini/gemini-skills | Skill | 5.1k | yesterday | Apache-2.0 | A | 96 | Claude Code |
| deepstream-sopNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 219 | Claude Code |
| tao-run-inference-serviceNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 92 | Claude Code |