> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiji.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# 网络与代理

> 排查连接超时、代理冲突和证书错误等网络问题。

吉吉API 的请求地址支持直连，日常调用不需要代理。

## 选择线路

吉吉API 提供三个域名，接口和 API Key 完全通用：

| 线路 | 域名 | 适合场景 |
| - | - | - |
| 默认 | `www.jiji.cc` | 大多数情况 |
| CF 优化 | `api.jiji.cc` | 经 Cloudflare 加速，适合海外网络或开着代理时使用 |
| 三网优化 | `api-slb.jiji.cc` | 针对国内电信、联通、移动网络优化 |

用下面的命令对比三个域名的响应时间，选最快的一个：

<CodeGroup>
  ```bash macOS/Linux theme={null}
  for h in www.jiji.cc api.jiji.cc api-slb.jiji.cc; do
    printf "%-18s" "$h"; curl -o /dev/null -s -w "%{time_total}s\n" "https://$h"
  done
  ```

  ```powershell Windows theme={null}
  foreach ($h in "www.jiji.cc","api.jiji.cc","api-slb.jiji.cc") {
    "{0,-18}{1:N0} ms" -f $h, (Measure-Command { curl.exe -o NUL -s "https://$h" }).TotalMilliseconds
  }
  ```
</CodeGroup>

切换线路时，只替换配置中的域名，路径保持不变。例如：

| 工具 | 默认 | 换成三网优化 |
| - | - | - |
| Claude Code | `https://www.jiji.cc` | `https://api-slb.jiji.cc` |
| Codex | `https://www.jiji.cc/v1` | `https://api-slb.jiji.cc/v1` |

## 安装工具时的网络问题

部分工具的官方安装脚本需要访问海外网站。无法访问时，可以改用国内镜像：

| 工具 | 官方脚本访问 | 国内替代方式 |
| - | - | - |
| Claude Code | `claude.ai` | 用 Homebrew 或 WinGet 安装，见 [安装](/claude-code/introduction#安装) |
| Codex | `chatgpt.com` | `npm i -g @openai/codex --registry=https://registry.npmmirror.com` |
| Gemini CLI | npm | `npm i -g @google/gemini-cli --registry=https://registry.npmmirror.com` |

npm 镜像的配置方法见 [Node.js 环境配置](/environment/setup#使用国内镜像)。

## 调用时的网络问题

<AccordionGroup>
  <Accordion title="开着代理时连接失败或很慢">
    代理软件可能把吉吉API 的流量转发到海外节点，导致变慢或失败。

    * **推荐**：在代理软件的规则中，把 `jiji.cc` 设置为直连
    * **或者**：改用 CF 优化线路 `api.jiji.cc`
    * **或者**：在终端中设置 `NO_PROXY`，让吉吉API 的请求绕过代理

    <CodeGroup>
      ```bash macOS/Linux theme={null}
      export NO_PROXY="jiji.cc,.jiji.cc,localhost,127.0.0.1"
      ```

      ```powershell Windows theme={null}
      $env:NO_PROXY = "jiji.cc,.jiji.cc,localhost,127.0.0.1"
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="检查终端是否设置了代理">
    终端中的代理环境变量会影响 CLI 工具：

    <CodeGroup>
      ```bash macOS/Linux theme={null}
      env | grep -i proxy
      ```

      ```powershell Windows theme={null}
      Get-ChildItem Env: | Where-Object Name -like "*proxy*"
      ```
    </CodeGroup>

    有输出且你不需要代理时，在当前终端中清除：

    ```bash theme={null}
    unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy
    ```
  </Accordion>

  <Accordion title="测试能否连接吉吉API">
    ```bash theme={null}
    curl -I https://www.jiji.cc
    ```

    能返回 HTTP 状态码说明网络正常。超时或无法解析域名时，先换另外两个域名测试，再检查网络连接、DNS 设置和代理配置。
  </Accordion>

  <Accordion title="SSL 证书错误">
    出现 `self-signed certificate`、`unable to verify the first certificate` 等错误，通常是公司网络、安全软件或代理软件拦截了 HTTPS 连接。

    * 关闭代理或安全软件的 HTTPS 扫描后重试
    * 在公司网络中，联系网络管理员获取根证书，并通过 `NODE_EXTRA_CA_CERTS` 指定证书路径
  </Accordion>

  <Accordion title="长任务中途断开">
    出现 `stream disconnected`、`connection reset` 时，通常是网络不稳定或代理节点切换导致。换一条线路，或关闭代理直连后重试。
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.