Supported Go versions
The SDK supports Go 1.24 and later. New SDK versions include breaking changes in the underlying libraries. If your project uses an earlier SDK version, pin the dependency to~v0.1,<v0.2 in your go.mod file.
Installation and update
Install the SDK package:Initialization
Initialize the SDK by usinggosdk.New:
gosdk.New constructor initializes the SDK. However, initialization alone is not enough to send requests to Nebius AI Cloud services: the SDK must authenticate the requests. Add credentials and other required options to gosdk.New.
The WithUserAgentPrefix method adds a prefix to the User-Agent header sent with each request. Use WithUserAgentPrefix to identify your application in the list of requests. The version or comment in the prefix is optional.
Authentication with a service account
For server-to-server communication, use a service account to authenticate SDK requests. The SDK uses the service account credentials to generate a JSON Web Token, exchange it for an IAM token and refresh the IAM token in the background. To authenticate with a service account:- Create a service account.
-
Generate an authorized key and create a service account credentials file:
In the command, set the following parameters:
--service-account-id: ID of your service account.--output: Path to the service account credentials file, for examplecredentials.json.
-
Initialize the SDK with the service account credentials file:
The SDK also supports authentication with IAM tokens. For more information, see the Go SDK repository.
Sending a request
The SDK provides service clients grouped by Nebius AI Cloud services and API versions. For mutating operations, such as creating, updating and deleting resources, the SDK returns an operation object. If an operation is asynchronous, callWait to wait until it is completed.
The following example creates a Compute virtual machine (VM).
-
Create a Go file with the following code.
This script already includes SDK initialization and authentication.
In the script, set the following parameters:
<application_name>/<application_version_or_comment>: Application or library that calls the SDK. The version or comment is optional. For more information, see Initialization.<credentials_file_path>: Path to the service account credentials file.<project_ID>: ID of the project where you create the resources.<image_family_name>: Name of the boot disk image family, for exampleubuntu24.04-driverless.<platform_name>: Name of the Compute platform, for examplecpu-e2.<preset_name>: Name of the resource preset. Available presets depend on the selected platform, for example2vcpu-8gbforcpu-e2.<subnet_ID>: ID of the VM’s subnet.
-
Execute the file: