[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-73917":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":36,"readmeContent":37,"aiSummary":38,"trendingCount":16,"starSnapshotCount":16,"syncStatus":39,"lastSyncTime":40,"discoverSource":41},73917,"octopus","bestruirui\u002Foctopus","bestruirui","One Hub All LLMs For You | 为个人打造的 LLM API 聚合网关","",null,"TypeScript",2220,305,12,56,0,18,37,108,54,29.46,"GNU Affero General Public License v3.0",false,"dev",true,[27,28,29,30,31,32,33,34,35],"ai","ai-gateway","anthropic","claude","claude-code","codex","llm-gateway","openai","self-hosted","2026-06-12 02:03:19","\u003Cdiv align=\"center\">\n\n\u003Cimg src=\"web\u002Fpublic\u002Flogo.svg\" alt=\"Octopus Logo\" width=\"120\" height=\"120\">\n\n### Octopus\n\n**A Simple, Beautiful, and Elegant LLM API Aggregation & Load Balancing Service for Individuals**\n\n English | [简体中文](README_zh.md)\n\n\u003C\u002Fdiv>\n\n\n## ✨ Features\n\n- 🔀 **Multi-Channel Aggregation** - Connect multiple LLM provider channels with unified management\n- 🔑 **Multi-Key Support** - Support multiple API keys for a single channel\n- ⚡ **Smart Selection** - Multiple endpoints per channel, smart selection of the endpoint with the shortest delay\n- ⚖️ **Load Balancing** - Automatic request distribution for stable and efficient service\n- 🔄 **Protocol Conversion** - Seamless conversion between OpenAI Chat \u002F OpenAI Responses \u002F Anthropic API formats\n- 💰 **Price Sync** - Automatic model pricing updates\n- 🔃 **Model Sync** - Automatic synchronization of available model lists with channels\n- 📊 **Analytics** - Comprehensive request statistics, token consumption, and cost tracking\n- 🎨 **Elegant UI** - Clean and beautiful web management panel\n- 🗄️ **Multi-Database Support** - Support for SQLite, MySQL, PostgreSQL\n\n\n## 🚀 Quick Start\n\n### 🐳 Docker\n\nRun directly:\n\n```bash\ndocker run -d --name octopus -v \u002Fpath\u002Fto\u002Fdata:\u002Fapp\u002Fdata -p 8080:8080 bestrui\u002Foctopus\n```\n\nOr use docker compose:\n\n```bash\nwget https:\u002F\u002Fraw.githubusercontent.com\u002Fbestruirui\u002Foctopus\u002Frefs\u002Fheads\u002Fdev\u002Fdocker-compose.yml\ndocker compose up -d\n```\n\n\n### 📦 Download from Release\n\nDownload the binary for your platform from [Releases](https:\u002F\u002Fgithub.com\u002Fbestruirui\u002Foctopus\u002Freleases), then run:\n\n```bash\n.\u002Foctopus start\n```\n\n### 🛠️ Build from Source\n\n**Requirements:**\n- Go 1.24.4\n- Node.js 18+\n- pnpm\n\n```bash\n# Clone the repository\ngit clone https:\u002F\u002Fgithub.com\u002Fbestruirui\u002Foctopus.git\ncd octopus\n# Build frontend\ncd web && pnpm install && pnpm run build && cd ..\n# Move frontend assets to static directory\nmv web\u002Fout static\u002F\n# Start the backend service\ngo run main.go start \n```\n\n> 💡 **Tip**: The frontend build artifacts are embedded into the Go binary, so you must build the frontend before starting the backend.\n\n**Development Mode**\n\n```bash\ncd web && pnpm install && NEXT_PUBLIC_API_BASE_URL=\"http:\u002F\u002F127.0.0.1:8080\" pnpm run dev\n## Open a new terminal, start the backend service\ngo run main.go start\n## Access the frontend at\nhttp:\u002F\u002Flocalhost:3000\n```\n\n### 🔐 Default Credentials\n\nAfter first launch, visit http:\u002F\u002Flocalhost:8080 and log in to the management panel with:\n\n- **Username**: `admin`\n- **Password**: `admin`\n\n> ⚠️ **Security Notice**: Please change the default password immediately after first login.\n\n### 📝 Configuration File\n\nThe configuration file is located at `data\u002Fconfig.json` by default and is automatically generated on first startup.\n\n**Complete Configuration Example:**\n\n```json\n{\n  \"server\": {\n    \"host\": \"0.0.0.0\",\n    \"port\": 8080\n  },\n  \"database\": {\n    \"type\": \"sqlite\",\n    \"path\": \"data\u002Fdata.db\"\n  },\n  \"log\": {\n    \"level\": \"info\"\n  }\n}\n```\n\n**Configuration Options:**\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `server.host` | Listen address | `0.0.0.0` |\n| `server.port` | Server port | `8080` |\n| `database.type` | Database type | `sqlite` |\n| `database.path` | Database connection string | `data\u002Fdata.db` |\n| `log.level` | Log level | `info` |\n\n**Database Configuration:**\n\nThree database types are supported:\n\n| Type | `database.type` | `database.path` Format |\n|------|-----------------|-----------------------|\n| SQLite | `sqlite` | `data\u002Fdata.db` |\n| MySQL | `mysql` | `user:password@tcp(host:port)\u002Fdbname` |\n| PostgreSQL | `postgres` | `postgresql:\u002F\u002Fuser:password@host:port\u002Fdbname?sslmode=disable` |\n\n**MySQL Configuration Example:**\n\n```json\n{\n  \"database\": {\n    \"type\": \"mysql\",\n    \"path\": \"root:password@tcp(127.0.0.1:3306)\u002Foctopus\"\n  }\n}\n```\n\n**PostgreSQL Configuration Example:**\n\n```json\n{\n  \"database\": {\n    \"type\": \"postgres\",\n    \"path\": \"postgresql:\u002F\u002Fuser:password@localhost:5432\u002Foctopus?sslmode=disable\"\n  }\n}\n```\n\n> 💡 **Tip**: MySQL and PostgreSQL require manual database creation. The application will automatically create the table structure.\n\n### 🌐 Environment Variables\n\nAll configuration options can be overridden via environment variables using the format `OCTOPUS_` + configuration path (joined with `_`):\n\n| Environment Variable | Configuration Option |\n|---------------------|---------------------|\n| `OCTOPUS_SERVER_PORT` | `server.port` |\n| `OCTOPUS_SERVER_HOST` | `server.host` |\n| `OCTOPUS_DATABASE_TYPE` | `database.type` |\n| `OCTOPUS_DATABASE_PATH` | `database.path` |\n| `OCTOPUS_LOG_LEVEL` | `log.level` |\n| `OCTOPUS_GITHUB_PAT` | For rate limiting when getting the latest version (optional) |\n| `OCTOPUS_RELAY_MAX_SSE_EVENT_SIZE` | Maximum SSE event size (optional) |\n| `OCTOPUS_IMAGES_BODY_MEMORY_THRESHOLD_MB` | Images request body in-memory threshold. If exceeded, it will be spooled to a temporary file (optional, default 16) |\n| `OCTOPUS_IMAGES_BODY_MAX_MB` | Images request body maximum size. Requests above this limit are rejected (optional, default 256) |\n| `OCTOPUS_IMAGES_BODY_TMP_DIR` | Images request body temporary directory (optional, default `.\u002Fcache`) |\n| `OCTOPUS_IMAGES_BODY_TMP_CLEANUP_HOURS` | Startup cleanup threshold for temporary files (optional, default 24) |\n\n## 📸 Screenshots\n\n### 🖥️ Desktop\n\n\u003Cdiv align=\"center\">\n\u003Ctable>\n\u003Ctr>\n\u003Ctd align=\"center\">\u003Cb>Dashboard\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Channel Management\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Group Management\u003C\u002Fb>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fdesktop-home.png\" alt=\"Dashboard\" width=\"400\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fdesktop-channel.png\" alt=\"Channel\" width=\"400\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fdesktop-group.png\" alt=\"Group\" width=\"400\">\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd align=\"center\">\u003Cb>Price Management\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Logs\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Settings\u003C\u002Fb>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fdesktop-price.png\" alt=\"Price Management\" width=\"400\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fdesktop-log.png\" alt=\"Logs\" width=\"400\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fdesktop-setting.png\" alt=\"Settings\" width=\"400\">\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\u003C\u002Fdiv>\n\n### 📱 Mobile\n\n\u003Cdiv align=\"center\">\n\u003Ctable>\n\u003Ctr>\n\u003Ctd align=\"center\">\u003Cb>Home\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Channel\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Group\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Price\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Logs\u003C\u002Fb>\u003C\u002Ftd>\n\u003Ctd align=\"center\">\u003Cb>Settings\u003C\u002Fb>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fmobile-home.png\" alt=\"Mobile Home\" width=\"140\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fmobile-channel.png\" alt=\"Mobile Channel\" width=\"140\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fmobile-group.png\" alt=\"Mobile Group\" width=\"140\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fmobile-price.png\" alt=\"Mobile Price\" width=\"140\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fmobile-log.png\" alt=\"Mobile Logs\" width=\"140\">\u003C\u002Ftd>\n\u003Ctd>\u003Cimg src=\"web\u002Fpublic\u002Fscreenshot\u002Fmobile-setting.png\" alt=\"Mobile Settings\" width=\"140\">\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftable>\n\u003C\u002Fdiv>\n\n\n## 📖 Documentation\n\n### 📡 Channel Management\n\nChannels are the basic configuration units for connecting to LLM providers.\n\n**Base URL Guide:**\n\nThe program automatically appends API paths based on channel type. You only need to provide the base URL:\n\n| Channel Type | Auto-appended Path | Base URL | Full Request URL Example |\n|--------------|-------------------|----------|--------------------------|\n| OpenAI Chat | `\u002Fchat\u002Fcompletions` | `https:\u002F\u002Fapi.openai.com\u002Fv1` | `https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fchat\u002Fcompletions` |\n| OpenAI Responses | `\u002Fresponses` | `https:\u002F\u002Fapi.openai.com\u002Fv1` | `https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fresponses` |\n| OpenAI Images | `\u002Fimages\u002Fgenerations`, `\u002Fimages\u002Fedits`, `\u002Fimages\u002Fvariations` | `https:\u002F\u002Fapi.openai.com\u002Fv1` | `https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fimages\u002Fgenerations` |\n| Anthropic | `\u002Fmessages` | `https:\u002F\u002Fapi.anthropic.com\u002Fv1` | `https:\u002F\u002Fapi.anthropic.com\u002Fv1\u002Fmessages` |\n| Gemini | `\u002Fmodels\u002F:model:generateContent` | `https:\u002F\u002Fgenerativelanguage.googleapis.com\u002Fv1beta` | `https:\u002F\u002Fgenerativelanguage.googleapis.com\u002Fv1beta\u002Fmodels\u002Fgemini-2.5-flash:generateContent` |\n\n> 💡 **Tip**: No need to include specific API endpoint paths in the Base URL - the program handles this automatically.\n\n---\n\n### 📁 Group Management\n\nGroups aggregate multiple channels into a unified external model name.\n\n**Core Concepts:**\n\n- **Group name** is the model name exposed by the program\n- When calling the API, set the `model` parameter to the group name\n\n**Load Balancing Modes:**\n\n| Mode | Description |\n|------|-------------|\n| 🔄 **Round Robin** | Cycles through channels sequentially for each request |\n| 🎲 **Random** | Randomly selects an available channel for each request |\n| 🛡️ **Failover** | Prioritizes high-priority channels, switches to lower priority only on failure |\n| ⚖️ **Weighted** | Distributes requests based on configured channel weights |\n\n> 💡 **Example**: Create a group named `gpt-4o`, add multiple providers' GPT-4o channels to it, then access all channels via a unified `model: gpt-4o`.\n\n---\n\n### 💰 Price Management\n\nManage model pricing information in the system.\n\n**Data Sources:**\n\n- The system periodically syncs model pricing data from [models.dev](https:\u002F\u002Fgithub.com\u002Fsst\u002Fmodels.dev)\n- When creating a channel, if the channel contains models not in models.dev, the system automatically creates pricing information for those models on this page, so this page displays models that haven't had their prices fetched from upstream, allowing users to set prices manually\n- Manual creation of models that exist in models.dev is also supported for custom pricing\n\n**Price Priority:**\n\n| Priority | Source | Description |\n|:--------:|--------|-------------|\n| 🥇 High | This Page | Prices set by user in price management page |\n| 🥈 Low | models.dev | Auto-synced default prices |\n\n> 💡 **Tip**: To override a model's default price, simply set a custom price for it in the price management page.\n\n---\n\n### ⚙️ Settings\n\nGlobal system configuration.\n\n**Statistics Save Interval (minutes):**\n\nSince the program handles numerous statistics, writing to the database on every request would impact read\u002Fwrite performance. The program uses this strategy:\n\n- Statistics are first stored in **memory**\n- Periodically **batch-written** to the database at the configured interval\n\n> ⚠️ **Important**: When exiting the program, use proper shutdown methods (like `Ctrl+C` or sending `SIGTERM` signal) to ensure in-memory statistics are correctly written to the database. **Do NOT use `kill -9` or other forced termination methods**, as this may result in statistics data loss.\n\n---\n\n## 🔌 Client Integration\n\n### OpenAI SDK\n\n```python\nfrom openai import OpenAI\nimport os\n\nclient = OpenAI(   \n    base_url=\"http:\u002F\u002F127.0.0.1:8080\u002Fv1\",   \n    api_key=\"sk-octopus-P48ROljwJmWBYVARjwQM8Nkiezlg7WOrXXOWDYY8TI5p9Mzg\", \n)\ncompletion = client.chat.completions.create(\n    model=\"octopus-openai\",  # Use the correct group name\n    messages = [\n        {\"role\": \"user\", \"content\": \"Hello\"},\n    ],\n)\nprint(completion.choices[0].message.content)\n```\n\n### Claude Code\n\nEdit `~\u002F.claude\u002Fsettings.json`\n\n```json\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"http:\u002F\u002F127.0.0.1:8080\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"sk-octopus-P48ROljwJmWBYVARjwQM8Nkiezlg7WOrXXOWDYY8TI5p9Mzg\",\n    \"API_TIMEOUT_MS\": \"3000000\",\n    \"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC\": \"1\",\n    \"ANTHROPIC_MODEL\": \"octopus-sonnet-4-5\",\n    \"ANTHROPIC_SMALL_FAST_MODEL\": \"octopus-haiku-4-5\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"octopus-sonnet-4-5\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"octopus-sonnet-4-5\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"octopus-haiku-4-5\"\n  }\n}\n```\n\n### Codex\n\nEdit `~\u002F.codex\u002Fconfig.toml`\n\n```toml\nmodel = \"octopus-codex\" # Use the correct group name\n\nmodel_provider = \"octopus\"\n\n[model_providers.octopus]\nname = \"octopus\"\nbase_url = \"http:\u002F\u002F127.0.0.1:8080\u002Fv1\"\n```\n\nEdit `~\u002F.codex\u002Fauth.json`\n\n```json\n{\n  \"OPENAI_API_KEY\": \"sk-octopus-P48ROljwJmWBYVARjwQM8Nkiezlg7WOrXXOWDYY8TI5p9Mzg\"\n}\n```\n\n---\n\n## 🤝 Acknowledgments\n\n- 🙏 [looplj\u002Faxonhub](https:\u002F\u002Fgithub.com\u002Flooplj\u002Faxonhub) - The LLM API adaptation module in this project is directly derived from this repository\n- 📊 [sst\u002Fmodels.dev](https:\u002F\u002Fgithub.com\u002Fsst\u002Fmodels.dev) - AI model database providing model pricing data\n- 🇨🇳 [AtomGit](https:\u002F\u002Fatomgit.com\u002Fbestruirui\u002Foctopus) - China-based code hosting\n","Octopus 是一个为个人打造的 LLM API 聚合服务。它支持多渠道聚合、多密钥管理，并具备智能选择延迟最低端点和自动负载均衡等功能，确保服务稳定高效。此外，Octopus 还提供了协议转换、价格同步、模型同步、请求统计及成本跟踪等特性，以及简洁美观的Web管理界面。该项目使用TypeScript开发，支持SQLite、MySQL和PostgreSQL等多种数据库。适用于需要整合多个LLM提供商API并进行统一管理和优化的个人开发者或小型团队。",2,"2026-06-11 03:47:54","high_star"]