Integrate Agent Studio
On this page
Agent Studio is a beta feature according to the Algolia Terms of Service (“Beta Services”).
Integration overview
Integrate the Agent Studio with your application to deliver generative AI experiences powered by Algolia and large language models (LLMs). You can interact with your published agents using HTTP API or use the AI SDK UI for a seamless integration.
Step-by-step: Integrate Agent Studio
- Prepare your agent
- Ensure your agent is created and configured in the Algolia dashboard.
- Only Published agents can be used for integration.
- See dashboard setup guide
- Get your agent ID
- Find your published agent’s ID in the dashboard under Generative AI > Agent Studio > Agents.
- Choose your integration method
- HTTP API: Directly interact with your agent using HTTP requests.
- 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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl 'https://{{YourApplicationID}}.algolia.net/agent-studio/1/agents/{{agentId}}/completions?stream=false&compatibilityMode=ai-sdk-4' \
-X POST \
-H 'Content-Type: application/json' \
-H 'x-algolia-application-id: YourApplicationID' \
-H 'X-Algolia-API-Key: YourSearchOnlyApiKey' \
--data-raw '{
"messages": [
{
"role": "user",
"content": "What is 1+1 ?"
}
]
}'
And the response would look like the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"role": "assistant",
"content": "The sum of 1 + 1 is 2.",
"parts": [
{
"type": "step-start"
},
{
"type": "text",
"text": "The sum of 1 + 1 is 2."
}
],
"tool_invocations": []
}
To continue the conversation, you should include the previous messages in the request:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"messages": [
{
"role": "user",
"content": "What is 1+1 ?"
},
{
"role": "assistant",
"content": "The sum of 1 + 1 is 2."
},
+ {
+ "role": "user",
+ "content": "What is the sum of the previous value + 3"
+ }
]
}
Notes:
- Replace
{{YourApplicationID}}
with your Algolia application ID. - 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-sdk v4 clients.
- For streaming responses, set
stream=true
in the query parameters. - For production, secure your API keys and restrict usage as needed.
AI SDK UI integration
The Agent Studio is compatible with AI SDK UI, a React-based UI integration for building conversational interfaces.
Installation
1
npm install @ai-sdk/react
Example React integration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { useChat } from '@ai-sdk/react'
const App = () => {
const { messages, input, handleInputChange, handleSubmit } = useChat({
api: `https://${YourApplicationID}.algolia.net/agent-studio/1/agents/${agentId}/completions?streaming=true&compatibilityMode=ai-sdk-4`,
headers: {
'x-algolia-application-id': 'YourApplicationID',
'x-algolia-api-key': 'YourSearchOnlyApiKey',
},
})
return (
<>
{messages.map(message => (
<div key={message.id}>
{message.role}:{message.content}
</div>
))}
<form onSubmit={handleSubmit}>
<input name="prompt" value={input} onChange={handleInputChange} />
<button type="submit">Submit</button>
</form>
</>
)
}
Why use AI SDK UI?
- Abstracts low-level HTTP calls.
- Built-in error handling, retries, and extensibility using middleware/plugins.
- Fast setup for conversational frontends.
Advanced use cases:
- Custom tool handling.
- UI state control.
- See AI SDK documentation for more.