feat(openai-chatgpt-auth)!: rename ChatGPT auth APIs
Add Node-only auth source helpers for SmartAI, OpenCode, and Codex credentials.
This commit is contained in:
@@ -107,29 +107,60 @@ console.log(result.text);
|
||||
|
||||
OpenAI `reasoningEffort` supports `'none'`, `'minimal'`, `'low'`, `'medium'`, `'high'`, and `'xhigh'`. Model IDs are accepted as strings, so new IDs like `'gpt-5.5'` can be used before upstream model unions are updated.
|
||||
|
||||
### OpenAI Max / ChatGPT Auth
|
||||
### OpenAI ChatGPT / Codex Auth
|
||||
|
||||
SmartAI can request ChatGPT subscription-backed Codex credentials with OpenAI's device-code flow. The returned credentials are passed to `getModel()` through `openAiMaxAuth`; SmartAI then routes OpenAI model calls through the ChatGPT Codex backend with the required account headers.
|
||||
SmartAI can request ChatGPT subscription-backed Codex credentials with OpenAI's device-code flow. The returned credentials are passed to `getModel()` through `openAiChatGptAuth`; SmartAI then routes OpenAI model calls through the ChatGPT Codex backend with the required account headers.
|
||||
|
||||
```typescript
|
||||
import {
|
||||
completeOpenAiMaxDeviceCodeLogin,
|
||||
completeOpenAiChatGptDeviceCodeLogin,
|
||||
getModel,
|
||||
requestOpenAiMaxDeviceCode,
|
||||
requestOpenAiChatGptDeviceCode,
|
||||
} from '@push.rocks/smartai';
|
||||
|
||||
const deviceCode = await requestOpenAiMaxDeviceCode();
|
||||
const deviceCode = await requestOpenAiChatGptDeviceCode();
|
||||
console.log(`Open ${deviceCode.verificationUrl} and enter ${deviceCode.userCode}`);
|
||||
|
||||
const openAiMaxAuth = await completeOpenAiMaxDeviceCodeLogin(deviceCode);
|
||||
const openAiChatGptAuth = await completeOpenAiChatGptDeviceCodeLogin(deviceCode);
|
||||
const model = getModel({
|
||||
provider: 'openai',
|
||||
model: 'gpt-5.5',
|
||||
openAiMaxAuth,
|
||||
openAiChatGptAuth,
|
||||
});
|
||||
```
|
||||
|
||||
Use `refreshOpenAiMaxTokenData(openAiMaxAuth)` before stored credentials expire, or after receiving an unauthorized response.
|
||||
Use `refreshOpenAiChatGptTokenData(openAiChatGptAuth)` before stored credentials expire, or after receiving an unauthorized response.
|
||||
|
||||
Node.js consumers can inspect and resolve local ChatGPT auth files through the Node-only subpath. This supports SmartAI's canonical auth file, OpenCode's `~/.local/share/opencode/auth.json`, and Codex's `~/.codex/auth.json` without exposing token values in inspection results.
|
||||
|
||||
```typescript
|
||||
import {
|
||||
inspectOpenAiChatGptAuthSources,
|
||||
resolveOpenAiChatGptAuth,
|
||||
} from '@push.rocks/smartai/openai-chatgpt-auth';
|
||||
|
||||
const sources = await inspectOpenAiChatGptAuthSources({
|
||||
sources: ['smartai', 'opencode', 'codex'],
|
||||
});
|
||||
|
||||
const resolved = await resolveOpenAiChatGptAuth({
|
||||
sources: ['smartai', 'opencode', 'codex'],
|
||||
refresh: 'ifNeeded',
|
||||
writeBack: {
|
||||
smartai: true,
|
||||
opencode: false,
|
||||
codex: false,
|
||||
},
|
||||
});
|
||||
|
||||
if (resolved) {
|
||||
const model = getModel({
|
||||
provider: 'openai',
|
||||
model: 'gpt-5.5',
|
||||
openAiChatGptAuth: resolved.tokenData,
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Re-exported AI SDK Functions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user