openrouter 0.1.2__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. openrouter/_version.py +2 -2
  2. openrouter/analytics.py +28 -2
  3. openrouter/api_keys.py +210 -14
  4. openrouter/chat.py +192 -200
  5. openrouter/components/__init__.py +229 -285
  6. openrouter/components/_schema10.py +39 -0
  7. openrouter/components/_schema14.py +11 -0
  8. openrouter/components/_schema17.py +154 -0
  9. openrouter/components/{_schema3.py → _schema19.py} +28 -22
  10. openrouter/components/{_schema0.py → _schema5.py} +7 -5
  11. openrouter/components/assistantmessage.py +32 -1
  12. openrouter/components/chatgenerationparams.py +57 -343
  13. openrouter/components/chatmessagecontentitemimage.py +4 -4
  14. openrouter/components/chatresponsechoice.py +1 -6
  15. openrouter/components/chatstreamingmessagechunk.py +3 -3
  16. openrouter/components/developermessage.py +41 -0
  17. openrouter/components/message.py +6 -39
  18. openrouter/components/model.py +7 -1
  19. openrouter/components/openresponsesrequest.py +31 -39
  20. openrouter/components/outputmodality.py +1 -0
  21. openrouter/components/providername.py +2 -0
  22. openrouter/components/providerpreferences.py +2 -10
  23. openrouter/components/publicendpoint.py +8 -24
  24. openrouter/components/publicpricing.py +3 -24
  25. openrouter/credits.py +86 -14
  26. openrouter/embeddings.py +92 -20
  27. openrouter/endpoints.py +62 -2
  28. openrouter/generations.py +26 -0
  29. openrouter/guardrails.py +3367 -0
  30. openrouter/models_.py +120 -12
  31. openrouter/oauth.py +90 -22
  32. openrouter/operations/__init__.py +601 -30
  33. openrouter/operations/bulkassignkeystoguardrail.py +116 -0
  34. openrouter/operations/bulkassignmemberstoguardrail.py +116 -0
  35. openrouter/operations/bulkunassignkeysfromguardrail.py +116 -0
  36. openrouter/operations/bulkunassignmembersfromguardrail.py +116 -0
  37. openrouter/operations/createauthkeyscode.py +81 -3
  38. openrouter/operations/createcoinbasecharge.py +82 -2
  39. openrouter/operations/createembeddings.py +82 -3
  40. openrouter/operations/createguardrail.py +325 -0
  41. openrouter/operations/createkeys.py +81 -3
  42. openrouter/operations/createresponses.py +84 -3
  43. openrouter/operations/deleteguardrail.py +104 -0
  44. openrouter/operations/deletekeys.py +69 -3
  45. openrouter/operations/exchangeauthcodeforapikey.py +81 -3
  46. openrouter/operations/getcredits.py +70 -1
  47. openrouter/operations/getcurrentkey.py +81 -3
  48. openrouter/operations/getgeneration.py +248 -3
  49. openrouter/operations/getguardrail.py +228 -0
  50. openrouter/operations/getkey.py +64 -1
  51. openrouter/operations/getmodels.py +95 -5
  52. openrouter/operations/getuseractivity.py +62 -1
  53. openrouter/operations/list.py +63 -1
  54. openrouter/operations/listembeddingsmodels.py +74 -0
  55. openrouter/operations/listendpoints.py +65 -2
  56. openrouter/operations/listendpointszdr.py +70 -2
  57. openrouter/operations/listguardrailkeyassignments.py +192 -0
  58. openrouter/operations/listguardrailmemberassignments.py +187 -0
  59. openrouter/operations/listguardrails.py +238 -0
  60. openrouter/operations/listkeyassignments.py +180 -0
  61. openrouter/operations/listmemberassignments.py +175 -0
  62. openrouter/operations/listmodelscount.py +74 -0
  63. openrouter/operations/listmodelsuser.py +70 -2
  64. openrouter/operations/listproviders.py +70 -2
  65. openrouter/operations/sendchatcompletionrequest.py +87 -3
  66. openrouter/operations/updateguardrail.py +334 -0
  67. openrouter/operations/updatekeys.py +63 -0
  68. openrouter/providers.py +36 -2
  69. openrouter/responses.py +178 -148
  70. openrouter/sdk.py +5 -8
  71. openrouter/types/models.py +378 -0
  72. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/METADATA +5 -1
  73. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/RECORD +76 -63
  74. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/WHEEL +1 -1
  75. openrouter/completions.py +0 -361
  76. openrouter/components/completionchoice.py +0 -82
  77. openrouter/components/completioncreateparams.py +0 -277
  78. openrouter/components/completionlogprobs.py +0 -54
  79. openrouter/components/completionresponse.py +0 -46
  80. openrouter/components/completionusage.py +0 -19
  81. openrouter/operations/getparameters.py +0 -123
  82. openrouter/parameters.py +0 -237
  83. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/licenses/LICENSE +0 -0
  84. {openrouter-0.1.2.dist-info → openrouter-0.6.0.dist-info}/top_level.txt +0 -0
