I put free AI into my local PHP stack: no API key to paste, and a Fix with AI button on every error
PHP Station is my free, open-source workbench for PHP and Laravel on Windows. Each project runs on its own PHP version, Composer and MariaDB, side by side. It also catches every email, dump() and error in one inbox, and
PHP Station is my free, open-source workbench for PHP and Laravel on Windows. Each project runs on its own PHP version, Composer and MariaDB, side by side. It also catches every email, dump() and error in one inbox, and can undo a single bad query.
A few weeks ago I added an AI hub to it. People liked the idea, but in practice almost nobody used it, and the reason was always the same:
"It wants an API key. I opened Google AI Studio, got lost, closed the tab."
Pasting keys is fine for us, but not for a student on XAMPP who just wants to know why Laravel says Target class [PostController] does not exist. So this update had one goal: the AI works the moment PHP Station starts, and adding more AI never needs a copy-paste.
What's new at a glance
| Feature | What it means for you | |
|---|---|---|
| 🆓 | Free AI, no key | Chat works on first start, with no account and nothing to paste |
| 🔑 | Quick connect | One OpenRouter login, or a key caught from the clipboard |
| 🛠️ | Fix with AI | You see a diff, then the panel backs up, applies, runs php -l and keeps Undo ready |
| 🦈 | Friendly error pages | A plain message and a Try again button, with the details one click away |
Below are the screenshots, plus the parts of the code I think are worth stealing.
1. A free AI that works with no key at all
The AI page now opens on a chat that is ready to answer. Out of the box it uses Pollinations, a free text API with an anonymous tier: no account, no key, no sign-up. You type a question and get an answer.

First start: a free AI is already answering, no login needed.
A few small things make it feel like a chat app and not a settings page:
- It opens on a hello with four starter questions, and a new chat starts with your first message (no "New chat" click first).
- Enter sends, Shift + Enter makes a new line, and the box grows with the text.
- The header shows which AI answers next, and replies show the logo of the AI that actually answered.
- Code blocks get a copy button, and each chat can be tied to one of your projects.

A real answer: the N+1 problem and eager loading, with code you can copy.
The anonymous tier has a small limit, so it is the floor, not the ceiling. The next two features are how you add more AI without touching a key.
2. Quick connect: three ways in, none of them is copy-paste
The AI accounts page now starts with a Quick connect box:
- No login, ready now. Pollinations, as above.
- One login, many free models. Log in with OpenRouter: one OAuth login, and you get OpenRouter's free models (DeepSeek, Qwen Coder, Llama, Gemma …). When one is busy, another one answers.
- More AI, one click each. Connect on a provider card, or Find keys on this PC.

Quick connect, then one card per free provider, each with its own logo.
Free tiers always come first. When one runs out (429, daily quota, "high demand"), it cools down and the next one answers the same conversation. Paid accounts are only used if you add them yourself.
Log in with OpenRouter (OAuth PKCE on localhost)
OpenRouter supports OAuth PKCE with a localhost callback, which is perfect for a local tool: no client secret, and no server of mine in the middle. The panel makes a verifier, sends the user to OpenRouter, and swaps the code for a key when the browser comes back to localhost:<port>/oauth/openrouter:
function startOpenRouterLogin(ctx) {
const verifier = b64url(crypto.randomBytes(32));
const challenge = b64url(crypto.createHash('sha256').update(verifier).digest());
const state = crypto.randomBytes(16).toString('hex'); // one-time, expires in 15 min
oauthPending.set(state, { verifier, at: Date.now() });
const cb = `http://localhost:${ctx.port}/oauth/openrouter`;
const q = new URLSearchParams({ callback_url: cb, code_challenge: challenge,
code_challenge_method: 'S256', state, key_label: 'PHP Station by x8code' });
return { url: `https://openrouter.ai/auth?${q}` };
}
💡 Safety rule: the free OpenRouter account only ever sends
:freemodels (price 0). If someone types a paid model by hand, it is dropped and a free one is picked. So even a key that has credit on it is never charged by PHP Station.
Connect: the key is caught from the clipboard
Gemini, Groq, Mistral, Cerebras and GitHub Models don't have a public OAuth flow for this. So Connect does the next best thing. It opens the provider's key page, and you only click Copy there. PHP Station sees the key on the clipboard, saves it and tests it.

