orq-ai-sdk 4.2.0rc48__py3-none-any.whl → 4.2.12__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 (103) hide show
  1. orq_ai_sdk/_hooks/globalhook.py +0 -1
  2. orq_ai_sdk/_version.py +3 -3
  3. orq_ai_sdk/audio.py +30 -0
  4. orq_ai_sdk/chat.py +22 -0
  5. orq_ai_sdk/completions.py +438 -0
  6. orq_ai_sdk/contacts.py +43 -886
  7. orq_ai_sdk/deployments.py +61 -0
  8. orq_ai_sdk/edits.py +364 -0
  9. orq_ai_sdk/embeddings.py +344 -0
  10. orq_ai_sdk/generations.py +370 -0
  11. orq_ai_sdk/images.py +28 -0
  12. orq_ai_sdk/models/__init__.py +3839 -424
  13. orq_ai_sdk/models/conversationresponse.py +1 -1
  14. orq_ai_sdk/models/conversationwithmessagesresponse.py +1 -1
  15. orq_ai_sdk/models/createagentrequestop.py +768 -12
  16. orq_ai_sdk/models/createagentresponse.py +68 -2
  17. orq_ai_sdk/models/createchatcompletionop.py +538 -313
  18. orq_ai_sdk/models/createcompletionop.py +2078 -0
  19. orq_ai_sdk/models/createcontactop.py +5 -10
  20. orq_ai_sdk/models/createconversationop.py +1 -1
  21. orq_ai_sdk/models/createconversationresponseop.py +2 -2
  22. orq_ai_sdk/models/createdatasetitemop.py +4 -4
  23. orq_ai_sdk/models/createdatasetop.py +1 -1
  24. orq_ai_sdk/models/createdatasourceop.py +1 -1
  25. orq_ai_sdk/models/createembeddingop.py +579 -0
  26. orq_ai_sdk/models/createevalop.py +14 -14
  27. orq_ai_sdk/models/createidentityop.py +1 -1
  28. orq_ai_sdk/models/createimageeditop.py +715 -0
  29. orq_ai_sdk/models/createimageop.py +228 -82
  30. orq_ai_sdk/models/createimagevariationop.py +706 -0
  31. orq_ai_sdk/models/creatememoryop.py +4 -2
  32. orq_ai_sdk/models/createmoderationop.py +521 -0
  33. orq_ai_sdk/models/createpromptop.py +375 -6
  34. orq_ai_sdk/models/creatererankop.py +608 -0
  35. orq_ai_sdk/models/createresponseop.py +2567 -0
  36. orq_ai_sdk/models/createspeechop.py +466 -0
  37. orq_ai_sdk/models/createtoolop.py +6 -6
  38. orq_ai_sdk/models/createtranscriptionop.py +732 -0
  39. orq_ai_sdk/models/createtranslationop.py +702 -0
  40. orq_ai_sdk/models/deploymentgetconfigop.py +17 -7
  41. orq_ai_sdk/models/deploymentsop.py +1 -0
  42. orq_ai_sdk/models/deploymentstreamop.py +7 -0
  43. orq_ai_sdk/models/filegetop.py +1 -1
  44. orq_ai_sdk/models/filelistop.py +1 -1
  45. orq_ai_sdk/models/fileuploadop.py +1 -1
  46. orq_ai_sdk/models/generateconversationnameop.py +1 -1
  47. orq_ai_sdk/models/getallmemoriesop.py +4 -2
  48. orq_ai_sdk/models/getallpromptsop.py +188 -3
  49. orq_ai_sdk/models/getalltoolsop.py +6 -6
  50. orq_ai_sdk/models/getevalsop.py +17 -17
  51. orq_ai_sdk/models/getonepromptop.py +188 -3
  52. orq_ai_sdk/models/getpromptversionop.py +188 -3
  53. orq_ai_sdk/models/invokedeploymentrequest.py +11 -4
  54. orq_ai_sdk/models/listagentsop.py +372 -0
  55. orq_ai_sdk/models/listdatasetdatapointsop.py +4 -4
  56. orq_ai_sdk/models/listdatasetsop.py +1 -1
  57. orq_ai_sdk/models/listdatasourcesop.py +1 -1
  58. orq_ai_sdk/models/listidentitiesop.py +1 -1
  59. orq_ai_sdk/models/listmodelsop.py +1 -0
  60. orq_ai_sdk/models/listpromptversionsop.py +188 -3
  61. orq_ai_sdk/models/partdoneevent.py +1 -1
  62. orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
  63. orq_ai_sdk/models/publiccontact.py +9 -3
  64. orq_ai_sdk/models/publicidentity.py +62 -0
  65. orq_ai_sdk/models/reasoningpart.py +1 -1
  66. orq_ai_sdk/models/responsedoneevent.py +14 -11
  67. orq_ai_sdk/models/retrieveagentrequestop.py +382 -0
  68. orq_ai_sdk/models/retrievedatapointop.py +4 -4
  69. orq_ai_sdk/models/retrievedatasetop.py +1 -1
  70. orq_ai_sdk/models/retrievedatasourceop.py +1 -1
  71. orq_ai_sdk/models/retrieveidentityop.py +1 -1
  72. orq_ai_sdk/models/retrievememoryop.py +4 -2
  73. orq_ai_sdk/models/retrievetoolop.py +6 -6
  74. orq_ai_sdk/models/runagentop.py +379 -9
  75. orq_ai_sdk/models/streamrunagentop.py +385 -9
  76. orq_ai_sdk/models/updateagentop.py +770 -12
  77. orq_ai_sdk/models/updateconversationop.py +1 -1
  78. orq_ai_sdk/models/updatedatapointop.py +4 -4
  79. orq_ai_sdk/models/updatedatasetop.py +1 -1
  80. orq_ai_sdk/models/updatedatasourceop.py +1 -1
  81. orq_ai_sdk/models/updateevalop.py +14 -14
  82. orq_ai_sdk/models/updateidentityop.py +1 -1
  83. orq_ai_sdk/models/updatememoryop.py +4 -2
  84. orq_ai_sdk/models/updatepromptop.py +375 -6
  85. orq_ai_sdk/models/updatetoolop.py +7 -7
  86. orq_ai_sdk/moderations.py +218 -0
  87. orq_ai_sdk/orq_completions.py +666 -0
  88. orq_ai_sdk/orq_responses.py +398 -0
  89. orq_ai_sdk/rerank.py +330 -0
  90. orq_ai_sdk/router.py +89 -641
  91. orq_ai_sdk/speech.py +333 -0
  92. orq_ai_sdk/transcriptions.py +416 -0
  93. orq_ai_sdk/translations.py +384 -0
  94. orq_ai_sdk/variations.py +364 -0
  95. orq_ai_sdk-4.2.12.dist-info/METADATA +888 -0
  96. {orq_ai_sdk-4.2.0rc48.dist-info → orq_ai_sdk-4.2.12.dist-info}/RECORD +98 -75
  97. {orq_ai_sdk-4.2.0rc48.dist-info → orq_ai_sdk-4.2.12.dist-info}/WHEEL +1 -1
  98. orq_ai_sdk/models/deletecontactop.py +0 -44
  99. orq_ai_sdk/models/listcontactsop.py +0 -265
  100. orq_ai_sdk/models/retrievecontactop.py +0 -142
  101. orq_ai_sdk/models/updatecontactop.py +0 -233
  102. orq_ai_sdk-4.2.0rc48.dist-info/METADATA +0 -788
  103. {orq_ai_sdk-4.2.0rc48.dist-info → orq_ai_sdk-4.2.12.dist-info}/top_level.txt +0 -0
