# Python client configuration

```python
from konduit.client import Client 

Client(
    timeout=60,
    input_data_format='NUMPY',
    output_data_format='NUMPY',
    input_names=['default'],
    output_names=['default'],
    host='http://localhost',
    port=None, 
    prediction_type=None
)
```

### Data formats

Data formats define how data is transported between the Client and the Konduit Serving instance. In addition to `JSON`, Konduit Serving also supports `NUMPY`, `ARROW`, `RAW` and `IMAGE`data formats. Specify data formats as strings.&#x20;

* `input_data_format` defines the data format of inputs sent to the server via the `predict()` method.
* `output_data_format`defines the data format returned by the API endpoint.

If you want to convert the result of your endpoint to another data format on return, change the `convert_to_format` attribute of the `Client` object:&#x20;

```python
client = Client(port=3226)
client.convert_to_format = "ARROW"
```

### Input and output names

Both the `input_names` and `output_names` arguments accept a list of strings. Input and output names are defined by the inputs and outputs to the first and last pipeline steps in the Konduit Serving pipeline configuration respectively.&#x20;

For `ModelStep`, input and output names should be configured when defining the model for training, or may need to be obtained by inspecting the model file. See the examples for details. &#x20;

For `PythonStep`, input names are defined in the `step()` method of a `PythonStep` object.

### Other arguments&#x20;

* `timeout`: Integer. Defaults to 60 (seconds).&#x20;
* `host`: String. If the model is hosted locally, the host should be specified as `http://localhost` (the default argument)&#x20;
* `port`: Integer.&#x20;

The arguments `output_data_format`, `input_data_format` and `prediction_type` are obtained from the server when the Client object is initialized. Refer to the [Server](https://serving.konduit.ai/0.1.0-snapshot/server/inference) documentation for details.&#x20;

### `.predict()`method

The `.predict()`method takes a dictionary with`input_names` as keys and the data inputs as values.&#x20;

## Example

Assume a Server object has been fully configured as `server`. Start the server:

```python
server.start()
```

Define a Client:

```python
client = Client(
    input_data_format='NUMPY',
    output_data_format="NUMPY",
    return_data_output_format='NUMPY',
    input_names=["input1"],
    host='http://localhost', 
    port=port
)
```

Request for a prediction:&#x20;

```python
client.predict({"input1": np.ones(5)})
server.stop()
```

## YAML configuration&#x20;

Refer to the [YAML configuration page](https://serving.konduit.ai/0.1.0-snapshot/yaml-configurations#client).&#x20;
