Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-candles-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/ai': patch
---

Add deprecation label to `totalBillableCharacters`. `totalTokens` should be used instead.
1 change: 1 addition & 0 deletions common/api-review/ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface CountTokensRequest {
// @public
export interface CountTokensResponse {
promptTokensDetails?: ModalityTokenCount[];
// @deprecated (undocumented)
totalBillableCharacters?: number;
totalTokens: number;
}
Expand Down
11 changes: 7 additions & 4 deletions docs-devsite/ai.counttokensresponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface CountTokensResponse
| Property | Type | Description |
| --- | --- | --- |
| [promptTokensDetails](./ai.counttokensresponse.md#counttokensresponseprompttokensdetails) | [ModalityTokenCount](./ai.modalitytokencount.md#modalitytokencount_interface)<!-- -->\[\] | The breakdown, by modality, of how many tokens are consumed by the prompt. |
| [totalBillableCharacters](./ai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request.<!-- -->This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)<!-- -->). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this property is not supported and will default to 0. |
| [totalBillableCharacters](./ai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | |
| [totalTokens](./ai.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. |

## CountTokensResponse.promptTokensDetails
Expand All @@ -38,9 +38,12 @@ promptTokensDetails?: ModalityTokenCount[];

## CountTokensResponse.totalBillableCharacters

The total number of billable characters counted across all instances from the request.

This property is only supported when using the Vertex AI Gemini API ([VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)<!-- -->). When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this property is not supported and will default to 0.
> Warning: This API is now obsolete.
>
> Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`<!-- -->.
>
> The total number of billable characters counted across all instances from the request.
>

<b>Signature:</b>

Expand Down
5 changes: 2 additions & 3 deletions packages/ai/src/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,10 @@ export interface CountTokensResponse {
*/
totalTokens: number;
/**
* @deprecated Use `totalTokens` instead. This property is undefined when using models greater than `gemini-1.5-*`.
*
* The total number of billable characters counted across all instances
* from the request.
*
* This property is only supported when using the Vertex AI Gemini API ({@link VertexAIBackend}).
* When using the Gemini Developer API ({@link GoogleAIBackend}), this property is not supported and will default to 0.
*/
totalBillableCharacters?: number;
/**
Expand Down
Loading