Skip to main content

Universal AI SDK from Genstack

Project description

Genstack Python SDK

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.

Features

  • 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.

Installation

Install via pip (recommended):

pip install genstack

Or clone this repository and install dependencies:

git clone <repo-url>
cd Python-SDK
pip install -r requirements.txt

Usage

Basic Example

from 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"))

Initialization

  • api_key (str): Your Genstack API key (must start with gen-).
  • base_url (str, optional): Override the default API endpoint (default: http://localhost:8000).

Generate Method

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.

Error Handling

  • Raises ValueError if the API key is invalid or track is missing.
  • Raises TypeError if input is not a string or dictionary.
  • Returns error details in the response dictionary for HTTP or runtime errors.

Testing

Tests are provided using pytest:

pytest tests/
  • test_generate_with_invalid_type: Ensures type validation for the generate method.
  • call_test.py: Example/test for real API calls (requires valid API key in environment).

Dependencies

Project Structure

Python-SDK/
  genstack/
    __init__.py
    genstack.py
  tests/
    test_generate.py
    call_test.py
    x_test.py
  pyproject.toml
  requirements.txt
  README.md

License

MIT License. See LICENSE for details.


For more information, visit the Genstack documentation or contact the maintainer at shreyk.dev@gmail.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genstack-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genstack-0.2.0-py2.py3-none-any.whl (3.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file genstack-0.2.0.tar.gz.

File metadata

  • Download URL: genstack-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for genstack-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cc87dfd7bbbb2c9cf82da2fc4f2c587036ff3e6ddd01c9c64a7b7dc62f84246a
MD5 912910cca6e5b1377bcd9cd90fc477b8
BLAKE2b-256 df2e1bc5061cef25a48a0ed18ba4e21fe7726b43c12dd0c37a32943a26895158

See more details on using hashes here.

File details

Details for the file genstack-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: genstack-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for genstack-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 30967d34b705058b54de413f0d36a27635371af66b4997da14de1c316f653a26
MD5 3f3085da1b605f97f71b7ac6302674a2
BLAKE2b-256 1fae088b2fe374d843e724c8e3ad411c0010c227936b87bac098e3be6f10d9eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page