@strand-js/openai 0.1.0 → 0.1.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 +53 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @strand-js/openai
|
|
2
|
+
|
|
3
|
+
OpenAI provider adapter for [Strand](https://github.com/strand-js/strand) — AI state management for React.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @strand-js/openai
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Express / Fastify / Hono
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createStrandHandler } from '@strand-js/openai'
|
|
17
|
+
|
|
18
|
+
app.post('/api/strand', createStrandHandler({
|
|
19
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
20
|
+
model: 'gpt-4o',
|
|
21
|
+
system: 'You are a helpful assistant.',
|
|
22
|
+
}))
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Next.js App Router
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// app/api/strand/route.ts
|
|
29
|
+
import { createStrandRoute } from '@strand-js/openai'
|
|
30
|
+
|
|
31
|
+
export const POST = createStrandRoute({
|
|
32
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
33
|
+
model: 'gpt-4o',
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Switching from Anthropic
|
|
38
|
+
|
|
39
|
+
Only the server changes — the React hooks are identical:
|
|
40
|
+
|
|
41
|
+
```diff
|
|
42
|
+
- import { createStrandHandler } from '@strand-js/anthropic'
|
|
43
|
+
+ import { createStrandHandler } from '@strand-js/openai'
|
|
44
|
+
|
|
45
|
+
createStrandHandler({
|
|
46
|
+
- apiKey: process.env.ANTHROPIC_API_KEY,
|
|
47
|
+
- model: 'claude-sonnet-4-6',
|
|
48
|
+
+ apiKey: process.env.OPENAI_API_KEY,
|
|
49
|
+
+ model: 'gpt-4o',
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
[Full documentation →](https://github.com/strand-js/strand)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strand-js/openai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OpenAI provider adapter for Strand",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"openai": "^4.77.0",
|
|
20
|
-
"@strand-js/core": "0.1.
|
|
20
|
+
"@strand-js/core": "0.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/express": "^5.0.0",
|