Learn how to integrate AWS Bedrock with Helicone using JavaScript.
This integration method is maintained but no longer actively developed. For the best experience and latest features, use our new AI Gateway with unified API access to 100+ models.
Here’s a complete example that puts all the steps together:
Copy
Ask AI
import { HeliconeAsyncLogger } from "@helicone/async";import * as bedrock from "@aws-sdk/client-bedrock-runtime";import util from "util";// Initialize Helicone Loggerconst logger = new HeliconeAsyncLogger({ apiKey: process.env.HELICONE_API_KEY, providers: { bedrock: bedrock, }, baseUrl: "https://api.helicone.ai/v1/trace/log",});logger.init();// Configure AWS Bedrock clientconst client = new bedrock.BedrockRuntimeClient({ region: process.env.AWS_REGION, credentials: { accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, },});// Create a command for the Bedrock modelconst command = new bedrock.ConverseCommand({ messages: [ { role: "user", content: [{ text: "Why is the unix epoch measured from 1970?" }], }, ], modelId: "meta.llama2-13b-chat-v1",});// Send the request and handle the responseasync function sendRequest() { try { const data = await client.send(command); console.log( "Response:\n", util.inspect(data, { showHidden: false, depth: null, colors: true }) ); } catch (error) { console.error("Error:", error); }}sendRequest();
This integration allows you to use AWS Bedrock with Helicone’s async logging. The Helicone logger will automatically capture traces of your AWS Bedrock API calls, providing you with valuable insights and analytics through the Helicone dashboard.For more information on using async logging, visit the Async Logging documentation.