diff --git a/public-endpoints/ai-sdk.mdx b/public-endpoints/ai-sdk.mdx index 9bede559..2b452a3f 100644 --- a/public-endpoints/ai-sdk.mdx +++ b/public-endpoints/ai-sdk.mdx @@ -63,6 +63,49 @@ const runpod = createRunpod({ | `baseURL` | Base URL for API requests | `https://api.runpod.ai/v2` | | `headers` | Custom HTTP headers to include with requests | `{}` | +## Using custom endpoints + +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. + +### Using endpoint IDs + +Pass your Serverless endpoint ID directly as the model identifier: + +```typescript +import { runpod } from "@runpod/ai-sdk-provider"; +import { generateText, experimental_generateImage as generateImage } from "ai"; + +// Use a custom chat endpoint +const { text } = await generateText({ + model: runpod("your-endpoint-id"), + prompt: "Hello, how are you?", +}); + +// Use a custom image endpoint +const { image } = await generateImage({ + model: runpod.image("your-image-endpoint-id"), + prompt: "A beautiful sunset", +}); +``` + +The SDK resolves your endpoint ID to `https://api.runpod.ai/v2/{endpointId}` automatically. + +### Using Console URLs + +Copy an endpoint URL directly from the Runpod Console and use it as the model identifier: + +```typescript +import { runpod } from "@runpod/ai-sdk-provider"; +import { experimental_generateImage as generateImage } from "ai"; + +const { image } = await generateImage({ + model: runpod.image("https://console.runpod.io/serverless/user/endpoint/abc123xyz"), + prompt: "A serene mountain landscape", +}); +``` + +The SDK extracts the endpoint ID from the Console URL and routes requests to your endpoint. + ## Text generation ### Basic text generation