@kenkaiiii/gg-ai 3.6.4 → 4.0.0

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.
Files changed (2) hide show
  1. package/README.md +90 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @kenkaiiii/gg-ai
2
+
3
+ <p align="center">
4
+ <strong>Unified LLM streaming API. Four providers. One interface.</strong>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@kenkaiiii/gg-ai"><img src="https://img.shields.io/npm/v/@kenkaiiii/gg-ai?style=for-the-badge" alt="npm version"></a>
9
+ <a href="../../LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="MIT License"></a>
10
+ </p>
11
+
12
+ One function. Flat options. Switch providers by changing a string. No adapters, no plugins, no wrapper classes.
13
+
14
+ Part of the [GG Framework](../../README.md) monorepo.
15
+
16
+ ---
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm i @kenkaiiii/gg-ai
22
+ ```
23
+
24
+ ---
25
+
26
+ ## How it works
27
+
28
+ Call `stream()` with a provider, model, and messages. That's the entire API.
29
+
30
+ - **`for await`** gives you streaming events (`text_delta`, `thinking_delta`, `toolcall_done`, etc.)
31
+ - **`await`** gives you the final response (`message`, `stopReason`, `usage`)
32
+
33
+ Same function, same call. Dual-nature `StreamResult` — async iterable and thenable.
34
+
35
+ Tool parameters are Zod schemas. Converted to JSON Schema at the provider boundary automatically.
36
+
37
+ ---
38
+
39
+ ## Providers
40
+
41
+ | Provider | Models | Notes |
42
+ |---|---|---|
43
+ | `anthropic` | Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 | Extended thinking, prompt caching, server-side compaction |
44
+ | `openai` | GPT-4.1, o3, o4-mini | Supports OAuth (codex endpoint) and API keys |
45
+ | `glm` | GLM-5, GLM-4.7 | Z.AI platform, OpenAI-compatible |
46
+ | `moonshot` | Kimi K2.5 | Moonshot platform, OpenAI-compatible |
47
+
48
+ ---
49
+
50
+ ## Stream events
51
+
52
+ | Event | Description |
53
+ |---|---|
54
+ | `text_delta` | Incremental text output |
55
+ | `thinking_delta` | Extended thinking output (Anthropic) |
56
+ | `toolcall_delta` | Streaming tool call arguments |
57
+ | `toolcall_done` | Completed tool call with parsed args |
58
+ | `server_toolcall` | Server-side tool invocation |
59
+ | `server_toolresult` | Server-side tool result |
60
+ | `done` | Stream finished, includes stop reason |
61
+ | `error` | Error occurred |
62
+
63
+ ---
64
+
65
+ ## Options
66
+
67
+ | Option | Type | Description |
68
+ |---|---|---|
69
+ | `provider` | `"anthropic" \| "openai" \| "glm" \| "moonshot"` | Required |
70
+ | `model` | `string` | Required |
71
+ | `messages` | `Message[]` | Required |
72
+ | `tools` | `Tool[]` | Tool definitions with Zod schemas |
73
+ | `toolChoice` | `"auto" \| "none" \| "required" \| { name }` | Tool selection strategy |
74
+ | `serverTools` | `ServerToolDefinition[]` | Server-side tool definitions |
75
+ | `maxTokens` | `number` | Max output tokens |
76
+ | `temperature` | `number` | Sampling temperature |
77
+ | `topP` | `number` | Nucleus sampling |
78
+ | `stop` | `string[]` | Stop sequences |
79
+ | `thinking` | `"low" \| "medium" \| "high" \| "max"` | Extended thinking (Anthropic) |
80
+ | `apiKey` | `string` | Provider API key |
81
+ | `baseUrl` | `string` | Custom endpoint |
82
+ | `signal` | `AbortSignal` | Cancellation |
83
+ | `cacheRetention` | `"none" \| "short" \| "long"` | Prompt cache preference |
84
+ | `compaction` | `boolean` | Server-side compaction (Anthropic only) |
85
+
86
+ ---
87
+
88
+ ## License
89
+
90
+ MIT
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@kenkaiiii/gg-ai",
3
- "version": "3.6.4",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "description": "Unified LLM streaming API for Anthropic and OpenAI",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/kenkaiiii/gg-coder.git",
9
+ "url": "git+https://github.com/kenkaiiii/gg-framework.git",
10
10
  "directory": "packages/gg-ai"
11
11
  },
12
12
  "exports": {