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_fastapi import genkit_fastapi_handler from genkit_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_fastapi-0.9.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

genkit_fastapi-0.9.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file genkit_fastapi-0.9.0.tar.gz.

File metadata

  • Download URL: genkit_fastapi-0.9.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for genkit_fastapi-0.9.0.tar.gz
Algorithm Hash digest
SHA256 c6e64a8fa4c1b72fda74198b49c61b3e6c095f021e906c917efaed99cc4957e0
MD5 f400b28355955aa1b9d5bb431ff0cde5
BLAKE2b-256 410ef38e20a955011e3dd8e94af4a17c55d6d5f8e52fd5c1f3f8d327edb0e1da

See more details on using hashes here.

Provenance

The following attestation bundles were made for genkit_fastapi-0.9.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_fastapi-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: genkit_fastapi-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for genkit_fastapi-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c5ee14b0f393757615c9e49010561da440fd0d3a89a41bdca11352253c1e368
MD5 111ea081d558fde8d3ea271360a0d17b
BLAKE2b-256 c658cc181831f649a1ffa50c8c63a0fd6f270764de4f1ddf672bbfe2445d8745

See more details on using hashes here.

Provenance

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