Adapters for codecompanion #979
-
|
I'm really struggling to get codecompanion running with openrouter.ai. I have tried a couple of approaches, but I think the best way should be to define setupOpts.adapters. I am not good enough with lua to troubleshoot the missing } error that I'm getting. If anyone could point me towards a working example? My current config is setupOpts.adapter = lib.generators.mkLuaInline ''
openrouter_claude = function()
return require("codecompanion.adapters").extend("openai_compatible", {
env = {
url = "https://openrouter.ai/api",
api_key = "OPENROUTER_API_KEY",
chat_url = "/v1/chat/completions",
},
schema = {
model = {
default = "anthropic/claude-3.7-sonnet",
},
},
})
''; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
luaInline options should be lua expressions: setupOpts.adapter.openrouter_claude = lib.generators.mkLuaInline ''
function()
return require("codecompanion.adapters").extend("openai_compatible", { env = { url = "https://openrouter.ai/api", api_key = "OPENROUTER_API_KEY", chat_url = "/v1/chat/completions", }, schema = { model = { default = "anthropic/claude-3.7-sonnet", }, }, })
end
'';(forgive the atrocious indentation, github mobile sucks) |
Beta Was this translation helpful? Give feedback.
-
codecompanion-nvim = {
enable = true;
setupOpts.adapters = lib.generators.mkLuaInline ''
{
openrouter_claude = function()
return require("codecompanion.adapters").extend("openai_compatible", { env = { url = "https://openrouter.ai/api", api_key = "OPENROUTER_API_KEY", chat_url = "/v1/chat/completions", }, schema = { model = { default = "anthropic/claude-4-sonnet", }, }, })
end
}
'';
setupOpts.strategies.chat.adapter = "openrouter_claude";
};sorry, |
Beta Was this translation helpful? Give feedback.
sorry,
adaptershas kind of a weird type, this should work