@openrouter/ai-sdk-provider 0.4.0 → 0.4.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 +63 -24
- package/package.json +8 -9
- /package/{internal/dist → dist/internal}/index.d.mts +0 -0
- /package/{internal/dist → dist/internal}/index.d.ts +0 -0
- /package/{internal/dist → dist/internal}/index.js +0 -0
- /package/{internal/dist → dist/internal}/index.js.map +0 -0
- /package/{internal/dist → dist/internal}/index.mjs +0 -0
- /package/{internal/dist → dist/internal}/index.mjs.map +0 -0
package/README.md
CHANGED
|
@@ -44,27 +44,66 @@ You can find the latest list of tool-supported models supported by OpenRouter [h
|
|
|
44
44
|
|
|
45
45
|
## Passing Extra Body to OpenRouter
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
There are 3 ways to pass extra body to OpenRouter:
|
|
48
|
+
|
|
49
|
+
1. Via the `providerOptions.openrouter` property:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
|
|
53
|
+
import { streamText } from 'ai';
|
|
54
|
+
|
|
55
|
+
const openrouter = createOpenRouter({ apiKey: 'your-api-key' });
|
|
56
|
+
const model = openrouter('anthropic/claude-3.7-sonnet:thinking');
|
|
57
|
+
await streamText({
|
|
58
|
+
model,
|
|
59
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
60
|
+
providerOptions: {
|
|
61
|
+
openrouter: {
|
|
62
|
+
reasoning: {
|
|
63
|
+
max_tokens: 10,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
2. Via the `extraBody` property in the model settings:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
|
|
74
|
+
import { streamText } from 'ai';
|
|
75
|
+
|
|
76
|
+
const openrouter = createOpenRouter({ apiKey: 'your-api-key' });
|
|
77
|
+
const model = openrouter('anthropic/claude-3.7-sonnet:thinking', {
|
|
78
|
+
extraBody: {
|
|
79
|
+
reasoning: {
|
|
80
|
+
max_tokens: 10,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
await streamText({
|
|
85
|
+
model,
|
|
86
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
3. Via the `extraBody` property in the model factory.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
|
|
94
|
+
import { streamText } from 'ai';
|
|
95
|
+
|
|
96
|
+
const openrouter = createOpenRouter({
|
|
97
|
+
apiKey: 'your-api-key',
|
|
98
|
+
extraBody: {
|
|
99
|
+
reasoning: {
|
|
100
|
+
max_tokens: 10,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const model = openrouter('anthropic/claude-3.7-sonnet:thinking');
|
|
105
|
+
await streamText({
|
|
106
|
+
model,
|
|
107
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
108
|
+
});
|
|
109
|
+
```
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/ai-sdk-provider",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist/**/*"
|
|
11
|
-
"internal/dist/**/*"
|
|
10
|
+
"dist/**/*"
|
|
12
11
|
],
|
|
13
12
|
"exports": {
|
|
14
13
|
"./package.json": "./package.json",
|
|
@@ -18,10 +17,10 @@
|
|
|
18
17
|
"require": "./dist/index.js"
|
|
19
18
|
},
|
|
20
19
|
"./internal": {
|
|
21
|
-
"types": "./internal/
|
|
22
|
-
"import": "./internal/
|
|
23
|
-
"module": "./internal/
|
|
24
|
-
"require": "./internal/
|
|
20
|
+
"types": "./dist/internal/index.d.ts",
|
|
21
|
+
"import": "./dist/internal/index.mjs",
|
|
22
|
+
"module": "./dist/internal/index.mjs",
|
|
23
|
+
"require": "./dist/internal/index.js"
|
|
25
24
|
}
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
"format": "prettier --write \"**/*.{ts,mts,tsx,md,mdx,mjs}\"",
|
|
71
70
|
"prepublish": "pnpm run build",
|
|
72
71
|
"test": "pnpm test:node && pnpm test:edge",
|
|
73
|
-
"test:edge": "vitest --config vitest.edge.config.
|
|
74
|
-
"test:node": "vitest --config vitest.node.config.
|
|
72
|
+
"test:edge": "vitest --config vitest.edge.config.ts --run",
|
|
73
|
+
"test:node": "vitest --config vitest.node.config.ts --run"
|
|
75
74
|
}
|
|
76
75
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|