Skip to main content
Your action can have a fetchers property that is an array of fetcher references. Fetchers allow you to populate dropdown options dynamically by fetching data from external APIs.

Define the fetcher in your action

First, export a fetcher constant and reference it in your action: In the action file (actions/createChatCompletion.ts):

Implement the fetcher handler

The fetcher implementation logic should be defined in your handlers file using createFetcherHandler: In the handlers file (handlers.ts):

Fetcher response format

The fetcher function must return an object with either a data or error property:
  • Success: { data: (string | { label: string; value: string })[] }
  • Error: { error: string | { description: string; details?: string; context?: string } }
The data array can contain either:
  • Simple strings: ["model-1", "model-2", "model-3"]
  • Objects with label and value: [{ label: "GPT-4", value: "gpt-4" }, { label: "GPT-3.5", value: "gpt-3.5-turbo" }]

Available parameters

The fetcher handler receives the following parameters:
  • credentials: The authenticated credentials for the action
  • options: The current values of all action options (useful when you have dependencies between options)
By passing the action as the first parameter to createFetcherHandler, TypeScript will automatically infer the correct types for credentials and options.