> ## 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.

# Resources

> Complete client surface reference for the Hexel Python SDK.

This page is the complete reference for every client method in the Python SDK.

The `Hexel` client exposes sub-clients for each product area. This page lists every namespace and method.

## Client

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

client = Hexel(
    api_key="YOUR_API_KEY",          # or client_id / client_secret
    timeout=30.0,                     # request timeout in seconds
)
```

## Compute

| Client                    | Methods                                                          |
| ------------------------- | ---------------------------------------------------------------- |
| `client.compute.sandbox`  | `create`, `list`, `get`, `execute`, `renew`, `release`, `delete` |
| `client.compute.agent`    | `register`, `list`, `get`, `update`, `delete`, `search`          |
| `client.compute.instance` | `list`, `get`, `stop`, `redeploy`, `delete`                      |

<Warning>
  There is no `instance.deploy()` method in the SDK. Deploy instances via the REST API (`POST /compute/v1/agents/{agent_id}/instances`) or the `hexel` CLI (`hexel compute instance deploy <agent-id>`).
</Warning>

```python theme={"dark"}
sandbox = client.compute.sandbox.create(tier="standard")
agent = client.compute.agent.register(name="a", image="ghcr.io/org/a:v1")

# Manage instances (deploy via CLI or REST first)
instances = client.compute.instance.list(agent_id=agent["id"])
client.compute.instance.stop(instances[0]["id"])
```

## Orchestration

| Client                         | Methods                                               |
| ------------------------------ | ----------------------------------------------------- |
| `client.orchestrator.task`     | `create`, `list`, `get`, `cancel`, `replay`, `stream` |
| `client.orchestrator.fleet`    | `list`, `get`                                         |
| `client.orchestrator.approval` | `list`, `get`, `review`                               |
| `client.orchestrator.policy`   | `list`, `get`, `evaluate`                             |
| `client.orchestrator.tools`    | `list`, `get`, `execute`, `bind`, `batch`             |

```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 the backlog",
)
client.orchestrator.approval.review("YOUR_APPROVAL_ID", decision="approve")
```

## Tools (Tool Gateway)

The top-level `client.tools` namespace provides full Tool Gateway access.

| Method                                                      | Description                                 |
| ----------------------------------------------------------- | ------------------------------------------- |
| `list_toolkits()`                                           | List available toolkits.                    |
| `get_toolkit(slug)`                                         | Get a single toolkit by slug.               |
| `list_tools(toolkit=...)`                                   | List tools, optionally filtered by toolkit. |
| `get_tool(slug)`                                            | Get a single tool by slug.                  |
| `discover_tools(scope=...)`                                 | Discover tools available in a scope.        |
| `execute(tool_slug, input, mode, credentials, webhook_url)` | Execute a tool (sync, async, or batch).     |
| `batch(executions)`                                         | Execute multiple tools in one call.         |
| `preflight(tool_slug, input)`                               | Validate inputs without executing.          |
| `get_call(call_id)`                                         | Fetch an async execution result.            |

## Agent runtime

`client.runtime` provides helpers for building agent applications that run on Hexel Compute.

## LLM instrumentation

Auto-instrument OpenAI and Anthropic calls for telemetry:

```python theme={"dark"}
from hexel.instrument import init, start_request, finish_request

init()  # Call once at startup

start_request()
# ... your LLM calls ...
telemetry = finish_request()
```

## Streaming

The SDK streams in two places:

* **Task events** — iterate `client.orchestrator.task.stream(task_id)` to receive [SSE events](/docs/orchestration/streaming-and-replay) (`task.state`, `runtime.delta`, `task.complete`, …) as a task runs.
* **Sandbox execution** — `client.compute.sandbox.execute(...)` runs code or commands and returns the collected `{ "output", "status" }`.

```python theme={"dark"}
for event in client.orchestrator.task.stream(task["id"]):
    print(event["type"], event.get("data"))
```

## Testing

For automated tests, exercise the SDK against real sandboxes (allocate, execute, release) or stub the HTTP layer in your own test suite. Use a separate API key scoped to a non-production [environment](/docs/iam/environments) so tests never touch production resources.

```python theme={"dark"}
# Use a test-environment key in CI
client = Hexel(api_key=os.environ["HEXEL_TEST_API_KEY"])
sandbox = client.compute.sandbox.create(tier="micro")
try:
    result = client.compute.sandbox.execute(sandbox["sandbox_id"], code="print('ok')", language="python")
    assert "ok" in result["output"]
finally:
    client.compute.sandbox.release(sandbox["sandbox_id"])
```

## Next steps

<CardGroup cols={2}>
  <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>
</CardGroup>
