Skip to main content

Python SDK for Pendra — UK-based, privacy-first LLM inference

Project description

pendra-python

Official Python SDK for Pendra — UK-based, privacy-first LLM inference.

Your data is processed in the UK, never stored, never shared with US cloud providers.

Installation

pip install pendra

Quick Start

import pendra

client = pendra.Pendra(
    api_key="pdr_sk_...",          # or set PENDRA_API_KEY env var
    base_url="http://localhost",    # your self-hosted instance
)

response = client.chat.completions.create(
    model="llama3.2",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of the UK?"},
    ],
)

print(response.choices[0].message.content)
# → London is the capital of the United Kingdom.

Streaming

with client.chat.completions.create(
    model="llama3.2",
    messages=[{"role": "user", "content": "Write me a short poem about London."}],
    stream=True,
) as stream:
    for chunk in stream:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Async

import asyncio
import pendra

async def main():
    async with pendra.AsyncPendra(api_key="pdr_sk_...") as client:
        # Non-streaming
        response = await client.chat.completions.create(
            model="llama3.2",
            messages=[{"role": "user", "content": "Hello!"}],
        )
        print(response.choices[0].message.content)

        # Streaming
        stream = await client.chat.completions.create(
            model="llama3.2",
            messages=[{"role": "user", "content": "Count to 5"}],
            stream=True,
        )
        async for chunk in stream:
            print(chunk.choices[0].delta.content or "", end="", flush=True)

asyncio.run(main())

List Models

models = client.models.list()
for model in models:
    print(model.id)

Environment Variables

Variable Description
PENDRA_API_KEY Your Pendra API key (pdr_sk_...)

OpenAI Compatibility

The Pendra SDK is fully compatible with the OpenAI Python SDK interface. To migrate:

# Before
from openai import OpenAI
client = OpenAI(api_key="sk-...")

# After
from pendra import Pendra
client = Pendra(api_key="pdr_sk_...", base_url="https://your-pendra-instance.com")

The client.chat.completions.create() interface is identical.

Self-Hosting

Pendra is fully open source. Run your own instance:

git clone https://github.com/pendra-ai/pendra
cd pendra
cp .env.example .env
docker compose up -d

Licence

MIT

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

pendra-0.1.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

pendra-0.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file pendra-0.1.1.tar.gz.

File metadata

  • Download URL: pendra-0.1.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pendra-0.1.1.tar.gz
Algorithm Hash digest
SHA256 185aaff87e58c19c15c5ac20df52c5dbe7905941847cbe42333c3c37cc4c739f
MD5 20110fff81fbaa026b1edd3e17f0b5ae
BLAKE2b-256 be0624c6bb7df5e4543029ba5be022143cc4657e2a53de84f8d3480784d281b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pendra-0.1.1.tar.gz:

Publisher: publish-sdk-python.yml on Pendra-Cloud/pendra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pendra-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pendra-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pendra-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fe155c0afaa7b885c243ad39aab926f39ddf1aa6eb6e6527a7e66c9d6667ca5
MD5 c7d10d00a1cb2a68962251644e552e63
BLAKE2b-256 ff21038562f7933963accae58dfdd662496fba6ed178e4fab7cedf06186b1ef2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pendra-0.1.1-py3-none-any.whl:

Publisher: publish-sdk-python.yml on Pendra-Cloud/pendra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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