Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 16.7 KB

File metadata and controls

59 lines (43 loc) · 16.7 KB

Usage

Overview

Available Operations

  • get_usage - Get usage details for the team.

get_usage

Get usage details for the team.

Example Usage

import os

from friendli import SyncFriendli
from friendli.utils import parse_datetime

with SyncFriendli(
    token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
    res = friendli.usage.get_usage(
        start_time=parse_datetime("2026-10-24T22:14:33.446Z"),
        end_time=parse_datetime("2024-09-25T19:40:35.742Z"),
    )

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
start_time date ✔️ RFC 3339 timestamp in UTC. Must fall on a 5-minute boundary (e.g., 2026-01-01T10:05:00Z). It must be no earlier than one year ago. When bucket_width=1h, it must align to an hour boundary (e.g., 10:00:00Z); when bucket_width=1d, it must align to a day boundary (e.g., 00:00:00Z).
end_time date ✔️ RFC 3339 timestamp in UTC. Must fall on a 5-minute boundary (e.g., 2026-01-01T10:05:00Z), and its minute value must match start_time's. It must obey the same hour/day alignment as start_time when bucket_width=1h or 1d.
bucket_width OptionalNullable[models.UsageBucketWidth] Width of each time bucket in response. Currently 1d, 1h, and 5m are supported, default to 1d.
limit OptionalNullable[int] Specifies the number of buckets to return.
- bucket_width=1d: default limit = 7, max limit = 31
- bucket_width=1h: default limit = 24, max limit = 168
- bucket_width=5m: default limit = 12, max limit = 288
page OptionalNullable[str] A cursor for use in pagination. Corresponding to the next_page field from the previous response.
group_by List[models.UsageGroupBy] Group the usage by the specified fields. Support fields include model, product_type, user_id and any combination of them.
models List[str] Return only usage for the listed Model APIs and Dedicated Endpoints. Values are model IDs, endpoint IDs, or a mix.
user_ids List[str] Return only usage for these users.
product_types List[models.ProductType] Return only usage for the specified product types. Supported fields include model_apis, dedicated_endpoints and any combination of them.
gpu_types List[str] Return only usage for the specified GPU types. When this filter is given, only 'gpu_usage' will be provided. Combining gpu_types with 'product_types=model_apis` is rejected with HTTP 400.
x_friendli_team OptionalNullable[str] ID of team to run requests as (optional parameter).
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UsageResponse

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*