Documentation Index
Fetch the complete documentation index at: https://docs.getnetra.ai/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Install both the Netra SDK and Groq SDK:
pip install netra-sdk groq
Usage
Initialize the Netra SDK with Groq instrumentation enabled. The SDK automatically traces all Groq API calls once initialized.
from netra import Netra
from groq import Groq
import os
# Initialize Netra with Groq instrumentation
Netra.init(
app_name="my-ai-app",
headers=f"x-api-key={os.environ.get('NETRA_API_KEY')}",
trace_content=True
)
# Use Groq client as usual - all calls are automatically traced
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
completion = client.chat.completions.create(
model="llama-3.1-70b-versatile",
messages=[
{"role": "user", "content": "What is observability?"}
]
)
print(completion.choices[0].message.content)
Streaming Responses
The SDK automatically handles streaming responses and captures the complete output:
stream = client.chat.completions.create(
model="llama-3.1-70b-versatile",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Multiple Model Support
Groq supports various open-source models, all automatically instrumented:
# Using Mixtral
mixtral_response = client.chat.completions.create(
model="mixtral-8x7b-32768",
messages=[{"role": "user", "content": "Explain AI"}]
)
# Using Gemma
gemma_response = client.chat.completions.create(
model="gemma-7b-it",
messages=[{"role": "user", "content": "Hello"}]
)
Selective Instrumentation
Control which integrations are enabled using the instruments or blockInstruments configuration:
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet
# Only enable Groq instrumentation
Netra.init(
headers=f"x-api-key={os.environ.get('NETRA_API_KEY')}",
instruments={InstrumentSet.GROQ}
)
# Or block specific instrumentations
Netra.init(
headers=f"x-api-key={os.environ.get('NETRA_API_KEY')}",
block_instruments={InstrumentSet.HTTPX}
)
Next Steps