orq_ai_sdk/deployments.py CHANGED
@@ -9,6 +9,7 @@ from orq_ai_sdk.models import (
9
9
  deploymentgetconfigop as models_deploymentgetconfigop,
10
10
  deploymentstreamop as models_deploymentstreamop,
11
11
  invokedeploymentrequest as models_invokedeploymentrequest,
12
+ publicidentity as models_publicidentity,
12
13
  )
13
14
  from orq_ai_sdk.types import OptionalNullable, UNSET
14
15
  from orq_ai_sdk.utils import eventstreaming, get_security_from_env
@@ -48,6 +49,12 @@ class Deployments(BaseSDK):
48
49
  List[models_invokedeploymentrequest.MessagesTypedDict],
49
50
  ]
50
51
  ] = None,
52
+ identity: Optional[
53
+ Union[
54
+ models_publicidentity.PublicIdentity,
55
+ models_publicidentity.PublicIdentityTypedDict,
56
+ ]
57
+ ] = None,
51
58
  file_ids: Optional[List[str]] = None,
52
59
  metadata: Optional[Dict[str, Any]] = None,
53
60
  extra_params: Optional[Dict[str, Any]] = None,
@@ -90,6 +97,7 @@ class Deployments(BaseSDK):
90
97
  :param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
91
98
  :param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
