Standalone Tracking
Track STT, TTS, and STS usage individually when they are not part of an integrated voice session. Use these methods to send granular usage data directly to Paygent.
Standalone STT
Track Speech-to-Text usage by providing the audio duration in minutes. This is ideal for modular systems where STT is handled independently.
standalone_stt.py
1from paygent_sdk import Client
2
3client = Client.new_client("your-paygent-api-key")
4
5client.track_stt(
6 agent_id="agent-123", # your external-agent-id
7 customer_id="customer-456",
8 indicator="stt-service-call",
9 stt_usage_data={
10 "serviceProvider": "Deepgram",
11 "model": "nova-3",
12 "plan": "default",
13 "audioDuration": 0.45, # Duration in minutes
14 }
15)Standalone TTS
Track Text-to-Speech usage by providing the character count. Use this for standalone voice synthesis tasks.
standalone_tts.py
1from paygent_sdk import Client
2
3client = Client.new_client("your-paygent-api-key")
4
5client.track_tts(
6 agent_id="agent-123", # your external-agent-id
7 customer_id="customer-456",
8 indicator="tts-service-call",
9 tts_usage_data={
10 "serviceProvider": "Elevenlabs",
11 "model": "eleven-v3",
12 "plan": "default",
13 "characterCount": 420, # total characters
14 }
15)Standalone STS
Track Speech-to-Speech usage with detailed input and output token counts for both text and audio modalities.
standalone_sts.py
1from paygent_sdk import Client
2from paygent_sdk.models import SpeechToSpeechUsageMetadata, StsInputSide, StsOutputSide, StsModalityUsage
3
4client = Client.new_client("your-paygent-api-key")
5
6# Define detailed usage metadata
7usage = SpeechToSpeechUsageMetadata(
8 input=StsInputSide(
9 audio=StsModalityUsage(tokens=2000),
10 text=StsModalityUsage(tokens=150)
11 ),
12 output=StsOutputSide(
13 audio=StsModalityUsage(tokens=2000),
14 text=StsModalityUsage(tokens=400)
15 ),
16)
17
18client.track_sts(
19 agent_id="agent-123", # your external-agent-id
20 customer_id="customer-456",
21 indicator="sts-service-call",
22 usage_metadata=usage,
23 service_provider="Google",
24 model="gemini-3.1-flash-live-preview",
25 plan="default",
26)Fire and Forget
All standalone tracking methods are asynchronous and follow a "fire-and-forget" pattern, ensuring minimal latency impact on your primary application flow.
Was this page helpful?
Need help? Contact us at support@withpaygent.com