FlowiseAI/Flowise · error · Error

Please set the REPLICATE_API_TOKEN

Error message

Please set the REPLICATE_API_TOKEN

What it means

Replicate constructor checks only fields.apiKey (no environment-variable fallback) and throws if falsy. Unlike HuggingFaceInference, REPLICATE_API_TOKEN is NOT read automatically here.

Source

Thrown at packages/components/nodes/llms/Replicate/core.ts:34

export class Replicate extends LLM implements ReplicateInput {
    lc_serializable = true

    model: ReplicateInput['model']

    input: ReplicateInput['input']

    apiKey: string

    promptKey?: string

    constructor(fields: ReplicateInput & BaseLLMParams) {
        super(fields)

        const apiKey = fields?.apiKey

        if (!apiKey) {
            throw new Error('Please set the REPLICATE_API_TOKEN')
        }

        this.apiKey = apiKey
        this.model = fields.model
        this.input = fields.input ?? {}
        this.promptKey = fields.promptKey
    }

    _llmType() {
        return 'replicate'
    }

    /** @ignore */
    async _call(prompt: string, options: this['ParsedCallOptions']): Promise<string> {
        const replicate = await this._prepareReplicate()
        const input = await this._getReplicateInput(replicate, prompt)

        const output = await this.caller.callWithOptions({ signal: options.signal }, () =>

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Attach a Replicate credential to the node so apiKey is passed into fields.
  2. Explicitly read the env var and pass it: new Replicate({ apiKey: process.env.REPLICATE_API_TOKEN, ... }).
  3. Verify the credential was saved with a non-empty token before re-running.

Example fix

// before
const llm = new Replicate({ model: 'meta/llama-2-70b', input: {} })
// after
const llm = new Replicate({ model: 'meta/llama-2-70b', input: {}, apiKey: process.env.REPLICATE_API_TOKEN })
Defensive patterns

Strategy: validation

Validate before calling

// Replicate has NO env fallback - you must pass apiKey explicitly
const apiKey = fields.apiKey ?? process.env.REPLICATE_API_TOKEN
if (!apiKey) throw new Error('REPLICATE_API_TOKEN is not set')
const llm = new Replicate({ ...fields, apiKey })

Type guard

function hasReplicateToken(fields: { apiKey?: string }): boolean {
  return Boolean(fields.apiKey ?? process.env.REPLICATE_API_TOKEN)
}

Try / catch

try {
  const llm = new Replicate(fields)
} catch (e) {
  if (/REPLICATE_API_TOKEN/.test((e as Error).message)) {
    // prompt for credential setup; do not retry
  }
  throw e
}

Prevention

When it happens

Trigger: Instantiating the Replicate LLM node without passing apiKey in fields, even if REPLICATE_API_TOKEN is set in the environment.

Common situations: Expecting the env var to be picked up automatically (it is not); credential not wired into the node; credential object empty.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/fb0e45e858a011cb. Report an issue: GitHub.