92
99
  :param messages: A list of messages to send to the deployment.
100
+ :param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
93
101
  :param file_ids: A list of file IDs that are associated with the deployment request.
94
102
  :param metadata: Key-value pairs that you want to attach to the log generated by this request.
95
103
  :param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
@@ -126,6 +134,9 @@ class Deployments(BaseSDK):
126
134
  messages=utils.get_pydantic_model(
127
135
  messages, Optional[List[models.Messages]]
128
136
  ),
137
+ identity=utils.get_pydantic_model(
138
+ identity, Optional[models.PublicIdentity]
139
+ ),
129
140
  file_ids=file_ids,
130
141
  metadata=metadata,
131
142
  extra_params=extra_params,
@@ -222,6 +233,12 @@ class Deployments(BaseSDK):
222
233
  List[models_invokedeploymentrequest.MessagesTypedDict],
223
234
  ]
224
235
  ] = None,
236
+ identity: Optional[
237
+ Union[
238
+ models_publicidentity.PublicIdentity,
239
+ models_publicidentity.PublicIdentityTypedDict,
240
+ ]
241
+ ] = None,
225
242
  file_ids: Optional[List[str]] = None,
226
243
  metadata: Optional[Dict[str, Any]] = None,
227
244
  extra_params: Optional[Dict[str, Any]] = None,
@@ -264,6 +281,7 @@ class Deployments(BaseSDK):
264
281
  :param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
265
282
  :param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
266
283
  :param messages: A list of messages to send to the deployment.
284
+ :param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
267
285
  :param file_ids: A list of file IDs that are associated with the deployment request.
268
286
  :param metadata: Key-value pairs that you want to attach to the log generated by this request.
269
287
  :param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
@@ -300,6 +318,9 @@ class Deployments(BaseSDK):
300
318
  messages=utils.get_pydantic_model(
301
319
  messages, Optional[List[models.Messages]]
302
320
  ),
321
+ identity=utils.get_pydantic_model(
322
+ identity, Optional[models.PublicIdentity]
323
+ ),
303
324
  file_ids=file_ids,
304
325
  metadata=metadata,
305
326
  extra_params=extra_params,
@@ -591,6 +612,12 @@ class Deployments(BaseSDK):
591
612
  List[models_deploymentgetconfigop.DeploymentGetConfigMessagesTypedDict],
592
613
  ]
593
614
  ] = None,
615
+ identity: Optional[
616
+ Union[
617
+ models_publicidentity.PublicIdentity,
618
+ models_publicidentity.PublicIdentityTypedDict,
619
+ ]
620
+ ] = None,
594
621
  file_ids: Optional[List[str]] = None,
595
622
  metadata: Optional[Dict[str, Any]] = None,
596
623
  extra_params: Optional[Dict[str, Any]] = None,
@@ -634,6 +661,7 @@ class Deployments(BaseSDK):
634
661
  :param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
635
662
  :param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
636
663
  :param messages: A list of messages to send to the deployment.
664
+ :param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
637
665
  :param file_ids: A list of file IDs that are associated with the deployment request.
638
666
  :param metadata: Key-value pairs that you want to attach to the log generated by this request.
639
667
  :param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
