From 8a9d490c81ec8805e5ae0587c6fe4db6b3c886ba Mon Sep 17 00:00:00 2001 From: Kingston Date: Mon, 30 Jun 2025 18:59:46 +0800 Subject: [PATCH] Update measureInputUsage() docs to include multimodal input array --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a95607..c622ec7 100644 --- a/README.md +++ b/README.md @@ -555,10 +555,18 @@ A given language model session will have a maximum number of tokens it can proce console.log(`${session.inputUsage} tokens used, out of ${session.inputQuota} tokens available.`); ``` -To know how many tokens a string will consume, without actually processing it, developers can use the `measureInputUsage()` method: +To know how many tokens a prompt will consume, without actually processing it, developers can use the `measureInputUsage()` method. This method accepts the same input types as `prompt()`, including strings and multimodal input arrays: ```js -const usage = await session.measureInputUsage(promptString); +const stringUsage = await session.measureInputUsage(promptString); + +const audioUsage = await session.measureInputUsage([{ + role: "user", + content: [ + { type: "text", value: "My response to your critique:" }, + { type: "audio", value: audioBlob } + ] +}]); ``` Some notes on this API: