Prerequisites
- A Paradigm API key: if you do not have one, go to your Paradigm profile (
/settings/api-key
in your instance) and generate a new API key.
- The desired document to upload: The file to upload cannot have a size above 100MB.
Ensure your documents don’t contain sensitive information that shouldn’t be processed by the AI. All uploaded documents are processed and indexed for search capabilities.
For better search and retrieval performance, use descriptive filenames and consider splitting very large documents into smaller, topic-focused sections.
Usage methods
There are several ways to call the endpoint:
- With the python
requests
package
- Through a curl request: for quick testing or first-time use
The Paradigm API key and base URL are configured using environment variables.
For private instances, set PARADIGM_BASE_URL
to your instance’s URL. See Instance Configuration for details.
Python requests
package
You can send request to the API endpoint through the requests
package.
import requests
import os
# Get API key and base URL from environment
api_key = os.getenv("PARADIGM_API_KEY")
base_url = os.getenv("PARADIGM_BASE_URL", "https://paradigm.lighton.ai/api/v2")
# Path of the file to upload
file_path = "/path/to/test_upload_file.pdf"
response = requests.request(
method="POST",
url=f"{base_url}/files",
headers={
'Authorization': f"Bearer {api_key}"
},
data={"purpose": "documents"},
files={
"file": open(file_path, "rb"),
}
)
print(response.json())
You would then get a JSON answer as a dictionary:
{
"id": 1,
"object": "file",
"bytes": 9626,
"created_at": 1714659874,
"filename": "test_upload_file.pdf",
"purpose": "documents",
"status": "success"
}
cURL request
If you would prefer sending a request to Paradigm with a simple cURL command, here is an example:
curl $PARADIGM_BASE_URL/files \
-H "Authorization: Bearer $PARADIGM_API_KEY" \
-F purpose="documents" \
-F file="@/path/to/test_upload_file.pdf"