bug: Unsupported parameter 'max_tokens' when using o1 and o3-mini
Describe the bug
It returns an error indicating that max_tokens is unsupported parameter for the current model (o1 or o3-mini) and that max_completion_tokens should be used instead; when explicitly specifying max_completion_tokens in the configuration.
To reproduce
Just by typing any prompt you get the following output:
Error: "API request failed with status 400. Body: \"{\\n \\\"error\\\": {\\n \\\"message\\\": \\\"Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.\\\",\\n \\\"type\\\": \\\"invalid_request_error\\\",\\n \\\"param\\\": \\\"max_tokens\\\",\\n \\\"code\\\": \\\"unsupported_parameter\\\"\\n }\\n}\""
Expected behavior
It should return the response without any errors.
Installation method
Use lazy.nvim (Lazyvim.org):
return {
"yetone/avante.nvim",
event = "VeryLazy",
version = false, -- Never set this value to "*"! Never!
opts = {
-- add any opts here
-- for example
provider = "openai",
openai = {
endpoint = "https://api.openai.com/v1",
model = "o3-mini", -- your desired model (or use gpt-4o, etc.)
timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models
temperature = 0.1,
max_completion_tokens = 30000, -- Increase this to include reasoning tokens (for reasoning models)
reasoning_effort = "high", -- low|medium|high, only used for reasoning models
},
vendors = {
-- Available
-- Available
openai_o1_pro = {
__inherited_from = "openai",
model = "o1-pro",
},
-- Available
openai_o3_mini = {
__inherited_from = "openai",
model = "o3-mini",
},
},
rag_service = {
enabled = true, -- Enables the RAG service
host_mount = os.getenv("HOME"), -- Host mount path for the rag service
provider = "openai", -- The provider to use for RAG service (e.g. openai or ollama)
llm_model = "", -- The LLM model to use for RAG service
embed_model = "", -- The embedding model to use for RAG service
endpoint = "https://api.openai.com/v1", -- The API endpoint for RAG service
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
"nvim-treesitter/nvim-treesitter",
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
--- The below dependencies are optional,
"echasnovski/mini.pick", -- for file_selector provider mini.pick
"nvim-telescope/telescope.nvim", -- for file_selector provider telescope
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
"ibhagwan/fzf-lua", -- for file_selector provider fzf
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"zbirenbaum/copilot.lua", -- for providers='copilot'
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
{
-- Make sure to set this up properly if you have lazy=true
"MeanderingProgrammer/render-markdown.nvim",
opts = {
file_types = { "markdown", "Avante" },
},
ft = { "markdown", "Avante" },
},
},
}
Environment
neovim version: v0.11.0 distribution: LazyVim platform: macOS Sequoia 15.3.2 (M1 Max)
Repro
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
-- add any other plugins here
},
})
same
+1 When using the reasoning models, the API fails no matter if you put max_completion_tokens or max_tokens in the config.
I opened a PR with a fix: https://github.com/yetone/avante.nvim/pull/1819
It's broken again after the revert: https://github.com/yetone/avante.nvim/pull/1839