Skip to main content
Agents are the conversational interface to your AI features. This guide creates an agent, gives it a tool and a knowledge base, then runs a streaming multi-turn conversation against it.
Prerequisites:
  • Authentication configured (see Authentication guide)
  • Optional: A knowledge base for RAG (see Create a Knowledge Base guide)
1

Create the agent

Define the agent with a name, LLM model, and system prompt that describes its behavior.Endpoint: POST /api/agents
model is a LiteLLM model ID. Bare IDs (gpt-4o, claude-sonnet-4-6) route to OpenAI/Anthropic; other providers are prefixed (gemini/..., openrouter/...). The field is not limited to the Studio model picker, but a provider you haven’t registered a key for (and that isn’t AI-on-us) returns 402 provider_key_decrypt_failed. Bring your own LLM covers the formats and an OpenRouter/DeepSeek example.
2

Assign a builtin tool

Enable the agent to use builtin tools like database_query, http_request, or code_execute.Endpoint: POST /api/agents/{id}/tools
3

Link a knowledge base

Assign a knowledge base and the agent automatically gets a search tool for it. During a conversation it can search the KB to ground its responses.Endpoint: POST /api/agents/{id}/knowledge-bases
4

Chat with the agent (streaming)

Send a message and receive a Server-Sent Events (SSE) stream. Events include tool calls, tool results, and the final response.Endpoint: POST /api/agents/{id}/run/stream
SSE events: start, chunk, step_started, tool_call, tool_result, step_completed, approval_requested, complete, error.
5

Continue the conversation

Pass the session_id from the previous run to continue the multi-turn conversation. The agent retains full message history within the session.Endpoint: POST /api/agents/{id}/run/stream

What’s Next

Streaming Responses

Deep dive into SSE event handling.

Advanced Agent Config

Add MCP servers, hooks, and approval flows.

Agents & Tools

Understand the ReAct loop and tool system.