countTokens

actual suspend fun countTokens(prompt: List<Content>): CountTokensResponse(source)
actual suspend fun countTokens(prompt: Content, vararg prompts: Content): CountTokensResponse(source)

Counts the number of tokens in a prompt using the model's tokenizer.

Return

The CountTokensResponse of running the model's tokenizer on the input.

Parameters

prompt

The input(s) given to the model as a prompt.

See also

for types of errors.

Throws

if the request failed.


actual suspend fun countTokens(prompt: String): CountTokensResponse(source)

Counts the number of tokens in a text prompt using the model's tokenizer.

Return

The CountTokensResponse of running the model's tokenizer on the input.

Parameters

prompt

The text given to the model as a prompt.

See also

for types of errors.

Throws

if the request failed.

expect suspend fun countTokens(prompt: List<Content>): CountTokensResponse(source)
expect suspend fun countTokens(prompt: Content, vararg prompts: Content): CountTokensResponse(source)

Counts the number of tokens in a prompt using the model's tokenizer.

Return

The CountTokensResponse of running the model's tokenizer on the input.

Parameters

prompt

The input(s) given to the model as a prompt.

See also

for types of errors.

Throws

if the request failed.


expect suspend fun countTokens(prompt: String): CountTokensResponse(source)

Counts the number of tokens in a text prompt using the model's tokenizer.

Return

The CountTokensResponse of running the model's tokenizer on the input.

Parameters

prompt

The text given to the model as a prompt.

See also

for types of errors.

Throws

if the request failed.

actual suspend fun countTokens(prompt: List<Content>): CountTokensResponse(source)
actual suspend fun countTokens(prompt: Content, vararg prompts: Content): CountTokensResponse(source)

Counts the number of tokens in a prompt using the model's tokenizer.

Return

The CountTokensResponse of running the model's tokenizer on the input.

Parameters

prompt

The input(s) given to the model as a prompt.

See also

for types of errors.

Throws

if the request failed.


actual suspend fun countTokens(prompt: String): CountTokensResponse(source)

Counts the number of tokens in a text prompt using the model's tokenizer.

Return

The CountTokensResponse of running the model's tokenizer on the input.

Parameters

prompt

The text given to the model as a prompt.

See also

for types of errors.

Throws

if the request failed.