> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/rt-lab/automation-api-and-scripting/rt-lab-api/python-rtlab-api-reference.md).

# Python RT-LAB API Reference

## Overview

All API C functions have the “Opal” prefix in their name. However, for Python, the prefix has been removed because the functions are grouped inside a module or a class.

{% code overflow="wrap" lineNumbers="true" %}

```python
	import RtlabApi
```

{% endcode %}

<details>

<summary><strong>List of Functions Available for Each State</strong></summary>

## API State

### Disconnected

This is the initial state of the API. In this state, you can get the list of active projects and either connect to one or create a new project instance.

* Connect (deprecated)
* ConnectByName (deprecated)
* CreatePackage
* ExportIOsConfiguration
* GetActiveModels (deprecated)
* GetActiveProjects
* OpenGlobalConfiguration
* OpenProject
* SetCurrentModel (deprecated)

### Connected

Once the API is connected, you can modify the model’s settings.

* CloseProject
* Disconnect (deprecated)

## Model states

### Unloaded

In this state, the model could be configured to prepare the simulation.

* AddExtraFile
* ImportConnections
* ImportIOsConfiguration
* InstallRtlab
* Load
* ModelClean
* RemoveExtraFile
* SetNodeCpu
* SetNodeMapping
* SetNodeXHP
* SetSimulationMode
* SetTargetPlatform
* StartCompile2
* UninstallRtlab

### Compiling

**In this state, settings cannot be modified.**

* AbortCompile
* DisplayInformation

### Loaded

When the model’s executable is started on a target, the model’s state becomes loaded. In this state, parameters and signals could be changed on the fly. Data acquisition could be performed for real-time or offline analysis.

**Execute**

* GetAcqGroupSyncSignals
* GetAcqTrigger
* GetBlob
* GetControlSignals
* GetParametersByName
* GetSignalsByName
* GetValueByAlias
* LoadParameters
* Pause
* PauseConsole
* RearmAsyncAcq
* Reset
* SendBlob
* SetAcqTrigger
* SetControlSignals
* SetParameters
* SetParametersByName
* SetSignalsByName
* SetValueByAlias
* SingleStep
* Snapshot

### Available at any model state

These functions could be called anytime when the API is connected to a model.

* AddTarget
* AddToSelection
* Command
* CreateAlias
* CreateConnection
* DeleteConnection
* DeleteConnHandleExecuteConsole
* ExecuteMatlabCmd
* ExportConnections
* FindObjectId
* GetAcqBlockLastVal
* GetAcqSampleTime
* GetAcquisitionControl
* GetAliasDescription
* GetAttributes
* GetBlobsControl
* GetChildren
* GetConfigurationControl
* GetConnectionPointsForIO
* GetConnectionsDescription
* GetConnHandle
* GetControlSignalsDescription
* GetCurrentModel
* GetDefaultAttributes
* GetExtraFiles
* GetInstalledMatlabReleases
* GetIOInterfaces
* GetIOsConfiguration
* GetLastErrMsg
* GetModelState
* GetMonitoringControl
* GetNodeCpu
* GetNodeXHP
* GetNumAcqGroup
* GetNumSignalsForGroup
* GetObjectType
* GetParameterControl
* GetParametersDescription
* GetPauseTime
* GetRtlabVersion
* GetSelectedModel
* GetSignalControl
* GetSignalsDescription
* GetPhysNodeList
* GetStopTime
* GetSubsystemList
* GetSystemControl
* GetTargetFile
* GetTargetNodeSystemInfo
* GetTargetPlatform
* GetTimeInfo
* OpalIsOriginalModelOpen
* LoadAlias
* LoadAliasDescription
* LoadConsole
* LoadOriginalModel
* LoadParametersDescription
* NewConnHandle
* PauseConsole
* Ping
* PutTargetFile
* RegisterDisplay
* ReleaseFunctionControl
* RemoveAlias
* RemoveFromSelection
* RemoveTarget
* RenameAlias
* ResetConsole
* ResetOriginalModel
* RestoreAttributes
* SaveAlias
* SaveParameters
* SetAcqBlockLastVal
* SetAcqWriteFile
* SetAttributes
* SetConnHandle
* SetDecimationFactor
* SetFillDecimation
* SetMatlabRelease
* SetNotificationCallback
* SetNumberValues
* SetPauseTime
* SetTimeFactor
* StartExecutable
* StartTargetPythonScript
* StopConsole
* StopExecutable
* SetStopTime
* TakeFunctionControl
* WaitExecutable

## Groupings

The functions are organized into several categories, reflecting the sequence in which they are used when interacting with the model.

The available types are:

* Model Selection - enables you to select current model
* Model Preparation - enables you to prepare the model before execution
* Model Execution - enables you to modify the model execution flow
* Model Interaction - enables you to modify the model during execution
* Model Configuration - enables you to modify the RT-LAB configuration
* Utilities - enables you to access utilities functions

