{"record":{"id":"f85aadb28563d348","repo":"vercel/ai","slug":"deepseek-assistant-prefix-completion-requires-a-be","errorCode":null,"errorMessage":"DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`.","messagePattern":"DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts","lineNumber":277,"sourceCode":"          ...(deepseekMessageOptions?.name != null && {\n            name: deepseekMessageOptions.name,\n          }),\n        });\n\n        break;\n      }\n      case 'assistant': {\n        if (deepseekMessageOptions?.prefix === true) {\n          if (index !== prompt.length - 1) {\n            throw new InvalidPromptError({\n              prompt,\n              message:\n                'DeepSeek assistant prefix completion requires the prefixed assistant message to be the final message.',\n            });\n          }\n\n          if (!supportsAssistantPrefixCompletion) {\n            throw new UnsupportedFunctionalityError({\n              functionality: 'DeepSeek assistant prefix completion',\n              message:\n                'DeepSeek assistant prefix completion requires a beta base URL ending in `/beta`.',\n            });\n          }\n        }\n\n        let text = '';\n        let reasoning: string | undefined;\n\n        const toolCalls: Array<{\n          id: string;\n          type: 'function';\n          function: { name: string; arguments: string };\n        }> = [];\n\n        for (const part of content) {\n          switch (part.type) {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/deepseek/src/chat/convert-to-deepseek-chat-messages.ts#L259-L295","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create the provider with baseURL 'https://api.deepseek.com/beta', e.g. createDeepSeek({ baseURL: 'https://api.deepseek.com/beta' })","Or use the deepseek.beta model factory if available","Or remove prefix: true if beta endpoints cannot be used"],"exampleFix":"// before\nconst deepseek = createDeepSeek({ apiKey });\n// after\nconst deepseek = createDeepSeek({ apiKey, baseURL: 'https://api.deepseek.com/beta' });","handlingStrategy":"validation","validationCode":"const baseURL = process.env.DEEPSEEK_BASE_URL ?? 'https://api.deepseek.com';\nfunction assertBetaForPrefix() {\n  if (!baseURL.endsWith('/beta')) throw new Error('prefix completion requires a baseURL ending in /beta');\n}","typeGuard":null,"tryCatchPattern":"try { ... } catch (e) { if (UnsupportedFunctionalityError.isInstance(e) && /assistant prefix completion/.test(e.message)) { /* recreate provider with /beta baseURL */ } throw e; }","preventionTips":["Set the DeepSeek baseURL to https://api.deepseek.com/beta wherever prefix completion is used","Gate prefix usage on a feature flag that also selects the beta endpoint","Verify proxy/gateway URLs still end with /beta"],"tags":["deepseek","prefix-completion","beta","base-url"],"backgroundTag":"feature-requires-beta-endpoint","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}