Skip to main content
This notebook demonstrates how to run the OpenCode coding agent on ZeroGPU and ship a real feature with it. You start with Trail Shop, a small React store that lists eight products with no way to search them, connect your ZeroGPU key in OpenCode, pick DeepSeek V4.1 Flash, and ask for a search box in one sentence. The agent reads the code, writes the feature, checks its own work, and the store updates in your browser, in about 20 seconds and for under a cent. By combining OpenCode and ZeroGPU, this notebook walks you through a practical pattern for handing everyday feature work to a coding agent on a low-cost model provider, with no provider configuration at all because ZeroGPU is listed on models.dev. For the full reference, see the OpenCode integration guide. For how ZeroGPUโ€™s listing works and which other tools read it, see the Models.dev integration guide. In this notebook, youโ€™ll explore:
  • OpenCode: An open-source AI coding agent for the terminal that reads your code, edits files, and runs commands. Its provider catalog comes from models.dev, so ZeroGPU shows up in /connect and /models with no extra setup. Here it reads the storeโ€™s code, writes the search feature, and type-checks its own work.
  • ZeroGPU: A compute-efficient inference provider for apps and agents. We run purpose-built small and nano language models across an edge network for the high-volume tasks you run constantly - classification, extraction, moderation, routing, summarization - at ~10x lower latency and 50%+ lower cost than frontier-model workflows. Auto-scaling, with zero GPU infrastructure to manage. Plug in and youโ€™re live.
  • Models.dev: An open-source database of AI model specifications, pricing, and capabilities that OpenCode reads its providers from. ZeroGPUโ€™s listing supplies the endpoint, the API key variable, and the nine chat models youโ€™ll pick from.
This setup not only demonstrates a practical application of agentic feature work on a low-cost model, but also provides a flexible framework that can be adapted to other real-world scenarios requiring fast, inexpensive code changes driven by plain-language requests.

๐ŸŽฅ Watch the Video Guide

If you prefer a visual walkthrough, check out the accompanying video guide below:

๐Ÿ“ฆ Installation

First, install the OpenCode CLI. This cookbook uses OpenCode v2:
Prefer a package manager? brew install anomalyco/tap/opencode-v2 or npm install -g @opencode/cli installs the same CLI. ZeroGPU needs no SDK here. OpenCode already knows ZeroGPUโ€™s endpoint and models from models.dev, so all it needs is your key. Youโ€™ll also need Node.js 20 or newer for the store, plus jq for one optional catalog lookup. See the OpenCode integration guide for every way to connect.

๐Ÿ”‘ Setting Up API Keys

Youโ€™ll need to set up your API key for ZeroGPU. This ensures that OpenCode can reach ZeroGPUโ€™s models securely. You can go to here to get an API key from ZeroGPU. The key starts with zgpu-api-. Copy the key now; youโ€™ll paste it into OpenCodeโ€™s /connect in a moment, which stores it for every OpenCode session on your machine. If youโ€™d rather keep it in your environment instead, export it under the name models.dev lists for ZeroGPU:
OpenCode reads environment variables from its shared background server, so if one is already running, restart it with opencode service stop after exporting.

๐Ÿ—‚๏ธ Finding ZeroGPU on Models.dev

OpenCode doesnโ€™t ship a hard-coded ZeroGPU integration. It reads ZeroGPUโ€™s entry from the models.dev catalog, which you can browse at models.dev/providers/zerogpu or query directly:
Thatโ€™s the whole integration: the endpoint OpenCode will call, the variable it checks for a key, and the nine models it will offer. Youโ€™ll use deepseek-v4.1-flash, listed at $0.30 per 1M input tokens and $1.20 per 1M output tokens, with a 1,048,576-token context window.

๐Ÿ•๏ธ Building the Trail Shop Starter

Trail Shop is a Vite, React, TypeScript, and Tailwind app with a header, a hero, and a grid of eight product cards. Create the project and install its dependencies:
Add the build configuration:
vite.config.ts
tsconfig.json
index.html
Now the app itself. src/index.css pulls in Tailwind, and src/main.tsx mounts the app:
src/index.css
src/main.tsx
The product data is the part the search will filter. Each product has a name and a category:
src/data/products.ts
Two small components render the header and each product card:
src/components/Header.tsx
src/components/ProductCard.tsx
And src/App.tsx puts it together. This is the file the agent will change:
src/App.tsx
Commit the starter so you can see exactly what the agent changes, and reset between runs:
Finally, start the dev server in a second terminal and open http://localhost:5173. Keep it running: Vite reloads the page by itself whenever the agent saves a file.
You should see the header, โ€œGear for every trailโ€, and eight product cards, with no search box.

๐Ÿ”Œ Access Agentic Coding with ZeroGPU

ZeroGPU is a compute-efficient inference provider for apps and agents. We run purpose-built small and nano language models across an edge network for the high-volume tasks you run constantly - classification, extraction, moderation, routing, summarization - at ~10x lower latency and 50%+ lower cost than frontier-model workflows. Auto-scaling, with zero GPU infrastructure to manage. Plug in and youโ€™re live. In this section, we will connect ZeroGPU in OpenCode, pick DeepSeek V4.1 Flash, and ask it one question about the store as an example. Start OpenCode in the trail-shop folder:
Connect ZeroGPU. Type /connect, press Enter, type zero, and pick ZeroGPU. Paste your key (itโ€™s masked as you paste) and press Enter:
Now pick the model. Type /models, press Enter, type deepseek, and pick DeepSeek V4.1 Flash marked ZeroGPU. Typing deepseek also shows deepseek-v4.1-flash-free from OpenCode Zen, so make sure the row you pick says ZeroGPU:
Every ZeroGPU model on models.dev is in this list, and they all support the tool calling OpenCode needs. Check the connection with a quick question. You can type it into the session, or run it from a shell with opencode run:
๐ŸŽ‰ ZeroGPU effortlessly plugs into OpenCode straight from its models.dev listing, providing a no-config, low-cost model provider for AI integration!

๐Ÿ”Ž Adding Product Search with OpenCode

This section asks the agent for a real feature in one sentence. OpenCode does the reading, editing, and checking, and every model call behind it runs on ZeroGPU. Lay out your screen so you can watch it happen: OpenCode in a terminal, src/App.tsx open in your editor above it, and the store in your browser.

Step 1: Ask for the feature

Type this prompt into the OpenCode session and press Enter. Then keep your hands off for about 20 seconds:

Step 2: Watch the agent work

OpenCode reads src/App.tsx, the product data, and the card component, then edits src/App.tsx in place, so youโ€™ll see the file change in your editor. OpenCodeโ€™s default agent is allowed to edit files and run commands, so thereโ€™s nothing to approve. Before it replies, the agent checks its own work with a type check or build. Thatโ€™s expected; let it finish. When the reply lands, the line under it reads DeepSeek V4.1 Flash ยท ZeroGPU. Hereโ€™s the change it made, from git diff:
The agent added a query state, filtered products by name and category with useMemo, put an accessible search input above the grid, and swapped in the empty-state message when nothing matches. The exact styling and wording change a little from run to run (full width or half width, a different summary), but the behavior is the same every time.

Step 3: Check the cost

Look at the sidebar for the sessionโ€™s cost. In our test runs, the whole feature took 17 to 18 seconds and cost $0.0047** and **$0.0060. OpenCode rounds the sidebar to the cent, so it may read $0.00 or $0.01; either way, itโ€™s under a cent. That figure comes straight from the catalog prices you looked up earlier. A run that sends roughly 15,000 input tokens and gets about 1,000 back costs 15,000 x $0.30/1M + 1,000 x $1.20/1M = $0.0057. Switch to the browser. Thereโ€™s no need to refresh: Vite already reloaded the page when the agent saved. Click the search box and type a few queries:

Step 5: Run it again headlessly (optional)

To try the same task from a script, reset the store and hand the prompt to opencode run. This is the same run without the interface, which is how youโ€™d use it in CI:
Each run costs about half a cent. If edits ever fail and the agent retries, stay on DeepSeek V4.1 Flash: in our tests it edited cleanly every time, while GPT-5.6 Lunaโ€™s file-edit calls failed twice before it recovered. ๐ŸŽ‰ From a single sentence, OpenCode on ZeroGPU read the store, wrote a working search box with an empty state, type-checked its own change, and shipped it to your browser in about 20 seconds, for under a cent. Your key stays saved in OpenCode, so every future session can pick a ZeroGPU model straight from /models.

๐ŸŒŸ Highlights

This notebook has guided you through setting up and running an OpenCode workflow with ZeroGPU for adding a search feature to a React store. You can adapt and expand this example for various other scenarios requiring fast, inexpensive code changes driven by plain-language requests. Key tools utilized in this notebook include:
  • OpenCode: An open-source AI coding agent for the terminal that reads your code, edits files, and runs commands. Its provider catalog comes from models.dev, so ZeroGPU shows up in /connect and /models with no extra setup. Here it reads the storeโ€™s code, writes the search feature, and type-checks its own work.
  • ZeroGPU: A compute-efficient inference provider for apps and agents. We run purpose-built small and nano language models across an edge network for the high-volume tasks you run constantly - classification, extraction, moderation, routing, summarization - at ~10x lower latency and 50%+ lower cost than frontier-model workflows. Auto-scaling, with zero GPU infrastructure to manage. Plug in and youโ€™re live.
  • Models.dev: An open-source database of AI model specifications, pricing, and capabilities that OpenCode reads its providers from. ZeroGPUโ€™s listing supplies the endpoint, the API key variable, and the nine chat models youโ€™ll pick from.
This comprehensive setup allows you to adapt and expand the example for various scenarios requiring fast, inexpensive code changes driven by plain-language requests.