Skip to content

Use an OpenInference Service

Invoke the deployed endpoint with a request body that matches the function's input tensor schema.

payload = {
    "inputs": [
        {
            "name": "input-0",
            "shape": [-1],
            "datatype": "BYTES",
            "data": ["hello world"],
        }
    ]
}
response = run.invoke(json=payload)

The response follows the output tensor schema declared by the function.

invoke

Invoke run service endpoint. It uses the service URL from the run status if no URL is specified. The method defaults to "POST" if data or json is provided in kwargs, otherwise it defaults to "GET". The function returns a requests.Response object.

Parameters:

Name Type Description Default
method str

Method of the request (e.g., "GET", "POST").

'POST'
url str

URL to invoke. If specified, it must start with the service URL (http:// or https:// prefixes are required and stripped before comparison).

None
**kwargs dict

Keyword arguments to pass to the request.

{}

Returns:

Type Description
Response

Response from service.

output

Get run's output by name.

Parameters:

Name Type Description Default
output_name str

Key of the result.

required
as_key bool

If True, return result as key.

False
as_dict bool

If True, return result as dictionary.

False

Returns:

Type Description
Entity | dict | str | None

Result.

outputs

Get run's outputs.

Parameters:

Name Type Description Default
as_key bool

If True, return results as keys.

False
as_dict bool

If True, return results as dictionaries.

False

Returns:

Type Description
dict

List of output objects.

result

Get result by name.

Parameters:

Name Type Description Default
result_name str

Name of the result.

required

Returns:

Type Description
Any

The result.

results

Get results.

Returns:

Type Description
dict

The results.