Multi Llm Ts
Multi Llm Ts is a TypeScript library to use LLM providers APIs in a unified way.
Last verified:
What is Multi Llm Ts?
Multi Llm Ts is a TypeScript library that provides a unified API interface to interact with multiple LLM providers. It allows developers to call 13 different LLM providers—including Anthropic, OpenAI, Google, Azure AI, MistralAI, Groq, Meta/Llama, Ollama, DeepSeek, Cerebras, OpenRouter, TogetherAI, and xAI—through a single consistent interface, eliminating the need to learn and maintain code for each provider's distinct API.
Key features include chat completion, chat streaming, text attachments, vision model support for image attachments, function calling, structured output, usage reporting with token counts, and models list retrieval. The library supports plugins for extending functionality, such as custom image generation with DALL-E, and handles multiple attachments per message. Version 4.0 introduced ChatModel objects that indicate model capabilities like tools (function calling), vision (image analysis), and reasoning (chain-of-thought models).
This tool is designed for TypeScript developers and teams building applications with large language models who want to test prompts across different models, switch between providers without changing their codebase, or avoid vendor lock-in. It is particularly useful for developers who need to compare model performance, implement fallback mechanisms between providers, or build applications that can adapt to different LLM capabilities.
The library is open-source under the Apache-2.0 license, written in 99.1% TypeScript, and has 57 GitHub stars. It brings your own API keys and calls models directly over HTTPS, giving you full control over your API usage and costs.
Multi Llm Ts pricing
Pricing model: Freemium
The library itself is free and open-source under the Apache-2.0 license. There is no paid tier or subscription for the library. Users must bring their own API keys for each LLM provider and pay directly to the respective providers (Anthropic, OpenAI, Google, Azure, etc.) for their API usage. The library calls models directly over HTTPS with no additional fees or markup.
Multi Llm Ts pros
- Unified API for 13 LLM providers in one library
- Supports chat completion and streaming out of the box
- Vision model support for image attachments
- Function calling capability across providers
- Structured output support for JSON responses
- Usage reporting with automatic token counting
- Models list retrieval for each provider
- Plugin system for custom extensions like DALL-E
- Multiple text attachments per message
- Open-source Apache-2.0 license
- Zero vendor lock-in, easy provider switching
- Supports reasoning models from Anthropic and others
- OpenAI Responses API support for compatible models
- ChatModel objects indicate model capabilities
- TypeScript-native with full type support
Multi Llm Ts cons
- No built-in API key management, bring your own keys
- Structured output not enforced by some providers
- o1 family models lack vision and function calling
- Cerebras lacks vision, function calling, and reasoning
- DeepSeek lacks vision support
- Groq lacks reasoning model support
- Meta/Llama lacks reasoning model support
- MistralAI and OpenRouter require ChatModel for capabilities
Frequently asked questions about Multi Llm Ts
What is multi-llm-ts?
multi-llm-ts is a TypeScript library that provides a unified API interface to use multiple LLM provider APIs in a consistent way. It supports 13 providers including Anthropic, OpenAI, Google, Azure AI, MistralAI, Groq, Meta/Llama, Ollama, DeepSeek, Cerebras, OpenRouter, TogetherAI, and xAI.
How do I install multi-llm-ts?
Install the library using npm with the command: npm i multi-llm-ts. After installation, you need to provide your own API key for the provider you want to use.
How do I use chat completion?
Use igniteEngine to create an LLM instance with your provider and API key, load models with loadModels, create messages array with Message objects, then call llm.complete() with the model and messages. Example: const llm = igniteEngine('openai', { apiKey: 'YOUR_KEY' }); await llm.complete(models.chat, messages);
How does chat streaming work?
Use llm.generate() instead of llm.complete() to get an async iterable stream. Iterate through chunks with for await (const chunk of stream) and check chunk.type to handle different content types like 'tool' for tool usage status or 'content' for generated text.
Which providers support vision models?
Anthropic, Azure AI, Google, Groq, Meta/Llama, MistralAI, Ollama, OpenAI, OpenRouter, TogetherAI, and xAI support vision. Cerebras and DeepSeek do not support vision models.
What is the ChatModel object in version 4.0?
The ChatModel object indicates model capabilities instead of just a model name string. It supports three capabilities: tools (function calling), vision (image analysis), and reasoning (chain-of-thought models). You can build it using LlmEngine.buildModel() or loadModels().
How do I implement function calling with plugins?
Create a Plugin class extending Plugin, override getName(), getDescription(), getParameters(), and execute() methods. Add it with llm.addPlugin(new MyPlugin()). The execute method receives parameters and can call external APIs like DALL-E for image generation.
Does multi-llm-ts support structured output?
Yes, structured output is supported for Azure AI, Cerebras, Google, Groq, MistralAI, Ollama, OpenAI, OpenRouter, TogetherAI, and xAI. Note that Google and MistralAI support JSON output but do not enforce a specific schema—you need to describe the schema in the user message.
How do I use the OpenAI Responses API?
Set EngineCreateOpts.useOpenAIResponsesApi to true when creating your engine, or set LlmCompletionOpts.useOpenAIResponsesApi to true when submitting a prompt. Some models incompatible with the Completions API will automatically use the Responses API.
Can I use multiple attachments in a message?
Yes, version 4.0 supports multiple attachments per message via the attachments attribute on Message objects. You can use attach() and detach() methods to manage attachments, unlike prior versions which only allowed one attachment per user message.