@@ -670,6 +698,9 @@ class Deployments(BaseSDK):
670
698
  messages=utils.get_pydantic_model(
671
699
  messages, Optional[List[models.DeploymentGetConfigMessages]]
672
700
  ),
701
+ identity=utils.get_pydantic_model(
702
+ identity, Optional[models.PublicIdentity]
703
+ ),
673
704
  file_ids=file_ids,
674
705
  metadata=metadata,
675
706
  extra_params=extra_params,
@@ -765,6 +796,12 @@ class Deployments(BaseSDK):
765
796
  List[models_deploymentgetconfigop.DeploymentGetConfigMessagesTypedDict],
766
797
  ]
767
798
  ] = None,
799
+ identity: Optional[
800
+ Union[
801
+ models_publicidentity.PublicIdentity,
802
+ models_publicidentity.PublicIdentityTypedDict,
803
+ ]
804
+ ] = None,
768
805
  file_ids: Optional[List[str]] = None,
769
806
  metadata: Optional[Dict[str, Any]] = None,
770
807
  extra_params: Optional[Dict[str, Any]] = None,
@@ -808,6 +845,7 @@ class Deployments(BaseSDK):
808
845
  :param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
809
846
  :param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
810
847
  :param messages: A list of messages to send to the deployment.
848
+ :param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
811
849
  :param file_ids: A list of file IDs that are associated with the deployment request.
812
850
  :param metadata: Key-value pairs that you want to attach to the log generated by this request.
813
851
  :param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
@@ -844,6 +882,9 @@ class Deployments(BaseSDK):
844
882
  messages=utils.get_pydantic_model(
845
883
  messages, Optional[List[models.DeploymentGetConfigMessages]]
846
884
  ),
885
+ identity=utils.get_pydantic_model(
886
+ identity, Optional[models.PublicIdentity]
887
+ ),
847
888
  file_ids=file_ids,
848
889
  metadata=metadata,
849
890
  extra_params=extra_params,
@@ -937,6 +978,12 @@ class Deployments(BaseSDK):
937
978
  List[models_deploymentstreamop.DeploymentStreamMessagesTypedDict],
938
979
  ]
939
980
  ] = None,
981
+ identity: Optional[
982
+ Union[
983
+ models_publicidentity.PublicIdentity,
984
+ models_publicidentity.PublicIdentityTypedDict,
985
+ ]
986
+ ] = None,
940
987
  file_ids: Optional[List[str]] = None,
941
988
  metadata: Optional[Dict[str, Any]] = None,
942
989
  extra_params: Optional[Dict[str, Any]] = None,
@@ -978,6 +1025,7 @@ class Deployments(BaseSDK):
978
1025
  :param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
979
1026
  :param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
980
1027
  :param messages: A list of messages to send to the deployment.
1028
+ :param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
981
1029
  :param file_ids: A list of file IDs that are associated with the deployment request.
982
1030
  :param metadata: Key-value pairs that you want to attach to the log generated by this request.
983
1031
  :param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
@@ -1013,6 +1061,9 @@ class Deployments(BaseSDK):
1013
1061
  messages=utils.get_pydantic_model(
1014
1062
  messages, Optional[List[models.DeploymentStreamMessages]]
1015
1063
  ),
1064
+ identity=utils.get_pydantic_model(
1065
+ identity, Optional[models.PublicIdentity]
1066
+ ),
1016
1067
  file_ids=file_ids,
1017
1068
  metadata=metadata,
1018
1069
  extra_params=extra_params,
@@ -1115,6 +1166,12 @@ class Deployments(BaseSDK):
1115
1166
  List[models_deploymentstreamop.DeploymentStreamMessagesTypedDict],
1116
1167
  ]
1117
1168
  ] = None,
1169
+ identity: Optional[
1170
+ Union[
1171
+ models_publicidentity.PublicIdentity,
1172
+ models_publicidentity.PublicIdentityTypedDict,
1173
+ ]
1174
+ ] = None,
1118
1175
  file_ids: Optional[List[str]] = None,
1119
1176
  metadata: Optional[Dict[str, Any]] = None,
1120
1177
  extra_params: Optional[Dict[str, Any]] = None,
