以编程方式使用文档

> any-llm is a unified interface for calling OpenAI, Anthropic, Google, local models (via Ollama/LocalAI), and 更多。只需更改一个字符串即可切换提供商。

安装和设置

pip install langchain-anyllm
uv add langchain-anyllm

您需要为您选择的提供商准备相应的 API 密钥。API 密钥可以通过 api_key 参数传递或设置为环境变量(例如, OPENAI_API_KEY, ANTHROPIC_API_KEY)。请参阅 any-llm 文档 了解提供商的具体要求。

聊天模型

from langchain_anyllm import ChatAnyLLM

API 参考

有关所有 ChatAnyLLM features and configurations, head to the API reference: https://github.com/mozilla-ai/langchain-any-llm