# polyfire-js

> 🔥 polyfire

Latest version **0.2.60** (published 2024-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install polyfire-js
pnpm add polyfire-js
yarn add polyfire-js
bun add polyfire-js
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.60 |
| Published | 2024-07-19 |
| First published | 2023-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 296.5 KB |
| Known vulnerabilities | 0 (+25 in 2 direct dependencies) |
| Install scripts | no |
| Author | Lancelot Owczarczak |
| Maintainers | kevin_btc, lowczarc, victorforissier |

## Links

- npm: https://www.npmjs.com/package/polyfire-js
- npm.io page: https://npm.io/package/polyfire-js

## Dependencies (14)

- [ws](https://npm.io/package/ws.md) ^8.13.0
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [axios](https://npm.io/package/axios.md) ^0.27.2
- [fp-ts](https://npm.io/package/fp-ts.md) ^2.16.0
- [react](https://npm.io/package/react.md) ^18.2.0
- [buffer](https://npm.io/package/buffer.md) ^6.0.3
- [process](https://npm.io/package/process.md) ^0.11.10
- [async-mutex](https://npm.io/package/async-mutex.md) ^0.4.0
- [js-tiktoken](https://npm.io/package/js-tiktoken.md) ^1.0.7
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) ^5.0.0
- [polyfact-io-ts](https://npm.io/package/polyfact-io-ts.md) ^2.2.20
- [lodash.debounce](https://npm.io/package/lodash.debounce.md) ^4.0.8
- [readable-stream](https://npm.io/package/readable-stream.md) ^4.4.2
- [@supabase/supabase-js](https://npm.io/package/@supabase/supabase-js.md) ^2.31.0

## Recent versions

- 0.2.60 (latest) — 2024-07-19
- 0.2.59 — 2024-04-30
- 0.2.58 — 2024-03-08
- 0.2.57 — 2024-02-23
- 0.2.56 — 2024-02-23
- 0.2.55 — 2024-02-23
- 0.2.54 — 2024-02-23
- 0.2.53 — 2024-02-19
- 0.2.52 — 2024-02-15
- 0.2.51 — 2024-02-15
- 0.2.50 — 2024-02-05
- 0.2.49 — 2024-01-29
- 0.2.48 — 2024-01-24
- 0.2.47 — 2024-01-23
- 0.2.46 — 2024-01-23
- … 44 more at https://npm.io/package/polyfire-js/versions

## README

<h1 align="center">🔥 polyfire</h1>

<h4 align="center">
    <a href="https://docs.polyfire.com">Documentation</a> |
    <a href="https://www.polyfire.com/discord">Discord</a> |  <a href="https://beta.polyfire.com">Dashboard</a>
</h4>

<p align="center">⚡ An all-in-one managed backend for AI apps. Build AI apps from the frontend, very fast. 🪶</p>

Why use Polyfire?

-   Just code from the frontend, no backend needed
-   If you already have backend, less code to write
-   Most backend services you'd need in a couple lines of code

We **manage your AI backend** so you don't have to.

![Demo Gif](https://files.readme.io/7442014-demo.gif)

## 🧰 Examples

We have several examples in our [documentation](https://docs.polyfire.com/). But here are two simple ones to get you started

### React

```js
import { useState, useEffect } from "react";
import { createRoot } from "react-dom/client";
import { TextGenerated, Login } from "polyfire-js/components";

function App() {
    return (
        <Login>
            <h2>Here's a little auto-generated haiku for you:</h2>
            <TextGenerated prompt="Generate a hello world haiku" />
        </Login>
    );
}

document.body.innerHTML = '<div id="app"></div>';
const root = createRoot(document.getElementById("app"));
root.render(
    <PolyfireProvider project="your_project_id">
        <App />
    </PolyfireProvider>,
);
```

> Don't forget to change the **your_project_id** by your project ID you will have got on https://beta.polyfire.com

### Vanilla JS

```html
<script src="https://github.com/polyfire-ai/polyfire-js/releases/download/0.2.7/polyfire-min-0.2.7.js"></script>
<script>
    (async () => {
        const polyfire = window.PolyfireClientBuilder({ project: "your_project_id" });

        const isAuthenticated = await polyfire.auth.init();
        if (!isAuthenticated) {
            await polyfire.auth.login("github");
        }

        const helloWorld = await polyfire.models.generate("Write me a hello world haiku");
        console.log(helloWorld);
    })();
</script>
```

> Don't forget to change the **your_project_id** by your project ID you will have got on https://beta.polyfire.com

## 🆕 Getting Started

To get an overview of Polyfire follow this **[Basic Usage](https://docs.polyfire.com/docs/basic-usage)** tutorial.

## ✨ Starter Guides

We also made a couple of tutorials you can use to get started with Polyfire:

-   **[How to make a clone of ChatGPT](https://docs.polyfire.com/docs/chatgpt-clone)**
-   **[New Project & Rate Limits](https://docs.polyfire.com/docs/new-project-rate-limit)**
-   **[Adding stripe subscriptions](https://docs.polyfire.com/docs/react-stripe-subscriptions)**
-   **[Call Polyfire from React](https://docs.polyfire.com/docs/usepolyfire)**: The usePolyfire hooks lets you use Polyfire and handle authentification without having to deploy any backend
-   **[Call Polyfire from other browser environments](https://docs.polyfire.com/docs/javascript)**: The Polyfire Client Object allows you to use Polyfire and handle authentification without having to deploy any backend in any environment

## 📚 Useful References

-   **[Generate Simple Text](https://docs.polyfire.com/reference/generate)**: Answer to simple requests as text
-   **[Create Chatbots](https://docs.polyfire.com/reference/chats)**: Easily create chatbots
-   **[Transcribe](https://docs.polyfire.com/reference/transcribe)**: Transcribe audio files to text
-   **[Memory](https://docs.polyfire.com/reference/embeddings)**: Easily create a long-term memory and simplify the use of large amounts of information
-   **[GenerateImage](https://docs.polyfire.com/reference/generate-image)**: Generate images with Dall-E

## 🔗 Links

-   Website: [polyfire.com](https://www.polyfire.com)
-   Documentation: [docs.polyfire.com](https://docs.polyfire.com)
-   Dashboard: [beta.polyfire.com](https://beta.polyfire.com)
-   Discord: [polyfire.com/discord](https://www.polyfire.com/discord)
-   Javascript SDK: [github.com/polyfire-ai/polyfire-js](https://www.github.com/polyfire-ai/polyfire-js)
-   Open Source API (your managed backend!): [github.com/polyfire-ai/polyfire-api](https://github.com/polyfire-ai/polyfire-api)

We're open source! Make a good PR to the JS SDK or the API and we'll merge it.

---
_Source: https://npm.io/package/polyfire-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
