> ## Documentation Index
> Fetch the complete documentation index at: https://vastai-80aa3a82-auto-cli-sdk-preview-pr-398.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# VastAI.update_instance

Update/recreate an instance from a new/updated template.

## Signature

```python theme={null}
VastAI.update_instance(
    id: int,
    template_id: Optional[int] = None,
    template_hash_id: Optional[str] = None,
    image: Optional[str] = None,
    args: Optional[str] = None,
    env: Optional[loads] = None,
    onstart: Optional[str] = None
) -> dict
```

## Parameters

<ParamField path="id" type="int" required>
  id of instance to update
</ParamField>

<ParamField path="template_id" type="Optional[int]">
  new template ID to associate with the instance
</ParamField>

<ParamField path="template_hash_id" type="Optional[str]">
  new template hash ID to associate with the instance
</ParamField>

<ParamField path="image" type="Optional[str]">
  new image UUID for the instance
</ParamField>

<ParamField path="args" type="Optional[str]">
  new arguments for the instance
</ParamField>

<ParamField path="env" type="Optional[loads]">
  new environment variables for the instance
</ParamField>

<ParamField path="onstart" type="Optional[str]">
  new onstart script for the instance
</ParamField>

## Returns

`dict`

## Example

```python theme={null}
from vastai import VastAI

client = VastAI(api_key="YOUR_API_KEY")
result = client.update_instance(id=12345)
print(result)
```
