From 97761ca1e42157c88c6b5fcd6eeba4356ace69c5 Mon Sep 17 00:00:00 2001
From: Takahiro Ikeuchi <takahiro.ikeuchi@awarefy.com>
Date: Tue, 15 Apr 2025 15:29:00 +0900
Subject: [PATCH 1/3] feat: add new GPT-4.1 model variants to completion.go

---
 completion.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/completion.go b/completion.go
index 015fa2a9f..b8c435003 100644
--- a/completion.go
+++ b/completion.go
@@ -37,6 +37,12 @@ const (
 	GPT4TurboPreview        = "gpt-4-turbo-preview"
 	GPT4VisionPreview       = "gpt-4-vision-preview"
 	GPT4                    = "gpt-4"
+	GPT4Dot1                = "gpt-4.1"
+	GPT4Dot120250414        = "gpt-4.1-2025-04-14"
+	GPT4Dot1Mini            = "gpt-4.1-mini"
+	GPT4Dot1Mini20250414    = "gpt-4.1-mini-2025-04-14"
+	GPT4Dot1Nano            = "gpt-4.1-nano"
+	GPT4Dot1Nano20250414    = "gpt-4.1-nano-2025-04-14"
 	GPT4Dot5Preview         = "gpt-4.5-preview"
 	GPT4Dot5Preview20250227 = "gpt-4.5-preview-2025-02-27"
 	GPT3Dot5Turbo0125       = "gpt-3.5-turbo-0125"

From 404e3546dbdf1f0fe57d22d9556848f4fa16c00f Mon Sep 17 00:00:00 2001
From: Takahiro Ikeuchi <takahiro.ikeuchi@awarefy.com>
Date: Tue, 15 Apr 2025 16:29:31 +0900
Subject: [PATCH 2/3] feat: add tests for unsupported models in completion
 endpoint

---
 completion.go      |  7 ++++
 completion_test.go | 83 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)

diff --git a/completion.go b/completion.go
index b8c435003..0d0c1a8f4 100644
--- a/completion.go
+++ b/completion.go
@@ -127,6 +127,13 @@ var disabledModelsForEndpoints = map[string]map[string]bool{
 		GPT432K:                 true,
 		GPT432K0314:             true,
 		GPT432K0613:             true,
+		O1:                      true,
+		GPT4Dot1:                true,
+		GPT4Dot120250414:        true,
+		GPT4Dot1Mini:            true,
+		GPT4Dot1Mini20250414:    true,
+		GPT4Dot1Nano:            true,
+		GPT4Dot1Nano20250414:    true,
 	},
 	chatCompletionsSuffix: {
 		CodexCodeDavinci002:     true,
diff --git a/completion_test.go b/completion_test.go
index 935bbe864..ca878f88a 100644
--- a/completion_test.go
+++ b/completion_test.go
@@ -181,3 +181,86 @@ func getCompletionBody(r *http.Request) (openai.CompletionRequest, error) {
 	}
 	return completion, nil
 }
