- 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
/connectand/modelswith 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.
๐ฅ 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: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 withzgpu-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 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: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:vite.config.ts
tsconfig.json
index.html
src/index.css pulls in Tailwind, and src/main.tsx mounts the app:
src/index.css
src/main.tsx
name and a category:
src/data/products.ts
src/components/Header.tsx
src/components/ProductCard.tsx
src/App.tsx puts it together. This is the file the agent will change:
src/App.tsx
๐ 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 thetrail-shop folder:
/connect, press Enter, type zero, and pick ZeroGPU. Paste your key (itโs masked as you paste) and press Enter:
/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:
opencode run:
๐ 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 readssrc/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:
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 costs15,000 x $0.30/1M + 1,000 x $1.20/1M = $0.0057.
Step 4: Try the search
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 toopencode run. This is the same run without the interface, which is how youโd use it in CI:
/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
/connectand/modelswith 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.

