{"id":20207882,"url":"https://github.com/haha-systems/toll","last_synced_at":"2026-05-04T23:35:42.230Z","repository":{"id":245023125,"uuid":"817030349","full_name":"haha-systems/toll","owner":"haha-systems","description":"The OpenAI tiktoken library as a service. For counting the number of tokens in a message to an LLM like GPT.","archived":false,"fork":false,"pushed_at":"2024-06-19T00:26:42.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T10:15:05.481Z","etag":null,"topics":["flask","llms","openai","python","tiktoken"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haha-systems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-06-18T22:01:06.000Z","updated_at":"2024-06-19T00:32:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"e13c6b8a-5ae7-4215-8102-016a992bbb91","html_url":"https://github.com/haha-systems/toll","commit_stats":null,"previous_names":["haha-systems/toll"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/haha-systems/toll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haha-systems%2Ftoll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haha-systems%2Ftoll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haha-systems%2Ftoll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haha-systems%2Ftoll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haha-systems","download_url":"https://codeload.github.com/haha-systems/toll/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haha-systems%2Ftoll/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259427005,"owners_count":22855557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["flask","llms","openai","python","tiktoken"],"created_at":"2024-11-14T05:33:09.515Z","updated_at":"2026-05-04T23:35:42.203Z","avatar_url":"https://github.com/haha-systems.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# toll\n\nThis microservice takes a string of content and returns the token count using the `tiktoken` library. It is built using Flask.\n\n## Table of Contents\n\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API Endpoints](#api-endpoints)\n\n## Prerequisites\n\n- Python 3.x\n- Flask\n- tiktoken\n- Poetry\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/haha-systems/toll.git\n   cd toll\n   ```\n\n2. Install the required packages:\n\n   ```bash\n   pip install flask tiktoken poetry\n   ```\n\n3. Create a `requirements.txt` file:\n\n   ```bash\n   pip freeze \u003e requirements.txt\n   ```\n\n## Usage\n\n1. Run the Flask app:\n\n   ```bash\n   python main.py\n   ```\n\n2. Send a POST request to the `/token_count` endpoint with the content you want to tokenize. For example, using `curl`:\n\n   ```bash\n   curl -X POST -H \"Content-Type: application/json\" -d '{\"content\": \"Your content here\"}' http://127.0.0.1:4000/token_count\n   ```\n\n   You should get a JSON response with the token count:\n\n   ```json\n   {\n     \"token_count\": 4\n   }\n   ```\n\n## API Endpoints\n\n### POST /token_count\n\n- **Description**: Returns the token count for the provided content.\n- **Request**:\n  - **Headers**: `Content-Type: application/json`\n  - **Body**: JSON object with a `content` field containing the string to be tokenized.\n- **Response**:\n  - **Success**: JSON object with a `token_count` field.\n  - **Error**: JSON object with an `error` field and an appropriate error message.\n\n#### Example Request\n\n```json\n{\n  \"content\": \"Your content here\"\n}\n```\n\n#### Example Response\n\n```json\n{\n  \"token_count\": 4\n}\n```\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaha-systems%2Ftoll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaha-systems%2Ftoll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaha-systems%2Ftoll/lists"}