Deploy to Vespa Cloud

Vespa Cloud logo

This notebook deploys a sample application to Vespa Cloud using pyvespa. The Vespa CLI is used for managing security credentials.

See pyvespa, and jupyter notebook requirements to run this notebook.

Refer to the sample apps site for more applications.

Open In Colab

Install pyvespa and the Vespa CLI

!pip install pyvespa

If homebrew is installed, install the Vespa CLI:

!brew install vespa-cli

Alternatively, when running in Colab, install the Vespa CLI:

import os
import requests
res = requests.get(url="").json()
os.environ["VERSION"] = res["tag_name"].replace("v", "")
!curl -fsSL${VERSION}/vespa-cli_${VERSION}_linux_amd64.tar.gz | tar -zxf -
!ln -sf /content/vespa-cli_${VERSION}_linux_amd64/bin/vespa /usr/local/bin/vespa

Create a Vespa Cloud tenant

Sign up and create a tenant: Run steps 1 and 2 in getting started, then replace the tenant name below:

import os
os.environ["TENANT_NAME"] = "mytenant"

Set up security credentials

Configure the tenant.application.instance:

!vespa config set target cloud
!vespa config set application ${TENANT_NAME}.myapp.default

If the tenant.application.instance is already created with security credentials, skip next two steps, and go directly to setting api_key_path. If not, create data-plane credentials:

!vespa auth cert -N

vespa auth cert -N stores the credentials in ~/.vespa, like:


Create an api-key, used to deploy the application:

!vespa auth api-key

vespa auth api-key stores the api key in ~/.vespa, like:


Add it in the console per instructions from the command. Enter full path to the api key:

api_key_path = "/Users/me/.vespa/mytenant.api-key.pem"

Create an application package

An application package is the application’s configuration, including schema. Here, using an empty appliction to ilustrate deployment only - see the other examples in pyvespa for real application packages.

from vespa.package import ApplicationPackage

app = ApplicationPackage(name="sampleapp")

Create a VespaCloud instance

Refer to the VespaCloud reference.

from vespa.deployment import VespaCloud

vespa_cloud = VespaCloud(

Deploy to Vespa Cloud

Refer to tenants, applications and instances for details - here creating an instance named default:

app = vespa_cloud.deploy(instance="default")

That is it, you can now interact with your deployed application through the app instance.