Skip to content

Commit 14f0815

Browse files
docs
1 parent 1ceb47a commit 14f0815

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

docs/en/latest/plugins/ai-proxy-multi.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,58 @@ curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
193193
```
194194

195195
In the above configuration `priority` for the deepseek provider is set to `0`. Which means if `openai` provider is unavailable then `ai-proxy-multi` plugin will retry sending request to `deepseek` in the second attempt.
196+
197+
### Send request to an OpenAI compatible LLM
198+
199+
Create a route with the `ai-proxy-multi` plugin with `provider.name` set to `openai-compatible` and the endpoint of the model set to `provider.override.endpoint` like so:
200+
201+
```shell
202+
curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
203+
-H "X-API-KEY: ${ADMIN_API_KEY}" \
204+
-d '{
205+
"id": "ai-proxy-multi-route",
206+
"uri": "/anything",
207+
"methods": ["POST"],
208+
"plugins": {
209+
"ai-proxy-multi": {
210+
"providers": [
211+
{
212+
"name": "openai-compatible",
213+
"model": "qwen-plus",
214+
"weight": 1,
215+
"priority": 1,
216+
"auth": {
217+
"header": {
218+
"Authorization": "Bearer '"$OPENAI_API_KEY"'"
219+
}
220+
},
221+
"override": {
222+
"endpoint": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
223+
}
224+
},
225+
{
226+
"name": "deepseek",
227+
"model": "deepseek-chat",
228+
"weight": 1,
229+
"auth": {
230+
"header": {
231+
"Authorization": "Bearer '"$DEEPSEEK_API_KEY"'"
232+
}
233+
},
234+
"options": {
235+
"max_tokens": 512,
236+
"temperature": 1.0
237+
}
238+
}
239+
],
240+
"passthrough": false
241+
}
242+
},
243+
"upstream": {
244+
"type": "roundrobin",
245+
"nodes": {
246+
"httpbin.org": 1
247+
}
248+
}
249+
}'
250+
```

docs/en/latest/plugins/ai-proxy.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,39 @@ You will receive a response like this:
142142
"usage": { "completion_tokens": 15, "prompt_tokens": 23, "total_tokens": 38 }
143143
}
144144
```
145+
146+
### Send request to an OpenAI compatible LLM
147+
148+
Create a route with the `ai-proxy` plugin with `provider` set to `openai-compatible` and the endpoint of the model set to `override.endpoint` like so:
149+
150+
```shell
151+
curl "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT \
152+
-H "X-API-KEY: ${ADMIN_API_KEY}" \
153+
-d '{
154+
"uri": "/anything",
155+
"plugins": {
156+
"ai-proxy": {
157+
"auth": {
158+
"header": {
159+
"Authorization": "Bearer <some-token>"
160+
}
161+
},
162+
"model": {
163+
"provider": "openai-compatible",
164+
"name": "qwen-plus"
165+
},
166+
"override": {
167+
"endpoint": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
168+
}
169+
}
170+
},
171+
"upstream": {
172+
"type": "roundrobin",
173+
"nodes": {
174+
"somerandom.com:443": 1
175+
},
176+
"scheme": "https",
177+
"pass_host": "node"
178+
}
179+
}'
180+
```

0 commit comments

Comments
 (0)