@@ -1156,6 +1213,7 @@ class Deployments(BaseSDK):
1156
1213
  :param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
1157
1214
  :param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
1158
1215
  :param messages: A list of messages to send to the deployment.
1216
+ :param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
1159
1217
  :param file_ids: A list of file IDs that are associated with the deployment request.
1160
1218
  :param metadata: Key-value pairs that you want to attach to the log generated by this request.
1161
1219
  :param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
@@ -1191,6 +1249,9 @@ class Deployments(BaseSDK):
1191
1249
  messages=utils.get_pydantic_model(
1192
1250
  messages, Optional[List[models.DeploymentStreamMessages]]
1193
1251
  ),
1252
+ identity=utils.get_pydantic_model(
1253
+ identity, Optional[models.PublicIdentity]
1254
+ ),
1194
1255
  file_ids=file_ids,
1195
1256
  metadata=metadata,
1196
1257
  extra_params=extra_params,
orq_ai_sdk/edits.py ADDED
@@ -0,0 +1,364 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from orq_ai_sdk import models, utils
5
+ from orq_ai_sdk._hooks import HookContext
6
+ from orq_ai_sdk.models import createimageeditop as models_createimageeditop
7
+ from orq_ai_sdk.types import OptionalNullable, UNSET
8
+ from orq_ai_sdk.utils import get_security_from_env
9
+ from orq_ai_sdk.utils.unmarshal_json_response import unmarshal_json_response
10
+ from typing import Any, List, Mapping, Optional, Union
11
+
12
+
13
+ class Edits(BaseSDK):
14
+ def create(
15
+ self,
16
+ *,
17
+ model: str,
18
+ prompt: str,
19
+ image: Optional[Any] = None,
20
+ n: OptionalNullable[int] = 1,
21
+ size: OptionalNullable[str] = UNSET,
22
+ quality: OptionalNullable[
23
+ models_createimageeditop.CreateImageEditQuality
24
+ ] = UNSET,
25
+ response_format: Optional[
26
+ models_createimageeditop.CreateImageEditResponseFormat
27
+ ] = None,
28
+ user: Optional[str] = None,
29
+ name: Optional[str] = None,
30
+ fallbacks: Optional[
31
+ Union[
32
+ List[models_createimageeditop.CreateImageEditFallbacks],
33
+ List[models_createimageeditop.CreateImageEditFallbacksTypedDict],
34
+ ]
35
+ ] = None,
36
+ retry: Optional[
37
+ Union[
38
+ models_createimageeditop.CreateImageEditRetry,
39
+ models_createimageeditop.CreateImageEditRetryTypedDict,
40
+ ]
41
+ ] = None,
42
+ cache: Optional[
43
+ Union[
44
+ models_createimageeditop.CreateImageEditCache,
45
+ models_createimageeditop.CreateImageEditCacheTypedDict,
46
+ ]
47
+ ] = None,
48
+ load_balancer: Optional[
49
+ Union[
50
+ models_createimageeditop.CreateImageEditLoadBalancer,
51
+ models_createimageeditop.CreateImageEditLoadBalancerTypedDict,
52
+ ]
53
+ ] = None,
54
+ timeout: Optional[
55
+ Union[
56
+ models_createimageeditop.CreateImageEditTimeout,
57
+ models_createimageeditop.CreateImageEditTimeoutTypedDict,
58
+ ]
59
+ ] = None,
60
+ orq: Optional[
61
+ Union[
62
+ models_createimageeditop.CreateImageEditOrq,
63
+ models_createimageeditop.CreateImageEditOrqTypedDict,
64
+ ]
65
+ ] = None,
66
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
67
+ server_url: Optional[str] = None,
68
+ timeout_ms: Optional[int] = None,
69
+ http_headers: Optional[Mapping[str, str]] = None,
70
+ ) -> models.CreateImageEditResponseBody:
71
+ r"""Create image edit
72
+
73
+ Edit an Image
74
+
75
+ :param model: The model to use for image edit. [Check models](https://docs.orq.ai/docs/ai-gateway-supported-models#image-models)
76
+ :param prompt: A text description of the desired image(s).
77
+ :param image: The image(s) to edit. Must be a supported image file or an array of images. Each image should be a png, webp, or jpg file less than 50MB. You can provide up to 16 images.
78
+ :param n: The number of images to generate. Must be between 1 and 10.
79
+ :param size: The size of the generated images
80
+ :param quality: The quality of the image that will be generated. Auto will automatically select the best quality for the given model.
81
+ :param response_format: The format in which the generated images are returned. Some of the models only return the image in base64 format.
82
+ :param user: A unique identifier representing your end-user, which can help to monitor and detect abuse.
83
+ :param name: The name to display on the trace. If not specified, the default system name will be used.
84
+ :param fallbacks: Array of fallback models to use if primary model fails
85
+ :param retry: Retry configuration for the request
86
+ :param cache: Cache configuration for the request.
87
+ :param load_balancer: Load balancer configuration for the request.
88
+ :param timeout: Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured.
89
+ :param orq:
90
+ :param retries: Override the default retry configuration for this method
91
+ :param server_url: Override the default server URL for this method
92
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
93
+ :param http_headers: Additional headers to set or replace on requests.
94
+ """
95
+ base_url = None
96
+ url_variables = None
97
+ if timeout_ms is None:
98
+ timeout_ms = self.sdk_configuration.timeout_ms
99
+
100
+ if timeout_ms is None:
101
+ timeout_ms = 600000
102
+
103
+ if server_url is not None:
104
+ base_url = server_url
105
+ else:
106
+ base_url = self._get_url(base_url, url_variables)
107
+
108
+ request = models.CreateImageEditRequestBody(
109
+ model=model,
110
+ image=image,
111
+ prompt=prompt,
112
+ n=n,
113
+ size=size,
114
+ quality=quality,
115
+ response_format=response_format,
116
+ user=user,
117
+ name=name,
118
+ fallbacks=utils.get_pydantic_model(
119
+ fallbacks, Optional[List[models.CreateImageEditFallbacks]]
120
+ ),
121
+ retry=utils.get_pydantic_model(
122
+ retry, Optional[models.CreateImageEditRetry]
123
+ ),
124
+ cache=utils.get_pydantic_model(
125
+ cache, Optional[models.CreateImageEditCache]
126
+ ),
127
+ load_balancer=utils.get_pydantic_model(
128
+ load_balancer, Optional[models.CreateImageEditLoadBalancer]
129
+ ),
130
+ timeout=utils.get_pydantic_model(
131
+ timeout, Optional[models.CreateImageEditTimeout]
132
+ ),
133
+ orq=utils.get_pydantic_model(orq, Optional[models.CreateImageEditOrq]),
134
+ )
135
+
136
+ req = self._build_request(
137
+ method="POST",
138
+ path="/v2/router/images/edits",
139
+ base_url=base_url,
140
+ url_variables=url_variables,
141
+ request=request,
142
+ request_body_required=True,
143
+ request_has_path_params=False,
144
+ request_has_query_params=True,
145
+ user_agent_header="user-agent",
146
+ accept_header_value="application/json",
147
+ http_headers=http_headers,
148
+ security=self.sdk_configuration.security,
149
+ get_serialized_body=lambda: utils.serialize_request_body(
150
+ request, False, False, "multipart", models.CreateImageEditRequestBody
151
+ ),
152
+ allow_empty_value=None,
153
+ timeout_ms=timeout_ms,
154
+ )
155
+
156
+ if retries == UNSET:
157
+ if self.sdk_configuration.retry_config is not UNSET:
158
+ retries = self.sdk_configuration.retry_config
159
+
160
+ retry_config = None
161
+ if isinstance(retries, utils.RetryConfig):
162
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
163
+
164
+ http_res = self.do_request(
165
+ hook_ctx=HookContext(
166
+ config=self.sdk_configuration,
167
+ base_url=base_url or "",
168
+ operation_id="createImageEdit",
169
+ oauth2_scopes=None,
170
+ security_source=get_security_from_env(
171
+ self.sdk_configuration.security, models.Security
172
+ ),
173
+ ),
174
+ request=req,
175
+ error_status_codes=["4XX", "5XX"],
176
+ retry_config=retry_config,
177
+ )
178
+
179
+ if utils.match_response(http_res, "200", "application/json"):
180
+ return unmarshal_json_response(models.CreateImageEditResponseBody, http_res)
181
+ if utils.match_response(http_res, "4XX", "*"):
182
+ http_res_text = utils.stream_to_text(http_res)
183
+ raise models.APIError("API error occurred", http_res, http_res_text)
184
+ if utils.match_response(http_res, "5XX", "*"):
185
+ http_res_text = utils.stream_to_text(http_res)
186
+ raise models.APIError("API error occurred", http_res, http_res_text)
187
+
188
+ raise models.APIError("Unexpected response received", http_res)
189
+
190
+ async def create_async(
191
+ self,
192
+ *,
193
+ model: str,
194
+ prompt: str,
195
+ image: Optional[Any] = None,
196
+ n: OptionalNullable[int] = 1,
197
+ size: OptionalNullable[str] = UNSET,
198
+ quality: OptionalNullable[
199
+ models_createimageeditop.CreateImageEditQuality
200
+ ] = UNSET,
201
+ response_format: Optional[
202
+ models_createimageeditop.CreateImageEditResponseFormat
203
+ ] = None,
204
+ user: Optional[str] = None,
205
+ name: Optional[str] = None,
206
+ fallbacks: Optional[
207
+ Union[
208
+ List[models_createimageeditop.CreateImageEditFallbacks],
209
+ List[models_createimageeditop.CreateImageEditFallbacksTypedDict],
210
+ ]
211
+ ] = None,
212
+ retry: Optional[
213
+ Union[
214
+ models_createimageeditop.CreateImageEditRetry,
215
+ models_createimageeditop.CreateImageEditRetryTypedDict,
216
+ ]
217
+ ] = None,
218
+ cache: Optional[
219
+ Union[
220
+ models_createimageeditop.CreateImageEditCache,
221
+ models_createimageeditop.CreateImageEditCacheTypedDict,
222
+ ]
223
+ ] = None,
224
+ load_balancer: Optional[
225
+ Union[
226
+ models_createimageeditop.CreateImageEditLoadBalancer,
227
+ models_createimageeditop.CreateImageEditLoadBalancerTypedDict,
228
+ ]
229
+ ] = None,
230
+ timeout: Optional[
231
+ Union[
232
+ models_createimageeditop.CreateImageEditTimeout,
233
+ models_createimageeditop.CreateImageEditTimeoutTypedDict,
234
+ ]
235
+ ] = None,
236
+ orq: Optional[
237
+ Union[
238
+ models_createimageeditop.CreateImageEditOrq,
239
+ models_createimageeditop.CreateImageEditOrqTypedDict,
240
+ ]
241
+ ] = None,
242
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
243
+ server_url: Optional[str] = None,
244
+ timeout_ms: Optional[int] = None,
245
+ http_headers: Optional[Mapping[str, str]] = None,
246
+ ) -> models.CreateImageEditResponseBody:
247
+ r"""Create image edit
248
+
249
+ Edit an Image
250
+
251
+ :param model: The model to use for image edit. [Check models](https://docs.orq.ai/docs/ai-gateway-supported-models#image-models)
252
+ :param prompt: A text description of the desired image(s).
253
+ :param image: The image(s) to edit. Must be a supported image file or an array of images. Each image should be a png, webp, or jpg file less than 50MB. You can provide up to 16 images.
254
+ :param n: The number of images to generate. Must be between 1 and 10.
255
+ :param size: The size of the generated images
256
+ :param quality: The quality of the image that will be generated. Auto will automatically select the best quality for the given model.
257
+ :param response_format: The format in which the generated images are returned. Some of the models only return the image in base64 format.
258
+ :param user: A unique identifier representing your end-user, which can help to monitor and detect abuse.
259
+ :param name: The name to display on the trace. If not specified, the default system name will be used.
260
+ :param fallbacks: Array of fallback models to use if primary model fails
261
+ :param retry: Retry configuration for the request
262
+ :param cache: Cache configuration for the request.
263
+ :param load_balancer: Load balancer configuration for the request.
264
+ :param timeout: Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured.
265
+ :param orq:
266
+ :param retries: Override the default retry configuration for this method
267
+ :param server_url: Override the default server URL for this method
268
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
269
+ :param http_headers: Additional headers to set or replace on requests.
270
+ """
271
+ base_url = None
272
+ url_variables = None
273
+ if timeout_ms is None:
274
+ timeout_ms = self.sdk_configuration.timeout_ms
275
+
276
+ if timeout_ms is None:
277
+ timeout_ms = 600000
278
+
279
+ if server_url is not None:
280
+ base_url = server_url
281
+ else:
282
+ base_url = self._get_url(base_url, url_variables)
283
+
284
+ request = models.CreateImageEditRequestBody(
285
+ model=model,
286
+ image=image,
287
+ prompt=prompt,
288
+ n=n,
289
+ size=size,
290
+ quality=quality,
291
+ response_format=response_format,
292
+ user=user,
293
+ name=name,
294
+ fallbacks=utils.get_pydantic_model(
295
+ fallbacks, Optional[List[models.CreateImageEditFallbacks]]
296
+ ),
297
+ retry=utils.get_pydantic_model(
298
+ retry, Optional[models.CreateImageEditRetry]
299
+ ),
300
+ cache=utils.get_pydantic_model(
301
+ cache, Optional[models.CreateImageEditCache]
302
+ ),
303
+ load_balancer=utils.get_pydantic_model(
304
+ load_balancer, Optional[models.CreateImageEditLoadBalancer]
305
+ ),
306
+ timeout=utils.get_pydantic_model(
307
+ timeout, Optional[models.CreateImageEditTimeout]
308
+ ),
309
+ orq=utils.get_pydantic_model(orq, Optional[models.CreateImageEditOrq]),
310
+ )
311
+
312
+ req = self._build_request_async(
313
+ method="POST",
314
+ path="/v2/router/images/edits",
315
+ base_url=base_url,
316
+ url_variables=url_variables,
317
+ request=request,
318
+ request_body_required=True,
319
+ request_has_path_params=False,
320
+ request_has_query_params=True,
321
+ user_agent_header="user-agent",
322
+ accept_header_value="application/json",
323
+ http_headers=http_headers,
324
+ security=self.sdk_configuration.security,
325
+ get_serialized_body=lambda: utils.serialize_request_body(
326
+ request, False, False, "multipart", models.CreateImageEditRequestBody
327
+ ),
328
+ allow_empty_value=None,
329
+ timeout_ms=timeout_ms,
330
+ )
331
+
332
+ if retries == UNSET:
333
+ if self.sdk_configuration.retry_config is not UNSET:
334
+ retries = self.sdk_configuration.retry_config
335
+
336
+ retry_config = None
337
+ if isinstance(retries, utils.RetryConfig):
338
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
339
+
340
+ http_res = await self.do_request_async(
341
+ hook_ctx=HookContext(
342
+ config=self.sdk_configuration,
343
+ base_url=base_url or "",
344
+ operation_id="createImageEdit",
345
+ oauth2_scopes=None,
346
+ security_source=get_security_from_env(
347
+ self.sdk_configuration.security, models.Security
348
+ ),
349
+ ),
350
+ request=req,
351
+ error_status_codes=["4XX", "5XX"],
352
+ retry_config=retry_config,
353
+ )
354
+
355
+ if utils.match_response(http_res, "200", "application/json"):
356
+ return unmarshal_json_response(models.CreateImageEditResponseBody, http_res)
357
+ if utils.match_response(http_res, "4XX", "*"):
358
+ http_res_text = await utils.stream_to_text_async(http_res)
359
+ raise models.APIError("API error occurred", http_res, http_res_text)
360
+ if utils.match_response(http_res, "5XX", "*"):
361
+ http_res_text = await utils.stream_to_text_async(http_res)
362
+ raise models.APIError("API error occurred", http_res, http_res_text)
363
+
364
+ raise models.APIError("Unexpected response received", http_res)