Skip to content

Commit 6ba3e7c

Browse files
authored
chore: update bundle path to be cleaner (#33)
* chore: update bundle path to be cleaner * chore: bump patch * chore: update README * correct bump
1 parent 14c37fb commit 6ba3e7c

5 files changed

+72
-34
lines changed

README.md

+63-24
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,66 @@ You can find the latest list of tool-supported models supported by OpenRouter [h
4444

4545
## Passing Extra Body to OpenRouter
4646

47-
When you want to pass extra body to OpenRouter or to the upstream provider, you can do so by setting the `extraBody` property on the language model.
48-
49-
```typescript
50-
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
51-
52-
const provider = createOpenRouter({
53-
apiKey: 'your-api-key',
54-
// Extra body to pass to OpenRouter
55-
extraBody: {
56-
custom_field: 'custom_value',
57-
providers: {
58-
anthropic: {
59-
custom_field: 'custom_value',
60-
},
61-
},
62-
},
63-
});
64-
const model = provider.chat('anthropic/claude-3.5-sonnet');
65-
const response = await model.doStream({
66-
inputFormat: 'prompt',
67-
mode: { type: 'regular' },
68-
prompt: [{ role: 'user', content: 'Hello' }],
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.json

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"name": "@openrouter/ai-sdk-provider",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"license": "Apache-2.0",
55
"sideEffects": false,
66
"main": "./dist/index.js",
77
"module": "./dist/index.mjs",
88
"types": "./dist/index.d.ts",
99
"files": [
10-
"dist/**/*",
11-
"internal/dist/**/*"
10+
"dist/**/*"
1211
],
1312
"scripts": {
1413
"build": "tsup",
@@ -20,8 +19,8 @@
2019
"format": "prettier --write \"**/*.{ts,mts,tsx,md,mdx,mjs}\"",
2120
"prepublish": "pnpm run build",
2221
"test": "pnpm test:node && pnpm test:edge",
23-
"test:edge": "vitest --config vitest.edge.config.js --run",
24-
"test:node": "vitest --config vitest.node.config.js --run"
22+
"test:edge": "vitest --config vitest.edge.config.ts --run",
23+
"test:node": "vitest --config vitest.node.config.ts --run"
2524
},
2625
"exports": {
2726
"./package.json": "./package.json",
@@ -31,10 +30,10 @@
3130
"require": "./dist/index.js"
3231
},
3332
"./internal": {
34-
"types": "./internal/dist/index.d.ts",
35-
"import": "./internal/dist/index.mjs",
36-
"module": "./internal/dist/index.mjs",
37-
"require": "./internal/dist/index.js"
33+
"types": "./dist/internal/index.d.ts",
34+
"import": "./dist/internal/index.mjs",
35+
"module": "./dist/internal/index.mjs",
36+
"require": "./dist/internal/index.js"
3837
}
3938
},
4039
"dependencies": {

tsup.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default defineConfig([
99
},
1010
{
1111
entry: ['src/internal/index.ts'],
12-
outDir: 'internal/dist',
12+
outDir: 'dist/internal',
1313
format: ['cjs', 'esm'],
1414
dts: true,
1515
sourcemap: true,
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)