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)
Execution preference. Common values include
auto, route, direct, reasoning.Optional cap on agent iterations.
Optional performance mode flag.
Optional flag to disable chaining across agent calls.
A unique identifier you set for the session. Recommended for tracking conversation threads.
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.