runpod-sdk 1.1.2 → 1.2.0-beta.2
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 +217 -32
- package/dist/src/graphql/client.d.ts +22 -0
- package/dist/src/graphql/client.js +75 -0
- package/dist/src/graphql/client.js.map +1 -0
- package/dist/src/graphql/generated/index.d.ts +742 -0
- package/dist/src/graphql/generated/index.js +347 -0
- package/dist/src/graphql/generated/index.js.map +1 -0
- package/dist/src/graphql/generated/operations.d.ts +428 -0
- package/dist/src/graphql/generated/operations.js +2 -0
- package/dist/src/graphql/generated/operations.js.map +1 -0
- package/dist/src/graphql/generated/sdk.d.ts +31 -0
- package/dist/src/graphql/generated/sdk.js +232 -0
- package/dist/src/graphql/generated/sdk.js.map +1 -0
- package/dist/src/graphql/generated/types.d.ts +4281 -0
- package/dist/src/graphql/generated/types.js +2 -0
- package/dist/src/graphql/generated/types.js.map +1 -0
- package/dist/src/index.d.ts +53 -8
- package/dist/src/index.js +73 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/pods/generated-gpu-types.d.ts +299 -0
- package/dist/src/pods/generated-gpu-types.js +148 -0
- package/dist/src/pods/generated-gpu-types.js.map +1 -0
- package/dist/src/pods/index.d.ts +122 -0
- package/dist/src/pods/index.js +242 -0
- package/dist/src/pods/index.js.map +1 -0
- package/package.json +17 -2
- package/schema.gql +161 -0
- package/.prettierrc +0 -12
- package/README-dev.md +0 -7
- package/examples/basic.js +0 -19
- package/examples/cancel.js +0 -27
- package/examples/devServerless.js +0 -17
- package/examples/errors.js +0 -11
- package/examples/health.js +0 -11
- package/examples/purge-queue.js +0 -11
- package/examples/run.js +0 -27
- package/examples/runSync.js +0 -17
- package/examples/stream.js +0 -48
- package/examples/test.js +0 -74
- package/src/index.ts +0 -330
- package/tsconfig.json +0 -17
package/schema.gql
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Public-facing RunPod GraphQL Schema
|
|
2
|
+
# Contains only operations exposed in the JavaScript SDK
|
|
3
|
+
|
|
4
|
+
scalar DateTime
|
|
5
|
+
scalar JSON
|
|
6
|
+
scalar JSONObject
|
|
7
|
+
|
|
8
|
+
type Query {
|
|
9
|
+
# User profile
|
|
10
|
+
myself: User
|
|
11
|
+
|
|
12
|
+
# Pod operations
|
|
13
|
+
pod(input: PodInput!): Pod
|
|
14
|
+
|
|
15
|
+
# GPU information
|
|
16
|
+
gpuTypes: [GpuType!]!
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Mutation {
|
|
20
|
+
# Pod lifecycle
|
|
21
|
+
podFindAndDeployOnDemand(input: PodFindAndDeployOnDemandInput!): Pod
|
|
22
|
+
podRentInterruptable(input: PodRentInterruptableInput!): Pod
|
|
23
|
+
podStop(input: PodInput!): Pod
|
|
24
|
+
podResume(input: PodResumeInput!): Pod
|
|
25
|
+
podTerminate(input: PodInput!): String
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Core types for public SDK
|
|
29
|
+
type User {
|
|
30
|
+
id: String
|
|
31
|
+
email: String
|
|
32
|
+
machineQuota: Int
|
|
33
|
+
currentSpendPerHr: Float
|
|
34
|
+
spendLimit: Float
|
|
35
|
+
referralEarned: Float
|
|
36
|
+
pods: [Pod!] # Missing field for ListMyPods query
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type Pod {
|
|
40
|
+
id: String!
|
|
41
|
+
name: String!
|
|
42
|
+
desiredStatus: String!
|
|
43
|
+
imageName: String
|
|
44
|
+
env: [String] # String array based on dev API
|
|
45
|
+
machineId: String
|
|
46
|
+
memoryInGb: Float
|
|
47
|
+
vcpuCount: Float
|
|
48
|
+
volumeInGb: Float
|
|
49
|
+
volumeMountPath: String
|
|
50
|
+
podType: String
|
|
51
|
+
costPerHr: Float!
|
|
52
|
+
gpuCount: Int
|
|
53
|
+
containerDiskInGb: Int
|
|
54
|
+
ports: String
|
|
55
|
+
volumeKey: String
|
|
56
|
+
containerRegistryAuthId: String
|
|
57
|
+
|
|
58
|
+
# Runtime information
|
|
59
|
+
runtime: PodRuntime
|
|
60
|
+
machine: PodMachine
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type PodRuntime {
|
|
64
|
+
uptimeInSeconds: Int
|
|
65
|
+
ports: [PodRuntimePort]
|
|
66
|
+
gpus: [PodRuntimeGpu]
|
|
67
|
+
container: PodRuntimeContainer
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type PodRuntimePort {
|
|
71
|
+
ip: String
|
|
72
|
+
isIpPublic: Boolean
|
|
73
|
+
privatePort: Int
|
|
74
|
+
publicPort: Int
|
|
75
|
+
type: String
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
type PodRuntimeGpu {
|
|
79
|
+
id: String
|
|
80
|
+
gpuUtilPercent: Int
|
|
81
|
+
memoryUtilPercent: Int
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type PodRuntimeContainer {
|
|
85
|
+
cpuPercent: Int
|
|
86
|
+
memoryPercent: Int
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type PodMachine {
|
|
90
|
+
podHostId: String
|
|
91
|
+
gpuDisplayName: String
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type GpuType {
|
|
95
|
+
id: String!
|
|
96
|
+
displayName: String!
|
|
97
|
+
memoryInGb: Int!
|
|
98
|
+
secureCloud: Boolean!
|
|
99
|
+
communityCloud: Boolean!
|
|
100
|
+
lowestPrice(input: GpuLowestPriceInput!): LowestPrice
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type LowestPrice {
|
|
104
|
+
gpuName: String # Missing field
|
|
105
|
+
stockStatus: String
|
|
106
|
+
uninterruptablePrice: Float
|
|
107
|
+
minimumBidPrice: Float
|
|
108
|
+
rentedCount: Int
|
|
109
|
+
totalCount: Int
|
|
110
|
+
availableGpuCounts: [Int]
|
|
111
|
+
maxUnreservedGpuCount: Int # Missing field
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Input types
|
|
115
|
+
input PodInput {
|
|
116
|
+
podId: String!
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
input PodResumeInput {
|
|
120
|
+
podId: String!
|
|
121
|
+
gpuCount: Int!
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
input PodFindAndDeployOnDemandInput {
|
|
125
|
+
name: String!
|
|
126
|
+
imageName: String!
|
|
127
|
+
gpuTypeId: String!
|
|
128
|
+
gpuCount: Int
|
|
129
|
+
volumeInGb: Int
|
|
130
|
+
volumeMountPath: String
|
|
131
|
+
containerDiskInGb: Int
|
|
132
|
+
env: [EnvironmentVariableInput]
|
|
133
|
+
ports: String
|
|
134
|
+
dockerArgs: String
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
input PodRentInterruptableInput {
|
|
138
|
+
name: String!
|
|
139
|
+
imageName: String!
|
|
140
|
+
gpuTypeId: String!
|
|
141
|
+
gpuCount: Int
|
|
142
|
+
volumeInGb: Int
|
|
143
|
+
volumeMountPath: String
|
|
144
|
+
containerDiskInGb: Int
|
|
145
|
+
bidPerGpu: Float!
|
|
146
|
+
env: [EnvironmentVariableInput]
|
|
147
|
+
ports: String
|
|
148
|
+
dockerArgs: String
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
input EnvironmentVariableInput {
|
|
152
|
+
key: String!
|
|
153
|
+
value: String!
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
input GpuLowestPriceInput {
|
|
157
|
+
gpuCount: Int!
|
|
158
|
+
secureCloud: Boolean
|
|
159
|
+
minMemoryInGb: Int
|
|
160
|
+
totalDisk: Int
|
|
161
|
+
}
|
package/.prettierrc
DELETED
package/README-dev.md
DELETED
package/examples/basic.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint("faster-whisper")
|
|
10
|
-
|
|
11
|
-
const input = {
|
|
12
|
-
input: {
|
|
13
|
-
audio: "https://github.com/runpod-workers/sample-inputs/raw/main/audio/gettysburg.wav",
|
|
14
|
-
model: "base",
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
const result = await endpoint.runSync(input)
|
|
18
|
-
|
|
19
|
-
console.log(result)
|
package/examples/cancel.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint("faster-whisper")
|
|
10
|
-
const input = {
|
|
11
|
-
input: {
|
|
12
|
-
audio: "https://github.com/runpod-workers/sample-inputs/raw/main/audio/gettysburg.wav",
|
|
13
|
-
model: "base",
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
const result = await endpoint.run(input)
|
|
17
|
-
console.log("run resp")
|
|
18
|
-
console.log(result)
|
|
19
|
-
|
|
20
|
-
const { id } = result
|
|
21
|
-
const cancelResp = await endpoint.cancel(id)
|
|
22
|
-
console.log("cancel resp")
|
|
23
|
-
console.log(cancelResp)
|
|
24
|
-
|
|
25
|
-
const statusResp = await endpoint.status(id)
|
|
26
|
-
console.log("status after cancellation")
|
|
27
|
-
console.log(statusResp)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import runpodSdk, { runpodServerlessBaseUrlDev } from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY, { baseUrl: runpodServerlessBaseUrlDev })
|
|
9
|
-
const endpoint = runpod.endpoint("faster-whisper")
|
|
10
|
-
const input = {
|
|
11
|
-
input: {
|
|
12
|
-
audio: "https://github.com/runpod-workers/sample-inputs/raw/main/audio/gettysburg.wav",
|
|
13
|
-
model: "base",
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
const result = await endpoint.runSync(input)
|
|
17
|
-
console.log(result)
|
package/examples/errors.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY, ENDPOINT_ID } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY || !ENDPOINT_ID) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint(ENDPOINT_ID)
|
|
10
|
-
const result = await endpoint.health()
|
|
11
|
-
console.log(result)
|
package/examples/health.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint("faster-whisper")
|
|
10
|
-
const result = await endpoint.health()
|
|
11
|
-
console.log(result)
|
package/examples/purge-queue.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY, ENDPOINT_ID } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY || !ENDPOINT_ID) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint(ENDPOINT_ID)
|
|
10
|
-
const result = await endpoint.purgeQueue()
|
|
11
|
-
console.log(result)
|
package/examples/run.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint("faster-whisper")
|
|
10
|
-
const input = {
|
|
11
|
-
input: {
|
|
12
|
-
audio: "https://github.com/runpod-workers/sample-inputs/raw/main/audio/gettysburg.wav",
|
|
13
|
-
model: "base",
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
const result = await endpoint.run(input)
|
|
17
|
-
console.log("run response")
|
|
18
|
-
console.log(result)
|
|
19
|
-
|
|
20
|
-
const { id } = result
|
|
21
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
22
|
-
for (let i = 0; i < 5; i++) {
|
|
23
|
-
const status = await endpoint.status(id)
|
|
24
|
-
console.log("status response")
|
|
25
|
-
console.log(status)
|
|
26
|
-
await sleep(1000)
|
|
27
|
-
}
|
package/examples/runSync.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
const { RUNPOD_API_KEY } = process.env
|
|
3
|
-
if (!RUNPOD_API_KEY) {
|
|
4
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
5
|
-
process.exit()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint("faster-whisper")
|
|
10
|
-
const input = {
|
|
11
|
-
input: {
|
|
12
|
-
audio: "https://github.com/runpod-workers/sample-inputs/raw/main/audio/gettysburg.wav",
|
|
13
|
-
model: "base",
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
const result = await endpoint.runSync(input, 3000)
|
|
17
|
-
console.log(result)
|
package/examples/stream.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "runpod-sdk"
|
|
2
|
-
|
|
3
|
-
const { RUNPOD_API_KEY } = process.env
|
|
4
|
-
if (!RUNPOD_API_KEY) {
|
|
5
|
-
console.log("please supply RUNPOD_API_KEY as an environment variable")
|
|
6
|
-
process.exit()
|
|
7
|
-
}
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
//mock endpoint which returns whatever you specify as a stream
|
|
10
|
-
//with a specified delay between inputs
|
|
11
|
-
const endpoint = runpod.endpoint("gwp4kx5yd3nur1")
|
|
12
|
-
|
|
13
|
-
const request = {
|
|
14
|
-
input: {
|
|
15
|
-
mock_return: ["a", "b", "c", "d", "e", "f", "g"],
|
|
16
|
-
mock_delay: 2,
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
const runResp = await endpoint.run(request)
|
|
20
|
-
const { id } = runResp
|
|
21
|
-
for await (const result of endpoint.stream(id)) {
|
|
22
|
-
console.log(`stream yielded ${JSON.stringify(result, null, 2)}`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Expected output
|
|
26
|
-
/*
|
|
27
|
-
stream yielded {
|
|
28
|
-
"output": "a",
|
|
29
|
-
}
|
|
30
|
-
stream yielded {
|
|
31
|
-
"output": "b"
|
|
32
|
-
}
|
|
33
|
-
stream yielded {
|
|
34
|
-
"output": "c"
|
|
35
|
-
}
|
|
36
|
-
stream yielded {
|
|
37
|
-
"output": "d"
|
|
38
|
-
}
|
|
39
|
-
stream yielded {
|
|
40
|
-
"output": "e"
|
|
41
|
-
}
|
|
42
|
-
stream yielded {
|
|
43
|
-
"output": "f"
|
|
44
|
-
}
|
|
45
|
-
stream yielded {
|
|
46
|
-
"output": "g"
|
|
47
|
-
}
|
|
48
|
-
*/
|
package/examples/test.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import runpodSdk from "../dist/index.js"
|
|
2
|
-
|
|
3
|
-
const { RUNPOD_API_KEY, ENDPOINT_ID } = process.env
|
|
4
|
-
if (!RUNPOD_API_KEY || !ENDPOINT_ID) {
|
|
5
|
-
console.log("please supply RUNPOD_API_KEY and ENDPOINT_ID as an environment variable")
|
|
6
|
-
process.exit()
|
|
7
|
-
}
|
|
8
|
-
const runpod = runpodSdk(RUNPOD_API_KEY)
|
|
9
|
-
const endpoint = runpod.endpoint(ENDPOINT_ID)
|
|
10
|
-
|
|
11
|
-
const request = {
|
|
12
|
-
input: {
|
|
13
|
-
prompt: "photo of a horse",
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
console.log("\nrun")
|
|
18
|
-
const runResp = await endpoint.run(request)
|
|
19
|
-
console.log(runResp)
|
|
20
|
-
const { id: requestId } = runResp
|
|
21
|
-
console.log("\nstatus")
|
|
22
|
-
const statusResp = await endpoint.status(requestId)
|
|
23
|
-
console.log(statusResp)
|
|
24
|
-
console.log("\ncancel")
|
|
25
|
-
const cancelResp = await endpoint.cancel(requestId)
|
|
26
|
-
console.log(cancelResp)
|
|
27
|
-
console.log("\nhealth")
|
|
28
|
-
const healthResp = await endpoint.health()
|
|
29
|
-
console.log(healthResp)
|
|
30
|
-
console.log("\npurge queue")
|
|
31
|
-
const purgeResp = await endpoint.purgeQueue()
|
|
32
|
-
console.log(purgeResp)
|
|
33
|
-
console.log("\nafter purge")
|
|
34
|
-
console.log(await endpoint.health())
|
|
35
|
-
|
|
36
|
-
console.log("runSync")
|
|
37
|
-
const result = await endpoint.runSync(request)
|
|
38
|
-
console.log(result)
|
|
39
|
-
|
|
40
|
-
const failingRequest = {
|
|
41
|
-
input: {
|
|
42
|
-
bogus_key: "photo of a horse",
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
console.log("runSync failing")
|
|
46
|
-
const failingResult = await endpoint.runSync(failingRequest)
|
|
47
|
-
console.log(failingResult)
|
|
48
|
-
|
|
49
|
-
const slowRequest = {
|
|
50
|
-
input: {
|
|
51
|
-
prompt: "photo of a horse",
|
|
52
|
-
num_inference_steps: 200,
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
console.log("runSync timed out")
|
|
57
|
-
const timedOutResult = await endpoint.runSync(slowRequest, 3000)
|
|
58
|
-
console.log(timedOutResult)
|
|
59
|
-
|
|
60
|
-
console.log("\nstream")
|
|
61
|
-
//mock endpoint which returns whatever you specify as a stream
|
|
62
|
-
//with a specified delay between inputs
|
|
63
|
-
const streamingEndpoint = runpod.endpoint("gwp4kx5yd3nur1")
|
|
64
|
-
const streamReq = {
|
|
65
|
-
input: {
|
|
66
|
-
mock_return: ["a", "b", "c", "d", "e", "f", "g"],
|
|
67
|
-
mock_delay: 2,
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
const streamRunResp = await streamingEndpoint.run(streamReq)
|
|
71
|
-
const { id } = streamRunResp
|
|
72
|
-
for await (const result of endpoint.stream(id)) {
|
|
73
|
-
console.log(`stream yielded ${JSON.stringify(result, null, 2)}`)
|
|
74
|
-
}
|