vercel/ai · error · UnsupportedFunctionalityError

DeepSeek assistant prefix completion requires a beta base UR

Error message

DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`.

What it means

DeepSeek assistant prefix completion is a beta feature available only on the /beta base URL. When a prefixed assistant message is present but the model was not created with a base URL ending in /beta (supportsAssistantPrefixCompletion false), the SDK throws UnsupportedFunctionalityError.

Source

Thrown at packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts:277

          ...(deepseekMessageOptions?.name != null && {
            name: deepseekMessageOptions.name,
          }),
        });

        break;
      }
      case 'assistant': {
        if (deepseekMessageOptions?.prefix === true) {
          if (index !== prompt.length - 1) {
            throw new InvalidPromptError({
              prompt,
              message:
                'DeepSeek assistant prefix completion requires the prefixed assistant message to be the final message.',
            });
          }

          if (!supportsAssistantPrefixCompletion) {
            throw new UnsupportedFunctionalityError({
              functionality: 'DeepSeek assistant prefix completion',
              message:
                'DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`.',
            });
          }
        }

        let text = '';
        let reasoning: string | undefined;

        const toolCalls: Array<{
          id: string;
          type: 'function';
          function: { name: string; arguments: string };
        }> = [];

        for (const part of content) {
          switch (part.type) {

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Create the provider with baseURL 'https://api.deepseek.com/beta', e.g. createDeepSeek({ baseURL: 'https://api.deepseek.com/beta' })
  2. Or use the deepseek.beta model factory if available
  3. Or remove prefix: true if beta endpoints cannot be used

Example fix

// before
const deepseek = createDeepSeek({ apiKey });
// after
const deepseek = createDeepSeek({ apiKey, baseURL: 'https://api.deepseek.com/beta' });
Defensive patterns

Strategy: validation

Validate before calling

const baseURL = process.env.DEEPSEEK_BASE_URL ?? 'https://api.deepseek.com';
function assertBetaForPrefix() {
  if (!baseURL.endsWith('/beta')) throw new Error('prefix completion requires a baseURL ending in /beta');
}

Try / catch

try { ... } catch (e) { if (UnsupportedFunctionalityError.isInstance(e) && /assistant prefix completion/.test(e.message)) { /* recreate provider with /beta baseURL */ } throw e; }

Prevention

When it happens

Trigger: Using createDeepSeek() with the default (non-beta) base URL — or a custom URL not ending in /beta — while sending an assistant message with deepseek.prefix: true.

Common situations: Production config pointing at the stable endpoint after testing locally against /beta; a proxy/gateway base URL that doesn't end with /beta; forgetting that prefix completion requires the beta endpoint.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/f85aadb28563d348. Report an issue: GitHub.