Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ node dist/cli.js lang show

## API Endpoints

- 国内线路: `https://api.qnaigc.com`
- 国内线路: `https://openai.qiniu.com`
- 国内备用线路: `https://api.qnaigc.com`
- 海外线路: `https://openai.sufy.com`
- Modelink 线路: `https://api.modelink.ai`
- 支持接口: `/v1/chat/completions`、`/v1/messages`、`/v1/models`
- API Key 校验: `/v2/stat/usage`(轻量级,验证 token 有效性)
- 认证: Bearer token
Expand Down
14 changes: 8 additions & 6 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
## ✨ Features

- **🎯 Interactive Wizard** — Guided step-by-step setup for language, endpoint, API Key, and model on first run
- **🌐 Multi-Region Support** — Domestic (api.qnaigc.com) / International (openai.sufy.com) endpoints
- **🌐 Multi-Region Support** — Domestic (openai.qiniu.com) / Domestic Backup (api.qnaigc.com) / International (openai.sufy.com) / Modelink (api.modelink.ai) endpoints
- **🔐 API Key Management** — Input, validate, save, and revoke API keys
- **📦 Model Configuration** — Fetch available models from the API, with manual model ID input support
- **⚡ Claude Code Integration** — Automatically writes environment variables to `~/.claude/settings.json`
Expand Down Expand Up @@ -208,8 +208,10 @@ npx qiniu-coding-helper enter hermes

| Region | Base URL | Best For |
|--------|----------|----------|
| 🇨🇳 **Domestic** | `https://api.qnaigc.com` | Users in China |
| 🇨🇳 **Domestic** | `https://openai.qiniu.com` | Users in China |
| 🇨🇳 **Domestic Backup** | `https://api.qnaigc.com` | Users in China |
| 🌍 **International** | `https://openai.sufy.com` | Users outside China |
| 🔁 **Modelink** | `https://api.modelink.ai` | Available in and outside China |

### 🔧 Claude Code Environment Variables

Expand All @@ -218,7 +220,7 @@ When configuration is applied, these environment variables are set in `~/.claude
```json
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.qnaigc.com",
"ANTHROPIC_BASE_URL": "https://openai.qiniu.com",
"ANTHROPIC_AUTH_TOKEN": "<your-api-key>",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
Expand All @@ -239,7 +241,7 @@ model_provider = "qnaigc"

[model_providers.qnaigc]
name = "Qiniu"
base_url = "https://api.qnaigc.com/bypass/openai/v1"
base_url = "https://openai.qiniu.com/bypass/openai/v1"
requires_openai_auth = true
wire_api = "responses"

Expand All @@ -263,7 +265,7 @@ The configuration flow lets you multi-select models from the Qiniu model market
"id": "anthropic/claude-sonnet-4-5",
"name": "Claude Sonnet 4.5",
"vendor": "Qiniu",
"url": "https://api.qnaigc.com/v1/chat/completions",
"url": "https://openai.qiniu.com/v1/chat/completions",
"apiKey": "<your-api-key>",
"maxInputTokens": 200000,
"maxOutputTokens": 8192,
Expand Down Expand Up @@ -300,7 +302,7 @@ Hermes Agent stores its configuration in `~/.hermes/config.yaml`. The configurat
model:
provider: custom
default: anthropic/claude-sonnet-4-5
base_url: https://api.qnaigc.com/v1
base_url: https://openai.qiniu.com/v1
api_key: <your-api-key>
```

Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
## ✨ 功能特性

- **🎯 交互式向导** — 首次运行引导配置语言、线路、API Key 和模型,步步引导
- **🌐 多线路支持** — 国内线路 (api.qnaigc.com) / 海外线路 (openai.sufy.com)
- **🌐 多线路支持** — 国内线路 (openai.qiniu.com) / 国内备用线路 (api.qnaigc.com) / 海外线路 (openai.sufy.com) / Modelink 线路 (api.modelink.ai)
- **🔐 API Key 管理** — 输入、验证、保存、删除,一条龙管理
- **📦 模型配置** — 从 API 获取可用模型列表,也支持手动输入模型 ID
- **⚡ Claude Code 集成** — 自动将环境变量写入 `~/.claude/settings.json`
Expand Down Expand Up @@ -208,8 +208,10 @@ npx qiniu-coding-helper enter hermes

| 线路 | 地址 | 适用场景 |
|------|------|----------|
| 🇨🇳 **国内线路** | `https://api.qnaigc.com` | 中国大陆用户 |
| 🇨🇳 **国内线路** | `https://openai.qiniu.com` | 中国大陆用户 |
| 🇨🇳 **国内备用线路** | `https://api.qnaigc.com` | 中国大陆用户 |
| 🌍 **海外线路** | `https://openai.sufy.com` | 海外用户 |
| 🔁 **Modelink 线路** | `https://api.modelink.ai` | 国内外通用 |

### 🔧 Claude Code 环境变量

