Skip to main content
Ctrl+K
PyFlink 1.20+vvr.11.7.dev0 documentation - Home PyFlink 1.20+vvr.11.7.dev0 documentation - Home
  • API Reference
  • Examples
  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataStream
  • PyFlink DataFrame
    • DataFrame
    • DataFrame Creation
    • Input/Output
    • SQL
    • DataType
    • User Defined Functions
    • Configuration
    • GPU Support
    • AI / LLM
  • PyFlink Common
  • API Reference
  • PyFlink DataFrame
  • AI / LLM
  • pyflink.dataframe.ai.llm.set_provider

pyflink.dataframe.ai.llm.set_provider#

set_provider(name_or_provider: str | Provider, provider: Provider | None = 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 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, 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

AI / LLM

next

pyflink.dataframe.ai.llm.set_default_provider

On this page
  • set_provider()

This Page

  • Show Source

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.16.1.