Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions anthropic_api_fundamentals/06_vision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down