Create and Manage Compute Resources¶
Use the AI Studio SDK to create compute resources and use the server-returned resource ID to read metrics or perform lifecycle operations. Creation requires a name, spec ID, CPU, and memory; other configurations can be provided as needed.
Task workflow¶
Select an available spec and prepare resource name, CPU, and memory.
Create the resource and save the server-returned resource ID.
Use that ID to read details, runtime records, or metrics, or submit update, suspend, resume, or retry operations.
Read preflight delete check results before deletion to confirm impact.
Prerequisites¶
Required item |
Role on this page |
|---|---|
Client context bound to target workspace |
Identify the workspace owning the resource. |
Available spec ID |
Select resource specifications. |
Name, CPU, and memory |
Mandatory inputs when creating the resource. |
Optional replica counts and configurations |
Adjust resource policies as needed. |
Create resources and read metrics¶
The creation call returns the resource handle and its bound resource metadata. Use the same object when querying metrics; returning metrics does not imply that the resource has met all operational prerequisites.
compute, _, err := workspace.CreateComputeResource(
ctx, computeName, specID, cpu, memoryGB,
sdk.WithComputeMinReplicas(minReplicas),
sdk.WithComputeMaxReplicas(maxReplicas),
)
if err != nil {
return err
}
metrics, err := compute.Metrics(ctx)
if err != nil {
return err
}
suspended, err := compute.Suspend(ctx)
if err != nil {
return err
}
_ = metrics
_ = suspended
compute, created = workspace.create_compute_resource(
compute_name, spec_id, cpu, memory_gb,
sdk.with_compute_min_replicas(min_replicas),
sdk.with_compute_max_replicas(max_replicas),
)
metrics = compute.metrics()
suspended = compute.suspend()
Control resource lifecycle¶
Suspend, resume, and retry operations each return resource information. The return payload reflects the immediate outcome of that call; to verify downstream statuses, read resource details, runtime records, or metrics.
Limitations¶
Resource operations may disrupt running tasks or incur cost. Deletion preflight checks return current impact data and do not mean deletion is completed. Do not reuse the original resource handle after deletion; to verify final state, re-read or list the resources.
Next steps¶
For HTTP endpoints managing compute instances, refer to the compute resource endpoints in the API Reference.