Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Trace AWS Bedrock foundation model calls with Netra auto-instrumentation. Monitor prompts, completions, token usage, and latency across all models.
pip install netra-sdk boto3
npm install netra-sdk @aws-sdk/client-bedrock-runtime
botocore
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!"}' )
import { Netra } from "netra-sdk"; import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime"; // Initialize Netra SDK (must await) await Netra.init({ headers: `x-api-key=${process.env.NETRA_API_KEY}`, appName: "bedrock-app" }); // Create Bedrock client - automatically instrumented const client = new BedrockRuntimeClient({ region: "us-east-1" }); // Make Bedrock calls - automatically traced const command = new InvokeModelCommand({ modelId: "anthropic.claude-v2", body: JSON.stringify({ prompt: "Hello, world!" }) }); const response = await client.send(command);
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 }) )
import { Netra } from "netra-sdk"; import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime"; await Netra.init({ headers: `x-api-key=${process.env.NETRA_API_KEY}` }); const client = new BedrockRuntimeClient({ region: "us-east-1" }); const command = new InvokeModelCommand({ modelId: "anthropic.claude-v2", body: JSON.stringify({ prompt: "Explain AI observability", max_tokens_to_sample: 300 }) }); await client.send(command);
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', ''))
import { Netra } from "netra-sdk"; import { BedrockRuntimeClient, InvokeModelWithResponseStreamCommand } from "@aws-sdk/client-bedrock-runtime"; await Netra.init({ headers: `x-api-key=${process.env.NETRA_API_KEY}` }); const client = new BedrockRuntimeClient({ region: "us-east-1" }); const command = new InvokeModelWithResponseStreamCommand({ modelId: "anthropic.claude-v2", body: JSON.stringify({ prompt: "Write a story", max_tokens_to_sample: 500 }) }); const response = await client.send(command); // Stream automatically traced for await (const event of response.body) { console.log(event.chunk?.bytes); }
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"}) )
import { Netra } from "netra-sdk"; import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime"; await Netra.init({ headers: `x-api-key=${process.env.NETRA_API_KEY}` }); Netra.setSessionId("session-123"); Netra.setUserId("user-456"); const client = new BedrockRuntimeClient({ region: "us-east-1" }); // All calls automatically tagged with session context const command = new InvokeModelCommand({ modelId: "anthropic.claude-v2", body: JSON.stringify({ prompt: "Hello" }) }); await client.send(command);