{"id":38169584,"url":"https://github.com/flexchar/tiktoken-counter","last_synced_at":"2026-01-16T23:24:44.767Z","repository":{"id":162619417,"uuid":"637128455","full_name":"flexchar/tiktoken-counter","owner":"flexchar","description":"Tiktoken-counter as standalone API","archived":false,"fork":false,"pushed_at":"2025-11-28T10:50:53.000Z","size":3,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-30T18:39:16.290Z","etag":null,"topics":["docker","openai-tokenizer","tiktoken","token-counter"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flexchar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-06T15:40:52.000Z","updated_at":"2025-11-28T10:50:57.000Z","dependencies_parsed_at":"2025-11-30T08:02:11.423Z","dependency_job_id":null,"html_url":"https://github.com/flexchar/tiktoken-counter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flexchar/tiktoken-counter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexchar%2Ftiktoken-counter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexchar%2Ftiktoken-counter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexchar%2Ftiktoken-counter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexchar%2Ftiktoken-counter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flexchar","download_url":"https://codeload.github.com/flexchar/tiktoken-counter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flexchar%2Ftiktoken-counter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28487586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T22:54:02.790Z","status":"ssl_error","status_checked_at":"2026-01-16T22:50:10.344Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","openai-tokenizer","tiktoken","token-counter"],"created_at":"2026-01-16T23:24:44.695Z","updated_at":"2026-01-16T23:24:44.752Z","avatar_url":"https://github.com/flexchar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiktoken Counter\n\nTiktoken Counter is an API for counting tokens in a text using the Tiktoken library. The API is built using Flask and served with Gunicorn. The Docker image is available at `ghcr.io/flexchar/tiktoken-counter`.\n\n## Purpose\n\nThis API is designed to help developers count tokens in a given text, from another service/language, which is particularly useful when working with OpenAI's GPT models, such as GPT-4o. By utilizing the Tiktoken library, this API provides a simple way to count tokens for specific encodings.\n\n\u003e For example, I use it from inside Laravel (php) code base where I need to estimate tokens without calling any APIs outside the server. Docker makes it super easy to expand with the microservice concept.\n\n## Building the Docker Image\n\nTo build the Docker image, simply run the following command in your terminal:\n\n```bash\nmake build\n```\n\nThis command will build the Docker image with the tag `tiktoken-counter`.\n\n## Running the API\n\nTo run the API, use the following command:\n\n```bash\nmake run\n```\n\nThis command will start the API on port 8000.\n\n## Pushing the Docker Image\n\nTo push the Docker image to GitHub Container Registry, use the following command:\n\n```bash\nmake push\n```\n\nThis command will tag the image with your GitHub username and push it to the registry.\n\n## Example Usage\n\nHere is an example of how to use the API for counting tokens:\n\n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"text\": \"Hello, World!\", \"model\": \"gpt-4o\"}' http://localhost:8000/count\n```\n\nThis request will return the number of tokens in the given text.\n\n```json\n{\n    \"tokens\": 5,\n    \"encoding\": \"o200k_base\"\n}\n```\n\nIn this example, the `text` parameter contains the text for which you want to count tokens, and the `model` parameter specifies the encoding used for tokenization. The default model is `gpt-4o`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflexchar%2Ftiktoken-counter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflexchar%2Ftiktoken-counter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflexchar%2Ftiktoken-counter/lists"}