from chunkr_ai import Chunkr# Initialize the Chunkr client with your API key - get this from https://chunkr.aichunkr = Chunkr(api_key="your_api_key")# Upload a document via url or local file pathurl = "https://chunkr-web.s3.us-east-1.amazonaws.com/landing_page/input/science.pdf"task = chunkr.upload(url)
You can authenticate with the Chunkr AI API in two ways:
Direct API Key - Pass your API key directly when initializing the client
Environment Variable - Set CHUNKR_API_KEY in your .env file
You can also configure the API endpoint:
Direct URL - Pass your API URL when initializing the client
Environment Variable - Set CHUNKR_URL in your .env file
This is particularly useful if you’re running a self-hosted version of Chunkr.
Copy
Ask AI
from chunkr_ai import Chunkr# Option 1: Initialize with API key directlychunkr = Chunkr(api_key="your_api_key")# Option 2: Initialize without api_key parameter - will use CHUNKR_API_KEY from environmentchunkr = Chunkr()# Option 3: Configure custom API endpointchunkr = Chunkr(api_key="your_api_key", chunkr_url="http://localhost:8000")# Option 4: Use environment variables for both API key and URLchunkr = Chunkr() # will use CHUNKR_API_KEY and CHUNKR_URL from environment