@namzu/openai
v1.5.0
Published
OpenAI API-key and ChatGPT subscription providers for @namzu/sdk, with streaming and tool use.
Readme
OpenAI API-key and ChatGPT subscription drivers for Namzu.
Install · Usage · Documentation
Implements the kernel's LLMProvider interface over the official OpenAI SDK.
The package has two explicit transports: OpenAIProvider speaks Chat
Completions with an API key, while CodexProvider speaks the account-routed
Responses backend with a ChatGPT subscription session. Installed only if you
use either one — the kernel has no preferred vendor and no driver is a
dependency of it.
Install
pnpm add @namzu/sdk @namzu/openai@namzu/sdk is a peer dependency. Install both.
Usage
OpenAI API key
import { ProviderRegistry } from '@namzu/sdk'
import { registerOpenAI } from '@namzu/openai'
// Once, at startup.
registerOpenAI()
const { provider } = ProviderRegistry.create({
type: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4o-mini', // default; overridable per call
})
for await (const chunk of provider.chatStream({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Hello' }],
})) {
if (chunk.delta.content) process.stdout.write(chunk.delta.content)
}chatStream is the only model entry point; a non-streaming call is that
stream collected. In practice the kernel's run loop calls it and hands you
events.
ChatGPT subscription
import { ProviderRegistry } from '@namzu/sdk'
import { registerCodex } from '@namzu/openai'
declare const accessToken: string
declare const accountId: string
registerCodex()
const { provider } = ProviderRegistry.create({
type: 'codex',
accessToken,
accountId,
model: 'gpt-5.6-luna',
})accessToken and accountId must come from a user-authorized ChatGPT session.
The driver does not discover, refresh or persist credentials; that ownership
belongs to the host. Namzu CLI can reuse a usable device session owned by the
Codex CLI, without copying it into Namzu's credential store, or create a
separate Namzu-owned device login when no external session is available.
Documentation
License
FSL-1.1-MIT, converting to MIT two years after each release.
