Skip to content

Commit fdf1072

Browse files
feat(api): update via SDK Studio
1 parent cab4d0e commit fdf1072

File tree

10 files changed

+350
-35
lines changed

10 files changed

+350
-35
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 26
1+
configured_endpoints: 27
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate-mpatankar%2Freplicate-client-e6d33ab6eefa3c8d7a322723d5eb38b10125260c59f41cb6adeb066996737a20.yml

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ client = ReplicateClient(
3636
), # This is the default and can be omitted
3737
)
3838

39-
client.collections.list()
39+
account = client.accounts.list()
40+
print(account.type)
4041
```
4142

4243
While you can provide a `bearer_token` keyword argument,
@@ -61,7 +62,8 @@ client = AsyncReplicateClient(
6162

6263

6364
async def main() -> None:
64-
await client.collections.list()
65+
account = await client.accounts.list()
66+
print(account.type)
6567

6668

6769
asyncio.run(main())
@@ -94,7 +96,7 @@ from replicate_client import ReplicateClient
9496
client = ReplicateClient()
9597

9698
try:
97-
client.collections.list()
99+
client.accounts.list()
98100
except replicate_client.APIConnectionError as e:
99101
print("The server could not be reached")
100102
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -137,7 +139,7 @@ client = ReplicateClient(
137139
)
138140

139141
# Or, configure per-request:
140-
client.with_options(max_retries=5).collections.list()
142+
client.with_options(max_retries=5).accounts.list()
141143
```
142144

143145
### Timeouts
@@ -160,7 +162,7 @@ client = ReplicateClient(
160162
)
161163

162164
# Override per-request:
163-
client.with_options(timeout=5.0).collections.list()
165+
client.with_options(timeout=5.0).accounts.list()
164166
```
165167

166168
On timeout, an `APITimeoutError` is thrown.
@@ -201,11 +203,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
201203
from replicate_client import ReplicateClient
202204

203205
client = ReplicateClient()
204-
response = client.collections.with_raw_response.list()
206+
response = client.accounts.with_raw_response.list()
205207
print(response.headers.get('X-My-Header'))
206208

207-
collection = response.parse() # get the object that `collections.list()` would have returned
208-
print(collection)
209+
account = response.parse() # get the object that `accounts.list()` would have returned
210+
print(account.type)
209211
```
210212

