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
userPromptstringNoNatural 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

GenerateMutationParams

Request parameters for the Mutation Agent.
interface GenerateMutationParams {
  config: GraphConfig;
  userPrompt?: string;
  metadata?: Metadata;
}
FieldTypeRequiredDescription
configGraphConfigYesThe current chart configuration, including the dataset to transform
userPromptstringNoNatural language description of the transformation to apply
metadataMetadataNoRequest tracking information

GenerateMutationResponse

Response from the Mutation Agent.
interface GenerateMutationResponse {
  response: {
    message: string;
    steps: string[];
  };
  config: GraphConfig;
}
FieldTypeDescription
response.messagestringExplanation of the transformations applied
response.stepsstring[]Ordered breakdown of each transformation step
configGraphConfigUpdated chart configuration with the transformed dataset

GenerateAnnotationsParams

Request parameters for the Annotation Agent.
interface GenerateAnnotationsParams {
  config: GraphConfig;
  userPrompt?: string;
  metadata?: Metadata;
}
FieldTypeRequiredDescription
configGraphConfigYesThe current chart configuration to annotate
userPromptstringNoNatural language description of the annotations to add or remove
metadataMetadataNoRequest tracking information

GenerateAnnotationsResponse

Response from the Annotation Agent.
interface GenerateAnnotationsResponse {
  response: {
    message: string;
    steps: string[];
  };
  config: GraphConfig;
}
FieldTypeDescription
response.messagestringExplanation of the annotations applied
response.stepsstring[]Ordered breakdown of each annotation step
configGraphConfigUpdated chart configuration with annotations applied

GenerateNarrativeParams

Request parameters for the Narrative Agent.
interface GenerateNarrativeParams {
  config: GraphConfig;
  userPrompt: string;
  metadata?: Metadata;
}
FieldTypeRequiredDescription
configGraphConfigYesThe chart configuration to narrate
userPromptstringYesNatural language instruction for the narrative
metadataMetadataNoRequest tracking information

GenerateNarrativeResponse

Response from the Narrative Agent.
interface GenerateNarrativeResponse {
  response: {
    message: string;
  };
  config: GraphConfig;
}
FieldTypeDescription
response.messagestringExplanation of the narrative produced
configGraphConfigUpdated chart configuration. Title, subtitle, and caption are written into config.content as TipTap JSON documents.

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
userPromptstringNoNatural 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

ExtractFromProseParams

Request parameters for the Extract Agent.
interface ExtractFromProseParams {
  sourceText?: string;
  attachments?: ExtractAttachmentInput[];
  images?: ExtractImageInput[];
  metadata?: Metadata;
}
FieldTypeRequiredDescription
sourceTextstringNoRaw text to extract data from. Up to 500,000 characters.
attachmentsExtractAttachmentInput[]NoImages, PDFs, and spreadsheets to extract data from. Up to 12 entries.
imagesExtractImageInput[]NoDeprecated. Legacy image array — use attachments instead.
metadataMetadataNoRequest tracking information
Provide sourceText, attachments, or both — at least one is required. images and attachments cannot be combined in a single request.

ExtractAttachmentInput

A discriminated union tagged by kind, used for the Extract Agent’s attachments array. Construct entries with the buildImageAttachment, buildPdfAttachment, and buildSpreadsheetAttachment helpers.
type ExtractAttachmentInput =
  | { kind: 'image'; mimeType: string; dataBase64: string }
  | { kind: 'document'; mimeType: string; dataBase64: string }
  | { kind: 'spreadsheet'; mimeType: string; dataBase64: string; filename?: string };
kindAccepted formatsDecoded size limit
'image'PNG, JPEG, WebP, GIF2 MB each, 8 max
'document'PDF6 MB each, 2 max
'spreadsheet'Excel .xlsx6 MB each, 2 max
A request accepts up to 12 attachments and 12 MB combined decoded size.

ExtractFromProseResponse

