Skip to content

Bug: 400 Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. #1251

@bitsnaps

Description

@bitsnaps

Issue Description

Hi

Some AI providers (including OpenAI) are deprecating the max_tokens parameter they use max_completion_tokensinstead, here is the error I get:

{
    "success": false,
    "error": {
        "delegate": "openai-completion",
        "message": "Error 400 from delegate `openai-completion`: 400 Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.",
        "code": "error_400_from_delegate",
        "$": "heyputer:api/APIError",
        "status": 400
    }
}

Query:

fetch("https://api.puter.com/drivers/call", {
  "headers": {
    "accept": "*/*",
    "authorization": `Bearer ${TOKEN}`,
    "content-type": "application/json;charset=UTF-8"
  },
  "body": "{\"interface\":\"puter-chat-completion\",\"driver\":\"openai-completion\",\"test_mode\":false,\"method\":\"complete\",\"args\":{\"messages\":[{\"role\":\"system\",\"content\":\"You are a helpful assistant.\",\"editing\":false},{\"role\":\"user\",\"content\":\"What is life?\"}],\"model\":\"o3\",\"temperature\":0.7,\"max_tokens\":2000,\"stream\":true}}",
  "method": "POST"
});

The weird thing is that it works with some models, I couldn't find the exact root cause (It could be when adding all the parameters for some type of models like o3), but that script is end up with error too frequently for some reason.

Steps to reproduce

Execute the previous script raise the previous error every time in my instance.

Expected behaviour

Output the response.

Addition Information or Screenshots (if applicable)

No response

Deployment

  • Production (puter.com)
  • Development (npm run start)
  • Docker (via docker run)
  • Docker (via docker-compose)

Puter version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood contributionIssues that benefit all Puter users, and can be completed in one or two weekends

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions