Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataFrame
    • DataFrame
    • DataFrame Creation
    • Input/Output
    • SQL
    • Data Types
    • User Defined Functions
    • Configuration
    • Catalog
    • GPU Support
    • AI / LLM
  • PyFlink Multimodal
  • PyFlink DataStream
  • PyFlink Common

pyflink.dataframe.set_provider#

set_provider(name_or_provider: Union[str, pyflink.dataframe.ai.providers.Provider], provider: Optional[pyflink.dataframe.ai.providers.Provider] = None, **options) → None[source]#

Register a global provider configuration.

Can be called in three ways:

  1. set_provider(Provider_instance) — register under the provider’s default name (e.g. "openai-compat").

  2. set_provider("name", Provider_instance) — register under a custom name. This allows registering multiple instances of the same provider type (e.g. one for chat, one for embeddings).

  3. set_provider("name", **options) — create a built-in provider when name matches a built-in provider name, otherwise create a GenericProvider with the given options.

Parameters
  • name_or_provider – Either a Provider instance (form 1) or a custom name string (forms 2 and 3).

  • provider – A Provider instance to register under the custom name (form 2 only).

  • **options – Provider options (form 3 only, dispatches when name matches a built-in provider name, otherwise wraps in GenericProvider).

Example::
>>> import pyflink.dataframe as pf
>>> # Form 1: Provider instance (registered as "openai-compat")
>>> pf.set_provider(pf.OpenAICompatProvider(
...     endpoint="https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
...     api_key="sk-..."))
>>> # Form 2: Custom name + Provider instance
>>> pf.set_provider("chat", pf.OpenAICompatProvider(
...     endpoint="https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
...     api_key="sk-..."))
>>> pf.set_provider("embedding", pf.OpenAICompatProvider(
...     endpoint="https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings",
...     api_key="sk-..."))
>>> # Form 3: Generic string API
>>> pf.set_provider(
...     "openai-compat",
...     endpoint="https://dashscope.aliyuncs.com/compatible-mode"
...              "/v1/chat/completions",
...     api_key="sk-...")

previous

pyflink.dataframe.GenericProvider.to_options

next

pyflink.dataframe.set_default_provider

Show Source

Created using Sphinx 4.5.0.