The Studio Agent Framework lets users explore data and build or modify dashboards using natural language and an LLM supplied by your application. Connecting it to the OpenAI Responses API takes three steps.
It runs the agent loop in the browser against an example OpenAI adapter, which you copy into your app and adapt to your own provider. This is one of several approaches the Agent Framework supports; for the concepts behind it, see Harness, Agents and Tools.
1. Register the Module Copy Link
The Agent Framework is provided via the AgStudioAiModule which must be imported and registered:
import { AgStudioAiModule, AgStudioModuleRegistry } from 'ag-studio';
AgStudioModuleRegistry.registerModules([AgStudioAiModule]); 2. Connect a Provider Copy Link
To connect to your provider, you must provide an adapter that translates the Agent Framework request format to the format your chosen provider expects.
The example on this page includes an OpenAI adapter. AG Studio ships no adapters - copy this one as a starting point for your provider:
// Example adapter, not a shipped API. Copy it into your app and adapt it.
import { openaiAdapter } from 'ag-studio-harness/example-shared/openaiAdapter';
const adapter = openaiAdapter({
endpoint: 'https://api.openai.com/v1/responses',
key: MY_KEY,
});This adapter calls the provider straight from the browser, which may expose your authentication key to your users. In production, route the LLM requests via your own application or an LLM proxy.
3. Configure the Harness Copy Link
Pass the adapter to createAiHarness and you get Studio's five agents, with the lead fronting the conversation:
<ag-studio
:ai="ai"
/* other studio properties ... */>
</ag-studio>
this.ai = ({ api }) => createAiHarness(api, { adapter });That is the shortest form. To change the agents, their instructions or their tools, pass a builder instead - see Agent Configuration.
Example Copy Link
Open the dashboard, open the chat panel from the side panels, and choose one of the suggested prompts - or type a request of your own. Choose "Chart average highs" and you should see the lead agent inspect the schema, delegate to the page agent to place a widget, then to a widget agent to configure it:
import {
createApp,
defineComponent,
onBeforeMount,
ref,
shallowRef,
} from "vue";
import { AgStudio } from "ag-studio-vue3";
import {
AgAiHarnessSetup,
AgAiModel,
AgAiPromptStarter,
AgDataEngine,
AgDataSourcesDefinition,
AgReportState,
AgStudioAiModule,
AgStudioApi,
AgStudioApiReadyEvent,
AgStudioMode,
AgStudioModuleRegistry,
AgStudioProperties,
createAiHarness,
} from "ag-studio";
import { getGhcnCitiesData } from "./shared/ghcnCities/data.ts";
import { ghcnCitiesReportState } from "./shared/ghcnCities/state.ts";
import { openaiAdapter } from "./shared/openaiAdapter.ts";
AgStudioModuleRegistry.registerModules([AgStudioAiModule]);
export const AI_API_URL = "https://ai-api.ag-grid.com/api/openai/v1";
export const AI_API_TOKEN = "";
// 2. Connect a provider. In production this endpoint is your own, so the key never reaches the browser.
const adapter = openaiAdapter({
endpoint: AI_API_URL,
key: AI_API_TOKEN,
});
/**
* The suggestions a new conversation opens on. They show only until the first message is sent,
* so they are an opening move rather than a menu.
*/
const PROMPT_STARTERS: AgAiPromptStarter[] = [
{
label: "Chart average highs",
prompt: "Add a bar chart of average high temperature by city.",
},
{
label: "Compare climate bands",
prompt:
"Add a bar chart comparing average high and average low temperature by climate band.",
},
{
label: "Explain the data",
prompt: "What tables and fields does this dashboard have available?",
},
];
/**
* The models offered beside the send button. Each `id` reaches the adapter as declared here and is
* passed straight on to the provider, so these are real model ids. The first is the one a new
* conversation starts on.
*/
const MODELS: AgAiModel[] = [
{ id: "gpt-5.6-terra", label: "GPT-5.6 Terra" },
{ id: "gpt-5.6-sol", label: "GPT-5.6 Sol" },
{ id: "gpt-5.6-luna", label: "GPT-5.6 Luna" },
];
const VueExample = defineComponent({
template: `
<div style="height: 100%">
<div style="display: flex; flex-direction: column; height: 100%">
<ag-studio
style="width: 100%; height: 100%;"
class="my-studio-container"
@api-ready="onApiReady"
:data="data"
:mode="mode"
:initialState="initialState"
:ai="ai"></ag-studio>
</div>
</div>
`,
components: {
"ag-studio": AgStudio,
},
setup(props) {
const studioApi = shallowRef<AgStudioApi | null>(null);
const data = ref<AgDataSourcesDefinition | AgDataEngine>(
getGhcnCitiesData("https://www.ag-grid.com/studio/example-assets"),
);
const mode = ref<AgStudioMode>("edit");
const initialState = ref<AgReportState>({
...ghcnCitiesReportState,
// Collapse the filters panel and open on the blank page, so the assistant has work to do.
panels: {
...ghcnCitiesReportState.panels,
filters: {
collapsed: true,
},
},
selectedPageId: "blank",
});
const ai = ref<AgAiHarnessSetup>(({ api }) =>
createAiHarness(api, {
adapter,
promptStarters: PROMPT_STARTERS,
models: MODELS,
}),
);
const onApiReady = (params: AgStudioApiReadyEvent) => {
studioApi.value = params.api;
};
return {
studioApi,
data,
mode,
initialState,
ai,
onApiReady,
};
},
});
const app = createApp(VueExample);
app.mount("#app");
Troubleshooting Copy Link
If you experience issues, work through these in order:
| Symptom | What to check |
|---|---|
| No chat panel | The module is not registered, or ai is not set. |
| Panel, but "AI is unavailable" | primary names an agent that is not in agents. |
| A licence error in the console | The key does not include AI. |
| The agent replies but never acts | The adapter is not relaying tool calls - see Tool Calls. |