Код: Выделить всё
function openRouterApiRequest() {
var apiKey = "****";
// var imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg';
var imageUrl = "https://drive.google.com/file/d/11178UwHmPb2TAnYCyxFOKXlPh-vSPecv/view?usp=sharing";
var apiEndpoint = 'https://openrouter.ai/api/v1/chat/completions';
var payload = {
"model": "meta-llama/llama-4-maverick",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": imageUrl
}
}
]
}
]
};
var options = {
'method': 'post',
'headers': {
'Authorization': 'Bearer ' + apiKey,
'Content-Type': 'application/json'
},
'payload': JSON.stringify(payload),
'muteHttpExceptions': true // To get the response even if the request fails
};
var response = UrlFetchApp.fetch(apiEndpoint, options);
var responseCode = response.getResponseCode();
var responseBody = response.getContentText();
// Handle the response as needed
Logger.log('Response Code: ' + responseCode);
Logger.log('Response Body: ' + responseBody);
// You might want to parse the responseBody if it's JSON
try {
var jsonResponse = JSON.parse(responseBody);
Logger.log(jsonResponse);
} catch (e) {
Logger.log('Failed to parse response as JSON: ' + e.message);
}
}
< /code>
Если я не пострял: < /p>
var imageUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg';
Я получаю: {«Ошибка»: {«Сообщение»: «Провер-обратный код», «код»: 502, »,« Metadata »: {{:« СОСТОЯНИЕ »:« СОСТОЯНИЕ »:« СОСТОЯНИЕ ». , Сообщение: неверный символ 'i' Ищу начало значения, Body: "," Provider_name ":" novita "}}," user_id ":" user_2i6mrzmhamlwptyrltp5urwhsyx "} < /p>
Похоже, что это не читается LLM. Есть ли способ сделать его читаемым?
Подробнее здесь: https://stackoverflow.com/questions/795 ... imodal-llm
Мобильная версия