@hashbrownai/openai
Version:
OpenAI provider for Hashbrown AI
60 lines (40 loc) • 1.84 kB
Markdown
<h1 align="center">Hashbrown - Build Generative User Interfaces</h1>
<p align="center">
<img src="https://hashbrown.dev/image/logo/brand-mark.svg" alt="Hashbrown Logo" width="144px" height="136px"/>
<br>
<em>Hashbrown is an open-source framework for building user interfaces
<br />that converse with users, dynamically reorganize, and even code themselves.</em>
<br>
</p>
<p align="center">
<a href="https://hashbrown.dev/"><strong>hashbrown.dev</strong></a>
<br>
</p>
```sh
npm install @hashbrownai/openai --save
```
Deploy an express server with a single /chat endpoint to use Hashbrown with OpenAI.
```ts
import { HashbrownOpenAI } from '@hashbrownai/openai';
app.post('/chat', async (req, res) => {
const stream = HashbrownOpenAI.stream.text({
apiKey: process.env.OPENAI_API_KEY!,
request: req.body, // must be Chat.Api.CompletionCreateParams
});
res.header('Content-Type', 'application/octet-stream');
for await (const chunk of stream) {
res.write(chunk); // Pipe each encoded frame as it arrives
}
res.end();
});
```
[](https://hashbrown.dev/docs/react/platform/openai).
hashbrown is a community-driven project. Read our [contributing guidelines](https://github.com/liveloveapp/hashbrown?tab=contributing-ov-file) on how to get involved.
Want to learn how to build web apps with AI? [Learn more about our workshops](https://hashbrown.dev/workshops).
LiveLoveApp provides hands-on engagement with our AI engineers for architecture reviews, custom integrations, proof-of-concept builds, performance tuning, and expert guidance on best practices. [Learn more about LiveLoveApp](https://liveloveapp.com).
MIT © [LiveLoveApp, LLC](https://liveloveapp.com)