@hashbrownai/openai
v0.7.0
Published
OpenAI provider for Hashbrown AI
Readme
@hashbrownai/openai is the Node adapter for OpenAI. It maps an AG-UI run from Hashbrown's React or Angular packages to the OpenAI SDK and streams AG-UI events back. Your server keeps the API key.
Getting Started
npm install @hashbrownai/openai openai @ag-ui/core @ag-ui/encoder --saveDeploy an Express server with a /run endpoint to use Hashbrown with OpenAI.
import type { RunAgentInput } from '@ag-ui/core';
import { EventEncoder } from '@ag-ui/encoder';
import { HashbrownOpenAI } from '@hashbrownai/openai';
app.post('/run', async (req, res) => {
const abortController = new AbortController();
req.once('aborted', () => abortController.abort());
res.once('close', () => abortController.abort());
const stream = HashbrownOpenAI.stream.text({
apiKey: process.env.OPENAI_API_KEY!,
model: process.env.OPENAI_MODEL ?? 'gpt-5-nano',
input: req.body as RunAgentInput,
signal: abortController.signal,
});
const encoder = new EventEncoder();
res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
res.header('Content-Type', encoder.getContentType());
res.header('Connection', 'keep-alive');
res.flushHeaders();
for await (const event of stream) {
res.write(encoder.encodeSSE(event));
}
if (!res.writableEnded) {
res.end();
}
});Docs
Read the docs for the Hashbrown OpenAI adapter.
Contributing
Hashbrown is a community-driven project. Read our contributing guidelines on how to get involved.
License
MIT © LiveLoveApp, LLC
