Sign inSign up

enrikenur/tiktoken

By enrikenur

Updated over 3 years ago

Tiktoken API token counter

Image
0

345

enrikenur/tiktoken repository overview

Tiktoken Counter API

The Tiktoken API is a tool that enables developers to calculate the token usage of their OpenAI API requests before sending them, allowing for more efficient use of tokens.

Docker

docker run -d -p 8000:8000 enrikenur/tiktoken:latest

Usage

/count sample payload:

Available models: gpt-3.5-turbo, gpt-4

 {
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "user",
      "content": "This late pivot means we don't have time to boil the ocean for the client deliverable."
    }
  ]
}

Response:

{
	"count":  27
}

CURL Request:

curl --location 'http://127.0.0.1:8000/count' \
	--header 'Content-Type: application/json' \
	--data  '{
		"model": "gpt-3.5-turbo",
		"messages": [
			{
				"role": "user",
				"content": "This late pivot means we don\'t have time to boil the ocean for the client deliverable."
			}
		]
	}'

License

The Tiktoken API is licensed under the MIT License. See the LICENSE file for more details.

Tag summary

Content type

Image

Digest

sha256:eba5b2ff4

Size

53.1 MB

Last updated

over 3 years ago

docker pull enrikenur/tiktoken