diff --git a/anthropic_api_fundamentals/06_vision.ipynb b/anthropic_api_fundamentals/06_vision.ipynb index dc0f5018..a801ca3e 100644 --- a/anthropic_api_fundamentals/06_vision.ipynb +++ b/anthropic_api_fundamentals/06_vision.ipynb @@ -965,9 +965,11 @@ "import base64\n", "import httpx\n", "\n", + "HEADERS = {\"User-Agent\": \"AnthropicCoursesBot/1.0 (https://github.com/anthropics/courses)\"}\n", + "\n", "image_url = \"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Church_of_light.jpg/1599px-Church_of_light.jpg\"\n", "image_media_type = \"image/jpeg\"\n", - "image_data = base64.b64encode(httpx.get(image_url).content).decode(\"utf-8\")\n", + "image_data = base64.b64encode(httpx.get(image_url, headers=HEADERS).content).decode(\"utf-8\")\n", "\n", "messages=[\n", " {\n", @@ -1034,7 +1036,7 @@ "\n", "def get_image_dict_from_url(image_url):\n", " # Send a GET request to the image URL and retrieve the content\n", - " response = httpx.get(image_url)\n", + " response = httpx.get(image_url, headers=HEADERS)\n", " image_content = response.content\n", "\n", " # Determine the media type of the image based on the URL extension\n",