everstack 0.1.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.
@@ -0,0 +1,160 @@
1
+ """Chat completions resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, Iterator, List, Optional, Union, overload
6
+
7
+ from .._transport import Transport, AsyncTransport
8
+ from .._types import ChatCompletionChunk, ChatCompletionResponse
9
+
10
+
11
+ def _parse_model(model: str) -> str:
12
+ """Extract model name from @provider/model format."""
13
+ if model.startswith("@"):
14
+ parts = model.split("/", 1)
15
+ if len(parts) == 2:
16
+ return parts[1]
17
+ return model
18
+
19
+
20
+ def _build_body(
21
+ model: str,
22
+ messages: List[Dict[str, Any]],
23
+ *,
24
+ stream: bool = False,
25
+ temperature: Optional[float] = None,
26
+ top_p: Optional[float] = None,
27
+ max_tokens: Optional[int] = None,
28
+ max_completion_tokens: Optional[int] = None,
29
+ stop: Optional[Union[str, List[str]]] = None,
30
+ tools: Optional[List[Dict[str, Any]]] = None,
31
+ tool_choice: Optional[Any] = None,
32
+ response_format: Optional[Dict[str, Any]] = None,
33
+ **kwargs: Any,
34
+ ) -> Dict[str, Any]:
35
+ body: Dict[str, Any] = {
36
+ "model": _parse_model(model),
37
+ "messages": messages,
38
+ "stream": stream,
39
+ }
40
+ if temperature is not None:
41
+ body["temperature"] = temperature
42
+ if top_p is not None:
43
+ body["top_p"] = top_p
44
+ if max_tokens is not None:
45
+ body["max_tokens"] = max_tokens
46
+ if max_completion_tokens is not None:
47
+ body["max_completion_tokens"] = max_completion_tokens
48
+ if stop is not None:
49
+ body["stop"] = [stop] if isinstance(stop, str) else stop
50
+ if tools is not None:
51
+ body["tools"] = tools
52
+ if tool_choice is not None:
53
+ body["tool_choice"] = tool_choice
54
+ if response_format is not None:
55
+ body["response_format"] = response_format
56
+ body.update(kwargs)
57
+ return body
58
+
59
+
60
+ class Completions:
61
+ """Sync chat completions."""
62
+
63
+ def __init__(self, transport: Transport) -> None:
64
+ self._transport = transport
65
+
66
+ @overload
67
+ def create(
68
+ self,
69
+ *,
70
+ model: str,
71
+ messages: List[Dict[str, Any]],
72
+ stream: None = ...,
73
+ **kwargs: Any,
74
+ ) -> ChatCompletionResponse: ...
75
+
76
+ @overload
77
+ def create(
78
+ self,
79
+ *,
80
+ model: str,
81
+ messages: List[Dict[str, Any]],
82
+ stream: bool = ...,
83
+ **kwargs: Any,
84
+ ) -> Union[ChatCompletionResponse, Iterator[ChatCompletionChunk]]: ...
85
+
86
+ def create(
87
+ self,
88
+ *,
89
+ model: str,
90
+ messages: List[Dict[str, Any]],
91
+ stream: Optional[bool] = None,
92
+ **kwargs: Any,
93
+ ) -> Union[ChatCompletionResponse, Iterator[ChatCompletionChunk]]:
94
+ """Create a chat completion.
95
+
96
+ Example::
97
+
98
+ response = client.chat.completions.create(
99
+ model="@openai/gpt-4o",
100
+ messages=[{"role": "user", "content": "Hello!"}],
101
+ )
102
+ print(response.choices[0].message.content)
103
+ """
104
+ body = _build_body(model, messages, stream=bool(stream), **kwargs)
105
+
106
+ if stream:
107
+ return self._stream(body)
108
+
109
+ data = self._transport.request("POST", "/v1/chat/completions", json_body=body)
110
+ return ChatCompletionResponse.model_validate(data)
111
+
112
+ def _stream(self, body: Dict[str, Any]) -> Iterator[ChatCompletionChunk]:
113
+ for event in self._transport.stream("POST", "/v1/chat/completions", json_body=body):
114
+ yield ChatCompletionChunk.model_validate(event)
115
+
116
+
117
+ class AsyncCompletions:
118
+ """Async chat completions."""
119
+
120
+ def __init__(self, transport: AsyncTransport) -> None:
121
+ self._transport = transport
122
+
123
+ async def create(
124
+ self,
125
+ *,
126
+ model: str,
127
+ messages: List[Dict[str, Any]],
128
+ stream: Optional[bool] = None,
129
+ **kwargs: Any,
130
+ ) -> Any:
131
+ """Create a chat completion (async)."""
132
+ body = _build_body(model, messages, stream=bool(stream), **kwargs)
133
+
134
+ if stream:
135
+ return self._stream(body)
136
+
137
+ data = await self._transport.request("POST", "/v1/chat/completions", json_body=body)
138
+ return ChatCompletionResponse.model_validate(data)
139
+
140
+ async def _stream(self, body: Dict[str, Any]) -> Any:
141
+ async for event in self._transport.stream("POST", "/v1/chat/completions", json_body=body):
142
+ yield ChatCompletionChunk.model_validate(event)
143
+
144
+
145
+ class Chat:
146
+ """Sync chat resource with completions sub-resource."""
147
+
148
+ completions: Completions
149
+
150
+ def __init__(self, transport: Transport) -> None:
151
+ self.completions = Completions(transport)
152
+
153
+
154
+ class AsyncChat:
155
+ """Async chat resource with completions sub-resource."""
156
+
157
+ completions: AsyncCompletions
158
+
159
+ def __init__(self, transport: AsyncTransport) -> None:
160
+ self.completions = AsyncCompletions(transport)
@@ -0,0 +1,114 @@
1
+ """Datasets resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict
6
+
7
+ from .._transport import Transport, AsyncTransport
8
+
9
+
10
+ class _Items:
11
+ def __init__(self, transport: Transport) -> None:
12
+ self._t = transport
13
+
14
+ def create(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
15
+ return self._t.request("POST", f"/v1/datasets/{dataset_id}/items", json_body=kwargs)
16
+
17
+ def create_batch(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
18
+ return self._t.request(
19
+ "POST", f"/v1/datasets/{dataset_id}/items/batch", json_body=kwargs
20
+ )
21
+
22
+ def get(self, item_id: str) -> Dict[str, Any]:
23
+ return self._t.request("GET", f"/v1/datasets/items/{item_id}")
24
+
25
+ def list(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
26
+ return self._t.request("GET", f"/v1/datasets/{dataset_id}/items", params=kwargs)
27
+
28
+ def update(self, item_id: str, **kwargs: Any) -> Dict[str, Any]:
29
+ return self._t.request("PATCH", f"/v1/datasets/items/{item_id}", json_body=kwargs)
30
+
31
+ def delete(self, item_id: str) -> Dict[str, Any]:
32
+ return self._t.request("DELETE", f"/v1/datasets/items/{item_id}")
33
+
34
+
35
+ class _ScoreConfigs:
36
+ def __init__(self, transport: Transport) -> None:
37
+ self._t = transport
38
+
39
+ def create(self, **kwargs: Any) -> Dict[str, Any]:
40
+ return self._t.request("POST", "/v1/score-configs", json_body=kwargs)
41
+
42
+ def get(self, config_id: str) -> Dict[str, Any]:
43
+ return self._t.request("GET", f"/v1/score-configs/{config_id}")
44
+
45
+ def list(self, **kwargs: Any) -> Dict[str, Any]:
46
+ return self._t.request("GET", "/v1/score-configs", params=kwargs)
47
+
48
+ def update(self, config_id: str, **kwargs: Any) -> Dict[str, Any]:
49
+ return self._t.request("PATCH", f"/v1/score-configs/{config_id}", json_body=kwargs)
50
+
51
+ def delete(self, config_id: str) -> Dict[str, Any]:
52
+ return self._t.request("DELETE", f"/v1/score-configs/{config_id}")
53
+
54
+
55
+ class Datasets:
56
+ """Sync datasets resource."""
57
+
58
+ items: _Items
59
+ score_configs: _ScoreConfigs
60
+
61
+ def __init__(self, transport: Transport) -> None:
62
+ self._t = transport
63
+ self.items = _Items(transport)
64
+ self.score_configs = _ScoreConfigs(transport)
65
+
66
+ def create(self, **kwargs: Any) -> Dict[str, Any]:
67
+ return self._t.request("POST", "/v1/datasets", json_body=kwargs)
68
+
69
+ def get(self, dataset_id: str) -> Dict[str, Any]:
70
+ return self._t.request("GET", f"/v1/datasets/{dataset_id}")
71
+
72
+ def list(self, **kwargs: Any) -> Dict[str, Any]:
73
+ return self._t.request("GET", "/v1/datasets", params=kwargs)
74
+
75
+ def update(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
76
+ return self._t.request("PATCH", f"/v1/datasets/{dataset_id}", json_body=kwargs)
77
+
78
+ def delete(self, dataset_id: str) -> Dict[str, Any]:
79
+ return self._t.request("DELETE", f"/v1/datasets/{dataset_id}")
80
+
81
+ def list_builtin_metrics(self) -> Dict[str, Any]:
82
+ return self._t.request("GET", "/v1/builtin-metrics")
83
+
84
+
85
+ class AsyncDatasets:
86
+ """Async datasets resource."""
87
+
88
+ def __init__(self, transport: AsyncTransport) -> None:
89
+ self._t = transport
90
+
91
+ async def create(self, **kwargs: Any) -> Dict[str, Any]:
92
+ return await self._t.request("POST", "/v1/datasets", json_body=kwargs)
93
+
94
+ async def get(self, dataset_id: str) -> Dict[str, Any]:
95
+ return await self._t.request("GET", f"/v1/datasets/{dataset_id}")
96
+
97
+ async def list(self, **kwargs: Any) -> Dict[str, Any]:
98
+ return await self._t.request("GET", "/v1/datasets", params=kwargs)
99
+
100
+ async def update(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
101
+ return await self._t.request("PATCH", f"/v1/datasets/{dataset_id}", json_body=kwargs)
102
+
103
+ async def delete(self, dataset_id: str) -> Dict[str, Any]:
104
+ return await self._t.request("DELETE", f"/v1/datasets/{dataset_id}")
105
+
106
+ async def create_item(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
107
+ return await self._t.request(
108
+ "POST", f"/v1/datasets/{dataset_id}/items", json_body=kwargs
109
+ )
110
+
111
+ async def create_item_batch(self, dataset_id: str, **kwargs: Any) -> Dict[str, Any]:
112
+ return await self._t.request(
113
+ "POST", f"/v1/datasets/{dataset_id}/items/batch", json_body=kwargs
114
+ )
@@ -0,0 +1,70 @@
1
+ """Embeddings resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, List, Optional, Union
6
+
7
+ from .._transport import Transport, AsyncTransport
8
+ from .._types import EmbeddingsResponse
9
+
10
+
11
+ def _parse_model(model: str) -> str:
12
+ if model.startswith("@"):
13
+ parts = model.split("/", 1)
14
+ if len(parts) == 2:
15
+ return parts[1]
16
+ return model
17
+
18
+
19
+ class Embeddings:
20
+ """Sync embeddings resource."""
21
+
22
+ def __init__(self, transport: Transport) -> None:
23
+ self._transport = transport
24
+
25
+ def create(
26
+ self,
27
+ *,
28
+ model: str,
29
+ input: Union[str, List[str]],
30
+ dimensions: Optional[int] = None,
31
+ **kwargs: Any,
32
+ ) -> EmbeddingsResponse:
33
+ """Create embeddings for the given input."""
34
+ body: Dict[str, Any] = {
35
+ "model": _parse_model(model),
36
+ "input": input if isinstance(input, str) else " ".join(input),
37
+ }
38
+ if dimensions is not None:
39
+ body["dimensions"] = dimensions
40
+ body.update(kwargs)
41
+
42
+ data = self._transport.request("POST", "/v1/embeddings", json_body=body)
43
+ return EmbeddingsResponse.model_validate(data)
44
+
45
+
46
+ class AsyncEmbeddings:
47
+ """Async embeddings resource."""
48
+
49
+ def __init__(self, transport: AsyncTransport) -> None:
50
+ self._transport = transport
51
+
52
+ async def create(
53
+ self,
54
+ *,
55
+ model: str,
56
+ input: Union[str, List[str]],
57
+ dimensions: Optional[int] = None,
58
+ **kwargs: Any,
59
+ ) -> EmbeddingsResponse:
60
+ """Create embeddings for the given input (async)."""
61
+ body: Dict[str, Any] = {
62
+ "model": _parse_model(model),
63
+ "input": input if isinstance(input, str) else " ".join(input),
64
+ }
65
+ if dimensions is not None:
66
+ body["dimensions"] = dimensions
67
+ body.update(kwargs)
68
+
69
+ data = await self._transport.request("POST", "/v1/embeddings", json_body=body)
70
+ return EmbeddingsResponse.model_validate(data)
@@ -0,0 +1,99 @@
1
+ """Evaluations resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict
6
+
7
+ from .._transport import Transport, AsyncTransport
8
+
9
+
10
+ class _Runs:
11
+ def __init__(self, transport: Transport) -> None:
12
+ self._t = transport
13
+
14
+ def create(self, **kwargs: Any) -> Dict[str, Any]:
15
+ return self._t.request("POST", "/v1/eval-runs", json_body=kwargs)
16
+
17
+ def get(self, run_id: str) -> Dict[str, Any]:
18
+ return self._t.request("GET", f"/v1/eval-runs/{run_id}")
19
+
20
+ def list(self, **kwargs: Any) -> Dict[str, Any]:
21
+ return self._t.request("GET", "/v1/eval-runs", params=kwargs)
22
+
23
+ def cancel(self, run_id: str) -> Dict[str, Any]:
24
+ return self._t.request("POST", f"/v1/eval-runs/{run_id}/cancel", json_body={})
25
+
26
+ def delete(self, run_id: str) -> Dict[str, Any]:
27
+ return self._t.request("DELETE", f"/v1/eval-runs/{run_id}")
28
+
29
+ def retry(self, run_id: str) -> Dict[str, Any]:
30
+ return self._t.request("POST", f"/v1/eval-runs/{run_id}/retry", json_body={})
31
+
32
+ def get_items(self, eval_run_id: str, **kwargs: Any) -> Dict[str, Any]:
33
+ return self._t.request("GET", f"/v1/eval-runs/{eval_run_id}/items", params=kwargs)
34
+
35
+ def get_summary(self, run_id: str) -> Dict[str, Any]:
36
+ return self._t.request("GET", f"/v1/eval-runs/{run_id}/summary")
37
+
38
+ def compare(self, **kwargs: Any) -> Dict[str, Any]:
39
+ return self._t.request("POST", "/v1/eval-runs/compare", json_body=kwargs)
40
+
41
+ def set_baseline(self, eval_run_id: str, **kwargs: Any) -> Dict[str, Any]:
42
+ return self._t.request(
43
+ "POST", f"/v1/eval-runs/{eval_run_id}/baseline", json_body=kwargs
44
+ )
45
+
46
+
47
+ class _Schedules:
48
+ def __init__(self, transport: Transport) -> None:
49
+ self._t = transport
50
+
51
+ def create(self, **kwargs: Any) -> Dict[str, Any]:
52
+ return self._t.request("POST", "/v1/eval-schedules", json_body=kwargs)
53
+
54
+ def get(self, schedule_id: str) -> Dict[str, Any]:
55
+ return self._t.request("GET", f"/v1/eval-schedules/{schedule_id}")
56
+
57
+ def list(self, **kwargs: Any) -> Dict[str, Any]:
58
+ return self._t.request("GET", "/v1/eval-schedules", params=kwargs)
59
+
60
+ def update(self, schedule_id: str, **kwargs: Any) -> Dict[str, Any]:
61
+ return self._t.request(
62
+ "PATCH", f"/v1/eval-schedules/{schedule_id}", json_body=kwargs
63
+ )
64
+
65
+ def delete(self, schedule_id: str) -> Dict[str, Any]:
66
+ return self._t.request("DELETE", f"/v1/eval-schedules/{schedule_id}")
67
+
68
+
69
+ class Evaluations:
70
+ """Sync evaluations resource."""
71
+
72
+ runs: _Runs
73
+ schedules: _Schedules
74
+
75
+ def __init__(self, transport: Transport) -> None:
76
+ self.runs = _Runs(transport)
77
+ self.schedules = _Schedules(transport)
78
+
79
+
80
+ class AsyncEvaluations:
81
+ """Async evaluations resource."""
82
+
83
+ def __init__(self, transport: AsyncTransport) -> None:
84
+ self._t = transport
85
+
86
+ async def create_run(self, **kwargs: Any) -> Dict[str, Any]:
87
+ return await self._t.request("POST", "/v1/eval-runs", json_body=kwargs)
88
+
89
+ async def get_run(self, run_id: str) -> Dict[str, Any]:
90
+ return await self._t.request("GET", f"/v1/eval-runs/{run_id}")
91
+
92
+ async def list_runs(self, **kwargs: Any) -> Dict[str, Any]:
93
+ return await self._t.request("GET", "/v1/eval-runs", params=kwargs)
94
+
95
+ async def cancel_run(self, run_id: str) -> Dict[str, Any]:
96
+ return await self._t.request("POST", f"/v1/eval-runs/{run_id}/cancel", json_body={})
97
+
98
+ async def get_run_summary(self, run_id: str) -> Dict[str, Any]:
99
+ return await self._t.request("GET", f"/v1/eval-runs/{run_id}/summary")
@@ -0,0 +1,120 @@
1
+ """Images resource — generation, editing, variations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ from typing import Any, Dict, Optional
7
+
8
+ from .._transport import Transport, AsyncTransport
9
+ from .._types import ImageResponse
10
+
11
+
12
+ class Images:
13
+ def __init__(self, transport: Transport) -> None:
14
+ self._transport = transport
15
+
16
+ def generate(
17
+ self,
18
+ *,
19
+ prompt: str,
20
+ model: Optional[str] = None,
21
+ n: Optional[int] = None,
22
+ quality: Optional[str] = None,
23
+ response_format: Optional[str] = None,
24
+ size: Optional[str] = None,
25
+ style: Optional[str] = None,
26
+ user: Optional[str] = None,
27
+ **kwargs: Any,
28
+ ) -> ImageResponse:
29
+ """Generate images from a text prompt."""
30
+ body: Dict[str, Any] = {"prompt": prompt}
31
+ if model:
32
+ body["model"] = model
33
+ if n is not None:
34
+ body["n"] = n
35
+ if quality:
36
+ body["quality"] = quality
37
+ if response_format:
38
+ body["response_format"] = response_format
39
+ if size:
40
+ body["size"] = size
41
+ if style:
42
+ body["style"] = style
43
+ if user:
44
+ body["user"] = user
45
+ body.update(kwargs)
46
+ data = self._transport.request("POST", "/v1/images/generations", json_body=body)
47
+ return ImageResponse.model_validate(data)
48
+
49
+ def edit(
50
+ self,
51
+ *,
52
+ image: bytes,
53
+ prompt: str,
54
+ mask: Optional[bytes] = None,
55
+ model: Optional[str] = None,
56
+ n: Optional[int] = None,
57
+ size: Optional[str] = None,
58
+ **kwargs: Any,
59
+ ) -> ImageResponse:
60
+ """Edit an existing image."""
61
+ body: Dict[str, Any] = {
62
+ "image": base64.b64encode(image).decode(),
63
+ "prompt": prompt,
64
+ }
65
+ if mask:
66
+ body["mask"] = base64.b64encode(mask).decode()
67
+ if model:
68
+ body["model"] = model
69
+ if n is not None:
70
+ body["n"] = n
71
+ if size:
72
+ body["size"] = size
73
+ body.update(kwargs)
74
+ data = self._transport.request("POST", "/v1/images/edits", json_body=body)
75
+ return ImageResponse.model_validate(data)
76
+
77
+ def create_variation(
78
+ self,
79
+ *,
80
+ image: bytes,
81
+ model: Optional[str] = None,
82
+ n: Optional[int] = None,
83
+ size: Optional[str] = None,
84
+ **kwargs: Any,
85
+ ) -> ImageResponse:
86
+ """Create variations of an image."""
87
+ body: Dict[str, Any] = {"image": base64.b64encode(image).decode()}
88
+ if model:
89
+ body["model"] = model
90
+ if n is not None:
91
+ body["n"] = n
92
+ if size:
93
+ body["size"] = size
94
+ body.update(kwargs)
95
+ data = self._transport.request("POST", "/v1/images/variations", json_body=body)
96
+ return ImageResponse.model_validate(data)
97
+
98
+
99
+ class AsyncImages:
100
+ def __init__(self, transport: AsyncTransport) -> None:
101
+ self._transport = transport
102
+
103
+ async def generate(self, *, prompt: str, **kwargs: Any) -> ImageResponse:
104
+ body: Dict[str, Any] = {"prompt": prompt, **kwargs}
105
+ data = await self._transport.request("POST", "/v1/images/generations", json_body=body)
106
+ return ImageResponse.model_validate(data)
107
+
108
+ async def edit(self, *, image: bytes, prompt: str, **kwargs: Any) -> ImageResponse:
109
+ body: Dict[str, Any] = {
110
+ "image": base64.b64encode(image).decode(),
111
+ "prompt": prompt,
112
+ **kwargs,
113
+ }
114
+ data = await self._transport.request("POST", "/v1/images/edits", json_body=body)
115
+ return ImageResponse.model_validate(data)
116
+
117
+ async def create_variation(self, *, image: bytes, **kwargs: Any) -> ImageResponse:
118
+ body: Dict[str, Any] = {"image": base64.b64encode(image).decode(), **kwargs}
119
+ data = await self._transport.request("POST", "/v1/images/variations", json_body=body)
120
+ return ImageResponse.model_validate(data)
@@ -0,0 +1,30 @@
1
+ """Models resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .._transport import Transport, AsyncTransport
6
+ from .._types import ModelsListResponse
7
+
8
+
9
+ class Models:
10
+ """Sync models resource."""
11
+
12
+ def __init__(self, transport: Transport) -> None:
13
+ self._transport = transport
14
+
15
+ def list(self) -> ModelsListResponse:
16
+ """List available models."""
17
+ data = self._transport.request("GET", "/v1/gateway/models")
18
+ return ModelsListResponse.model_validate(data)
19
+
20
+
21
+ class AsyncModels:
22
+ """Async models resource."""
23
+
24
+ def __init__(self, transport: AsyncTransport) -> None:
25
+ self._transport = transport
26
+
27
+ async def list(self) -> ModelsListResponse:
28
+ """List available models (async)."""
29
+ data = await self._transport.request("GET", "/v1/gateway/models")
30
+ return ModelsListResponse.model_validate(data)
@@ -0,0 +1,53 @@
1
+ """Moderations resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, List, Optional, Union
6
+
7
+ from .._transport import Transport, AsyncTransport
8
+ from .._types import ModerationResponse
9
+
10
+
11
+ class Moderations:
12
+ def __init__(self, transport: Transport) -> None:
13
+ self._transport = transport
14
+
15
+ def create(
16
+ self,
17
+ *,
18
+ input: Optional[str] = None,
19
+ inputs: Optional[List[Dict[str, Any]]] = None,
20
+ model: Optional[str] = None,
21
+ ) -> ModerationResponse:
22
+ """Classify content for policy violations."""
23
+ body: Dict[str, Any] = {}
24
+ if input is not None:
25
+ body["input"] = input
26
+ if inputs is not None:
27
+ body["inputs"] = inputs
28
+ if model:
29
+ body["model"] = model
30
+ data = self._transport.request("POST", "/v1/moderations", json_body=body)
31
+ return ModerationResponse.model_validate(data)
32
+
33
+
34
+ class AsyncModerations:
35
+ def __init__(self, transport: AsyncTransport) -> None:
36
+ self._transport = transport
37
+
38
+ async def create(
39
+ self,
40
+ *,
41
+ input: Optional[str] = None,
42
+ inputs: Optional[List[Dict[str, Any]]] = None,
43
+ model: Optional[str] = None,
44
+ ) -> ModerationResponse:
45
+ body: Dict[str, Any] = {}
46
+ if input is not None:
47
+ body["input"] = input
48
+ if inputs is not None:
49
+ body["inputs"] = inputs
50
+ if model:
51
+ body["model"] = model
52
+ data = await self._transport.request("POST", "/v1/moderations", json_body=body)
53
+ return ModerationResponse.model_validate(data)