Skip to content
,

How to Create an AI Agent (2026): No-Code, Claude Agent SDK and OpenAI Agents SDK

10–15 minutes
Surprised woman in a white jacket on a rooftop at sunset, holding a card that reads AGENT, with the hook Build your own AI agent today

“AI agent” is the buzzword of the year, but the idea is simple. A chatbot answers questions. An agent takes a goal, decides what steps to take, uses tools such as search, files or apps, checks the results and keeps going until the job is done.

The good news is you no longer need to be an AI engineer to build one. This guide shows how to create an AI agent three ways: with no code, with the Claude Agent SDK, and with the OpenAI Agents SDK.

You will also learn how to plan an agent, keep it safe, control costs and fix common problems.

TL;DR

  • An agent = model + instructions + tools + a loop that keeps working until the goal is met.
  • No code: use an automation tool like n8n (free to self-host) with an AI Agent node, or build assistants inside ChatGPT or Claude.
  • Claude Agent SDK: pip install claude-agent-sdk (Python 3.10+) or npm install @anthropic-ai/claude-agent-sdk (Node 18.14+), set ANTHROPIC_API_KEY, call query() with allowed tools.
  • OpenAI Agents SDK: pip install openai-agents (Python 3.10+), set OPENAI_API_KEY, create an Agent and run it with Runner.
  • Stay safe: give the agent only the tools it needs, require approval for risky actions and set spending limits.

What an AI Agent Is (and Isn’t)

Every AI agent has four parts:

Part What it does Example
Model The “brain” that reasons and decides Claude, GPT, Gemini or a local model
Instructions The job description and rules “You are a support agent. Never issue refunds over $50.”
Tools Things it can do in the world Web search, read files, send email, query a database
Loop Repeats think, act, observe until done Search, read result, search again, write the answer

The loop is what makes it an agent. A normal chatbot gives one reply. An agent might run ten tool calls in a row, fix its own mistakes and only stop when the task is complete or it hits a limit you set.

What an agent is not: magic. It is only as good as its model, its instructions and its tools. Most “my agent doesn’t work” problems come from vague instructions or missing tools, not the model.

Step 1: Plan Your Agent

Before touching any tool, answer these five questions on paper:

  1. What is the one job? “Summarise new support emails and draft replies” beats “handle my business”.
  2. What does done look like? A draft in a folder, a row in a sheet, a fixed bug, a report.
  3. Which tools does it need? List the minimum: read email, write drafts. Not “send email” yet.
  4. Where must a human approve? Anything that sends, pays, deletes or publishes.
  5. How will you test it? Collect 5 to 10 real examples with the answer you expect.

Start narrow. A small agent that does one job reliably is far more useful than a big one that fails half the time. You can add tools and jobs later.

Step 2: Choose How to Build It

Option Coding needed Best for Main cost
Assistants inside ChatGPT, Claude or Gemini None Personal helpers, research, writing Your chat subscription
n8n, Zapier, Make (automation tools) None to little Business workflows across apps Tool plan plus model API usage (n8n can be self-hosted free)
Claude Agent SDK Python or TypeScript Agents that work with files, code and commands Claude API usage
OpenAI Agents SDK Python (JS/TS version too) Multi-agent workflows, handoffs, voice agents Model API usage

If you have never coded, start with Method 1. If you are comfortable running a script, Methods 2 and 3 give you far more control.

Method 1: Build an Agent Without Code (n8n)

n8n is a visual automation tool with an AI Agent node. You connect a trigger, a model and tools by dragging boxes, much like ComfyUI for business tasks. You can self-host it for free or use n8n’s paid cloud.

  1. Install or sign up for n8n. Self-hosting with Docker is free.
  2. Add a trigger, for example “On chat message”, “Schedule” or “New email”.
  3. Add an AI Agent node after the trigger.
  4. Connect a chat model to the agent: Claude, OpenAI, Gemini or a local Ollama model. You will need an API key for cloud models, such as an OpenAI API key.
  5. Write the system message in the agent node: its job, rules and output format.
  6. Add memory if it should remember the conversation.
  7. Add tools: Google Sheets, Gmail drafts, HTTP requests, a calculator or a web search.
  8. Test in the chat panel with your 5 to 10 examples, then activate the workflow.

Want it completely free and private? Our n8n + Ollama local AI agent guide builds the same thing with a model running on your own PC.

Method 2: Build an Agent With the Claude Agent SDK

The Claude Agent SDK gives you the same agent loop that powers Claude Code, as a library. Its big advantage: built-in tools like reading files, editing, searching and running commands are already included, so you do not have to write them yourself.

Requirements

  • Python 3.10+ or Node.js 18.14+
  • An Anthropic account and API key from the Claude Console

Steps

  1. Create a project folder and open a terminal in it:
    mkdir my-agent
    cd my-agent
  2. Install the SDK (Python with a virtual environment):
    python3 -m venv .venv
    source .venv/bin/activate      # Windows: .venv\Scripts\Activate.ps1
    pip install claude-agent-sdk

    Or with Node: npm install @anthropic-ai/claude-agent-sdk. Both SDKs bundle a Claude Code binary, so most installs need nothing else.

  3. Set your API key:
    export ANTHROPIC_API_KEY=your-api-key
    # Windows PowerShell: $env:ANTHROPIC_API_KEY = "your-api-key"

    The SDK does not read .env files automatically.

  4. Create agent.py:
    import asyncio
    from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage
    
    async def main():
        async for message in query(
            prompt="Review utils.py for bugs that would cause crashes. Fix any issues you find.",
            options=ClaudeAgentOptions(
                allowed_tools=["Read", "Edit", "Glob"],
                permission_mode="acceptEdits",
            ),
        ):
            if isinstance(message, AssistantMessage):
                for block in message.content:
                    if hasattr(block, "text"):
                        print(block.text)
                    elif hasattr(block, "name"):
                        print(f"Tool: {block.name}")
            elif isinstance(message, ResultMessage):
                print(f"Done: {message.subtype}")
    
    asyncio.run(main())
  5. Run it: python agent.py. You will see the agent’s reasoning and each tool it calls, ending with Done: success.

Customise it

  • Add web search: add "WebSearch" to allowed_tools.
  • Let it run commands: add "Bash", then try “Write unit tests for utils.py, run them and fix failures”.
  • Give it a persona: set system_prompt="You are a senior Python developer...".
  • Read-only mode: allow only Read, Glob and Grep for analysis agents that must not change anything.

Note Anthropic’s rule: unless approved, third-party products built on the Agent SDK must use API key authentication, not claude.ai logins or plan limits. If you already use Claude Code, our guides to claude -p headless mode and Claude Skills show other ways to automate it.

Method 3: Build an Agent With the OpenAI Agents SDK

The OpenAI Agents SDK is a lightweight Python framework (with a JavaScript/TypeScript version too) for single agents and multi-agent workflows. It supports OpenAI’s APIs and, through adapters, 100+ other models. It includes tools, handoffs between agents, guardrails, sessions, human-in-the-loop and built-in tracing.

  1. Install it (Python 3.10+):
    python -m venv .venv
    source .venv/bin/activate      # Windows: .venv\Scripts\activate
    pip install openai-agents
  2. Set your key: export OPENAI_API_KEY=sk-...
  3. Create a simple agent:
    from agents import Agent, Runner
    
    agent = Agent(name="Assistant", instructions="You are a helpful assistant")
    result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
    print(result.final_output)
  4. Give it a tool by turning a Python function into one:
    from agents import Agent, Runner, function_tool
    
    @function_tool
    def get_order_status(order_id: str) -> str:
        """Look up an order's status."""
        # replace with a real database or API call
        return f"Order {order_id} shipped yesterday."
    
    agent = Agent(
        name="Support agent",
        instructions="Help customers with orders. Use tools to look up facts. Be brief.",
        tools=[get_order_status],
    )
    print(Runner.run_sync(agent, "Where is order 1234?").final_output)
  5. Grow it: add more agents and let one hand off to another (for example a triage agent that passes billing questions to a billing agent), add guardrails to block off-topic requests, and use sessions to remember conversation history.

For agents that need to work with files and commands over longer tasks, the SDK also has sandbox agents that run in a container. On Windows, its docs recommend the Docker sandbox client.

Giving Your Agent Tools (MCP and Functions)

Tools are where agents get their power. There are two common ways to add them:

  • Functions: write a normal function (like get_order_status above) and register it as a tool. Clear names, type hints and a one-line description help the model use it correctly.
  • MCP servers: the Model Context Protocol is a standard way to plug ready-made tools, such as GitHub, Google Drive, databases or browsers, into many agent frameworks, including both SDKs above.

