File size: 849 Bytes
1a86107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)