AELDER

Vercel AI SDK: custom OpenAI-compatible provider

Configure Vercel AI SDK with AELDER using createOpenAICompatible. Set a custom base URL, keep keys server-side and compare model API prices.

AELDER · SERVICE BASE URL
https://aelder.dev/v1

LOCAL CONFIGURATION

Let my agent set this up

Copy this task to an agent already running on your computer. Enter your API key locally when asked.

SETUP PROMPT
Help me connect Vercel AI SDK to AELDER using this guide: https://aelder.dev/docs/vercel-ai-sdk/
Service Base URL: https://aelder.dev/v1
First inspect my installed version, active profile and configuration. Explain any mismatch with the guide before changing anything.
Use the documented local configuration or CLI method. Do not automate the GUI, install software or change permissions without asking.
Preserve existing accounts, providers, models, defaults, permissions and unrelated settings. Propose the smallest change, show a redacted diff, and back up any files before editing.
Have me enter my API key locally using the tool's secret storage or an environment variable. Never ask me to paste a key into chat, print it, or include it in a command, diff, log or commit.
Use the exact model ID I choose from my account's model list. Do not invent model IDs or assume every model supports every API format or tool feature.
Validate syntax and configuration loading before making any generation request. If there is no dry-run, say so.
Explain any proposed paid test, the model and what it sends, and ask for approval before running it. Do not send project files or private conversation history as a test.
Finish with the settings changed, checks performed and steps to restore the backup.

Create a custom OpenAI-compatible provider in Vercel AI SDK to call AELDER from your server-side JavaScript application. This recipe uses the Chat Completions adapter with your own API key and base URL. It configures a provider instance in your application; it does not require publishing a provider package.

1. Add the adapter

For model selection, review the Claude family price table or DeepSeek API catalog. Select an exact version and confirm its capabilities separately from the adapter configuration.

In your existing Node.js application, install compatible versions of the core SDK and adapter:

npm install ai @ai-sdk/openai-compatible

Set SERVICE_BASE_URL to the Base URL above with /v1. Set SERVICE_MODEL_ID to an exact ID from your model list. Supply SERVICE_API_KEY through your server environment. In a browser framework, keep the key and this code on the server; do not use a public environment variable.

2. Create a provider

import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';

const service = createOpenAICompatible({
  name: 'my-api',
  baseURL: process.env.SERVICE_BASE_URL,
  apiKey: process.env.SERVICE_API_KEY,
});

const result = await generateText({
  model: service.chatModel(process.env.SERVICE_MODEL_ID),
  prompt: 'Reply with OK.',
  maxRetries: 0,
});
console.log(result.text);

The provider label my-api is local to your app. The HTTP request uses the exact model ID you pass to chatModel; do not add that label to the ID.

Use baseURL with this adapter. Python SDK examples use base_url, which is a different option name. Keep /v1 in the Base URL and leave /chat/completions out; the adapter appends the path.

3. Check the request

Running generateText sends a billable request. Confirm its model and usage in your dashboard. Changing the environment’s model ID changes the model used after your app reloads. Compile or type-check your app before a live test.

The same adapter works with the SDK’s streamText for a compatible streaming model. Tool calls and structured output need model support; leave capability flags at their defaults until verified. This text guide does not configure embeddings, images, uploads or provider-hosted tools. The SDK’s separate OpenAI adapter may select another API format, so retain the explicit compatible adapter for this recipe.

Model API costs

Compare AELDER model prices and estimate token usage with the cost calculator. The chosen model determines the API rates. Your application hosting and deployment costs are separate from AELDER’s model API billing.

Troubleshoot the provider

For 401, check the server’s environment and API key. For 404, check the custom Base URL and ensure the code still uses @ai-sdk/openai-compatible. For model not found, compare SERVICE_MODEL_ID with your account’s model list. If the adapter and core SDK report a model-version or type mismatch, check their installed versions together before changing provider options.

Sources: AI SDK’s OpenAI-compatible provider and text generation reference.

Need the key? Open your AELDER dashboard. For direct API calls, see the API reference.