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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for genkit_plugin_fastapi-0.5.2.tar.gz
Algorithm Hash digest
SHA256 cf9bddedd2f451d8b9475ef9f177cdba718b2a5dca5def147757c3bb42718564
MD5 6d7c081ef7035bcbf3460ac457eed1d6
BLAKE2b-256 b2d95f5fa4fd13abd2c0d010ab16a38b13a7b5a0b4db7cba14e3681b6cb804ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for genkit_plugin_fastapi-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6fa57d4a609f7f93b3674e1818d0466737d5456a62686a32bf98d905b8a5f3f0
MD5 8613c96931963f89fc5da04f1fd0509d
BLAKE2b-256 c4a3fc6d5aff05bda059519f0bff6511473fa6394b2dc2b5011076416ef80577

See more details on using hashes here.

Provenance

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