Skip to content

instructions for running reviews with llama #3

@ewhittakerwalker

Description

@ewhittakerwalker

import os
import requests
import base64
from io import BytesIO
from PIL import Image

OPENROUTER_API_KEY = os.getenv('OPENROUTER_API_KEY')
OPENROUTER_API_BASE = os.getenv('OPENROUTER_API_BASE', 'https://openrouter.ai/api/v1')

MODELS = [
'meta-llama/llama-4-maverick',
'meta-llama/llama-4-scout'
]

Create a simple black square PNG in memory

img = Image.new('RGB', (128, 128), color='black')
buf = BytesIO()
img.save(buf, format='PNG')
image_bytes = buf.getvalue()
image_b64 = base64.b64encode(image_bytes).decode('utf-8')

prompt = 'What is in this image?'

for model in MODELS:
print(f'\nTesting model: {model}')
url = f"{OPENROUTER_API_BASE}/chat/completions"
headers = {
"Authorization": f"Bearer {OPENROUTER_API_KEY}",
"Content-Type": "application/json"
}
data = {
"model": model,
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": prompt},
{"type": "image_url", "image_url": f"data:image/png;base64,{image_b64}"}
]
}
],
"max_tokens": 128,
"temperature": 0.2
}
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print('Response:', result['choices'][0]['message']['content'])
except Exception as e:
print('Error:', e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions