IMAGE_URL to an HTTPS image that the model provider can fetch, then send text and image content in the same user message.
curl https://api.yelu.ai/v1/chat/completions \
-H "Authorization: Bearer $YELU_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"Return a concise alt-text description.\"},{\"type\":\"image_url\",\"image_url\":{\"url\":\"$IMAGE_URL\",\"detail\":\"auto\"}}]}],\"max_completion_tokens\":120}"
const response = await fetch('https://api.yelu.ai/v1/chat/completions', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.YELU_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'Return a concise alt-text description.' },
{ type: 'image_url', image_url: { url: process.env.IMAGE_URL, detail: 'auto' } },
],
}],
max_completion_tokens: 120,
}),
});
if (!response.ok) throw new Error(await response.text());
console.log((await response.json()).choices[0].message.content);
import os
import requests
response = requests.post(
"https://api.yelu.ai/v1/chat/completions",
headers={"Authorization": f"Bearer {os.environ['YELU_API_KEY']}"},
json={
"model": "gpt-4o-mini",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Return a concise alt-text description."},
{"type": "image_url", "image_url": {"url": os.environ["IMAGE_URL"], "detail": "auto"}},
],
}],
"max_completion_tokens": 120,
},
timeout=120,
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])
Validate user-supplied URLs against SSRF, size, and media-type rules before forwarding them. Use signed URLs with short expiry for private images.