Skip to content

Commit 2c34ebd

Browse files
docs: Document custom endpoint support in Vercel AI SDK (#579)
2 parents d3cb8ab + 158e17d commit 2c34ebd

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

public-endpoints/ai-sdk.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,49 @@ const runpod = createRunpod({
6363
| `baseURL` | Base URL for API requests | `https://api.runpod.ai/v2` |
6464
| `headers` | Custom HTTP headers to include with requests | `{}` |
6565

66+
## Using custom endpoints
67+
68+
You can use your own [Serverless endpoints](/serverless/overview) with the AI SDK. This is useful when you've deployed a custom model or want to use a specific endpoint you've created.
69+
70+
### Using endpoint IDs
71+
72+
Pass your Serverless endpoint ID directly as the model identifier:
73+
74+
```typescript
75+
import { runpod } from "@runpod/ai-sdk-provider";
76+
import { generateText, experimental_generateImage as generateImage } from "ai";
77+
78+
// Use a custom chat endpoint
79+
const { text } = await generateText({
80+
model: runpod("your-endpoint-id"),
81+
prompt: "Hello, how are you?",
82+
});
83+
84+
// Use a custom image endpoint
85+
const { image } = await generateImage({
86+
model: runpod.image("your-image-endpoint-id"),
87+
prompt: "A beautiful sunset",
88+
});
89+
```
90+
91+
The SDK resolves your endpoint ID to `https://api.runpod.ai/v2/{endpointId}` automatically.
92+
93+
### Using Console URLs
94+
95+
Copy an endpoint URL directly from the Runpod Console and use it as the model identifier:
96+
97+
```typescript
98+
import { runpod } from "@runpod/ai-sdk-provider";
99+
import { experimental_generateImage as generateImage } from "ai";
100+
101+
const { image } = await generateImage({
102+
model: runpod.image("https://console.runpod.io/serverless/user/endpoint/abc123xyz"),
103+
prompt: "A serene mountain landscape",
104+
});
105+
```
106+
107+
The SDK extracts the endpoint ID from the Console URL and routes requests to your endpoint.
108+
66109
## Text generation
67110

68111
### Basic text generation

0 commit comments

Comments
 (0)