openrouter/responses.py CHANGED
@@ -22,6 +22,8 @@ class Responses(BaseSDK):
22
22
  def send(
23
23
  self,
24
24
  *,
25
+ http_referer: Optional[str] = None,
26
+ x_title: Optional[str] = None,
25
27
  input: Optional[
26
28
  Union[components.OpenResponsesInput, components.OpenResponsesInputTypedDict]
27
29
  ] = None,
@@ -84,16 +86,10 @@ class Responses(BaseSDK):
84
86
  truncation: OptionalNullable[components.Truncation] = UNSET,
85
87
  stream: Union[Literal[False], None] = None,
86
88
  provider: OptionalNullable[
87
- Union[
88
- components.OpenResponsesRequestProvider,
89
- components.OpenResponsesRequestProviderTypedDict,
90
- ]
89
+ Union[components.Provider, components.ProviderTypedDict]
91
90
  ] = UNSET,
92
91
  plugins: Optional[
93
- Union[
94
- List[components.OpenResponsesRequestPluginUnion],
95
- List[components.OpenResponsesRequestPluginUnionTypedDict],
96
- ]
92
+ Union[List[components.Plugin], List[components.PluginTypedDict]]
97
93
  ] = None,
98
94
  user: Optional[str] = None,
99
95
  session_id: Optional[str] = None,
@@ -106,6 +102,11 @@ class Responses(BaseSDK):
106
102
 
107
103
  Creates a streaming or non-streaming response using OpenResponses API format
108
104
 
105
+ :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
106
+ This is used to track API usage per application.
107
+
108
+ :param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
109
+
109
110
  :param input: Input for a response request - can be a string or array of items
110
111
  :param instructions:
111
112
  :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
@@ -150,6 +151,8 @@ class Responses(BaseSDK):
150
151
  def send(
151
152
  self,
152
153
  *,
154
+ http_referer: Optional[str] = None,
155
+ x_title: Optional[str] = None,
153
156
  input: Optional[
154
157
  Union[components.OpenResponsesInput, components.OpenResponsesInputTypedDict]
155
158
  ] = None,
@@ -212,16 +215,10 @@ class Responses(BaseSDK):
212
215
  truncation: OptionalNullable[components.Truncation] = UNSET,
213
216
  stream: Literal[True],
214
217
  provider: OptionalNullable[
215
- Union[
216
- components.OpenResponsesRequestProvider,
217
- components.OpenResponsesRequestProviderTypedDict,
218
- ]
218
+ Union[components.Provider, components.ProviderTypedDict]
219
219
  ] = UNSET,
220
220
  plugins: Optional[
221
- Union[
222
- List[components.OpenResponsesRequestPluginUnion],
223
- List[components.OpenResponsesRequestPluginUnionTypedDict],
224
- ]
221
+ Union[List[components.Plugin], List[components.PluginTypedDict]]
225
222
  ] = None,
226
223
  user: Optional[str] = None,
227
224
  session_id: Optional[str] = None,
@@ -234,6 +231,11 @@ class Responses(BaseSDK):
234
231
 
235
232
  Creates a streaming or non-streaming response using OpenResponses API format
236
233
 
234
+ :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
235
+ This is used to track API usage per application.
236
+
237
+ :param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
238
+
237
239
  :param input: Input for a response request - can be a string or array of items
238
240
  :param instructions:
239
241
  :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
@@ -277,6 +279,8 @@ class Responses(BaseSDK):
277
279
  def send(
278
280
  self,
279
281
  *,
282
+ http_referer: Optional[str] = None,
283
+ x_title: Optional[str] = None,
280
284
  input: Optional[
281
285
  Union[components.OpenResponsesInput, components.OpenResponsesInputTypedDict]
282
286
  ] = None,
@@ -339,16 +343,10 @@ class Responses(BaseSDK):
339
343
  truncation: OptionalNullable[components.Truncation] = UNSET,
340
344
  stream: Optional[bool] = False,
341
345
  provider: OptionalNullable[
342
- Union[
343
- components.OpenResponsesRequestProvider,
344
- components.OpenResponsesRequestProviderTypedDict,
345
- ]
346
+ Union[components.Provider, components.ProviderTypedDict]
346
347
  ] = UNSET,
347
348
  plugins: Optional[
348
- Union[
349
- List[components.OpenResponsesRequestPluginUnion],
350
- List[components.OpenResponsesRequestPluginUnionTypedDict],
351
- ]
349
+ Union[List[components.Plugin], List[components.PluginTypedDict]]
352
350
  ] = None,
353
351
  user: Optional[str] = None,
354
352
  session_id: Optional[str] = None,
@@ -361,6 +359,11 @@ class Responses(BaseSDK):
361
359
 
362
360
  Creates a streaming or non-streaming response using OpenResponses API format
363
361
 
362
+ :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
363
+ This is used to track API usage per application.
364
+
365
+ :param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
366
+
364
367
  :param input: Input for a response request - can be a string or array of items
365
368
  :param instructions:
366
369
  :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
@@ -410,56 +413,60 @@ class Responses(BaseSDK):
410
413
  else:
411
414
  base_url = self._get_url(base_url, url_variables)
412
415
 
413
- request = components.OpenResponsesRequest(
414
- input=utils.get_pydantic_model(
415
- input, Optional[components.OpenResponsesInput]
416
- ),
417
- instructions=instructions,
418
- metadata=metadata,
419
- tools=utils.get_pydantic_model(
420
- tools, Optional[List[components.OpenResponsesRequestToolUnion]]
421
- ),
422
- tool_choice=utils.get_pydantic_model(
423
- tool_choice, Optional[components.OpenAIResponsesToolChoiceUnion]
424
- ),
425
- parallel_tool_calls=parallel_tool_calls,
426
- model=model,
427
- models=models,
428
- text=utils.get_pydantic_model(
429
- text, Optional[components.OpenResponsesResponseText]
430
- ),
431
- reasoning=utils.get_pydantic_model(
432
- reasoning, OptionalNullable[components.OpenResponsesReasoningConfig]
433
- ),
434
- max_output_tokens=max_output_tokens,
435
- temperature=temperature,
436
- top_p=top_p,
437
- top_logprobs=top_logprobs,
438
- max_tool_calls=max_tool_calls,
439
- presence_penalty=presence_penalty,
440
- frequency_penalty=frequency_penalty,
441
- top_k=top_k,
442
- image_config=image_config,
443
- modalities=modalities,
444
- prompt_cache_key=prompt_cache_key,
445
- previous_response_id=previous_response_id,
446
- prompt=utils.get_pydantic_model(
447
- prompt, OptionalNullable[components.OpenAIResponsesPrompt]
448
- ),
449
- include=include,
450
- background=background,
451
- safety_identifier=safety_identifier,
452
- service_tier=service_tier,
453
- truncation=truncation,
454
- stream=stream,
455
- provider=utils.get_pydantic_model(
456
- provider, OptionalNullable[components.OpenResponsesRequestProvider]
457
- ),
458
- plugins=utils.get_pydantic_model(
459
- plugins, Optional[List[components.OpenResponsesRequestPluginUnion]]
416
+ request = operations.CreateResponsesRequest(
417
+ http_referer=http_referer,
418
+ x_title=x_title,
419
+ open_responses_request=components.OpenResponsesRequest(
420
+ input=utils.get_pydantic_model(
421
+ input, Optional[components.OpenResponsesInput]
422
+ ),
423
+ instructions=instructions,
424
+ metadata=metadata,
425
+ tools=utils.get_pydantic_model(
426
+ tools, Optional[List[components.OpenResponsesRequestToolUnion]]
427
+ ),
428
+ tool_choice=utils.get_pydantic_model(
429
+ tool_choice, Optional[components.OpenAIResponsesToolChoiceUnion]
430
+ ),
431
+ parallel_tool_calls=parallel_tool_calls,
432
+ model=model,
433
+ models=models,
434
+ text=utils.get_pydantic_model(
435
+ text, Optional[components.OpenResponsesResponseText]
436
+ ),
437
+ reasoning=utils.get_pydantic_model(
438
+ reasoning, OptionalNullable[components.OpenResponsesReasoningConfig]
439
+ ),
440
+ max_output_tokens=max_output_tokens,
441
+ temperature=temperature,
442
+ top_p=top_p,
443
+ top_logprobs=top_logprobs,
444
+ max_tool_calls=max_tool_calls,
445
+ presence_penalty=presence_penalty,
446
+ frequency_penalty=frequency_penalty,
447
+ top_k=top_k,
448
+ image_config=image_config,
449
+ modalities=modalities,
450
+ prompt_cache_key=prompt_cache_key,
451
+ previous_response_id=previous_response_id,
452
+ prompt=utils.get_pydantic_model(
453
+ prompt, OptionalNullable[components.OpenAIResponsesPrompt]
454
+ ),
455
+ include=include,
456
+ background=background,
457
+ safety_identifier=safety_identifier,
458
+ service_tier=service_tier,
459
+ truncation=truncation,
460
+ stream=stream,
461
+ provider=utils.get_pydantic_model(
462
+ provider, OptionalNullable[components.Provider]
463
+ ),
464
+ plugins=utils.get_pydantic_model(
465
+ plugins, Optional[List[components.Plugin]]
466
+ ),
467
+ user=user,
468
+ session_id=session_id,
460
469
  ),
461
- user=user,
462
- session_id=session_id,
463
470
  )
464
471
 
465
472
  req = self._build_request(
@@ -474,9 +481,17 @@ class Responses(BaseSDK):
474
481
  user_agent_header="user-agent",
475
482
  accept_header_value="text/event-stream" if stream else "application/json",
476
483
  http_headers=http_headers,
484
+ _globals=operations.CreateResponsesGlobals(
485
+ http_referer=self.sdk_configuration.globals.http_referer,
486
+ x_title=self.sdk_configuration.globals.x_title,
487
+ ),
477
488
  security=self.sdk_configuration.security,
478
489
  get_serialized_body=lambda: utils.serialize_request_body(
479
- request, False, False, "json", components.OpenResponsesRequest
490
+ request.open_responses_request,
491
+ False,
492
+ False,
493
+ "json",
494
+ components.OpenResponsesRequest,
480
495
  ),
481
496
  allow_empty_value=None,
482
497
  timeout_ms=timeout_ms,
@@ -655,6 +670,8 @@ class Responses(BaseSDK):
655
670
  async def send_async(
656
671
  self,
657
672
  *,
673
+ http_referer: Optional[str] = None,
674
+ x_title: Optional[str] = None,
658
675
  input: Optional[
659
676
  Union[components.OpenResponsesInput, components.OpenResponsesInputTypedDict]
660
677
  ] = None,
@@ -717,16 +734,10 @@ class Responses(BaseSDK):
717
734
  truncation: OptionalNullable[components.Truncation] = UNSET,
718
735
  stream: Union[Literal[False], None] = None,
719
736
  provider: OptionalNullable[
720
- Union[
721
- components.OpenResponsesRequestProvider,
722
- components.OpenResponsesRequestProviderTypedDict,
723
- ]
737
+ Union[components.Provider, components.ProviderTypedDict]
724
738
  ] = UNSET,
725
739
  plugins: Optional[
726
- Union[
727
- List[components.OpenResponsesRequestPluginUnion],
728
- List[components.OpenResponsesRequestPluginUnionTypedDict],
729
- ]
740
+ Union[List[components.Plugin], List[components.PluginTypedDict]]
730
741
  ] = None,
731
742
  user: Optional[str] = None,
732
743
  session_id: Optional[str] = None,
@@ -739,6 +750,11 @@ class Responses(BaseSDK):
739
750
 
740
751
  Creates a streaming or non-streaming response using OpenResponses API format
741
752
 
753
+ :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
754
+ This is used to track API usage per application.
755
+
756
+ :param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
757
+
742
758
  :param input: Input for a response request - can be a string or array of items
743
759
  :param instructions:
744
760
  :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
@@ -783,6 +799,8 @@ class Responses(BaseSDK):
783
799
  async def send_async(
784
800
  self,
785
801
  *,
802
+ http_referer: Optional[str] = None,
803
+ x_title: Optional[str] = None,
786
804
  input: Optional[
787
805
  Union[components.OpenResponsesInput, components.OpenResponsesInputTypedDict]
788
806
  ] = None,
@@ -845,16 +863,10 @@ class Responses(BaseSDK):
845
863
  truncation: OptionalNullable[components.Truncation] = UNSET,
846
864
  stream: Literal[True],
847
865
  provider: OptionalNullable[
848
- Union[
849
- components.OpenResponsesRequestProvider,
850
- components.OpenResponsesRequestProviderTypedDict,
851
- ]
866
+ Union[components.Provider, components.ProviderTypedDict]
852
867
  ] = UNSET,
853
868
  plugins: Optional[
854
- Union[
855
- List[components.OpenResponsesRequestPluginUnion],
856
- List[components.OpenResponsesRequestPluginUnionTypedDict],
857
- ]
869
+ Union[List[components.Plugin], List[components.PluginTypedDict]]
858
870
  ] = None,
859
871
  user: Optional[str] = None,
860
872
  session_id: Optional[str] = None,
@@ -867,6 +879,11 @@ class Responses(BaseSDK):
867
879
 
868
880
  Creates a streaming or non-streaming response using OpenResponses API format
869
881
 
882
+ :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
883
+ This is used to track API usage per application.
884
+
885
+ :param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
886
+
870
887
  :param input: Input for a response request - can be a string or array of items
871
888
  :param instructions:
872
889
  :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
@@ -910,6 +927,8 @@ class Responses(BaseSDK):
910
927
  async def send_async(
911
928
  self,
912
929
  *,
930
+ http_referer: Optional[str] = None,
931
+ x_title: Optional[str] = None,
913
932
  input: Optional[
914
933
  Union[components.OpenResponsesInput, components.OpenResponsesInputTypedDict]
915
934
  ] = None,
@@ -972,16 +991,10 @@ class Responses(BaseSDK):
972
991
  truncation: OptionalNullable[components.Truncation] = UNSET,
973
992
  stream: Optional[bool] = False,
974
993
  provider: OptionalNullable[
975
- Union[
976
- components.OpenResponsesRequestProvider,
977
- components.OpenResponsesRequestProviderTypedDict,
978
- ]
994
+ Union[components.Provider, components.ProviderTypedDict]
979
995
  ] = UNSET,
980
996
  plugins: Optional[
981
- Union[
982
- List[components.OpenResponsesRequestPluginUnion],
983
- List[components.OpenResponsesRequestPluginUnionTypedDict],
984
- ]
997
+ Union[List[components.Plugin], List[components.PluginTypedDict]]
985
998
  ] = None,
986
999
  user: Optional[str] = None,
987
1000
  session_id: Optional[str] = None,
@@ -994,6 +1007,11 @@ class Responses(BaseSDK):
994
1007
 
995
1008
  Creates a streaming or non-streaming response using OpenResponses API format
996
1009
 
1010
+ :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
1011
+ This is used to track API usage per application.
1012
+
1013
+ :param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
1014
+
997
1015
  :param input: Input for a response request - can be a string or array of items
998
1016
  :param instructions:
999
1017
  :param metadata: Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
@@ -1043,56 +1061,60 @@ class Responses(BaseSDK):
1043
1061
  else:
1044
1062
  base_url = self._get_url(base_url, url_variables)
1045
1063
 
1046
- request = components.OpenResponsesRequest(
1047
- input=utils.get_pydantic_model(
1048
- input, Optional[components.OpenResponsesInput]
1049
- ),
1050
- instructions=instructions,
1051
- metadata=metadata,
1052
- tools=utils.get_pydantic_model(
1053
- tools, Optional[List[components.OpenResponsesRequestToolUnion]]
1054
- ),
1055
- tool_choice=utils.get_pydantic_model(
1056
- tool_choice, Optional[components.OpenAIResponsesToolChoiceUnion]
1057
- ),
1058
- parallel_tool_calls=parallel_tool_calls,
1059
- model=model,
1060
- models=models,
1061
- text=utils.get_pydantic_model(
1062
- text, Optional[components.OpenResponsesResponseText]
1063
- ),
1064
- reasoning=utils.get_pydantic_model(
1065
- reasoning, OptionalNullable[components.OpenResponsesReasoningConfig]
1066
- ),
1067
- max_output_tokens=max_output_tokens,
1068
- temperature=temperature,
1069
- top_p=top_p,
1070
- top_logprobs=top_logprobs,
1071
- max_tool_calls=max_tool_calls,
1072
- presence_penalty=presence_penalty,
1073
- frequency_penalty=frequency_penalty,
1074
- top_k=top_k,
1075
- image_config=image_config,
1076
- modalities=modalities,
1077
- prompt_cache_key=prompt_cache_key,
1078
- previous_response_id=previous_response_id,
1079
- prompt=utils.get_pydantic_model(
1080
- prompt, OptionalNullable[components.OpenAIResponsesPrompt]
1081
- ),
1082
- include=include,
1083
- background=background,
1084
- safety_identifier=safety_identifier,
1085
- service_tier=service_tier,
1086
- truncation=truncation,
1087
- stream=stream,
1088
- provider=utils.get_pydantic_model(
1089
- provider, OptionalNullable[components.OpenResponsesRequestProvider]
1090
- ),
1091
- plugins=utils.get_pydantic_model(
1092
- plugins, Optional[List[components.OpenResponsesRequestPluginUnion]]
1064
+ request = operations.CreateResponsesRequest(
1065
+ http_referer=http_referer,
1066
+ x_title=x_title,
1067
+ open_responses_request=components.OpenResponsesRequest(
1068
+ input=utils.get_pydantic_model(
1069
+ input, Optional[components.OpenResponsesInput]
1070
+ ),
1071
+ instructions=instructions,
1072
+ metadata=metadata,
1073
+ tools=utils.get_pydantic_model(
1074
+ tools, Optional[List[components.OpenResponsesRequestToolUnion]]
1075
+ ),
1076
+ tool_choice=utils.get_pydantic_model(
1077
+ tool_choice, Optional[components.OpenAIResponsesToolChoiceUnion]
1078
+ ),
1079
+ parallel_tool_calls=parallel_tool_calls,
1080
+ model=model,
1081
+ models=models,
1082
+ text=utils.get_pydantic_model(
1083
+ text, Optional[components.OpenResponsesResponseText]
1084
+ ),
1085
+ reasoning=utils.get_pydantic_model(
1086
+ reasoning, OptionalNullable[components.OpenResponsesReasoningConfig]
1087
+ ),
1088
+ max_output_tokens=max_output_tokens,
1089
+ temperature=temperature,
1090
+ top_p=top_p,
1091
+ top_logprobs=top_logprobs,
1092
+ max_tool_calls=max_tool_calls,
1093
+ presence_penalty=presence_penalty,
1094
+ frequency_penalty=frequency_penalty,
1095
+ top_k=top_k,
1096
+ image_config=image_config,
1097
+ modalities=modalities,
1098
+ prompt_cache_key=prompt_cache_key,
1099
+ previous_response_id=previous_response_id,
1100
+ prompt=utils.get_pydantic_model(
1101
+ prompt, OptionalNullable[components.OpenAIResponsesPrompt]
1102
+ ),
1103
+ include=include,
1104
+ background=background,
1105
+ safety_identifier=safety_identifier,
1106
+ service_tier=service_tier,
1107
+ truncation=truncation,
1108
+ stream=stream,
1109
+ provider=utils.get_pydantic_model(
1110
+ provider, OptionalNullable[components.Provider]
1111
+ ),
1112
+ plugins=utils.get_pydantic_model(
1113
+ plugins, Optional[List[components.Plugin]]
1114
+ ),
1115
+ user=user,
1116
+ session_id=session_id,
1093
1117
  ),
1094
- user=user,
1095
- session_id=session_id,
1096
1118
  )
1097
1119
 
1098
1120
  req = self._build_request_async(
@@ -1107,9 +1129,17 @@ class Responses(BaseSDK):
1107
1129
  user_agent_header="user-agent",
1108
1130
  accept_header_value="text/event-stream" if stream else "application/json",
1109
1131
  http_headers=http_headers,
1132
+ _globals=operations.CreateResponsesGlobals(
1133
+ http_referer=self.sdk_configuration.globals.http_referer,
1134
+ x_title=self.sdk_configuration.globals.x_title,
1135
+ ),
1110
1136
  security=self.sdk_configuration.security,
1111
1137
  get_serialized_body=lambda: utils.serialize_request_body(
1112
- request, False, False, "json", components.OpenResponsesRequest
1138
+ request.open_responses_request,
1139
+ False,
1140
+ False,
1141
+ "json",
1142
+ components.OpenResponsesRequest,
1113
1143
  ),
1114
1144
  allow_empty_value=None,
1115
1145
  timeout_ms=timeout_ms,
openrouter/sdk.py CHANGED
@@ -20,19 +20,18 @@ if TYPE_CHECKING:
20
20
  from openrouter.api_keys import APIKeys
21
21
  from openrouter.beta import Beta
22
22
  from openrouter.chat import Chat
23
- from openrouter.completions import Completions
24
23
  from openrouter.credits import Credits
25
24
  from openrouter.embeddings import Embeddings
26
25
  from openrouter.endpoints import Endpoints
27
26
  from openrouter.generations import Generations
27
+ from openrouter.guardrails import Guardrails
28
28
  from openrouter.models_ import Models
29
29
  from openrouter.oauth import OAuth
30
- from openrouter.parameters import Parameters
31
30
  from openrouter.providers import Providers
32
31
 
33
32
 
34
33
  class OpenRouter(BaseSDK):
35
- r"""OpenRouter API: OpenAI-compatible Chat Completions and Completions API with additional OpenRouter features
34
+ r"""OpenRouter API: OpenAI-compatible API with additional OpenRouter features
36
35
  https://openrouter.ai/docs - OpenRouter Documentation
37
36
  """
38
37
 
@@ -49,16 +48,15 @@ class OpenRouter(BaseSDK):
49
48
  r"""Model information endpoints"""
50
49
  endpoints: "Endpoints"
51
50
  r"""Endpoint information"""
52
- parameters: "Parameters"
53
- r"""Parameters endpoints"""
54
51
  providers: "Providers"
55
52
  r"""Provider information endpoints"""
56
53
  api_keys: "APIKeys"
57
54
  r"""API key management endpoints"""
55
+ guardrails: "Guardrails"
56
+ r"""Guardrails endpoints"""
58
57
  o_auth: "OAuth"
59
58
  r"""OAuth authentication endpoints"""
60
59
  chat: "Chat"
61
- completions: "Completions"
62
60
  _sub_sdk_map = {
63
61
  "beta": ("openrouter.beta", "Beta"),
64
62
  "analytics": ("openrouter.analytics", "Analytics"),
@@ -67,12 +65,11 @@ class OpenRouter(BaseSDK):
67
65
  "generations": ("openrouter.generations", "Generations"),
68
66
  "models": ("openrouter.models_", "Models"),
69
67
  "endpoints": ("openrouter.endpoints", "Endpoints"),
70
- "parameters": ("openrouter.parameters", "Parameters"),
71
68
  "providers": ("openrouter.providers", "Providers"),
72
69
  "api_keys": ("openrouter.api_keys", "APIKeys"),
70
+ "guardrails": ("openrouter.guardrails", "Guardrails"),
73
71
  "o_auth": ("openrouter.oauth", "OAuth"),
74
72
  "chat": ("openrouter.chat", "Chat"),
75
- "completions": ("openrouter.completions", "Completions"),
76
73
  }
77
74
 
78
75
  def __init__(