Skip to content

bug: vertex-ai embeddings drop dimensions (no mapping to parameters.outputDimensionality) #14311

In review

Description

@BrianTAllen

Current Behavior

For an OpenAI embeddings request sent to provider: vertex-ai, the request converter keeps only input and drops everything else, including dimensions (openai-embeddings-to-vertex-predict.lua#L32-L66). The :predict body is always {"instances": [...]}, so gemini-embedding-001 always returns its default 3072 dimensions whatever the client asks for.

Expected Behavior

dimensions should map to Vertex's parameters.outputDimensionality, so the client gets the size it asked for, as it does from OpenAI through the same gateway.

Error Logs

No error: the vector is the wrong size. Direct :predict calls to gemini-embedding-001 (locations/global):

Body Vector length
{"instances":[{"content":"red shirt"}]} 3072
{"instances":[{"content":"red shirt"}],"parameters":{"outputDimensionality":768}} 768

Through APISIX 3.21.0, {"model":"gemini-embedding-001","input":"red shirt","dimensions":768} returns 3072.

Steps to Reproduce

  1. Configure a vertex-ai instance on an embeddings route (for example provider_conf: {project_id: "<project>", region: us-central1}, auth: {gcp: {}}).
  2. POST {"model":"gemini-embedding-001","input":"red shirt","dimensions":768}.
  3. len(data[0].embedding) is 3072, not 768.

Environment

  • APISIX version: 3.21.0 (apache/apisix:3.21.0-debian image), standalone mode. The same code is on master at c157fcf.
  • OS: Debian container on macOS (Colima)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions