{"id":5094,"library":"volcengine-python-sdk","title":"Volcengine SDK for Python","description":"The Volcengine SDK for Python provides comprehensive access to Volcengine cloud services, including compute, storage, networking, and AI. It is currently at version 5.0.23 and receives frequent minor updates adding new services and API versions.","status":"active","version":"5.0.23","language":"en","source_language":"en","source_url":"https://github.com/volcengine/volcengine-python-sdk","tags":["cloud-sdk","volcengine","iaas","paas","cloud-services"],"install":[{"cmd":"pip install volcengine-python-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for making HTTP requests to Volcengine APIs.","package":"requests","optional":false},{"reason":"Optional dependency for KMS (Key Management Service) related operations.","package":"cryptography","optional":true},{"reason":"Optional dependency for loading configurations from YAML files.","package":"pyyaml","optional":true}],"imports":[{"note":"The generic client for configuring authentication and making arbitrary API calls.","symbol":"Client","correct":"from volcengine.client import Client"},{"note":"A service-specific client for interacting with the Identity and Access Management (IAM) service.","symbol":"IAMService","correct":"from volcengine.iam.IAMService import IAMService"},{"note":"A service-specific client for interacting with the Security Token Service (STS).","symbol":"StsService","correct":"from volcengine.sts.StsService import StsService"}],"quickstart":{"code":"import os\nfrom volcengine.iam.IAMService import IAMService\n\n# Set your Volcengine Access Key (AK) and Secret Key (SK) as environment variables\n# or replace with actual credentials. NEVER hardcode production credentials.\nVOLCENGINE_AK = os.environ.get(\"VOLCENGINE_AK\", \"YOUR_AK\")\nVOLCENGINE_SK = os.environ.get(\"VOLCENGINE_SK\", \"YOUR_SK\")\n\nif VOLCENGINE_AK == \"YOUR_AK\" or VOLCENGINE_SK == \"YOUR_SK\":\n    print(\"Please set VOLCENGINE_AK and VOLCENGINE_SK environment variables or replace placeholders.\")\n    exit(1)\n\ntry:\n    # Initialize the IAM service client\n    iam_service = IAMService()\n    iam_service.set_ak(VOLCENGINE_AK)\n    iam_service.set_sk(VOLCENGINE_SK)\n    # Default region is cn-beijing. You can set it explicitly if needed:\n    # iam_service.set_region(\"cn-beijing\")\n\n    # Example: List up to 10 access keys for the current account\n    print(\"Attempting to list access keys...\")\n    resp = iam_service.list_access_keys({\"Limit\": 10})\n\n    if resp.get(\"ResponseMetadata\", {}).get(\"Error\"):\n        error_message = resp[\"ResponseMetadata\"][\"Error\"][\"Message\"]\n        print(f\"Error listing access keys: {error_message}\")\n    else:\n        access_keys = resp.get(\"Result\", {}).get(\"AccessKeys\", [])\n        print(f\"Successfully listed {len(access_keys)} access keys.\")\n        for key in access_keys:\n            print(f\"  Access Key Id: {key.get('AccessKeyId')}, Status: {key.get('Status')}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart initializes an IAMService client using environment variables for credentials and then attempts to list the access keys associated with the account. This demonstrates basic client setup and a simple API call."},"warnings":[{"fix":"Set environment variables `VOLCENGINE_AK` and `VOLCENGINE_SK` or use `client.set_ak()` and `client.set_sk()` with valid credentials. Verify your credentials in the Volcengine console.","message":"Missing or incorrect authentication credentials (Access Key and Secret Key) are the most common cause of API request failures. Ensure 'VOLCENGINE_AK' and 'VOLCENGINE_SK' environment variables are correctly set or provided to the client.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Explicitly set the region using `client.set_region('your-region')` (e.g., 'cn-beijing') and verify that the service you are trying to access is available in that region. Some services may also require a specific `set_service_host()`.","message":"Volcengine services are region-specific. Making requests to a service endpoint in a region where the service is not deployed, or using the wrong region for your resources, will result in errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For specific service interactions, prefer importing and using the dedicated service client (e.g., `from volcengine.ecs.ECSService import ECSService`). Use the generic `volcengine.client.Client` when needing more dynamic API call patterns or for services without a dedicated client wrapper.","message":"The SDK offers a generic `volcengine.client.Client` and numerous service-specific clients (e.g., `volcengine.iam.IAMService`). The generic client requires manual construction of `ServiceInfo` and `APIInfo` for each call, while service-specific clients provide type-hinted methods for ease of use.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}