> ## Documentation Index
> Fetch the complete documentation index at: https://hexelstudio.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with the Hexel Python SDK in five minutes.

**What you'll accomplish:** by the end of this page you'll have initialized the client, run code in a sandbox, managed an agent instance, submitted an orchestration task, and executed a tool — the four operations you'll use most.

This quickstart covers the four things you will do most: run code in a sandbox, manage agent instances, submit an orchestration task, and execute a tool.

## Initialize

```python theme={"dark"}
from hexel import Hexel

client = Hexel(api_key="YOUR_API_KEY")
```

## Run code in a sandbox

```python theme={"dark"}
sandbox = client.compute.sandbox.create(tier="standard")

result = client.compute.sandbox.execute(
    sandbox["sandbox_id"],
    code="print('Hello from Hexel')",
    language="python",
)
print(result)

client.compute.sandbox.release(sandbox["sandbox_id"])
```

## Deploy an agent instance

Deploying is done via the REST API or the `hexel` CLI. The Python SDK manages instances after deployment.

<Tabs>
  <Tab title="CLI">
    ```bash theme={"dark"}
    hexel compute instance deploy YOUR_AGENT_ID --env-file .env
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={"dark"}
    curl -X POST https://api.hexelstudio.com/compute/v1/agents/YOUR_AGENT_ID/instances \
      -H "Authorization: Bearer $TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"env": {"MODEL": "gpt-4"}}'
    ```
  </Tab>
</Tabs>

Once deployed, manage instances with the SDK:

```python theme={"dark"}
# List running instances for an agent
instances = client.compute.instance.list(agent_id="YOUR_AGENT_ID")

# Get instance details
instance = client.compute.instance.get("YOUR_INSTANCE_ID")
print(instance["endpoint"])

# Redeploy with updated config
client.compute.instance.redeploy("YOUR_INSTANCE_ID")

# Stop an instance
client.compute.instance.stop("YOUR_INSTANCE_ID")
```

## Submit an orchestration task

```python theme={"dark"}
task = client.orchestrator.task.create(
    fleet_id="YOUR_FLEET_ID",
    environment_id="YOUR_ENVIRONMENT_ID",
    workspace_id="YOUR_WORKSPACE_ID",
    input="Summarize this week's support tickets",
)

# Stream progress
for event in client.orchestrator.task.stream(task["id"]):
    print(event["type"], event.get("data"))
```

## Execute a tool

```python theme={"dark"}
result = client.tools.execute(
    tool_slug="SLACK_POST_MESSAGE",
    input={"channel": "#alerts", "text": "Deploy complete"},
)
print(result)
```

## Next steps

<CardGroup cols={2}>
  <Card title="Resources" icon="cubes" href="/docs/sdks/python/resources">
    Every client and method.
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/docs/sdks/python/error-handling">
    Retries, timeouts, and errors.
  </Card>

  <Card title="Examples" icon="code" href="/docs/sdks/python/examples">
    End-to-end examples.
  </Card>

  <Card title="Authentication" icon="key" href="/docs/getting-started/authentication">
    Credentials and tokens.
  </Card>
</CardGroup>
