Skip to content

Blocks Catalog

Below is a list of Blocks available for registration in prefect-openai.

To register blocks in this module to view and edit them on Prefect Cloud:

prefect block register -m prefect_openai
Note, to use the load method on Blocks, you must already have a block document saved through code or saved through the UI.

Credentials Module

OpenAICredentials

Credentials used to authenticate with OpenAI.

To load the OpenAICredentials:

from prefect import flow
from prefect_openai.credentials import OpenAICredentials

@flow
def my_flow():
    my_block = OpenAICredentials.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Credentials Module under Examples Catalog.

Completion Module

CompletionModel

A block that contains config for an OpenAI Completion Model. Learn more in the OpenAPI Text Completion docs.

To load the CompletionModel:

from prefect import flow
from prefect_openai.completion import CompletionModel

@flow
def my_flow():
    my_block = CompletionModel.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Completion Module under Examples Catalog.

Image Module

ImageModel

A block that contains config for an OpenAI Image Model. Learn more in the OpenAPI Image generation docs.

To load the ImageModel:

from prefect import flow
from prefect_openai.image import ImageModel

@flow
def my_flow():
    my_block = ImageModel.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Image Module under Examples Catalog.