Integrating Signals with Cost Tracking
Overview
This guide shows you how to integrate cost tracking with Signals in your AI product workflow. By linking these two together, you can:
- Automatically attribute AI provider costs (OpenAI, Anthropic, etc.) to specific business events
- Track the true cost of achieving business outcomes (e.g., booking a meeting, sending an email, processing an image or a document)
- Generate accurate invoices that reflect both usage-based pricing and actual AI costs
Prerequisites
Before you begin, make sure you have:
- Created an API key in the Paid dashboard
- Installed the Paid SDK for your language
- Configured at least one Product with Signals
- Set up your customer and order records
Note: This feature is currently available in Python and Node.js SDKs.
How It Works
In a typical AI product workflow, your event processing logic might look like this:
To link AI costs with signals, you need to:
- Process your AI calls as usual with your AI provider
- Send signals to Paid using the Paid SDK
This allows Paid to track your business outcomes and attribute costs accordingly.
Automatic Cost Tracking
The Paid SDK can automatically instrument your AI provider calls so that costs are tracked without any manual bookkeeping. Call initialize_tracing and autoinstrument once at startup, then wrap your business logic in a trace. Supported providers include OpenAI, Anthropic, Gemini, Bedrock, LangChain, OpenAI Agents, and Instructor.
Python
Node.js
Next.js
AI SDK
Basic Integration Pattern
Here’s the recommended pattern for integrating cost tracking with signals using the SDK:
Python
Node.js
Real-World Example: AI SDR Product
Let’s walk through a complete example of an AI SDR product that processes email replies and sends signals via the SDK.
Python
Node.js
Event Loop Integration
Most AI products run in an event loop, processing events continuously. Here’s how to integrate signal tracking in that pattern:
Python
Node.js
Best Practices
1. One Signal Per Business Outcome
Each business outcome should have one signal:
Python
Node.js
2. Use Idempotency Keys
Always include idempotency keys to prevent duplicate signals:
Python
Node.js
Troubleshooting
Signals Not Appearing in Dashboard
If signals aren’t showing up:
- Check API key: Verify your API key is valid and has the correct permissions
- Check customer exists: The customer ID must exist in your Paid organization
- Check product exists: If using attribution, the product must exist
- Check response: Verify the API response shows
ingested: 1
Duplicate Signals
If you’re seeing duplicate signals:
- Add
idempotencyKeyto your signals - Use a unique identifier for each business event (e.g.,
{event_type}_{entity_id}_{timestamp})
Next Steps
Need Help?
- Email: support@paid.ai
- Community: Join
#paid-developerson Slack