Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
pip install traceAI-bedrock
pip install boto3
npm install @traceai/bedrock @traceai/fi-core @opentelemetry/instrumentation
import os
os.environ["AWS_ACCESS_KEY_ID"] = "your-aws-access-key-id"
os.environ["AWS_SECRET_ACCESS_KEY"] = "your-aws-secret-access-key"
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
process.env.AWS_ACCESS_KEY_ID = "your-aws-access-key-id";
process.env.AWS_SECRET_ACCESS_KEY = "your-aws-secret-access-key";
process.env.FI_API_KEY = "your-futureagi-api-key";
process.env.FI_SECRET_KEY = "your-futureagi-secret-key";
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="bedrock_project",
)
import { register, ProjectType } from "@traceai/fi-core";
const tracerProvider = register({
project_type: ProjectType.OBSERVE,
project_name: "bedrock_project",
});
from traceai_bedrock import BedrockInstrumentor
BedrockInstrumentor().instrument(tracer_provider=trace_provider)
import { BedrockInstrumentation } from "@traceai/bedrock";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
const bedrockInstrumentation = new BedrockInstrumentation({});
registerInstrumentations({
instrumentations: [bedrockInstrumentation],
tracerProvider: tracerProvider,
});
import boto3
client = boto3.client(
service_name="bedrock",
region_name="your-region",
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
)
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
const client = new BedrockRuntimeClient({
region: "your-region",
});
def converse_with_claude():
system_prompt = [{"text": "You are an expert at creating music playlists"}]
messages = [
{
"role": "user",
"content": [{"text": "Hello, how are you?"}, {"text": "What's your name?"}],
}
]
inference_config = {"maxTokens": 1024, "temperature": 0.0}
try:
response = client.converse(
modelId="model_id",
system=system_prompt,
messages=messages,
inferenceConfig=inference_config,
)
out = response["output"]["message"]
messages.append(out)
print(out)
except Exception as e:
print(f"Error: {str(e)}")
if __name__ == "__main__":
converse_with_claude()
import { ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
async function converseWithClaude() {
const system = [{ text: "You are an expert at creating music playlists" }];
const messages = [
{
role: "user",
content: [{ text: "Hello, how are you?" }, { text: "What's your name?" }],
},
];
const inferenceConfig = { maxTokens: 1024, temperature: 0.0 };
try {
const response = await client.send(
new ConverseCommand({
modelId: "model_id",
system,
messages,
inferenceConfig,
})
);
const out = response.output?.message;
if (out) {
console.log(out);
}
} catch (e) {
console.error("Error:", e);
}
}
converseWithClaude();
Was this page helpful?