@runpod/ai-sdk-provider 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/CHANGELOG.md +6 -0
- package/README.md +35 -57
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Runpod AI SDK Provider
|
|
2
2
|
|
|
3
|
-
The **
|
|
3
|
+
The **Runpod provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Runpod's](https://runpod.io) public endpoints.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
+
# npm
|
|
8
9
|
npm install @runpod/ai-sdk-provider
|
|
10
|
+
|
|
11
|
+
# pnpm
|
|
12
|
+
pnpm add @runpod/ai-sdk-provider
|
|
13
|
+
|
|
14
|
+
# yarn
|
|
15
|
+
yarn add @runpod/ai-sdk-provider
|
|
9
16
|
```
|
|
10
17
|
|
|
11
18
|
## Setup
|
|
12
19
|
|
|
13
|
-
The
|
|
20
|
+
The Runpod provider requires a Runpod API key. You can obtain one from the [Runpod console](https://console.runpod.io/user/settings) under "API Keys".
|
|
14
21
|
|
|
15
22
|
### Environment Variable
|
|
16
23
|
|
|
@@ -25,7 +32,7 @@ export RUNPOD_API_KEY="your-api-key-here"
|
|
|
25
32
|
Import the provider:
|
|
26
33
|
|
|
27
34
|
```ts
|
|
28
|
-
import { runpod } from
|
|
35
|
+
import { runpod } from '@runpod/ai-sdk-provider';
|
|
29
36
|
```
|
|
30
37
|
|
|
31
38
|
## Supported Models
|
|
@@ -40,12 +47,12 @@ import { runpod } from "@runpod/ai-sdk-provider";
|
|
|
40
47
|
### Basic Text Generation
|
|
41
48
|
|
|
42
49
|
```ts
|
|
43
|
-
import { runpod } from
|
|
44
|
-
import { generateText } from
|
|
50
|
+
import { runpod } from '@runpod/ai-sdk-provider';
|
|
51
|
+
import { generateText } from 'ai';
|
|
45
52
|
|
|
46
53
|
const { text } = await generateText({
|
|
47
|
-
model: runpod(
|
|
48
|
-
prompt:
|
|
54
|
+
model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
|
|
55
|
+
prompt: 'Write a Python function that sorts a list:',
|
|
49
56
|
});
|
|
50
57
|
|
|
51
58
|
console.log(text);
|
|
@@ -53,19 +60,19 @@ console.log(text);
|
|
|
53
60
|
|
|
54
61
|
### Streaming
|
|
55
62
|
|
|
56
|
-
**Note**: Streaming is not yet supported by
|
|
63
|
+
**Note**: Streaming is not yet supported by Runpod's public endpoints. The team is working on implementing this feature.
|
|
57
64
|
|
|
58
65
|
### Chat Conversations
|
|
59
66
|
|
|
60
67
|
```ts
|
|
61
|
-
import { runpod } from
|
|
62
|
-
import { generateText } from
|
|
68
|
+
import { runpod } from '@runpod/ai-sdk-provider';
|
|
69
|
+
import { generateText } from 'ai';
|
|
63
70
|
|
|
64
71
|
const { text } = await generateText({
|
|
65
|
-
model: runpod(
|
|
72
|
+
model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
|
|
66
73
|
messages: [
|
|
67
|
-
{ role:
|
|
68
|
-
{ role:
|
|
74
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
75
|
+
{ role: 'user', content: 'What is the capital of France?' },
|
|
69
76
|
],
|
|
70
77
|
});
|
|
71
78
|
```
|
|
@@ -73,18 +80,18 @@ const { text } = await generateText({
|
|
|
73
80
|
### Function Calling
|
|
74
81
|
|
|
75
82
|
```ts
|
|
76
|
-
import { runpod } from
|
|
77
|
-
import { generateText, tool } from
|
|
78
|
-
import { z } from
|
|
83
|
+
import { runpod } from '@runpod/ai-sdk-provider';
|
|
84
|
+
import { generateText, tool } from 'ai';
|
|
85
|
+
import { z } from 'zod';
|
|
79
86
|
|
|
80
87
|
const { text, toolCalls } = await generateText({
|
|
81
|
-
model: runpod(
|
|
82
|
-
prompt:
|
|
88
|
+
model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
|
|
89
|
+
prompt: 'What is the weather like in San Francisco?',
|
|
83
90
|
tools: {
|
|
84
91
|
getWeather: tool({
|
|
85
|
-
description:
|
|
92
|
+
description: 'Get weather information for a city',
|
|
86
93
|
parameters: z.object({
|
|
87
|
-
city: z.string().describe(
|
|
94
|
+
city: z.string().describe('The city name'),
|
|
88
95
|
}),
|
|
89
96
|
execute: async ({ city }) => {
|
|
90
97
|
// Your weather API call here
|
|
@@ -98,12 +105,12 @@ const { text, toolCalls } = await generateText({
|
|
|
98
105
|
### Structured Output
|
|
99
106
|
|
|
100
107
|
```ts
|
|
101
|
-
import { runpod } from
|
|
102
|
-
import { generateObject } from
|
|
103
|
-
import { z } from
|
|
108
|
+
import { runpod } from '@runpod/ai-sdk-provider';
|
|
109
|
+
import { generateObject } from 'ai';
|
|
110
|
+
import { z } from 'zod';
|
|
104
111
|
|
|
105
112
|
const { object } = await generateObject({
|
|
106
|
-
model: runpod(
|
|
113
|
+
model: runpod('qwen/qwen3-32b-awq'),
|
|
107
114
|
schema: z.object({
|
|
108
115
|
recipe: z.object({
|
|
109
116
|
name: z.string(),
|
|
@@ -111,44 +118,15 @@ const { object } = await generateObject({
|
|
|
111
118
|
steps: z.array(z.string()),
|
|
112
119
|
}),
|
|
113
120
|
}),
|
|
114
|
-
prompt:
|
|
121
|
+
prompt: 'Generate a recipe for chocolate chip cookies.',
|
|
115
122
|
});
|
|
116
123
|
|
|
117
124
|
console.log(object.recipe);
|
|
118
125
|
```
|
|
119
126
|
|
|
120
|
-
## Model Methods
|
|
121
|
-
|
|
122
|
-
The provider supports multiple ways to create models:
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
// Default chat model
|
|
126
|
-
const model1 = runpod("deep-cogito/deep-cogito-v2-llama-70b");
|
|
127
|
-
|
|
128
|
-
// Explicit chat model
|
|
129
|
-
const model2 = runpod.chatModel("deep-cogito/deep-cogito-v2-llama-70b");
|
|
130
|
-
|
|
131
|
-
// Language model (alias for chat)
|
|
132
|
-
const model3 = runpod.languageModel("qwen/qwen3-32b-awq");
|
|
133
|
-
|
|
134
|
-
// Completion model
|
|
135
|
-
const model4 = runpod.completionModel("deep-cogito/deep-cogito-v2-llama-70b");
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## API Compatibility
|
|
139
|
-
|
|
140
|
-
RunPod's endpoints are OpenAI API compatible, supporting:
|
|
141
|
-
|
|
142
|
-
- Chat completions (`/chat/completions`)
|
|
143
|
-
- Text completions (`/completions`)
|
|
144
|
-
- Function/tool calling
|
|
145
|
-
- Structured outputs
|
|
146
|
-
|
|
147
|
-
**Note**: Streaming responses are not yet supported but are being worked on.
|
|
148
|
-
|
|
149
127
|
## Links
|
|
150
128
|
|
|
151
|
-
- [
|
|
152
|
-
- [
|
|
129
|
+
- [Runpod](https://runpod.io) - Cloud platform for AI compute
|
|
130
|
+
- [Runpod Public Endpoints Documentation](https://docs.runpod.io/hub/public-endpoints)
|
|
153
131
|
- [AI SDK Documentation](https://ai-sdk.dev/docs)
|
|
154
132
|
- [GitHub Repository](https://github.com/runpod/ai-sdk-provider)
|