Documentation Index
Fetch the complete documentation index at: https://algolia.com/llms.txt
Use this file to discover all available pages before exploring further.
This is a beta feature according to Algolia’s Terms of Service (“Beta Services”).
Steps for integrating Agent Studio
Prepare your agent
Ensure that your agent is configured and published in the Algolia dashboard.
To learn more, see Get started with the Agent Studio dashboard.
Get your agent ID
On the Agents page in the Agent Studio’s dashboard,
find your published agent’s ID.
Choose how you want to integrate Agent Studio
- HTTP API: directly interact with your agent using HTTP requests.
- InstantSearch: use the InstantSearch.js or React InstantSearch libraries to integrate search capabilities alongside your agent.
- AI SDK UI: use the React-based SDK for a ready-to-use conversational UI.
API integration
Interact with your GenAI agent directly using the Agent Studio API. Example curl request:Command line
JSON
JSON
algolia.searchParameters in the request body.
For supported fields and examples, see Algolia Search tool.
For the request schema for POST /agent-studio/1/agents/{agentId}/completions, see the Agent Studio API reference.
Enable conversation persistence
To automatically save conversations server-side, include both a conversation ID and message IDs in your request:Command line
id: conversation identifier (prefix withalg_cnv_for consistency)messages[].id: unique ID for each message (prefix withalg_msg_)
- Replace
{{ALGOLIA_APPLICATION_ID}}with your Algolia . - Replace
{{agentId}}with your published agent ID. - Use your application’s search-only API key for authentication.
- The endpoint supports streaming responses and is compatible with
ai-sdkv4 and v5. - For streaming responses, set
stream=truein the query parameters. - For production, secure your API keys and restrict usage as needed.
InstantSearch integration
Agent Studio is compatible with InstantSearch.js and React InstantSearch. The InstantSearch integration only supportsai-sdk v5.
The benefits of using InstantSearch are:
- Provides an out-of-the-box chat interface with multiple customization options.
- Integrates search results alongside your agent’s responses.
- Handles custom tools with minimal setup.
Examples
Rendering search results
If your agent uses a search tool, you must define item templates or components to control how search results appear in the chat interface. Templates are required for search results. They let you display product information, images, or other data in a format that fits your application.itemComponent (React) or templates.item (JavaScript) template renders each search result item with custom HTML and styling. If your agent uses a search tool, you must define this template to display search results correctly in the chat interface.
If your agent uses the Algolia Display Results tool, check the
displayResultsEnabled flag in the response’s messageMetadata.
When the flag is true, render the curated layout from the Display Results tool output (groups of results with intros and rationales) instead of, or alongside, the per-item template.Tools
InstantSearch Chat widgets let you integrate tools in your agent’s responses. Once a tool has been added to your agent in the dashboard, you can customize how it’s rendered with InstantSearch. For a complete guide to configuring tools in Agent Studio, see Tools for Agent Studio.tools prop is an object where the keys are the tool names defined in your agent configuration.
Each tool includes a layoutComponent (React) or templates.layout (JavaScript) to customize how tool calls appear in the chat interface, and an optional onToolCall handler to run custom logic when the tool is invoked.
For the full list of available props (including applyFilters, sendEvent, onClose, and streamInput), see the Chat widget reference for React or JavaScript.
Hidden context
Use thecontext prop (React) or context option (JavaScript) on the chat widget to send extra metadata with each user message—for example, the current page, locale, or session segment.
The widget serializes the value as JSON and adds it to the user message as a hidden text part of the form <context>{"key":"value"}</context>.
Users don’t see it in the chat UI, but the agent does.
context can be a static object or a function that returns an object at send time. Use a function when the context depends on the current state of the page.
Prompt suggestions
Prompt Suggestions can be enabled in InstantSearch by enabling the suggestions feature in the Agent Studio dashboard or API. When enabled, the Chat widgets automatically handle and display suggestions after each agent response. You can customize the suggestions layout using thesuggestions component or template.
Complete examples
AI SDK UI integration
The Agent Studio is compatible with AI SDK UI, a React-based UI integration for building conversational interfaces. Agent Studio supports bothai-sdk v5 and v4.
AI SDK UI isn’t required to use Agent Studio, but it makes the integration process much easier by handling common tasks like UI rendering and state management.
The benefits of using the AI SDK UI are:
- Abstractions over low-level HTTP requests
- Built-in error handling, retries, and extensibility using middleware and plugins
- Fast setup for conversational user interfaces
- Custom tool handling
- UI state control
Installation
Command line
Example React integration
React