Skip to main content

Player2 for Python

A lightweight Python client designed to easily interact with Player2 Local Endpoints.

Installation

Install the package via pip:

pip install player2

Usage

1. Initialize the Client

When initializing the client, pass your game_id. It will automatically handle web login to fetch authorization keys and spin up a background health-check loop.

from player2 import APIClient

client = APIClient(game_id="your_game_id")  # Get the gameID from the player2 website

2. Chat Completions

Send user queries with optional system instructions:

response = client.chat(
    user="Hello, how are you doing today?",
    system="You are a helpful and witty assistant."
)

print(response)

3. Text-to-Speech (TTS)

Trigger speech generation locally:

tts_response = client.speak(
    text="Hello, how are you doing today?",
    instructions="Speak with a cheerful tone",
    speed=1.0
)

print(tts_response)

4. Speech-to-Text (STT)

Info This function is still untested and might not work, It's still W.I.P.

Trigger speech recording for 5 seconds and then stop.

from time import sleep # For this example, we will use time.sleep

client.start_stt()
sleep(5)
recording = client.stop_stt()

print(recording) # Returns the text in a JSON format.

5. Image Generation

Generate an image

generated_image_url = client.image(
    height=512, 
    width=512, 
    prompt="A cute cybernetic cat sitting on a neon rooftop at night"
).generate()

print(generated_image_url) # Print the image as a data URI

6. Image Editing

Edit an image

edited_image = client.image(
    height=512,
    width=512,
    prompt="Add a tiny astronaut helmet onto the cat's head",
    images=generated_image_url
).edit()

print(edited_image) # Print the image as a data URI

Metadata

Release files for player2 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for player2 0.0.4
File Size Uploaded Provenance
player2-0.0.4.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for player2 0.0.4
File Interpreter ABI Platform
player2-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / player2-0.0.4.tar.gz

Download URL player2-0.0.4.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
279cbffc55b8e5e5b79f71844919b7e41501ae8443885e89f32084655df55ac9
BLAKE2b-256 checksum
How to use checksums
bf84fb59e2cf64202d474082fd59f634b012afe31467f22be3bb5cebee0b6420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / player2-0.0.4-py3-none-any.whl

Download URL player2-0.0.4-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b85d1f355367915c0d86c051c72e47a6169cb7f9589a7cd3a179434c77e6efc
BLAKE2b-256 checksum
How to use checksums
9a7f4d6537ba7b93a19d0f3654c2677717bae7ca7b59620e99345bebdfd30fee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Security for player2 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page