Response from the Extract Agent.
interface ExtractFromProseResponse {
  response: {
    message: string;
  };
  config: GraphConfig;
  extractMeta: ExtractMeta | null;
  lastAccuracyEvaluation?: ExtractAccuracyEvaluation;
}
FieldTypeDescription
response.messagestringSummary of what was extracted
configGraphConfigChart configuration containing the extracted dataset
extractMetaExtractMeta | nullTrust metadata for the extraction, or null when unavailable
lastAccuracyEvaluationExtractAccuracyEvaluationThe agent’s final self-check of the extracted data, when performed

ExtractMeta

Trust metadata attached to an extraction result.
interface ExtractMeta {
  confidence: ExtractConfidence;
  needsUserInput: boolean;
  warnings: string[];
  cellConfidence?: Array<{
    rowIndex: number;
    columnKey: string;
    confidence: ExtractConfidence;
    quote?: string;
  }>;
}

type ExtractConfidence = 'high' | 'medium' | 'low';
FieldTypeDescription
confidenceExtractConfidenceOverall confidence in the extraction
needsUserInputbooleanWhether the result should be reviewed before use
warningsstring[]Notes about ambiguous, conflicting, or missing source data
cellConfidenceArray<…>Optional per-cell confidence, each with a supporting source quote

ExtractAccuracyEvaluation

The Extract Agent’s self-check of an extraction result.
interface ExtractAccuracyEvaluation {
  score: number;
  issues: string[];
  sufficient: boolean;
  summary: string;
}
FieldTypeDescription
scorenumberAccuracy score, from 0 to 1
issuesstring[]Specific accuracy problems the agent identified
sufficientbooleanWhether the accuracy is good enough to use as-is
summarystringHuman-readable summary of the accuracy check

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;
  effort?: 'low' | 'medium' | 'high';
  /** @deprecated Prefer `effort`. */
  storytellingEffort?: 'none' | 'low' | 'medium' | 'high';
  budget?: InvocationBudget;
  executionMode?: 'agentic' | 'fast';
}
FieldTypeDescription
callIdstringOptional. Identifier for tracking and debugging.
localestringLocale for responses (e.g., en-US, fr-FR).
effort'low' | 'medium' | 'high'Preferred invocation tier; stored on the invocation and forwarded to nested agents. Default medium when omitted.
storytellingEffort'none' | 'low' | 'medium' | 'high'Deprecated — prefer effort. Still accepted for chart narrative and to infer effort when effort is omitted.
budgetInvocationBudgetOptional hard caps on time, tokens, and cost for the request.
executionMode'agentic' | 'fast'Execution strategy: agentic runs the full multi-step loop, fast runs a single-shot plan.

InvocationBudget

Optional hard limits applied to a single request. The server merges any provided fields with its own per-agent defaults.
interface InvocationBudget {
  maxWallClockMs?: number;
  maxTotalTokens?: number;
  maxCostUsd?: number;
}
FieldTypeDescription
maxWallClockMsnumberHard wall-clock timeout for the request, in milliseconds
maxTotalTokensnumberHard cap on total tokens consumed
maxCostUsdnumberHard cap on request cost, in USD

SSE Events

ProgressEvent

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

CompleteEvent

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

ErrorEvent

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

PreviewEvent

An incremental preview of an agent’s work-in-progress result. The payload is spread at the top level, and its shape depends on the agent.
interface PreviewEvent {
  type: 'preview';
  [key: string]: unknown;
}

ReasoningEvent

A reasoning message emitted by an agent as it works.
interface ReasoningEvent {
  type: 'reasoning';
  agentId: string;
  executionId: string;
  message: string;
}

SSEEvent Union

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

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'
  | 'areaStacked'
  | 'bar'
  | 'groupedBar'
  | 'stackedBar'
  | '100StackedBar'
  | 'column'
  | 'groupedColumn'
  | 'stackedColumn'
  | '100StackedColumn'
  | 'combo'
  | 'pie'
  | 'donut'
  | 'funnel'
  | 'heatmap'
  | 'scatter'
  | 'bubble'
  | 'waterfall'
  | 'table'
  | 'mekko';
TypeDescription
lineLine chart
areaStackedStacked area 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
bubbleBubble chart
waterfallWaterfall chart
tableData table
mekkoMarimekko chart

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);