{"id":15288321,"url":"https://github.com/thiggle/api","last_synced_at":"2026-01-14T08:55:22.553Z","repository":{"id":179976691,"uuid":"662775607","full_name":"thiggle/api","owner":"thiggle","description":"Structured LLM APIs","archived":true,"fork":false,"pushed_at":"2023-09-12T23:02:17.000Z","size":893,"stargazers_count":156,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-21T22:57:19.358Z","etag":null,"topics":["api","categorization","go","llm","python","rust","typescript"],"latest_commit_sha":null,"homepage":"https://thiggle.com","language":"MDX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiggle.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":"2023-07-05T21:36:52.000Z","updated_at":"2025-03-19T18:42:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"155d24f0-75a5-43ed-86f6-ee9562ea2f38","html_url":"https://github.com/thiggle/api","commit_stats":null,"previous_names":["thiggle/api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thiggle/api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiggle%2Fapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiggle%2Fapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiggle%2Fapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiggle%2Fapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiggle","download_url":"https://codeload.github.com/thiggle/api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiggle%2Fapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","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":["api","categorization","go","llm","python","rust","typescript"],"created_at":"2024-09-30T15:47:20.327Z","updated_at":"2026-01-14T08:55:22.530Z","avatar_url":"https://github.com/thiggle.png","language":"MDX","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cfont size=\"28\"\u003e\n  \u003cb\u003e\n    thiggle\n  \u003c/b\u003e\n  \u003c/font\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e\n  \u003ca href=\"https://docs.thiggle.com\"\u003eAPI Docs\u003c/a\u003e |\n  \u003ca href=\"https://thiggle.com\"\u003eWebsite\u003c/a\u003e\n\u003c/h4\u003e\n\nStructured LLM APIs that always return deterministic results.\n\n- [LLM Model API Gateway](#llm-model-api-gateway) -- Call over 20+ LLMs with a single API\n- [LLM Typed Completion API](#typed-completion-api) -- Generate LLM output in JSON that matches a TypeScript schema\n- [LLM Regex Completion API](#regex-completion-api) -- Generate LLM output that always matches a regex pattern\n- [LLM Context-Free Grammar Completion API](#context-free-grammar-completion-api) -- Generate LLM output that always matches a context-free grammar\n- [LLM Categorization API](#categorization-api) -- A simple structured API to run categorization tasks with an LLM\n\n### Model API Gateway\n\nCall over 20+ LLM models with a single API from Llama 2, GPT-4, Cohere, and more.\n\n- Single API to inference over 20+ LLMs. Llama 2, GPT-4, Cohere, StableLM and more.\n- Same price as direct inference. No upcharge.\n- Drop-in compatible with OpenAI clients. Just change one line of code.\n- One API key. Never give up your OpenAI credentials.\n\nIf you’re already using the OpenAI Python APIs, you can switch\n\n```\nopenai.api_base = 'https://api.thiggle.com/v1/'\n```\n\nOtherwise, you can use the client libraries provided here, or a simple cURL command.\n\n```bash\ncurl -X POST \"https://api.thiggle.com/v1/completion\" \\\n     -H \"Content-Type: application/json\" \\\n     -H \"Authorization: Bearer $THIGGLE_API_KEY\" \\\n     -d '{\n         \"prompt\": \"What animal barks?\",\n         \"max_new_tokens\": 10,\n         \"model\": [\"llama-2-70b-chat\", \"gpt-4\"]\n     }'\n```\n\nModels Supported\n\n- llama-2-70b-chat\n- llama-2-70b\n- llama-2-13b-chat\n- llama-2-7b\n- llama-2-7b-chat\n- gpt-4\n- gpt-4-0613\n- gpt-4-0314\n- gpt-4-32k\n- gpt-4-32k-0613\n- gpt-4-32k-0314\n- gpt-3.5-turbo\n- gpt-3.5-turbo-0613\n- gpt-3.5-turbo-0301\n- gpt-3.5-turbo-16k\n- gpt-3.5-turbo-16k-0613\n- cohere-command\n- cohere-command-light\n- cohere-command-nightly\n- text-davinci-00{3,2,1}\n\n### Regex Completion API\n\n- **Regex Constraint**: Generate LLM output that always matches a regex pattern.\n- **Deterministic**: Never returns unexpected or unparsable results.\n\nGiven a prompt and a regex pattern, produces a constrained LLM text generation. Useful for generating specific semantic structures, typed primitives, or templates. The output is always deterministic and will always match the regex pattern provided.\n\n### Typed Completion API\n\n- **TypeScript Constraint**: Generate LLM output in JSON that matches a TypeScript schema.\n\nGiven a set of TypeScript definitions and a target type, generate LLM output that is valid JSON in shape of that type. Useful for generating specific semantic structures, typed primitives, or templates.\n\n### Categorization API\n\nA simple structured API to run categorization tasks with an LLM.\n\n- **Zero Parsing**: Always returns structured JSON with only your categories\n- **0,1,or N Labels**: Return exactly one class, or allow multiple classes, or allow uncategorized results\n- **Deterministic**: Never returns unexpected or unparsable results.\n\n### Examples\n\n- [Building block for building higher-level AI agents](#ai-agents)\n- [Answering multiple choice questions](#multiple-choice-questions)\n- [Labeling training data](#labeling-training-data)\n- [Sentiment analysis](#sentiment-analysis)\n\n### Quickstart\n\nGet an API key at [thiggle.com/account](https://thiggle.com/account). Set it as an environment variable `THIGGLE_API_KEY`. Call the API directly over HTTPS or use one of the client libraries.\n\n- [cURL](#curl)\n- [Python](#python)\n- [Go](#go)\n- [TypeScript](#typescript)\n\n#### cURL\n\n```bash\ncurl -X POST \"https://api.thiggle.com/v1/categorize\" \\\n     -H \"Content-Type: application/json\" \\\n     -H \"Authorization: Bearer $THIGGLE_API_KEY\" \\\n     -d '{\n         \"prompt\": \"What animal barks?\",\n         \"categories\": [\"Dog\", \"Cat\", \"Bird\", \"Fish\"]\n     }'\n```\n\n#### Python\n\n```bash\npip install thiggle\n```\n\n```python\nimport thiggle as tg\n\napi = tg.API(os.getenv(\"THIGGLE_API_KEY\"))\nresponse = api.categorize(\"What animal barks?\", [\"dog\", \"cat\", \"bird\", \"fish\"])\nprint(response)\n```\n\n#### TypeScript\n\n```bash\nnpm install @thiggle/client\n```\n\n```typescript\nimport Thiggle from \"@thiggle/client\";\n\nconst api = new Thiggle(process.env.THIGGLE_API_KEY);\nconst response = await api.categorize(\"What animal barks?\", [\n  \"dog\",\n  \"cat\",\n  \"bird\",\n  \"fish\",\n]);\nconsole.log(response);\n```\n\n#### Go\n\n```bash\ngo get github.com/thiggle/api/client-go\n```\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n\n    \"github.com/thiggle/api\"\n)\n\nfunc main() {\n    client := api.NewClient(os.Getenv(\"THIGGLE_API_KEY\"))\n    response, err := client.Categorize(\"What animal barks?\", []string{\"dog\", \"cat\", \"bird\", \"fish\"})\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(response)\n}\n```\n\n### Context-Free Grammar Completion API\n\nGiven a prompt and a context-free grammar, produces a constrained LLM text generation. Useful for generating specific semantic structures, typed primitives, or templates. The output is always deterministic and will always match the context-free grammar provided.\n\nGrammars must be LALR grammars in Lark format. See the [lark-parser](https://lark-parser.readthedocs.io/en/latest/grammar.html).\n\nSee [docs.thiggle.com](https://docs.thiggle.com/#context-free-grammar-completion-api) for more information and examples.\n\n### API Keys\n\nTo get started, you'll need an API key. You can get one by signing up for an account at [https://thiggle.com](https://thiggle.com). Once you create an account, you generate API keys on your [account page](https://thiggle.com/account). Set the `THIGGLE_API_KEY` environment variable to your API key.\n\n```bash\nexport THIGGLE_API_KEY=your-api-key\n```\n\nIf you are using a client library, you can pass the API key as a parameter to the client constructor. If you are using the REST API directly, you can pass the API key in the `Authorization` header (be sure to include the `Bearer` prefix).\n\n```bash copy\ncurl -X POST \"https://api.thiggle.com/v1/categorize\" \\\n   -H \"Content-Type: application/json\" \\\n   -H \"Authorization: Bearer $THIGGLE_API_KEY\" \\\n   -d '{\n       \"prompt\": \"What animal barks?\",\n       \"categories\": [\"Dog\", \"Cat\", \"Bird\", \"Fish\"]\n   }'\n```\n\n### Examples\n\n#### AI Agents\n\nUse the categorization API to choose the relevant tools to complete the task. Use this as a reliable building block for higher-order AI agents. Never worry about the API returning extraneous text or unknown categories that break your agent.\n\n```json\n{\n  \"prompt\": \"What tools do I need to complete the following task? Task: find the best restaurant in San Francisco. Tools:\",\n  \"categories\": [\n    \"google-maps-api\",\n    \"python-repl\",\n    \"calculator\",\n    \"yelp-api\",\n    \"ffmpeg\"\n  ]\n}\n```\n\n```json\n{\n  \"choices\": [\"google-maps-api\", \"yelp-api\"]\n}\n```\n\n#### Multiple-Choice Questions\n\nAnswer multiple-choice questions. For questions with more than one correct answer, use the `allow_multiple_classes` flag.\n\n```json\n{\n  \"prompt\": \"What animals have four legs?\",\n  \"categories\": [\"cat\", \"dog\", \"bird\", \"fish\", \"elephant\", \"snake\"],\n  \"allow_multiple_classes\": true\n}\n```\n\n```json\n{\n  \"choices\": [\"cat\", \"dog\", \"elephant\"]\n}\n```\n\n#### Labeling Training Data\n\nYou can use the categorization API to label text for training data. For example, you could use it to label text for a text classifier. This example bins text into different buckets: ['finance', 'sports', 'politics', 'science', 'technology', 'entertainment', 'health', 'other'].\n\n```json\n{\n  \"prompt\": \"What category does this text belong to? Text: The Dow Jones Industrial Average fell 200 points on Monday.\",\n  \"categories\": [\n    \"finance\",\n    \"sports\",\n    \"politics\",\n    \"science\",\n    \"technology\",\n    \"entertainment\",\n    \"health\",\n    \"other\"\n  ]\n}\n```\n\n```json\n{\n  \"choices\": [\"finance\"]\n}\n```\n\n#### Sentiment Analysis\n\nClassify any text into sentiment classes.\n\n```json\n{\n  \"prompt\": \"Is this a positive or negative review of Star Wars? The more one sees the main characters, the less appealing they become. Luke Skywalker is a whiner, Han Solo a sarcastic clod, Princess Leia a nag, and C-3PO just a drone\",\n  \"categories\": [\"positive\", \"negative\"]\n}\n```\n\n```json\n{\n  \"choices\": [\"negative\"]\n}\n```\n\nUse any sentiment categories you like. For example, you could use `[\"positive\", \"neutral\", \"negative\"]` or `[\"positive\", \"negative\", \"very positive\", \"very negative\"]`. Or even `[\"happy\", \"sad\", \"angry\", \"surprised\", \"disgusted\", \"fearful\"]`.\n\n### Rate Limits\n\nThe API is rate limited to 100 requests per minute. If you exceed this limit, you will receive a `429 Too Many Requests` response. If you need a higher rate limit, please contact us at [quota@thiggle.com](mailto:quota@thiggle.com).\n\nYour current rate limit usage is returned in the `X-RateLimit-Remaining` header. If you are using a client library, you can use this to determine when you are approaching the rate limit.\n\n### Quota\n\nQuotas are determined by your current plan. You can view your current plan on your [account page](https://thiggle.com/account). The quota is reset at the beginning of each month. If you exceed your quota, you will receive a `402 Payment Required` response. Your current quota usage is returned in the `X-Quota-Remaining` header. If you are using a client library, you can use this to determine when you are approaching your quota.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiggle%2Fapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiggle%2Fapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiggle%2Fapi/lists"}