OpenRouter integration with Plone
Project description
interaktiv.aiclient
This is a simple OpenRouter integration for Plone.
Tested for Plone 6.0.15
Configuration
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.1
extras = test
Or using https:
[interaktiv.aiclient]
url = https://github.com/interaktivgmbh/interaktiv.aiclient.git
rev = v2.0.1
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interaktiv_aiclient-2.0.1.tar.gz.
File metadata
- Download URL: interaktiv_aiclient-2.0.1.tar.gz
- Upload date:
- Size: 67.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eef690668b387e84f4cc79520eedc87cbc06a075669792c5553df31845ad68e1
|
|
| MD5 |
005fc6874ed35fdbbf3e2e86b53616fe
|
|
| BLAKE2b-256 |
699957c5f0817a377c0d5cad0edadf38ea2cb983e47eefd1bc404ff6b70e779e
|
File details
Details for the file interaktiv_aiclient-2.0.1-py3-none-any.whl.
File metadata
- Download URL: interaktiv_aiclient-2.0.1-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e65986125dd7f76ed8679770dec634184856c50a10b22905e5acdebabd3024f4
|
|
| MD5 |
e6d96c74751c043a56e3ef816b08b4f2
|
|
| BLAKE2b-256 |
2d5f9e309b16ab72e86838d7c7bcfefce94dc0c0f09067ab5e45f630f38ca8f8
|