@xberg-io/liter-llm-wasm 0.0.1 → 1.9.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +274 -2
- package/liter_llm_wasm.d.ts +2859 -0
- package/liter_llm_wasm.js +12416 -0
- package/liter_llm_wasm_bg.wasm +0 -0
- package/package.json +28 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 Kreuzberg, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,275 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/xberg-io/assets@v1/banner/readme-banner-dark.svg">
|
|
4
|
+
<img alt="Xberg" width="420" src="https://cdn.jsdelivr.net/gh/xberg-io/assets@v1/banner/readme-banner-light.svg">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
# WebAssembly
|
|
9
|
+
|
|
10
|
+
<div align="center" style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0">
|
|
11
|
+
<!-- Built with -->
|
|
12
|
+
<a href="https://github.com/xberg-io/alef">
|
|
13
|
+
<img src="https://img.shields.io/badge/Bindings-alef%20%D7%90-007ec6" alt="Bindings" />
|
|
14
|
+
</a>
|
|
15
|
+
<!-- Language Bindings -->
|
|
16
|
+
<a href="https://crates.io/crates/liter-llm">
|
|
17
|
+
<img src="https://img.shields.io/crates/v/liter-llm?label=Rust&color=007ec6" alt="Rust" />
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://pypi.org/project/liter-llm/">
|
|
20
|
+
<img src="https://img.shields.io/pypi/v/liter-llm?label=Python&color=007ec6" alt="Python" />
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://www.npmjs.com/package/@xberg-io/liter-llm">
|
|
23
|
+
<img src="https://img.shields.io/npm/v/@xberg-io/liter-llm?label=Node.js&color=007ec6" alt="Node.js" />
|
|
24
|
+
</a>
|
|
25
|
+
<a href="https://www.npmjs.com/package/@xberg-io/liter-llm-wasm">
|
|
26
|
+
<img src="https://img.shields.io/npm/v/@xberg-io/liter-llm-wasm?label=WASM&color=007ec6" alt="WASM" />
|
|
27
|
+
</a>
|
|
28
|
+
<a href="https://central.sonatype.com/artifact/io.xberg.literllm/liter-llm">
|
|
29
|
+
<img src="https://img.shields.io/maven-central/v/io.xberg.literllm/liter-llm?label=Java&color=007ec6" alt="Java" />
|
|
30
|
+
</a>
|
|
31
|
+
<a href="https://github.com/xberg-io/liter-llm/tree/main/packages/go">
|
|
32
|
+
<img src="https://img.shields.io/github/v/tag/xberg-io/liter-llm?label=Go&color=007ec6" alt="Go" />
|
|
33
|
+
</a>
|
|
34
|
+
<a href="https://www.nuget.org/packages/LiterLlm">
|
|
35
|
+
<img src="https://img.shields.io/nuget/v/LiterLlm?label=C%23&color=007ec6" alt="C#" />
|
|
36
|
+
</a>
|
|
37
|
+
<a href="https://packagist.org/packages/xberg-io/liter-llm">
|
|
38
|
+
<img src="https://img.shields.io/packagist/v/xberg-io/liter-llm?label=PHP&color=007ec6" alt="PHP" />
|
|
39
|
+
</a>
|
|
40
|
+
<a href="https://rubygems.org/gems/liter_llm">
|
|
41
|
+
<img src="https://img.shields.io/gem/v/liter_llm?label=Ruby&color=007ec6" alt="Ruby" />
|
|
42
|
+
</a>
|
|
43
|
+
<a href="https://hex.pm/packages/liter_llm">
|
|
44
|
+
<img src="https://img.shields.io/hexpm/v/liter_llm?label=Elixir&color=007ec6" alt="Elixir" />
|
|
45
|
+
</a>
|
|
46
|
+
<a href="https://github.com/xberg-io/liter-llm/pkgs/container/liter-llm">
|
|
47
|
+
<img src="https://img.shields.io/badge/Docker-007ec6?logo=docker&logoColor=white" alt="Docker" />
|
|
48
|
+
</a>
|
|
49
|
+
<a href="https://github.com/xberg-io/homebrew-tap/blob/main/Formula/liter-llm.rb">
|
|
50
|
+
<img src="https://img.shields.io/badge/Homebrew-007ec6?logo=homebrew&logoColor=white" alt="Homebrew" />
|
|
51
|
+
</a>
|
|
52
|
+
<a href="https://github.com/xberg-io/liter-llm/tree/main/crates/liter-llm-ffi">
|
|
53
|
+
<img src="https://img.shields.io/badge/C-FFI-007ec6" alt="C FFI" />
|
|
54
|
+
</a>
|
|
55
|
+
|
|
56
|
+
<!-- Project Info -->
|
|
57
|
+
<a href="https://github.com/xberg-io/liter-llm/blob/main/LICENSE">
|
|
58
|
+
<img src="https://img.shields.io/badge/License-MIT-007ec6" alt="License" />
|
|
59
|
+
</a>
|
|
60
|
+
<a href="https://docs.liter-llm.xberg.io">
|
|
61
|
+
<img src="https://img.shields.io/badge/Docs-liter--llm-007ec6" alt="Docs" />
|
|
62
|
+
</a>
|
|
63
|
+
</div>
|
|
64
|
+
<div align="center" style="margin: 24px 0 0">
|
|
65
|
+
<a href="https://xberg.io">
|
|
66
|
+
<img
|
|
67
|
+
alt="xberg.io"
|
|
68
|
+
src="https://github.com/user-attachments/assets/1b6c6ad7-3b6d-4171-b1c9-f2026cc9deb8"
|
|
69
|
+
/>
|
|
70
|
+
</a>
|
|
71
|
+
</div>
|
|
72
|
+
<div align="center" style="display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 28px 0 24px">
|
|
73
|
+
<a href="https://discord.gg/xt9WY3GnKR">
|
|
74
|
+
<img
|
|
75
|
+
height="22"
|
|
76
|
+
src="https://img.shields.io/badge/Discord-Chat-007ec6?logo=discord&logoColor=white"
|
|
77
|
+
alt="Join Discord"
|
|
78
|
+
/>
|
|
79
|
+
</a>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
Universal LLM API client for browsers and WebAssembly runtimes. Access 143 LLM providers with portable deployment across browsers, Deno, and Cloudflare Workers.
|
|
83
|
+
|
|
84
|
+
## What This Package Provides
|
|
85
|
+
|
|
86
|
+
- **One provider surface** — chat, streaming, embeddings, images, audio, search, OCR, tools, and structured output across the provider registry.
|
|
87
|
+
- **Provider/model routing** — call models with the `provider/model` convention and keep provider-specific request code out of application paths.
|
|
88
|
+
- **Production controls** — retries, fallback, rate limits, cache layers, budgets, health checks, OpenTelemetry spans, and redacted secrets.
|
|
89
|
+
- **Same core as every binding** — Rust, Python, Node.js, Go, Java, PHP, Ruby, .NET, Elixir, WASM, Kotlin Android, Swift, Dart, Zig, and C FFI use the same Rust implementation.
|
|
90
|
+
- **WASM package** — browser and edge-compatible client for provider calls from WebAssembly runtimes.
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
### Package Installation
|
|
95
|
+
|
|
96
|
+
Install via one of the supported package managers:
|
|
97
|
+
|
|
98
|
+
**npm:**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm install @xberg-io/liter-llm-wasm
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**pnpm:**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pnpm add @xberg-io/liter-llm-wasm
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**yarn:**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
yarn add @xberg-io/liter-llm-wasm
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### System Requirements
|
|
117
|
+
|
|
118
|
+
- Modern browser with WebAssembly support, or Deno 1.0+, or Cloudflare Workers
|
|
119
|
+
- API keys via environment variables or runtime configuration
|
|
120
|
+
|
|
121
|
+
## Quick Start
|
|
122
|
+
|
|
123
|
+
### Basic Chat
|
|
124
|
+
|
|
125
|
+
Send a message to any provider using the `provider/model` prefix:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import init, { createClient, WasmChatCompletionRequest } from "@xberg-io/liter-llm-wasm";
|
|
129
|
+
|
|
130
|
+
await init();
|
|
131
|
+
|
|
132
|
+
const client = createClient(process.env.OPENAI_API_KEY!);
|
|
133
|
+
|
|
134
|
+
const request = WasmChatCompletionRequest.default();
|
|
135
|
+
request.model = "openai/gpt-4o";
|
|
136
|
+
request.messages = [{ role: "user", content: "Hello!" }];
|
|
137
|
+
|
|
138
|
+
const response = await client.chat(request);
|
|
139
|
+
console.log(response.choices[0].message.content);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Common Use Cases
|
|
143
|
+
|
|
144
|
+
#### Streaming Responses
|
|
145
|
+
|
|
146
|
+
Stream tokens in real time:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import init, { createClient, WasmChatCompletionRequest } from "@xberg-io/liter-llm-wasm";
|
|
150
|
+
|
|
151
|
+
await init();
|
|
152
|
+
|
|
153
|
+
const client = createClient(process.env.OPENAI_API_KEY!);
|
|
154
|
+
|
|
155
|
+
const request = WasmChatCompletionRequest.default();
|
|
156
|
+
request.model = "openai/gpt-4o";
|
|
157
|
+
request.messages = [{ role: "user", content: "Tell me a story" }];
|
|
158
|
+
request.stream = true;
|
|
159
|
+
|
|
160
|
+
const stream = await client.chatStream(request);
|
|
161
|
+
while (true) {
|
|
162
|
+
const chunk = await stream.next();
|
|
163
|
+
if (chunk === null) {
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
|
|
167
|
+
}
|
|
168
|
+
console.log();
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Next Steps
|
|
172
|
+
|
|
173
|
+
- **[Provider Registry](https://github.com/xberg-io/liter-llm/blob/main/schemas/providers.json)** - Full list of supported providers
|
|
174
|
+
- **[GitHub Repository](https://github.com/xberg-io/liter-llm)** - Source, issues, and discussions
|
|
175
|
+
|
|
176
|
+
## Features
|
|
177
|
+
|
|
178
|
+
### Supported Providers (143)
|
|
179
|
+
|
|
180
|
+
Route to any provider using the `provider/model` prefix convention:
|
|
181
|
+
|
|
182
|
+
| Provider | Example Model |
|
|
183
|
+
| ------------------ | ------------------------------------------------------------- |
|
|
184
|
+
| **OpenAI** | `openai/gpt-4o`, `openai/gpt-4o-mini` |
|
|
185
|
+
| **Anthropic** | `anthropic/claude-3-5-sonnet-20241022` |
|
|
186
|
+
| **Groq** | `groq/llama-3.1-70b-versatile` |
|
|
187
|
+
| **Mistral** | `mistral/mistral-large-latest` |
|
|
188
|
+
| **Cohere** | `cohere/command-r-plus` |
|
|
189
|
+
| **Together AI** | `together/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo` |
|
|
190
|
+
| **Fireworks** | `fireworks/accounts/fireworks/models/llama-v3p1-70b-instruct` |
|
|
191
|
+
| **Google Vertex** | `vertexai/gemini-1.5-pro` |
|
|
192
|
+
| **Amazon Bedrock** | `bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0` |
|
|
193
|
+
|
|
194
|
+
**[Complete Provider List](https://github.com/xberg-io/liter-llm/blob/main/schemas/providers.json)**
|
|
195
|
+
|
|
196
|
+
### Key Capabilities
|
|
197
|
+
|
|
198
|
+
- **Provider Routing** -- Single client for 143 LLM providers via `provider/model` prefix
|
|
199
|
+
- **Local LLMs** — Connect to locally-hosted models via Ollama, LM Studio, vLLM, llama.cpp, and other local inference servers
|
|
200
|
+
- **Unified API** -- Consistent `chat`, `chat_stream`, `embeddings`, `list_models` interface
|
|
201
|
+
- **Streaming** -- Real-time token streaming via `chat_stream`
|
|
202
|
+
- **Tool Calling** -- Function calling and tool use across all supporting providers
|
|
203
|
+
- **Type Safe** -- Schema-driven types compiled from JSON schemas
|
|
204
|
+
- **Secure** -- API keys never logged or serialized, managed via environment variables
|
|
205
|
+
- **Observability** -- Built-in [OpenTelemetry](https://opentelemetry.io/docs/specs/semconv/gen-ai/) with GenAI semantic conventions
|
|
206
|
+
- **Error Handling** -- Structured errors with provider context and retry hints
|
|
207
|
+
|
|
208
|
+
### Performance
|
|
209
|
+
|
|
210
|
+
Built on a compiled Rust core for speed and safety:
|
|
211
|
+
|
|
212
|
+
- **Provider resolution** at client construction -- zero per-request overhead
|
|
213
|
+
- **Configurable timeouts** and connection pooling
|
|
214
|
+
- **Zero-copy streaming** with SSE and AWS EventStream support
|
|
215
|
+
- **API keys** wrapped in secure memory, zeroed on drop
|
|
216
|
+
|
|
217
|
+
## Provider Routing
|
|
218
|
+
|
|
219
|
+
Route to 143 providers using the `provider/model` prefix convention:
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
openai/gpt-4o
|
|
223
|
+
anthropic/claude-3-5-sonnet-20241022
|
|
224
|
+
groq/llama-3.1-70b-versatile
|
|
225
|
+
mistral/mistral-large-latest
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
See the [provider registry](https://github.com/xberg-io/liter-llm/blob/main/schemas/providers.json) for the full list.
|
|
229
|
+
|
|
230
|
+
## Proxy, MCP Server & Plugin
|
|
231
|
+
|
|
232
|
+
<details>
|
|
233
|
+
<summary><strong>Run the OpenAI-compatible proxy or the MCP server</strong></summary>
|
|
234
|
+
|
|
235
|
+
Beyond the SDK, the `liter-llm` CLI ships an OpenAI-compatible proxy and a Model Context Protocol (MCP) server:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
brew install xberg-io/tap/liter-llm # or: cargo install liter-llm-cli
|
|
239
|
+
liter-llm api --config liter-llm-proxy.toml # OpenAI-compatible proxy
|
|
240
|
+
liter-llm mcp --transport stdio # MCP tool server
|
|
241
|
+
|
|
242
|
+
# or run the proxy without installing:
|
|
243
|
+
docker run -p 4000:4000 -e LITER_LLM_MASTER_KEY=sk-your-key ghcr.io/xberg-io/liter-llm
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
To use the MCP server inside a coding agent, install the **liter-llm plugin** from the [`xberg-io/plugins`](https://github.com/xberg-io/plugins) marketplace — it auto-registers the server. See the [MCP server](https://docs.liter-llm.xberg.io/server/mcp-server/) and [proxy server](https://docs.liter-llm.xberg.io/server/proxy-server/) guides for configuration, CLI usage, and agent integration.
|
|
247
|
+
|
|
248
|
+
</details>
|
|
249
|
+
|
|
250
|
+
## Documentation
|
|
251
|
+
|
|
252
|
+
- **[Documentation](https://docs.liter-llm.xberg.io)** -- Full docs and API reference
|
|
253
|
+
- **[GitHub Repository](https://github.com/xberg-io/liter-llm)** -- Source, issues, and discussions
|
|
254
|
+
- **[Provider Registry](https://github.com/xberg-io/liter-llm/blob/main/schemas/providers.json)** -- 143 supported providers
|
|
255
|
+
|
|
256
|
+
## Part of Xberg.io
|
|
257
|
+
|
|
258
|
+
- [Xberg](https://github.com/xberg-io/xberg) — document intelligence: text, tables, metadata from 91+ formats with optional OCR.
|
|
259
|
+
- [Xberg Enterprise](https://github.com/xberg-io/xberg-enterprise) — managed extraction API with SDKs, dashboards, and observability.
|
|
260
|
+
- [crawlberg](https://github.com/xberg-io/crawlberg) — web crawling and scraping with HTML→Markdown and headless-Chrome fallback.
|
|
261
|
+
- [html-to-markdown](https://github.com/xberg-io/html-to-markdown) — fast, lossless HTML→Markdown engine.
|
|
262
|
+
- [liter-llm](https://github.com/xberg-io/liter-llm) — universal LLM API client with native bindings for 14 languages and 143 providers.
|
|
263
|
+
- [tree-sitter-language-pack](https://github.com/xberg-io/tree-sitter-language-pack) — tree-sitter grammars and code-intelligence primitives.
|
|
264
|
+
- [alef](https://github.com/xberg-io/alef) — the polyglot binding generator that produces every per-language binding across the 5 polyglot repos.
|
|
265
|
+
- [Discord](https://discord.gg/xt9WY3GnKR) — community, roadmap, announcements.
|
|
266
|
+
|
|
267
|
+
## Contributing
|
|
268
|
+
|
|
269
|
+
Contributions are welcome! See [CONTRIBUTING.md](https://github.com/xberg-io/liter-llm/blob/main/CONTRIBUTING.md) for guidelines.
|
|
270
|
+
|
|
271
|
+
Join our [Discord community](https://discord.gg/xt9WY3GnKR) for questions and discussion.
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
MIT -- see [LICENSE](https://github.com/xberg-io/liter-llm/blob/main/LICENSE) for details.
|