Connect Neovim (avante.nvim & codecompanion.nvim) to byesu API
Key Takeaways
avante.nvimnative Claude (0.1xcache reads): Setproviders.claude = { endpoint = "https://byesu.com", model = "claude-sonnet-5-5", api_key_name = "BYESU_API_KEY" }(without/v1).avante.nvimOpenAI-compatible (providers/vendors): Inherit from"openai"withendpoint = "https://byesu.com/v1"forgpt-6.2-sol,deepseek-v4-pro, andgemini-4-argon.codecompanion.nvimHTTP adapters: Extend"anthropic"withurl = "https://byesu.com/v1/messages", and extend"openai_compatible"withenv = { url = "https://byesu.com", chat_url = "/v1/chat/completions", api_key = "BYESU_API_KEY" }.- One key, pay-as-you-go: A single default
autogroupsk-...key unlocks Claude 5.5, GPT-6.2, Gemini 4, and DeepSeek V4 at a fraction of list rates, funded via USDT or Alipay.
Neovim pairs sub-millisecond modal editing with two standout AI plugins: avante.nvim (Cursor-style sidebar diffs and inline buffer patching) and codecompanion.nvim (buffer-native chat, slash commands, MCP tools, and inline transformations). Connecting either plugin to byesu gives you native Anthropic /v1/messages (0.1x prompt caching) alongside /v1/chat/completions inside clean lazy.nvim Lua specs.
Exact URL matrix across Neovim plugins
| Plugin & Adapter | Exact Endpoint / URL Config | Wire Protocol |
|---|---|---|
avante.nvim (providers.claude) | endpoint = "https://byesu.com" (no /v1) | Native /v1/messages + 0.1x cache |
avante.nvim (__inherited_from = "openai") | endpoint = "https://byesu.com/v1" (or custom vendors) | OpenAI /v1/chat/completions |
codecompanion.nvim (extend("anthropic")) | url = "https://byesu.com/v1/messages" | Native /v1/messages + 0.1x cache |
codecompanion.nvim (extend("openai_compatible")) | url = "https://byesu.com" + chat_url = "/v1/chat/completions" | OpenAI /v1/chat/completions |
Step 0: Export BYESU_API_KEY & Run the 5-Second Smoke Test
Create an sk-... token in the byesu Console under the default auto group (Quickstart), export BYESU_API_KEY in ~/.zshrc or ~/.bashrc so Neovim never stores plaintext secrets in your dotfiles repo, and run the 5-second smoke test:
export BYESU_API_KEY="sk-your-byesu-token"
curl -fsSL https://docs.byesu.com/setup/test.sh | sh(Non-interactive shells: BYESU_KEY="$BYESU_API_KEY" curl -fsSL https://docs.byesu.com/setup/test.sh | bash.) You can also generate custom Lua blocks in the Client & SDK Config Generator.
Setup 1: avante.nvim (lazy.nvim Complete Lua Spec)
Save the spec below to ~/.config/nvim/lua/plugins/avante.lua. It wires claude-sonnet-5-5 as your default native Anthropic sidebar engine (0.1x cached reads) while registering claude-opus-5-5, gpt-6.2-sol, and deepseek-v4-pro for instant :AvanteSwitchProvider switching:
-- ~/.config/nvim/lua/plugins/avante.lua
return {
"yetone/avante.nvim",
event = "VeryLazy",
version = false,
build = "make",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons",
},
opts = {
provider = "claude",
providers = {
-- 1. Native Anthropic (/v1/messages appended automatically — NO /v1 suffix!)
claude = {
endpoint = "https://byesu.com",
model = "claude-sonnet-5-5",
api_key_name = "BYESU_API_KEY",
timeout = 120000,
extra_request_body = {
max_tokens = 24000,
},
},
-- 2. Claude Opus 5.5 for multi-file architecture & deep reasoning
byesu_opus = {
__inherited_from = "claude",
endpoint = "https://byesu.com",
model = "claude-opus-5-5",
api_key_name = "BYESU_API_KEY",
timeout = 180000,
extra_request_body = {
max_tokens = 32000,
},
},
-- 3. OpenAI-compatible GPT-6.2 Sol (includes /v1)
byesu_gpt = {
__inherited_from = "openai",
endpoint = "https://byesu.com/v1",
model = "gpt-6.2-sol",
api_key_name = "BYESU_API_KEY",
timeout = 180000,
extra_request_body = {
max_completion_tokens = 32768,
},
},
-- 4. High-throughput DeepSeek V4 Pro
byesu_deepseek = {
__inherited_from = "openai",
endpoint = "https://byesu.com/v1",
model = "deepseek-v4-pro",
api_key_name = "BYESU_API_KEY",
timeout = 120000,
extra_request_body = {
max_tokens = 16384,
},
},
},
},
}Using an older avante.nvim release (vendors table)?
Prior to avante.nvim's unified opts.providers migration, custom OpenAI-compatible entries lived under opts.vendors = { byesu_gpt = { __inherited_from = "openai", endpoint = "https://byesu.com/v1", model = "gpt-6.2-sol", api_key_name = "BYESU_API_KEY" } } (or raw vendor handlers pointing directly at "https://byesu.com/v1/chat/completions"). Run :Lazy update avante.nvim to use the unified opts.providers schema above.
Setup 2: codecompanion.nvim (lazy.nvim Complete Lua Spec)
Save the spec below to ~/.config/nvim/lua/plugins/codecompanion.lua. It configures both the native anthropic HTTP adapter (for 0.1x cached Claude buffers) and openai_compatible (for GPT-6.2, DeepSeek V4, and Gemini 4):
-- ~/.config/nvim/lua/plugins/codecompanion.lua
return {
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
opts = function()
local adapters = require("codecompanion.adapters")
return {
strategies = {
chat = { adapter = "byesu_claude" },
inline = { adapter = "byesu_claude" },
cmd = { adapter = "byesu_openai" },
},
adapters = {
http = {
-- Native Anthropic /v1/messages adapter (preserves 0.1x prompt cache reads)
byesu_claude = function()
return adapters.http.extend("anthropic", {
url = "https://byesu.com/v1/messages",
env = {
api_key = "BYESU_API_KEY",
},
schema = {
model = {
default = "claude-sonnet-5-5",
choices = {
"claude-sonnet-5-5",
"claude-opus-5-5",
"claude-haiku-5-5",
},
},
},
})
end,
-- OpenAI-compatible adapter for GPT-6.2, DeepSeek V4 & Gemini 4
byesu_openai = function()
return adapters.http.extend("openai_compatible", {
env = {
url = "https://byesu.com",
api_key = "BYESU_API_KEY",
chat_url = "/v1/chat/completions",
models_endpoint = "/v1/models",
},
schema = {
model = {
default = "gpt-6.2-sol",
choices = {
"gpt-6.2-sol",
"deepseek-v4-pro",
"deepseek-v4.1-flash",
"gemini-4-argon",
},
},
},
})
end,
},
},
}
end,
}(On older codecompanion.nvim versions prior to adapters.http, place byesu_claude and byesu_openai directly under adapters = { ... } and call adapters.extend(...).) Inside any :CodeCompanionChat buffer, press ga to swap adapters or models on the fly.
Common Neovim Pitfalls & Fixes
1. /v1 vs /v1/messages Endpoint Mismatch (HTTP 404)
- In
avante.nvim,providers.claudeappends/v1/messagesinternally — settingendpoint = "https://byesu.com/v1"hits/v1/v1/messages(404). Keependpoint = "https://byesu.com". - In
codecompanion.nvim,extend("anthropic", ...)expects the full pathurl = "https://byesu.com/v1/messages", whileextend("openai_compatible", ...)combinesenv.url("https://byesu.com") +env.chat_url("/v1/chat/completions"). See Claude 404 model/path fix.
2. max_tokens vs thinking Budget & temperature in avante.nvim (HTTP 400)
- Omit fixed
temperature: Olderavante.nvimconfigs passtemperature = 0insideextra_request_body. Claude 5.5 (2026-10-21) andgpt-6.2-solreject fixed sampling parameters with HTTP400(Claude 400 temperature fix). If an older Avante preset injectstemperature, settemperature = nilor upgradeavante.nvim. - Size
max_tokensabovethinking.budget_tokens: When enabling Claude thinking blocks (thinking = { type = "enabled", budget_tokens = 16000 }or adaptive thinking), Anthropic requiresmax_tokens > budget_tokens(for examplemax_tokens = 32000) — otherwise/v1/messagesrejects the call with HTTP400(Claude max_tokens fix).
3. 401 authentication_error When Launching Neovim from GUI / Tmux
- Confirm
:lua print(os.getenv("BYESU_API_KEY"))inside Neovim prints yoursk-...key — detachedtmuxsessions started before editing~/.zshrcwill not inherit new exports until sourced (Claude 401 fix). Top up your pay-as-you-go balance anytime via USDT or Alipay, and read Prompt Caching, Explained to maximize0.1xcached buffer reads.
FAQ
What endpoint URL should I set for Claude in avante.nvim vs codecompanion.nvim?
Set endpoint = "https://byesu.com" (no /v1) in avante.nvim's claude provider, and set url = "https://byesu.com/v1/messages" in codecompanion.nvim's anthropic adapter.
How do I add GPT-6.2 and DeepSeek V4 alongside Claude in avante.nvim?
Define entries under opts.providers with __inherited_from = "openai", endpoint = "https://byesu.com/v1", and api_key_name = "BYESU_API_KEY", then switch with :AvanteSwitchProvider.
Why does avante.nvim return HTTP 400 regarding temperature or max_tokens vs thinking budget?
Remove hardcoded temperature values for Claude 5.5 and GPT-6.2 reasoning models, and ensure max_tokens (24000–32000) strictly exceeds any thinking.budget_tokens value.
How do I configure codecompanion.nvim openai_compatible adapter for byesu?
Extend "openai_compatible" with env = { url = "https://byesu.com", api_key = "BYESU_API_KEY", chat_url = "/v1/chat/completions", models_endpoint = "/v1/models" }.