跳至內容

The number of output and input tokens in Bedrock responses

0

I want to find the number of output and input tokens in retrieve_and_generate and invoke_agent API. In the response structure of the invoke_agent I can parse the Eventcompletion and access the output and input tokens. But I cant find any field in the retrieve_and_generate API. I want to know how to find number of input and output tokens inside the retrieve_and_generate API or its not possible?

已提問 1 年前檢視次數 1117 次
1 個回答
0
已接受的答案

For the retrieve_and_generate API in Amazon Bedrock, there isn't a direct way to access the number of input and output tokens in the response structure, unlike the invoke_agent API where you can parse the EventCompletion to get this information.

The retrieve_and_generate API doesn't provide explicit token count information in its response. This means that, unfortunately, it's not possible to directly obtain the number of input and output tokens from the retrieve_and_generate API response.

However, it's worth noting that token usage information is generally available for other Bedrock operations. For example, when using the InvokeModel or Converse APIs, you can typically find token usage details in the response. These details usually include the number of input tokens, output tokens, and total tokens used for the request.

If token count information is crucial for your use case with retrieve_and_generate, you might need to consider alternative approaches or use other APIs that provide this information explicitly. You could also reach out to AWS support for more specific guidance on this particular API's behavior regarding token counts.

Sources
TokenUsage - Amazon Bedrock
Generate responses in the console using playgrounds - Amazon Bedrock
Chat with a model in the Amazon Bedrock in SageMaker Unified Studio chat playground - Amazon SageMaker Unified Studio

已回答 1 年前
專家
已審閱 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。