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

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 = v1.1.1
extras = test

Or using https:

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

interaktiv_aiclient-1.1.1.tar.gz (27.7 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-1.1.1-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: interaktiv_aiclient-1.1.1.tar.gz
  • Upload date:
  • Size: 27.7 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-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9323fceb05221365e357eadaabbbf588c2e20b968b1bfe3edb198d3960a94f37
MD5 0f6235f451c093dbe761f892ac6c65bf
BLAKE2b-256 24f6cca5851e400190102617bc93365676c7ff614eafe240308256b25cc8698f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for interaktiv_aiclient-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95020d70b78ed5ccf3efc54a296d3a6979eb51e1450932278c49b1aa7077efbf
MD5 4d6dcd3812721753b191a1f297846556
BLAKE2b-256 48578bcdcf129f013854e6adb5bf13cb7ce5cdeabc53b1c693e463c8d17934e6

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