This is the documentation of version 0.64.0. Go to the latest version, 1.0.0-rc.5.

Agent Toolkit plugin

The Agent Toolkit turns a TomTom map into something a user can talk to. Bring an LLM and a chat box, and your users plan routes, search for places, inspect traffic and reshape the map with sentences instead of clicks.

What you can build with it

What's in the box

@tomtom-org/maps-sdk-plugin-agent-toolkit is a headless plugin built on Vercel AI SDK v6. createMapAgent returns a ToolLoopAgent wired to a TomTomMap and the TomTom services.

You bring:

The plugin provides:

Quickstart

All plugins use @tomtom-org/maps-sdk as a peer dependency — ensure the SDK is installed first. See the Project Setup guide if needed.

Install

npm install @tomtom-org/maps-sdk-plugin-agent-toolkit ai zod
npm install @ai-sdk/react @ai-sdk/openai   # or @ai-sdk/anthropic, @ai-sdk/azure, …

The plugin's other peer dependencies — @tomtom-org/maps-sdk-plugin-map-theme, maplibre-gl, @turf/turf, chart.js, h3-js — are installed automatically by npm 7+ and pnpm 8+; add them yourself with other package managers.

Wire it up

import { TomTomConfig } from '@tomtom-org/maps-sdk/core';
import { TomTomMap } from '@tomtom-org/maps-sdk/map';
import { createMapAgent } from '@tomtom-org/maps-sdk-plugin-agent-toolkit';
import { openai } from '@ai-sdk/openai';
import { useChat } from '@ai-sdk/react';
import { DirectChatTransport } from 'ai';

TomTomConfig.instance.put({ apiKey: 'YOUR_API_KEY' });

const map = new TomTomMap({ mapLibre: { container: 'map' } });

const agent = createMapAgent(map, {
    model: openai('gpt-4o'),
    dataEntries: {
        routes: { entryMode: 'single' }, // one route on the map at a time
        byod: { enabled: false },        // no bring-your-own-data tools in this deployment
    },
});

const { messages, sendMessage } = useChat({
    transport: new DirectChatTransport({ agent }),
});

Without a chat UI, call the agent directly:

const { text } = await agent.generate({
    messages: [{ role: 'user', content: 'Find coffee shops near Dam Square' }],
});

Try it out

Clean up

agent.destroy(); // resets every built-in and custom state slice that implements reset()

Options

createMapAgent(map, options) takes one required option, model; each other option is explained on the page that owns it.

Option What it controls Read
tools, includeDefaultTools Add, remove, replace or hand-pick tools Customizing tools
systemPrompt, systemPromptPrefix, systemPromptSuffix The system prompt Customizing the system prompt
classifier, onClassify Per-turn tool selection How it works
prepareStep, maxSteps, stepProviderOptions, providerOptions, outputSchemas The tool loop How it works
onToolExecute Per-tool timing and errors How it works
state, dataEntries Custom state slices; which data kinds exist and their entry mode State
byod Which URLs the agent may fetch Bring your own data
codeExecution Sandbox timeout and worker libraries Code generation

Building with an AI coding assistant

The tomtom-maps-sdk-js skill covers this plugin; drop a public API name such as createMapAgent or analyseData into your question. AI coding with the SDK explains how to install and use it.

Where to next

In "learn enough to ship something" order:

API reference

Agent Toolkit Plugin API Reference

Related guides