AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-10-10 · Documentation low

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

Summary

Removed multiple code examples demonstrating Amazon Bedrock runtime operations (InvokeModel, Converse, streaming responses) for Titan Text and Cohere Command models

Security assessment

The changes remove general API usage examples but contain no references to security vulnerabilities, mitigations, or security feature enhancements. The deleted content demonstrated normal service operations without security-specific configurations or warnings.

Diff

diff --git a/code-library/latest/ug/python_3_bedrock-runtime_code_examples.md b/code-library/latest/ug/python_3_bedrock-runtime_code_examples.md
index 0ea5df52f..5ccc02d16 100644
--- a//code-library/latest/ug/python_3_bedrock-runtime_code_examples.md
+++ b//code-library/latest/ug/python_3_bedrock-runtime_code_examples.md
@@ -17,182 +16,0 @@ Each example includes a link to the complete source code, where you can find ins
-**Get started**
-
-The following code examples show how to get started using Amazon Bedrock.
-
-**SDK for Python (Boto3)**
-    
-
-###### 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/python/example_code/bedrock-runtime#code-examples). 
-
-Send a prompt to a model with the InvokeModel operation.
-    
-    
-    """
-    Uses the Amazon Bedrock runtime client InvokeModel operation to send a prompt to a model.
-    """
-    import logging
-    import json
-    import boto3
-    
-    
-    from botocore.exceptions import ClientError
-    
-    
-    logging.basicConfig(level=logging.INFO)
-    logger = logging.getLogger(__name__)
-    
-    
-    def invoke_model(brt, model_id, prompt):
-        """
-        Invokes the specified model with the supplied prompt.
-        param brt: A bedrock runtime boto3 client
-        param model_id: The model ID for the model that you want to use.
-        param prompt: The prompt that you want to send to the model.
-    
-        :return: The text response from the model.
-        """
-    
-        # Format the request payload using the model's native structure.
-        native_request = {
-            "inputText": prompt,
-            "textGenerationConfig": {
-                "maxTokenCount": 512,
-                "temperature": 0.5,
-                "topP": 0.9
-            }
-        }
-    
-        # Convert the native request to JSON.
-        request = json.dumps(native_request)
-    
-        try:
-            # Invoke the model with the request.
-            response = brt.invoke_model(modelId=model_id, body=request)
-    
-            # Decode the response body.
-            model_response = json.loads(response["body"].read())
-    
-            # Extract and print the response text.
-            response_text = model_response["results"][0]["outputText"]
-            return response_text
-    
-        except (ClientError, Exception) as e:
-            print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
-            raise
-    
-    
-    def main():
-        """Entry point for the example. Uses the AWS SDK for Python (Boto3)
-        to create an Amazon Bedrock runtime client. Then sends a prompt to a model
-        in the region set in the callers profile and credentials.
-        """
-    
-        # Create an Amazon Bedrock Runtime client.
-        brt = boto3.client("bedrock-runtime")
-    
-        # Set the model ID, e.g., Amazon Titan Text G1 - Express.
-        model_id = "amazon.titan-text-express-v1"
-    
-        # Define the prompt for the model.
-        prompt = "Describe the purpose of a 'hello world' program in one line."
-    
-        # Send the prompt to the model.
-        response = invoke_model(brt, model_id, prompt)
-    
-        print(f"Response: {response}")
-    
-        logger.info("Done.")
-    
-    
-    if __name__ == "__main__":
-        main()
-    
-    
-    
-
-Send a user message to a model with the Converse operation.
-    
-    
-    """
-    Uses the Amazon Bedrock runtime client Converse operation to send a user message to a model.
-    """
-    import logging
-    import boto3
-    
-    from botocore.exceptions import ClientError
-    
-    
-    logging.basicConfig(level=logging.INFO)
-    logger = logging.getLogger(__name__)
-    
-    
-    def converse(brt, model_id, user_message):
-        """
-        Uses the Converse operation to send a user message to the supplied model.
-        param brt: A bedrock runtime boto3 client
-        param model_id: The model ID for the model that you want to use.
-        param user message: The user message that you want to send to the model.
-    
-        :return: The text response from the model.
-        """
-    
-        # Format the request payload using the model's native structure.
-        conversation = [
-        {
-            "role": "user",
-            "content": [{"text": user_message}],
-        }
-    ]
-    
-        try:
-            # Send the message to the model, using a basic inference configuration.
-            response = brt.converse(
-                modelId=model_id,
-                messages=conversation,
-                inferenceConfig={"maxTokens": 512, "temperature": 0.5, "topP": 0.9},
-            )
-    
-            # Extract and print the response text.
-            response_text = response["output"]["message"]["content"][0]["text"]
-            return response_text
-    
-        except (ClientError, Exception) as e:
-            print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
-            raise
-    
-    
-    def main():
-        """Entry point for the example. Uses the AWS SDK for Python (Boto3)
-        to create an Amazon Bedrock runtime client. Then sends a user message to a model
-        in the region set in the callers profile and credentials.
-        """
-    
-        # Create an Amazon Bedrock Runtime client.
-        brt = boto3.client("bedrock-runtime")
-    
-        # Set the model ID, e.g., Amazon Titan Text G1 - Express.
-        model_id = "amazon.titan-text-express-v1"
-    
-        # Define the message for the model.
-        message = "Describe the purpose of a 'hello world' program in one line."
-    
-        # Send the message to the model.
-        response = converse(brt, model_id, message)
-    
-        print(f"Response: {response}")
-    
-        logger.info("Done.")
-    
-    
-    if __name__ == "__main__":
-        main()
-    
-    
-    
-
-  * For API details, see [InvokeModel](https://docs.aws.amazon.com/goto/boto3/bedrock-runtime-2023-09-30/InvokeModel) in _AWS SDK for Python (Boto3) API Reference_. 
-
-
-
-
@@ -1339,115 +1156,0 @@ Create an image with the Amazon Titan Image Generator.
-The following code example shows how to send a text message to Amazon Titan Text, using Bedrock's Converse API.
-
-**SDK for Python (Boto3)**
-    
-
-###### 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/python/example_code/bedrock-runtime#code-examples). 
-
-Send a text message to Amazon Titan Text, using Bedrock's Converse API.
-    
-