{"id":9389,"library":"volcengine","title":"Volcengine SDK for Python","description":"The `volcengine` library is the official Python SDK for interacting with Volcengine cloud services. It provides client interfaces for various services like STS, ECS, IAM, and more. It is actively maintained with frequent releases, often on a daily or weekly basis.","status":"active","version":"1.0.220","language":"en","source_language":"en","source_url":"https://github.com/Volcengine/volc-sdk-python","tags":["cloud","volcengine","sdk","client"],"install":[{"cmd":"pip install volcengine","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for HTTP communication with Volcengine API endpoints.","package":"requests"},{"reason":"Crucial for serializing and deserializing API requests and responses using Protocol Buffers.","package":"protobuf"},{"reason":"Underlying RPC framework used for communication with Volcengine services.","package":"grpcio"},{"reason":"Used for compiling protobuf definitions, often a runtime dependency for SDKs.","package":"grpcio-tools"}],"imports":[{"note":"Import the client for the Security Token Service (STS).","symbol":"StsService","correct":"from volcengine.sts.StsService import StsService"},{"note":"Import specific request models, which are Protocol Buffer messages, from the service's 'model' submodule.","symbol":"GetCallerIdentityRequest","correct":"from volcengine.sts.model.sts_pb2 import GetCallerIdentityRequest"},{"note":"General pattern for importing a service client, e.g., for Elastic Compute Service (ECS).","symbol":"ECSService","correct":"from volcengine.ecs.ECSService import ECSService"}],"quickstart":{"code":"import os\nfrom volcengine.sts.StsService import StsService\nfrom volcengine.sts.model.sts_pb2 import GetCallerIdentityRequest\n\n# Initialize STS service client with credentials from environment variables\nsts_service = StsService()\nsts_service.set_ak(os.environ.get(\"VOLCENGINE_ACCESSKEYID\", \"\"))\nsts_service.set_sk(os.environ.get(\"VOLCENGINE_SECRETACCESSKEY\", \"\"))\nsts_service.set_region(os.environ.get(\"VOLCENGINE_REGION\", \"cn-beijing\")) # Default to cn-beijing if not set\n\n# Create a request object\nreq = GetCallerIdentityRequest()\n\ntry:\n    # Call the API\n    resp = sts_service.get_caller_identity(req)\n    # Print the response\n    print(\"Successfully called GetCallerIdentity:\")\n    print(f\"  Account ID: {resp.AccountId}\")\n    print(f\"  User ID: {resp.UserId}\")\n    print(f\"  User Name: {resp.UserName}\")\nexcept Exception as e:\n    print(f\"Error calling GetCallerIdentity: {e}\")","lang":"python","description":"This quickstart initializes the Security Token Service (STS) client and calls `GetCallerIdentity` to retrieve the current user's identity. It expects `VOLCENGINE_ACCESSKEYID`, `VOLCENGINE_SECRETACCESSKEY`, and `VOLCENGINE_REGION` to be set as environment variables."},"warnings":[{"fix":"Set the required environment variables (recommended for production) or use `client.set_ak()`, `client.set_sk()`, `client.set_region()` methods directly on the service client instance before making API calls.","message":"Authentication requires correct `VOLCENGINE_ACCESSKEYID`, `VOLCENGINE_SECRETACCESSKEY`, and `VOLCENGINE_REGION` environment variables or explicit client configuration. Misconfiguration is the most common cause of API failures.","severity":"gotcha","affected_versions":"All 1.x.x"},{"fix":"Always refer to the specific service's `model` submodule for the correct request and response types, e.g., `from volcengine.sts.model.sts_pb2 import GetCallerIdentityRequest`.","message":"API request and response objects are typically Protocol Buffer messages, imported from `volcengine.<service_name>.model.<service_name>_pb2`. Failing to use these specific types can lead to `TypeError` or `AttributeError`.","severity":"gotcha","affected_versions":"All 1.x.x"},{"fix":"If encountering `TypeError` or `AttributeError` related to message objects or RPC communication, try `pip install --upgrade protobuf grpcio grpcio-tools` to ensure compatible versions.","message":"Ensure `protobuf` and `grpcio` are correctly installed and compatible. Version mismatches between these core dependencies or with the SDK can lead to cryptic errors during API calls or client initialization.","severity":"gotcha","affected_versions":"All 1.x.x"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the `volcengine` package is installed via `pip install volcengine`. Verify the exact import path against the official documentation or examples for the specific service you are trying to use.","cause":"The `volcengine` package or a specific service sub-module is not installed, or the import path is incorrect.","error":"No module named 'volcengine.ecs.ECSService'"},{"fix":"Double-check the `VOLCENGINE_ACCESSKEYID`, `VOLCENGINE_SECRETACCESSKEY`, and `VOLCENGINE_REGION` environment variables or the values passed to `set_ak()`, `set_sk()`, `set_region()` methods. Ensure they correspond to a valid Volcengine account and region.","cause":"The provided Volcengine AccessKey ID, Secret Access Key, or Region is incorrect or does not match the request signature.","error":"Status code: 401, Error code: SignatureDoesNotMatch"},{"fix":"Verify the exact method name and its arguments in the official API documentation for your SDK version. Ensure your SDK is up to date with `pip install --upgrade volcengine`.","cause":"This usually indicates a typo in the API method name, using an outdated client version, or attempting to call a method that doesn't exist for the service/client.","error":"AttributeError: 'StsService' object has no attribute 'get_caller_identity'"}]}