You don't have an AI key yet. This guide tells you exactly which one to get, why, how to pay for it from Nigeria, and the three lines to change in api/config.php to switch it on.
Get a Google Gemini key (from Google AI Studio). It is the only option that is free to start with no card, works from Nigeria without payment headaches, and is the best in the world at drawing labelled science diagrams β which is exactly the hard part for your lesson notes.
If you'd rather have one key that can reach every model (and pay with a virtual dollar card), use OpenRouter instead. Both drop straight into your existing api/config.php β no code changes.
NaijaClass AI asks the AI to do two very different jobs, and they are not done by the same model:
Write accurate, curriculum-correct lesson notes, lesson plans, exam papers and schemes of work for Nigerian subjects. This needs a strong, cheap, fast chat model. Almost every provider does this well β the differences are price and speed.
Draw accurate, labelled educational diagrams β the water cycle, the human digestive system, photosynthesis, fractions. This is much harder: most image models make pretty pictures with garbled or wrong labels. Only a few models can reliably spell "oesophagus" and point the arrow at the right organ.
So the right question isn't "which AI is best?" β it's "which text model + which image model?"
Prices are the published rates as of October 2026, in US dollars. "OpenAI-compatible" means it drops straight into your existing api/generate.php with no code changes.
| Provider | Text quality | Diagram / image quality | Accurate labels in images? | Text price | Image price | Free tier | Signup from Nigeria | OpenAI-compatible? |
|---|---|---|---|---|---|---|---|---|
| Google Gemini AI Studio |
Excellent Gemini 2.5 / 3.5 Flash |
Best for diagrams Nano Banana Pro, up to 4K |
β
Best 94β97% text accuracy |
Free tier; paid from $0.10β$1.50 / 1M in |
Imagen 4: $0.02β$0.06 Gemini image: ~$0.04β$0.15 |
β
Yes no card needed |
β
Easiest free tier, no card |
β
Yes /v1beta/openai |
| OpenAI | Excellent GPT-4o mini, GPT-5 mini |
Very good GPT Image 2 β best prompt-following |
β Very good | $0.15 / $0.60 (4o-mini) $0.25 / $2.00 (5-mini) |
$0.005β$0.21 per image | $5 trial credit | β οΈ Cards often declined needs virtual dollar card |
β Native |
| OpenRouter aggregator |
Any model routes to all of the above |
Any model Gemini, Flux, Ideogram⦠|
Depends on model chosen | Provider rate + 5.5% fee | Provider rate + 5.5% fee | Some free models | β Virtual dollar card | β Yes |
| Anthropic Claude | Excellent Sonnet 4.6 |
β None β text only | N/A | $3.00 / $15.00 per 1M | β | No | β οΈ Card issues | β Different API |
| Groq | Very good, fastest ~500 tokens/sec |
β None | N/A | Very cheap open models | β | β Generous | β Card | β Yes |
| DeepSeek | Very good, very cheap | β None | N/A | ~$0.44 / $0.87 per 1M | β | Trial credit | β Card | β Yes |
| Ideogram | β Image only | Excellent for text-in-image | β
Excellent best-in-class typography |
β | $0.03 / $0.06 / $0.10 | Limited | β Card | β Own API |
| Recraft | β Image only | Good β vector / SVG output | β Good | β | ~$0.04 per image | Limited | β Card | β Own API |
| FLUX.2 via fal.ai / Replicate |
β Image only | Good, open-weight | Moderate | β | ~$0.014β$0.07 per MP | Limited | β Card | β Own API |
| Stability Stable Diffusion |
β Image only | Cheap, artistic | β Weak labels | β | Very cheap | Limited | β Card | β Own API |
Reading the table: the two rows that matter most are Google Gemini (best diagrams + free to start) and OpenRouter (one key, everything, easy to pay for). Everything else is either text-only or needs a separate account and card.
Google Gemini β one key does both jobs.
gemini-3.5-flash β fast, cheap, excellent at Nigerian curriculum content.api/generate.php needs no changes.OpenRouter β one key, every model.
config.php β great for testing which is cheapest.No image model reliably produces a perfectly labelled scientific diagram every single time. Even the best ones occasionally misspell a label, put an arrow in the wrong place, or invent an organ that doesn't exist. This is a limitation of the technology in 2026, not of your website.
So NaijaClass uses a hybrid diagram strategy β and it already works this way:
That third layer is what makes it safe for the classroom. Never let a generated diagram go to pupils without a teacher glancing at it first.
Follow the Gemini path below (recommended). The OpenRouter path is at the end if you prefer it.
Go to aistudio.google.com and sign in with a normal Google account. No card, no payment, no Nigerian card problems β the free tier is available immediately.
Click "Get API key" β "Create API key" β choose (or create) a project β copy the key. It starts with AIzaβ¦
AIza. Copy it now β treat it like a password.In AI Studio, open Billing / Usage limits and set a low monthly cap (e.g. $5). This means even if your key leaks, the most anyone can spend is $5.
Google bills in USD. Nigerian naira debit cards are usually declined. Use a virtual dollar card β these are the ones people report working in 2026:
Fund the card, then add it as the payment method in your Google billing account. Tip: make sure the card has a matching billing address β Google checks it.
Go to openrouter.ai β sign up β Keys β Create key. Top up credits with a virtual dollar card. Your key starts with sk-or-v1-β¦. Then use the OpenRouter values in the next section. OpenRouter is the better choice if you want to test several models without opening several accounts.
config.phpOpen api/config.php on your server (cPanel β File Manager β api/config.php β right-click β Edit). You only change three lines:
// 1) YOUR API KEY 'api_key' => 'AIza...paste-your-key-here...', // 2) PROVIDER ENDPOINT 'base_url' => 'https://generativelanguage.googleapis.com/v1beta/openai', // 3) MODEL 'model' => 'gemini-3.5-flash', // 3b) FALLBACK MODELS (auto-retry if a name is retired) 'fallback_models' => ['gemini-3.6-flash', 'gemini-3.1-flash-lite'],
Save the file. That's it β the whole site now uses live AI.
Copy the row for whichever provider you chose:
| Provider | api_key looks like | base_url | model |
|---|---|---|---|
| Google Gemini recommended | AIza⦠|
https://generativelanguage.googleapis.com/v1beta/openai |
gemini-3.5-flash |
| OpenRouter | sk-or-v1-β¦ |
https://openrouter.ai/api/v1 |
google/gemini-3.5-flash |
| OpenAI | sk-proj-β¦ |
https://api.openai.com/v1 |
gpt-4o-mini |
| Groq | gsk_β¦ |
https://api.groq.com/openai/v1 |
llama-3.3-70b-versatile |
| DeepSeek | sk-β¦ |
https://api.deepseek.com/v1 |
deepseek-chat |
π Never put the key in the HTML or JavaScript. It belongs only in api/config.php, which is blocked from the web by api/.htaccess. Test it: visit yourdomain.com/api/config.php β you must get 403 Forbidden or a blank page, never your key.
Visit yourdomain.com/api/generate.php?action=status
{"ok":true,"configured":true,"model":"gemini-3.5-flash",β¦} β configured:true means your key was read correctly.Open the site, go to Lesson Notes, pick a subject and topic, and click Generate.
Test Lesson Plans, Lesson Notes, Exams & Quizzes and Scheme of Work once each.
Right now your site generates the written part of the illustration ("Draw and label a diagram of the water cycle showing evaporation, condensation, precipitation and collection") plus four ready-made diagram images. That already works and needs no key.
To also generate a fresh image for any topic, the backend needs a second call β because chat models and image models use different endpoints. Here's how it would work:
image block to config.php (provider, model, size) β already stubbed out for you in the file.api/generate.php, when illustration = true, after the text call, make a second request to the image endpoint with a prompt built from the topic (e.g. "clean educational diagram of the water cycle, white background, clear labels: evaporation, condensation, precipitation, collection").doc.illustration.image β the front-end already knows how to display it.Which image model? For labelled science diagrams, in order of accuracy: Gemini image (Nano Banana) β Ideogram 4.0 β GPT Image 2 β Recraft (vector) β FLUX.2.
Want me to build this? Just say the word and I'll wire the image endpoint into api/generate.php β it's a contained change and the front-end is already ready for it.
config.php out of the web root if you can β move it above public_html and point to it with the NAIJACLASS_CONFIG environment variable (see DEPLOY-CPANEL.md, section 6).api/generate.php before you make the site public β otherwise a stranger could burn your credits. (I can add this β just ask.)| What you see | What it means | Fix |
|---|---|---|
| Amber "Sample content" badge | No key was read | Recheck the three lines in config.php; run the ?action=status check |
| "The AI provider rejected the API key" | Wrong key, or base_url doesn't match the provider |
Re-copy the key; make sure the base_url row matches your provider exactly |
| "The provider endpoint or model was not found" | Typo in base_url or model |
Copy the exact values from the table in section 5 |
| "Rate-limiting this key" | Too many requests, or free-tier quota used up | Wait a minute; check your quota; consider a paid tier |
| "Could not reach the AI provider" | Server can't make outbound HTTPS calls | Ask your host (Truehost) to allow outbound port 443; make sure curl is enabled in PHP |
| 500 Internal Server Error | PHP too old, or a typo in config.php |
Set PHP 8.1 in MultiPHP Manager; check quotes and commas in config.php |
| Blank page | PHP error being hidden | Open error_log in your site folder β the last lines name the problem |
| Works on my laptop, not on the server | You tested a local file, not the live site | Always test through the real web address, never file:// |
Get a free Google Gemini key from AI Studio, paste it into the three lines in api/config.php, and your site is live with real AI β then ask me to wire in the image endpoint when you're ready for generated diagrams.