Skip to main content
The gcore package provides typed access to the full Gcore REST API from Python 3.9+. Both synchronous (Gcore) and asynchronous (AsyncGcore) clients are included, powered by httpx. All request parameters are typed as TypedDict; all responses are Pydantic models with editor autocomplete. Package: gcore on PyPI · Source: gcore-python on GitHub

Requirements

Python 3.9 or higher.

Install

A virtual environment avoids dependency conflicts with other projects:

Initialize the client

The SDK constructor reads three environment variables automatically — no arguments needed:
With GCORE_CLOUD_PROJECT_ID and GCORE_CLOUD_REGION_ID set, Cloud API methods use them automatically — no project ID or region ID is passed to individual calls:
Never hardcode credentials in source files. Store the three variables in a .env file and load them with python-dotenv.

First call

These calls verify authentication, list projects, and find active regions with VM support:

Method naming pattern

SDK methods map directly to API endpoints. The resource path in the URL becomes a chain of attributes on the client: The API reference code samples show the exact SDK method for every endpoint.

Polling task completion

Cloud API write operations return a task ID instead of the created resource directly. Use _and_poll convenience methods where available - they submit the request and block until the resource is ready:
When _and_poll is not available for a resource, use tasks.poll() directly as an alternative:
task.created_resources is a typed struct - use attribute access (task.created_resources.instances[0]), not dict-style access (task.created_resources["instances"][0]). The latter raises TypeError.

Pagination

List methods return auto-paginating iterators. The SDK fetches additional pages automatically as the iterator is consumed:
For manual page control:

Error handling

All errors inherit from gcore.APIError:

Retries and timeouts

The client retries connection errors, 408, 409, 429, and 5xx errors twice by default with exponential backoff. The default timeout is 2 minutes.

Async usage

Use AsyncGcore for concurrent operations or when integrating with async frameworks such as FastAPI or aiohttp. All method signatures are identical to Gcore - add await and use async with:
The main advantage of the async client is running multiple API calls concurrently with asyncio.gather(). The example below creates three networks in parallel instead of sequentially:
For improved concurrency performance, install aiohttp as the HTTP backend: