Examples
Upload a File (PDF, images)
1 import requests 2 from typing import List, Dict, Any 3 4 def extract_data(api_key: str, file_paths: List[str], prompt: str) -> Dict[str, Any]: 5 url = "https://api2.boundaryml.com/v3/extract" 6 headers = { 7 "Authorization": f"Bearer {api_key}" 8 } 9 files = [('files', open(file_path, 'rb')) for file_path in file_paths] 10 data = { 11 'prompt': prompt 12 } 13 response = requests.post(url, headers=headers, files=files, data=data) 14 response.raise_for_status() 15 return response.json() 16 17 # Usage example 18 api_key = 'your_api_key_here' 19 file_paths = ['path/to/file1.pdf', 'path/to/file2.png'] 20 prompt = 'Please extract the text content.' 21 22 result = extract_data(api_key, file_paths, prompt) 23 print(result)