from google import genai from google.genai import types import pathlib import httpx client = genai.Client() doc_url = "https://discovery.ucl.ac.uk/id/eprint/10089234/1/343019_3_art_0_py4t4l_convrt.pdf" # Replace with the actual URL of your PDF # Retrieve and encode the PDF byte filepath = pathlib.Path('file.pdf') filepath.write_bytes(httpx.get(doc_url).content) prompt = "Summarize this document" response = client.models.generate_content( model="gemini-1.5-flash", contents=[ types.Part.from_bytes( data=filepath.read_bytes(), mime_type='application/pdf', ), prompt]) print(response.text)