Agents Workshop

Deploy to Vercel

Now - let's deploy our agent to Vercel!

Create a new file for our endpoint.

api/agent.ts
import { codingAgent } from "../utils/agent";

export async function POST(request: Request): Promise<Response> {
  const body = await request.json();
  const { prompt, repoUrl }: { prompt: string; repoUrl: string } = body;

  try {
    const { response } = await codingAgent(prompt, repoUrl);
    return new Response(JSON.stringify({ prompt, response, repoUrl }), {
      headers: { "Content-Type": "application/json" },
    });
  } catch (e) {
    console.error(e);
    return new Response(JSON.stringify({ error: "An error occurred" }), {
      status: 500,
      headers: { "Content-Type": "application/json" },
    });
  }
}

We can test it out by running the following command to start the server:

vc dev

Then we can test it with a cURL command:

curl -X POST localhost:3000/api/agent \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "update readme to say hey were so back",
    "repoUrl": "https://github.com/nicoalbanese/ship-25-nextjs-playground"
  }'

Awesome!

Commit and Deploy

All that's left is to commit our changes to our git repo, which will trigger a new deployment.

On this page