Upload image

Published August 3, 2026

Introduction

This step will guide you on how to upload images for inference. After uploading the files, the PhenoNet platform will return the parameters file_path and task_id, which serve as an identifier for inference.

Request Description

  • API address: https://api.phenonet.org/api/v1/openapi/upload/
  • Request method: HTTPS POST
  • Return format: JSON
  • Content-Type: multipart/form-data
  • Headers: {"accessID": "{{STRING}}", "secretKey": "{{STRING}}"}
  • Body: {"file": "{{BINARY_STREAM}}"}

Parameter Description

parameter data type description value required
accessID string accessID is required when sending requests see Step I: Get AI&SK True
secretKey string secretKey is required when sending requests see Step I: Get AI&SK True
file binary stream File content binary stream, only a single image is allowed per uploading. - True

Response Description

json
{
  "code": "{{INTEGER}}",
  "msg": "{{STRING}}",
  "data": {
    "file_path": "{{STRING}}",
    "task_id": "{{STRING}}"
  }
}

Returned parameter description

parameter data type description
code integer state code
msg string reference information
data object returned content
file_path string file save path
task_id string task unique identification

Example Code

Python

python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests

ACCESS_ID = ''
SECRET_KEY = ''
HEADERS = {
    "accessID": ACCESS_ID,
    "secretKey": SECRET_KEY,
}

def upload_file(file_path, headers):
    url = "https://api.phenonet.org/api/v1/openapi/upload/"
    try:
        with open(file_path, 'rb') as image_file:
            response = requests.post(url, headers=headers, files={'file': image_file})
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as error:
        print(f"Error uploading file: {error}")
        return None

if __name__ == '__main__':
    result = upload_file('image.jpg', HEADERS)
    if result:
        print(result)

Error Code

code description
403 AI (Access ID) or SK (Secret Key) error