Skip to content

Latest commit

 

History

History
506 lines (336 loc) · 40.8 KB

File metadata and controls

506 lines (336 loc) · 40.8 KB

Workflows.Deployments

Overview

Available Operations

list_deployments

List Deployments

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.list_deployments(active_only=True, order="desc")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
active_only Optional[bool] N/A
is_hardened OptionalNullable[bool] Filter deployments by hardened status
workflow_name OptionalNullable[str] N/A
search OptionalNullable[str] Filter deployments by name or ID prefix
order_by OptionalNullable[models.ListDeploymentsV1WorkflowsDeploymentsGetOrderBy] Field to sort by. When omitted, active and managed deployments are grouped first, then sorted by created_at. When set, results are sorted purely by the specified field with no grouping.
order Optional[models.ListDeploymentsV1WorkflowsDeploymentsGetOrder] Sort direction. Applied to order_by when set, or within each activity group when omitted.
limit OptionalNullable[int] Maximum number of deployments to return
cursor OptionalNullable[str] Cursor from a previous response for pagination
workspace_id OptionalNullable[str] Workspace ID to scope the request to. Defaults to the caller's context.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeploymentListResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

create_deployment

Create Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.create_deployment(name="<value>", spec={
        "github_url": "https://ugly-parade.com",
    }, hardened=False)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
spec models.DeploymentWorkerSpecInput ✔️ N/A
resources OptionalNullable[models.DeploymentResourceConfig] N/A
hardened Optional[bool] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ManagedDeploymentResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update_deployment

Update Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.update_deployment(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
spec OptionalNullable[models.WorkflowsWorkerSpecUpdate] N/A
resources OptionalNullable[models.DeploymentResourceConfigUpdate] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ManagedDeploymentResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

delete_deployment

Delete Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.delete_deployment(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ManagedDeploymentResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get_deployment

Get Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.get_deployment(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
workflow_name OptionalNullable[str] Scope serving status to this workflow
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeploymentDetailResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

stop_deployment

Stop Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.stop_deployment(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ManagedDeploymentResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

start_deployment

Start Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.start_deployment(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ManagedDeploymentResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

restart_deployment

Restart Deployment

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.restart_deployment(name="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ManagedDeploymentResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

list_deployment_workers

List Deployment Workers

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.list_deployment_workers(name="<value>", limit=50)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
worker_status OptionalNullable[models.WorkerStatus] Filter by worker activity. active=only active, inactive=only inactive, None=no filter
limit Optional[int] Maximum number of workers to return
cursor OptionalNullable[str] Cursor from a previous response's next_cursor. Resend worker_status unchanged alongside it.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeploymentWorkerListResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get_deployment_logs

Retrieve logs for a deployment (across all of its workers).

Use after/before/order on the first request to set the time range and sort order; for the next pages pass the cursor from the previous response (it remembers the range and order).

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.get_deployment_logs(name="<value>", order="asc", limit=50)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
worker_name OptionalNullable[str] Filter logs by worker name
workflow_name OptionalNullable[str] Filter logs by workflow name
after date Only return logs at or after this timestamp
before date Only return logs before this timestamp
order Optional[models.GetDeploymentLogsOrder] First-page sort order: 'asc' (oldest first) or 'desc'. Ignored when cursor is set.
cursor OptionalNullable[str] Pagination cursor from a previous response's next_cursor; carries the window and order
limit Optional[int] Maximum number of logs to return
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeploymentLogSearchResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

stream_deployment_logs

Stream logs for a deployment (all of its workers) via SSE.

Resume cursor comes from the Last-Event-ID header or last_event_id query param (header wins) and takes precedence over after; omit all to tail from the deployment start.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.workflows.deployments.stream_deployment_logs(name="<value>")

    with res as event_stream:
        for event in event_stream:
            # handle event
            print(event, flush=True)

Parameters

Parameter Type Required Description
name str ✔️ N/A
worker_name OptionalNullable[str] Filter logs by worker name
workflow_name OptionalNullable[str] Filter logs by workflow name
after date Start a fresh stream at this timestamp (ignored when resuming via last_event_id)
last_event_id OptionalNullable[str] Resume from this cursor (a prior response's SSE id)
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

Union[eventstreaming.EventStream[models.StreamDeploymentLogsResponseBody], eventstreaming.EventStreamAsync[models.StreamDeploymentLogsResponseBody]]

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*