...
取得 User API key:
點選達哥面板左下角的
Settings
按鈕點選
Assistant API Key
後,點選+ API Key
按鈕新增複製
API Key
取得 Assistant ID:
選取欲 preview 的 Assistant,點選
Setting
按鈕選取
Advanced
tab,複製Assistant ID
Demo
Text:
Image:
替換掉對應的
API_KEY
與ASSISTANT_ID
在輸入框輸入 image url 即可
如果您想要使用本機影像,您可以使用下列 Python 程式碼將它轉換成 base64,以便將其傳遞至 API。 或者您可以使用線上工具將影像檔轉成 base64。
程式碼區塊 language py import base64 from mimetypes import guess_type # Function to encode a local image into data URL def local_image_to_data_url(image_path): # Guess the MIME type of the image based on the file extension mime_type, _ = guess_type(image_path) if mime_type is None: mime_type = 'application/octet-stream' # Default MIME type if none is found # Read and encode the image file with open(image_path, "rb") as image_file: base64_encoded_data = base64.b64encode(image_file.read()).decode('utf-8') # Construct the data URL return f"data:{mime_type};base64,{base64_encoded_data}" # Example usage image_path = '<path_to_image>' data_url = local_image_to_data_url(image_path) print("Data URL:", data_url)
...