How I bypassed the daily limits of a terminal-based AI agent by routing traffic through a local proxy and free API providers.
Introduction

If you rely on CLI-based AI agents like opencode for your daily development, you know the pain of hitting the daily limit. Recently, I hit the message: "You've used today's free messages." Instead of waiting, I decided to dive into how these limits are enforced and build a workaround.

🇪🇬 توضيح بالعامية: بص يا سيدي، لو إنت زيك زيي بتستخدم أدوات الذكاء الاصطناعي اللي بتشتغل من الـ Terminal زي opencode، أكيد طقيت من رسالة "إنت استهلكت رسايل النهاردة المجانية". المرة دي قررت مغسلش إيدي، وقلت أفتح الكود وأشوف إزاي الأداة دي بتتحكم في الليميت، وأعمل حوار يخليني أكمل شغل من غير ما أستنى بكرة. 
  1. The Problem: The Illusion of the IP Limit

My first logical thought was to change my public IP address. I logged into my router's web interface, inspected the network traffic using Chrome DevTools, and extracted the cURL requests for the login and reboot endpoints. After executing a script that rebooted the router, my public IP changed successfully.

However, the limit persisted. The conclusion was clear: the quota is bound to your account, not your IP address.

🇪🇬 توضيح بالعامية: أول حاجة جت في دماغي إني أغير الـ IP بتاع الراوتر، عشان قلت يمكن الشركة بتحظر الـ IP. دخلت على إعدادات الراوتر، وشغلت أدوات المطور في المتصفح (F12)، وشحطت أوامر الـ cURL اللي بتعمل ريستارت للراوتر. الروتر فعلاً عمل ريستارت والـ IP اتغير، بس المفاجأة! الليميت لسه موجود. ساعتها عرفت إن الحكاية مش IP، الحكاية إنهم ربطين الليميت بالحساب بتاعي نفسه. 
  1. The Architecture: Routing CLI Traffic via Local Proxy

Instead of creating multiple accounts, I opted for a cleaner engineering solution: intercepting the HTTP requests from opencode and routing them through a local proxy. I used 9Router, a local proxy that translates OpenAI-compatible requests into GitHub Copilot and OpenRouter API requests.

🇪🇬 توضيح بالعامية: طيب ما دام الحساب هو المشكلة، بدل ما أقعد أعمل إيميلات وحسابات وهمية وأتعب نفسي، قلت أعمل حركة هندسية نضيفة. إيه رأيك أعترض الطلبات اللي الـ opencode بيبعتها، وأوجهها لبرنامج تاني (بروكسي محلي اسمه 9Router)؟ البروكسي ده بياخد الطلب ويوديه لـ GitHub Copilot أو OpenRouter، وكأن الأداة الأصلية هي اللي بتتكلم معاهم. 
  1. The Technical Hurdles (Debugging the Implementation)

Configuring a CLI tool to use a custom endpoint is where most setups break. I encountered a cascade of errors that required deep configuration tweaks:

Error 1: Database Lock (Windows) Issue: Error: Database is not empty and has no session table. Fix: The SQLite database was locked by a zombie Node/Bun process. I forcefully killed the processes and deleted the local database. cmd taskkill /F /IM node.exe del "%USERPROFILE%\.local\share\opencode\opencode.db" Error 2: Bypassing the OpenAI SDK Issue: Incorrect API key provided. The CLI was defaulting to official OpenAI servers. Fix: Created a custom provider configuration in ~/.config/opencode/opencode.json pointing to the local proxy using @ai-sdk/openai-compatible. Error 3: 429 Rate Limit & Premium Interactions Issue: 429: exceeded your rate limit. GitHub Copilot had exhausted its premium requests (0% left). Fix: The ultimate solution was adding OpenRouter to the proxy and switching the CLI to completely free models like tinsel-alpha or ernie-5.5-flash. 🇪🇬 توضيح بالعامية: هنا بقى الصداع كله ظهر. قعدت أحل مشاكل ورا بعضها: أولاً: البرنامج كان بيضرب إيرور إن ملف الداتا بيز متقفل، طلع بسبب عملية Node مخفية ماسكة الملف. حليتها إني قتلت العمليات دي ومسحت الداتا بيز بدراعي. ثانياً: البرنامج كان لسه بيروح يكلم OpenAI الحقيقية ويرفض مفتاحي، حليتها إني قعدت أعدل في ملف الإعدادات opencode.json وأقوله "يا حبيبي تعالى نكلم البروكسي المحلي". ثالثاً: وأخيراً، استهلكت حصة Copilot بالكامل (0% Premium)، فربطت OpenRouter بالبروكسي واخترت موديلات مجانية 100% زي tinsel-alpha. 
  1. The Final Configuration (The Code)

Here is the opencode.json configuration that successfully routes the traffic to the local proxy (9Router) and uses the free OpenRouter models:
json

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"9router": {
"npm": "@ai-sdk/openai-compatible",
"name": "9Router",
"options": {
"baseURL": "http://localhost:20128/v1",
"apiKey": "sk-proxy-api-key-here"
},
"models": {
"openrouter/stealth/tinsel-alpha": {
"name": "Tinsel Alpha (Coding)"
},
"openrouter/baidu/ernie-5.5-flash-preview:free": {
"name": "Ernie 5.5 Flash"
}
}
}
}
}

🇪🇬 توضيح بالعامية: ده الملف السحري اللي خلى الدنيا تمشي. الملف ده هو opencode.json، إنت بتقوله فيه: "أنا مش هكلم OpenAI الأصلية، أنا هكلم البروكسي بتاعي على البورت 20128، وهستخدم الموديلات المجانية دي اللي جاية من OpenRouter". بمجرد ما ظبطت الملف ده، كله اشتغل زي الفل. 
  1. Conclusion

By building a routing layer around developer tools, we can understand how modern AI integrations handle authentication, headers, and rate limiting. It transforms a frustrating subscription limit into a fun engineering challenge.

🇪🇬 توضيح بالعامية: الخلاصة: إحنا كدا لعبنا في دماغ الأدوات دي. لما تبني طبقة توجيه (Routing Layer) وتفهم إزاي البرامج دي بتتعامل مع المصادقة والـ Headers، هتقدر تكسر أي ليميت وتحول العقبة اللي كانت بتقرفك لتحدي هندسي ممتع جداً.