Click Copy on the provider's page. PHP Station picks the key up, saves it and tests it.
Reading the clipboard is a privacy question, so it is kept narrow:
- It only accepts text shaped like that provider's key. Nothing else is read into the panel or kept.
- It stops after 3 minutes, on Cancel, or as soon as it has the key.
/** What a key of each provider looks like (to catch it from the clipboard). */
const KEY_RE = {
gemini: /^AIza[0-9A-Za-z_-]{30,}$/,
groq: /^gsk_[A-Za-z0-9]{20,}$/,
openrouter: /^sk-or-(v1-)?[A-Za-z0-9]{20,}$/,
cerebras: /^csk-[A-Za-z0-9]{20,}$/,
github: /^(github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9]{20,})$/,
// ...
};
PHP Station has zero npm dependencies, so the watcher is a short PowerShell loop. The key pattern comes in through an environment variable, never on a command line:
$end = (Get-Date).AddSeconds([int]$env:PS_AI_SECS)
while ((Get-Date) -lt $end) {
if (Test-Path -LiteralPath $env:PS_AI_STOP) { break } # Cancel
try { $c = Get-Clipboard -Raw -ErrorAction Stop } catch { $c = $null }
if ($c) { $c = $c.Trim(); if ($c -cmatch $env:PS_AI_RE) { @{ ok = $true; v = $c } | ConvertTo-Json -Compress; exit } }
Start-Sleep -Milliseconds 700
}
Find keys on this PC covers developers who already have keys. It reads GEMINI_API_KEY, GROQ_API_KEY, OPENROUTER_API_KEY … from the environment, or your GitHub CLI login for GitHub Models. It asks before it uses any of them.
🔒 Every key is encrypted with Windows DPAPI (current user only). The page only ever sees
••••abcd.
3. Fix with AI, and why it kept failing
Every error in PHP Station's Inbox (and every broken file in the Upgrade Lab and the Security scan) has a Fix with AI button. It sends the error, the file around the line and up to two of your own stack frames. It never sends .env, vendor, storage, or files outside the project.

Step 1: the error, which AI gets it first, and exactly what is sent.
The AI answers with exact search/replace edits, and you see the diff before anything changes:

Step 2: the diff. Nothing changes until you press Apply and check.
Apply and check does the following:
- Backs up the files.
- Applies the edits.
- Runs
php -lwith the same PHP the error came from. - Opens the page again, if the error came from a page.
If the check fails, the files go back and the AI gets one more try with what failed. Undo is always there.

Step 3: fixed and checked with php -l. Undo puts the files back.
The bug: answers that were nearly right
That was the theory. In practice, my own "Fix with AI" failed with no AI answered almost every time. The panel log showed why. The answers were nearly right, and "nearly right" was thrown away:
- One model left out the last
}of its JSON. - Another copied the
searchtext with the line numbers from the view I gave it, or with different indentation, so it matched zero times.
What I changed:
- Ask the same AI once more, with the reason, before moving on to the next AI. Most models fix their own answer when told "your search text was found 0 times".
- Close JSON whose last brackets are missing (a small bracket stack over the text).
- Match the search text loosely, but only if it is still unique: first exact, then without copied line numbers, then line by line ignoring whitespace. The replacement moves to the file's own indentation.
// Exact first; then without line numbers; then whole lines compared without spaces.
// A loose match must still be unique, and it returns the file's own text.
const norm = (l) => l.trim().replace(/\s+/g, ' ');
for (let i = 0; i + want.length <= have.length; i++) {
let ok = true;
for (let k = 0; k < want.length && ok; k++) ok = norm(have[i + k]) === norm(want[k]);
if (ok) hits.push(i);
}
if (hits.length !== 1) throw new Error(`the search text was found ${hits.length} times`);
Fixes now also get more room (8192 tokens), and a "free limit reached, retry after N s" is waited out when no other AI is left. The error message now says why an answer was refused, instead of a bare "no AI answered".
🎯 Lesson: with free and small models, build for answers that are nearly right. One retry that includes the reason is worth more than a long chain of fallbacks.
4. Error pages with a shark 🦈
Raw errors scare people more than they help them. When something fails now, PHP Station shows one deep-sea scene, in the panel's black & silver: a shark biting through the network cable. It has a plain title, what to do next, and a Try again button. The technical text is folded under Details (for developers) with a copy button.
When no AI can answer, the chat shows it inline, with a button straight to AI accounts:

No AI ready: a plain message, two buttons, and the raw error folded under Details.
When the panel's own server goes away (closed, restarting), the whole panel shows it after 2.5 s and reconnects by itself. The art is kept in memory, so it still shows when the server that would serve it is gone:

The panel's server is gone. Your projects and databases keep running.
Unknown addresses get the same page from the server, in the panel's language (Urdu right to left too), with no script:

The 404 page: the same scene, served without any script.
The art is one hand-written SVG (public/shark.svg) with CSS animations only. It is still when prefers-reduced-motion is on, and it is served with a CSP that allows nothing but its own inline style.
What I'd tell anyone adding AI to a dev tool
- The first answer must need zero setup. A keyless tier, even a small one, changes who uses the feature.
- Treat key handling as UX. OAuth where it exists, clipboard catch where it doesn't, environment variables for the people who already have keys.
- Never let a free path cost money. Filter to free models in code, not in the docs.
-
Plan for answers that are nearly right. Retry with the reason, repair what is safe to repair, and verify (
php -l, reload the page) before you call it fixed. - Make failure friendly, but keep the details one click away for the developer.
Try it
PHP Station is free and MIT licensed, with zero npm dependencies. It runs on Windows 10/11 with PHP 7.4 to 8.5 and MariaDB 10.4 to 12.
git clone https://github.com/sami-hussain-dev/PHP-Station.git
Then double-click PHP-Station.bat. The setup wizard installs PHP, MariaDB and Composer from their official sources, and the AI page works right away.
Stars, issues and PRs are very welcome.
If you try it, tell me in the comments: which free AI answered your first question, and did Fix with AI get it right? 👇
Built by **Muhammad Sami Hussain, Founder & Lead Software Engineer at x8code.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.
