Skip to content

Latest commit

 

History

History
51 lines (42 loc) · 1 KB

README.md

File metadata and controls

51 lines (42 loc) · 1 KB

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.