// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Components extends APIResource { /** * Run a component with the given inputs */ run( componentID: string, params: ComponentRunParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-API-Key': xAPIKey, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/components/${componentID}/run`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xAPIKey != null ? { 'X-API-Key': xAPIKey } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } export type ComponentRunResponse = { [key: string]: unknown }; export interface ComponentRunParams { /** * Body param: The config to the component */ config: { [key: string]: unknown }; /** * Body param: The inputs to the component */ inputs: { [key: string]: unknown }; /** * Body param: The model name */ model_name?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param */ 'X-API-Key'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Components { export { type ComponentRunResponse as ComponentRunResponse, type ComponentRunParams as ComponentRunParams }; }