mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* fix(router): strip the Bedrock route marker from the model in pass-through paths A router model on a bedrock/invoke/ or bedrock/converse/ deployment sent /model/invoke/<model id>/<action> upstream on /bedrock/model/<group>/..., which Bedrock answers with UnknownOperationException. The rewrite now drops the same routing prefixes the chat invoke path drops. * fix(router): strip the Bedrock route marker from the model in pass-through paths * test(router): pin the pass-through model path at the router core for Bedrock route markers and other providers Bedrock invoke and converse deployments must send the bare model id, a hosted_vllm deployment keeps its full provider model, and a model no provider resolves is sent as written * fix(bedrock): send chat's model id on pass-through and log spend for route-pinned models Pass-through paths for Bedrock deployments now drop a region path and resolve latest aliases like chat does, every Bedrock ARN gets its resource slash encoded, and a converse reply on an invoke-pinned deployment is logged with the converse parser so its spend row is written * fix(bedrock): build the pass-through model id with chat's builder and encode custom model ARNs * fix(bedrock): price invoke replies on application profile ARNs by their base model * fix(passthrough): keep the pass-through ARN form and price streamed invoke replies on app profile ARNs by base_model * test(bedrock): cover custom model ARN encoding on the bedrock/openai chat route --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| main.py | ||
| README.md | ||
| timeout_utils.py | ||
| utils.py | ||
This makes it easier to pass through requests to the LLM APIs.
E.g. Route to VLLM's /classify endpoint:
SDK (Basic)
import litellm
response = litellm.llm_passthrough_route(
model="hosted_vllm/papluca/xlm-roberta-base-language-detection",
method="POST",
endpoint="classify",
api_base="http://localhost:8090",
api_key=None,
json={
"model": "swapped-for-litellm-model",
"input": "Hello, world!",
}
)
print(response)
SDK (Router)
import asyncio
from litellm import Router
router = Router(
model_list=[
{
"model_name": "roberta-base-language-detection",
"litellm_params": {
"model": "hosted_vllm/papluca/xlm-roberta-base-language-detection",
"api_base": "http://localhost:8090",
}
}
]
)
request_data = {
"model": "roberta-base-language-detection",
"method": "POST",
"endpoint": "classify",
"api_base": "http://localhost:8090",
"api_key": None,
"json": {
"model": "roberta-base-language-detection",
"input": "Hello, world!",
}
}
async def main():
response = await router.allm_passthrough_route(**request_data)
print(response)
if __name__ == "__main__":
asyncio.run(main())
PROXY
- Setup config.yaml
model_list:
- model_name: roberta-base-language-detection
litellm_params:
model: hosted_vllm/papluca/xlm-roberta-base-language-detection
api_base: http://localhost:8090
- Run the proxy
litellm proxy --config config.yaml
# RUNNING on http://localhost:4000
- Use the proxy
curl -X POST http://localhost:4000/vllm/classify \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-api-key>" \
-d '{"model": "roberta-base-language-detection", "input": "Hello, world!"}' \
How to add a provider for passthrough
See VLLMModelInfo for an example.
- Inherit from BaseModelInfo
from litellm.llms.base_llm.base_utils import BaseLLMModelInfo
class VLLMModelInfo(BaseLLMModelInfo):
pass
- Register the provider in the ProviderConfigManager.get_provider_model_info
from litellm.utils import ProviderConfigManager
from litellm.types.utils import LlmProviders
provider_config = ProviderConfigManager.get_provider_model_info(
model="my-test-model", provider=LlmProviders.VLLM
)
print(provider_config)