Skip to content

Commit a70d9da

Browse files
committed
test: add responses API test to validate OpenAI Responses functionality
Signed-off-by: Sivanantham Chinnaiyan <[email protected]>
1 parent 0906299 commit a70d9da

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/e2e-aigw/llm_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/openai/openai-go"
1515
"github.com/openai/openai-go/option"
16+
"github.com/openai/openai-go/responses"
1617
"github.com/stretchr/testify/require"
1718

1819
internaltesting "github.com/envoyproxy/ai-gateway/internal/testing"
@@ -50,6 +51,30 @@ func TestAIGWRun_LLM(t *testing.T) {
5051
"chat completion never succeeded")
5152
})
5253

54+
// Responses API (OpenAI Responses)
55+
t.Run("responses API", func(t *testing.T) {
56+
internaltesting.RequireEventuallyNoError(t, func() error {
57+
// POST directly to the Responses endpoint so we don't depend on the
58+
// exact client types in the test. The gateway should proxy this to
59+
// the backend and return a JSON body.
60+
t.Logf("model to use: %q", ollamaModel)
61+
client := openai.NewClient(option.WithBaseURL("http://localhost:1975/v1/"))
62+
chatReq := responses.ResponseNewParams{
63+
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Say this is a test")},
64+
Model: ollamaModel,
65+
}
66+
resp, err := client.Responses.New(ctx, chatReq)
67+
if err != nil {
68+
return fmt.Errorf("responses api failed: %w", err)
69+
}
70+
if resp.OutputText() != "" {
71+
return nil
72+
}
73+
return fmt.Errorf("empty body from responses API")
74+
}, 10*time.Second, 2*time.Second,
75+
"responses API never succeeded")
76+
})
77+
5378
t.Run("access metrics", func(t *testing.T) {
5479
t.Skip()
5580
internaltesting.RequireEventuallyNoError(t, func() error {

0 commit comments

Comments
 (0)