Skip to content

Commit b13140b

Browse files
ranaroussiclaude
andcommitted
Fix OpenAI provider compatibility with newer models
- Convert max_tokens to max_completion_tokens for all OpenAI API calls - Remove temperature parameter for GPT-5 and o-series models (they only support default) - Bump version to 0.1.2 - Update CHANGELOG with compatibility fixes These changes ensure OneLLM works seamlessly with GPT-5, o1, o3, and future OpenAI models while maintaining backward compatibility for existing code. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 096b056 commit b13140b

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# CHANGELOG
22

3+
## 0.1.2 - OpenAI Provider Compatibility Updates
4+
5+
**Status**: Development Status :: 5 - Production/Stable
6+
7+
### Bug Fixes
8+
9+
- **OpenAI Provider Parameter Updates**: Fixed compatibility issues with newer OpenAI models
10+
- Automatically converts `max_tokens` to `max_completion_tokens` for all OpenAI models
11+
- Removes `temperature` parameter for GPT-5 and o-series models that only support default temperature
12+
- Ensures compatibility with GPT-5, o1, o3, and future OpenAI model releases
13+
- Backward compatible - existing code using `max_tokens` continues to work without changes
14+
15+
### Technical Details
16+
17+
- Models starting with `gpt-5` or `o` now have temperature parameter automatically removed
18+
- All OpenAI API calls now use `max_completion_tokens` instead of deprecated `max_tokens`
19+
- Changes are transparent to users - no code modifications required
20+
321
## 0.1.1 - Moonshot Provider Addition
422

523
**Status**: Development Status :: 5 - Production/Stable

onellm/.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.1
1+
0.1.2

onellm/providers/openai.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,14 @@ async def create_chat_completion(
376376
# Process messages for vision models if needed
377377
processed_messages = self._process_messages_for_vision(messages, model)
378378

379+
# Handle max_tokens -> max_completion_tokens renaming for OpenAI API
380+
if "max_tokens" in kwargs:
381+
kwargs["max_completion_tokens"] = kwargs.pop("max_tokens")
382+
383+
# Remove temperature for GPT-5 and o-series models that don't support it
384+
if model.startswith("gpt-5") or model.startswith("o"):
385+
kwargs.pop("temperature", None)
386+
379387
# Set up the request data
380388
data = {
381389
"model": model,
@@ -573,6 +581,14 @@ async def create_completion(
573581
Returns:
574582
CompletionResponse or generator yielding completion chunks
575583
"""
584+
# Handle max_tokens -> max_completion_tokens renaming for OpenAI API
585+
if "max_tokens" in kwargs:
586+
kwargs["max_completion_tokens"] = kwargs.pop("max_tokens")
587+
588+
# Remove temperature for GPT-5 and o-series models that don't support it
589+
if model.startswith("gpt-5") or model.startswith("o"):
590+
kwargs.pop("temperature", None)
591+
576592
# Prepare request data with all parameters
577593
request_data = {"model": model, "prompt": prompt, "stream": stream, **kwargs}
578594

0 commit comments

Comments
 (0)