I built an autonomous "Senior Editor" agent to run my portfolio. A deep dive into using Laravel 12, Next.js 15, and OpenRouter to benchmark AI models in real-time and automate the friction of SEO and content metadata.

As a Tech Lead and AI Engineer, I often tell my colleagues: "The cobbler's children have no shoes." We build sophisticated, high-performance systems for others, but our own portfolio sites often gather dust, lacking the polish we demand in our professional work.
I decided to fix this for my own platform, Yabasha.dev. I didn't just want a blog; I wanted a living playground for my expertise in AI Agents and Full-Stack Architecture.
So, I built an AI Agent to be my "Senior Editor" and "SEO Manager," automating the tedious parts of content creation so I could focus on writing. Here is a deep dive into how I built it using Laravel, Next.js, and OpenRouter.
I chose a hybrid stack that leverages the strengths of two ecosystems:
This setup gives me the developer experience and stability of Laravel for data management, while delivering the blazing-fast performance of Next.js for the end user.
Writing a technical article is only 50% of the work. The other 50% is:
This friction often prevented me from hitting "Publish".
I created a background service in Laravel (
PostAiService) that acts as an autonomous agent. It doesn't just "summarize" text; it analyzes it with a specific persona.
The core logic resides in a dedicated service that constructs a complex prompt. I instruct the LLM to act as an "Expert SEO Specialist and Content Editor".
Here is a simplified look at the prompt structure I use:
// app/Services/PostAiService.php
protected function buildAnalysisPrompt(string $content): string
{
return <<<EOT
ActasanexpertSEOspecialistandcontenteditor.
AnalyzethefollowingblogpostcontentandreturnaJSONobjectwith:
1.`summary_short`:Aconcise1-2sentencehook.
2.`level`:'beginner','intermediate',or'advanced'.
3.`intent`:'guide','opinion','case_study',etc.
4.`og_title`:AcatchyOpenGraphtitleoptimization.
5.`primary_keyword`:ThesinglemostimportantSEOkeyword.
6.`secondary_keywords`:Anarrayofsupportingkeywords.
Content:
{$safeContent}
EOT;
}
This ensures that every single article I write has structured, machine-readable metadata that Next.js can easily ingest.
One of the coolest features I built is a dynamic model selector. The AI landscape changes weekly. One week GPT-5.2 is king, the next Claude Opus 4.5 takes the crown, or Gemini 3 Pro offers 2M token context.
I didn't want to hardcode a model.
I built an
AiModel resource in Filament that tracks available models from OpenRouter. But I went a step further—I implemented a
Benchmarking System
.
// app/Services/OpenRouterService.php
public function benchmarkModel(AiModel $model): ?float
{
// We fire a standard test prompt to measure real-world speed
$startTime = microtime(true);
$response = Http::withToken($this->apiKey)
->post($this->baseUrl.'/chat/completions', [
'model' => $model->request_id,
'messages' => [['role' => 'user', 'content' => 'Count from 1 to 10.']],
]);
// Calculate tokens per second (TPS)
// ...
$model->update(['actual_speed' => $tps]);
}
In my admin panel, I can sort models by Cost and Speed (Tokens/Sec) and toggle the active model for my agent instantly. If a new, cheaper model comes out, I add it, benchmark it, and switch my agent to use it.
Now, my workflow is simple:
PostObserver detects the change and queues a job.<head> of the document.The result is a perfectly optimized page on Yabasha.dev without me spending a single second on "optimization."
AI isn't about replacing engineers; it's about amplifying them. By building this agent, I've removed the administrative burden of blogging, allowing me to focus entirely on sharing knowledge.
If you're interested in building similar AI-driven architectures or need a senior pair of hands on your Next.js/Laravel stack, feel free to reach out or check out my work at Yabasha.dev.