{"_id":"@andeya/token-free-gateway-linux-arm64","name":"@andeya/token-free-gateway-linux-arm64","dist-tags":{"latest":"0.5.1"},"versions":{"0.5.1":{"name":"@andeya/token-free-gateway-linux-arm64","version":"0.5.1","description":"Prebuilt token-free-gateway binary for Linux (ARM64)","author":{"name":"andeya","email":"andeyalee@outlook.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/andeya/token-free-gateway.git"},"keywords":["openai","gateway","ai","llm","claude","chatgpt","cli"],"os":["linux"],"cpu":["arm64"],"bin":{"token-free-gateway":"bin/token-free-gateway"},"publishConfig":{"access":"public"},"_id":"@andeya/token-free-gateway-linux-arm64@0.5.1","gitHead":"717d028328ea5c577b8ef2437dd2f75f6ab3db46","bugs":{"url":"https://github.com/andeya/token-free-gateway/issues"},"homepage":"https://github.com/andeya/token-free-gateway#readme","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-GBeHE+c7Tpbiwo5kYbo6GIT2H0emeSzIqhW5dp/VQPfTbpIBzhGh368lXRGm54s87uq6uGSdaV5zUbrqw+X09w==","shasum":"0304ff0db78a98ab597b9de039875800859ad00d","tarball":"https://registry.npmjs.org/@andeya/token-free-gateway-linux-arm64/-/token-free-gateway-linux-arm64-0.5.1.tgz","fileCount":3,"unpackedSize":102749877,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC5OVt5NE5glDba5Fjqp4uHx/aiI8f05HovfhpA3Odr9gIhAJejyDlj6K0FAxOhQhRzi8k1rsqzsoPYTXX6+WQN10l/"}]},"_npmUser":{"name":"andeya","email":"andeyalee@outlook.com"},"directories":{},"maintainers":[{"name":"andeya","email":"andeyalee@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/token-free-gateway-linux-arm64_0.5.1_1775547382300_0.43131497632242"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-07T07:36:22.168Z","0.5.1":"2026-04-07T07:36:23.488Z","modified":"2026-04-07T07:36:23.758Z"},"maintainers":[{"name":"andeya","email":"andeyalee@outlook.com"}],"description":"Prebuilt token-free-gateway binary for Linux (ARM64)","homepage":"https://github.com/andeya/token-free-gateway#readme","keywords":["openai","gateway","ai","llm","claude","chatgpt","cli"],"repository":{"type":"git","url":"git+https://github.com/andeya/token-free-gateway.git"},"author":{"name":"andeya","email":"andeyalee@outlook.com"},"bugs":{"url":"https://github.com/andeya/token-free-gateway/issues"},"license":"MIT","readme":"# Token-Free Gateway\n\n**[中文文档](README_zh-CN.md)**\n\nUse ChatGPT, Claude, Gemini, DeepSeek, and 9 more AI models — **completely free, no API keys required**. Just log in via browser.\n\nToken-Free Gateway is a lightweight OpenAI-compatible API server that turns web-based AI sessions into a standard `/v1/chat/completions` endpoint with full **Tools / Function Calling** support. Point any OpenAI SDK client at it and it just works.\n\n## Why Token-Free Gateway?\n\n| Traditional API usage | Token-Free Gateway         |\n| --------------------- | -------------------------- |\n| Purchase API tokens   | **Completely free**        |\n| Pay per request       | No quota, no billing       |\n| Credit card required  | Browser login only         |\n| API key may leak      | Credentials stored locally |\n\n## What You Get\n\n- **One endpoint, 13 providers** — Claude, ChatGPT, DeepSeek, Doubao, Gemini, GLM, GLM Intl, Grok, Kimi, Perplexity, Qwen, Qwen CN, Xiaomi MiMo\n- **100% OpenAI-compatible** — `/v1/chat/completions`, `/v1/models`, streaming, tool_calls — zero client-side changes\n- **Full Function Calling** — tools are injected as prompts, responses are parsed back into standard `tool_calls`\n- **Single binary, batteries included** — `playwright-core` is bundled; the **only** external dependency is Chrome\n- **Cross-platform** — macOS, Linux, Windows\n- **Daemon mode** — `start` / `stop` / `restart` / `status` like a proper service\n\n---\n\n## Prerequisites\n\n**Chrome (or Chromium)** — Install from [google.com/chrome](https://www.google.com/chrome/) or your OS package manager. Keep it updated to a **recent stable** version. The gateway controls your browser over CDP — it does **not** embed a browser.\n\nThat's it. `playwright-core` is bundled in the binary; no `playwright install`, no extra runtime dependencies.\n\n> **Does my Chrome version need to \"match\" something?** — No. The gateway connects to your Chrome's debug WebSocket; CDP stays compatible across recent Chrome versions.\n\n---\n\n## Quick Start\n\n### Step 1 — Install\n\nChoose **one** method:\n\n**Via npm** (recommended):\n\n```bash\nnpm install -g token-free-gateway\n```\n\n**Prebuilt binary** — download from [GitHub Releases](../../releases):\n\n```bash\ntar xzf token-free-gateway-<platform>.tar.gz\nchmod +x token-free-gateway\n```\n\n**From source:**\n\n```bash\ngit clone https://github.com/andeya/token-free-gateway.git && cd token-free-gateway\nbun install\nbun run build    # → ./token-free-gateway\n```\n\n### Step 2 — Authorize providers\n\nRun the authorization wizard. Chrome will **start automatically** if it is not already running in debug mode:\n\n```bash\ntoken-free-gateway webauth\n```\n\nChrome opens with login pages for all 13 providers. Log in to the ones you want, then press **Enter** in the terminal. Select which providers to authorize — credentials are saved to `~/.token-free-gateway/auth-profiles.json`.\n\n> **DeepSeek:** keep the DeepSeek chat page open while running `webauth` — the wizard captures the bearer token from the live session.\n>\n> **Tip:** if the terminal doesn't return after authorization, press **Ctrl+C** — credentials are already saved.\n\n### Step 3 — Start the gateway\n\n```bash\ntoken-free-gateway start      # background daemon (logs: ~/.token-free-gateway/gateway.log)\ntoken-free-gateway serve      # foreground (for debugging)\n```\n\nThe gateway listens on `http://localhost:3456` by default. Chrome is checked (and auto-started if needed) before the daemon launches.\n\n### Step 4 — Use it\n\nPoint **any** OpenAI SDK client at the gateway:\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http://localhost:3456/v1\",\n    api_key=\"any-string\",          # or your TFG_API_KEY if configured\n)\n\n# Simple chat\nresponse = client.chat.completions.create(\n    model=\"claude-sonnet-4-20250514\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n)\nprint(response.choices[0].message.content)\n```\n\n**Function Calling** works out of the box:\n\n```python\nresponse = client.chat.completions.create(\n    model=\"claude-sonnet-4-20250514\",\n    messages=[{\"role\": \"user\", \"content\": \"What's the weather in Tokyo?\"}],\n    tools=[{\n        \"type\": \"function\",\n        \"function\": {\n            \"name\": \"get_weather\",\n            \"description\": \"Get current weather for a city\",\n            \"parameters\": {\n                \"type\": \"object\",\n                \"properties\": {\"city\": {\"type\": \"string\"}},\n                \"required\": [\"city\"],\n            },\n        },\n    }],\n)\n# response.choices[0].message.tool_calls → standard OpenAI tool_calls\n```\n\n**cURL:**\n\n```bash\n# List available models\ncurl http://localhost:3456/v1/models\n\n# Chat completion\ncurl http://localhost:3456/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"claude-sonnet-4-20250514\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello!\"}]}'\n```\n\n> If you have set `TFG_API_KEY`, add `-H \"Authorization: Bearer <your-key>\"` to every request (except `/health`).\n\n---\n\n## Supported Providers\n\n| Provider    | Model ID prefix | Auth Method           | Client                    |\n| ----------- | --------------- | --------------------- | ------------------------- |\n| Claude      | `claude-*`      | Session cookie        | CDP (browser fetch)       |\n| ChatGPT     | `chatgpt-*`     | Access token + cookie | CDP (browser fetch)       |\n| DeepSeek    | `deepseek-*`    | Bearer token + cookie | CDP (browser fetch + PoW) |\n| Doubao      | `doubao-*`      | Session cookie        | CDP (browser fetch)       |\n| Gemini      | `gemini-*`      | Google SID cookie     | CDP (browser fetch)       |\n| GLM (智谱)  | `glm-*`         | Refresh token cookie  | CDP (browser fetch)       |\n| GLM Intl    | `glm-intl-*`    | Session cookie        | CDP (browser fetch)       |\n| Grok        | `grok-*`        | SSO cookie            | CDP (browser fetch)       |\n| Kimi        | `kimi-*`        | Access token          | CDP (browser fetch)       |\n| Perplexity  | `perplexity-*`  | Next-auth cookie      | CDP (browser fetch)       |\n| Qwen        | `qwen-*`        | Session cookie        | CDP (browser fetch)       |\n| Qwen CN     | `qwen-cn-*`     | XSRF + cookie         | CDP (browser fetch)       |\n| Xiaomi MiMo | `xiaomimo-*`    | Bearer token          | CDP (browser fetch)       |\n\n> All providers share a centralized `BrowserManager` that maintains a single CDP connection to Chrome with auto-reconnection and health monitoring.\n\n---\n\n## CLI Reference\n\n```\ntoken-free-gateway [command] [options]\n\nCommands:\n  serve               Start in foreground (default)\n  start               Start as background daemon\n  stop                Stop the daemon\n  restart             Restart the daemon\n  status              Show running status\n  webauth             Authorize web AI providers\n  chrome [start|stop] Launch/stop Chrome debug mode\n\nOptions:\n  --help, -h          Show help\n  --version, -v       Show version\n```\n\n---\n\n## Configuration\n\nTwo ways to configure the gateway — pick whichever fits your workflow:\n\n```\nTFG_* environment variables  ← highest priority\n        ↓ fall through if not set\n~/.token-free-gateway/config.json\n        ↓ fall through if not set\nbuilt-in defaults             ← lowest priority\n```\n\n### Option A — config file (recommended)\n\nOn **first start** the gateway automatically creates `~/.token-free-gateway/config.json` with all defaults filled in:\n\n```json\n{\n  \"port\": 3456,\n  \"apiKey\": \"\",\n  \"cdpUrl\": \"http://127.0.0.1:9222\"\n}\n```\n\nEdit the fields you want to change and leave the rest as-is.\n\n| Field    | Default                 | Description                                   |\n| -------- | ----------------------- | --------------------------------------------- |\n| `port`   | `3456`                  | Server listen port                            |\n| `apiKey` | `\"\"` (disabled)         | Bearer token for client auth; empty = no auth |\n| `cdpUrl` | `http://127.0.0.1:9222` | Chrome DevTools Protocol endpoint             |\n\n### Option B — environment variables\n\nAll variables use the `TFG_` prefix to avoid conflicts with other software.\n\n| Variable      | Default                 | Description                                   |\n| ------------- | ----------------------- | --------------------------------------------- |\n| `TFG_PORT`    | `3456`                  | Server listen port                            |\n| `TFG_API_KEY` | `\"\"` (disabled)         | Bearer token for client auth; empty = no auth |\n| `TFG_CDP_URL` | `http://127.0.0.1:9222` | Chrome DevTools Protocol endpoint             |\n\nYou can also put them in a `.env` file next to the binary — Bun loads it automatically:\n\n```bash\nTFG_PORT=3456\nTFG_API_KEY=my-secret-key\nTFG_CDP_URL=http://127.0.0.1:9222\n```\n\n> **Note:** environment variables always win over `config.json`, so you can use the file for defaults and override individual values per-session with env vars.\n\n---\n\n## API Endpoints\n\n| Method | Path                   | Auth     | Description                                  |\n| ------ | ---------------------- | -------- | -------------------------------------------- |\n| `POST` | `/v1/chat/completions` | Required | Chat completions (streaming + non-streaming) |\n| `GET`  | `/v1/models`           | Required | List models from authorized providers        |\n| `GET`  | `/v1/models/:id`       | Required | Get model details                            |\n| `GET`  | `/health`              | Public   | Health check (includes browser CDP status)   |\n\n> \"Required\" means the `Authorization: Bearer <TFG_API_KEY>` header is checked **only** when `TFG_API_KEY` is configured. If unset, all endpoints are open.\n\n---\n\n## How It Works\n\n```mermaid\nsequenceDiagram\n    participant C as Client (OpenAI SDK)\n    participant G as Token-Free Gateway\n    participant B as BrowserManager\n    participant Ch as Chrome (CDP)\n    participant P as Web AI Provider\n\n    C->>G: POST /v1/chat/completions<br/>(messages + tools)\n    G->>G: tools → prompt injection<br/>route to provider\n    G->>B: getPage(provider domain)\n    B->>Ch: CDP connection (auto-reconnect)\n    Ch->>P: Browser-side fetch (with cookies)\n    P-->>Ch: Response\n    Ch-->>B: page.evaluate result\n    B-->>G: Parsed response\n    G->>G: Parse text → tool_calls\n    G-->>C: OpenAI-format tool_calls\n\n    Note over C: Client executes tools locally\n\n    C->>G: POST /v1/chat/completions<br/>(messages + tool results)\n    G->>B: Forward via CDP\n    B->>Ch: Browser-side fetch\n    Ch->>P: Request with session\n    P-->>Ch: Final response\n    Ch-->>G: Result\n    G-->>C: Final answer\n```\n\nAll API requests to web AI providers are executed **inside the browser** via Chrome DevTools Protocol (CDP), bypassing Cloudflare and other bot-protection systems. A centralized `BrowserManager` singleton manages the shared CDP connection with auto-reconnection, health monitoring, and Chrome auto-start.\n\n---\n\n## Platform Compatibility\n\n| Feature                          | macOS | Linux | Windows                         |\n| -------------------------------- | ----- | ----- | ------------------------------- |\n| Gateway (`serve`/`start`/`stop`) | ✅    | ✅    | ✅                              |\n| `chrome` command                 | ✅    | ✅    | ✅                              |\n| `start-chrome-debug.sh`          | ✅    | ✅    | ✅ (use `chrome start` instead) |\n| All providers                    | ✅    | ✅    | ✅                              |\n\n---\n\n## Dev Scripts\n\n```bash\nbun run dev         # Dev server with hot reload\nbun run test        # Unit tests\nbun run check       # Biome lint + format check\nbun run lint:fix    # Auto-fix all issues\nbun run typecheck   # TypeScript check\nbun run build       # Compile standalone binary\nbun run bump        # Show current version\nbun run bump:patch  # Bump patch version (x.y.Z) and sync all package.json files\nbun run bump:minor  # Bump minor version (x.Y.0) and sync all package.json files\nbun run bump:major  # Bump major version (X.0.0) and sync all package.json files\n```\n\n---\n\n## Troubleshooting\n\n| Problem                         | Solution                                                                  |\n| ------------------------------- | ------------------------------------------------------------------------- |\n| `/v1/models` returns empty      | Run `token-free-gateway webauth` to authorize providers                   |\n| `/health` returns `degraded`    | Chrome is not reachable — run `token-free-gateway chrome start`           |\n| webauth hangs                   | Press **Ctrl+C** — credentials are saved                                  |\n| Chrome auto-start fails         | Run `token-free-gateway chrome start` manually, then rerun `webauth`      |\n| Chrome port 9222 already in use | Stop conflicting process: `lsof -i:9222` / `netstat -ano \\| findstr 9222` |\n| DeepSeek auth fails             | Keep DeepSeek chat page open during `webauth`                             |\n| Daemon not starting             | Check logs: `~/.token-free-gateway/gateway.log`                           |\n\n---\n\n## Acknowledgments\n\nThis project was distilled and redesigned from [openclaw-zero-token](https://github.com/linuxhsj/openclaw-zero-token), extracting the web AI provider layer and OpenAI compatibility module into a standalone, lightweight gateway focused purely on protocol conversion.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-4f76c918dc7ec350b5a44b2baf4e1f8e"}