@@ -26,7 +26,9 @@ import (
2626func TestClient_GetChatCompletions (t * testing.T ) {
2727 deploymentID := "gpt-35-turbo"
2828
29- cred := KeyCredential {APIKey : apiKey }
29+ cred , err := NewKeyCredential (apiKey )
30+ require .NoError (t , err )
31+
3032 chatClient , err := NewClientWithKeyCredential (endpoint , cred , deploymentID , newClientOptionsForTest (t ))
3133 require .NoError (t , err )
3234
@@ -158,7 +160,9 @@ func testGetChatCompletions(t *testing.T, chatClient *Client, modelOrDeployment
158160}
159161
160162func TestClient_GetChatCompletions_InvalidModel (t * testing.T ) {
161- cred := KeyCredential {APIKey : apiKey }
163+ cred , err := NewKeyCredential (apiKey )
164+ require .NoError (t , err )
165+
162166 chatClient , err := NewClientWithKeyCredential (endpoint , cred , "thisdoesntexist" , newClientOptionsForTest (t ))
163167 require .NoError (t , err )
164168
@@ -179,7 +183,9 @@ func TestClient_GetChatCompletions_InvalidModel(t *testing.T) {
179183}
180184
181185func TestClient_GetEmbeddings_InvalidModel (t * testing.T ) {
182- cred := KeyCredential {APIKey : apiKey }
186+ cred , err := NewKeyCredential (apiKey )
187+ require .NoError (t , err )
188+
183189 chatClient , err := NewClientWithKeyCredential (endpoint , cred , "thisdoesntexist" , newClientOptionsForTest (t ))
184190 require .NoError (t , err )
185191
@@ -197,7 +203,9 @@ func TestClient_GetCompletions(t *testing.T) {
197203 body CompletionsOptions
198204 options * GetCompletionsOptions
199205 }
200- cred := KeyCredential {APIKey : apiKey }
206+ cred , err := NewKeyCredential (apiKey )
207+ require .NoError (t , err )
208+
201209 client , err := NewClientWithKeyCredential (endpoint , cred , streamingModelDeployment , newClientOptionsForTest (t ))
202210 if err != nil {
203211 log .Fatalf ("%v" , err )
@@ -267,7 +275,9 @@ func TestClient_GetEmbeddings(t *testing.T) {
267275 // model deployment points to `text-similarity-curie-001`
268276 deploymentID := "embedding"
269277
270- cred := KeyCredential {APIKey : apiKey }
278+ cred , err := NewKeyCredential (apiKey )
279+ require .NoError (t , err )
280+
271281 client , err := NewClientWithKeyCredential (endpoint , cred , deploymentID , newClientOptionsForTest (t ))
272282 require .NoError (t , err )
273283
@@ -330,7 +340,10 @@ func newOpenAIClientForTest(t *testing.T) *Client {
330340 t .Skipf ("OPENAI_API_KEY not defined, skipping OpenAI public endpoint test" )
331341 }
332342
333- chatClient , err := NewClientForOpenAI (openAIEndpoint , KeyCredential {APIKey : openAIKey }, newClientOptionsForTest (t ))
343+ cred , err := NewKeyCredential (openAIKey )
344+ require .NoError (t , err )
345+
346+ chatClient , err := NewClientForOpenAI (openAIEndpoint , cred , newClientOptionsForTest (t ))
334347 require .NoError (t , err )
335348
336349 return chatClient
0 commit comments