{"id":51594414,"url":"https://github.com/cfryerdev/opencode-plugin-credit-switcher","last_synced_at":"2026-07-11T17:02:37.023Z","repository":{"id":335586351,"uuid":"1146378147","full_name":"cfryerdev/opencode-plugin-credit-switcher","owner":"cfryerdev","description":"A plugin that switches your Github Copilot subscription to hosted AI Foundry models when you run out of credits","archived":false,"fork":false,"pushed_at":"2026-01-31T02:24:54.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-31T17:38:53.239Z","etag":null,"topics":["ai-foundry","github-copilot","opencode","opencode-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/cfryerdev.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":"2026-01-31T02:07:56.000Z","updated_at":"2026-01-31T02:24:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cfryerdev/opencode-plugin-credit-switcher","commit_stats":null,"previous_names":["cfryerdev/opencode-plugin-credit-switcher"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/cfryerdev/opencode-plugin-credit-switcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfryerdev%2Fopencode-plugin-credit-switcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfryerdev%2Fopencode-plugin-credit-switcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfryerdev%2Fopencode-plugin-credit-switcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfryerdev%2Fopencode-plugin-credit-switcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cfryerdev","download_url":"https://codeload.github.com/cfryerdev/opencode-plugin-credit-switcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfryerdev%2Fopencode-plugin-credit-switcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35368768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-11T02:00:05.354Z","response_time":104,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ai-foundry","github-copilot","opencode","opencode-plugin"],"created_at":"2026-07-11T17:02:36.423Z","updated_at":"2026-07-11T17:02:37.017Z","avatar_url":"https://github.com/cfryerdev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCode Credit Switcher Plugin\n\nThis plugin retries a session with a fallback model when the primary provider reports a credit exhaustion error, and switches back after a daily credit check.\n\n## Files\n\n- `.opencode/plugins/credit-switcher.js` - Plugin implementation.\n- `.opencode/credit-switcher.json` - Plugin configuration.\n- `.opencode/credit-switcher.state.json` - Plugin state (last exhausted time and original model).\n\n## Install\n\n### From npm\n\nAdd the plugin to your OpenCode config:\n\n```jsonc\n// opencode.jsonc\n{\n  \"plugin\": [\"opencode-credit-switcher@latest\"]\n}\n```\n\n### From local files\n\nCopy `.opencode/plugins/credit-switcher.js` into one of:\n\n- `.opencode/plugins/` (project)\n- `~/.config/opencode/plugins/` (global)\n\n## Configure\n\n1. Update `.opencode/credit-switcher.json` with your primary and fallback models.\n2. Ensure your providers are configured in `opencode.json` and credentials are stored via `/connect`.\n\nExample `opencode.json` for a self-hosted OpenAI-compatible endpoint:\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"provider\": {\n    \"llama.cpp\": {\n      \"npm\": \"@ai-sdk/openai-compatible\",\n      \"name\": \"llama-server (local)\",\n      \"options\": {\n        \"baseURL\": \"http://127.0.0.1:8080/v1\"\n      },\n      \"models\": {\n        \"qwen3-coder:a3b\": {\n          \"name\": \"Qwen3-Coder a3b\"\n        }\n      }\n    }\n  }\n}\n```\n\n## How it works\n\n- Listens for `session.error` events.\n- Detects credit exhaustion via status codes, error codes, or message text.\n- Replays the last user message using `fallbackModel`.\n- If `confirmOnFallback` is enabled and the confirm dialog is available, asks before retrying.\n- Once per day, attempts to switch sessions back to the original model after credits likely reset.\n\n## Notes\n\n- The plugin only retries once per session to avoid loops.\n- Fallback requires your providers to exist in OpenCode config.\n- Customize matching via `.opencode/credit-switcher.json`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfryerdev%2Fopencode-plugin-credit-switcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcfryerdev%2Fopencode-plugin-credit-switcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfryerdev%2Fopencode-plugin-credit-switcher/lists"}