Skip to content

Instantly share code, notes, and snippets.

@thornewolf
Last active March 8, 2024 18:01
Show Gist options
  • Select an option

  • Save thornewolf/01e3652b8355192b2d73c3e623006e9e to your computer and use it in GitHub Desktop.

Select an option

Save thornewolf/01e3652b8355192b2d73c3e623006e9e to your computer and use it in GitHub Desktop.
Product Studio TiDe API Example
import requests
import pprint
API_KEY = 'YOUR-API-KEY' # @param {type: "string"}
PROJECT = 'YOUR-GCP-PROJECT' # @param {type: "string"}
URI = f'https://productstudio.googleapis.com/v1/projects/{PROJECT}'
API_ENDPOINT = f'{URI}:generateProductText'
title = 'Matching Shirt and Shorts pajama set' # @param {type: "string"}
description = 'This Mr. Beast brand purple shirt and shorts set is perfect for a casual day at the movies. Size M. This is a day-to-day outfit that you can wear out looking well put together, yet still casual. Get a few sets to share with your friends!' # @param {type: "string"}
optional_image_url = '' # @param {type: "string"}
payload = {}
payload |= {'output_spec': {'workflow_id': 'tide'}}
payload |= {'product_info':{'product_attributes': {'title': title, 'description': description, 'brand': 'Mr. Beast', 'color': 'purple'}}}
if optional_image_url:
payload['product_info'] |= {'product_image':{'uri':optional_image_url}}
response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
pprint.pprint(payload)
print(response.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment