Overview and setup

The coding agent you will build

We build a small coding agent for Python and Django projects. The target experience is similar to a project bootstrapper: you give it a short instruction like to-do list, it reads a working Django template, plans the changes, edits files, runs safe checks, and gives you a project you can start with make run.

We are not trying to compete with a product like Lovable. Lovable has a team, a polished interface, a prepared React template, streaming, browser preview, and many safety checks. We are building the smaller version so you can see the moving parts: a template, a set of file tools, a developer prompt, and an agent runner.

The final shape:

flowchart LR USER["You<br/>short app request"] CHAT["Jupyter chat UI<br/>ToyAIKit"] RUNNER["Agent runner<br/>Responses API or framework"] TOOLS["AgentTools<br/>read, write, tree, grep, bash"] DJANGO["Copied Django template<br/>project folder"] LLM["LLM provider<br/>OpenAI, Anthropic, Z.AI"] USER -->|type request| CHAT CHAT --> RUNNER RUNNER -->|tool calls| TOOLS TOOLS -->|modify files| DJANGO RUNNER -->|messages and tools| LLM DJANGO -->|make run| USER

The workshop starts with the OpenAI tool-calling mechanics because a coding agent is still an agent: the model decides which tool to call, your code executes that tool, and the result goes back into the conversation. Then we let ToyAIKit handle the loop so we can focus on the coding-agent pieces.

Links

The main resources for this workshop:

Prerequisites

You need basic Python programming and enough command-line comfort to run Jupyter, install packages, and start a Django server. The workshop hides some of the lower-level agent loop inside ToyAIKit, so you do not need to know the OpenAI Responses API deeply before starting.

Accounts and keys:

  • OpenAI API key
  • GitHub account if you want to use Codespaces
  • Anthropic API key if you want to try the Claude example
  • Z.AI API key if you want to try the GLM example

Local tools:

  • Python
  • pip
  • uv
  • Jupyter Notebook
  • make if you want to use the provided Makefile
  • Git

OpenAI is the only required provider. The optional examples also show Anthropic through PydanticAI and Z.AI through the OpenAI-compatible chat completions API.

OpenAI key setup

Create an API key in the OpenAI dashboard. You will only see the value once, so copy it into a safe place when it appears.

If you work locally, export the key before starting Jupyter:

export OPENAI_API_KEY='YOUR_KEY'

If you work in GitHub Codespaces, store it as a Codespaces secret:

  1. Create a GitHub repository, with a README.md if you want an easy starting point.
  2. Open the repository settings.
  3. Go to Secrets and variables, then Codespaces.
  4. Click New repository secret.
  5. Use OPENAI_API_KEY as the name.
  6. Paste your key as the secret value.
  7. Create a new codespace from the repository.

Codespaces is convenient because everyone gets a similar Linux environment with Python already available. A local environment is also fine. Nothing in this workshop depends on Codespaces specifically.

Install the workshop packages

Open a terminal in your environment. In VS Code you can use the integrated terminal. Codespaces works from desktop VS Code or from the browser.

Install the packages:

pip install jupyter django uv openai toyaikit

Upgrade ToyAIKit if you already had an older version installed:

pip install -U toyaikit

Use at least toyaikit 0.0.3. The workshop relies on the chat interface, tool wrapper, and runner classes from that library.

Start Jupyter

Start Jupyter from the same terminal:

jupyter notebook

If you use Codespaces or a remote VS Code session, VS Code should forward the Jupyter port automatically. If it does not, open the Ports panel and forward the port printed by Jupyter, usually 8888.

Create a new notebook. Next, start with a small OpenAI example so the tool-calling mechanics are visible before we hand the loop to ToyAIKit.

Continue with Part 1: OpenAI function calling recap.

Questions & Answers (0)

Sign in to ask questions