From c7aeb1b44f8494ee30b2728d4f9396c7ced3d03a Mon Sep 17 00:00:00 2001 From: fpagny Date: Fri, 21 Mar 2025 13:39:36 +0100 Subject: [PATCH 1/3] feat(genapi): add faq about token consumption monitoring --- pages/generative-apis/faq.mdx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pages/generative-apis/faq.mdx b/pages/generative-apis/faq.mdx index 154d6753fa..e42849e959 100644 --- a/pages/generative-apis/faq.mdx +++ b/pages/generative-apis/faq.mdx @@ -29,6 +29,28 @@ Note that: - Cockpits are isolated by Projects, hence you first need to select the right project in the Scaleway console before accessing Cockpit to see your token consumption for this Project (you can see the `project_id` in the Cockpit URL: `https://{project_id}.dashboard.obs.fr-par.scw.cloud/`. - Cockpit graphs can take up to 1 hour to update token consumption, see [Troubleshooting](https://www.scaleway.com/en/docs/generative-apis/troubleshooting/fixing-common-issues/#tokens-consumption-is-not-displayed-in-cockpit-metrics) for further details. +## How can I give access to token consumption to my users outside of Scaleway? +If your users do not have a Scaleway account, you can still give them access to their Generative API usage consumption by either: +- Providing them an access to Grafana inside [Cockpit](https://console.scaleway.com/cockpit/overview). You can create dedicated [Grafana users](https://console.scaleway.com/cockpit/users) (unrelated to Scaleway IAM currently), with read-only accesses (**Viewer** Role). Note that these users will still have access to all other Cockpit dashboards for this project. +- Collecting consumption data from [Billing API](https://www.scaleway.com/en/developers/api/billing/#path-consumption-get-monthly-consumption) and expose it to your users. Consumption can be detailed by projects. +- Collecting consumption data from [Cockpit Data Source](https://console.scaleway.com/cockpit/dataSource) and expose it to your users. As an example, you can query consumption using the following query: +```curl +curl -G 'https://{data-source-id}.metrics.cockpit.fr-par.scw.cloud/prometheus/api/v1/query_range' \ + --data-urlencode 'query=generative_apis_tokens_total{resource_name=~".*",type=~"(input_tokens|output_tokens)"}' \ + --data-urlencode 'start=2025-03-15T20:10:51.781Z' \ + --data-urlencode 'end=2025-03-20T20:10:51.781Z' \ + --data-urlencode 'step=1h' \ + -H "Authorization: Bearer $COCKPIT_TOKEN" | jq +``` +where: +- `data-source-id` is the id of your [Scaleway Metrics data source](https://console.scaleway.com/cockpit/dataSource) +- $COCKPIT_TOKEN is an environment variable storing your [Cockpit Token](https://console.scaleway.com/cockpit/tokens) + +You can see your token consumption in [Scaleway Cockpit](/cockpit/). You can access it from the Scaleway console under the [Metrics tab](https://console.scaleway.com/generative-api/metrics). +Note that: +- Cockpits are isolated by Projects, hence you first need to select the right project in the Scaleway console before accessing Cockpit to see your token consumption for this Project (you can see the `project_id` in the Cockpit URL: `https://{project_id}.dashboard.obs.fr-par.scw.cloud/`. +- Cockpit graphs can take up to 1 hour to update token consumption, see [Troubleshooting](https://www.scaleway.com/en/docs/generative-apis/troubleshooting/fixing-common-issues/#tokens-consumption-is-not-displayed-in-cockpit-metrics) for further details. + ## Can I configure a maximum billing threshold? Currently, you cannot configure a specific threshold after which your usage will blocked. However: - You can [configure billing alerts](/billing/how-to/use-billing-alerts/) to ensure you are warned when you hit specific budget thresholds. From 088bb2b027d715de9cc85f964bcac076b56df66d Mon Sep 17 00:00:00 2001 From: fpagny Date: Fri, 21 Mar 2025 13:41:21 +0100 Subject: [PATCH 2/3] feat(genapi): update faq --- pages/generative-apis/faq.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/generative-apis/faq.mdx b/pages/generative-apis/faq.mdx index e42849e959..a24b25cbc5 100644 --- a/pages/generative-apis/faq.mdx +++ b/pages/generative-apis/faq.mdx @@ -44,7 +44,8 @@ curl -G 'https://{data-source-id}.metrics.cockpit.fr-par.scw.cloud/prometheus/ap ``` where: - `data-source-id` is the id of your [Scaleway Metrics data source](https://console.scaleway.com/cockpit/dataSource) -- $COCKPIT_TOKEN is an environment variable storing your [Cockpit Token](https://console.scaleway.com/cockpit/tokens) +- `$COCKPIT_TOKEN` is an environment variable storing your [Cockpit Token](https://console.scaleway.com/cockpit/tokens) +- `start` and `end` time properties should be edited for your specific time range You can see your token consumption in [Scaleway Cockpit](/cockpit/). You can access it from the Scaleway console under the [Metrics tab](https://console.scaleway.com/generative-api/metrics). Note that: From d08cfb7949514c6fcde0b71eff9c5803b5869d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9da?= <87707325+nerda-codes@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:00:30 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- pages/generative-apis/faq.mdx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pages/generative-apis/faq.mdx b/pages/generative-apis/faq.mdx index a24b25cbc5..0bec3dc647 100644 --- a/pages/generative-apis/faq.mdx +++ b/pages/generative-apis/faq.mdx @@ -31,9 +31,9 @@ Note that: ## How can I give access to token consumption to my users outside of Scaleway? If your users do not have a Scaleway account, you can still give them access to their Generative API usage consumption by either: -- Providing them an access to Grafana inside [Cockpit](https://console.scaleway.com/cockpit/overview). You can create dedicated [Grafana users](https://console.scaleway.com/cockpit/users) (unrelated to Scaleway IAM currently), with read-only accesses (**Viewer** Role). Note that these users will still have access to all other Cockpit dashboards for this project. -- Collecting consumption data from [Billing API](https://www.scaleway.com/en/developers/api/billing/#path-consumption-get-monthly-consumption) and expose it to your users. Consumption can be detailed by projects. -- Collecting consumption data from [Cockpit Data Source](https://console.scaleway.com/cockpit/dataSource) and expose it to your users. As an example, you can query consumption using the following query: +- Providing them an access to Grafana inside [Cockpit](https://console.scaleway.com/cockpit/overview). You can create dedicated [Grafana users](https://console.scaleway.com/cockpit/users) with read-only access (**Viewer** Role). Note that these users will still have access to all other Cockpit dashboards for this project. +- Collecting consumption data from the [Billing API](https://www.scaleway.com/en/developers/api/billing/#path-consumption-get-monthly-consumption) and exposing it to your users. Consumption can be detailed by Projects. +- Collecting consumption data from [Cockpit data sources](https://console.scaleway.com/cockpit/dataSource) and exposing it to your users. As an example, you can query consumption using the following query: ```curl curl -G 'https://{data-source-id}.metrics.cockpit.fr-par.scw.cloud/prometheus/api/v1/query_range' \ --data-urlencode 'query=generative_apis_tokens_total{resource_name=~".*",type=~"(input_tokens|output_tokens)"}' \ @@ -42,15 +42,15 @@ curl -G 'https://{data-source-id}.metrics.cockpit.fr-par.scw.cloud/prometheus/ap --data-urlencode 'step=1h' \ -H "Authorization: Bearer $COCKPIT_TOKEN" | jq ``` -where: -- `data-source-id` is the id of your [Scaleway Metrics data source](https://console.scaleway.com/cockpit/dataSource) -- `$COCKPIT_TOKEN` is an environment variable storing your [Cockpit Token](https://console.scaleway.com/cockpit/tokens) -- `start` and `end` time properties should be edited for your specific time range +Make sure that you replace the following values: +- `data-source-id`: ID of your [Scaleway metrics data source](https://console.scaleway.com/cockpit/dataSource) +- `$COCKPIT_TOKEN`: your [Cockpit token](https://console.scaleway.com/cockpit/tokens) +- `start` and `end` time properties: your specific time range -You can see your token consumption in [Scaleway Cockpit](/cockpit/). You can access it from the Scaleway console under the [Metrics tab](https://console.scaleway.com/generative-api/metrics). +You can see your token consumption in [Scaleway Cockpit](https://console.scaleway.com/cockpit/). You can access it from the Scaleway console under the [Metrics tab](https://console.scaleway.com/generative-api/metrics). Note that: -- Cockpits are isolated by Projects, hence you first need to select the right project in the Scaleway console before accessing Cockpit to see your token consumption for this Project (you can see the `project_id` in the Cockpit URL: `https://{project_id}.dashboard.obs.fr-par.scw.cloud/`. -- Cockpit graphs can take up to 1 hour to update token consumption, see [Troubleshooting](https://www.scaleway.com/en/docs/generative-apis/troubleshooting/fixing-common-issues/#tokens-consumption-is-not-displayed-in-cockpit-metrics) for further details. +- Cockpits are isolated by Projects. You first need to select the right Project in the Scaleway console before accessing Cockpit to see your token consumption for the desired Project (you can see the `project_id` in the Cockpit URL: `https://{project_id}.dashboard.obs.fr-par.scw.cloud/`. +- Cockpit graphs can take up to 1 hour to update token consumption, see [Troubleshooting](/generative-apis/troubleshooting/fixing-common-issues/#tokens-consumption-is-not-displayed-in-cockpit-metrics) for further details. ## Can I configure a maximum billing threshold? Currently, you cannot configure a specific threshold after which your usage will blocked. However: