Skip to main content

createLLMProviderFromEnv

workflow.createLLMProviderFromEnv() is the provider factory exposed to business workflows by src/runtime-api.ts in the Core repository. It delegates to createLLMProviderFromWorkflowEnv() and reads environment variables through workflow.getEnv.

Signature

workflow.createLLMProviderFromEnv(): LLMProvider

Parameter

ParameterDescription
NoneRead configuration directly from the workflow runtime environment.

Environment variables read

VariableAliasDescription
LLM_TYPETYPEprovider type, required. Supports OpenAI completion, OpenAI responses, and Anthropic.
LLM_API_KEYAPI_KEY, APIKEYProvider API key. Required.
LLM_BASE_URLBASE_URLCustom provider base URL.
LLM_MODELMODELThe model name. The default model is used when not passed.

Provider Type

Input valueNormalization resultsDescription
openai-completion, openai-chat, chat, completionopenai-completionUse the OpenAI Chat Completions API.
openai-responses, openai-response, responses, responseopenai-responsesUse the OpenAI Responses API.
anthropic, claudeanthropicUse the Anthropic Messages API.

Default Model

Provider TypeDefault Model
openai-completiongpt-4.1-mini
openai-responsesgpt-4.1-mini
anthropicclaude-3-haiku-20240307

Return value

ReturnTypeDescription
providerLLMProvidercontains name, chat(input), stream(input).

Create Process

PhaseInputResult
runtime envLLM_* Variableprovider options
createLLMProviderFromEnvprovider optionsLLMProvider
LLM nodeLLMProvider, LLMChatInputLLM output

Example

const llmProvider = workflow.createLLMProviderRef("default", () => {
return workflow.createLLMProviderFromEnv();
});

Error

SituationError TypeDescription
Missing LLM_TYPE or LLM_API_KEYinput_validationprovider configuration is incomplete.
Unsupported provider typeinput_validationLLM_TYPE cannot be normalized to a supported type.