Gitpod SDK
The Gitpod SDK provides powerful tools for developers to interact programmatically with Gitpod environments. It allows you to automate environment creation, run tasks, manage automations, and scale infrastructure with Gitpod runners. Available in Python, Node/Typescript, and Go, the SDK gives developers flexibility in their choice of language.
SDKs Available
- Python SDK: For Python developers interacting with Gitpod environments.
- Node/Typescript SDK: For JavaScript and TypeScript developers.
- Go SDK: For Go developers intgerating with Gitpod.
For detailed API references, consult the Gitpod API Reference.
End-to-End Walkthrough
Watch the video below to see an end-to-end walkthrough of how to use the Gitpod SDK. The steps below are based on the video.
1. Sign Up at Gitpod
- Go to app.gitpod.io and sign up for a Gitpod account.
- Once logged in, generate a Personal Access Token for SDK authentication under your account settings at Gitpod Personal Access Tokens.
2. Install the SDK
You need to install the Gitpod SDK for your preferred language. Here’s how to do it for the three SDKs:
- Python SDK:
- Node/Typescript SDK:
- Go SDK:
3. Authenticate with Gitpod
Once you’ve installed the SDK, authenticate using your personal access token. You can either set it via the environment variable or explicitly pass it in your code.
-
Option 1: Set the environment variable
GITPOD_API_KEY
: -
Option 2: Authenticate directly in your code:
-
For Python SDK:
-
For Go SDK:
-
For Node/Typescript SDK:
-
4. Run an Example
Once authenticated, you can start experimenting with the SDK by running one of the examples. Here’s an example of how to create an environment and run a command inside it using the Python SDK:
This example demonstrates:
- Creating a new environment initialized from a Git repository.
- Running a command inside the environment.
- Deleting the environment once the task is completed.
Available Examples
Here are the available examples in the SDK repositories, with descriptions of what they demonstrate:
1. Run a Command in an Environment
- Description: Demonstrates how to initialize an environment from a Git repository and run a command inside it.
- Location: Python SDK Example - Run Command
2. Run a Service in an Environment
- Description: Demonstrates how to run a long-lived service (such as a database or message queue) inside a Gitpod environment.
- Location: Python SDK Example - Run Service
3. Access the File System in an Environment
- Description: Shows how to access and interact with the file system inside a Gitpod environment programmatically.
- Location: Python SDK Example - File System Access
4. Use the Anthropic Tool in a Gitpod Environment
- Description: Demonstrates how to use the Anthropic tool within a Gitpod environment and interact with the Model Context Protocol (MCP).
- Location: Python SDK Example - Anthropic Tool Use
5. MCP Server Example
- Description: Demonstrates the integration of the Model Context Protocol (MCP) in a Gitpod environment, used for managing model contexts.
- Location: Go SDK Example - MCP Server
Was this page helpful?