You’ll need the requests library for making HTTP requests and json for handling the response data.
import jsonimport requests
2
Configure your API request
Set up your payload with the prompt and optional parameters. Replace YOUR_API_KEY with your actual API key from the cloro dashboard.
# API parameterspayload = { 'prompt': 'Compare the top 3 programming languages for web development in 2025', 'country': 'US', 'include': { 'markdown': True, 'rawResponse': True, 'searchQueries': True }}# Get a responseresponse = requests.post( 'https://api.cloro.dev/v1/monitor/chatgpt', headers={'Authorization': 'Bearer YOUR_API_KEY'}, json=payload)
3
Handle the response
Process the API response by printing it to stdout or saving it to a file.
# Print response to stdoutprint(response.json())# Save response to a JSON filewith open('response.json', 'w') as file: json.dump(response.json(), file, indent=2)
import jsonimport requests# API parameterspayload = { 'prompt': 'Compare the top 3 programming languages for web development in 2025', 'country': 'US', 'include': { 'markdown': True, 'rawResponse': True, 'searchQueries': True }}# Get a responseresponse = requests.post( 'https://api.cloro.dev/v1/monitor/chatgpt', headers={'Authorization': 'Bearer YOUR_API_KEY'}, json=payload)# Print response to stdoutprint(response.json())# Save response to a JSON filewith open('response.json', 'w') as file: json.dump(response.json(), file, indent=2)
The API returns a JSON object with the following structure:
{ "status": "success", "result": { "model": "gpt-5-mini", "text": "When comparing programming languages for web development in 2025, three languages stand out...", "markdown": "**When comparing programming languages for web development in 2025**, three languages stand out...", "shoppingCards": [...], "searchQueries": ["web development languages 2025"], "rawResponse": [...] }}
You can access specific fields like this:
data = response.json()model = data['result']['model']text_response = data['result']['text']markdown_response = data['result']['markdown']
import json# Save the complete responsewith open('response.json', 'w') as file: json.dump(response.json(), file, indent=2)# Or save just the text responsedata = response.json()with open('chatgpt_response.txt', 'w') as file: file.write(data['result']['text'])