Skip to main content

A Python client for the Playlab API

Project description

Playlab Python Client

A Python client for interacting with the Playlab API, enabling you to create interactive AI tutoring experiences.

Requirements

  • Python 3.7 or later

Installation

pip install playlab-api

Getting an API Key

To use the Playlab API, you'll need to obtain an API key.

  1. Log in to your account: Once your account is set up, log in at https://playlab.ai/login.
  2. Create and publish an app:
    • Navigate to a workspace within your organization or create a new one.
    • Create a new app within a workspace.
    • Develop your app using Playlab's tools.
    • Once ready, publish your app to your desired visibility.
    • Note down the project ID (also known as the app ID) - you'll need this for API calls.
      • The project ID can be found in the URL when you are on the project page as the group of characters after the last / .
      • For example, for: https://www.playlab.ai/build/clzni6ang00112by7c4vwbabc the project ID is: clzni6ang00112by7c4vwbabc
  3. Create an API Keys: In your organization's menu bar, look for the "API Keys" link in the upper-right side of the page.

Quick Start

from playlab_api import PlaylabApp

# Initialize the app with your API key and project ID
app = PlaylabApp(
    api_key="your_api_key_here",
    project_id="your_project_id_here"
)

# Send a message and get the response
response = app.send_message("Hello, AI!")

Environment Variables

You can set your API key and project ID using environment variables:

export PLAYLAB_API_KEY="your_api_key_here"
export PLAYLAB_PROJECT_ID="your_project_id_here"

Then initialize the app without parameters:

app = PlaylabApp()

Error Handling and Troubleshooting

The client includes improved error handling for common issues:

Common Error Scenarios

  • 403 Forbidden: Usually indicates Cloudflare security blocking or invalid project ID
  • 401 Unauthorized: Invalid or missing API key
  • 429 Rate Limited: Too many requests, wait before retrying
  • Cloudflare Challenges: Temporary blocking, try again in a few minutes

Troubleshooting Connection Issues

# Run diagnostic checks
results = app.troubleshoot_connection()
print(results)

# Example output:
# {
#     "api_key_valid": True,
#     "project_id_valid": True,
#     "base_url_reachable": True,
#     "authentication_works": True,
#     "project_access": True
# }

Detailed Usage

Please refer to the usage.ipynb notebook for more detailed examples, including:

  • File attachments
  • Conversation management
  • History access
  • System prompts
  • Interactive chat
  • Error handling and troubleshooting

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

playlab_api-0.1.3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

playlab_api-0.1.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file playlab_api-0.1.3.tar.gz.

File metadata

  • Download URL: playlab_api-0.1.3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for playlab_api-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2302c61d26f8f43cdeff0daf5b7af3f7579712f28b64b1349cf00434300355ac
MD5 32493a8d50ec00de9b6ab58dd0621730
BLAKE2b-256 9540e8e10801106546f874b8fef71323df2cb829cb17b12522f9fd7fdc4a9639

See more details on using hashes here.

File details

Details for the file playlab_api-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: playlab_api-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for playlab_api-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 50bfe7d3cff89942449d065699d21b7b3367bb61a5618e685e29d595b3d9b1ae
MD5 d15f1b9e9efbdeab575cefa42334880c
BLAKE2b-256 7a6d036fd41d356a5fca01efb11045afd6ae28a4ee581a6e032ed20578a61cc9

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