Q: Can it connect to openrouter to use different ai image models?

Wei_Sheng
May 8, 2025A: Hi yes, you can connect to OpenRouter to use different AI image models with our =API() formula. The OpenRouter API allows you to interact with various AI models using a consistent request format similar to the OpenAI Chat API.
To get started, you'll need to obtain an API key from OpenRouter. Once you have your API key, you can create requests to the OpenRouter API endpoint, specifically to /api/v1/chat/completions for generating model responses.
Here's an example of how to structure your request using the =API() formula in Google Sheets:
=API("POST", "https://openrouter.ai/api/v1/chat/completions", {
"headers": {
"Authorization": "Bearer <YOUR_OPENROUTER_API_KEY>",
"Content-Type": "application/json"
},
"body": JSON.stringify({
"model": "your_selected_model",
"messages": [{
"role": "user",
"content": "What image would you like to generate?"
}]
})
})
Make sure to replace <YOUR_OPENROUTER_API_KEY> with your actual key and define "your_selected_model" according to the models available in OpenRouter. Remember to check the OpenRouter API documentation for a complete list of supported models and parameters you can use in your requests.
Here to get Openrouter API key https://openrouter.ai/keys
This setup should enable you to generate images and other content as needed from various AI models available through OpenRouter. If you need further assistance, feel free to ask!