Skip to main content

An asynchronous Python client for the Puter API

Project description

PutergenAI

Python Version License PyPI Version

Asynchronous Python SDK for Puter.com API — an open-source cloud platform with AI capabilities, file storage, and privacy-first design.

Features

  • 200+ AI Models: GPT, Claude, Gemini, Mistral, Grok, DeepSeek, and more
  • File System: Cloud storage operations (read/write/delete)
  • Key-Value Store: Persist data in the cloud
  • Image Generation: Text-to-image with multiple providers
  • OCR: Extract text from images
  • Text-to-Speech: Convert text to MP3 audio
  • Streaming Support: Real-time chat completions
  • Async/Await: Modern Python async architecture

Quick Start

Install the package:

pip install putergenai

Basic usage:

import asyncio
from putergenai import PuterClient

async def main():
    async with PuterClient() as client:
        await client.login("your_username", "your_password")
        
        result = await client.ai_chat(
            prompt="Hello, how are you?",
            options={"model": "gpt-4o"}
        )
        
        print(result["response"]["result"]["message"]["content"])

asyncio.run(main())

CLI Usage

PuterGenAI now includes a command-line interface!

# Login
puter login

# Chat
puter chat --model gpt-4o

# List Models
puter models

# KV Store Operations
puter kv set mykey "hello world"
puter kv get mykey

Documentation

Examples

Streaming Chat

async def stream_example():
    async with PuterClient() as client:
        await client.login("username", "password")
        
        stream = await client.ai_chat(
            prompt="Tell me a story",
            options={"model": "claude-opus-4.5", "stream": True}
        )
        
        async for chunk, model in stream:
            print(chunk, end='', flush=True)

asyncio.run(stream_example())

File Operations

async def file_example():
    async with PuterClient() as client:
        await client.login("username", "password")
        
        await client.fs_write("test.txt", "Hello, Puter!")
        content = await client.fs_read("test.txt")
        print(content.decode('utf-8'))
        await client.fs_delete("test.txt")

asyncio.run(file_example())

Key-Value Store

async def kv_example():
    async with PuterClient() as client:
        await client.login("username", "password")
        
        await client.kv_set("my_key", "my_value")
        value = await client.kv_get("my_key")
        print(value)

asyncio.run(kv_example())

Vision (Image Analysis)

messages = [{
    "role": "user",
    "content": [
        {"type": "text", "text": "What's in this image?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
    ]
}]

result = await client.ai_chat(messages=messages, options={"model": "gpt-4o"})

Image Generation

image_url = await client.ai_txt2img(
    "A beautiful sunset over mountains",
    model="pollinations-image"
)
print(image_url)

OCR (Image to Text)

text = await client.ai_img2txt("https://example.com/image.png")
print(text)

Text-to-Speech

audio_bytes = await client.ai_txt2speech("Hello, world!")
with open("output.mp3", "wb") as f:
    f.write(audio_bytes)

GUI Application

Try the interactive GUI built with CustomTkinter:

python examples/example-ui.py

Features:

  • Secure login with encrypted credentials
  • Multi-model chat interface
  • Image generation with 4 free APIs
  • Async operations (non-blocking UI)
  • API key management via system keychain

Supported Models

The SDK supports models from multiple providers:

Provider Examples
OpenAI GPT-5, GPT-4o, o3 series
Anthropic Claude Opus, Sonnet, Haiku
Google Gemini Pro, Flash
Mistral Large, Medium, Small
xAI Grok series
DeepSeek Chat, Reasoner
TogetherAI Various LLMs
OpenRouter 100+ models

For the complete list, see the API Reference.

Security

  • Encrypted Storage: API keys stored via system keychain or Fernet encryption
  • No Plain-Text Credentials: Session tokens instead of passwords
  • SSL/TLS: All connections secured by default
  • Input Validation: Sanitized user inputs

See SECURITY.md for reporting vulnerabilities.

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/xyz)
  3. Commit your changes
  4. Add tests for new functionality
  5. Submit a pull request

Run tests:

python -m unittest discover tests

License

MIT License — see LICENSE for details.

Links


Maintainers: Nerve11KernFerm
Version: 3.0.0 • Built with ❤️ for the Puter.com platform

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

putergenai-3.0.0.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

putergenai-3.0.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file putergenai-3.0.0.tar.gz.

File metadata

  • Download URL: putergenai-3.0.0.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for putergenai-3.0.0.tar.gz
Algorithm Hash digest
SHA256 933309f44353f849003fc272efe356ba99b5e1576793bf5bf28f5c79e6669cf9
MD5 94d0ed1d3fddb47e0744b262920ebc07
BLAKE2b-256 4cd3175ee22a527694eafe0d250360bbbdf49cb5b5b44c4a1f83d1e4f6dc827d

See more details on using hashes here.

File details

Details for the file putergenai-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: putergenai-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for putergenai-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a3ba09bf0c9e20a25588f19c0c33da5f761c19b4cbf57b8fead33bf2f32c924
MD5 88e681cafe8ddcf02594acefa7b90afe
BLAKE2b-256 274b7fb12ca4c9f81fc9730ef8323ef86b87c7d0f5e1941e1620ff729d029c16

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