Registry / llm-agents / aistudio-sdk

aistudio-sdk

JSON →
library0.3.9pypypi✓ verified 23d ago

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-sdk
INSTALL
IMPORT
SIG · AISTUDIO-SDK
A
aistudio-sdk
llm-agentspythonv0.3.9
Install
4.2s avg
Import
Disk
47MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 49.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.2s · import 0.000s · 51MB
47MB installed
● package 47MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TextGeneration
from aistudio_sdk.hub import TextGeneration
from aistudio_sdk import TextGeneration

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.

import os from aistudio import TextGeneration # Ensure the AISTUDIO_API_KEY environment variable is set. # Example: export AISTUDIO_API_KEY="your_secret_key" # For local testing without setting a real key (will likely fail API calls): # os.environ['AISTUDIO_API_KEY'] = 'sk-aistudio-dummy-key' try: # The SDK automatically picks up AISTUDIO_API_KEY from environment variables. gen = TextGeneration() response = gen.create( prompt="Hello, my name is", model="gpt-3.5-turbo", # Replace with an available model on AIStudio temperature=0.7, max_tokens=20 ) print("Generated text:", response.text) except Exception as e: print(f"An error occurred: {e}") print("Please ensure AISTUDIO_API_KEY is set and valid, and the model specified is available.")
Debug
Known issues
breakingAs the library is in its 0.x.x version, breaking changes to the API surface (class names, method signatures, return types) may occur in minor releases without a full major version bump.
fix
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.
affects: 0.x.x (all versions before 1.0.0)
gotchaThe SDK primarily relies on the `AISTUDIO_API_KEY` environment variable for authentication. While a `Client` object can be instantiated with an `api_key` argument, service classes like `TextGeneration` do not directly accept `api_key` in their constructor.
fix
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.
affects: All versions
gotchaThe example models provided in the documentation (e.g., 'gpt-3.5-turbo') are illustrative. The actual availability and names of models depend on the AIStudio API itself and may change. Using an unsupported model will result in an API error.
fix
Consult the official AIStudio API documentation or SDK methods (if available) to get a list of currently supported models before making API calls.
affects: All versions
gotchaAPI responses may contain detailed error messages or specific structures beyond just `response.text` for generation results. Ignoring these can lead to missed debugging opportunities.
fix
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).
affects: All versions
Upgrade
Version history
0.3.9latest on PyPI · released Jul 27, 2026
Audit
Dependencies
anyiorequiredAsynchronous I/O support
httpxrequiredHTTP client for API requests
pyyamlrequiredConfiguration and data handling
tqdmrequiredProgress bar for long operations (optional user-facing feature)
typing_extensionsrequiredBackports and extensions for typing features
Agent activity
78 hits · last 30 days
node
68
OpenAI (training)
2
Perplexity
1
Resources
aistudio-sdk — pip install aistudio-sdk · libregistry