In AgentRun, a vector model, also known as an embedding model, transforms text into high-dimensional vectors. It is a fundamental component for core capabilities such as semantic similarity calculation, vector retrieval, and knowledge base recall.
Features
With Vector Model Management, you can:
-
Add and configure embedding models, such as Qwen's
text-embedding-v3. -
Connect to custom services that support third-party embedding model APIs compatible with the OpenAI specification.
-
Centrally manage multiple embedding models and switch between them as needed for different scenarios.
-
Directly reference models in Agent modules, such as the knowledge base and retrieval-augmented generation (RAG).
Procedure
Step 1: Go to the Vector Model Management page
-
Go to the AgentRun console. If this is your first time using the console, you must grant Service-Linked Role (SLR) authorization. In the dialog box that appears, click Confirm.
-
In the left-side navigation pane, choose Models and Tools > Model Management, and then select Vector Model.
Step 2: Add a model
-
Click Add Model.
-
In the dialog box that appears, API Model is selected by default.
Step 3: Fill in the basic information
-
Name (Required): Enter an easily recognizable name, such as
kb-embedding-cn. For clarity, include the service provider or model version in the name. -
Description (Optional): Briefly describe the model's purpose, such as "Semantic search for the Chinese knowledge base".
Step 4: Select a service provider
From the Service Provider drop-down list, select an option:
Qwen: Alibaba Cloud's official large model service. It provides multiple versions of text embedding models, such as text-embedding-v3.
Custom Service: Connect to any third-party embedding model API that is compatible with the OpenAI specification. This is suitable for private deployments or custom scenarios.
Vector models support custom providers by default. The AI Gateway option is not available for vector models.
Step 5: Configure the model
Qwen
-
API Endpoint configuration:
-
After you select Qwen, the system automatically populates the API destination. No changes are needed.
https://dashscope-intl.aliyuncs.com/compatible-mode/v1 -
In the Configure Specific Model area, select the required model versions. You can select multiple versions, but only one is used for API calls based on the configuration.
-
text-embedding-v1 -
text-embedding-v2 -
text-embedding-v3 -
text-embedding-v4
-
Custom service
-
VPC Configuration: If your model service is deployed in an Alibaba Cloud VPC, select the corresponding VPC, subnet, and security group to ensure network connectivity from AgentRun. If your service is deployed on the public network, leave this field empty.
-
API Destination: In the API Destination field, enter the service endpoint. This endpoint must provide a
/v1/embeddingsinterface that is compatible with the OpenAI specification. -
Enter a model name, such as
my-embedding-v1. You will use this name to reference the model in an Agent.
Step 6: Configure access credentials (optional)
Whether you need to configure credentials depends on your server-side authentication requirements. If your API calls require an Authorization: Bearer xxx header or a similar field, you must configure a credential. Otherwise, select "Do not use credentials".
Click Outbound: Access Third-Party Credentials to open the configuration panel. Select one of the following options:
-
Select Use Existing Credential (Recommended): This is suitable for scenarios where multiple services share the same credential for centralized key management. From the drop-down list, select an API key that you created in Credential Management. If no credentials are available, see Credential Management to add one.
-
Select API Key: The key is used only for the current model and is not saved to the global credential management. Enter the API key from the third-party service directly into the AccessKey field.
-
Do not use credentials: This is suitable for test or internal services that allow anonymous access.
Step 7: Create and validate the model
-
After you verify that the configuration is correct, click Create Model in the lower-right corner of the dialog box.
-
After the model is created, you are redirected to its management page. On the model's card, click Details to view information such as the model name, creation time, supported models, and service configuration.
-
Test the model: On the Details page, view the invocation examples and test the model using one of the following methods:
API
curl https://dashscope-intl.aliyuncs.com/compatible-mode/v1/embeddings \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "input": "The food was delicious and the waiter...", "model": "text-embedding-ada-002", "encoding_format": "float" }'Python SDK
from agentrun import ModelClient ms = ModelClient().get(name="model-9FIYil") result = ms.completions( messages=[{"role": "user", "content": "Write a poem praising AI"}], stream=True, ) for chunk in result: print(chunk.choices[0].delta.content, end="", flush=True)Node.js SDK
import OpenAI from "openai"; const openai = new OpenAI(); async function main() { const embedding = await openai.embeddings.create({ model: "text-embedding-ada-002", input: "The quick brown fox jumped over the lazy dog", encoding_format: "float", }); console.log(embedding); } main();