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]

[Feature]: Support GPT-OSS models on vertex ai (#14184)

Ishaan Jaffc821f1ddf1d5
diff --git a/docs/my-website/docs/providers/vertex_partner.md b/docs/my-website/docs/providers/vertex_partner.md
index cf780e35dbd..856f054b8e6 100644
--- a/docs/my-website/docs/providers/vertex_partner.md
+++ b/docs/my-website/docs/providers/vertex_partner.md
@@ -15,6 +15,7 @@ import TabItem from '@theme/TabItem';
| Mistral | `vertex_ai/mistral-*` | [Vertex AI - Mistral Models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/mistral) |
| AI21 (Jamba) | `vertex_ai/jamba-*` | [Vertex AI - AI21 Models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/ai21) |
| Qwen | `vertex_ai/qwen/*` | [Vertex AI - Qwen Models](https://cloud.google.com/vertex-ai/generative-ai/docs/maas/qwen) |
+| OpenAI (GPT-OSS) | `vertex_ai/openai/gpt-oss-*` | [Vertex AI - GPT-OSS Models](https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/) |
| Model Garden | `vertex_ai/openai/{MODEL_ID}` or `vertex_ai/{MODEL_ID}` | [Vertex Model Garden](https://cloud.google.com/model-garden?hl=en) |
## Vertex AI - Anthropic (Claude)
@@ -658,6 +659,141 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \
</Tabs>
+## VertexAI GPT-OSS Models
+
+| Property | Details |
+|----------|---------|
+| Provider Route | `vertex_ai/openai/{MODEL}` |
+| Vertex Documentation | [Vertex AI - GPT-OSS Models](https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/) |
+
+**LiteLLM Supports all Vertex AI GPT-OSS Models.** Ensure you use the `vertex_ai/openai/` prefix for all Vertex AI GPT-OSS models.
+
+| Model Name | Usage |
+|------------------|------------------------------|
+| vertex_ai/openai/gpt-oss-20b-maas | `completion('vertex_ai/openai/gpt-oss-20b-maas', messages)` |
+
+#### Usage
+
+<Tabs>
+<TabItem value="sdk" label="SDK">
+
+```python
+from litellm import completion
+import os
+
+os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = ""
+
+model = "openai/gpt-oss-20b-maas"
+
+vertex_ai_project = "your-vertex-project" # can also set this as os.environ["VERTEXAI_PROJECT"]
+vertex_ai_location = "your-vertex-location" # can also set this as os.environ["VERTEXAI_LOCATION"]
+
+response = completion(
+ model="vertex_ai/" + model,
+ messages=[{"role": "user", "content": "hi"}],
+ vertex_ai_project=vertex_ai_project,
+ vertex_ai_location=vertex_ai_location,
+)
+print("\nModel Response", response)
+```
+</TabItem>
+<TabItem value="proxy" label="Proxy">
+
+**1. Add to config**
+
+```yaml
+model_list:
+ - model_name: gpt-oss
+ litellm_params:
+ model: vertex_ai/openai/gpt-oss-20b-maas
+ vertex_ai_project: "my-test-project"
+ vertex_ai_location: "us-central1"
+```
+
+**2. Start proxy**
+
+```bash
+litellm --config /path/to/config.yaml
+
+# RUNNING at http://0.0.0.0:4000
+```
+
+**3. Test it!**
+
+```bash
+curl --location 'http://0.0.0.0:4000/chat/completions' \
+ --header 'Authorization: Bearer sk-1234' \
+ --header 'Content-Type: application/json' \
+ --data '{
+ "model": "gpt-oss", # 👈 the 'model_name' in config
+ "messages": [
+ {
+ "role": "user",
+ "content": "what llm are you"
+ }
+ ],
+ }'
+```
+
+</TabItem>
+</Tabs>
+
+#### Usage - `reasoning_effort`
+
+GPT-OSS models support the `reasoning_effort` parameter for enhanced reasoning capabilities.
+
+<Tabs>
+<TabItem value="sdk" label="SDK">
+
+```python
+from litellm import completion
+
+response = completion(
+ model="vertex_ai/openai/gpt-oss-20b-maas",
+ messages=[{"role": "user", "content": "Solve this complex problem step by step"}],
+ reasoning_effort="low", # Options: "minimal", "low", "medium", "high"
+ vertex_ai_project="your-vertex-project",
+ vertex_ai_location="us-central1",
+)
+```
+
+</TabItem>
+
+<TabItem value="proxy" label="PROXY">
+
+1. Setup config.yaml
+
+```yaml
+model_list:
+- model_name: gpt-oss
+ litellm_params:
+ model: vertex_ai/openai/gpt-oss-20b-maas
+ vertex_ai_project: "my-test-project"
+ vertex_ai_location: "us-central1"
+```
+
+2. Start proxy
+
+```bash
+litellm --config /path/to/config.yaml
+```
+
+3. Test it!
+
+```bash
+curl http://0.0.0.0:4000/v1/chat/completions \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer <YOUR-LITELLM-KEY>" \
+ -d '{
+ "model": "gpt-oss",
+ "messages": [{"role": "user", "content": "Solve this complex problem step by step"}],
+ "reasoning_effort": "low"
+ }'
+```
+
+</TabItem>
+</Tabs>
+
## Model Garden
:::tip
diff --git a/litellm/__init__.py b/litellm/__init__.py
index 453396f9a0f..6a184d70b5a 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -458,6 +458,7 @@ vertex_llama3_models: Set = set()
vertex_deepseek_models: Set = set()
vertex_ai_ai21_models: Set = set()
vertex_mistral_models: Set = set()
+vertex_openai_models: Set = set()
ai21_models: Set = set()
ai21_chat_models: Set = set()
nlp_cloud_models: Set = set()
@@ -604,6 +605,9 @@ def add_known_models():
elif value.get("litellm_provider") == "vertex_ai-image-models":
key = key.replace("vertex_ai/", "")
vertex_ai_image_models.add(key)
+ elif value.get("litellm_provider") == "vertex_ai-openai_models":
+ key = key.replace("vertex_ai/", "")
+ vertex_openai_models.add(key)
elif value.get("litellm_provider") == "ai21":
if value.get("mode") == "chat":
ai21_chat_models.add(key)
diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/transformation.py
new file mode 100644
index 00000000000..86e36e802ed
--- /dev/null
+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/transformation.py
@@ -0,0 +1,27 @@
+import litellm
+from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig
+
+
+class VertexAIGPTOSSTransformation(OpenAIGPTConfig):
+ """
+ Transformation for GPT-OSS model from VertexAI
+
+ https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/gpt-oss-120b-maas?hl=id
+ """
+ def __init__(self):
+ super().__init__()
+
+ def get_supported_openai_params(self, model: str) -> list:
+ base_gpt_series_params = super().get_supported_openai_params(model=model)
+ gpt_oss_only_params = ["reasoning_effort"]
+ base_gpt_series_params.extend(gpt_oss_only_params)
+
+ #########################################################
+ # VertexAI - GPT-OSS does not support tool calls
+ #########################################################
+ if litellm.supports_function_calling(model=model) is False:
+ TOOL_CALLING_PARAMS_TO_REMOVE = ["tool", "tool_choice", "function_call", "functions"]
+ base_gpt_series_params = [param for param in base_gpt_series_params if param not in TOOL_CALLING_PARAMS_TO_REMOVE]
+
+ return base_gpt_series_params
+
diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py
index f281cab3b58..ee30c1749a8 100644
--- a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py
+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py
@@ -49,6 +49,7 @@ class VertexAIPartnerModels(VertexBase):
or model.startswith("jamba")
or model.startswith("claude")
or model.startswith("qwen")
+ or model.startswith("openai")
):
return True
return False
@@ -59,6 +60,7 @@ class VertexAIPartnerModels(VertexBase):
"llama",
"deepseek-ai",
"qwen",
+ "openai",
]
if any(provider in model for provider in OPENAI_LIKE_VERTEX_PROVIDERS):
return True
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 57309554621..7cedffd93f3 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -9884,6 +9884,28 @@
"supports_tool_choice": true,
"supports_prompt_caching": true
},
+ "vertex_ai/openai/gpt-oss-20b-maas": {
+ "max_tokens": 32768,
+ "max_input_tokens": 131072,
+ "max_output_tokens": 32768,
+ "input_cost_per_token": 0.075e-06,
+ "output_cost_per_token": 0.30e-06,
+ "litellm_provider": "vertex_ai-openai_models",
+ "mode": "chat",
+ "supports_reasoning": true,
+ "source": "https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/gpt-oss-120b-maas"
+ },
+ "vertex_ai/openai/gpt-oss-120b-maas": {
+ "max_tokens": 32768,
+ "max_input_tokens": 131072,
+ "max_output_tokens": 32768,
+ "input_cost_per_token": 0.15e-06,
+ "output_cost_per_token": 0.60e-06,
+ "litellm_provider": "vertex_ai-openai_models",
+ "mode": "chat",
+ "supports_reasoning": true,
+ "source": "https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/gpt-oss-120b-maas"
+ },
"vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas": {
"max_tokens": 32768,
"max_input_tokens": 262144,
diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml
index acff522196e..72c69a28e95 100644
--- a/litellm/proxy/proxy_config.yaml
+++ b/litellm/proxy/proxy_config.yaml
@@ -3,4 +3,3 @@ model_list:
litellm_params:
model: openai/*
api_base: https://exampleopenaiendpoint-production-0ee2.up.railway.app/
- mock_response: "hi"
diff --git a/litellm/utils.py b/litellm/utils.py
index 1601d01d3f0..405d4cb98e4 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -3601,6 +3601,17 @@ def get_optional_params( # noqa: PLR0915
else False
),
)
+ elif provider_config is not None:
+ optional_params = provider_config.map_openai_params(
+ non_default_params=non_default_params,
+ optional_params=optional_params,
+ model=model,
+ drop_params=(
+ drop_params
+ if drop_params is not None and isinstance(drop_params, bool)
+ else False
+ ),
+ )
else: # use generic openai-like param mapping
optional_params = litellm.VertexAILlama3Config().map_openai_params(
non_default_params=non_default_params,
@@ -6864,6 +6875,11 @@ class ProviderConfigManager:
return litellm.VertexGeminiConfig()
elif "claude" in model:
return litellm.VertexAIAnthropicConfig()
+ elif "gpt-oss" in model:
+ from litellm.llms.vertex_ai.vertex_ai_partner_models.gpt_oss.transformation import (
+ VertexAIGPTOSSTransformation,
+ )
+ return VertexAIGPTOSSTransformation()
elif model in litellm.vertex_mistral_models:
if "codestral" in model:
return litellm.CodestralTextCompletionConfig()
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 57309554621..7cedffd93f3 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -9884,6 +9884,28 @@
"supports_tool_choice": true,
"supports_prompt_caching": true
},
+ "vertex_ai/openai/gpt-oss-20b-maas": {
+ "max_tokens": 32768,
+ "max_input_tokens": 131072,
+ "max_output_tokens": 32768,
+ "input_cost_per_token": 0.075e-06,
+ "output_cost_per_token": 0.30e-06,
+ "litellm_provider": "vertex_ai-openai_models",
+ "mode": "chat",
+ "supports_reasoning": true,
+ "source": "https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/gpt-oss-120b-maas"
+ },
+ "vertex_ai/openai/gpt-oss-120b-maas": {
+ "max_tokens": 32768,
+ "max_input_tokens": 131072,
+ "max_output_tokens": 32768,
+ "input_cost_per_token": 0.15e-06,
+ "output_cost_per_token": 0.60e-06,
+ "litellm_provider": "vertex_ai-openai_models",
+ "mode": "chat",
+ "supports_reasoning": true,
+ "source": "https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/gpt-oss-120b-maas"
+ },
"vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas": {
"max_tokens": 32768,
"max_input_tokens": 262144,
diff --git a/tests/local_testing/test_amazing_vertex_completion.py b/tests/local_testing/test_amazing_vertex_completion.py
index b908eabd0cf..9b6fa868677 100644
--- a/tests/local_testing/test_amazing_vertex_completion.py
+++ b/tests/local_testing/test_amazing_vertex_completion.py
@@ -840,7 +840,8 @@ from test_completion import response_format_tests
[
("vertex_ai/mistral-large-2411", "us-central1"),
("vertex_ai/mistral-nemo@2407", "us-central1"),
- ("vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas", "us-south1")
+ ("vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas", "us-south1"),
+ ("vertex_ai/openai/gpt-oss-20b-maas", "us-central1"),
],
)
@pytest.mark.parametrize(
@@ -911,6 +912,7 @@ async def test_partner_models_httpx(model, region, sync_mode):
("vertex_ai/meta/llama-4-scout-17b-16e-instruct-maas", "us-east5"),
("vertex_ai/qwen/qwen3-coder-480b-a35b-instruct-maas", "us-south1"),
("vertex_ai/mistral-large-2411", "us-central1"), # critical - we had this issue: https://github.com/BerriAI/litellm/issues/13888
+ ("vertex_ai/openai/gpt-oss-20b-maas", "us-central1"),
],
)
@pytest.mark.parametrize(
diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py
new file mode 100644
index 00000000000..6743258bae6
--- /dev/null
+++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py
@@ -0,0 +1,223 @@
+import json
+import os
+import sys
+from unittest.mock import AsyncMock, MagicMock, patch
+
+import httpx
+import pytest
+
+sys.path.insert(
+ 0, os.path.abspath("../../../../../..")
+) # Adds the parent directory to the system path
+
+import litellm
+from litellm.llms.vertex_ai.vertex_ai_partner_models.gpt_oss.transformation import (
+ VertexAIGPTOSSTransformation,
+)
+
+
+class TestVertexAIGPTOSSTransformation:
+ """Test class for VertexAI GPT-OSS transformation functionality."""
+
+ def test_supports_reasoning_effort(self):
+ """Test that reasoning_effort parameter is supported for GPT-OSS models."""
+ config = VertexAIGPTOSSTransformation()
+ supported_params = config.get_supported_openai_params(model="openai/gpt-oss-20b-maas")
+
+ assert "reasoning_effort" in supported_params
+
+ def test_removes_tool_calling_params_when_not_supported(self):
+ """Test that tool calling parameters are removed when function calling is not supported."""
+ config = VertexAIGPTOSSTransformation()
+
+ # Mock litellm.supports_function_calling to return False
+ with patch('litellm.supports_function_calling', return_value=False):
+ supported_params = config.get_supported_openai_params(model="openai/gpt-oss-20b-maas")
+
+ # Tool calling params should be removed
+ assert "tool" not in supported_params
+ assert "tool_choice" not in supported_params
+ assert "function_call" not in supported_params
+ assert "functions" not in supported_params
+
+ # But reasoning_effort should still be there
+ assert "reasoning_effort" in supported_params
+
+
+async def test_vertex_ai_gpt_oss_simple_request():
+ """
+ Test that a simple request to vertex_ai/openai/gpt-oss-20b-maas lands at the correct URL
+ with the correct request body.
+ """
+ from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
+
+ # Mock response
+ mock_response = AsyncMock()
+ mock_response.status_code = 200
+ mock_response.headers = {}
+ mock_response.json.return_value = {
+ "id": "chatcmpl-test123",
+ "object": "chat.completion",
+ "created": 1234567890,
+ "model": "openai/gpt-oss-20b-maas",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "Hello! I'm Litellm Bot, a helpful assistant. I don't have access to real-time weather information, but I'd be happy to help you with other questions or tasks!"
+ },
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 42,
+ "completion_tokens": 28,
+ "total_tokens": 70
+ }
+ }
+
+ client = AsyncHTTPHandler()
+
+ with patch.object(client, "post", return_value=mock_response) as mock_post:
+ response = await litellm.acompletion(
+ model="vertex_ai/openai/gpt-oss-20b-maas",
+ messages=[
+ {
+ "role": "system",
+ "content": "Your name is Litellm Bot, you are a helpful assistant"
+ },
+ {
+ "role": "user",
+ "content": "Hello, what is your name and can you tell me the weather?"
+ }
+ ],
+ vertex_ai_location="us-central1",
+ vertex_ai_project="pathrise-convert-1606954137718",
+ client=client
+ )
+
+ # Verify the mock was called
+ mock_post.assert_called_once()
+
+ # Get the call arguments
+ call_args = mock_post.call_args
+ called_url = call_args[0][0] # First positional argument is the URL
+ request_body = json.loads(call_args.kwargs["data"])
+
+ # Verify the URL
+ expected_url = "https://us-central1-aiplatform.googleapis.com/v1/projects/pathrise-convert-1606954137718/locations/us-central1/endpoints/openapi/chat/completions"
+ assert called_url == expected_url
+
+ # Verify the request body
+ expected_request_body = {
+ 'model': 'openai/gpt-oss-20b-maas',
+ 'messages': [
+ {
+ 'role': 'system',
+ 'content': 'Your name is Litellm Bot, you are a helpful assistant'
+ },
+ {
+ 'role': 'user',
+ 'content': 'Hello, what is your name and can you tell me the weather?'
+ }
+ ],
+ 'stream': False
+ }
+ assert request_body == expected_request_body
+
+ # Verify response structure
+ assert response.model == "vertex_ai/openai/gpt-oss-20b-maas"
+ assert len(response.choices) == 1
+ assert response.choices[0].message.role == "assistant"
+
+
+async def test_vertex_ai_gpt_oss_reasoning_effort():
+ """
+ Test that reasoning_effort parameter is correctly passed in the request body
+ for GPT-OSS models.
+ """
+ from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
+
+ # Mock response
+ mock_response = AsyncMock()
+ mock_response.status_code = 200
+ mock_response.headers = {}
+ mock_response.json.return_value = {
+ "id": "chatcmpl-test456",
+ "object": "chat.completion",
+ "created": 1234567890,
+ "model": "openai/gpt-oss-20b-maas",
+ "choices": [
+ {
+ "index": 0,
+ "message": {
+ "role": "assistant",
+ "content": "I need to think about this carefully. The weather varies by location and time, so I would need to know your specific location to provide accurate weather information."
+ },
+ "finish_reason": "stop"
+ }
+ ],
+ "usage": {
+ "prompt_tokens": 35,
+ "completion_tokens": 32,
+ "total_tokens": 67
+ }
+ }
+
+ client = AsyncHTTPHandler()
+
+ with patch.object(client, "post", return_value=mock_response) as mock_post:
+ response = await litellm.acompletion(
+ model="vertex_ai/openai/gpt-oss-20b-maas",
+ messages=[
+ {
+ "role": "system",
+ "content": "Your name is Litellm Bot, you are a helpful assistant"
+ },
+ {
+ "role": "user",
+ "content": "Hello, what is your name and can you tell me the weather?"
+ }
+ ],
+ reasoning_effort="low",
+ vertex_ai_location="us-central1",
+ vertex_ai_project="pathrise-convert-1606954137718",
+ client=client
+ )
+
+ # Verify the mock was called
+ mock_post.assert_called_once()
+
+ # Get the call arguments
+ call_args = mock_post.call_args
+ request_body = json.loads(call_args.kwargs["data"])
+
+ # Verify reasoning_effort is in the request body
+ assert "reasoning_effort" in request_body
+ assert request_body["reasoning_effort"] == "low"
+
+ # Verify other expected fields
+ expected_request_body = {
+ 'model': 'openai/gpt-oss-20b-maas',
+ 'messages': [
+ {
+ 'role': 'system',
+ 'content': 'Your name is Litellm Bot, you are a helpful assistant'
+ },
+ {
+ 'role': 'user',
+ 'content': 'Hello, what is your name and can you tell me the weather?'
+ }
+ ],
+ 'reasoning_effort': 'low',
+ 'stream': False
+ }
+ assert request_body == expected_request_body
+
+ # Verify response structure
+ assert response.model == "vertex_ai/openai/gpt-oss-20b-maas"
+ assert len(response.choices) == 1
+ assert response.choices[0].message.role == "assistant"