Groq Wrapper
Wrap your Groq client to automatically trace every chat.completions.create() call. Groq uses an OpenAI-compatible API, so the wrapper follows the same pattern.
Installation
pip install twosignal[groq]Usage
from twosignal import TwoSignal
from twosignal.wrappers.groq import wrap_groq
from groq import Groq
ts = TwoSignal()
client = wrap_groq(Groq(api_key="your-key"))
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Hello"}],
)What Gets Captured
| Field | Description |
|---|---|
model | Model name (e.g., llama-3.3-70b-versatile) |
input | Input messages array |
output | Response content |
usage.prompt_tokens | Input token count |
usage.completion_tokens | Output token count |
cost | Estimated cost in USD |
Async
from groq import AsyncGroq
async_client = wrap_groq(AsyncGroq(api_key="your-key"))