@hashbrownai/anthropic
v0.7.0
Published
Anthropic provider for Hashbrown AI
Readme
@hashbrownai/anthropic is the Node adapter for Anthropic. It maps an AG-UI run from Hashbrown's React or Angular packages to the Anthropic SDK and streams AG-UI events back. Your server keeps the API key.
Getting Started
npm install @hashbrownai/anthropic @anthropic-ai/sdk @ag-ui/core @ag-ui/encoder --saveDeploy an Express server with a /run endpoint to use Hashbrown with Anthropic.
import type { RunAgentInput } from '@ag-ui/core';
import { EventEncoder } from '@ag-ui/encoder';
import { HashbrownAnthropic } from '@hashbrownai/anthropic';
app.post('/run', async (req, res) => {
const abortController = new AbortController();
req.once('aborted', () => abortController.abort());
res.once('close', () => abortController.abort());
const stream = HashbrownAnthropic.stream.text({
apiKey: process.env.ANTHROPIC_API_KEY!,
model: process.env.ANTHROPIC_MODEL ?? 'claude-haiku-4-5-20251001',
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 Anthropic adapter.
Contributing
Hashbrown is a community-driven project. Read our contributing guidelines on how to get involved.
License
MIT © LiveLoveApp, LLC
