跳转到内容

提供商设置指南

本指南详细介绍 Claudex 支持的每个提供商的配置方法,包括 API Key 提供商、OAuth 订阅、云平台和本地模型。

  1. console.anthropic.com 注册
  2. 进入 API Keys 页面创建密钥(格式:sk-ant-*
[[profiles]]
name = "anthropic"
provider_type = "DirectAnthropic"
base_url = "https://api.anthropic.com"
api_key = "sk-ant-..."
default_model = "claude-sonnet-4-20250514"
Terminal window
claudex profile test anthropic
  1. platform.minimaxi.com 注册
  2. 在控制台中进入 API Keys 页面
[[profiles]]
name = "minimax"
provider_type = "DirectAnthropic"
base_url = "https://api.minimax.io/anthropic"
api_key = "..."
default_model = "claude-sonnet-4-20250514"
Terminal window
claudex profile test minimax
  1. openrouter.ai 注册
  2. openrouter.ai/keys 获取 API 密钥
[[profiles]]
name = "openrouter"
provider_type = "OpenAICompatible"
base_url = "https://openrouter.ai/api/v1"
api_key = "sk-or-..."
default_model = "anthropic/claude-sonnet-4"
Terminal window
claudex profile test openrouter
  1. console.x.ai 注册
  2. 在控制台中创建 API 密钥
[[profiles]]
name = "grok"
provider_type = "OpenAICompatible"
base_url = "https://api.x.ai/v1"
api_key = "xai-..."
default_model = "grok-3-beta"
Terminal window
claudex profile test grok
  1. platform.openai.com 注册
  2. platform.openai.com/api-keys 创建 API 密钥
[[profiles]]
name = "chatgpt"
provider_type = "OpenAICompatible"
base_url = "https://api.openai.com/v1"
api_key = "sk-..."
default_model = "gpt-4o"
Terminal window
claudex profile test chatgpt
  1. platform.deepseek.com 注册
  2. 在控制台中创建 API 密钥
[[profiles]]
name = "deepseek"
provider_type = "OpenAICompatible"
base_url = "https://api.deepseek.com"
api_key = "sk-..."
default_model = "deepseek-chat"
Terminal window
claudex profile test deepseek
  1. platform.moonshot.cn 注册
  2. 在控制台中创建 API 密钥
[[profiles]]
name = "kimi"
provider_type = "OpenAICompatible"
base_url = "https://api.moonshot.ai/v1"
api_key = "sk-..."
default_model = "kimi-k2-0905-preview"
Terminal window
claudex profile test kimi
  1. open.bigmodel.cn 注册
  2. 在控制台中创建 API 密钥
[[profiles]]
name = "glm"
provider_type = "OpenAICompatible"
base_url = "https://api.z.ai/api/paas/v4"
api_key = "..."
default_model = "glm-4.6"
Terminal window
claudex profile test glm
  1. console.groq.com 注册
  2. Settings > API Keys 中创建 API 密钥
[[profiles]]
name = "groq"
provider_type = "OpenAICompatible"
base_url = "https://api.groq.com/openai/v1"
api_key = "gsk_..."
default_model = "llama-3.3-70b-versatile"
Terminal window
claudex profile test groq
  1. console.mistral.ai 注册
  2. 在控制台中创建 API 密钥
[[profiles]]
name = "mistral"
provider_type = "OpenAICompatible"
base_url = "https://api.mistral.ai/v1"
api_key = "..."
default_model = "mistral-large-latest"
Terminal window
claudex profile test mistral
  1. api.together.ai 注册
  2. 在仪表盘中创建 API 密钥
[[profiles]]
name = "together"
provider_type = "OpenAICompatible"
base_url = "https://api.together.xyz/v1"
api_key = "..."
default_model = "meta-llama/Llama-3.3-70B-Instruct-Turbo"
Terminal window
claudex profile test together
  1. perplexity.ai 注册
  2. perplexity.ai/settings/api 创建 API 密钥
[[profiles]]
name = "perplexity"
provider_type = "OpenAICompatible"
base_url = "https://api.perplexity.ai"
api_key = "pplx-..."
default_model = "sonar-pro"
Terminal window
claudex profile test perplexity
  1. cloud.cerebras.ai 注册
  2. 在仪表盘中创建 API 密钥
[[profiles]]
name = "cerebras"
provider_type = "OpenAICompatible"
base_url = "https://api.cerebras.ai/v1"
api_key = "..."
default_model = "llama-3.3-70b"
Terminal window
claudex profile test cerebras
  1. Azure Portal 创建 Azure OpenAI 资源
  2. 部署模型并记录资源名称和部署名称
  3. Keys and Endpoint 获取 API 密钥
[[profiles]]
name = "azure-openai"
provider_type = "OpenAICompatible"
base_url = "https://YOUR_RESOURCE.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT"
api_key = "YOUR_AZURE_KEY"
default_model = "gpt-4o"
[profiles.query_params]
api-version = "2024-12-01-preview"
Terminal window
claudex profile test azure-openai
  1. 在 GCP 项目中启用 Vertex AI API
  2. 使用 gcloud auth print-access-token 生成访问令牌
[[profiles]]
name = "vertex-ai"
provider_type = "DirectAnthropic"
base_url = "https://us-east5-aiplatform.googleapis.com/v1/projects/YOUR_PROJECT/locations/us-east5/publishers/anthropic/models"
api_key = "YOUR_GCLOUD_TOKEN"
default_model = "claude-sonnet-4@20250514"
Terminal window
claudex profile test vertex-ai

AWS Bedrock 通过 LiteLLM 代理支持:

  1. 安装 LiteLLM:pip install litellm
  2. 启动代理:
Terminal window
litellm --model bedrock/anthropic.claude-sonnet-4-20250514-v2:0
  1. 配置 Claudex:
[[profiles]]
name = "bedrock"
provider_type = "OpenAICompatible"
base_url = "http://localhost:4000/v1"
api_key = "sk-litellm"
default_model = "bedrock/anthropic.claude-sonnet-4-20250514-v2:0"

OAuth 认证允许你使用现有的提供商订阅(ChatGPT Plus、Claude Max 等),无需单独的 API 密钥。

使用你现有的 Claude 订阅,通过 Claude Code 的原生 OAuth 会话。

前置条件:已安装 Claude Code 且已登录(claude 命令正常工作)

[[profiles]]
name = "claude-max"
provider_type = "DirectAnthropic"
base_url = "https://api.claude.ai"
default_model = "claude-sonnet-4-20250514"
auth_type = "oauth"
oauth_provider = "claude"
[profiles.models]
haiku = "claude-haiku-4-20250514"
sonnet = "claude-sonnet-4-20250514"
opus = "claude-opus-4-20250514"

通过 Codex CLI token 使用你的 ChatGPT Plus 或 Pro 订阅。

前置条件:安装 Codex CLI 并完成认证:

Terminal window
# 安装 Codex CLI
npm install -g @openai/codex
# 认证(会打开浏览器)
codex auth

然后配置 Claudex:

[[profiles]]
name = "codex-sub"
provider_type = "OpenAIResponses"
base_url = "https://chatgpt.com/backend-api/codex"
default_model = "gpt-5.3-codex"
auth_type = "oauth"
oauth_provider = "openai"
[profiles.models]
haiku = "codex-mini-latest"
sonnet = "gpt-5.3-codex"
opus = "gpt-5.3-codex"
Terminal window
# 从 Codex CLI 读取 token
claudex auth login openai --profile codex-sub
# 验证
claudex auth status
# 运行
claudex run codex-sub

通过 Gemini CLI 凭证使用你的 Google 账户。

[[profiles]]
name = "gemini-sub"
provider_type = "OpenAICompatible"
base_url = "https://generativelanguage.googleapis.com/v1beta/openai"
default_model = "gemini-2.5-pro"
auth_type = "oauth"
oauth_provider = "google"
[profiles.models]
haiku = "gemini-2.0-flash"
sonnet = "gemini-2.5-pro"
opus = "gemini-2.5-pro"
Terminal window
# 从 Gemini CLI 凭证读取登录信息
claudex auth login google --profile gemini-sub
# 验证
claudex auth status

通过 OAuth Device Code 流程使用你的 Qwen 账户。

[[profiles]]
name = "qwen-oauth"
provider_type = "OpenAICompatible"
base_url = "https://chat.qwen.ai/api"
default_model = "qwen3-235b-a22b"
auth_type = "oauth"
oauth_provider = "qwen"
Terminal window
# 启动 Device Code 流程
claudex auth login qwen --profile qwen-oauth
# 验证
claudex auth status

通过 Kimi CLI 凭证使用你的 Kimi 账户。

[[profiles]]
name = "kimi-oauth"
provider_type = "OpenAICompatible"
base_url = "https://api.moonshot.cn/v1"
default_model = "moonshot-v1-128k"
auth_type = "oauth"
oauth_provider = "kimi"
Terminal window
# 从 Kimi CLI 凭证读取登录信息
claudex auth login kimi --profile kimi-oauth
# 验证
claudex auth status

通过 OAuth Device Code 流程使用你的 GitHub Copilot 订阅。

[[profiles]]
name = "copilot"
provider_type = "OpenAICompatible"
base_url = "https://api.githubcopilot.com"
default_model = "gpt-4o"
auth_type = "oauth"
oauth_provider = "github"
Terminal window
# 启动 Device Code 流程(打开浏览器进行 GitHub 登录)
claudex auth login github --profile copilot
# 验证
claudex auth status

通过个人访问令牌使用你的 GitLab Duo 订阅。

[[profiles]]
name = "gitlab-duo"
provider_type = "OpenAICompatible"
base_url = "https://gitlab.com/api/v4/ai/llm/proxy"
default_model = "claude-sonnet-4-20250514"
auth_type = "oauth"
oauth_provider = "gitlab"
Terminal window
# 将 GitLab token 设为环境变量
export GITLAB_TOKEN=glpat-...
# 登录
claudex auth login gitlab --profile gitlab-duo
# 验证
claudex auth status
  1. 安装 Ollama:ollama.com
  2. 拉取模型:
Terminal window
ollama pull qwen2.5:72b
  1. 配置 Claudex:
[[profiles]]
name = "local-qwen"
provider_type = "OpenAICompatible"
base_url = "http://localhost:11434/v1"
api_key = ""
default_model = "qwen2.5:72b"
Terminal window
claudex profile test local-qwen
  1. 安装并启动 vLLM:
Terminal window
pip install vllm
vllm serve meta-llama/Llama-3.3-70B-Instruct --port 8000
  1. 配置 Claudex:
[[profiles]]
name = "local-llama"
provider_type = "OpenAICompatible"
base_url = "http://localhost:8000/v1"
api_key = ""
default_model = "meta-llama/Llama-3.3-70B-Instruct"
  1. lmstudio.ai 下载 LM Studio
  2. 加载模型并启动本地服务器(默认端口:1234)
[[profiles]]
name = "lm-studio"
provider_type = "OpenAICompatible"
base_url = "http://localhost:1234/v1"
api_key = "lm-studio"
default_model = "local-model"

配置任何提供商后,验证连通性:

Terminal window
# 测试指定 profile
claudex profile test <profile-name>
# 测试所有 profile
claudex profile test all
# 列出所有已配置的 profile
claudex profile list