Skip to main content
Complete type definitions for the Graphy AI SDK.

GraphConfig

The chart configuration object. See Graph Config Schema for the complete reference.
import type { GraphConfig } from '@graphysdk/core';

GenerateGraphParams

Request parameters for the Chart Maker Agent.
interface GenerateGraphParams {
  config: GraphConfig;
  userPrompt: string;
  metadata?: Metadata;
  storytellingOptions?: StorytellingOptions;
}
FieldTypeRequiredDescription
configGraphConfigYesThe current chart configuration
userPromptstringYesNatural language instruction
metadataMetadataNoRequest tracking information
storytellingOptionsStorytellingOptionsNoPrune storytelling from config content client-side (SDK only).

GenerateGraphResponse

Response from the Chart Maker Agent.
interface GenerateGraphResponse {
  config: GraphConfig;
  response: {
    message: string;
    steps?: string[];
  };
}
FieldTypeDescription
configGraphConfigUpdated chart configuration. Narrative (title, subtitle, caption) is embedded in config.content as TipTap JSON documents.
response.messagestringExplanation of changes made
response.stepsstring[]Optional breakdown of modifications

GenerateGraphSuggestionsParams

Request parameters for the Suggestions Agent.
interface GenerateGraphSuggestionsParams {
  config: GraphConfig;
  userPrompt: string;
  metadata?: Metadata;
  maxSuggestionCount?: 1 | 2 | 3 | 4;
}
FieldTypeRequiredDescription
configGraphConfigYesThe chart configuration containing the dataset
userPromptstringYesNatural language description of what to visualize
metadataMetadataNoRequest tracking information
maxSuggestionCount1 | 2 | 3 | 4NoOptional cap (1–4) passed to the model for how many suggestions to aim for. Omitted uses the default (4). Responses are not truncated if longer.

GenerateGraphSuggestionsResponse

Response from the Suggestions Agent.
interface GenerateGraphSuggestionsResponse {
  suggestions: Suggestion[];
}
FieldTypeDescription
suggestionsSuggestion[]List of chart type suggestions

Suggestion

A single chart suggestion returned by the Suggestions Agent.
interface Suggestion {
  dataPrepPrompt: string;
  chartType: AiChartType;
  summary: string;
}
FieldTypeDescription
dataPrepPromptstringPrompt describing how to prepare the data for this chart
chartTypeAiChartTypeSuggested chart type
summarystringShort description of what the chart would show

StorytellingOptions

SDK-only options to prune storytelling fields from the config content after the API returns. For each option set to true, the SDK removes that field from config.content before returning.
interface StorytellingOptions {
  excludeTitle?: boolean;
  excludeSubtitle?: boolean;
  excludeCaption?: boolean;
}
FieldTypeDescription
excludeTitlebooleanIf true, the SDK removes config.content.title.
excludeSubtitlebooleanIf true, the SDK removes config.content.subtitle.
excludeCaptionbooleanIf true, the SDK removes config.content.caption.

Metadata

Optional tracking information for requests.
interface Metadata {
  callId?: string;
  locale?: string;
  storytellingEffort?: 'none' | 'low' | 'medium' | 'high';
}
FieldTypeDescription
callIdstringRequired when metadata is provided. Unique identifier for tracking and debugging.
localestringLocale for responses (e.g., en-US, fr-FR).
storytellingEffort'none' | 'low' | 'medium' | 'high'Which narrative fields the agent embeds in config.content: none → no narrative; low → title only; medium → title + caption; high → title + subtitle + caption. Default is 'low'.

SSE Events

ProgressEvent

interface ProgressEvent {
  type: 'progress';
  percentage: number;
  message?: string;
  metadata?: Record<string, unknown>;
}

CompleteEvent

interface CompleteEvent<T> {
  type: 'complete';
  data: T;
}

ErrorEvent

interface ErrorEvent {
  type: 'error';
  error: string;
  code?: string;
  retryable?: boolean;
}

SSEEvent Union

type SSEEvent<T> = ProgressEvent | CompleteEvent<T> | ErrorEvent;

Error Types

GraphyApiError

Error thrown by the SDK when an API request fails. Covers HTTP errors, SSE stream errors, and network failures.
import { GraphyApiError } from '@graphysdk/agents-sdk';

class GraphyApiError extends Error {
  readonly status: number | undefined;
  readonly code: string | undefined;
  readonly retryable: boolean;

  constructor(message: string, options?: GraphyApiErrorOptions);
}
PropertyTypeDescription
statusnumber | undefinedHTTP status code, if from an HTTP response
codestring | undefinedMachine-readable error code from the API
retryablebooleanWhether the SDK considers this error retryable

GraphyApiErrorOptions

interface GraphyApiErrorOptions {
  status?: number;
  code?: string;
  retryable?: boolean;
}

isGraphyApiError

Type guard for narrowing unknown errors to GraphyApiError:
import { isGraphyApiError } from '@graphysdk/agents-sdk';

if (isGraphyApiError(error)) {
  console.error(error.status, error.code, error.retryable);
}

Configuration Types

ClientConfig

interface ClientConfig {
  apiKey: string;
  baseUrl: string;
  timeout?: number;
  retryConfig?: RetryConfig;
  logger?: Logger;
}

RetryConfig

interface RetryConfig {
  attempts: number;
  delay: number;
  backoff: number;
}
Defaults:
{
  attempts: 3,
  delay: 1000,
  backoff: 2
}

Logger

interface Logger {
  log: (...args: unknown[]) => void;
  warn: (...args: unknown[]) => void;
  error: (...args: unknown[]) => void;
  debug: (...args: unknown[]) => void;
}

AiChartType

Supported chart types for AI operations.
type AiChartType =
  | 'line'
  | 'bar'
  | 'groupedBar'
  | 'stackedBar'
  | '100StackedBar'
  | 'column'
  | 'groupedColumn'
  | 'stackedColumn'
  | '100StackedColumn'
  | 'combo'
  | 'pie'
  | 'donut'
  | 'funnel'
  | 'heatmap'
  | 'scatter'
  | 'waterfall'
  | 'table';
TypeDescription
lineLine chart
barHorizontal bar chart
groupedBarGrouped horizontal bars
stackedBarStacked horizontal bars
100StackedBar100% stacked horizontal bars
columnVertical column chart
groupedColumnGrouped vertical columns
stackedColumnStacked vertical columns
100StackedColumn100% stacked vertical columns
comboCombined line and column
piePie chart
donutDonut chart
funnelFunnel chart
heatmapHeatmap
scatterScatter plot
waterfallWaterfall chart
tableData table

Zod Schemas

The SDK exports Zod schemas for runtime validation:
import { AiChartTypeEnum, GenerateGraphResponseSchema } from '@graphysdk/agents-sdk';

// Validate a response
const validated = GenerateGraphResponseSchema.parse(response);