NaijaClass AI Β· Setup Guide Β· October 2026

Which AI should NaijaClass use?

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.

⚑ The short answer

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.

What's inside
  1. What you actually need (two jobs)
  2. The full comparison table
  3. The recommendation
  4. Step-by-step: get your key
  5. Plug it into config.php
  6. Test that it works
  7. The diagram problem (honest truth)
  8. Keep your key safe & control cost
  9. Troubleshooting

1. What you actually need

NaijaClass AI asks the AI to do two very different jobs, and they are not done by the same model:

πŸ“ Job 1 β€” Text easy

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.

🎨 Job 2 β€” Diagrams the hard part

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?"

2. The full comparison table

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.

3. The recommendation

πŸ† Best setup for NaijaClass

Google Gemini β€” one key does both jobs.

  • Text: gemini-3.5-flash β€” fast, cheap, excellent at Nigerian curriculum content.
  • Diagrams: Gemini's image model (Nano Banana) β€” the most accurate at rendering correct labels on science diagrams.
  • Free to start β€” no card, works from Nigeria immediately.
  • Drops straight in β€” Google offers an OpenAI-compatible endpoint, so api/generate.php needs no changes.

πŸ’° Cheaper / more flexible alternative

OpenRouter β€” one key, every model.

  • Reach Gemini, GPT, Claude, DeepSeek, Flux and Ideogram through one account and one key.
  • Swap models by changing one line in config.php β€” great for testing which is cheapest.
  • Pay with a virtual dollar card (works from Nigeria).
  • Adds a 5.5% fee on credit top-ups.

⚠️ The honest trade-off (please read this)

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:

  1. A ready-made diagram for the most common topics (the site already ships with photosynthesis, the water cycle, the digestive system and fractions).
  2. A generated image for other topics, when you switch the image feature on.
  3. Always a written "draw and label this" description β€” so even if the picture is imperfect, the teacher has exact, correct instructions to draw it on the board themselves.

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.

4. Step-by-step: get your key

Follow the Gemini path below (recommended). The OpenRouter path is at the end if you prefer it.

1

Create the account

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.

βœ… You should see: the Google AI Studio dashboard with a "Get API key" button.
2

Create your API key

Click "Get API key" β†’ "Create API key" β†’ choose (or create) a project β†’ copy the key. It starts with AIza…

βœ… You should see: a long string starting with AIza. Copy it now β€” treat it like a password.
3

Set a spend limit (do this even on the free tier)

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.

βœ… You should see: a monthly budget/limit saved against your project.
4

If you later add a paid plan β€” how to pay from Nigeria

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.

βœ… You should see: the card accepted and a small verification charge (usually refunded).

Prefer OpenRouter instead?

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.

5. Plug it into config.php

Open 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.

Exact values for every provider

Copy the row for whichever provider you chose:

Providerapi_key looks likebase_urlmodel
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.

6. Test that it works

1

Health check

Visit yourdomain.com/api/generate.php?action=status

βœ… You should see: {"ok":true,"configured":true,"model":"gemini-3.5-flash",…} β€” configured:true means your key was read correctly.
2

Generate something real

Open the site, go to Lesson Notes, pick a subject and topic, and click Generate.

βœ… You should see: a green "AI generated" badge and content that matches your exact topic. An amber "Sample content" badge means the key wasn't picked up β€” recheck step 5.
3

Try all four generators

Test Lesson Plans, Lesson Notes, Exams & Quizzes and Scheme of Work once each.

βœ… You should see: all four return real content with the green badge.

7. The diagram problem β€” and how images get wired in

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:

  1. Add an image block to config.php (provider, model, size) β€” already stubbed out for you in the file.
  2. In 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").
  3. Return the image as a URL or base64 string in the same JSON, under doc.illustration.image β€” the front-end already knows how to display it.
  4. If the image call fails, fall back to the written description (already implemented).

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.

8. Keep your key safe & control cost

9. Troubleshooting

What you seeWhat it meansFix
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://

🎯 In one sentence

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.