A robust Python SDK for seamless integration with the Genstack AI platform. This SDK enables developers to interact with Genstack's AI generation APIs, providing a simple and efficient interface for sending requests and handling responses.
- Easy API Integration: Quickly connect to Genstack's AI services with minimal setup.
- Async and Sync Support: Internally uses async HTTP calls, exposed via a synchronous interface for convenience.
- Customizable: Configure API keys and endpoints as needed.
- Error Handling: Graceful error management for HTTP and runtime issues.
Install via pip (recommended):
pip install genstackOr clone this repository and install dependencies:
git clone <repo-url>
cd Python-SDK
pip install -r requirements.txtfrom genstack import Genstack
client = Genstack(api_key="gen-<your-api-key>")
response = client.generate(
input="Generate a short poem about the sea.",
track="default-track", # Required
model="gpt-4-1-nano-oai" # Optional, defaults to 'auto'
)
if "output" in response:
print(response["output"][0]["output"]["text"])
else:
print("Error:", response.get("error", "Unknown error"))api_key(str): Your Genstack API key (must start withgen-).base_url(str, optional): Override the default API endpoint (default:http://localhost:8000).
generate(input, model="auto", track=None)input(str or dict): The prompt or payload to send. If a string, it is wrapped as{ "input": <input> }.model(str, optional): Model identifier (default:auto).track(str, required): Track identifier for the request.
Returns: dict — The API response as a dictionary.
- Raises
ValueErrorif the API key is invalid ortrackis missing. - Raises
TypeErrorifinputis not a string or dictionary. - Returns error details in the response dictionary for HTTP or runtime errors.
Tests are provided using pytest:
pytest tests/test_generate_with_invalid_type: Ensures type validation for thegeneratemethod.call_test.py: Example/test for real API calls (requires valid API key in environment).
Python-SDK/
genstack/
__init__.py
genstack.py
tests/
test_generate.py
call_test.py
x_test.py
pyproject.toml
requirements.txt
README.md
MIT License. See LICENSE for details.
For more information, visit the Genstack documentation or contact the maintainer at shreyk.dev@gmail.com.