Spaces:
Sleeping
Sleeping
import requests | |
import json | |
import os | |
api_key = os.getenv('GROQ_API_KEY') | |
url = "https://api.groq.com/openai/v1/chat/completions" | |
payload = json.dumps({ | |
"messages": [ | |
{ | |
"role": "user", | |
"content": [ | |
{ | |
"type": "text", | |
"text": "What's in this image?" | |
}, | |
{ | |
"type": "image_url", | |
"image_url": { | |
"url": "https://upload.wikimedia.org/wikipedia/commons/f/f2/LPU-v1-die.jpg" | |
} | |
} | |
] | |
} | |
], | |
"model": "meta-llama/llama-4-scout-17b-16e-instruct", | |
"temperature": 1, | |
"max_completion_tokens": 1024, | |
"top_p": 1, | |
"stream": False, | |
"stop": None | |
}) | |
headers = { | |
'Content-Type': 'application/json', | |
'Authorization': f'Bearer {api_key}' | |
} | |
response = requests.request("POST", url, headers=headers, data=payload) | |
print(response.text) | |