Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Easy token price estimates for 400+ LLMs. TokenOps.
| Date | Stars |
|---|---|
| 2026-07-24 | 1997 |
| 2026-07-25 | 1997 |
| 2026-07-28 | 1997 |
| 2026-07-30 | 1997 |
| 2026-07-31 | 1999 |
| 2026-08-06 | 1999 |
Today
— stars today
This week
+2 stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.10%/day
<p align="center">
<img src="https://raw.githubusercontent.com/AgentOps-AI/tokencost/main/tokencost.png" height="300" alt="Tokencost" />
</p>
<p align="center">
<em>Clientside token counting + price estimation for LLM apps and AI agents.</em>
</p>
<p align="center">
<a href="https://pypi.org/project/tokencost/" target="_blank">
<img alt="Python" src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" />
<img alt="Version" src="https://img.shields.io/pypi/v/tokencost?style=for-the-badge&color=3670A0">
</a>
</p>
<p align="center">
<a href="https://twitter.com/agentopsai/">🐦 Twitter</a>
<span> • </span>
<a href="https://discord.com/invite/FagdcwwXRR">📢 Discord</a>
<span> • </span>
<a href="https://agentops.ai/?tokencost">🖇️ AgentOps</a>
</p>
# TokenCost
[](https://opensource.org/licenses/MIT) 
[](https://x.com/agentopsai)
Tokencost helps calculate the USD cost of using major Large Language Model (LLMs) APIs by calculating the estimated cost of prompts and completions.
Building AI agents? Check out [AgentOps](https://agentops.ai/?tokencost)
### Features
* **LLM Price Tracking** Major LLM providers frequently add new models and update pricing. This repo helps track the latest price changes
* **Token counting** Accurately count prompt tokens before sending OpenAI requests
* **Easy integration** Get the cost of a prompt or completion with a single function
### Example usage:
```python
from tokencost import calculate_prompt_cost, calculate_completion_cost
model = "gpt-3.5-turbo"
prompt = [{ "role": "user", "content": "Hello world"}]
completion = "How may I assist you today?"
prompt_cost = calculate_prompt_cost(prompt, model)
completion_cost = calculate_completion_cost(completion, model)
print(f"{prompt_cost} + {completion_cost} = {prompt_cost + completion_cost}")
# 0.0000135 + 0.000014 = 0.0000275
```
## Installation
#### Recommended: [PyPI](https://pypi.org/project/tokencost/):
```bash
pip install tokencost
```
## Usage
### Cost estimates
Calculating the cost of prompts and completions from OpenAI requests
```python
from openai import OpenAI
client = OpenAI()
model = "gpt-3.5-turbo"
prompt = [{ "role": "user", "content": "Say this is a test"}]
chat_completion = client.chat.completions.create(
messages=prompt, model=model
)
completion = chat_completion.choices[0].message.content
# "This is a test."
prompt_cost = calculate_prompt_cost(prompt, model)
completion_cost = calculate_completion_cost(completion, model)
print(f"{prompt_cost} + {completion_cost} = {prompt_cost + completion_cost}")
# 0.0000180 + 0.000010 = 0.0000280
```
**Calculating cost using string prompts instead of messages:**
```python
from tokencost import calculate_prompt_cost
prompt_string = "Hello world"
response = "How may I assist you today?"
model= "gpt-3.5-turbo"
prompt_cost = calculate_prompt_cost(prompt_string, model)
print(f"Cost: ${prompt_cost}")
# Cost: $3e-06
```
**Counting tokens**
```python
from tokencost import count_message_tokens, count_string_tokens
message_prompt = [{ "role": "user", "content": "Hello world"}]
# Counting tokens in prompts formatted as message lists
print(count_message_tokens(message_prompt, model="gpt-3.5-turbo"))
# 9
# Alternatively, counting tokens in string prompts
print(count_string_tokens(prompt="Hello world", model="gpt-3.5-turbo"))
# 2
```
## How tokens are counted
Under the hood, strings and ChatML messages are tokenized using [Tiktoken](https://github.com/openai/tiktoken), OpenAI's official tokenizer. Tiktoken splits text into tokens (which can be parts of words or individual characters) and handles both raw strings and message formats with additional tokens for message formattiExcerpt of 334,866 characters
Read on GitHubAlex Reibman · United States
195
Pratyush Shukla · Abundant AI
136
30
9
Travis Dent · a10k, Inc. · United States
8
3
3
2
Cursor Agent
2
1
1
Braelyn Boynton · i work for no man · United States
1
1
1
1
1
1
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:24bd7c8c4c784b9b, topic:large-language-models, topic:llm
matched fp:24bd7c8c4c784b9b, topic:observability