Skip to content

开放 API

前置说明

支持的请求方式

  • 支持 Claude API,即将 Base URL 替换为 https://aiwith.chat
  • 支持 Openai Completions API,即将 Base URL 替换为 https://aiwith.chat/v1
  • 支持 Openai Responses API,即将 Base URL 替换为 https://aiwith.chat/v1
  • 支持 Google Gemini API,即将 Base URL 替换为 https://aiwith.chat/v1

价格与支持的模型

有关支持的模型及其价格,请参阅 API 产品页

一、Claude Code 接入

1. 前提条件

  • 已注册并获取本平台 API Key
  • 已安装 Node.js 环境。

2. 安装与配置

  1. 全局安装 Claude Code:
    bash
    npm install -g @anthropic-ai/claude-code
  2. 配置环境变量:
zsh
echo 'export ANTHROPIC_BASE_URL="https://aiwith.chat"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"' >> ~/.zshrc
source ~/.zshrc

请将 YOUR_API_KEY 替换为您的平台 API Key。

3. 启动 Claude Code

bash
claude

在对话框中输入您的问题,即可体验 Claude Code 智能编程能力。

二、Cline 接入

1. 前提条件

  • 已注册并获取本平台 API Key
  • 已安装 VSCode。
  • 已在 VSCode 扩展市场安装 Cline 插件。

2. 配置步骤

  1. 打开 VSCode 左侧边栏,进入 Cline 插件界面。

  2. 点击 Use custom base URL,进行如下配置:

    • API Provider 选择 Anthropic
    • Anthropic API Key 配置替换为本平台 API Key
    • 勾选 'Use custom base URL': 输入 https://aiwith.chat
  3. 完成后点击 Done。

若使用 Openai API,则 API Provider 选择 Openai Compatible,Base URL 输入 https://aiwith.chat/v1

若使用 Google Gemini,则 API Provider 选择 Openai Compatible,Base URL 输入 https://aiwith.chat

三、Roo Code、Kilo Code 接入

Roo Code、Kilo Code 配置和 Cline 类似

四、OpenAI SDK 接入

bash
curl -X POST "https://aiwith.chat/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4-turbo",
    "messages": [
      {
        "role": "user",
        "content": "Hello, how are you?"
      }
    ],
    "max_tokens": 1000,
    "temperature": 0.7
  }'

常见问题

  • 401 错误:请检查 API Key、Base URL、API Provider 配置是否正确。
  • Token 消耗快:建议关闭自动权限审批,仅在需要时开启。
  • Cline 计费显示:实际费用因不同模型而定,显示计费已经不准确,

如有更多问题,请联系我们