Skip to main content

interaktiv.aiclient

Code checks

This is a simple OpenRouter integration for Plone.

Tested with Plone 6.0, 6.1 and 6.2.

Configuration

AI Client controlpanel

In the controlpanel, you may configure the

  • OpenRouter API key
  • the used model
  • the maximum amount of retries per request
  • the maximum amount of concurrent requests
  • the timeout for each request in seconds

How to use

To get started, fill in your API key and select a model from the AI Client controlpanel. Available models are fetched from the OpenRouter Models API.

You may also set the maximum amount of retries and a timeout for each request.

You can then get the AI Client utility and call its call method with a prompt.

from interaktiv.aiclient.client import AIClient
from interaktiv.aiclient.interfaces import IAIClient
from zope.component import getUtility

prompt = [{"role": "user", "content": "Hello World!"}]

ai_client: AIClient = getUtility(IAIClient)
response = ai_client.call(prompt)

To run multiple prompts concurrently, you can use the batch method instead. Pass a list of prompts, following the same format as shown above.

from interaktiv.aiclient.client import AIClient
from interaktiv.aiclient.interfaces import IAIClient
from zope.component import getUtility

prompts = [
    [{"role": "user", "content": "This is the first prompt."}],
    [{"role": "user", "content": "And this is the second prompt."}],
]

ai_client: AIClient = getUtility(IAIClient)
result = ai_client.batch(prompts)

The order is preserved in the result, meaning that you can map the prompt index to the response index. This is a good use case for python's zip function.

Failed requests (after the configured retries) return None; in a batch, other errors are returned in place of the answer.

Keyword arguments are passed on to the chat completions request, for call and for every prompt of a batch. Parameters only OpenRouter knows go into extra_body:

ai_client.call(
    prompt,
    max_tokens=500,
    temperature=0.2,
    extra_body={"reasoning": {"enabled": False}},
)

Unknown parameters raise a TypeError right away, also in batch.

Prompts use the message format of the OpenAI chat completions API, which OpenRouter implements and are sent unchanged. Content can also be a list of parts, e.g. for images:

prompt = [
    {"role": "system", "content": "Answer in one sentence."},
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "What does this picture show?"},
            {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}},
        ],
    },
]

For more information on how to construct prompts, please refer to the OpenAI docs.

Adding this add-on to your project

Install the add-on using pip:

pip install interaktiv.aiclient

or if you're using uv:

uv pip install interaktiv.aiclient

Install from source

You can also install the add-on from the source. In your mx.ini file, add:

[interaktiv.aiclient]
url = git@github.com:interaktivgmbh/interaktiv.aiclient.git
rev = v3.0.0
extras = test

Or using https:

[interaktiv.aiclient]
url = https://github.com/interaktivgmbh/interaktiv.aiclient.git
rev = v3.0.0
extras = test

Contribute

License

The project is licensed under GPLv2.

Credits and acknowledgements

Generated using Cookieplone (0.9.10) and cookieplone-templates (eae593d) on 2025-11-21 13:43:16.160908. A special thanks to all contributors and supporters!

Metadata

Release files for interaktiv.aiclient 3.0.0

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

Source distribution (sdist)

Source distribution for interaktiv.aiclient 3.0.0
File Size Uploaded Provenance Actions
interaktiv_aiclient-3.0.0.tar.gz 69.9 kB Without provenance Details for interaktiv_aiclient-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for interaktiv.aiclient 3.0.0
File Interpreter ABI Platform Actions
interaktiv_aiclient-3.0.0-py3-none-any.whl Python 3 none any Details for interaktiv_aiclient-3.0.0-py3-none-any.whl

Total release size: 103.6 kB

Release files / interaktiv_aiclient-3.0.0.tar.gz

Download URL interaktiv_aiclient-3.0.0.tar.gz
Size 69.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a7482225f0a8605906b6249bad699292e92b80b6915cc8a7bfa28520e2457cfc
BLAKE2b-256 checksum
How to use checksums
ee8f5d10ba2bba8e483e86174c2216a371ab64e58c31f7fd36ef11dde34a315e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Pop!_OS","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.3"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.3","system":{"name":"Linux","release":"7.0.11-76070011-generic"}} HTTPX2/2.13.1

Release files / interaktiv_aiclient-3.0.0-py3-none-any.whl

Download URL interaktiv_aiclient-3.0.0-py3-none-any.whl
Size 33.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aabffc0d225bfaddb53d80bc7b02d068ee8eb4f20c7abeaad5f507b78c4c2124
BLAKE2b-256 checksum
How to use checksums
e5be83cfda746528837c3399c4b0755486be82e723db030196946231cc830e00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Pop!_OS","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.3"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.3","system":{"name":"Linux","release":"7.0.11-76070011-generic"}} HTTPX2/2.13.1

Security for interaktiv.aiclient 3.0.0

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