+
+// TestCompletionWithO1Model Tests that O1 model is not supported for completion endpoint
+func TestCompletionWithO1Model(t *testing.T) {
+	config := openai.DefaultConfig("whatever")
+	config.BaseURL = "http://localhost/v1"
+	client := openai.NewClientWithConfig(config)
+
+	_, err := client.CreateCompletion(
+		context.Background(),
+		openai.CompletionRequest{
+			MaxTokens: 5,
+			Model:     openai.O1,
+		},
+	)
+	if !errors.Is(err, openai.ErrCompletionUnsupportedModel) {
+		t.Fatalf("CreateCompletion should return ErrCompletionUnsupportedModel for O1 model, but returned: %v", err)
+	}
+}
+
+// TestCompletionWithGPT4DotModels Tests that newer GPT4 models are not supported for completion endpoint
+func TestCompletionWithGPT4DotModels(t *testing.T) {
+	config := openai.DefaultConfig("whatever")
+	config.BaseURL = "http://localhost/v1"
+	client := openai.NewClientWithConfig(config)
+
+	models := []string{
+		openai.GPT4Dot1,
+		openai.GPT4Dot120250414,
+		openai.GPT4Dot1Mini,
+		openai.GPT4Dot1Mini20250414,
+		openai.GPT4Dot1Nano,
+		openai.GPT4Dot1Nano20250414,
+		openai.GPT4Dot5Preview,
+		openai.GPT4Dot5Preview20250227,
+	}
+
+	for _, model := range models {
+		t.Run(model, func(t *testing.T) {
+			_, err := client.CreateCompletion(
+				context.Background(),
+				openai.CompletionRequest{
+					MaxTokens: 5,
+					Model:     model,
+				},
+			)
+			if !errors.Is(err, openai.ErrCompletionUnsupportedModel) {
+				t.Fatalf("CreateCompletion should return ErrCompletionUnsupportedModel for %s model, but returned: %v", model, err)
+			}
+		})
+	}
+}
+
+// TestCompletionWithGPT4oModels Tests that GPT4o models are not supported for completion endpoint
+func TestCompletionWithGPT4oModels(t *testing.T) {
+	config := openai.DefaultConfig("whatever")
+	config.BaseURL = "http://localhost/v1"
+	client := openai.NewClientWithConfig(config)
+
+	models := []string{
+		openai.GPT4o,
+		openai.GPT4o20240513,
+		openai.GPT4o20240806,
+		openai.GPT4o20241120,
+		openai.GPT4oLatest,
+		openai.GPT4oMini,
+		openai.GPT4oMini20240718,
+	}
+
+	for _, model := range models {
+		t.Run(model, func(t *testing.T) {
+			_, err := client.CreateCompletion(
+				context.Background(),
+				openai.CompletionRequest{
+					MaxTokens: 5,
+					Model:     model,
+				},
+			)
+			if !errors.Is(err, openai.ErrCompletionUnsupportedModel) {
+				t.Fatalf("CreateCompletion should return ErrCompletionUnsupportedModel for %s model, but returned: %v", model, err)
+			}
+		})
+	}
+}

From 086174ed17acad79c200b1e275300dee39c12d08 Mon Sep 17 00:00:00 2001
From: Takahiro Ikeuchi <takahiro.ikeuchi@awarefy.com>
Date: Tue, 15 Apr 2025 16:34:52 +0900
Subject: [PATCH 3/3] fix: add missing periods to test function comments in
 completion_test.go

---
 completion_test.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/completion_test.go b/completion_test.go
index ca878f88a..83bd899a1 100644
--- a/completion_test.go
+++ b/completion_test.go
@@ -182,7 +182,7 @@ func getCompletionBody(r *http.Request) (openai.CompletionRequest, error) {
 	return completion, nil
 }
 
-// TestCompletionWithO1Model Tests that O1 model is not supported for completion endpoint
+// TestCompletionWithO1Model Tests that O1 model is not supported for completion endpoint.
 func TestCompletionWithO1Model(t *testing.T) {
 	config := openai.DefaultConfig("whatever")
 	config.BaseURL = "http://localhost/v1"
@@ -200,7 +200,7 @@ func TestCompletionWithO1Model(t *testing.T) {
 	}
 }
 
-// TestCompletionWithGPT4DotModels Tests that newer GPT4 models are not supported for completion endpoint
+// TestCompletionWithGPT4DotModels Tests that newer GPT4 models are not supported for completion endpoint.
 func TestCompletionWithGPT4DotModels(t *testing.T) {
 	config := openai.DefaultConfig("whatever")
 	config.BaseURL = "http://localhost/v1"
@@ -233,7 +233,7 @@ func TestCompletionWithGPT4DotModels(t *testing.T) {
 	}
 }
 
-// TestCompletionWithGPT4oModels Tests that GPT4o models are not supported for completion endpoint
+// TestCompletionWithGPT4oModels Tests that GPT4o models are not supported for completion endpoint.
 func TestCompletionWithGPT4oModels(t *testing.T) {
 	config := openai.DefaultConfig("whatever")
 	config.BaseURL = "http://localhost/v1"