Skip to content

Get Agent Usage

client.Agents.GetUsage(ctx, uuid, query) (*AgentGetUsageResponse, error)
get/v2/gen-ai/agents/{uuid}/usage

To get agent usage, send a GET request to /v2/gen-ai/agents/{uuid}/usage. Returns usage metrics for the specified agent within the provided time range.

ParametersExpand Collapse
uuid string
query AgentGetUsageParams
Start param.Field[string]optional

Return all usage data from this date.

Stop param.Field[string]optional

Return all usage data up to this date, if omitted, will return up to the current date.

ReturnsExpand Collapse
type AgentGetUsageResponse struct{…}

Agent usage

LogInsightsUsage AgentGetUsageResponseLogInsightsUsageoptional

Resource Usage Description

Measurements []AgentGetUsageResponseLogInsightsUsageMeasurementoptional
Tokens int64optional
formatint64
UsageType stringoptional
ResourceUuid stringoptional
Start Timeoptional
formatdate-time
Stop Timeoptional
formatdate-time
Usage AgentGetUsageResponseUsageoptional

Resource Usage Description

Measurements []AgentGetUsageResponseUsageMeasurementoptional
Tokens int64optional
formatint64
UsageType stringoptional
ResourceUuid stringoptional
Start Timeoptional
formatdate-time
Stop Timeoptional
formatdate-time
Get Agent Usage
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := gradient.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  response, err := client.Agents.GetUsage(
    context.TODO(),
    `"123e4567-e89b-12d3-a456-426614174000"`,
    gradient.AgentGetUsageParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.LogInsightsUsage)
}
{
  "log_insights_usage": {
    "measurements": [
      {
        "tokens": 123,
        "usage_type": "example string"
      }
    ],
    "resource_uuid": "123e4567-e89b-12d3-a456-426614174000",
    "start": "2023-01-01T00:00:00Z",
    "stop": "2023-01-01T00:00:00Z"
  },
  "usage": {
    "measurements": [
      {
        "tokens": 123,
        "usage_type": "example string"
      }
    ],
    "resource_uuid": "123e4567-e89b-12d3-a456-426614174000",
    "start": "2023-01-01T00:00:00Z",
    "stop": "2023-01-01T00:00:00Z"
  }
}
Returns Examples
{
  "log_insights_usage": {
    "measurements": [
      {
        "tokens": 123,
        "usage_type": "example string"
      }
    ],
    "resource_uuid": "123e4567-e89b-12d3-a456-426614174000",
    "start": "2023-01-01T00:00:00Z",
    "stop": "2023-01-01T00:00:00Z"
  },
  "usage": {
    "measurements": [
      {
        "tokens": 123,
        "usage_type": "example string"
      }
    ],
    "resource_uuid": "123e4567-e89b-12d3-a456-426614174000",
    "start": "2023-01-01T00:00:00Z",
    "stop": "2023-01-01T00:00:00Z"
  }
}