Skip to main content

Genkit FastAPI Plugin

Project description

Genkit FastAPI Plugin

Serve Genkit flows as FastAPI endpoints.

Installation

pip install genkit-plugin-fastapi

Usage

from fastapi import FastAPI from genkit import Genkit from genkit.plugins.fastapi import genkit_fastapi_handler from genkit.plugins.google_genai import GoogleAI

ai = Genkit(plugins=[GoogleAI()]) app = FastAPI()

@ai.flow() async def chat_flow(prompt: str) -> str: response = await ai.generate(prompt=prompt) return response.text

@app.post('/chat') @genkit_fastapi_handler(ai) async def chat(): return chat_flow

Running

# With Genkit Dev UI
genkit start -- uvicorn main:app --reload

# Production (no Dev UI)
uvicorn main:app

Streaming

The handler automatically supports streaming when the client sends Accept: text/event-stream:

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"data": "Tell me a joke"}'

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

genkit_plugin_fastapi-0.6.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

genkit_plugin_fastapi-0.6.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file genkit_plugin_fastapi-0.6.0.tar.gz.

File metadata

  • Download URL: genkit_plugin_fastapi-0.6.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for genkit_plugin_fastapi-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7d561754e0bf2d7a76d3d985f893cadb1c9530aad823311efed381ce8ba51da7
MD5 390955f49c917633847ca0813ee6d390
BLAKE2b-256 9484b624f7cc186099b48365217fd1cf51b261dc0198c478688bd52eda3a6b23

See more details on using hashes here.

Provenance

The following attestation bundles were made for genkit_plugin_fastapi-0.6.0.tar.gz:

Publisher: publish_python.yml on genkit-ai/genkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genkit_plugin_fastapi-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for genkit_plugin_fastapi-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6f6d4b3d5bd3da14d3649b2c5d13d9b2891ae806e0bfd007bf298d9965e88c
MD5 39eedc277fc9fbd82e6624cb14a74425
BLAKE2b-256 2c3de1d93cb5d2a7e07787d505f54e31c59fc66d2712ef2662b2098cdcab69dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for genkit_plugin_fastapi-0.6.0-py3-none-any.whl:

Publisher: publish_python.yml on genkit-ai/genkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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