@@ -62,7 +62,9 @@ def create(
62
62
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
63
63
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
64
64
stream : Optional [Literal [False ]] | NotGiven = NOT_GIVEN ,
65
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
65
+ stream_options : (
66
+ Optional [completion_create_params .StreamOptions ] | NotGiven
67
+ ) = NOT_GIVEN ,
66
68
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
67
69
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
68
70
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -191,7 +193,9 @@ def create(
191
193
n : Optional [int ] | NotGiven = NOT_GIVEN ,
192
194
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
193
195
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
194
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
196
+ stream_options : (
197
+ Optional [completion_create_params .StreamOptions ] | NotGiven
198
+ ) = NOT_GIVEN ,
195
199
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
196
200
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
197
201
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -319,7 +323,9 @@ def create(
319
323
n : Optional [int ] | NotGiven = NOT_GIVEN ,
320
324
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
321
325
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
322
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
326
+ stream_options : (
327
+ Optional [completion_create_params .StreamOptions ] | NotGiven
328
+ ) = NOT_GIVEN ,
323
329
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
324
330
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
325
331
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -447,7 +453,9 @@ def create(
447
453
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
448
454
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
449
455
stream : Optional [Literal [False ]] | Literal [True ] | NotGiven = NOT_GIVEN ,
450
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
456
+ stream_options : (
457
+ Optional [completion_create_params .StreamOptions ] | NotGiven
458
+ ) = NOT_GIVEN ,
451
459
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
452
460
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
453
461
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -461,18 +469,23 @@ def create(
461
469
extra_body : Body | None = None ,
462
470
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
463
471
) -> CompletionCreateResponse | Stream [ChatCompletionChunk ]:
464
- # This method requires an inference_key to be set via client argument or environment variable
465
- if not self ._client .inference_key :
472
+ # This method requires an model_access_key to be set via client argument or environment variable
473
+ if not self ._client .model_access_key :
466
474
raise TypeError (
467
- "Could not resolve authentication method. Expected inference_key to be set for chat completions."
475
+ "Could not resolve authentication method. Expected model_access_key to be set for chat completions."
468
476
)
469
477
headers = extra_headers or {}
470
- headers = {"Authorization" : f"Bearer { self ._client .inference_key } " , ** headers }
478
+ headers = {
479
+ "Authorization" : f"Bearer { self ._client .model_access_key } " ,
480
+ ** headers ,
481
+ }
471
482
472
483
return self ._post (
473
- "/chat/completions"
474
- if self ._client ._base_url_overridden
475
- else "https://inference.do-ai.run/v1/chat/completions" ,
484
+ (
485
+ "/chat/completions"
486
+ if self ._client ._base_url_overridden
487
+ else f"{ self ._client .inference_endpoint } /v1/chat/completions"
488
+ ),
476
489
body = maybe_transform (
477
490
{
478
491
"messages" : messages ,
@@ -495,12 +508,17 @@ def create(
495
508
"top_p" : top_p ,
496
509
"user" : user ,
497
510
},
498
- completion_create_params .CompletionCreateParamsStreaming
499
- if stream
500
- else completion_create_params .CompletionCreateParamsNonStreaming ,
511
+ (
512
+ completion_create_params .CompletionCreateParamsStreaming
513
+ if stream
514
+ else completion_create_params .CompletionCreateParamsNonStreaming
515
+ ),
501
516
),
502
517
options = make_request_options (
503
- extra_headers = headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
518
+ extra_headers = headers ,
519
+ extra_query = extra_query ,
520
+ extra_body = extra_body ,
521
+ timeout = timeout ,
504
522
),
505
523
cast_to = CompletionCreateResponse ,
506
524
stream = stream or False ,
@@ -544,7 +562,9 @@ async def create(
544
562
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
545
563
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
546
564
stream : Optional [Literal [False ]] | NotGiven = NOT_GIVEN ,
547
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
565
+ stream_options : (
566
+ Optional [completion_create_params .StreamOptions ] | NotGiven
567
+ ) = NOT_GIVEN ,
548
568
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
549
569
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
550
570
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -673,7 +693,9 @@ async def create(
673
693
n : Optional [int ] | NotGiven = NOT_GIVEN ,
674
694
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
675
695
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
676
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
696
+ stream_options : (
697
+ Optional [completion_create_params .StreamOptions ] | NotGiven
698
+ ) = NOT_GIVEN ,
677
699
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
678
700
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
679
701
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -801,7 +823,9 @@ async def create(
801
823
n : Optional [int ] | NotGiven = NOT_GIVEN ,
802
824
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
803
825
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
804
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
826
+ stream_options : (
827
+ Optional [completion_create_params .StreamOptions ] | NotGiven
828
+ ) = NOT_GIVEN ,
805
829
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
806
830
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
807
831
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -929,7 +953,9 @@ async def create(
929
953
presence_penalty : Optional [float ] | NotGiven = NOT_GIVEN ,
930
954
stop : Union [Optional [str ], List [str ], None ] | NotGiven = NOT_GIVEN ,
931
955
stream : Optional [Literal [False ]] | Literal [True ] | NotGiven = NOT_GIVEN ,
932
- stream_options : Optional [completion_create_params .StreamOptions ] | NotGiven = NOT_GIVEN ,
956
+ stream_options : (
957
+ Optional [completion_create_params .StreamOptions ] | NotGiven
958
+ ) = NOT_GIVEN ,
933
959
temperature : Optional [float ] | NotGiven = NOT_GIVEN ,
934
960
tool_choice : completion_create_params .ToolChoice | NotGiven = NOT_GIVEN ,
935
961
tools : Iterable [completion_create_params .Tool ] | NotGiven = NOT_GIVEN ,
@@ -943,18 +969,26 @@ async def create(
943
969
extra_body : Body | None = None ,
944
970
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
945
971
) -> CompletionCreateResponse | AsyncStream [ChatCompletionChunk ]:
946
- # This method requires an inference_key to be set via client argument or environment variable
947
- if not hasattr (self ._client , "inference_key" ) or not self ._client .inference_key :
972
+ # This method requires an model_access_key to be set via client argument or environment variable
973
+ if (
974
+ not hasattr (self ._client , "model_access_key" )
975
+ or not self ._client .model_access_key
976
+ ):
948
977
raise TypeError (
949
- "Could not resolve authentication method. Expected inference_key to be set for chat completions."
978
+ "Could not resolve authentication method. Expected model_access_key to be set for chat completions."
950
979
)
951
980
headers = extra_headers or {}
952
- headers = {"Authorization" : f"Bearer { self ._client .inference_key } " , ** headers }
981
+ headers = {
982
+ "Authorization" : f"Bearer { self ._client .model_access_key } " ,
983
+ ** headers ,
984
+ }
953
985
954
986
return await self ._post (
955
- "/chat/completions"
956
- if self ._client ._base_url_overridden
957
- else "https://inference.do-ai.run/v1/chat/completions" ,
987
+ (
988
+ "/chat/completions"
989
+ if self ._client ._base_url_overridden
990
+ else f"{ self ._client .inference_endpoint } /chat/completions"
991
+ ),
958
992
body = await async_maybe_transform (
959
993
{
960
994
"messages" : messages ,
@@ -977,12 +1011,17 @@ async def create(
977
1011
"top_p" : top_p ,
978
1012
"user" : user ,
979
1013
},
980
- completion_create_params .CompletionCreateParamsStreaming
981
- if stream
982
- else completion_create_params .CompletionCreateParamsNonStreaming ,
1014
+ (
1015
+ completion_create_params .CompletionCreateParamsStreaming
1016
+ if stream
1017
+ else completion_create_params .CompletionCreateParamsNonStreaming
1018
+ ),
983
1019
),
984
1020
options = make_request_options (
985
- extra_headers = headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
1021
+ extra_headers = headers ,
1022
+ extra_query = extra_query ,
1023
+ extra_body = extra_body ,
1024
+ timeout = timeout ,
986
1025
),
987
1026
cast_to = CompletionCreateResponse ,
988
1027
stream = stream or False ,
0 commit comments