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

Or using https:

[interaktiv.aiclient]
url = https://github.com/interaktivgmbh/interaktiv.aiclient.git
rev = v1.1.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-1.1.0.tar.gz (26.2 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.0-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for interaktiv_aiclient-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f1ed33f0cf6b67c37d6e50bfbe0940fcb8df9efcf892051f8ec962892fa9b252
MD5 dcc80b2fc291e405f6145cfa3bb67c23
BLAKE2b-256 f3c16b24dd039be7e1bb9f8fc98f4c7f6f83d62ce450c8f3707c00f5229ac8f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for interaktiv_aiclient-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35f903de1486113ebbac9b3ae42a28b50bd22cc11e617de31bfb58b49da638f9
MD5 086ab891108e0fbd1e7d12b7d024da26
BLAKE2b-256 35d0da01b086df0f31863ded1a883c7cf16638914c8c6e1be227b9d1fdc0d7ea

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