Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

add OpenAI o1 config

Ishaan Jafffed9c89cc71b
diff --git a/litellm/llms/OpenAI/o1_reasoning.py b/litellm/llms/OpenAI/o1_reasoning.py
new file mode 100644
index 00000000000..c2c48456f63
--- /dev/null
+++ b/litellm/llms/OpenAI/o1_reasoning.py
@@ -0,0 +1,72 @@
+"""
+Support for o1 model family
+
+https://platform.openai.com/docs/guides/reasoning
+
+Translations handled by LiteLLM:
+- modalities: image => drop param (if user opts in to dropping param)
+- role: system ==> translate to role assistant
+- streaming => faked by LiteLLM
+- Tools, response_format => drop param (if user opts in to dropping param)
+- Logprobs => drop param (if user opts in to dropping param)
+"""
+
+import types
+from typing import Optional, Union
+
+import litellm
+
+from .openai import OpenAIConfig
+
+
+class OpenAIO1Config(OpenAIConfig):
+ """
+ Reference: https://platform.openai.com/docs/guides/reasoning
+
+ """
+
+ @classmethod
+ def get_config(cls):
+ return {
+ k: v
+ for k, v in cls.__dict__.items()
+ if not k.startswith("__")
+ and not isinstance(
+ v,
+ (
+ types.FunctionType,
+ types.BuiltinFunctionType,
+ classmethod,
+ staticmethod,
+ ),
+ )
+ and v is not None
+ }
+
+ def get_supported_openai_params(self, model: str) -> list:
+ """
+ Get the supported OpenAI params for the given model
+
+ """
+
+ all_openai_params = litellm.OpenAIConfig.get_supported_openai_params(
+ model="gpt-4o"
+ )
+ non_supported_params = [
+ "logprobs",
+ "tools",
+ "tool_choice",
+ "parallel_tool_calls",
+ "function_call",
+ "functions",
+ ]
+
+ return [
+ param for param in all_openai_params if param not in non_supported_params
+ ]
+
+ def map_openai_params(self, non_default_params: dict, optional_params: dict):
+ for param, value in non_default_params.items():
+ if param == "max_tokens":
+ optional_params["max_completion_tokens"] = value
+ return optional_params
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 37ac239664c..6b075e11120 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -11,6 +11,42 @@
"supports_parallel_function_calling": true,
"supports_vision": true
},
+ "o1-preview-2024-09-12": {
+ "max_tokens": 4096,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 32768,
+ "input_cost_per_token": 0.000015,
+ "output_cost_per_token": 0.00006,
+ "litellm_provider": "openai",
+ "mode": "chat"
+ },
+ "o1-preview": {
+ "max_tokens": 4096,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 32768,
+ "input_cost_per_token": 0.000015,
+ "output_cost_per_token": 0.00006,
+ "litellm_provider": "openai",
+ "mode": "chat"
+ },
+ "o1-mini": {
+ "max_tokens": 4096,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 65536,
+ "input_cost_per_token": 0.000003,
+ "output_cost_per_token": 0.000012,
+ "litellm_provider": "openai",
+ "mode": "chat"
+ },
+ "o1-mini-2024-09-12": {
+ "max_tokens": 4096,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 65536,
+ "input_cost_per_token": 0.000003,
+ "output_cost_per_token": 0.000012,
+ "litellm_provider": "openai",
+ "mode": "chat"
+ },
"gpt-4": {
"max_tokens": 4096,
"max_input_tokens": 8192,
@@ -57,6 +93,54 @@
"supports_parallel_function_calling": true,
"supports_vision": true
},
+ "o1-mini": {
+ "max_tokens": 16384,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 16384,
+ "input_cost_per_token": 0.000003,
+ "output_cost_per_token": 0.000012,
+ "litellm_provider": "openai",
+ "mode": "chat",
+ "supports_function_calling": true,
+ "supports_parallel_function_calling": true,
+ "supports_vision": true
+ },
+ "o1-mini-2024-09-12": {
+ "max_tokens": 16384,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 16384,
+ "input_cost_per_token": 0.000003,
+ "output_cost_per_token": 0.000012,
+ "litellm_provider": "openai",
+ "mode": "chat",
+ "supports_function_calling": true,
+ "supports_parallel_function_calling": true,
+ "supports_vision": true
+ },
+ "o1-preview": {
+ "max_tokens": 16384,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 16384,
+ "input_cost_per_token": 0.000015,
+ "output_cost_per_token": 0.000060,
+ "litellm_provider": "openai",
+ "mode": "chat",
+ "supports_function_calling": true,
+ "supports_parallel_function_calling": true,
+ "supports_vision": true
+ },
+ "o1-preview-2024-09-12": {
+ "max_tokens": 16384,
+ "max_input_tokens": 128000,
+ "max_output_tokens": 16384,
+ "input_cost_per_token": 0.000015,
+ "output_cost_per_token": 0.000060,
+ "litellm_provider": "openai",
+ "mode": "chat",
+ "supports_function_calling": true,
+ "supports_parallel_function_calling": true,
+ "supports_vision": true
+ },
"chatgpt-4o-latest": {
"max_tokens": 4096,
"max_input_tokens": 128000,