# Run the Hybrid Runner

Once the Runner has been set up, it can be called and executed directly from via its provided API. This applies to both [Hybrid method 1: Automatic Wasm pull](/hybrid-runner/setup-the-hybrid-runner/hybrid-method-1-automatic-wasm-pull.md) and [Hybrid method 2: Manual Wasm mount](/hybrid-runner/setup-the-hybrid-runner/hybrid-method-2-manual-wasm-mount.md).

These are the following action breakdown.&#x20;

| Action         |                           | Supported Method(s)   |
| -------------- | ------------------------- | --------------------- |
| `/healthcheck` | Health check for runner   | Method 1 and Method 2 |
| `/execute`     | Execute payload via v3/v4 | Method 1 and Method 2 |
| `/upload`      | Upload Wasm to Runner     | Method 2              |

## **Run using curl**

1. Test the service using the `healthcheck` endpoint. You should receive the message `{"msg":"ok"}`.

   ```shellscript
   curl 'http://localhost:3000/healthcheck'
   ```
2. Execute a request similar to that in the [API Tester](/navigation/api-tester.md).

   * Note the change in the URI to `localhost:3000` and make sure to update `mytenant` in the URI to your tenant name.
   * See [Execute API (v3)](/spark-apis/execute-api/execute-api-v3.md) for more information on the [Execute API (v3)](/spark-apis/execute-api/execute-api-v3.md#request_data) and [Execute API (v3)](/spark-apis/execute-api/execute-api-v3.md#request_meta) structure and options.
     * Also see the [Hybrid Runner API reference](/hybrid-runner/hybrid-runner-api-reference.md) for alternative endpoints available from the runner.

   ```shellscript
   curl --location --request POST 'http://localhost:3000/mytenant/api/v3/execute' \
   --header 'Content-Type: application/json' \
   --data '{
       "request_data": {
           "inputs": { "value": 13 }
       },
       "request_meta": {
           "version_id": "c16d9b89-92c4-430f-a30e-9b04805fcb78",
           "call_purpose": "Online",
           "source_system": "Hybrid Runner"
       }
   }'
   ```

## Run using the Python SDK

The [Coherent Spark Python SDK](https://github.com/Coherent-Partners/spark-python-sdk/) supports interaction with the Hybrid Runner API, enabling you to deploy and manage a runner through Python.

If you have a hybrid deployment setup, you can leverage the Python SDK to interact with and manage the Hybrid Runner. The runner provides limited functionality compared to the full SaaS API, focusing on executing services in local or controlled environments. This capability is especially useful for scenarios where data privacy or on-premise processing is necessary.

### Initialize the Hybrid Runner client

To interact with the Hybrid Runner API, you need to initialize a client instance pointing to the runner’s base URL. The default base URL is `http://localhost:3000`, but you can configure it according to your environment. Authentication is optional and depends on your specific setup.

Here is an example of how to set up and connect to the Hybrid Runner using Python:

```python
import cspark.wasm as Hybrid

# Initialize the Hybrid Runner client
hybrid = Hybrid.Client(
    base_url='http://localhost:8080',  # Adjust the base URL as needed
    tenant='my-tenant',  # Replace with your tenant identifier
    token='open'  # Replace with your authentication token, if required
)

# Execute Spark services using the runner
try:
    with hybrid.services as s:
        response = s.execute('my-folder/my-service', inputs={'value': 42})
        print(response.data) # Do something upon successful execution
except Exception as e:
    print(e) # Apply graceful error handling
```

| Key        | Value                                                                    |
| ---------- | ------------------------------------------------------------------------ |
| `base_url` | Defines the address where your hybrid runner is accessible.              |
| `tenant`   | Represents the specific tenant under which the operations are conducted. |
| `token`    | Optional, used for authentication if your deployment requires it.        |

Ensure your deployment environment is configured to allow connections at the specified `base_url`, and that any necessary authentication is properly set up to match your security requirements.

With this setup, you can begin leveraging Python to interact with the hybrid runner, streamlining local execution and enabling efficient service management.

For more details, please visit the Python SDK [documentation](https://github.com/Coherent-Partners/spark-python-sdk/blob/main/docs/hybrid.md#upload-a-wasm-package).

## Run using the Node.js SDK

The [Coherent Spark Node.js SDK](https://www.npmjs.com/package/@cspark/wasm) provides a streamlined way to interact with the Hybrid Runner API for hybrid deployments, making it easy to execute services locally or in restricted environments.

### Install the `@cspark/wasm` package

```shellscript
npm install @cspark/wasm
# or
yarn add @cspark/wasm
```

> **Note**: `@cspark/wasm` is an extension of `@cspark/sdk` enabling support for the Hybrid Runner API.

### Initialize and configure the runner

To connect with the Hybrid Runner, you need to initialize a `HybridClient` that points to the base URL of the runner. By default, the base URL is `http://localhost:3000` and can be read as an environment variable `CSPARK_RUNNER_URL`.

You may choose to use authentication or not, depending on how your runner is configured.

```javascript
import Hybrid from '@cspark/wasm';

// Initialize the Hybrid Runner client
const hybrid = new Hybrid({ 
  baseUrl: 'http://localhost:8080',  // Adjust the base URL as needed
  tenant: 'my-tenant',  // Replace with your tenant identifier
  token: 'open'  // Replace with your authentication token, if required
});

// Execute Spark services using the runner
hybrid.services
  .execute('my-folder/my-service', { inputs: { value: 42 } })
  .then((response) => console.log(response.data))
  .catch(console.error);
```

With this setup, you can quickly deploy and run services via Node.js on your hybrid runner. For more information, [explore the documentation](https://github.com/Coherent-Partners/spark-ts-sdk/blob/main/packages/wasm/docs/readme.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherent.global/hybrid-runner/run-the-hybrid-runner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
