@galdor/provider-openai
v0.3.1
Published
OpenAI (Chat Completions API) provider adapter for galdor-bun. Also targets OpenAI-compatible endpoints (Groq, Together, MiniMax, Mistral, DeepSeek, vLLM, Ollama, ...) via baseURL.
Readme
@galdor/provider-openai
The OpenAI (Chat Completions API) provider
adapter for galdor. Implements the core
Provider interface, so it drops into any graph, agent, or council.
Because it speaks the Chat Completions wire format, it also targets
OpenAI-compatible endpoints (Groq, Together, MiniMax, Mistral, DeepSeek,
vLLM, Ollama, …) via baseURL. Covers generate + streaming, tool calling,
structured output, vision, reasoning effort, the typed error taxonomy with
Retry-After, cancellation, and a stream-safe header timeout (60 s default).
Install
bun add @galdor/provider-openai # or: npm install @galdor/provider-openaiUsage
import { newOpenAI } from "@galdor/provider-openai";
import { userMessage, messageText } from "@galdor/core/schema";
const provider = newOpenAI({ apiKey: process.env.OPENAI_API_KEY! });
const res = await provider.generate({
model: "gpt-4o-mini",
messages: [userMessage("Explain MCP in one sentence.")],
});
console.log(messageText(res.message), res.usage);Point it at an OpenAI-compatible backend with baseURL:
const groq = newOpenAI({ apiKey: process.env.GROQ_API_KEY!, baseURL: "https://api.groq.com/openai/v1" });
const local = newOpenAI({ apiKey: "no-key", baseURL: "http://localhost:11434/v1" }); // OllamaTip:
@galdor/providersetresolves these aliases by name (groq,ollama, …) with the right presetbaseURL.
License
Apache-2.0
