Skip to content

Services

flowdrop_ai_provider.model_service

Class: Drupal\flowdrop_ai_provider\Service\AiModelService

Lists and resolves models through Drupal AI's provider manager. Results are cached so a node's schema and its run do not instantiate every provider again.

Method Returns
getAvailableModels(string $operation_type = 'chat', array $capabilities = []) Models for the operation type, keyed by model id, each with name and provider.
getModel(string $model_id, string $operation_type = '') The model config (id, provider, ...) or NULL.
getDefaultModelForOperationType(string $operation_type) The site default model id, or NULL.
hasProvidersForOperationType(string $operation_type, array $capabilities = []) Whether any model supports the operation type.

flowdrop_ai_provider.operation_availability

Class: Drupal\flowdrop_ai_provider\Service\AiOperationAvailability

Maps an executor plugin id (flowdrop_ai_provider:<id>) to the Drupal AI operation type it needs and says whether a provider exists for it. The node sidebar filter and the node type form warning both use it, so they agree.

  • getOperationType(string $executorPlugin): ?string
  • isExecutorAvailable(string $executorPlugin): bool

A plugin whose id differs from its operation type needs an entry in the class's map (for example simple_chat maps to chat). A plugin id that is not a Drupal AI operation type, such as guardrails or session_history, counts as needing no provider and is always available.

flowdrop_ai_provider.ai_prompt_resolver

Class: Drupal\flowdrop_ai_provider\Service\AiPromptResolver

  • resolve(string $value, array $variables = []): string returns plain text unchanged, or loads the prompt for an ai_prompt:<id> reference. Either way it replaces {name} placeholders from $variables. Throws when the referenced prompt does not exist.
  • isReference(string $value): bool

flowdrop_ai_provider.secure_file_loader

Class: Drupal\flowdrop_ai_provider\Service\SecureFileLoader

Loads file contents for media nodes. Use it for any path or URL that comes from workflow input. See Security for the checks it runs.

  • loadFromFile(string $path): string
  • loadFromUrl(string $url): string

Both throw on failure; neither returns FALSE.

flowdrop_ai_provider.cost_calculator

Interface: Drupal\flowdrop_ai_provider\Cost\CostCalculatorInterface (@api)

Prices the token usage of one AI call. The Chat, Simple Chat and Decision nodes add its result to usage.cost. The default class, NullCostCalculator, prices nothing, so usage has no cost key.

  • calculate(string $provider_id, string $model_id, array $usage): ?array receives the usage keys (input, output, total, reasoning, cached, cache_write) and returns input, output, cached, cache_write, total and currency, or NULL when the cost is unknown.

To price calls, replace the service from your module's service provider alter(), as the flowdrop_ai_provider_metering submodule does with FlowdropAiProviderMeteringServiceProvider. A site has one calculator: if two modules replace the service, the last one wins, so do not enable two modules that both price calls. See Usage and cost.

flowdrop_ai_provider.token_usage

Class: Drupal\flowdrop_ai_provider\Service\TokenUsageBuilder (@internal)

Builds the usage output of the AI nodes from the provider response and adds the cost. It is internal to this module: read the usage from the node output instead.

flowdrop.chat_reasoner

Class: Drupal\flowdrop_ai_provider\Service\Reasoning\ChatReasoner

FlowDrop ships a null reasoner under this service id. This module replaces it, so FlowDrop's Reason node gets a working backend once the module is enabled. ChatReasoner translates FlowDrop's ReasonRequest into a Drupal AI chat call with function calling, and maps the response back to a ReasonResult. Loop control and tool call pairing stay in FlowDrop.

Model resolution: the model on the request, then the default for the request's operation type, then the chat default, then the first available model.