Integration · @namzu/openai
Namzu × OpenAI.API keys and ChatGPT subscription sessions.
Two drivers in one package: OpenAI API keys over Chat Completions, and ChatGPT subscription sessions over the Responses backend.
Install.
pnpm add @namzu/sdk @namzu/openai@namzu/sdk is a peer dependency, so install both. The SDK needs zod@^3 too.
Why pair the kernel with OpenAI.
The package has two explicit transports over the official OpenAI SDK. OpenAIProvider speaks Chat Completions with an API key; CodexProvider speaks the account-routed Responses backend with a ChatGPT subscription session. Install it only if you use either one.
- The API-key transport streams, calls tools, accepts user images and documents, and maps JSON-schema responses natively. Its tool-result wire is text-only, and the SDK's capability warning makes that degradation visible before the affected request.
- The subscription transport maps PNG, JPEG, WebP and GIF inputs and image tool results to Responses
input_imageparts, in order with the text. Documents and unresolved stored references are refused before transport. - For a subscription,
accessTokenandaccountIdmust come from a user-authorized ChatGPT session. The driver does not discover, refresh or persist credentials; the host owns that. The terminal app can reuse a usable device session owned by the Codex CLI, or create its own device login. baseURLpoints the API-key driver at another compatible endpoint such as Azure OpenAI. For a generic endpoint, use@namzu/http.
Example.
import { ProviderRegistry, runAgent } from '@namzu/sdk'
import { registerOpenAI } from '@namzu/openai'
registerOpenAI() // once, at startup
const model = 'gpt-4o-mini'
const { provider } = ProviderRegistry.create({
type: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
model,
})
const { output } = await runAgent({ provider, model, prompt: 'Plan tomorrow\'s release.' })
console.log(output)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',
})Configure.
API key (type: 'openai')
- apiKeystring
- Required.
- modelstring
- Default model; overridable per call.
- baseURLstring
- Override the base URL, for example for Azure OpenAI or an enterprise endpoint.
- organizationstring
- Organization ID.
- projectstring
- Project ID.
- timeoutnumber (ms)
- Request timeout.
- defaultHeadersRecord<string, string>
- Headers appended to every request.
- maxRetriesnumber
- Retries the vendor SDK makes by itself before an error reaches you. Unset leaves the SDK default (two). Set 0 when the host retries and shows its retries.
ChatGPT subscription (type: 'codex')
- accessTokenstring
- From a user-authorized ChatGPT session. Required.
- accountIdstring
- The session's account. Required.
- modelstring
- Default model; overridable per call.
- baseURLstring
- Defaults to the ChatGPT Codex backend.
- timeoutnumber (ms)
- Request timeout.
- defaultHeadersRecord<string, string>
- Headers appended to every request.
- maxRetriesnumber
- As above.
What the driver declares.
- StreamingYes
- Tool callsYes
- Image attachmentsYes
- Document attachmentsYes
- Native JSON-schema outputYes
- Images in tool resultsNot on the API-key transport
Ship OpenAI agents on a runtime you can own.
OpenAI owns the model. Namzu owns the runtime. The package is a thin adapter, not a wrapper, so you keep everything OpenAI ships and add the kernel concerns you do not get from the model API alone.