Prerequisites
- Create an Agent in the Portal: Create Agent
- Get the Agent name and Application name from the Portal
Execute an Agent
OpenAI SDK usage (base_url)
If you’re already using the OpenAI SDK, you can call Maitai directly by settingmodel to your agent name and passing application via extra_body.
To use the Agents API, set the OpenAI SDK base URL to:
https://api.trymaitai.ai/agent/
Parameters
Maitai agents support two equivalent request shapes:AgentRequest(recommended): pass arequest=...wrapper toclient.agent.completions.create(...)- OpenAI SDK (base_url): pass standard chat completion fields plus agent fields via
extra_body
Agent identification (required)
The agent name. When using the OpenAI SDK base_url approach, you can alternatively set
model to the agent name and omit this field.Required when identifying an agent by name.
Alternative identifier. If
agent is provided, it is preferred over agent_id.Optional. Alternative application identifier (legacy). Can be used with
agent instead of application.When using the OpenAI SDK base_url approach without providing
agent or agent_id, Maitai will use model as the agent name.Agent execution controls (optional)
Controls how the agent processes the request.
See Orchestration for more details on execution modes.
| Value | Behavior |
|---|---|
auto | (default) Automatically selects the best mode based on the agent’s configuration. Picks reasoning if sub-agents exist or multiple actions are available; otherwise falls back to route. |
reasoning | Activates the full reasoning loop (Cortex). The agent plans actions via an LLM orchestrator, executes them, processes results, and iterates until it can respond. Best for complex, multi-step tasks. |
route | Single-step routing. The agent picks one capability and returns the result. Best for simple request/response patterns. |
Maximum number of orchestration iterations before the agent stops. Useful as a safety limit for
reasoning mode. Defaults to 100.When
true, the agent flattens sub-agent actions into the root agent and runs everything in-process. Instead of dispatching work to sub-agents over Redis queues, all capabilities (including those defined on sub-agents) execute directly within the root agent’s process.This eliminates inter-process overhead and reduces latency, especially for agents with deep sub-agent hierarchies. The orchestrator sees a single flat list of all available capabilities.Controls whether the orchestrator can plan multi-step action chains in a single LLM call.
false(default): Chaining ON. The orchestrator can output a sequence of actions where later actions trigger on the completion of earlier ones (e.g., “fetch data, then when that completes, enrich it”). Reduces orchestration round-trips.true: Chaining OFF. The orchestrator plans one action at a time, then re-orchestrates after each completion. Simpler and more predictable.
When
true, skips the strategy-building step and goes straight to action planning. Useful when the agent’s task is straightforward and doesn’t benefit from upfront planning.A unique identifier you set for the session. Recommended for tracking conversation threads. The agent uses this to maintain state (forms, context, checkpoints) across multiple requests.
Optional task identifier used to group related agent requests.
request (AgentRequest wrapper)
Wrapper request for agent execution. Provider model inputs live under
request.params and match the standard chat completion params documented at Chat.