A Python application that demonstrates how to use Box AI to extract metadata from files in Box with a flexible string. This quickstart guide will walk you through these steps.
- Python 3.11+
- Box Developer Account
- Box App with appropriate permissions
-
Clone the repository
git clone https://github.com/box-community/box-quickstarts.git cd box-ai-freeform-extract-quickstart -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install python-dotenv "boxsdk>=10" -
Configure environment variables
cp .env.template .env
Edit
.envand add your values:BOX_DEVELOPER_TOKEN: Your Box developer tokenBOX_FILE_ID: ID of the file to extract metadata from
Run the extraction script:
python extract.pyThe script will:
- Authenticate with Box using your developer token
- Extract structured metadata from the specified file using Box AI
- Attach the extracted metadata to the file
- Create a Box App with
Client Credentials Grantauthentication - Ensure your app the following scopes:
Read all files and folders stored in BoxManage AI
- Upload a file to Box and note its file ID
freeform_extract.py- Main application script.env.template- Environment variables template.env- Your environment variables (not tracked in git).gitignore- Git ignore rules for Python projects