DecisionAI Client#

API Reference > Client > DecisionAI Client

The decision_ai.DecisionAI class is the main entry point for interacting with the DecisionAI service. It provides methods to create and manage chat sessions, authenticate with the service, and configure client settings.

This is typically the first class you’ll instantiate when using the DecisionAI SDK.

Quick Start#

First, set up your API key as an environment variable:

For Linux/macOS:

export QUANTAGONIA_API_KEY=<YOUR_API_KEY>

For Windows:

set QUANTAGONIA_API_KEY=<YOUR_API_KEY>

Then you can create a client instance and start using it:

from decision_ai import DecisionAI


client = DecisionAI()

# Create a new chat session
chat_session = client.create_chat_session()

Class Reference#

class decision_ai.DecisionAI(api_key: str | None = None, timeout: int = 30, process_model_timeout: int = 150, base_url: str | None = None)#

Bases: object

Main client class for interacting with Quantagonia’s Decision AI.

create_chat_session(opt_input_data: InputData, opt_model_id: str) ChatSession#

Start a new chat session with the Decision AI.

Parameters:
  • opt_input_data (InputData) – Input data for the chat session

  • opt_model_id (str) – ID of the optimization model to use for the chat session

Returns:

A new ChatSession object

continue_chat_session(chat_session_id: str) ChatSession#

Continue a chat session with the Decision AI.

Parameters:
  • chat_session_id (str) – ID of the chat session to continue

  • opt_input_data_class_name (str | None, optional) – Input data for the chat session. If not provided, the input data class name will be fetched from the meta information in the chat session. Defaults to None.

list_chat_sessions(limit: int | None = 20) list[ChatSessionState]#

List all chat sessions.

Parameters:

limit (int | None, optional) – Maximum number of chat sessions to return. Defaults to None.

Returns:

List of chat sessions

deploy_model(module: ModuleType | str | os.PathLike, model_name: str, description: str = '', examples_dir: str | os.PathLike | None = None, class_names: OptModelClassNames | None = None) OptModelStatusResponse#

Create a new model and upload its code.

Parameters:
  • module (ModuleType | str | os.PathLike) – Python module containing the model code

  • model_name (str) – Name for the model

  • class_names (ModelClassNames | None, optional) – Name of the class in the module that contains the model code. If not provided, the class names will be fetched from the meta information in the model. Defaults to None.

  • description (str, optional) – Optional description of the model. Defaults to “”.

  • examples_dir (str | os.PathLike | None, optional) – Directory containing example XML files. If provided, examples will be synced with the backend. Defaults to None.

Returns:

The ID of the created model

Raises:
  • ImportError – If the module spec cannot be found

  • RuntimeError – If the code upload fails

  • FileNotFoundError – If examples_dir is provided but doesn’t exist

list_opt_models() list[OptModelGetResponse]#

List all deployed optimization models.

get_opt_model(opt_model_id: str) OptModelGetResponse#

Get a deployed optimization model by ID.

get_model_processing_status(opt_model_id: str) OptModelStatusResponse#

Get the processing status of a model.

get_opt_input_data(opt_input_data_id: str, opt_input_data_cls_type: type[InputDataCls]) InputDataCls#

Get optimization input data by ID.

Parameters:
  • opt_input_data_id (str) – The identifier of the input data to retrieve.

  • opt_input_data_cls_type (type[InputDataCls]) – The type of the input data class.

Returns:

An instance of the specified input data class.

Return type:

InputDataCls

Raises:
  • RequestException – If the request fails.

  • AuthorizationError – If the API key is invalid.

post_opt_input_data(input_data: InputData) str#

Create new optimization input data.

Parameters:

input_data (InputData) – The input data to create.

Returns:

The ID of the created input data.

Return type:

str

Raises:
  • RequestException – If the request fails.

  • AuthorizationError – If the API key is invalid.

delete_opt_input_data(data_id: str) None#

Delete optimization input data by ID.

Parameters:

data_id (str) – The identifier of the input data to delete.

Raises:
  • RequestException – If the request fails.

  • AuthorizationError – If the API key is invalid.

delete_opt_model(model_id: str) None#

Delete an optimization model by ID.

Parameters:

model_id (str) – The identifier of the model to delete.

Raises:
  • RequestException – If the request fails.

  • AuthorizationError – If the API key is invalid.

assert_version_compatibility() None#

Check if the client version is compatible with the server version.

Raises:
  • UnsupportedVersionError – If the client version is not compatible with the server version.

  • OutdatedVersionError – If the client version is outdated compared to the server version.

Back to: API Reference (API Reference Overview)