fix(ocr): drop retired Vertex deepseek-ocr-maas model, take self-deployed model id (#20423)

This commit is contained in:
diegosouzapw
2026-11-19 05:19:58 -03:00
parent cc59ad70b2
commit 658402ca7f
6 changed files with 95 additions and 14 deletions

View File

@@ -0,0 +1 @@
- fix(ocr): `vertex-deepseek-ocr` no longer advertises or sends the `deepseek-ocr-maas` model Google retired on 2026-10-21; it now takes a self-deployed Model Garden model id and endpoint (#20423)

View File

@@ -436,11 +436,11 @@ Content-Type: application/json
`mistral-ocr-latest`) resolves to its registered provider, and an omitted `model` defaults to
Mistral (`mistral-ocr-latest`). Registered providers (`open-sse/config/ocrRegistry.ts`):
| Provider id | Model id | `model` value | Notes |
| ----------------------------- | -------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `mistral` | `mistral-ocr-latest` | `mistral/mistral-ocr-latest` (or bare `mistral-ocr-latest`) | Synchronous — the response is returned directly from the single upstream call. |
| `azure-document-intelligence` | `prebuilt-read` | `azure-document-intelligence/prebuilt-read` | Asynchronous upstream (`analyze` + poll) — see below. |
| `vertex-deepseek-ocr` | `deepseek-ocr-maas` | `vertex-deepseek-ocr/deepseek-ocr-maas` | Synchronous, via Vertex AI's `openapi/chat/completions` partner endpoint — see below for auth/URL. |
| Provider id | Model id | `model` value | Notes |
| ----------------------------- | --------------------------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mistral` | `mistral-ocr-latest` | `mistral/mistral-ocr-latest` (or bare `mistral-ocr-latest`) | Synchronous — the response is returned directly from the single upstream call. |
| `azure-document-intelligence` | `prebuilt-read` | `azure-document-intelligence/prebuilt-read` | Asynchronous upstream (`analyze` + poll) — see below. |
| `vertex-deepseek-ocr` | self-deployed (no built-in model) | `vertex-deepseek-ocr/<your-deployed-model-id>` | Synchronous, via your own Vertex AI Model Garden DeepSeek-OCR endpoint (`openapi/chat/completions` shape); Google retired the managed `deepseek-ocr-maas` on 2026-10-21 (#20423), so that id returns 400. |
All three providers respond in the same Mistral-shaped body:

View File

@@ -107,10 +107,10 @@ export const AZURE_DI_TRANSFORMATION: OcrTransformation = {
};
/**
* Vertex AI DeepSeek OCR (deepseek-ai/deepseek-ocr-maas), served through Vertex's generic
* Vertex AI DeepSeek OCR (self-deployed Model Garden endpoint), served through Vertex's generic
* OpenAI-compatible partner endpoint ("openapi/chat/completions"). Modeled on litellm's
* VertexAIDeepSeekOCRConfig (litellm/llms/vertex_ai/ocr/deepseek_transformation.py):
* - request: OpenAI chat-completions shape, model prefixed with "deepseek-ai/", the OCR
* - request: OpenAI chat-completions shape, model id sent as supplied, the OCR
* document sent as a single image_url content part (document_url documents are mapped to
* the same image_url shape — Vertex accepts both gs:// and https:// URLs there).
* - response: an OpenAI chat-completions body whose choices[0].message.content is either a
@@ -129,6 +129,14 @@ function vertexDeepseekOcrContent(document: Record<string, unknown> | undefined)
return { type: "image_url", image_url: url };
}
/**
* Google retired the managed (MaaS) `deepseek-ocr-maas` model on Vertex AI on 2026-10-21; the only
* remaining path is a self-deployed DeepSeek-OCR on Model Garden (#20423). The provider therefore
* has no built-in model: callers pass `vertex-deepseek-ocr/<deployed-model-id>` plus the dedicated
* endpoint in `providerSpecificData.baseUrl`, and the id is sent upstream exactly as supplied.
*/
export const VERTEX_DEEPSEEK_RETIRED_MODEL_ID = "deepseek-ocr-maas";
export const VERTEX_DEEPSEEK_TRANSFORMATION: OcrTransformation = {
buildRequest({ baseUrl, token, body, modelId }) {
return {
@@ -137,7 +145,7 @@ export const VERTEX_DEEPSEEK_TRANSFORMATION: OcrTransformation = {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
body: JSON.stringify({
model: `deepseek-ai/${modelId}`,
model: modelId,
messages: [
{
role: "user",
@@ -154,7 +162,7 @@ export const VERTEX_DEEPSEEK_TRANSFORMATION: OcrTransformation = {
choices?: Array<{ message?: { content?: unknown } }>;
usage?: Record<string, unknown>;
};
const model = r.model ?? "deepseek-ocr-maas";
const model = r.model ?? "vertex-deepseek-ocr";
const content = r.choices?.[0]?.message?.content;
if (typeof content === "string") {
@@ -204,7 +212,7 @@ export const OCR_PROVIDERS: Record<string, OcrProvider> = {
baseUrl: "",
authType: "apikey",
authHeader: "bearer",
models: [{ id: "deepseek-ocr-maas", name: "DeepSeek OCR (Vertex AI MaaS)" }],
models: [],
transformation: VERTEX_DEEPSEEK_TRANSFORMATION,
},
};

View File

@@ -10,6 +10,7 @@ import {
getOcrTransformation,
parseOcrModel,
OCR_PROVIDERS,
VERTEX_DEEPSEEK_RETIRED_MODEL_ID,
type OcrResponseShape,
} from "../config/ocrRegistry.ts";
import { errorResponse, sanitizeErrorMessage } from "../utils/error.ts";
@@ -182,6 +183,16 @@ export async function handleOcr({
);
}
if (
providerId === VERTEX_DEEPSEEK_OCR_PROVIDER_ID &&
modelId === VERTEX_DEEPSEEK_RETIRED_MODEL_ID
) {
return errorResponse(
400,
`Model "${VERTEX_DEEPSEEK_RETIRED_MODEL_ID}" was retired by Google on 2026-10-21. Self-deploy DeepSeek-OCR on Vertex Model Garden and pass its model id with the dedicated endpoint URL.`
);
}
// accessToken wins when both are present: providers like vertex-deepseek-ocr resolve a
// short-lived OAuth token from a Service Account JSON apiKey (see resolveVertexOcrAccessToken
// in src/app/api/v1/ocr/route.ts) while keeping the original apiKey around for other

View File

@@ -78,7 +78,7 @@ test("azure DI maps base64/image_url documents to base64Source/urlSource", () =>
// URL/body/response shapes verified against the upstream reference
// (litellm/llms/vertex_ai/ocr/deepseek_transformation.py): the endpoint is the
// generic Vertex "openapi/chat/completions" partner endpoint, the model id is
// prefixed with "deepseek-ai/", and the OCR document is sent as an
// sent as supplied (no forced prefix, #20423), and the OCR document is sent as an
// OpenAI-chat-shaped image_url content part.
test("vertex-deepseek-ocr resolves its own transformation (not the passthrough)", () => {
@@ -96,7 +96,7 @@ test("vertex-deepseek-ocr builds an OpenAI-chat-shaped request against the resol
"https://aiplatform.googleapis.com/v1/projects/proj-1/locations/us-central1/endpoints/openapi/chat/completions",
token: "ya29.mock",
body: { document: { type: "image_url", image_url: "https://x/y.png" } },
modelId: "deepseek-ocr-maas",
modelId: "my-deployed-ocr",
});
assert.equal(
url,
@@ -105,7 +105,7 @@ test("vertex-deepseek-ocr builds an OpenAI-chat-shaped request against the resol
assert.equal(init.method, "POST");
assert.equal((init.headers as Record<string, string>).Authorization, "Bearer ya29.mock");
const sent = JSON.parse(String(init.body));
assert.equal(sent.model, "deepseek-ai/deepseek-ocr-maas");
assert.equal(sent.model, "my-deployed-ocr");
assert.deepEqual(sent.messages, [
{ role: "user", content: [{ type: "image_url", image_url: "https://x/y.png" }] },
]);
@@ -118,7 +118,7 @@ test("vertex-deepseek-ocr maps a document_url document to the same image_url con
"https://aiplatform.googleapis.com/v1/projects/p/locations/us-central1/endpoints/openapi/chat/completions",
token: "t",
body: { document: { type: "document_url", document_url: "https://x/d.pdf" } },
modelId: "deepseek-ocr-maas",
modelId: "my-deployed-ocr",
});
const sent = JSON.parse(String(init.body));
assert.deepEqual(sent.messages[0].content, [{ type: "image_url", image_url: "https://x/d.pdf" }]);

View File

@@ -0,0 +1,61 @@
import test from "node:test";
import assert from "node:assert/strict";
import {
getAllOcrModels,
getOcrProvider,
parseOcrModel,
VERTEX_DEEPSEEK_RETIRED_MODEL_ID,
} from "../../open-sse/config/ocrRegistry.ts";
import { handleOcr } from "../../open-sse/handlers/ocr.ts";
// Vertex AI retired the managed deepseek-ocr-maas model on 2026-10-21 (#20423).
const RETIRED = "deepseek-ocr-maas";
const credentials = {
apiKey: "tok",
baseUrl: "https://example.test/v1/endpoints/openapi/chat/completions",
};
const okFetch = (capture: { model?: string; calls: number }) =>
(async (_url: string, init: { body: string }) => {
capture.calls++;
capture.model = JSON.parse(init.body).model;
return new Response(JSON.stringify({ choices: [{ message: { content: "x" } }] }), {
status: 200,
});
}) as unknown as typeof fetch;
test("#20423: vertex-deepseek-ocr no longer advertises the retired model", () => {
assert.equal(VERTEX_DEEPSEEK_RETIRED_MODEL_ID, RETIRED);
const ids = getOcrProvider("vertex-deepseek-ocr")?.models.map((m) => m.id) ?? [];
assert.ok(!ids.includes(RETIRED));
assert.ok(!getAllOcrModels().some((m) => m.id === `vertex-deepseek-ocr/${RETIRED}`));
assert.equal(parseOcrModel(RETIRED).provider, null);
});
test("#20423: the retired model id is rejected with 400 and never sent upstream", async () => {
const cap = { calls: 0 } as { model?: string; calls: number };
const res = await handleOcr({
body: {
model: `vertex-deepseek-ocr/${RETIRED}`,
document: { type: "document_url", document_url: "gs://b/x.pdf" },
},
credentials,
fetchImpl: okFetch(cap),
});
assert.equal(res.status, 400);
assert.equal(cap.calls, 0);
});
test("#20423: a self-deployed model id is sent as supplied, without a forced deepseek-ai/ prefix", async () => {
const cap = { calls: 0 } as { model?: string; calls: number };
const res = await handleOcr({
body: {
model: "vertex-deepseek-ocr/my-deployed-ocr",
document: { type: "document_url", document_url: "gs://b/x.pdf" },
},
credentials,
fetchImpl: okFetch(cap),
});
assert.equal(res.status, 200);
assert.equal(cap.model, "my-deployed-ocr");
});