Skip to main content
AI Agents is currently in alpha. APIs may change.
Get your first AI-generated chart modification working in 5 minutes.

Prerequisites

  • Node.js 18+
  • A Graphy API key
  • An existing GraphConfig (or use the example below)

1. Install the SDK

npm install @graphysdk/ai @graphysdk/core

2. Create the Client

import { GraphyAiSdk } from '@graphysdk/ai';

const ai = new GraphyAiSdk({
  apiKey: process.env.GRAPHY_API_KEY,
  baseUrl: 'https://agents.graphy.dev',
});

3. Prepare a Graph Configuration

import type { GraphConfig } from '@graphysdk/core';

const config: GraphConfig = {
  type: 'column',
  data: {
    columns: [
      { key: 'quarter', label: 'Quarter' },
      { key: 'revenue', label: 'Revenue ($)' },
    ],
    rows: [
      { quarter: 'Q1', revenue: 50000 },
      { quarter: 'Q2', revenue: 62000 },
      { quarter: 'Q3', revenue: 58000 },
      { quarter: 'Q4', revenue: 71000 },
    ],
  },
};

4. Call the Agent

const result = await ai.generateGraph({
  config,
  userPrompt: 'Change this to a line chart and add a trend line',
});

console.log(result.config);           // Updated GraphConfig
console.log(result.response.message); // "Changed chart type to line and added trend line"

5. Render the Result

import { GraphProvider, Graph } from '@graphysdk/core';

function Chart() {
  return (
    <GraphProvider config={result.config}>
      <Graph />
    </GraphProvider>
  );
}

Next Steps