Agent recipe · 01

Build your first AI agent in 10 minutes

A small tool-using loop that turns a user request into a function call, runs the function, and asks the model for a grounded answer.

Beginner10 minutesEnglishVerified 2026-09-25
Use https://aiwave.live/v1 as the OpenAI-compatible base URL. Keep your key in AIWAVE_API_KEY, never in source control.

1. The 60-second version

Install the SDK, define one tool, then let the model choose whether to call it. The example uses deepseek-v4-flash, a live AIWave catalog ID verified on 2026-09-25.

python -m pip install openai

$env:AIWAVE_API_KEY = "your-aiwave-key"
python agent.py
from openai import OpenAI
import os
import json

client = OpenAI(base_url="https://aiwave.live/v1", api_key=os.environ["AIWAVE_API_KEY"])

def lookup_status(service: str) -> str:
    return f"{service} is operational"

tools = [{"type":"function","function":{"name":"lookup_status","description":"Check a service status","parameters":{"type":"object","properties":{"service":{"type":"string"}},"required":["service"]}}}]
messages = [{"role":"system","content":"Use lookup_status when the user asks about a service status."},{"role":"user","content":"Is the payments service operational?"}]
first = client.chat.completions.create(model="deepseek-v4-flash", messages=messages, tools=tools)
call = first.choices[0].message.tool_calls[0]
result = lookup_status(**json.loads(call.function.arguments))
messages += [first.choices[0].message, {"role":"tool","tool_call_id":call.id,"content":result}]
final = client.chat.completions.create(model="deepseek-v4-flash", messages=messages, tools=tools)
print(final.choices[0].message.content)

Run it with the same command shown above. Expected output is a short answer grounded in “payments is operational”.

2. One-run cost model

AssumptionCalculation
2,000 input + 500 output tokens($0.638 × 0.002) + ($1.914 × 0.0005) = about $0.0022
Rate sourceAIWave pricing, deepseek-v4-flash, effective 2026-08-27; checked 2026-09-25

Actual usage depends on message history, tool payloads, cache hits, and the key’s effective billing group.

3. Extend it safely

For errors, see request recovery and client setup.

Next steps