Search

Search HiAPI models, tools, and resources.

Back to blog
Tutorial7 min read

Agent Course Stuck at Example One? Fix It With a Single Key

X is debating whether $500 agent courses are obsolete now that free material exists. Courses were never the bottleneck. Getting the sample code to run is.

HiAPIAI AgentsTutorialAPI Integration

A post on X jokes that people who paid $500 for an AI agent course can now watch the free version. Original post: https://x.com/deanwperkins/status/2116911546282733623 by Dean W. Perkins (@deanwperkins). The replies converge on something true: courses are not scarce. Getting what is in them to run is.

That lands. Most people do not get stuck on understanding the agent loop. They get stuck on step one: the sample code needs a model key they do not have, or they swap in a different model and the protocol no longer matches. If it does not run, nothing gets verified.

This is about the minimum working setup, not agent theory.

A minimal agent is three things

Strip the frameworks and abstractions and an agent that does work is three components:

  1. A model that can call tools
  2. A set of tool definitions (name, parameters, description)
  3. A loop: the model picks a tool, you execute it, you feed the result back, repeat until it stops asking

Everything courses teach about multi-agent systems, memory, and planning is built on top of these three. Get these three running first.

Step one: get a key working

The first assignment in most courses is "go sign up for some model's API key." That is where a lot of people quit: registration, card binding, approval waits, sometimes quota requests.

A single gateway entry skips that step. One HiAPI key covers Claude, GPT, Kimi, Grok, DeepSeek, and more text models, all over standard Chat Completions.

Confirm it works first:

curl -s https://api.hiapi.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_HIAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.1-sol",
    "messages": [{"role": "user", "content": "Say hello"}]
  }'

If content comes back, the key is fine.

Step two: define a tool

A tool definition is an instruction manual for the model. It needs to know what tools exist and what parameters each takes.

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "City name, e.g. Tokyo"}
            },
            "required": ["city"]
        }
    }
}]

There is only one thing to get right: the model decides when to use a tool based on description. The clearer it is, the fewer wrong calls.

Step three: write the loop

import json, requests

API = "https://api.hiapi.ai/v1/chat/completions"
KEY = "YOUR_HIAPI_API_KEY"
HEADERS = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}

def run_weather(city):
    return {"city": city, "temp": 18, "condition": "clear"}  # sample implementation

messages = [{"role": "user", "content": "What's the temperature in Tokyo?"}]

for _ in range(5):  # guard against infinite loops
    resp = requests.post(API, headers=HEADERS, json={
        "model": "gpt-6.1-sol",
        "messages": messages,
        "tools": tools,
    }).json()

    msg = resp["choices"][0]["message"]
    messages.append(msg)

    if not msg.get("tool_calls"):
        print(msg["content"])
        break

    for call in msg["tool_calls"]:
        args = json.loads(call["function"]["arguments"])
        result = run_weather(args["city"])
        messages.append({
            "role": "tool",
            "tool_call_id": call["id"],
            "content": json.dumps(result),
        })

Run it and you will see the model decide to call get_weather, receive the result, then phrase an answer. That is a complete agent loop.

Choosing a model

The same loop switches models by editing the model field. Prices differ enormously:

ModelInputOutputFits
GPT-6 Luna$0.025$0.125Simple tool calls, classification, extraction
GPT-6.1 Terra$0.25$1.25Everyday agents, coding tasks
GPT-6.1 Sol$0.50$2.50Complex multi-step work
Claude Opus 5.5$2.02$10.08Long runs, deep reasoning

One tool-calling loop is a few thousand tokens. On the cheapest model that is well under a cent. Experimenting with a course costs nothing meaningful.

If the course names a specific model, use it. If it is unavailable or unnamed, an equivalent-tier substitute does not change what you learn, because the loop logic is identical.

The three places courses break

Tool call response format looks wrong. Vendors organize tool_calls fields slightly differently. With Chat Completions-compatible models the format is uniform, so parsing code survives a model swap.

Context keeps growing. Sending full history every turn hits the limit around turn thirty. Later course modules cover trimming; for now just know the trap exists.

The model answers in text instead of calling a tool. Usually the tool description is too vague, or the system prompt never said tools exist. Make the description specific and state it explicitly.

After it runs

Do not reach for a framework yet.

Add these in order:

  1. Error handling: on tool failure, pass the error back to the model so it can retry or reroute
  2. Usage tracking: log token counts per call so you know where cost goes
  3. Timeouts and retries: network flakiness is normal
  4. Then consider frameworks: only when the task genuinely needs multi-agent orchestration or complex state

Course architectures are usually production-oriented. Building to that spec first is how you get stuck at step one. Run the three components, then add what you need.

FAQ

Does it have to be a specific model?

No. Any model supporting function calling works with the same loop. If a course's model is unavailable, an equivalent-tier substitute does not change your understanding.

What separates free courses from paid ones?

Per the thread on X, the difference is structure and support rather than knowledge. Running the examples is on you either way.

Can tools call real APIs?

Yes. Replace run_weather with a real HTTP request. Make sure the tool function catches its own exceptions, or one failure breaks the whole loop.

What does a run cost?

A minimal example is a few thousand tokens. Under a cent on the cheapest model, a few cents on expensive ones. Experiment freely.

Bottom line

The blocker in agent courses was never theory. It is getting the first example to run. Three things produce a complete loop: a working key, one tool definition, and a loop that feeds results back. Add production details afterward, which is ten times easier than the reverse.

See available text models and pricing


Sources

  • Topic origin: Dean W. Perkins (@deanwperkins), https://x.com/deanwperkins/status/2116911546282733623
  • That post links no specific course, so this article points to no particular program and covers the general setup instead
  • Code samples and pricing are ours; prices read from HiAPI production on November 2, 2026

Generate it with HiAPI

Choose a model, enter your prompt, and see the result.

HiAPI Blog

Related articles

HiAPI

Generate it with HiAPI

Start generating