GigaChat API icon

GigaChat API

Consume GigaChat API functions

Токены → Посчитать токены

AI-generated

Overview

This node interacts with the GigaChat API to count tokens in a given message. It is useful for scenarios where you need to monitor or manage token usage in text inputs, such as optimizing prompts for language models or tracking token consumption in chat applications.

Use Case Examples

  1. Counting tokens in a user prompt before sending it to a language model to ensure it fits within token limits.
  2. Analyzing token usage in messages to manage API costs or quotas.

Properties

Name Meaning
Model Select the GigaChat model to be used for token counting.
Промпт The text prompt for which tokens will be counted. This is a required input.

Output

JSON

  • tokenCount - The number of tokens counted in the provided prompt.
  • modelId - The identifier of the GigaChat model used for counting tokens.

Dependencies

  • Requires GigaChat API credentials for authentication.

Troubleshooting

  • Ensure the GigaChat API credentials are correctly configured and valid to avoid authentication errors.
  • Verify that the prompt text is provided and not empty, as it is required for token counting.
  • If token counting fails, check network connectivity and API endpoint availability.

Links

Discussion