Program a Smart Machine

Viam offers software development kits (SDKs) in popular languages which

  • Broker connection, authentication, and encryption for communication with smart machines running viam-server using WebRTC
  • Enable you to interface with robot gRPC APIs in a way that is idiomatic to that programming language

Diagram showing how a client connects to a robot with Viam. Diagram shows a client as a computer sending commands to a robot. Robot 1 then communicates with other robotic parts over gRPC and WebRTC and communicating that information back to the client.

Use the SDK of your preferred language to write code to control your smart machine.

Viam currently offers SDKs for the following languages:


Before you get started with your program, ensure that you have installed viam-server on the computer you want to use to control your robot (likely a single-board computer), and configured your robot.

Next, to install your preferred Viam SDK on your Linux or macOS development machine or single-board computer, run one of the following commands in your terminal:

If you are using the Python SDK, set up a virtual environment to package the SDK inside before running your code, avoiding conflicts with other projects or your system.

pip install viam-sdk
go install
npm install --save @viamrobotics/sdk
flutter pub add viam_sdk

Hello World: The Code Sample Tab

Create a program in the language of your choice that connects to your robot and uses methods built into the SDK’s client API libraries to interact with and control the resources on the robot.

Start by navigating to your robot’s page on the Viam app. Select the Code Sample tab, select your preferred SDK, and copy the code generated for you. This code snippet imports all the necessary libraries to set up a connection with your robot and interface with its configured components and services.

Your boilerplate code sample should look similar to this:

Click this to see example boilerplate code from the Code Sample tab

Save this file on your development machine with the file type of your preferred SDK.

The sample code contains the required imports as well as the connect logic which establishes a connection for your client application to communicate with the robot’s viam-server instance. This section of the boilerplate code contains your robot’s address and location secret. You can think of these as keys or access tokens to your robot that are important to keep private. This connection must be established for your program to be executed properly on your robot.

Run the sample code

Once you have saved the sample code, execute your program.

You can run your program on any computer which:

  1. has the appropriate SDK installed
  2. can establish a connection to your robot through the cloud, on a local or wide area network (LAN or WAN), or locally

The program will connect to your robot and print a list of the available resources.

Edit the sample code

Once you have successfully run the sample code, you can edit the boilerplate code by adding control logic to make a client application that connects to your robot and controls it in the way you want. You can find the right libraries to import for SDK methods, typing, interfaces, and utilities at the start of each resource’s API documentation, as well as in the individual SDK documentation sites and on GitHub.