Providers

OpenAI Custom

配置自定义 OpenAI 兼容服务

OpenAI Custom

OpenAI Custom 允许你配置任何 OpenAI 兼容的 API 服务。

适用场景

  • 使用 OpenAI 官方 API
  • 使用 Azure OpenAI
  • 使用其他 OpenAI 兼容服务(如 Groq、Together AI)
  • 使用本地部署的模型(如 Ollama、vLLM)

API Key 配置

获取 API Key

OpenAI 官方:

  1. 访问 OpenAI Platform
  2. 进入 API Keys 页面
  3. 创建新的 API Key

Azure OpenAI:

  1. 访问 Azure Portal
  2. 创建 Azure OpenAI 资源
  3. 获取 API Key 和端点

在 ProxyCast 中配置

  1. 进入 凭证池 页面
  2. 点击 添加凭证
  3. 选择 OpenAI Custom
  4. 填写配置信息:
字段说明
名称凭证标识名称
API KeyOpenAI API Key
Base URLAPI 端点(可选)

Base URL 设置

默认端点

不填写 Base URL 时,使用 OpenAI 官方端点:

https://api.openai.com/v1

自定义端点

服务Base URL
Azure OpenAIhttps://{resource}.openai.azure.com/openai/deployments/{deployment}
Groqhttps://api.groq.com/openai/v1
Together AIhttps://api.together.xyz/v1
Ollamahttp://localhost:11434/v1

配置示例

providers:
  - name: openai-official
    type: openai-custom
    api_key: "sk-..."
    # 使用默认 Base URL
    
  - name: azure-openai
    type: openai-custom
    api_key: "..."
    base_url: "https://myresource.openai.azure.com/openai/deployments/gpt-4"
    
  - name: ollama-local
    type: openai-custom
    api_key: "ollama"  # Ollama 不需要真实 key
    base_url: "http://localhost:11434/v1"

支持的模型

取决于你使用的服务,常见模型:

服务模型
OpenAIgpt-4, gpt-4-turbo, gpt-3.5-turbo
Azure取决于部署
Groqllama-3.1-70b, mixtral-8x7b
Ollamallama3, mistral, codellama

高级配置

请求头

添加自定义请求头:

openai-custom:
  headers:
    X-Custom-Header: "value"

Azure 特殊配置

Azure OpenAI 需要额外配置:

azure-openai:
  api_key: "..."
  base_url: "https://..."
  api_version: "2024-02-15-preview"
  headers:
    api-key: "..."  # Azure 使用 api-key 头

故障排除

API Key 无效

  1. 确认 API Key 正确
  2. 检查 Key 是否过期
  3. 确认账户有足够余额

连接失败

  1. 检查 Base URL 是否正确
  2. 确认网络可以访问端点
  3. 检查是否需要代理

模型不存在

  1. 确认模型名称正确
  2. 检查账户是否有该模型的访问权限
  3. Azure 用户确认部署名称