{
  "id": 14245826,
  "title": "A free AI chat that costs me nothing: BYOK on Cloudflare Workers AI",
  "url": "https://urgent.news/2026/10/13/a-free-ai-chat-that-costs-me-nothing-byok-on-cloudflare-workers-ai",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-13T16:53:29.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/bartoszosiej/a-free-ai-chat-that-costs-me-nothing-byok-on-cloudflare-workers-ai-5878"
  },
  "original_language": "en",
  "account": "There is no free AI chat service that stays free. The usual solution is to purchase credits, but there is an alternative: let the user pay for their own key. Cloudflare Workers AI provides tokens, which are then relayed along with the request. This approach incurs no cost, avoids storing credentials that weren't initially provided, and simplifies abuse management by revoking your token.\n\nThis architecture was implemented for the chat on ai.hartwell-labs.pl, taking only an afternoon. The authentication process was concise, consisting of just twenty lines of code. The most challenging aspect was not related to the chat functionality itself, but rather an unrelated issue.\n\nThe backend is incredibly simple: a single Worker handles incoming requests without any AI binding. It forwards the caller's credentials directly to the appropriate model. The request body contains configuration details such as provider, API key, account ID, and model. The Worker performs several checks: verifying the presence of an API key, confirming the token's validity by listing the user's accounts, and finally forwarding the request to the appropriate upstream service. The response is then returned to the client as an event stream.\n\nTwo key points enhance the user experience: account discovery eliminates the need for a manual account selection step, and the user can simply paste a token and start typing without any additional prompts. The system automatically selects the first account and stores it for future use. Additionally, error messages are crafted to provide actionable guidance instead of overwhelming the user with cryptic codes.\n\nOne critical aspect to consider is the handling of structured directives emitted by the model. For instance, a directive like \"Zapisuję. [notepad action=new doc= Zakupy mleko chleb [/notepad]\" would typically be parsed and processed correctly when the entire response is received. However, due to the streaming nature of the request, incomplete directives could lead to unexpected behavior, such as stray bullet lists appearing in the chat output.\n\nTo address this issue, the code includes a function to strip directives from the received text. This function iterates through the text, identifying and removing complete and partial directives, ensuring that only the intended content is displayed to the user. By focusing on the essential aspects of the chat functionality and implementing robust error handling, this solution offers a free and efficient AI chat experience without compromising on security or usability.",
  "summary": "TL;DR There is no free tier that stays free. The usual answer is to buy credits and hope. There is another: make the user pay, using their own key. Workers AI gives out tokens; you relay the request. You pay $0, you never store a credential you didn't already hand you, and the abuse story collapses into \"revoke your own token.\" This is the architecture I used for the chat on ai.hartwell-labs.pl .…",
  "key_points": [
    "Users pay for their own AI chat key, avoiding credit purchases",
    "Cloudflare Workers AI provides tokens for request relay",
    "Backend handles requests, forwards credentials to appropriate model"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}