Skip to main content
Weaviate Docs (migrated from docs.weaviate.io) Docs

Search documentation

Type to search this documentation.

On this pageOverview

Text Embeddings

Weaviate's integration with Morph's API lets you access Morph-hosted embedding models directly from Weaviate.

Configure a Weaviate vector index to use a Morph embedding model, and Weaviate generates embeddings for imports and searches automatically using your Morph API key. This is the vectorizer.

At import time, Weaviate generates text object embeddings and saves them into the index. For vector and hybrid search operations, Weaviate converts text queries into embeddings.

Embedding integration illustration

Your Weaviate instance must have the text2vec-morph module enabled. The module is available in Weaviate v1.32.6 and later.

For Weaviate Cloud (WCD) users

This integration is enabled by default on Weaviate Cloud (WCD) instances.

For self-hosted users

You must provide a Morph API key to Weaviate for this integration. Generate one in the Morph dashboard and supply it via one of:

  • Set the MORPH_APIKEY environment variable on the Weaviate server.
  • Provide the X-Openai-Api-Key header at request time, as shown below.

Weaviate builds Morph requests with its OpenAI-compatible client, so the request header is X-Openai-Api-Key. There is no Morph-specific header. A key provided in the header takes precedence over the server environment variable.

Python
# Recommended: save sensitive data as environment variables
morph_key = os.getenv("MORPH_APIKEY")
JavaScript/TypeScript
const morphApiKey = process.env.MORPH_APIKEY || '';  // Replace with your inference API key
Java
// Best practice: store your credentials in environment variablesString weaviateUrl = System.getenv("WEAVIATE_URL");String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");String morphApiKey = System.getenv("MORPH_APIKEY");// Morph requests are built by Weaviate's OpenAI-compatible client,// so the Morph key is supplied under the OpenAI header name.WeaviateClient client = WeaviateClient.connectToWeaviateCloud(    weaviateUrl,    weaviateApiKey,    config -> config.setHeaders(Map.of("X-Openai-Api-Key", morphApiKey)));System.out.println(client.isReady()); // Should print: `True`client.close(); // Free up resources
C#
// Best practice: store your credentials in environment variablesstring weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");string morphApiKey = Environment.GetEnvironmentVariable("MORPH_APIKEY");// Morph requests are built by Weaviate's OpenAI-compatible client,// so the Morph key is supplied under the OpenAI header name.using var client = await Connect.Cloud(    weaviateUrl,    weaviateApiKey,    headers: new Dictionary<string, string>    {        ["X-Openai-Api-Key"] = morphApiKey,    });var meta = await client.GetMeta();Console.WriteLine(meta.Version);

Configure a Weaviate index to use a Morph embedding model by setting the vectorizer as follows:

