CreateConnection

Updated at:

Creates a connection to link PAI cloud services with your models, databases, and other services. This is useful for scenarios such as LangStudio and multimodal dataset retrieval.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

paiworkspace:CreateConnection

create

*All Resource

*

None None

Request syntax

POST /api/v1/connections HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body, which contains the parameters required to create the connection.

Accessibility

string

No

The visibility of the workspace. The default value is PRIVATE.

Valid values:

  • PUBLIC :

    Visible to all users in this workspace.

  • PRIVATE :

    Visible only to you and administrators in this workspace.

PRIVATE

Configs

object

Yes

Configuration properties for the connection, provided as key-value pairs. The required keys depend on the connection type. For details, see the supplementary parameter information.

string

No

The value of a configuration property for the connection.

6379

ConnectionName

string

Yes

The name of the connection.

llm-connection

ConnectionType

string

No

The type of the connection.

Valid values:

  • ElasticsearchConnection :

    Elasticsearch connection

  • MilvusConnection :

    Milvus connection

  • OpenSearchConnection :

    OpenSearch connection

  • HologresConnection :

    Hologres connection

  • DashScopeConnection :

    Alibaba Cloud Model Studio service

  • LindormConnection :

    Lindorm connection

  • RDSConnection :

    RDS connection

  • OpenLLMConnection :

    Generic LLM model connection

  • CustomConnection :

    Custom connection

DashScopeConnection

Description

string

No

The description of the connection.

开源大模型服务连接。

Secrets

object

No

Sensitive connection properties that require encryption, such as database credentials or an API key for a model service.

string

No

The value of an encrypted connection property.

Dsjk***hsl01

WorkspaceId

string

No

The ID of the workspace. To get this ID, call the ListWorkspaces operation.

123**45

ResourceMeta

object

No

Resource metadata for the connection. This parameter is typically used for database connection types.

InstanceName

string

No

The instance name.

测试实例。

InstanceId

string

No

The instance ID.

ld-uf69****9nqjjes

Extra

string

No

Additional configuration information.

{"vpcId":"vpc-xxxx"}

Models

array<object>

No

A list of models. This parameter applies to model service connections.

object

No

A model.

Model

string

No

The model identifier. This value corresponds to the model parameter in an OpenAI API request.

model_001

DisplayName

string

No

The display name of the model.

语言模型。

ModelType

string

No

The model type.

Valid values:

  • Embedding :

    Embedding model

  • LLM :

    LLM

  • ReRank :

    ReRank model

LLM

ToolCall

boolean

No

Specifies whether the model supports tool calling.

Valid values:

  • true :

    The model supports tool calling.

  • false :

    The model does not support tool calling.

true

SupportReasoning

boolean

No

Specifies whether the model supports deep reasoning and can output the reasoning process as reasoning_content.

Valid values:

  • true :

    The model supports deep reasoning.

  • false :

    The model does not support deep reasoning.

true

SupportResponseSchema

boolean

No

Specifies whether the model supports structured output in the OpenAI API's JSON Schema format.

Valid values:

  • true :

    The model supports structured output.

  • false :

    The model does not support structured output.

true

SupportVision

boolean

No

Specifies whether the model supports visual understanding.

Valid values:

  • true :

    The model supports visual understanding.

  • false :

    The model does not support visual understanding.

false

MaxModelLength

integer

No

The context length.

4096

The Configs and Secrets formats vary for each connection type:

  • DashScopeConnection/OpenLLMConnection

{
    "Secrets": {
        "api_key": "xxx"
    },
    "Configs": {
        "base_url": "cn-hangzhou.aigc.aliyuncs.com/api/v1/services/xxx"
    }
}
  • OpenSearchConnection/LindormConnection/ElasticsearchConnection

{
    "Secrets": {
        "password": "xxx"
    },
    "Configs": {
        "uri": "xxx",
        "username": "xxx"
    }
}

  • MilvusConnection

{
    "Secrets": {
        "password": "xxx"
    },
    "Configs": {
        "uri": "xxx",
        "username": "xxx"
    }
}
  • HologresConnection

{
    "Secrets": {
        "password": "xxx"
    },
    "Configs": {
        "database": "xx",
        "port": "xx",
        "host": "xx",
        "user": "xx"
    }
}
  • RDSConnection

{
    "Secrets": {
        "password": "xxx"
    },
    "Configs": {
        "database": "xxx",
        "port": "xxx",
        "host": "xxx",
        "type": "db_type",
        "username": "xxx"
    }
}
  • CustomConnection

Uses a custom format.

Response elements

Element

Type

Description

Example

object

The response data.

RequestId

string

The request ID.

5A14FA81-DD4E-******-6343FE44B941

ConnectionId

string

The connection ID.

conn-pai9m***mi47

Examples

Success response

JSON format

{
  "RequestId": "5A14FA81-DD4E-******-6343FE44B941",
  "ConnectionId": "conn-pai9m***mi47"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.