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 the Netra SDK along with the AWS SDK for Bedrock:
pip install netra-sdk boto3
Usage
Netra SDK automatically instruments AWS Bedrock calls when you enable the botocore instrumentation. This captures traces for all Bedrock API calls including model invocations, streaming responses, and embeddings.
Basic Setup
Initialize Netra with Bedrock instrumentation enabled:
from netra import Netra
import boto3
import os
# Initialize Netra SDK
Netra.init(
headers=f"x-api-key={os.environ.get('NETRA_API_KEY')}",
app_name="bedrock-app"
)
# Create Bedrock client - automatically instrumented
bedrock = boto3.client(
service_name='bedrock-runtime',
region_name='us-east-1'
)
# Make Bedrock calls - automatically traced
response = bedrock.invoke_model(
modelId='anthropic.claude-v2',
body='{"prompt": "Hello, world!"}'
)
Model Invocation
The SDK automatically captures model invocations with full request and response details:
from netra import Netra
import boto3
import json
import os
Netra.init(headers=f"x-api-key={os.environ.get('NETRA_API_KEY')}")
bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')
# Text generation
response = bedrock.invoke_model(
modelId='anthropic.claude-v2',
body=json.dumps({
"prompt": "Explain AI observability",
"max_tokens_to_sample": 300
})
)
Streaming Responses
Bedrock streaming responses are automatically traced with full visibility:
from netra import Netra
import boto3
import json
import os
Netra.init(headers=f"x-api-key={os.environ.get('NETRA_API_KEY')}")
bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')
response = bedrock.invoke_model_with_response_stream(
modelId='anthropic.claude-v2',
body=json.dumps({
"prompt": "Write a story",
"max_tokens_to_sample": 500
})
)
# Stream automatically traced
for event in response['body']:
chunk = json.loads(event['chunk']['bytes'])
print(chunk.get('completion', ''))
Session Tracking
Track user sessions and conversations with Bedrock models:
from netra import Netra
import boto3
import json
Netra.init(api_key="your-api-key")
Netra.set_session_id("session-123")
Netra.set_user_id("user-456")
bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')
# All calls automatically tagged with session context
response = bedrock.invoke_model(
modelId='anthropic.claude-v2',
body=json.dumps({"prompt": "Hello"})
)
Next Steps