# Calling the Seldon API with Seldon Python client

We provide an example python client for calling the API using REST or gRPC for internal microservice testing or for calling the public external API.

Examples of its use can be found in most of the [Seldon Core examples](https://github.com/SeldonIO/seldon-core/blob/master/docs-gb/wrappers/examples/notebooks.html).

To use the client simply create an instance with settings for your use case, for example:

```python
from seldon_core.seldon_client import SeldonClient
sc = SeldonClient(deployment_name="mymodel",namespace="seldon",gateway_endpoint="localhost:8003",gateway="ambassador")
```

In the above we set our deployment\_name to "mymodel" and the namespace to "seldon". For the full set of parameters see [here](https://github.com/SeldonIO/seldon-core/blob/master/docs-gb/wrappers/python/api/seldon_core.html#seldon_core.seldon_client.SeldonClient).

To make a REST call with a random payload:

```python
r = sc.predict(transport="rest")
```

To make a gRPC call with random payload:

```python
r = sc.predict(transport="grpc")
```

The default return type is the protobuf of type "SeldonMessage", but you can also choose to return a JSON dictionary which could make it easier for interacting with the internal data. You can do this by passing the kwarg `client_return_type` with the value `dict` (default value is `proto`) when either initialising your Seldon Client or when sending a predict request. For example:

```python
sc = SeldonClient(..., client_return_type="dict")
```

Or alternatively you can pass it when sending the request to override your default parameter:

```python
sc = SeldonClient(..., client_return_type="proto")

sc.predict(..., client_return_type="dict") # Here we override it
```

## Advanced Examples

* [SSL and Authentication](https://github.com/SeldonIO/seldon-core/blob/master/docs-gb/wrappers/examples/seldon_client.html)


---

# 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.seldon.ai/seldon-core-1/configuration/wrappers-and-sdks/python-language-wrapper/seldon_client.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.
