AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-04-11 · Documentation low

File: code-library/latest/ug/javascript_3_bedrock-runtime_code_examples.md

Summary

Removed all references and code examples related to AI21 Labs Jurassic-2 model

Security assessment

The changes appear to be routine documentation maintenance removing support for a specific model, with no security-related explanations or vulnerability mentions in the diff

Diff

diff --git a/code-library/latest/ug/javascript_3_bedrock-runtime_code_examples.md b/code-library/latest/ug/javascript_3_bedrock-runtime_code_examples.md
index 4ecf57d4c..160ffc54b 100644
--- a//code-library/latest/ug/javascript_3_bedrock-runtime_code_examples.md
+++ b//code-library/latest/ug/javascript_3_bedrock-runtime_code_examples.md
@@ -5 +5 @@
-ScenariosAI21 Labs Jurassic-2Amazon NovaAmazon Nova CanvasAmazon Titan TextAnthropic ClaudeCohere CommandMeta LlamaMistral AI
+ScenariosAmazon NovaAmazon Nova CanvasAmazon Titan TextAnthropic ClaudeCohere CommandMeta LlamaMistral AI
@@ -113,2 +112,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-  * AI21 Labs Jurassic-2
-
@@ -231,151 +228,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-## AI21 Labs Jurassic-2
-
-The following code example shows how to send a text message to AI21 Labs Jurassic-2, using Bedrock's Converse API.
-
-**SDK for JavaScript (v3)**
-    
-
-###### Note
-
-There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/bedrock-runtime#code-examples). 
-
-Send a text message to AI21 Labs Jurassic-2, using Bedrock's Converse API.
-    
-    
-    // Use the Conversation API to send a text message to AI21 Labs Jurassic-2.
-    
-    import {
-      BedrockRuntimeClient,
-      ConverseCommand,
-    } from "@aws-sdk/client-bedrock-runtime";
-    
-    // Create a Bedrock Runtime client in the AWS Region you want to use.
-    const client = new BedrockRuntimeClient({ region: "us-east-1" });
-    
-    // Set the model ID, e.g., Jurassic-2 Mid.
-    const modelId = "ai21.j2-mid-v1";
-    
-    // Start a conversation with the user message.
-    const userMessage =
-      "Describe the purpose of a 'hello world' program in one line.";
-    const conversation = [
-      {
-        role: "user",
-        content: [{ text: userMessage }],
-      },
-    ];
-    
-    // Create a command with the model ID, the message, and a basic configuration.
-    const command = new ConverseCommand({
-      modelId,
-      messages: conversation,
-      inferenceConfig: { maxTokens: 512, temperature: 0.5, topP: 0.9 },
-    });
-    
-    try {
-      // Send the command to the model and wait for the response
-      const response = await client.send(command);
-    
-      // Extract and print the response text.
-      const responseText = response.output.message.content[0].text;
-      console.log(responseText);
-    } catch (err) {
-      console.log(`ERROR: Can't invoke '${modelId}'. Reason: ${err}`);
-      process.exit(1);
-    }
-    
-    
-    
-
-  * For API details, see [Converse](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/ConverseCommand) in _AWS SDK for JavaScript API Reference_. 
-
-
-
-
-The following code example shows how to send a text message to AI21 Labs Jurassic-2, using the Invoke Model API.
-
-**SDK for JavaScript (v3)**
-    
-
-###### Note
-
-There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/bedrock-runtime#code-examples). 
-
-Use the Invoke Model API to send a text message.
-    
-    
-    import { fileURLToPath } from "node:url";
-    
-    import { FoundationModels } from "../../config/foundation_models.js";
-    import {
-      BedrockRuntimeClient,
-      InvokeModelCommand,
-    } from "@aws-sdk/client-bedrock-runtime";
-    
-    /**
-     * @typedef {Object} Data
-     * @property {string} text
-     *
-     * @typedef {Object} Completion
-     * @property {Data} data
-     *
-     * @typedef {Object} ResponseBody
-     * @property {Completion[]} completions
-     */
-    
-    /**
-     * Invokes an AI21 Labs Jurassic-2 model.
-     *
-     * @param {string} prompt - The input text prompt for the model to complete.
-     * @param {string} [modelId] - The ID of the model to use. Defaults to "ai21.j2-mid-v1".
-     */
-    export const invokeModel = async (prompt, modelId = "ai21.j2-mid-v1") => {
-      // Create a new Bedrock Runtime client instance.
-      const client = new BedrockRuntimeClient({ region: "us-east-1" });
-    
-      // Prepare the payload for the model.
-      const payload = {
-        prompt,
-        maxTokens: 500,
-        temperature: 0.5,
-      };
-    
-      // Invoke the model with the payload and wait for the response.
-      const command = new InvokeModelCommand({
-        contentType: "application/json",
-        body: JSON.stringify(payload),
-        modelId,
-      });
-      const apiResponse = await client.send(command);
-    
-      // Decode and return the response(s).
-      const decodedResponseBody = new TextDecoder().decode(apiResponse.body);
-      /** @type {ResponseBody} */
-      const responseBody = JSON.parse(decodedResponseBody);
-      return responseBody.completions[0].data.text;
-    };
-    
-    // Invoke the function if this file was run directly.
-    if (process.argv[1] === fileURLToPath(import.meta.url)) {
-      const prompt =
-        'Complete the following in one sentence: "Once upon a time..."';
-      const modelId = FoundationModels.JURASSIC2_MID.modelId;
-      console.log(`Prompt: ${prompt}`);
-      console.log(`Model ID: ${modelId}`);
-    
-      try {
-        console.log("-".repeat(53));
-        const response = await invokeModel(prompt, modelId);
-        console.log(response);
-      } catch (err) {
-        console.log(err);
-      }
-    }
-    
-    
-
-  * For API details, see [InvokeModel](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/InvokeModelCommand) in _AWS SDK for JavaScript API Reference_. 
-
-
-
-