Upload a Custom Component with the REST API
Upload a custom component to Haystack Enterprise Platform using an API endpoint so that you can use it in your pipelines.
About This Task
Permissions
You must be an organization Admin to upload custom components to Haystack Enterprise Platform.
When you upload a component, we verify the structure and version of the uploaded ZIP file.
Prerequisites
- An API Key to connect to Haystack Enterprise Platform.
- A tested custom component that follows the linting and formatting conventions. You can use the
hatch run code-quality:allcommand to check the linting.
Upload the Component
- Zip the repository from the template folder. The zipped repository should contain the same files in the same hierarchy as the
dc-custom-component-templaterepository.
This command creates a ZIP file calledcustom_component.zipin the parent directory:- Linux and macOS
- Windows
zip -r ../custom_component.zip ./*Compress-Archive -Path .\* -DestinationPath ..\custom_component.zip -Force - Upload the ZIP file to Haystack Platform using the Import Custom Components endpoint. Here's a sample code you can use as a starting point for your request:
- cURL
- Python
curl --request POST \--url https://api.cloud.deepset.ai/api/v2/custom_components \--header 'accept: application/json' \--header 'Authorization: Bearer <YOUR_API_KEY>' \--form 'file=@"/path/to/custom/component/custom_component.zip";type=application/zip'import requestsurl = "https://api.cloud.deepset.ai/api/v2/custom_components"files = { "file": ("custom_component.zip", open("path/to/custom_component.zip", "rb"), "application/x-zip-compressed") }headers = {"accept": "application/json","authorization": "Bearer <YOUR_API_KEY>"}response = requests.post(url, files=files, headers=headers)print(response.text)
Related Information
Was this page helpful?