Expand All @@ -218,7 +220,7 @@ npx qiniu-coding-helper enter hermes
```json
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.qnaigc.com",
"ANTHROPIC_BASE_URL": "https://openai.qiniu.com",
"ANTHROPIC_AUTH_TOKEN": "<your-api-key>",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
Expand All @@ -239,7 +241,7 @@ model_provider = "qnaigc"

[model_providers.qnaigc]
name = "Qiniu"
base_url = "https://api.qnaigc.com/bypass/openai/v1"
base_url = "https://openai.qiniu.com/bypass/openai/v1"
requires_openai_auth = true
wire_api = "responses"

Expand All @@ -263,7 +265,7 @@ CodeBuddy 是一个 CLI 工具,配置保存在 `~/.codebuddy/models.json`。
"id": "anthropic/claude-sonnet-4-5",
"name": "Claude Sonnet 4.5",
"vendor": "Qiniu",
"url": "https://api.qnaigc.com/v1/chat/completions",
"url": "https://openai.qiniu.com/v1/chat/completions",
"apiKey": "<your-api-key>",
"maxInputTokens": 200000,
"maxOutputTokens": 8192,
Expand Down Expand Up @@ -298,7 +300,7 @@ Hermes Agent 配置保存在 `~/.hermes/config.yaml`。配置流程会从七牛
model:
provider: custom
default: anthropic/claude-sonnet-4-5
base_url: https://api.qnaigc.com/v1
base_url: https://openai.qiniu.com/v1
api_key: <your-api-key>
```

Expand Down
12 changes: 11 additions & 1 deletion src/lib/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export interface EndpointDefinition {
}

export const ENDPOINT_DEFINITIONS: Record<string, EndpointDefinition> = {
qiniu: {
id: 'qiniu',
i18nKey: 'endpoint_qiniu',
baseUrl: 'https://openai.qiniu.com',
},
china: {
id: 'china',
i18nKey: 'endpoint_china',
Expand All @@ -17,9 +22,14 @@ export const ENDPOINT_DEFINITIONS: Record<string, EndpointDefinition> = {
i18nKey: 'endpoint_international',
baseUrl: 'https://openai.sufy.com',
},
modelink: {
id: 'modelink',
i18nKey: 'endpoint_modelink',
baseUrl: 'https://api.modelink.ai',
},
};

export const DEFAULT_ENDPOINT = 'china';
export const DEFAULT_ENDPOINT = 'qiniu';

// 根据端点 ID 获取 base URL
export function getBaseUrl(endpointId: string): string {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/tools/codex-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os from 'node:os';
import { execSync } from 'node:child_process';
import type { ITool } from './base-tool.js';
import { configManager, type ModelConfig } from '../config.js';
import { DEFAULT_ENDPOINT, getBaseUrl } from '../endpoints.js';
import { t } from '../i18n.js';
import { uiRenderer } from '../wizard/ui/ui-renderer.js';
import { promptHelper } from '../wizard/ui/prompt-helper.js';
Expand All @@ -14,6 +15,7 @@ const CODEX_AUTH_FILE = path.join(CODEX_DIR, 'auth.json');
const PROVIDER_NAME = 'qnaigc';
const PROFILE_NAME = 'qn-gpt';
const CODEX_MODEL = 'openai/gpt-5.5';
const DEFAULT_CODEX_BASE_URL = getBaseUrl(DEFAULT_ENDPOINT);

// Codex 工具实现
export class CodexTool implements ITool {
Expand Down Expand Up @@ -88,7 +90,7 @@ export function buildCodexConfig(existing: string, baseUrl?: string, model?: str
let content = removeManagedCodexConfig(existing);
content = upsertTopLevelModelProvider(content);

const providerBaseUrl = `${(baseUrl || 'https://api.qnaigc.com').replace(/\/+$/, '')}/bypass/openai/v1`;
const providerBaseUrl = `${(baseUrl || DEFAULT_CODEX_BASE_URL).replace(/\/+$/, '')}/bypass/openai/v1`;
const sections = [
`[model_providers.${PROVIDER_NAME}]`,
'name = "Qiniu"',
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"language_set": "Language set to: {{lang}}",
"language_current": "Current language: {{lang}}",
"endpoint_prompt": "Select API endpoint",
"endpoint_china": "China (api.qnaigc.com)",
"endpoint_qiniu": "Domestic (openai.qiniu.com)",
"endpoint_china": "Domestic Backup (api.qnaigc.com)",
"endpoint_international": "International (openai.sufy.com)",
"endpoint_modelink": "Modelink (api.modelink.ai)",
"endpoint_set": "Endpoint set to: {{endpoint}}",
"apikey_hint": "To get an API Key, visit: https://portal.qiniu.com/ai-inference/api-key",
"apikey_prompt": "Enter your API Key",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"language_current": "当前语言: {{lang}}",

"endpoint_prompt": "请选择 API 线路",
"endpoint_china": "国内线路 (api.qnaigc.com)",
"endpoint_qiniu": "国内线路 (openai.qiniu.com)",
"endpoint_china": "国内备用线路 (api.qnaigc.com)",
"endpoint_international": "海外线路 (openai.sufy.com)",
"endpoint_modelink": "Modelink 线路 (api.modelink.ai)",
"endpoint_set": "线路已设置为: {{endpoint}}",

"apikey_hint": "如需获取 API Key,请访问: https://portal.qiniu.com/ai-inference/api-key",
Expand Down
Loading