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.7.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.7.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: genkit_plugin_fastapi-0.7.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.7.0.tar.gz
Algorithm Hash digest
SHA256 fa17606cd6c725ad1a8458f525d74a5727bc2988ffeeeaed942c0abeb31eb534
MD5 56fd98ddc1e0884b0224d5455e3d3aeb
BLAKE2b-256 066e50277d9baf6ae376178d2f5ea643d25fe79f931476161adda14bc601294c

See more details on using hashes here.

Provenance

The following attestation bundles were made for genkit_plugin_fastapi-0.7.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.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for genkit_plugin_fastapi-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b31f186b8c4ef1a37336202cf25bb3691c9536a4b2f1011028bf5be1f230ab9d
MD5 d9c5c1b32b9780bae530c08625c6e730
BLAKE2b-256 9e1e8ed7316853d7181389bc855615c5f7f32045ee7cb9ae04898fab66859a3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for genkit_plugin_fastapi-0.7.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