aiqinxuancai/TiktokenSharp

Token calculation for OpenAI models, using `o200k_base` `cl100k_base` `p50k_base` encoding.

52
/ 100
Established

This is a C# library that helps developers accurately count tokens for text processed by OpenAI's large language models like GPT-3.5 and GPT-4. It takes a model name or encoding identifier as input, along with your text, and outputs the precise token count. This tool is for C# developers building applications that integrate with OpenAI APIs and need to manage token limits effectively.

126 stars.

Use this if you are a C# developer building an application that interacts with OpenAI models and you need a reliable way to calculate token counts for pricing, input limits, or response length management.

Not ideal if you are working in a programming language other than C#, or if you do not directly integrate with OpenAI's API.

C# development OpenAI API integration token management large language models application development
No Package No Dependents
Maintenance 10 / 25
Adoption 10 / 25
Maturity 16 / 25
Community 16 / 25

How are scores calculated?

Stars

126

Forks

18

Language

C#

License

MIT

Last pushed

Feb 22, 2026

Commits (30d)

0

Get this data via API

curl "https://pt-edge.onrender.com/api/v1/quality/llm-tools/aiqinxuancai/TiktokenSharp"

Open to everyone — 100 requests/day, no key needed. Get a free key for 1,000/day.