Skip to content

Conversation

@uchkw
Copy link
Contributor

@uchkw uchkw commented May 23, 2025

Overview

This pull request fixes an API parameter error that occurred when using o-series models (such as o3) with the official OpenAI API endpoint.

Background

Previously, when calling the OpenAI API with o-series models, the following error was returned:

- INFO - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 400 Bad Request"
- WARNING - Error on attempt 1/4: Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}. Retrying...

This was due to the use of the max_tokens parameter, which is not supported by these models. Instead, the API expects the max_completion_tokens parameter.

Fix Details

  • The code now checks if both the model name starts with "o" and the API base is https://api.openai.com/v1.
  • If so, it uses the max_completion_tokens parameter instead of max_tokens when making the API call.
  • For o-series models, parameters such as temperature and top_p are omitted because the official OpenAI API does not support customizing these values for these models.
  • For all other models or endpoints, the original parameters are used.

Impact

This change ensures compatibility with the latest o-series models on the official OpenAI API, preventing 400 Bad Request errors due to unsupported parameters.


If you have any questions or need further clarification, please let me know. Thank you for reviewing this pull request!

@codelion
Copy link
Member

This looks good, can you just run black openevolve tests examples to fix linting errors as described in https://github.com/codelion/openevolve/blob/main/CONTRIBUTING.md#code-style

@uchkw
Copy link
Contributor Author

uchkw commented May 23, 2025

I did. Thanks for your comment.

@codelion codelion merged commit 6e37fe0 into algorithmicsuperintelligence:main May 23, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants