@galdor/provider-openai 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @galdor/provider-openai
|
|
2
|
+
|
|
3
|
+
The [OpenAI](https://platform.openai.com/docs) (Chat Completions API) provider
|
|
4
|
+
adapter for [galdor](https://github.com/YasserCR/galdor-bun). Implements the core
|
|
5
|
+
`Provider` interface, so it drops into any graph, agent, or council.
|
|
6
|
+
|
|
7
|
+
Because it speaks the Chat Completions wire format, it also targets
|
|
8
|
+
**OpenAI-compatible** endpoints (Groq, Together, MiniMax, Mistral, DeepSeek,
|
|
9
|
+
vLLM, Ollama, …) via `baseURL`. Covers generate + streaming, tool calling,
|
|
10
|
+
structured output, vision, reasoning effort, the typed error taxonomy with
|
|
11
|
+
`Retry-After`, cancellation, and a stream-safe header timeout (60 s default).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add @galdor/provider-openai # or: npm install @galdor/provider-openai
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { newOpenAI } from "@galdor/provider-openai";
|
|
23
|
+
import { userMessage, messageText } from "@galdor/core/schema";
|
|
24
|
+
|
|
25
|
+
const provider = newOpenAI({ apiKey: process.env.OPENAI_API_KEY! });
|
|
26
|
+
|
|
27
|
+
const res = await provider.generate({
|
|
28
|
+
model: "gpt-4o-mini",
|
|
29
|
+
messages: [userMessage("Explain MCP in one sentence.")],
|
|
30
|
+
});
|
|
31
|
+
console.log(messageText(res.message), res.usage);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Point it at an OpenAI-compatible backend with `baseURL`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const groq = newOpenAI({ apiKey: process.env.GROQ_API_KEY!, baseURL: "https://api.groq.com/openai/v1" });
|
|
38
|
+
const local = newOpenAI({ apiKey: "no-key", baseURL: "http://localhost:11434/v1" }); // Ollama
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
> Tip: [`@galdor/providerset`](https://www.npmjs.com/package/@galdor/providerset)
|
|
42
|
+
> resolves these aliases by name (`groq`, `ollama`, …) with the right preset
|
|
43
|
+
> `baseURL`.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galdor/provider-openai",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenAI (Chat Completions API) provider adapter for galdor-bun. Also targets OpenAI-compatible endpoints (Groq, Together, MiniMax, Mistral, DeepSeek, vLLM, Ollama, ...) via baseURL.",
|
|
6
6
|
"author": {
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"bun": ">=1.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@galdor/core": "0.3.
|
|
34
|
+
"@galdor/core": "0.3.1"
|
|
35
35
|
}
|
|
36
36
|
}
|