Skip to content
Merged
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ numpy = [
{ version = ">=1.26.0", python = ">=3.12" },
]
pillow = "^11.1.0"
black = "^25.9.0"

[tool.poetry.extras]
pyarrow = ["pyarrow"]
Expand Down
21 changes: 19 additions & 2 deletions src/together/cli/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,30 @@ def delete(client: Together, endpoint_id: str) -> None:
type=click.Choice(["dedicated", "serverless"]),
help="Filter by endpoint type",
)
@click.option(
"--mine",
type=click.BOOL,
default=None,
help="true (only mine), default=all",
)
@click.option(
"--usage-type",
type=click.Choice(["on-demand", "reserved"]),
help="Filter by endpoint usage type",
)
@click.pass_obj
@handle_api_errors
def list(
client: Together, json: bool, type: Literal["dedicated", "serverless"] | None
client: Together,
json: bool,
type: Literal["dedicated", "serverless"] | None,
usage_type: Literal["on-demand", "reserved"] | None,
mine: bool | None,
) -> None:
"""List all inference endpoints (includes both dedicated and serverless endpoints)."""
endpoints: List[ListEndpoint] = client.endpoints.list(type=type)
endpoints: List[ListEndpoint] = client.endpoints.list(
type=type, usage_type=usage_type, mine=mine
)

if not endpoints:
click.echo("No dedicated endpoints found", err=True)
Expand Down
46 changes: 39 additions & 7 deletions src/together/resources/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ def __init__(self, client: TogetherClient) -> None:
self._client = client

def list(
self, type: Optional[Literal["dedicated", "serverless"]] = None
self,
type: Optional[Literal["dedicated", "serverless"]] = None,
usage_type: Optional[Literal["on-demand", "reserved"]] = None,
mine: Optional[bool] = None,
) -> List[ListEndpoint]:
"""
List all endpoints, can be filtered by type.
List all endpoints, can be filtered by endpoint type and ownership.

Args:
type (str, optional): Filter endpoints by type ("dedicated" or "serverless"). Defaults to None.
type (str, optional): Filter endpoints by endpoint type ("dedicated" or "serverless"). Defaults to None.
usage_type (str, optional): Filter endpoints by usage type ("on-demand" or "reserved"). Defaults to None.
mine (bool, optional): If True, return only endpoints owned by the caller. Defaults to None.

Returns:
List[ListEndpoint]: List of endpoint objects
Expand All @@ -28,9 +33,20 @@ def list(
client=self._client,
)

params = {}
params: Dict[
str,
Union[
Literal["dedicated", "serverless"],
Literal["on-demand", "reserved"],
bool,
],
] = {}
if type is not None:
params["type"] = type
if usage_type is not None:
params["usage_type"] = usage_type
if mine is not None:
params["mine"] = mine

response, _, _ = requestor.request(
options=TogetherRequest(
Expand Down Expand Up @@ -263,13 +279,18 @@ def __init__(self, client: TogetherClient) -> None:
self._client = client

async def list(
self, type: Optional[Literal["dedicated", "serverless"]] = None
self,
type: Optional[Literal["dedicated", "serverless"]] = None,
usage_type: Optional[Literal["on-demand", "reserved"]] = None,
mine: Optional[bool] = None,
) -> List[ListEndpoint]:
"""
List all endpoints, can be filtered by type.
List all endpoints, can be filtered by type and ownership.

Args:
type (str, optional): Filter endpoints by type ("dedicated" or "serverless"). Defaults to None.
usage_type (str, optional): Filter endpoints by usage type ("on-demand" or "reserved"). Defaults to None.
mine (bool, optional): If True, return only endpoints owned by the caller. Defaults to None.

Returns:
List[ListEndpoint]: List of endpoint objects
Expand All @@ -278,9 +299,20 @@ async def list(
client=self._client,
)

params = {}
params: Dict[
str,
Union[
Literal["dedicated", "serverless"],
Literal["on-demand", "reserved"],
bool,
],
] = {}
if type is not None:
params["type"] = type
if usage_type is not None:
params["usage_type"] = usage_type
if mine is not None:
params["mine"] = mine

response, _, _ = await requestor.arequest(
options=TogetherRequest(
Expand Down