Skip to main content

OpenRouter integration with Plone

Project description

interaktiv.aiclient

Code checks

This is a simple OpenRouter integration for Plone.

Tested for Plone 6.0.15

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.

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 = v2.0.0
extras = test

Or using https:

[interaktiv.aiclient]
url = https://github.com/interaktivgmbh/interaktiv.aiclient.git
rev = v2.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!

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

interaktiv_aiclient-2.0.0.tar.gz (65.0 kB view details)

Uploaded Source

Built Distribution

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

interaktiv_aiclient-2.0.0-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file interaktiv_aiclient-2.0.0.tar.gz.

File metadata

  • Download URL: interaktiv_aiclient-2.0.0.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.3 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for interaktiv_aiclient-2.0.0.tar.gz
Algorithm Hash digest
SHA256 50e39d216761619d6000653813df50f3291f63fc1d4d9f796fb07875a0177a24
MD5 602a3eb4e1c0366e59fbcabe65c4e709
BLAKE2b-256 bd285cda9ed73fa913781bac30105a488b399b7d5c48828a81b2815599648c7d

See more details on using hashes here.

File details

Details for the file interaktiv_aiclient-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for interaktiv_aiclient-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7f358689ad376ac5164e08eac71694ba91bf8e69dc5e64c3168cb900c280c38
MD5 b8728e84c31870873ce572fda4c14847
BLAKE2b-256 a464953b68a2eaee449045d499366c0e53ffee829674a14d96f26b2dd4f0af8d

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