@reactor-cloud/ai
v0.3.0
Published
AI client for Reactor JS SDK - OpenAI-compatible chat completions and embeddings
Maintainers
Readme
@reactor-cloud/ai
AI client for Reactor. OpenAI-compatible chat completions (with streaming), embeddings, and model listing through the Reactor AI gateway.
Installation
npm install @reactor-cloud/ai @reactor-cloud/sharedOr use the unified client:
npm install @reactor-cloud/clientQuick Start
import { createClient } from '@reactor-cloud/client';
import { userMessage, getContent } from '@reactor-cloud/ai';
const reactor = createClient('https://reactor.cloud', { key: 'rk_pub_...' });
// Non-streaming completion
const { data } = await reactor.ai.chatCompletion({
model: 'gpt',
messages: [userMessage('Write a haiku about databases.')],
});
console.log(getContent(data!));
// Streaming completion
const { data: stream } = await reactor.ai.chatCompletionStream({
model: 'gpt',
messages: [userMessage('Stream a short story.')],
});
for await (const chunk of stream!) {
process.stdout.write(chunk.choices[0]?.delta.content ?? '');
}
// Embeddings
const { data: embeddings } = await reactor.ai.embed({
model: 'text-embedding-3-small',
input: 'hello world',
});License
MIT
