Skip to content

add wrapEmbeddingModel to allow overwriting dimensions #7947

Description

@zirkelc

Description

I would like to request a wrapEmbeddingModel function similar to the existing wrapLanguageModel function to allow overwriting the dimensions for an embedding model:

export const openai = customProvider({
  embeddingModels: {
    'text-embedding-3-large': wrapEmbeddingModel({
      model: openai('text-embedding-3-large'),
      middleware: defaultSettingsMiddleware({
        settings: {
          providerOptions: {
            openai: {
              dimensions: 1536
            },
          },
        },
      }),
    }),
  },
});

AI SDK Version

No response

Activity

  1. added
    feature
    ai/core
    and removed on Aug 11, 2025
  2. changed the title [-][Feature] add `wrapEmbeddingModel` to allow overwriting dimensions[/-] [+]add `wrapEmbeddingModel` to allow overwriting dimensions[/+] on Aug 11, 2025
  3. added
    ai/provider
    provider/openai
    on Oct 15, 2025
  4. 0xlakshan commented on Oct 16, 2025

    @0xlakshan
    Contributor

    Hi @gr2m , This pattern should work for OpenAI and other embedding models as well, since it uses embeddingModelV3 shared base property providerOptions that directly bind properties to the specific model.

    /**
    Additional provider-specific options. They are passed through
    to the provider from the AI SDK and enable provider-specific
    functionality that can be fully encapsulated in the provider.
    */
    providerOptions?: SharedV3ProviderOptions;

    And in here any custom provider specific options like dimensions and classificationTypes are bound through params, and doTransform.

    async function doTransform({
    params,
    }: {
    params: EmbeddingModelCallOptions<string>;
    }) {
    return transformParams ? await transformParams({ params, model }) : params;
    }

    return {
    specificationVersion: 'v3',
    provider: providerId ?? overrideProvider?.({ model }) ?? model.provider,
    modelId: modelId ?? overrideModelId?.({ model }) ?? model.modelId,
    maxEmbeddingsPerCall:
    overrideMaxEmbeddingsPerCall?.({ model }) ?? model.maxEmbeddingsPerCall,
    supportsParallelCalls:
    overrideSupportsParallelCalls?.({ model }) ?? model.supportsParallelCalls,
    async doEmbed(
    params: EmbeddingModelCallOptions<string>,
    ): Promise<Awaited<ReturnType<EmbeddingModelV3<string>['doEmbed']>>> {
    const transformedParams = await doTransform({ params });
    const doEmbed = async () => model.doEmbed(transformedParams);
    return wrapEmbed
    ? wrapEmbed({
    doEmbed,
    params: transformedParams,
    model,
    })
    : doEmbed();
    },
    };
    };

  5. added a commit that references this issue on Oct 28, 2025
  6. lgrammel commented on Jul 22, 2026

    @lgrammel
    Collaborator

    Identify issue type

    Identified as Feature
    Confidence: High

    Rationale

    This is an API expansion and ergonomics request for embedding-model middleware, not a report of broken existing behavior.

    Evidence

    • The issue requests a new wrapEmbeddingModel API analogous to wrapLanguageModel.
    • The intended capability is to apply default provider options such as OpenAI embedding dimensions.
    • The comment references an embedding middleware implementation and shared providerOptions, but does not report a concrete failure of documented behavior.
  7. added theissue type on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/coreai/providerfeaturemerged-mainprovider/openaitask-identify-issue-type-done

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions