# Create Workflow

Use the AI Studio SDK to deploy a workflow definition to a specified workspace. The caller provides the workflow ID during deployment; upon successful deployment, a workflow reference bound to that ID is returned, which can subsequently be used to launch runs.

(sdk-ai-studio-workflow-deploy-flow)=
## Task workflow

Prepare the workspace, workflow name, DSL YAML, and workflow ID. Save the workflow reference after deployment submission; the return of the deployment request does not mean that the workflow has executed. When execution is required, launch a run using the same workflow ID on the execution page.

(sdk-ai-studio-workflow-deploy-prepare)=
## Prerequisites

| Required item | How to obtain | Role on this page |
| --- | --- | --- |
| Authenticated client and workspace ID | [Bind an existing workspace](../工作区管理/绑定工作区.md#sdk-ai-studio-resource-model-bind-workspace). | Determine the resource scope of deployment. |
| Workflow name, DSL YAML, and workflow ID | Provided by workflow designers and callers. | Create workflow definitions and define identifiers for future runs. |

This page only submits workflow definitions; it does not interpret DSL semantics or trigger runs.

(sdk-ai-studio-workflow-deploy-submit)=
## Submit deployment

The following example deploys a workflow and retains the returned workflow reference. The workflow ID must be provided by the caller; subsequent reads or runs continue using this same identifier.

:::::{tab-set}
:sync-group: sdk-language

::::{tab-item} Python
:sync: python

```python
import os

import moi_product_sdk as sdk

client = sdk.new_with_personal_access_token(
    os.environ["PRODUCT_API_BASE_URL"],
    os.environ["PRODUCT_API_KEY"],
)
workspace = client.workspace("<workspace-id>")
workflow, deployment = workspace.deploy_workflow(
    "<workflow-name>",
    "<workflow-dsl-yaml>",
    "<workflow-id>",
    sdk.with_workflow_description("<workflow-description>"),
)

print(workflow.id)
print(deployment)
```

::::

::::{tab-item} Go
:sync: go

```go
package main

import (
	"context"
	"fmt"
	"os"

	sdk "github.com/matrixorigin/matrixflow/sdk/go-sdk"
)

func main() {
	ctx := context.Background()
	client, err := sdk.NewWithPersonalAccessToken(
		os.Getenv("PRODUCT_API_BASE_URL"),
		os.Getenv("PRODUCT_API_KEY"),
	)
	if err != nil {
		panic(err)
	}
	workspace, err := client.Workspace("<workspace-id>")
	if err != nil {
		panic(err)
	}
	workflow, deployment, err := workspace.DeployWorkflow(
		ctx,
		"<workflow-name>",
		"<workflow-dsl-yaml>",
		"<workflow-id>",
		sdk.WithWorkflowDescription("<workflow-description>"),
	)
	if err != nil {
		panic(err)
	}

	fmt.Println(workflow.ID())
	fmt.Println(deployment)
}
```

::::

:::::

(sdk-ai-studio-workflow-deploy-next)=
## Next steps

The deployed workflow reference and workflow ID can be passed to [Run and track workflows](运行并跟踪工作流.md#sdk-ai-studio-workflow-run-start) to launch an execution. Prior to running, prepare runtime inputs according to the workflow's input schema.