Python
from weaviate.classes.config import Configureclient.collections.create(    "DemoCollection",    vector_config=[        Configure.Vectors.text2vec_morph(            name="title_vector",            source_properties=["title"],        )    ],    # Additional parameters not shown)
JavaScript/TypeScript
await client.collections.create({  name: 'DemoCollection',  properties: [    {      name: 'title',      dataType: 'text' as const,    },  ],  vectorizers: [    weaviate.configure.vectors.text2VecMorph({      name: 'title_vector',      sourceProperties: ['title'],    }),  ],  // Additional parameters not shown});
Java
client.collections.create("DemoCollection",
    col -> col
        .vectorConfig(
            VectorConfig.text2vecMorph("title_vector", c -> c.sourceProperties("title")))
        .properties(Property.text("title"), Property.text("description")));
C#
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "DemoCollection",
        VectorConfig = new VectorConfigList
        {
            Configure.Vector(
                "title_vector",
                v => v.Text2VecMorph(),
                sourceProperties: ["title"]
            ),
        },
        Properties = [Property.Text("title"), Property.Text("description")],
    }
);
Vectorization behavior

Weaviate follows the collection configuration and a set of predetermined rules to vectorize objects.

Unless specified otherwise in the collection definition, the default behavior is to:

  • Only vectorize properties that use the text or text[] data type (unless skipped)
  • Sort properties in alphabetical (a-z) order before concatenating values
  • If vectorizePropertyName is true (false by default) prepend the property name to each property value
  • Join the (prepended) property values with spaces
  • Prepend the class name (unless vectorizeClassName is false)
  • Convert the produced string to lowercase
  • model: The Morph model id. Defaults to morph-embedding-v3.
  • baseURL: The base URL prefix that requests are sent to. Any existing path is preserved when endpoint is appended. Defaults to https://api.morphllm.com.
  • endpoint: The API path that Weaviate appends to the base URL. Defaults to /v1/embeddings. Set it if the service you target uses a different path.

For how Weaviate combines baseURL and endpoint into a request URL, see Header parameters.

Weaviate stores baseURL and model in the collection configuration even when you do not set them, because the module supplies a default for each. endpoint is different: it appears in the stored configuration only when you set it explicitly. If you read a collection back and see no endpoint, the default path applies.

No dimensions parameter is sent, so the embedding dimension is always the model's native size.

The following examples set the Morph-specific options. Client libraries do not all expose the same options, so each example shows what that client supports.

Python
from weaviate.classes.config import Configureclient.collections.create(    "DemoCollection",    vector_config=[        Configure.Vectors.text2vec_morph(            name="title_vector",            source_properties=["title"],            model="morph-embedding-v3",            base_url="https://api.morphllm.com",  # Base URL; an existing path is preserved            endpoint="/v1/embeddings",            # Path appended to the base URL        )    ],    # Additional parameters not shown)
JavaScript/TypeScript
await client.collections.create({  name: 'DemoCollection',  properties: [    {      name: 'title',      dataType: 'text' as const,    },  ],  vectorizers: [    weaviate.configure.vectors.text2VecMorph({      name: 'title_vector',      sourceProperties: ['title'],      model: 'morph-embedding-v3',      baseURL: 'https://api.morphllm.com',  // Base URL; an existing path is preserved    }),  ],  // Additional parameters not shown});
Java
client.collections.create("DemoCollection",
    col -> col
        .vectorConfig(VectorConfig.text2vecMorph("title_vector",
            c -> c.sourceProperties("title")
                .model("morph-embedding-v3")
                .baseUrl("https://api.morphllm.com") // Base URL; an existing path is preserved
                .endpoint("/v1/embeddings"))) // Path appended to the base URL
        .properties(Property.text("title"), Property.text("description")));
C#
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "DemoCollection",
        VectorConfig = new VectorConfigList
        {
            Configure.Vector(
                "title_vector",
                v => v.Text2VecMorph(model: "morph-embedding-v3"),
                sourceProperties: ["title"]
            ),
        },
        Properties = [Property.Text("title"), Property.Text("description")],
    }
);

You can provide the API key and the base URL at runtime through headers. Headers provided at request time take precedence over the collection configuration and over the server environment variable:

  • X-Openai-Api-Key: The Morph API key for this request.
  • X-Openai-Baseurl: The base URL to use instead of the default.

Provide the headers as shown in the API credentials examples above.

After configuring the vectorizer, import data into Weaviate. Weaviate generates embeddings for text objects using the configured model.

Once the vectorizer is configured, Weaviate performs vector and hybrid searches using the specified Morph model.

Embedding integration at search illustration

When you perform a vector search, Weaviate converts the text query into an embedding using the configured Morph model and returns the most similar objects.

When you perform a hybrid search, Weaviate fuses keyword and vector ranking. The text query is embedded with the configured Morph model; the keyword side uses Weaviate's inverted index.

Weaviate does not restrict which model id you can set, so any model the Morph API accepts can be used. morph-embedding-v3 is the default. Morph's list models endpoint returns the model ids your key can use. Check it before you rely on a model id, as availability and dimensions can change.

Once the vectorizer is configured, Weaviate handles model inference transparently. The standard client library how-tos apply unchanged. No Morph-specific code is required at query or import time beyond the configuration shown above.

Have a question or feedback? Here's how to reach us.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu