Parse all documents in a folder by iterating through files and calling the parse API for each supported file type.
These examples require the Python or TypeScript client library. Before running a script, set your API key and install the library and any required dependencies.
from pathlib import Pathfrom landingai_ade import LandingAIADE# Initialize client (uses the API key from the VISION_AGENT_API_KEY environment variable)client = LandingAIADE()# Replace "data/" with your folder pathdata_folder = Path("data/")for filepath in data_folder.glob("*"): # Adjust file types as needed for your use case if filepath.suffix.lower() in ['.pdf', '.png', '.jpg', '.jpeg']: print(f"Processing: {filepath.name}") response = client.parse( document=filepath, model="dpt-2-latest" ) print(response.chunks) # Save markdown output (useful if you plan to run extract on the markdown) output_md = filepath.stem + ".md" with open(output_md, "w", encoding="utf-8") as f: f.write(response.markdown)