abyss-ai-sdk
v0.1.2
Published
Multi-provider AI utility with structured responses
Readme
abyss-ai
Multi-provider AI utility with structured responses and streaming. Supports Groq, OpenAI, and Anthropic with a unified API.
Install
npm install abyss-ai zodUsage
Plain text
import { ask } from "abyss-ai";
const result = await ask(
{ provider: "groq", apiKey: process.env.GROQ_API_KEY! },
{ prompt: "Explain black holes in one sentence." }
);
console.log(result.data); // stringStructured response
import { ask } from "abyss-ai";
import { z } from "zod";
const schema = z.object({
sentiment: z.enum(["positive", "negative", "neutral"]),
confidence: z.number().min(0).max(1),
summary: z.string(),
});
const result = await ask(
{ provider: "openai", apiKey: process.env.OPENAI_API_KEY! },
{
prompt: "Analyse: 'This product is amazing!'",
schema,
}
);
console.log(result.data.sentiment); // "positive"
console.log(result.data.confidence); // 0.95Streaming
import { stream } from "abyss-ai";
for await (const chunk of stream(
{ provider: "anthropic", apiKey: process.env.ANTHROPIC_API_KEY! },
{ prompt: "Write a short poem about the ocean." }
)) {
process.stdout.write(chunk);
}Providers
| Provider | Default Model |
|---|---|
| groq | llama-3.1-8b-instant |
| openai | gpt-4o-mini |
| anthropic | claude-sonnet-4-6 |
Override the model with the model field:
{ provider: "groq", apiKey: "...", model: "llama-3.3-70b-versatile" }API
ask(config, options)
| Option | Type | Description |
|---|---|---|
| prompt | string | The user message |
| system | string? | System prompt |
| schema | ZodTypeAny? | Zod schema for structured output |
| temperature | number? | 0–1, default 0.7 |
| maxTokens | number? | Default 1024 |
Returns { data, raw, provider, model }.
stream(config, options)
Same options as ask() minus schema. Returns AsyncIterable<string>.
License
MIT
