Skip to content

Commit 0613799

Browse files
committed
use v1 route
1 parent c8be2b1 commit 0613799

13 files changed

Lines changed: 395 additions & 94 deletions

File tree

src/together/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
MAX_RETRY_DELAY = 8.0
1010

1111
# API defaults
12-
BASE_URL = "https://api.together.xyz"
12+
BASE_URL = "https://api.together.xyz/v1"
1313

1414
# Download defaults
1515
DOWNLOAD_BLOCK_SIZE = 10 * 1024 * 1024 # 10 MB

src/together/resources/audio/speech.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def create(
7676
response, streamed, _ = requestor.request(
7777
options=TogetherRequest(
7878
method="POST",
79-
url="/v1/audio/speech",
79+
url="audio/speech",
8080
params=parameter_payload,
8181
),
8282
stream=stream,
@@ -144,7 +144,7 @@ async def create(
144144
response, _, _ = await requestor.arequest(
145145
options=TogetherRequest(
146146
method="POST",
147-
url="/v1/audio/speech",
147+
url="audio/speech",
148148
params=parameter_payload,
149149
),
150150
stream=stream,

src/together/resources/chat/completions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def create(
141141
response, _, _ = requestor.request(
142142
options=TogetherRequest(
143143
method="POST",
144-
url="/v1/chat/completions",
144+
url="chat/completions",
145145
params=parameter_payload,
146146
),
147147
stream=stream,
@@ -283,7 +283,7 @@ async def create(
283283
response, _, _ = await requestor.arequest(
284284
options=TogetherRequest(
285285
method="POST",
286-
url="/v1/chat/completions",
286+
url="chat/completions",
287287
params=parameter_payload,
288288
),
289289
stream=stream,

src/together/resources/completions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def create(
123123
response, _, _ = requestor.request(
124124
options=TogetherRequest(
125125
method="POST",
126-
url="/v1/completions",
126+
url="completions",
127127
params=parameter_payload,
128128
),
129129
stream=stream,
@@ -247,7 +247,7 @@ async def create(
247247
response, _, _ = await requestor.arequest(
248248
options=TogetherRequest(
249249
method="POST",
250-
url="/v1/completions",
250+
url="completions",
251251
params=parameter_payload,
252252
),
253253
stream=stream,

src/together/resources/embeddings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def create(
4747
response, _, _ = requestor.request(
4848
options=TogetherRequest(
4949
method="POST",
50-
url="/v1/embeddings",
50+
url="embeddings",
5151
params=parameter_payload,
5252
),
5353
stream=False,
@@ -93,7 +93,7 @@ async def create(
9393
response, _, _ = await requestor.arequest(
9494
options=TogetherRequest(
9595
method="POST",
96-
url="/v1/embeddings",
96+
url="embeddings",
9797
params=parameter_payload,
9898
),
9999
stream=False,

src/together/resources/endpoints.py

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def list(
3535
response, _, _ = requestor.request(
3636
options=TogetherRequest(
3737
method="GET",
38-
url="/v1/endpoints",
38+
url="endpoints",
3939
params=params,
4040
),
4141
stream=False,
@@ -59,6 +59,7 @@ def create(
5959
disable_prompt_cache: bool = False,
6060
disable_speculative_decoding: bool = False,
6161
state: Literal["STARTED", "STOPPED"] = "STARTED",
62+
inactive_timeout: Optional[int] = None,
6263
) -> DedicatedEndpoint:
6364
"""
6465
Create a new dedicated endpoint.
@@ -72,6 +73,7 @@ def create(
7273
disable_prompt_cache (bool, optional): Whether to disable the prompt cache. Defaults to False.
7374
disable_speculative_decoding (bool, optional): Whether to disable speculative decoding. Defaults to False.
7475
state (str, optional): The desired state of the endpoint. Defaults to "STARTED".
76+
inactive_timeout (int, optional): The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
7577
7678
Returns:
7779
DedicatedEndpoint: Object containing endpoint information
@@ -80,7 +82,7 @@ def create(
8082
client=self._client,
8183
)
8284

83-
data: Dict[str, Union[str, bool, Dict[str, int]]] = {
85+
data: Dict[str, Union[str, bool, Dict[str, int], int]] = {
8486
"model": model,
8587
"hardware": hardware,
8688
"autoscaling": {
@@ -95,10 +97,13 @@ def create(
9597
if display_name is not None:
9698
data["display_name"] = display_name
9799

100+
if inactive_timeout is not None:
101+
data["inactive_timeout"] = inactive_timeout
102+
98103
response, _, _ = requestor.request(
99104
options=TogetherRequest(
100105
method="POST",
101-
url="/v1/endpoints",
106+
url="endpoints",
102107
params=data,
103108
),
104109
stream=False,
@@ -125,7 +130,7 @@ def get(self, endpoint_id: str) -> DedicatedEndpoint:
125130
response, _, _ = requestor.request(
126131
options=TogetherRequest(
127132
method="GET",
128-
url=f"/v1/endpoints/{endpoint_id}",
133+
url=f"endpoints/{endpoint_id}",
129134
),
130135
stream=False,
131136
)
@@ -148,7 +153,7 @@ def delete(self, endpoint_id: str) -> None:
148153
requestor.request(
149154
options=TogetherRequest(
150155
method="DELETE",
151-
url=f"/v1/endpoints/{endpoint_id}",
156+
url=f"endpoints/{endpoint_id}",
152157
),
153158
stream=False,
154159
)
@@ -161,6 +166,7 @@ def update(
161166
max_replicas: Optional[int] = None,
162167
state: Optional[Literal["STARTED", "STOPPED"]] = None,
163168
display_name: Optional[str] = None,
169+
inactive_timeout: Optional[int] = None,
164170
) -> DedicatedEndpoint:
165171
"""
166172
Update an endpoint's configuration.
@@ -171,6 +177,7 @@ def update(
171177
max_replicas (int, optional): The maximum number of replicas to scale up to
172178
state (str, optional): The desired state of the endpoint ("STARTED" or "STOPPED")
173179
display_name (str, optional): A human-readable name for the endpoint
180+
inactive_timeout (int, optional): The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
174181
175182
Returns:
176183
DedicatedEndpoint: Object containing endpoint information
@@ -179,7 +186,7 @@ def update(
179186
client=self._client,
180187
)
181188

182-
data: Dict[str, Union[str, Dict[str, int]]] = {}
189+
data: Dict[str, Union[str, Dict[str, int], int]] = {}
183190

184191
if min_replicas is not None or max_replicas is not None:
185192
current_min = min_replicas
@@ -200,10 +207,13 @@ def update(
200207
if display_name is not None:
201208
data["display_name"] = display_name
202209

210+
if inactive_timeout is not None:
211+
data["inactive_timeout"] = inactive_timeout
212+
203213
response, _, _ = requestor.request(
204214
options=TogetherRequest(
205215
method="PATCH",
206-
url=f"/v1/endpoints/{endpoint_id}",
216+
url=f"endpoints/{endpoint_id}",
207217
params=data,
208218
),
209219
stream=False,
@@ -235,7 +245,7 @@ def list_hardware(self, model: Optional[str] = None) -> List[HardwareWithStatus]
235245
response, _, _ = requestor.request(
236246
options=TogetherRequest(
237247
method="GET",
238-
url="/v1/hardware",
248+
url="hardware",
239249
params=params,
240250
),
241251
stream=False,
@@ -275,7 +285,7 @@ async def list(
275285
response, _, _ = await requestor.arequest(
276286
options=TogetherRequest(
277287
method="GET",
278-
url="/v1/endpoints",
288+
url="endpoints",
279289
params=params,
280290
),
281291
stream=False,
@@ -297,6 +307,7 @@ async def create(
297307
disable_prompt_cache: bool = False,
298308
disable_speculative_decoding: bool = False,
299309
state: Literal["STARTED", "STOPPED"] = "STARTED",
310+
inactive_timeout: Optional[int] = None,
300311
) -> DedicatedEndpoint:
301312
"""
302313
Create a new dedicated endpoint.
@@ -310,6 +321,7 @@ async def create(
310321
disable_prompt_cache (bool, optional): Whether to disable the prompt cache. Defaults to False.
311322
disable_speculative_decoding (bool, optional): Whether to disable speculative decoding. Defaults to False.
312323
state (str, optional): The desired state of the endpoint. Defaults to "STARTED".
324+
inactive_timeout (int, optional): The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
313325
314326
Returns:
315327
DedicatedEndpoint: Object containing endpoint information
@@ -318,7 +330,7 @@ async def create(
318330
client=self._client,
319331
)
320332

321-
data: Dict[str, Union[str, bool, Dict[str, int]]] = {
333+
data: Dict[str, Union[str, bool, Dict[str, int], int]] = {
322334
"model": model,
323335
"hardware": hardware,
324336
"autoscaling": {
@@ -333,10 +345,13 @@ async def create(
333345
if display_name is not None:
334346
data["display_name"] = display_name
335347

348+
if inactive_timeout is not None:
349+
data["inactive_timeout"] = inactive_timeout
350+
336351
response, _, _ = await requestor.arequest(
337352
options=TogetherRequest(
338353
method="POST",
339-
url="/v1/endpoints",
354+
url="endpoints",
340355
params=data,
341356
),
342357
stream=False,
@@ -363,7 +378,7 @@ async def get(self, endpoint_id: str) -> DedicatedEndpoint:
363378
response, _, _ = await requestor.arequest(
364379
options=TogetherRequest(
365380
method="GET",
366-
url=f"/v1/endpoints/{endpoint_id}",
381+
url=f"endpoints/{endpoint_id}",
367382
),
368383
stream=False,
369384
)
@@ -386,7 +401,7 @@ async def delete(self, endpoint_id: str) -> None:
386401
await requestor.arequest(
387402
options=TogetherRequest(
388403
method="DELETE",
389-
url=f"/v1/endpoints/{endpoint_id}",
404+
url=f"endpoints/{endpoint_id}",
390405
),
391406
stream=False,
392407
)
@@ -399,6 +414,7 @@ async def update(
399414
max_replicas: Optional[int] = None,
400415
state: Optional[Literal["STARTED", "STOPPED"]] = None,
401416
display_name: Optional[str] = None,
417+
inactive_timeout: Optional[int] = None,
402418
) -> DedicatedEndpoint:
403419
"""
404420
Update an endpoint's configuration.
@@ -409,6 +425,7 @@ async def update(
409425
max_replicas (int, optional): The maximum number of replicas to scale up to
410426
state (str, optional): The desired state of the endpoint ("STARTED" or "STOPPED")
411427
display_name (str, optional): A human-readable name for the endpoint
428+
inactive_timeout (int, optional): The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
412429
413430
Returns:
414431
DedicatedEndpoint: Object containing endpoint information
@@ -417,7 +434,7 @@ async def update(
417434
client=self._client,
418435
)
419436

420-
data: Dict[str, Union[str, Dict[str, int]]] = {}
437+
data: Dict[str, Union[str, Dict[str, int], int]] = {}
421438

422439
if min_replicas is not None or max_replicas is not None:
423440
current_min = min_replicas
@@ -438,10 +455,13 @@ async def update(
438455
if display_name is not None:
439456
data["display_name"] = display_name
440457

458+
if inactive_timeout is not None:
459+
data["inactive_timeout"] = inactive_timeout
460+
441461
response, _, _ = await requestor.arequest(
442462
options=TogetherRequest(
443463
method="PATCH",
444-
url=f"/v1/endpoints/{endpoint_id}",
464+
url=f"endpoints/{endpoint_id}",
445465
params=data,
446466
),
447467
stream=False,
@@ -475,7 +495,7 @@ async def list_hardware(
475495
response, _, _ = await requestor.arequest(
476496
options=TogetherRequest(
477497
method="GET",
478-
url="/v1/hardware",
498+
url="hardware",
479499
params=params,
480500
),
481501
stream=False,

src/together/resources/files.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def list(self) -> FileList:
5757
response, _, _ = requestor.request(
5858
options=TogetherRequest(
5959
method="GET",
60-
url="/v1/files",
60+
url="files",
6161
),
6262
stream=False,
6363
)
@@ -74,7 +74,7 @@ def retrieve(self, id: str) -> FileResponse:
7474
response, _, _ = requestor.request(
7575
options=TogetherRequest(
7676
method="GET",
77-
url=f"/v1/files/{id}",
77+
url=f"files/{id}",
7878
),
7979
stream=False,
8080
)
@@ -110,7 +110,7 @@ def delete(self, id: str) -> FileDeleteResponse:
110110
response, _, _ = requestor.request(
111111
options=TogetherRequest(
112112
method="DELETE",
113-
url=f"/v1/files/{id}",
113+
url=f"files/{id}",
114114
),
115115
stream=False,
116116
)
@@ -137,7 +137,7 @@ async def list(self) -> FileList:
137137
response, _, _ = await requestor.arequest(
138138
options=TogetherRequest(
139139
method="GET",
140-
url="/v1/files",
140+
url="files",
141141
),
142142
stream=False,
143143
)
@@ -154,7 +154,7 @@ async def retrieve(self, id: str) -> FileResponse:
154154
response, _, _ = await requestor.arequest(
155155
options=TogetherRequest(
156156
method="GET",
157-
url=f"/v1/files/{id}",
157+
url=f"files/{id}",
158158
),
159159
stream=False,
160160
)
@@ -176,7 +176,7 @@ async def delete(self, id: str) -> FileDeleteResponse:
176176
response, _, _ = await requestor.arequest(
177177
options=TogetherRequest(
178178
method="DELETE",
179-
url=f"/v1/files/{id}",
179+
url=f"files/{id}",
180180
),
181181
stream=False,
182182
)

0 commit comments

Comments
 (0)