How do I have multiple models when using a custom provider? #2197
Replies: 2 comments
-
|
Did you find anything on how to do this? |
Beta Was this translation helpful? Give feedback.
-
|
Just wanted to share that I found a way to do this, I feel it's kynda hacky but it worked for me. local function retrieve_openrouter_models()
local openrouter_key = os.getenv(openrouter_key_env)
-- Use plenary's curl to make HTTP request
local curl = require('plenary.curl')
-- Make synchronous GET request to /models endpoint
local response = curl.get(openrouter_endpoint .. '/models', {
headers = {
['Authorization'] = 'Bearer ' .. openrouter_key,
['Content-Type'] = 'application/json',
},
accept = 'application/json',
})
-- Parse the JSON response
if response.status ~= 200 then
vim.notify('Failed to retrieve OpenRouter models: ' .. response.status, vim.log.levels.ERROR)
return {}
end
local ok, data = pcall(vim.fn.json_decode, response.body)
if not ok then
vim.notify('Failed to parse OpenRouter models response', vim.log.levels.ERROR)
return {}
end
-- Extract model names from the response
local models = {}
if data.data then
for _, model in ipairs(data.data) do
table.insert(models, model.id)
end
end
return models
endAnd then inside my opts I call this function to populate the field Hope this helps anyone that may find this |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I define a proxy to OpenAI like so (this is internal to where I work for model usage e.t.c)
But this only has
gpt-4oas an available model, I'd like the ability to switch between all the models openai (and claude) provide.I'd also like to disable other providers
Beta Was this translation helpful? Give feedback.
All reactions