Interface for counting tokens
Open
area-ai
enhancement
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 894
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
Most providers now have an API for counting tokens, i.e. submit the full request as you otherwise would, but get back a token count rather than an actual response. We should consider adding an interface for this purpose, e.g.
```csharp
Task CountTokensAsync(IEnumerable, ChatOptions, CancellationToken);
```
It could be implemented by IChatClients that support it and served up from their GetService implementations.
Contributor guide
Assessment
This issue has not been assessed yet.