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.0rc1.tar.gz (8.5 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.0rc1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: genkit_plugin_fastapi-0.6.0rc1.tar.gz
  • Upload date:
  • Size: 8.5 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.0rc1.tar.gz
Algorithm Hash digest
SHA256 bc93aa89376058b3cadee0ec9a133b21747da226ed66f7be5c2974a744aaa56f
MD5 197e852f495359655b0045f88d380f4c
BLAKE2b-256 0d9d44d76856ea4123b06d9bd0e564ea69535a41d6223ed326ec7f1af7f52d32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for genkit_plugin_fastapi-0.6.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc342dc234ae33a6f2922d8a88f65498ff87c39cada72b450ede4c0df663787e
MD5 346c86de92fff0f099e63456ce9187b4
BLAKE2b-256 ec8629cd08571e100777646ca98b720d0067b64440a0234d62f135df4cc25454

See more details on using hashes here.

Provenance

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