Before connecting third-party MCP servers, read our MCP security best practices. When your agent must return data in a fixed format for another program, use structured outputs.

Make Your Agent Safe

Risk What can go wrong How to prevent it
Too many tools Agent deletes files or sends emails you didn’t want Give only the tools the job needs; start read-only
Irreversible actions Payments, deletes, public posts Require human approval for these steps
Prompt injection A web page or email tells the agent to do something bad Treat fetched content as data; limit tools when reading untrusted content
Runaway loops Agent keeps calling tools and burns money Set a maximum number of turns and a spending limit on your API account
Leaked secrets API keys pasted into prompts or logs Keep keys in environment variables, never in code you share
Wrong answers Agent invents facts Give it tools to look things up and test with real examples

Run coding agents in a project folder or container, not your whole home directory, and keep backups or version control.

What It Costs

  • Frameworks: both SDKs and self-hosted n8n are free to install.
  • Model usage: you pay per token to the model provider. Agents use more tokens than chat because each loop step sends context again.
  • Local models: free per token if you run them on your own GPU with Ollama, at the cost of lower quality on hard tasks.

See our OpenAI API pricing guide for current token prices, and set a monthly budget in your provider’s console before you let an agent run unattended.

10 Agent Ideas to Build First

  1. Inbox sorter that labels emails and drafts replies for you to approve.
  2. Research agent that searches the web and writes a sourced summary.
  3. Code reviewer that reads a pull request and lists bugs.
  4. Bug fixer that runs tests and fixes failures (Claude Agent SDK with Bash).
  5. Meeting notes agent that turns transcripts into action items.
  6. Support triage agent that routes questions to the right team.
  7. Spreadsheet analyst that answers questions about a CSV.
  8. Social media drafter that turns a blog post into posts for approval.
  9. Documentation writer that keeps a README up to date.
  10. Price watcher that checks product pages and alerts you to drops.

Troubleshooting

Problem Cause Fix
“Invalid API key” or “Not logged in” Key not set in this terminal Set ANTHROPIC_API_KEY or OPENAI_API_KEY in the same shell; SDKs don’t load .env automatically
Agent never uses its tool Vague tool name or description Give the tool a clear name and docstring, and mention it in the instructions
Agent stops halfway Turn limit or permission prompt Raise the turn limit, or pre-approve the needed tools
Agent loops forever No clear finish condition Define “done” in the instructions and cap the number of turns
429 rate limit errors Too many requests Slow down, add retries, or raise your API tier; see OpenAI API errors fixed
Costs higher than expected Long context resent every step Use a cheaper model for simple steps, shorten instructions, cap turns
Claude SDK says no binary found Install skipped the bundled binary (e.g. ARM64 Windows) Install Claude Code natively so the SDK finds it on PATH

My Take

The fastest way to build a useful agent is to pick one boring, repetitive job and automate only that. Start in n8n if you don’t code.

If you do, the Claude Agent SDK is the quickest route for anything involving files and code because the tools are built in, and the OpenAI Agents SDK shines for multi-agent setups with handoffs and voice.

Whatever you choose: minimum tools, human approval for risky actions and a spending cap. That one rule prevents most agent disasters.

FAQ

Can I create an AI agent for free?

Yes. Self-hosted n8n and both SDKs are free, and you can use a free local model through Ollama. Cloud models charge per token.

Do I need to know how to code?

No. Tools like n8n let you build agents visually. Coding with an SDK gives more control.

What is the best framework for building AI agents?

There is no single best. The Claude Agent SDK is strongest for file and code tasks, the OpenAI Agents SDK for multi-agent workflows, and n8n for no-code business automation.

What is the difference between a chatbot and an AI agent?

A chatbot replies to messages. An agent works towards a goal by planning, using tools and repeating steps until the job is done.

Can an AI agent use local models?

Yes. n8n supports Ollama, and the OpenAI Agents SDK supports many non-OpenAI models. Quality depends on the model you run.

Are AI agents safe?

They are as safe as the tools and permissions you give them. Limit tools, require approval for risky actions and set spending limits.

How long does it take to build a first agent?

A simple agent from the SDK quickstarts takes under 30 minutes. A reliable business agent takes longer because testing with real examples matters most.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Surprised woman in a white jacket on a rooftop at sunset, holding a card that reads AGENT, with the hook Build your own AI agent today