https://github.com/frontllm/frontllm-sdk
FrontLLM is your public gateway to LLMs. Request LLM directly from your front-end code. No backend needed.
https://github.com/frontllm/frontllm-sdk
ai gateway-api llm llm-framework llm-gateway openai
Last synced: 10 months ago
JSON representation
FrontLLM is your public gateway to LLMs. Request LLM directly from your front-end code. No backend needed.
- Host: GitHub
- URL: https://github.com/frontllm/frontllm-sdk
- Owner: frontllm
- License: mit
- Created: 2025-05-18T21:46:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-30T21:22:53.000Z (about 1 year ago)
- Last Synced: 2025-08-09T20:18:47.398Z (11 months ago)
- Topics: ai, gateway-api, llm, llm-framework, llm-gateway, openai
- Language: TypeScript
- Homepage: https://frontllm.com/
- Size: 102 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

# FrontLLM
[](https://actions-badge.atrox.dev/frontllm/frontllm-sdk/goto?ref=main) [](/LICENSE) [](https://npmjs.org/package/frontllm)
FrontLLM is your public gateway to LLMs. Request LLM directly from your front-end code. No backend needed.
📝 Check the [documentation](https://frontllm.com/docs/introduction) for more details.
### 👀 Demos
* [Explain This](https://frontllm.com/docs/demos/explain-this)
* [Streaming](https://frontllm.com/docs/demos/streaming)
* [Translator](https://frontllm.com/docs/demos/translator)
## 🚀 Installation
### NPM
To use FrontLLM in your project, you can install it via npm:
```bash
npm install frontllm
```
Now you can import the library and create an instance of the gateway with your specific gateway ID:
```js
import { frontLLM } from 'frontllm';
const gateway = frontLLM('');
```
### CDN
To use FrontLLM via CDN, you can include the following script tag in your HTML file:
```html
```
This will expose the `frontLLM` function globally, which you can use to create an instance of the gateway:
```html
const gateway = frontLLM('<gateway_id>');
// ...
```
## 🎬 Usage
Chat Completion:
```js
// Short syntax - requires the default model configured in the gateway
const response = await gateway.complete('Hello world!');
// Full syntax
const response = await gateway.complete({
model: 'gpt-4',
messages: [
{ role: 'user', content: 'Hello world!' }
],
temperature: 0.7
});
// Output the generated response text to the console.
console.log(response.choices[0].message.content);
```
Chat Completion with Streaming:
```js
// Short syntax - requires the default model configured in the gateway
const response = await gateway.completeStreaming('Where is Europe?');
// Full syntax
const response = await gateway.completeStreaming({
model: 'gpt-4',
messages: [
{ role: 'user', content: 'Where is Europe?' }
],
temperature: 0.7
});
// Output the generated response text to the console.
for (;;) {
const { finished, chunks } = await response.read();
for (const chunk of chunks) {
console.log(chunk.choices[0].delta.content);
}
if (finished) {
break;
}
}
```
## 💡 License
This project is released under the MIT license.