---
title: "依提供者的萬用字元路由"
url: "/docs/wildcard_routing"
canonical_url: "https://docs.litellm.ai/docs/wildcard_routing"
type: "docs"
last_updated: "2026-10-08"
related:
  - "/docs/proxy/timeout"
  - "/docs/proxy/health_check_routing"
---
# 依提供者的萬用字元路由

> Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt


**代理來自提供者的所有模型**

如果您想要**代理來自特定提供者的所有模型，而不在 config.yaml 中定義它們**，請使用此功能

## 步驟 1. 定義依提供者的路由  {#step-1-define-provider-specific-routing}

**SDK**

```python
import os
from litellm import Router

router = Router(
    model_list=[
        {
            "model_name": "anthropic/*",
            "litellm_params": {
                "model": "anthropic/*",
                "api_key": os.environ["ANTHROPIC_API_KEY"]
            }
        }, 
        {
            "model_name": "groq/*",
            "litellm_params": {
                "model": "groq/*",
                "api_key": os.environ["GROQ_API_KEY"]
            }
        }, 
        {
            "model_name": "fo::*:static::*", # all requests matching this pattern will be routed to this deployment, example: model="fo::hi::static::hi" will be routed to deployment: "openai/fo::*:static::*"
            "litellm_params": {
                "model": "openai/fo::*:static::*",
                "api_key": os.environ["OPENAI_API_KEY"]
            }
        }
    ]
)
```

**PROXY**

**步驟 1** - 在 config.yaml 上定義依提供者的路由
```yaml
model_list:
  # provider specific wildcard routing
  - model_name: "anthropic/*"
    litellm_params:
      model: "anthropic/*"
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: "groq/*"
    litellm_params:
      model: "groq/*"
      api_key: os.environ/GROQ_API_KEY
  - model_name: "fo::*:static::*" # all requests matching this pattern will be routed to this deployment, example: model="fo::hi::static::hi" will be routed to deployment: "openai/fo::*:static::*"
    litellm_params:
      model: "openai/fo::*:static::*"
      api_key: os.environ/OPENAI_API_KEY
```

## [僅限 PROXY] 步驟 2 - 執行 litellm proxy  {#proxy-only-step-2---run-litellm-proxy}

```shell
$ litellm --config /path/to/config.yaml
```

## 步驟 3 - 測試它  {#step-3---test-it}

**SDK**

```python
from litellm import Router

router = Router(model_list=...)

# Test with `anthropic/` - all models with `anthropic/` prefix will get routed to `anthropic/*`
resp = router.completion(model="anthropic/claude-sonnet-5", messages=[{"role": "user", "content": "Hello, Claude!"}])
print(resp)

# Test with `groq/` - all models with `groq/` prefix will get routed to `groq/*`
resp = router.completion(model="groq/llama3-8b-8192", messages=[{"role": "user", "content": "Hello, Groq!"}])
print(resp)

# Test with `fo::*::static::*` - all requests matching this pattern will be routed to `openai/fo::*:static::*`
resp = router.completion(model="fo::hi::static::hi", messages=[{"role": "user", "content": "Hello, Claude!"}])
print(resp)
```

**PROXY**

使用 `anthropic/` 進行測試 - 所有帶有 `anthropic/` 前綴的模型都會被路由到 `anthropic/*`
```bash
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LITELLM_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'
```

使用 `groq/` 進行測試 - 所有帶有 `groq/` 前綴的模型都會被路由到 `groq/*`
```shell
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LITELLM_API_KEY" \
  -d '{
    "model": "groq/llama3-8b-8192",
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'
```

使用 `fo::*::static::*` 進行測試 - 所有符合此模式的請求都會被路由到 `openai/fo::*:static::*`
```shell
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LITELLM_API_KEY" \
  -d '{
    "model": "fo::hi::static::hi",
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'
```

## [[僅限 PROXY] 控制萬用字元模型存取](/docs/proxy/model_access#advanced-model-access-groups) {#proxy-only-control-wildcard-model-accessdocsproxymodel_accessadvanced-model-access-groups}

## Related pages

- [逾時](https://docs.litellm.ai/docs/proxy/timeout.md)
- [受健康檢查驅動的路由](https://docs.litellm.ai/docs/proxy/health_check_routing.md)
