Skip to content

Script Development / Connector Object DFF.CONN / LLM (OpenAI-compatible)

The LLM connector operation object is used to initiate text conversations through the OpenAI-compatible Chat Completions API configured in the connector.

This connector requires the target service to be compatible with the OpenAI Chat Completions API

Different services may support different models and request parameters; refer to the target service's documentation for details.

1. Connector Configuration

When creating an LLM connector, you need to configure the following fields:

Field Required / Default Description
Base URL Required / https://api.openai.com/v1 Base address of the OpenAI-compatible API
API Key Required API key used to access the target service
Model Required The model ID used by default; it must be a Chat Completions model ID supported by the target service

After filling in Base URL and API Key, when you expand the Model selection box, the UI attempts to load the model list through the target service's /models endpoint. If the loading fails, you can still manually enter a model ID supported by the target service.

Messages are sent to the target service and may incur charges

Please confirm the target service the connector points to, and do not send API keys, passwords, or other unrelated sensitive data in messages.

2. Getting the Connector Operation Object

The DFF.CONN(...) parameters are as follows:

Parameter Type Required / Default Description
connector_id str Required Connector ID
model str None Overrides the default model in the connector configuration
timeout int/float 60 Request timeout in seconds
Example
1
2
3
4
llm = DFF.CONN('llm_connector_id')

# Override the default model and request timeout for the current operation object
another_llm = DFF.CONN('llm_connector_id', model='another-model', timeout=30)

3. .chat(...)

It calls the OpenAI-compatible Chat Completions API. The method signature is as follows:

Python
1
llm.chat(messages, model=None, **kwargs)

The parameters are as follows:

Parameter Type Required / Default Description
messages str/list[dict] Required Conversation messages. When a string is passed, it is automatically converted into one user message; when a message list is passed, it is sent as-is
model str None Overrides the model for this call only
**kwargs any none Other keyword arguments are passed through to client.chat.completions.create(...) of the OpenAI Python SDK; availability depends on the target service

This method converts the full Chat Completions response to a dict and returns it. The text reply is usually located in choices[0].message.content.

For information about Chat Completions request parameters and response structure, refer to OpenAI API / Create chat completion.

3.1 Single-turn Conversation

messages can be passed directly as a string:

Example
1
2
3
4
5
llm = DFF.CONN('llm_connector_id')

response = llm.chat('What is DataFlux Func?')
reply    = response['choices'][0]['message']['content']
print(reply)

The string is automatically converted to the following message list before being sent:

Python
1
2
3
4
messages = [{
    'role'   : 'user',
    'content': 'What is DataFlux Func?',
}]

3.2 Multi-turn Conversation

This connector does not save conversation history. For multi-turn conversations, the script should save the full message list and pass it in on each call:

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
llm = DFF.CONN('llm_connector_id')

messages = [
    {
        'role'   : 'system',
        'content': 'Please answer briefly.',
    },
    {
        'role'   : 'user',
        'content': 'What is DataFlux Func?',
    },
]

response = llm.chat(messages, temperature=0)
reply    = response['choices'][0]['message']['content']

messages.append({
    'role'   : 'assistant',
    'content': reply,
})
messages.append({
    'role'   : 'user',
    'content': 'What tasks is it suitable for?',
})

response = llm.chat(messages, temperature=0)

3.3 Temporarily Overriding the Model

The model is selected according to the following priority:

  1. The model parameter of .chat(...);
  2. The model parameter of DFF.CONN(...);
  3. The Model in the connector configuration.
Example
1
2
3
4
llm = DFF.CONN('llm_connector_id', model='default-model-for-this-object')

# This call uses another-model
response = llm.chat('Hello!', model='another-model')

4. Capability Boundaries and Security Considerations

  • This connector calls the Chat Completions API, not the Responses API.
  • This connector only supports non-streaming responses; do not pass stream=True.
  • This connector does not save conversation history or automatically manage context length. You should limit the message history and output size according to the model's context window, the DataFlux Func task timeout, and the caller's requirements.
  • Although other parameters can be passed through **kwargs, this connector does not manage tool calls, files, images, audio, or other content, nor does it automatically execute tool parameters returned by the model.
  • Model output is untrusted data. Before executing code, commands, SQL, or tool parameters generated by the model, you must separately validate and confirm authorization.