211213
These methods return an [`APIResponse`](https://github.com/stainless-sdks/replicate-client-python/tree/main/src/replicate_client/_response.py) object.
@@ -219,7 +221,7 @@ The above interface eagerly reads the full response body when you make the reque
219221
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
220222

221223
```python
222-
with client.collections.with_streaming_response.list() as response:
224+
with client.accounts.with_streaming_response.list() as response:
223225
print(response.headers.get("X-My-Header"))
224226

225227
for line in response.iter_lines():

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ Methods:
4141

4242
- <code title="get /hardware">client.hardware.<a href="./src/replicate_client/resources/hardware.py">list</a>() -> <a href="./src/replicate_client/types/hardware_list_response.py">HardwareListResponse</a></code>
4343

44+
# Accounts
45+
46+
Types:
47+
48+
```python
49+
from replicate_client.types import AccountListResponse
50+
```
51+
52+
Methods:
53+
54+
- <code title="get /account">client.accounts.<a href="./src/replicate_client/resources/accounts.py">list</a>() -> <a href="./src/replicate_client/types/account_list_response.py">AccountListResponse</a></code>
55+
4456
# Models
4557

4658
Methods:

src/replicate_client/_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
get_async_library,
2525
)
2626
from ._version import __version__
27-
from .resources import hardware, trainings, collections, deployments, predictions
27+
from .resources import accounts, hardware, trainings, collections, deployments, predictions
2828
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2929
from ._exceptions import APIStatusError, ReplicateClientError
3030
from ._base_client import (
@@ -51,6 +51,7 @@ class ReplicateClient(SyncAPIClient):
5151
collections: collections.CollectionsResource
5252
deployments: deployments.DeploymentsResource
5353
hardware: hardware.HardwareResource
54+
accounts: accounts.AccountsResource
5455
models: models.ModelsResource
5556
predictions: predictions.PredictionsResource
5657
trainings: trainings.TrainingsResource
@@ -115,6 +116,7 @@ def __init__(
115116
self.collections = collections.CollectionsResource(self)
116117
self.deployments = deployments.DeploymentsResource(self)
117118
self.hardware = hardware.HardwareResource(self)
119+
self.accounts = accounts.AccountsResource(self)
118120
self.models = models.ModelsResource(self)
119121
self.predictions = predictions.PredictionsResource(self)
120122
self.trainings = trainings.TrainingsResource(self)
@@ -231,6 +233,7 @@ class AsyncReplicateClient(AsyncAPIClient):
231233
collections: collections.AsyncCollectionsResource
232234
deployments: deployments.AsyncDeploymentsResource
233235
hardware: hardware.AsyncHardwareResource
236+
accounts: accounts.AsyncAccountsResource
234237
models: models.AsyncModelsResource
235238
predictions: predictions.AsyncPredictionsResource
236239
trainings: trainings.AsyncTrainingsResource
@@ -295,6 +298,7 @@ def __init__(
295298
self.collections = collections.AsyncCollectionsResource(self)
296299
self.deployments = deployments.AsyncDeploymentsResource(self)
297300
self.hardware = hardware.AsyncHardwareResource(self)
301+
self.accounts = accounts.AsyncAccountsResource(self)
298302
self.models = models.AsyncModelsResource(self)
299303
self.predictions = predictions.AsyncPredictionsResource(self)
300304
self.trainings = trainings.AsyncTrainingsResource(self)
@@ -412,6 +416,7 @@ def __init__(self, client: ReplicateClient) -> None:
412416
self.collections = collections.CollectionsResourceWithRawResponse(client.collections)
413417
self.deployments = deployments.DeploymentsResourceWithRawResponse(client.deployments)
414418
self.hardware = hardware.HardwareResourceWithRawResponse(client.hardware)
419+
self.accounts = accounts.AccountsResourceWithRawResponse(client.accounts)
415420
self.models = models.ModelsResourceWithRawResponse(client.models)
416421
self.predictions = predictions.PredictionsResourceWithRawResponse(client.predictions)
417422
self.trainings = trainings.TrainingsResourceWithRawResponse(client.trainings)
@@ -423,6 +428,7 @@ def __init__(self, client: AsyncReplicateClient) -> None:
423428
self.collections = collections.AsyncCollectionsResourceWithRawResponse(client.collections)
424429
self.deployments = deployments.AsyncDeploymentsResourceWithRawResponse(client.deployments)
425430
self.hardware = hardware.AsyncHardwareResourceWithRawResponse(client.hardware)
431+
self.accounts = accounts.AsyncAccountsResourceWithRawResponse(client.accounts)
426432
self.models = models.AsyncModelsResourceWithRawResponse(client.models)
427433
self.predictions = predictions.AsyncPredictionsResourceWithRawResponse(client.predictions)
428434
self.trainings = trainings.AsyncTrainingsResourceWithRawResponse(client.trainings)
@@ -434,6 +440,7 @@ def __init__(self, client: ReplicateClient) -> None:
434440
self.collections = collections.CollectionsResourceWithStreamingResponse(client.collections)
435441
self.deployments = deployments.DeploymentsResourceWithStreamingResponse(client.deployments)
436442
self.hardware = hardware.HardwareResourceWithStreamingResponse(client.hardware)
443+
self.accounts = accounts.AccountsResourceWithStreamingResponse(client.accounts)
437444
self.models = models.ModelsResourceWithStreamingResponse(client.models)
438445
self.predictions = predictions.PredictionsResourceWithStreamingResponse(client.predictions)
439446
self.trainings = trainings.TrainingsResourceWithStreamingResponse(client.trainings)
@@ -445,6 +452,7 @@ def __init__(self, client: AsyncReplicateClient) -> None:
445452
self.collections = collections.AsyncCollectionsResourceWithStreamingResponse(client.collections)
446453
self.deployments = deployments.AsyncDeploymentsResourceWithStreamingResponse(client.deployments)
447454
self.hardware = hardware.AsyncHardwareResourceWithStreamingResponse(client.hardware)
455+
self.accounts = accounts.AsyncAccountsResourceWithStreamingResponse(client.accounts)
448456
self.models = models.AsyncModelsResourceWithStreamingResponse(client.models)
449457
self.predictions = predictions.AsyncPredictionsResourceWithStreamingResponse(client.predictions)
450458
self.trainings = trainings.AsyncTrainingsResourceWithStreamingResponse(client.trainings)

src/replicate_client/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
ModelsResourceWithStreamingResponse,
99
AsyncModelsResourceWithStreamingResponse,
1010
)
11+
from .accounts import (
12+
AccountsResource,
13+
AsyncAccountsResource,
14+
AccountsResourceWithRawResponse,
15+
AsyncAccountsResourceWithRawResponse,
16+
AccountsResourceWithStreamingResponse,
17+
AsyncAccountsResourceWithStreamingResponse,
18+
)
1119
from .hardware import (
1220
HardwareResource,
1321
AsyncHardwareResource,
@@ -76,6 +84,12 @@
7684
"AsyncHardwareResourceWithRawResponse",
7785
"HardwareResourceWithStreamingResponse",
7886
"AsyncHardwareResourceWithStreamingResponse",
87+
"AccountsResource",
88+
"AsyncAccountsResource",
89+
"AccountsResourceWithRawResponse",
90+
"AsyncAccountsResourceWithRawResponse",
91+
"AccountsResourceWithStreamingResponse",
92+
"AsyncAccountsResourceWithStreamingResponse",
7993
"ModelsResource",
8094
"AsyncModelsResource",
8195
"ModelsResourceWithRawResponse",
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
import httpx
6+
7+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
8+
from .._compat import cached_property
9+
from .._resource import SyncAPIResource, AsyncAPIResource
10+
from .._response import (
11+
to_raw_response_wrapper,
12+
to_streamed_response_wrapper,
13+
async_to_raw_response_wrapper,
14+
async_to_streamed_response_wrapper,
15+
)
16+
from .._base_client import make_request_options
17+
from ..types.account_list_response import AccountListResponse
18+
19+
__all__ = ["AccountsResource", "AsyncAccountsResource"]
20+
21+
22+
class AccountsResource(SyncAPIResource):
23+
@cached_property
24+
def with_raw_response(self) -> AccountsResourceWithRawResponse:
25+
"""
26+
This property can be used as a prefix for any HTTP method call to return
27+
the raw response object instead of the parsed content.
28+
29+
For more information, see https://www.github.com/stainless-sdks/replicate-client-python#accessing-raw-response-data-eg-headers
30+
"""
31+
return AccountsResourceWithRawResponse(self)
32+
33+
@cached_property
34+
def with_streaming_response(self) -> AccountsResourceWithStreamingResponse:
35+
"""
36+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
37+
38+
For more information, see https://www.github.com/stainless-sdks/replicate-client-python#with_streaming_response
39+
"""
40+
return AccountsResourceWithStreamingResponse(self)
41+
42+
def list(
43+
self,
44+
*,
45+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
46+
# The extra values given here take precedence over values defined on the client or passed to this method.
47+
extra_headers: Headers | None = None,
48+
extra_query: Query | None = None,
49+
extra_body: Body | None = None,
50+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
51+
) -> AccountListResponse:
52+
"""
53+
Returns information about the user or organization associated with the provided
54+
API token.
55+
56+
Example cURL request:
57+
58+
```console
59+
curl -s \\
60+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
61+
https://api.replicate.com/v1/account
62+
```
63+
64+
The response will be a JSON object describing the account:
65+
66+
```json
67+
{
68+
"type": "organization",
69+
"username": "acme",
70+
"name": "Acme Corp, Inc.",
71+
"github_url": "https://github.com/acme"
72+
}
73+
```
74+
"""
75+
return self._get(
76+
"/account",
77+
options=make_request_options(
78+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
79+
),
80+
cast_to=AccountListResponse,
81+
)
82+
83+
84+
class AsyncAccountsResource(AsyncAPIResource):
85+
@cached_property
86+
def with_raw_response(self) -> AsyncAccountsResourceWithRawResponse:
87+
"""
88+
This property can be used as a prefix for any HTTP method call to return
89+
the raw response object instead of the parsed content.
90+
91+
For more information, see https://www.github.com/stainless-sdks/replicate-client-python#accessing-raw-response-data-eg-headers
92+
"""
93+
return AsyncAccountsResourceWithRawResponse(self)
94+
95+
@cached_property
96+
def with_streaming_response(self) -> AsyncAccountsResourceWithStreamingResponse:
97+
"""
98+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
99+
100+
For more information, see https://www.github.com/stainless-sdks/replicate-client-python#with_streaming_response
101+
"""
102+
return AsyncAccountsResourceWithStreamingResponse(self)
103+
104+
async def list(
105+
self,
106+
*,
107+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
108+
# The extra values given here take precedence over values defined on the client or passed to this method.
109+
extra_headers: Headers | None = None,
110+
extra_query: Query | None = None,
111+
extra_body: Body | None = None,
112+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
113+
) -> AccountListResponse:
114+
"""
115+
Returns information about the user or organization associated with the provided
116+
API token.
117+
118+
Example cURL request:
119+
120+
```console
121+
curl -s \\
122+
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \\
123+
https://api.replicate.com/v1/account
124+
```
125+
126+
The response will be a JSON object describing the account:
127+
128+
```json
129+
{
130+
"type": "organization",
131+
"username": "acme",
132+
"name": "Acme Corp, Inc.",
133+
"github_url": "https://github.com/acme"
134+
}
135+
```
136+
"""
137+
return await self._get(
138+
"/account",
139+
options=make_request_options(
140+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
141+
),
142+
cast_to=AccountListResponse,
143+
)
144+
145+
146+
class AccountsResourceWithRawResponse:
147+
def __init__(self, accounts: AccountsResource) -> None:
148+
self._accounts = accounts
149+
150+
self.list = to_raw_response_wrapper(
151+
accounts.list,
152+
)
153+
154+
155+
class AsyncAccountsResourceWithRawResponse:
156+
def __init__(self, accounts: AsyncAccountsResource) -> None:
157+
self._accounts = accounts
158+
159+
self.list = async_to_raw_response_wrapper(
160+
accounts.list,
161+
)
162+
163+
164+
class AccountsResourceWithStreamingResponse:
165+
def __init__(self, accounts: AccountsResource) -> None:
166+
self._accounts = accounts
167+
168+
self.list = to_streamed_response_wrapper(
169+
accounts.list,
170+
)
171+
172+
173+
class AsyncAccountsResourceWithStreamingResponse:
174+
def __init__(self, accounts: AsyncAccountsResource) -> None:
175+
self._accounts = accounts
176+
177+
self.list = async_to_streamed_response_wrapper(
178+
accounts.list,
179+
)

src/replicate_client/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .model_create_params import ModelCreateParams as ModelCreateParams
66
from .prediction_response import PredictionResponse as PredictionResponse
7+
from .account_list_response import AccountListResponse as AccountListResponse
78
from .hardware_list_response import HardwareListResponse as HardwareListResponse
89
from .prediction_list_params import PredictionListParams as PredictionListParams
910
from .deployment_create_params import DeploymentCreateParams as DeploymentCreateParams

0 commit comments

Comments
 (0)