跳转至

常用服务配置示例

本文档提供常见 AI 服务的实例配置示例,帮助用户快速上手。

在线 API 服务

OpenAI GPT

字段
服务类型chat
实例名称gpt-4o
基础 URLhttps://api.openai.com
路径/v1/chat/completions
适配器normal
请求头Authorization: Bearer sk-xxx
基础 URL:    https://api.openai.com
路径:        /v1/chat/completions
请求头名称:  Authorization
请求头值:    Bearer sk-proj-xxxxx

DeepSeek

DeepSeek 兼容 OpenAI API 格式,使用 normal 适配器。

字段
服务类型chat
实例名称deepseek-chat
基础 URLhttps://api.deepseek.com
路径/v1/chat/completions
适配器normal
请求头Authorization: Bearer sk-xxx
基础 URL:    https://api.deepseek.com
路径:        /v1/chat/completions
请求头名称:  Authorization
请求头值:    Bearer sk-xxxxxxxx

Anthropic Claude

Claude 使用专用适配器,认证方式为 x-api-key 头。

字段
服务类型chat
实例名称claude-sonnet
基础 URLhttps://api.anthropic.com
路径/v1/messages
适配器claude
请求头x-api-key: sk-ant-xxx
基础 URL:    https://api.anthropic.com
路径:        /v1/messages
请求头名称:  x-api-key
请求头值:    sk-ant-api03-xxxxx

注意anthropic-version 头由适配器自动注入,无需手动配置。


Google Gemini

Gemini 兼容 OpenAI API 格式,使用 normal 适配器。

字段
服务类型chat
实例名称gemini-pro
基础 URLhttps://generativelanguage.googleapis.com/v1beta/openai
路径/chat/completions
适配器normal
请求头Authorization: Bearer xxx
基础 URL:    https://generativelanguage.googleapis.com/v1beta/openai
路径:        /chat/completions
请求头名称:  Authorization
请求头值:    Bearer AIzaSyxxxxx

阿里云百炼(通义千问)

字段
服务类型chat
实例名称qwen-plus
基础 URLhttps://dashscope.aliyuncs.com/compatible-mode
路径/v1/chat/completions
适配器normal
请求头Authorization: Bearer sk-xxx
基础 URL:    https://dashscope.aliyuncs.com/compatible-mode
路径:        /v1/chat/completions
请求头名称:  Authorization
请求头值:    Bearer sk-xxxxxxxx

腾讯云混元

字段
服务类型chat
实例名称hunyuan-chat
基础 URLhttps://api.hunyuan.cloud.tencent.com
路径/v1/chat/completions
适配器normal
请求头Authorization: Bearer sk-xxx
基础 URL:    https://api.hunyuan.cloud.tencent.com
路径:        /v1/chat/completions
请求头名称:  Authorization
请求头值:    Bearer sk-xxxxxxxx

百度智能云(文心一言)

字段
服务类型chat
实例名称ernie-4.0
基础 URLhttps://aip.baidubce.com
路径/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-4.0-8k
适配器normal
请求头Authorization: Bearer access_token

注意:百度 API 需要先获取 access_token,不是 API Key 直接使用。


本地推理引擎

Ollama

字段
服务类型chat
实例名称ollama-llama3
基础 URLhttp://localhost:11434
路径/api/chat
适配器ollama
请求头无需认证
基础 URL:    http://localhost:11434
路径:        /api/chat
适配器:      ollama
请求头:      无需配置

vLLM

字段
服务类型chat
实例名称vllm-qwen
基础 URLhttp://localhost:8000
路径/v1/chat/completions
适配器vllm
请求头无需认证(除非配置了 API Key)
基础 URL:    http://localhost:8000
路径:        /v1/chat/completions
适配器:      vllm
请求头:      无需配置

GPUStack

字段
服务类型chat
实例名称gpustack-llama
基础 URLhttp://localhost:8080
路径/v1/chat/completions
适配器gpustack
请求头Authorization: Bearer sk-xxx(如果配置了 API Key)
基础 URL:    http://localhost:8080
路径:        /v1/chat/completions
适配器:      gpustack
请求头名称:  Authorization(可选)
请求头值:    Bearer your-api-key(可选)

Xinference

字段
服务类型chat
实例名称xinference-chat
基础 URLhttp://localhost:9997
路径/v1/chat/completions
适配器xinference
请求头无需认证
基础 URL:    http://localhost:9997
路径:        /v1/chat/completions
适配器:      xinference
请求头:      无需配置

LocalAI

字段
服务类型chat
实例名称localai-chat
基础 URLhttp://localhost:8080
路径/v1/chat/completions
适配器localai
请求头无需认证
基础 URL:    http://localhost:8080
路径:        /v1/chat/completions
适配器:      localai
请求头:      无需配置

适配器对照表

适配器适用服务认证方式
normalOpenAI、DeepSeek、Gemini、阿里百炼、腾讯混元Authorization: Bearer
claudeAnthropic Claudex-api-key
ollamaOllama无需认证
vllmvLLM无需认证(可选)
gpustackGPUStackAuthorization: Bearer(可选)
xinferenceXinference无需认证
localaiLocalAI无需认证

Embedding 服务配置示例

OpenAI Embedding

字段
服务类型embedding
实例名称text-embedding-3-small
基础 URLhttps://api.openai.com
路径/v1/embeddings
适配器normal
请求头Authorization: Bearer sk-xxx

Ollama Embedding

字段
服务类型embedding
实例名称nomic-embed-text
基础 URLhttp://localhost:11434
路径/api/embeddings
适配器ollama
请求头无需认证

常见问题

Q: 如何同时配置多个 OpenAI 实例?

A: 添加多个实例,设置不同的名称和权重即可。例如:

实例 1: gpt-4o      权重 5
实例 2: gpt-4o-mini 权重 3
实例 3: gpt-3.5-turbo 权重 2

Q: 请求头中的 API Key 会暴露吗?

A: API Key 在页面上以密码形式显示,在传输过程中使用 HTTPS 加密。JAiRouter 内部存储时会进行脱敏处理。

Q: Claude 适配器的 anthropic-version 头需要手动配置吗?

A: 不需要。选择 claude 适配器后,anthropic-version: 2023-06-01 会自动注入。

Q: 本地推理引擎没有认证,需要配置请求头吗?

A: 不需要。Ollama、vLLM、Xinference 等本地服务默认无需认证,请求头留空即可。