[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-78614":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":35,"readmeContent":36,"aiSummary":37,"trendingCount":16,"starSnapshotCount":16,"syncStatus":38,"lastSyncTime":39,"discoverSource":40},78614,"any-llm","mozilla-ai\u002Fany-llm","mozilla-ai","Communicate with an LLM provider using a single interface","https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm",null,"Python",2053,178,9,19,0,5,18,44,15,82.16,"Apache License 2.0",false,"main",true,[27,28,29,30,31,32,33,34],"ai","anthropic","developer-tools","inference","llm","openai","python","text-completion","2026-06-12 04:01:23","\u003Cp align=\"center\">\n  \u003Cpicture>\n    \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fmozilla-ai\u002Fany-llm\u002Frefs\u002Fheads\u002Fmain\u002Fdocs\u002Fimages\u002Fany-llm-logo-mark.png\" width=\"20%\" alt=\"Project logo\"\u002F>\n  \u003C\u002Fpicture>\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n\n# any-llm\n\n[![Read the Blog Post](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FRead%20the%20Blog%20Post-red.svg)](https:\u002F\u002Fblog.mozilla.ai\u002Fintroducing-any-llm-a-unified-api-to-access-any-llm-provider\u002F)\n\n[![Docs](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Fdocs.yaml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Fdocs.yaml\u002F)\n\n[![Linting](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Flint.yaml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Flint.yaml\u002F)\n[![Unit Tests](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Ftests-unit.yaml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Ftests-unit.yaml\u002F)\n[![Integration Tests](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Ftests-integration.yaml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-llm\u002Factions\u002Fworkflows\u002Ftests-integration.yaml\u002F)\n\n![Python 3.11+](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-3.11%2B-blue.svg)\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fany-llm-sdk)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fany-llm-sdk\u002F)\n\u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002F4gf3zXrQUc\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fstatic\u002Fv1?label=Chat%20on&message=Discord&color=blue&logo=Discord&style=flat-square\" alt=\"Discord\">\n\u003C\u002Fa>\n\n**Communicate with any LLM provider using a single, unified interface.**\nSwitch between OpenAI, Anthropic, Mistral, Ollama, and more without changing your code.\n\n[Documentation](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002F) | [otari.ai](https:\u002F\u002Fotari.ai\u002F) | [Try the Demos](#-try-it) | [Contributing](#-contributing)\n\n\u003C\u002Fdiv>\n\n## Quickstart\n\n```python\npip install 'any-llm-sdk[mistral,ollama]'\n\nexport MISTRAL_API_KEY=\"YOUR_KEY_HERE\"  # or OPENAI_API_KEY, etc\nfrom any_llm import completion\nimport os\n\n# Make sure you have the appropriate environment variable set\nassert os.environ.get('MISTRAL_API_KEY')\n\nresponse = completion(\n    model=\"mistral-small-latest\",\n    provider=\"mistral\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\nprint(response.choices[0].message.content)\n```\n**That's it!** Change the provider name and add provider-specific keys to switch between LLM providers.\n\n\n> **Coming from LiteLLM?** Your API keys and environment variables carry over unchanged. Install the SDK with extras for the providers you need, then update your import and model strings:\n>\n> ```bash\n> pip install 'any-llm-sdk[openai,anthropic]'  # or [all] for everything\n> ```\n> ```python\n> # before\n> from litellm import completion\n> response = completion(model=\"openai\u002Fgpt-4o\", messages=[...])\n>\n> # after\n> from any_llm import completion\n> response = completion(model=\"openai:gpt-4o\", messages=[...])\n> ```\n>\n> See [Supported Providers](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002Fproviders\u002F) to map your existing model strings.\n\nThat's the full migration — no proxy, no extra config.\n\n## Installation\n\n### Requirements\n\n- Python 3.11 or newer\n- API keys for whichever LLM providers you want to use\n\n### Basic Installation\n\nInstall support for specific providers:\n\n```bash\npip install 'any-llm-sdk[openai]'           # Just OpenAI\npip install 'any-llm-sdk[mistral,ollama]'   # Multiple providers\npip install 'any-llm-sdk[all]'              # All supported providers\n```\n\nSee our [list of supported providers](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002Fproviders\u002F) to choose which ones you need.\n\n### Setting Up API Keys\n\nSet environment variables for your chosen providers:\n\n```bash\nexport OPENAI_API_KEY=\"your-key-here\"\nexport ANTHROPIC_API_KEY=\"your-key-here\"\nexport MISTRAL_API_KEY=\"your-key-here\"\n# ... etc\n```\n\nAlternatively, pass API keys directly in your code (see [Usage](#usage) examples).\n\n## Otari Gateway\n\nFor budget management, API key management, usage analytics, and multi-tenant support, see [mozilla-ai\u002Fotari](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fotari).\n\n## Why choose `any-llm`?\n\n- **Simple, unified interface** - Single function for all providers, switch models with just a string change\n- **Developer friendly** - Full type hints for better IDE support and clear, actionable error messages\n- **Leverages official provider SDKs** - Ensures maximum compatibility\n- **Stays framework-agnostic** so it can be used across different projects and use cases\n- **Battle-tested** - Powers our own production tools ([any-agent](https:\u002F\u002Fgithub.com\u002Fmozilla-ai\u002Fany-agent))\n\n## Usage\n\n`any-llm` offers two main approaches for interacting with LLM providers:\n\n#### Option 1: Direct API Functions (Recommended for Bootstrapping and Experimentation)\n\n**Recommended approach:** Use separate `provider` and `model` parameters:\n\n```python\nfrom any_llm import completion\nimport os\n\n# Make sure you have the appropriate environment variable set\nassert os.environ.get('MISTRAL_API_KEY')\n\nresponse = completion(\n    model=\"mistral-small-latest\",\n    provider=\"mistral\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\nprint(response.choices[0].message.content)\n```\n\n**Alternative syntax:** Use combined `provider:model` format:\n\n```python\nresponse = completion(\n    model=\"mistral:mistral-small-latest\", # \u003Cprovider_id>:\u003Cmodel_id>\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\n```\n\n#### Option 2: AnyLLM Class (Recommended for Production)\n\nFor applications that need to reuse providers, perform multiple operations, or require more control:\n\n```python\nfrom any_llm import AnyLLM\n\nllm = AnyLLM.create(\"mistral\", api_key=\"your-mistral-api-key\")\n\nresponse = llm.completion(\n    model=\"mistral-small-latest\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\n\n```\n\n#### When to Use Which Approach\n\n| Approach | Best For | Connection Handling |\n|----------|----------|---------------------|\n| **Direct API Functions** (`completion`) | Scripts, notebooks, single requests | New client per call (stateless) |\n| **AnyLLM Class** (`AnyLLM.create`) | Production apps, multiple requests | Reuses client (connection pooling) |\n\nBoth approaches support identical features: streaming, tools, responses API, etc.\n\n### Responses API\n\nFor providers that implement the OpenAI-style Responses API, use [`responses`](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002Fapi\u002Fresponses\u002F) or `aresponses`:\n\n```python\nfrom any_llm import responses\n\nresult = responses(\n    model=\"gpt-4o-mini\",\n    provider=\"openai\",\n    input_data=[\n        {\"role\": \"user\", \"content\": [\n            {\"type\": \"text\", \"text\": \"Summarize this in one sentence.\"}\n        ]}\n    ],\n)\n\n# Non-streaming returns an OpenAI-compatible Responses object alias\nprint(result.output_text)\n```\n\n### Finding the Right Model\n\nThe `provider_id` should match our [supported provider names](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002Fproviders\u002F).\n\nThe `model_id` is passed directly to the provider. To find available models:\n- Check the provider's documentation\n- Use our `list_models` API (if the provider supports it)\n\n\n## Motivation\n\nThe landscape of LLM provider interfaces is fragmented. While OpenAI's API has become the de facto standard, providers implement slight variations in parameter names, response formats, and feature sets. This creates a need for light wrappers that gracefully handle these differences while maintaining a consistent interface.\n\n**Existing Solutions and Their Limitations:**\n\n- **[LiteLLM](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm)**: Popular but reimplements provider interfaces rather than leveraging official SDKs, leading to potential compatibility issues.\n- **[AISuite](https:\u002F\u002Fgithub.com\u002Fandrewyng\u002Faisuite\u002Fissues)**: Clean, modular approach but lacks active maintenance, comprehensive testing, and modern Python typing standards.\n- **[Framework-specific solutions](https:\u002F\u002Fgithub.com\u002Fagno-agi\u002Fagno\u002Ftree\u002Fmain\u002Flibs\u002Fagno\u002Fagno\u002Fmodels)**: Some agent frameworks either depend on LiteLLM or implement their own provider integrations, creating fragmentation\n- **[Proxy Only Solutions](https:\u002F\u002Fopenrouter.ai\u002F)**: solutions like [OpenRouter](https:\u002F\u002Fopenrouter.ai\u002F) and [Portkey](https:\u002F\u002Fgithub.com\u002FPortkey-AI\u002Fportkey-python-sdk) require a hosted proxy between your code and the LLM provider.\n\n`any-llm` addresses these challenges by leveraging official SDKs when available, maintaining framework-agnostic design, and requiring no proxy servers.\n\n## Documentation\n- **[Full Documentation](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002F)** - Complete guides and API reference\n- **[Supported Providers](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002Fproviders\u002F)** - List of all supported LLM providers\n- **[Cookbook Examples](https:\u002F\u002Fdocs.mozilla.ai\u002Fany-llm\u002Fcookbooks\u002Fany-llm-getting-started)** - In-depth usage examples\n- **[Platform](https:\u002F\u002Fotari.ai\u002F)** - Managed control plane for key management, usage tracking, and cost visibility\n\n\n## Contributing\nWe welcome contributions from developers of all skill levels! Please see our [Contributing Guide](CONTRIBUTING.md) or open an issue to discuss changes.\n\n## License\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE.md) file for details.\n","any-llm 是一个用于通过单一接口与多个大型语言模型（LLM）提供商进行通信的项目。其核心功能在于提供了一个统一的API，使得开发者可以在不同的LLM提供商之间轻松切换，而无需修改代码逻辑，支持包括OpenAI、Anthropic、Mistral等在内的多种主流LLM服务。该项目使用Python编写，并且提供了详细的文档和示例帮助快速上手。any-llm非常适合需要跨多个LLM平台开发或迁移应用的场景，特别是对于那些希望减少因更换LLM供应商而导致的技术债务的企业级应用来说非常有用。",2,"2026-06-11 03:57:01","high_star"]