Skip to content

Fix Wikimedia image fetching by adding User-Agent header#140

Open
gersonazgo wants to merge 1 commit intoanthropics:masterfrom
gersonazgo:fix/wikimedia-user-agent
Open

Fix Wikimedia image fetching by adding User-Agent header#140
gersonazgo wants to merge 1 commit intoanthropics:masterfrom
gersonazgo:fix/wikimedia-user-agent

Conversation

@gersonazgo
Copy link
Copy Markdown

Summary

  • Wikimedia Commons returns 403 for requests without a User-Agent header, causing the vision notebook's URL-based image fetching to fail with BadRequestError
  • Added a HEADERS constant with a descriptive User-Agent string and passed it to all httpx.get() calls that fetch remote images in 06_vision.ipynb

Test plan

  • Restart kernel and run all cells in courses/anthropic_api_fundamentals/06_vision.ipynb
  • Verify cells that fetch images from URLs succeed without 403 errors
  • Confirm Claude returns valid image descriptions for URL-sourced images

🤖 Generated with Claude Code

Wikimedia Commons returns 403 for requests without a User-Agent header,
causing base64-encoded error pages instead of images. Add HEADERS constant
and pass it to all httpx.get() calls that fetch remote images.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant