aixplain Agents SDK
The fastest way to turn an AI agent into an API. Deploy agents with one save, embed them in your apps, and pay only when someone calls them. Use any of 1,000+ models, tools and integrations with one API key, cap cost with budgets, check every step with inspectors, and trace every run in code or in the aixplain app dashboard.
Anatomy of an agent
- Agent
- Python
- API
agent.run("...")Prompt, files, sessionresult.data.outputresult.data.stepsresult.used_creditsfrom aixplain import Aixplain
aix = Aixplain(api_key="YOUR_API_KEY")
llm = aix.Model.get("openai/gpt-5.4/openai")
web_search = aix.Tool.get("tavily/tavily-web-search/tavily")
guard = aix.Inspector( # optional: severity, description
name="no-competitors",
targets=["output"],
action="abort",
metric={"assetId": llm.id, "prompt": "Fail if it names Globex."},
)
researcher = aix.Agent(name="Researcher", tools=[web_search])
agent = aix.Agent( # optional: description, instructions, tools
name="Research agent",
llm=llm,
agents=[researcher, aix.Agent(name="Writer")],
inspectors=[guard],
)
agent.budget.max_cost = 0.5
agent.save(save_subcomponents=True)
result = agent.run("What are the top AI papers this week?")
print(result.data.output)
curl -X POST \
"https://platform-api.aixplain.com/v2/agents/YOUR_AGENT_ID/run" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "What are the top AI papers this week?"}'
Use agent.id from the Python tab. The response holds a URL to poll for the answer; see the REST API.
Ways to build
- Python SDKDefine, deploy and run agents in code.Quickstart
- REST API and MCPCall any agent, model or tool from any language or MCP client.REST API
- Coding agentDescribe the agent. Koder or your coding agent builds and deploys it.Build with coding agents
No code? Use the aixplain desktop app.
Recommended path
- Quickstart: run your first agent in five minutes.
- API keys: keep your key in
AIXPLAIN_API_KEY, out of git. - Agents: instructions, LLM, JSON output and subagents.
- Tools and Knowledge base: web search, apps and your documents.
- Budgets and Inspectors: cap cost and check every step.
- Deployment and Tracing and monitoring: call it by ID and see every run.
What you can build
Compare the top three vector databases and estimate their monthly cost.
- Web search
- Python sandbox
Every tool call is in result.data.steps.
What is our parental leave policy?
- Knowledge base
Every tool call is in result.data.steps.
Which customers churned last quarter, and why?
- SQL database
- Knowledge base
Every tool call is in result.data.steps.
Summarize today's support emails and post it to Slack.
- Gmail
- Slack
Every tool call is in result.data.steps.
Research the EV market and write a one-page brief.
- Researcher agent
- Writer agent
Every tool call is in result.data.steps.
Draft a reply to this customer complaint.
- Knowledge base
- Gmail
Every tool call is in result.data.steps.