### Generic

* AddTarget
* AddToSelection
* Command
* FindObjectId
* GetAttributes
* GetChildren
* GetDefaultAttributes
* GetObjectType
* RemoveFromSelection
* RestoreAttributese
* SetAttributes

### Model Selection

* CloseProject
* Connect
* ConnectByName
* DeleteConnHandle
* Disconnect
* GetActiveModels
* GetActiveProjects
* GetConnHandle
* GetCurrentModel
* GetSelectedModel
* NewConnHandle
* OpenProject
* SetConnHandle
* SetCurrentModel

### Model Preparation

* AbortCompile
* AddExtraFile
* CreateConnection
* DeleteConnection
* GetConnectionPointsForIO
* GetConnectionsDescription
* GetExtraFiles
* GetIOInterfaces
* GetIOsConfiguration
* GetNodeXHP
* GetPhysicalNodeList
* GetSubsystemList
* GetTargetPlatform
* ImportConnections
* ImportIOsConfiguration
* ModelClean
* OpenGlobalConfiguration
* RemoveExtraFile
* SetNodeCpu
* SetNodeMapping
* SetNodeXHP
* SetSimulationMode
* SetTargetPlatform
* StartCompile2

### Model Execution

* Execute
* GetModelState
* GetPauseTime
* GetStopTime
* Load
* Pause
* Reset
* SetPauseTime
* SetStopTime
* SetTimeFactor
* SingleStep

### Model Interaction

**The functions of this type can be further categorized as follows:**

* alias
* blobs
* console
* monitoring
* original model
* parameters
* signals

### Alias

**These functions manage aliases.**

* CreateAlias
* GetAliasDescription
* GetValueByAlias
* LoadAlias
* LoadAliasDescription
* RemoveAlias
* RenameAlias
* SaveAlias
* SetValueByAlias

### Blobs

These functions manage blobs.

**The blobs are used to exchange data between the RT-LAB subsystem or between the host and the target.**

* GetBlob (C only)
* GetBlobsControl (C only)
* SendBlob (C only)

### Console

* ExecuteConsole
* LoadConsole
* PauseConsole
* ResetConsole
* StopConsole

### Monitoring

* GetMonitoringControl
* Snapshot

### Original Model

* IsOriginalModelOpen
* LoadOriginalModel
* ResetOriginalModel

### Parameters

* GetParameterControl
* GetParametersByName
* GetParametersDescription
* LoadParameters
* LoadParametersDescription
* SaveParameters
* SetParameters
* SetParametersByName

### Signals

These functions manage signal transmission within the system.

**Control signals** are transmitted over TCP/IP from the console subsystem to the computation nodes.

**Acquisition signals** are transmitted over TCP/IP from the computation nodes back to the console subsystem (e.g., signals prefixed with *SC\_xxx*).

For additional information please see the section [Simulation Control, Monitoring & Logging](https://www.opal-rt.com/docs/rt-lab/simulation-control-monitoring-and-logging/interact-using-dashboards.md).

* GetAcqGroupSyncSignals
* GetControlSignals
* GetControlSignalsDescription
* GetSignalControl
* GetSignalsByName
* GetSignalsDescription
* SetControlSignals
* SetSignalsByName

### Model Configuration

This type can be further categorized as follows: Acquisition and system.

#### Acquisition

* GetAcqBlockLastVal
* GetAcqSampleTime
* GetAcquisitionControl
* GetAcqTrigger
* GetNumAcqGroup
* GetNumSignalsForGroup
* RearmAsyncAcq
* SetAcqBlockLastVal
* SetAcqTrigger
* SetAcqWriteFile
* SetAsyncAcqOpts
* SetDecimationFactor
* SetDynSignalListForGroup
* SetFillDecimation
* SetMaxDynSignalForGroup
* SetNumberValues

#### System

* GetConfigurationControl
* GetSystemControl
* GetTimeInfo

### Utilities

* CreatePackage
* DisplayInformation
* GetInstalledMatlabReleases
* ExecuteMatlabCmd
* ExportConnections
* ExportIOsConfiguration
* GetLastErrMsg
* GetRtlabVersion
* GetTargetFile
* GetTargetNodeSystemInfo
* InstallRtlab
* Ping
* PutTargetFile
* RegisterDisplay
* ReleaseFunctionControl
* RemoveTarget
* SetMatlabRelease
* SetNotificationCallback
* StartExecutable
* StartTargetPythonScript
* StopExecutable
* TakeFunctionControl
* UninstallRtlab
* WaitExecutable

</details>

## Example

Examples are available in the folder: C:\OPAL-RT\RT-LAB\\\<version>\Examples\API, where \<version> is the currently installed version of RT-LAB.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/rt-lab/automation-api-and-scripting/rt-lab-api/python-rtlab-api-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
