The `aistudio-sdk` is a Python client library for interacting with the AIStudio API. It provides convenient access to AI models for tasks like text generation. Currently at version 0.3.8, it receives frequent updates aligning with the underlying API's evolution.
pip install aistudio-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to perform text generation using the `TextGeneration` class. The SDK automatically picks up the `AISTUDIO_API_KEY` from environment variables. Remember to replace 'gpt-3.5-turbo' with an actual model supported by the AIStudio API.
Always review release notes for `aistudio-sdk` when upgrading. Pin your dependency to a specific minor version (e.g., `aistudio-sdk~=0.3.0`) in production to control updates.
Ensure `AISTUDIO_API_KEY` is consistently set in your environment. If you need to manage multiple keys or explicitly pass one, instantiate `aistudio.Client(api_key="...")` first and then pass that client to service classes if they support it, or set the environment variable programmatically with `os.environ['AISTUDIO_API_KEY'] = '...'` before initializing the service.
Consult the official AIStudio API documentation or SDK methods (if available) to get a list of currently supported models before making API calls.
When an API call fails, inspect the full exception object or response object for `status_code`, `error` fields, or other diagnostic information to understand the cause (e.g., rate limits, invalid input, authentication issues).