amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

AI does not support receiving input and output tokens used

Open rpostulart opened this issue 11 months ago • 4 comments

Is your feature request related to a problem? Please describe. I would like to track and limit the token usage per person. Therefor I need to receive the used tokens per input and output

Describe the solution you'd like I want meta data to be returned:

"usage": { "inputTokens": number, "outputTokens": number, "totalTokens": number }

in the docs: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html#API_runtime_ConverseStream_ResponseElements

rpostulart avatar Dec 18 '24 05:12 rpostulart

Thanks for opening this feature request @rpostulart. I'm transferring it over to the amplify-backend repo.

Providing access to the Bedrock request metadata and allowing per user token based throttling is something we're thinking about.

A few questions to help us better understand your use case:

  • Is this for conversation routes, generation routes, or both?
  • What criteria are you expecting to use to determine if a user request should be throttled? Is it n tokens within last x time frame? Something else?

atierian avatar Dec 19 '24 16:12 atierian

  • It is for conversations!
  • I would like to set a max tokens on user level in DynomaDB and for each request if there are sufficient tokens, it not then deny the request, otherwise continue and receive the usedTokens and update the Dynamodb

rpostulart avatar Dec 23 '24 12:12 rpostulart

any update?

rpostulart avatar Feb 10 '25 20:02 rpostulart

Any update how this can be achieved?

rpostulart avatar Mar 17 '25 21:03 rpostulart