Genkit Django Plugin
Project description
Genkit Django Plugin
genkit-plugin-django exposes Genkit flows as HTTP endpoints in a Django application. It mirrors genkit-plugin-flask and genkit-plugin-fastapi: one decorator turns a @ai.flow() into a Django view that speaks the Genkit HTTP protocol (JSON envelope, optional SSE streaming, structured error responses).
Install
pip install genkit-plugin-django
Usage
# myapp/views.py
from genkit import Genkit
from genkit.plugins.django import genkit_django_handler
ai = Genkit(plugins=[...])
@genkit_django_handler(ai)
@ai.flow()
async def chat(prompt: str) -> str:
response = await ai.generate(prompt=prompt)
return response.text
# myproject/urls.py
from django.urls import path
from myapp.views import chat
urlpatterns = [
path('chat/', chat),
]
The view requires Django's ASGI server (Django 4.1+):
uvicorn myproject.asgi:application
Wire protocol
- Body:
{"data": <flow_input>}. Missingdata→ 400. - Streaming:
Accept: text/event-streamor?stream=true. Each chunk emitsdata: {"message": ...}\n\n; completion emitsdata: {"result": ...}\n\n; on exceptionerror: {"error": ...}. - Non-stream:
{"result": <flow_output>}on success; 500 withHttpErrorWireFormatJSON on exception.
Context provider
async def auth(request_data):
return {'username': request_data.headers.get('authorization')}
@genkit_django_handler(ai, context_provider=auth)
@ai.flow()
async def chat(prompt, ctx):
user = ctx.context.get('username')
...
Project details
Release history Release notifications | RSS feed
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 genkit_plugin_django-0.7.0.tar.gz.
File metadata
- Download URL: genkit_plugin_django-0.7.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f58b7e20d8c6477ecaaa39e5d7c82e8fc3ec7ca5998f85aff0dab238ce409c81
|
|
| MD5 |
3725afca7e96918dab9a785d467ad2c5
|
|
| BLAKE2b-256 |
0c696e70ecf0b78570beed9be0b020f4e92bcebe6d369c968ef268baec4999b9
|
Provenance
The following attestation bundles were made for genkit_plugin_django-0.7.0.tar.gz:
Publisher:
publish_python.yml on genkit-ai/genkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genkit_plugin_django-0.7.0.tar.gz -
Subject digest:
f58b7e20d8c6477ecaaa39e5d7c82e8fc3ec7ca5998f85aff0dab238ce409c81 - Sigstore transparency entry: 1780844225
- Sigstore integration time:
-
Permalink:
genkit-ai/genkit@546090f09745c7f9b24a2fbc02ddca2d474c92d6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/genkit-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_python.yml@546090f09745c7f9b24a2fbc02ddca2d474c92d6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file genkit_plugin_django-0.7.0-py3-none-any.whl.
File metadata
- Download URL: genkit_plugin_django-0.7.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d46084d9754abfb8134ca602eb91bb8c256a3d85cf2a157a5537d12b5f8a95f
|
|
| MD5 |
1e36db1a558f68cd44026c156d6cd348
|
|
| BLAKE2b-256 |
5af343d5494fc72b45e70bf5e4d363ae99e9d33a8709d7b133a38ca4e8a27a11
|
Provenance
The following attestation bundles were made for genkit_plugin_django-0.7.0-py3-none-any.whl:
Publisher:
publish_python.yml on genkit-ai/genkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genkit_plugin_django-0.7.0-py3-none-any.whl -
Subject digest:
1d46084d9754abfb8134ca602eb91bb8c256a3d85cf2a157a5537d12b5f8a95f - Sigstore transparency entry: 1780845344
- Sigstore integration time:
-
Permalink:
genkit-ai/genkit@546090f09745c7f9b24a2fbc02ddca2d474c92d6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/genkit-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_python.yml@546090f09745c7f9b24a2fbc02ddca2d474c92d6 -
Trigger Event:
workflow_dispatch
-
Statement type: