What Developers Need to Know About Generative AI
Generative AI changes what a developer builds and how. Here is what to learn first: models, prompts, grounding, cost and testing.
On this page
Short answer
Generative AI is a class of models that produce new text, code, images or audio from a prompt, and a developer uses it by calling a model through an API and grounding its answers in real data. The core skills are choosing the right model, writing clear prompts, keeping costs under control, and checking the output, because the model can be confident and wrong at the same time.
What is generative AI, in developer terms?
Generative AI is a model that takes an input, usually text, and produces a new output in the same or another form: a paragraph, a function, an image, a summary or a structured record. Under the hood it predicts the next piece of output from patterns learned during training, which is why it is fluent and fast, and also why it can invent details that sound right.
For a developer, the model is a component, not a product. You call it through an API, send it a prompt plus context, and receive text back. Your code stays in charge of the interface, the data, the rules and the checks. The model does one job: turning a prompt into a draft. Everything around it — the data it reads, the tools it can call, the review step — is ordinary software engineering.
| Model type | What it produces | Typical developer use |
|---|---|---|
| Text model | Text, code, structured data | Drafting, summarising, classification |
| Code model | Functions, tests, fixes | Autocompletion, refactoring, test writing |
| Image model | Images from text prompts | Placeholders, illustrations, mockups |
| Audio model | Speech, transcripts, music | Voice interfaces, captioning, dubbing |
| Multimodal model | Text from mixed input | Reading screenshots, forms and charts |
The same prompt can return different text on different runs, because the model samples from likely outputs. That is normal behaviour, not a bug, and it shapes how you design: keep the model away from decisions that must be identical every time, and keep a record of what it produced. For the basic definitions, see what generative AI is.
How do the APIs actually work?
A model API takes a prompt and returns a completion. The prompt is usually split into a system message that sets the role and rules, a user message with the task, and sometimes extra context such as retrieved documents. The model charges by tokens, which are small chunks of text, roughly three quarters of a word each in English, and both the input and the output count.
Three settings matter most. The context window is how much text the model can see at once: your prompt, your retrieved documents and the answer must all fit inside it. Temperature controls randomness: low values give steadier, more predictable output, high values give more variety. The output limit caps how long the answer can be, which also caps the cost of a single call.
Two habits save most beginners. First, put the instructions, the data and the expected output format in the prompt itself, instead of assuming the model knows them. Second, ask for structured output, such as JSON with named fields, so your code can parse the answer instead of scraping free text. A prompt that returns a clean record is worth more than a clever paragraph.
Prompt, retrieve, fine-tune or agent: which should you build?
Most developer work with generative AI falls into four patterns, and the right one depends on what the model needs to know. A plain prompt works when the task needs general knowledge and the answer is short. Retrieval, often called RAG, works when the answer must come from your own documents: the code searches them first and puts the best matches into the prompt.
Fine-tuning changes the model itself, which is worth doing only when you have many examples of the exact behaviour you want and prompting cannot reach it. Agents add tools: the model decides which tool to call, reads the result, and repeats until the job is done. Agents are the most powerful pattern and the hardest to test, so they belong last, not first.
| Pattern | Best when | Main cost |
|---|---|---|
| Prompt only | General knowledge, short answers | Prompt design time |
| Retrieval (RAG) | Answers must come from your data | Search quality and document upkeep |
| Fine-tuning | Many examples of one exact style | Training data and evaluation |
| Agent with tools | Multi-step jobs across systems | Testing and guardrails |
Start with prompting, add retrieval when the answers need your data, and only then consider the heavier options. Each step up adds moving parts, and each moving part needs its own tests. For prompt technique, see what prompt engineering is.
What does it cost, and how do you control it?
Model use is billed per token, so the bill grows with the length of the prompts and the volume of calls. Long prompts with big retrieved documents cost more than short ones, and a model that reasons step by step costs more than one that answers directly.
The cheapest call is the one you do not make: cache repeated answers, reuse retrieved context, and skip the model for tasks a lookup or a rule can do.
Model choice is the biggest lever. A small, fast model handles drafting, classification and simple extraction at a fraction of the price of the largest model. Use the large model only where the task needs it, such as hard reasoning or long documents, and measure whether the answers are actually better before you pay for them.
Set a budget per feature and watch it. Log the tokens per call, the model used and the outcome, so you can see which feature spends the money. Prices change often and differ by provider, so check the vendor's own pricing page when you plan, and see vendor site for current rates. A feature that looks cheap in a demo can become the largest line in the bill at real volume.
How do you test something that answers differently every time?
You test generative AI the way you test any system with variable output: with a fixed set of cases and a clear pass mark. Build an evaluation set from real examples of the work: past tickets, real documents, real questions. Run the feature on those cases, and score the answers against rules a person can check, such as whether the answer names the right product, cites the right document, or follows the required format.
Keep three kinds of tests. Unit tests check the plumbing: the prompt builds, the output parses, the fallback fires when the model fails. Evaluation runs check quality on the fixed set, so you can compare a new prompt or model against the old one. Human review checks the cases the automated tests cannot judge, such as tone and whether the answer is actually helpful.
Never ship without a fallback. If the model call fails, times out or returns something unparsable, the feature should show a clear message or hand the work to a person, not a blank screen or a made-up answer. Log every model output with its inputs in the first months, so you can trace a bad answer back to the prompt that produced it.
Example (hypothetical): a support-drafting feature
Example (hypothetical): a small software team adds AI drafting to its support inbox. Support agents handle about 800 tickets a month, and each reply takes about 3 minutes to write, which is 800 x 3 = 2,400 minutes, or 40 hours, a month.
The team builds a retrieval feature: for each ticket it searches the help centre, puts the three best articles into the prompt, and asks the model to draft a reply. In the first month the model drafts replies for 500 tickets, which is about 60% of the volume. Each draft takes an agent about 2 minutes to review and send, which is 500 x 2 = 1,000 minutes, or about 17 hours.
The remaining 300 tickets still take 3 minutes each, which is 15 hours. Total reply time falls from 40 hours to about 32 hours, and the team uses the saved 8 hours to clear the backlog. The model bill is small next to the time saved, but the team keeps reviewing every draft until the error rate is steady.
What are the common mistakes?
The most common mistakes with generative AI are trusting the output without checking it, skipping the evaluation set, and building an agent before a simple prompt is proven.
- Trusting the output. Models invent facts, dates and citations with confidence. Check answers against your data before they reach a customer.
- No evaluation set. Without fixed cases and a pass mark, every prompt change is a guess and regressions go unnoticed.
- Agent first. An agent that calls tools is hard to test and debug. Prove the prompt and the retrieval first.
- Stuffing the context window. More documents in the prompt does not mean better answers. Retrieve less, and retrieve better.
- Ignoring the bill. Long prompts and large models at high volume add up fast. Log tokens per call from day one.
- No fallback. A model call can fail, time out or return garbage. Plan what the user sees when it does.
For the build side, see generative AI development.
Key takeaways
- A model is a component: your code owns the data, rules and checks
- Prompt first, add retrieval when answers need your data, agents last
- Small models handle most tasks; pay for the large one only where it helps
- Test on a fixed set of real cases with a clear pass mark
- Log tokens per call and keep a fallback for every model failure
- Check every answer before it reaches a customer
Frequently asked questions
What should a developer learn first about generative AI?
Learn how model APIs work: prompts, tokens, context windows and temperature. Then learn retrieval, so answers come from your own documents, and build an evaluation set of real cases before you ship anything to users.
Do developers need to understand how models are trained?
Not in depth. You need to know that a model predicts likely text from patterns in its training data, which is why it can be fluent and wrong. That one fact explains most of the failure modes you will meet.
When should I use retrieval instead of fine-tuning?
Use retrieval when answers must come from your own documents, because it is cheaper, easier to update and lets the model cite its sources. Fine-tuning fits when you need one exact style or format across many examples.
How much does it cost to add generative AI to an app?
It depends on the model, the prompt length and the volume of calls. Small models and short prompts cost little; long prompts and large models at high volume add up. Prices change often, so check the vendor's own pricing page.
How do I stop the model from inventing facts?
Ground it in your data with retrieval, ask it to say it does not know when the answer is not in the sources, and check the output against the source documents before it reaches a user. No prompt removes the risk entirely.
What is the hardest part of building with generative AI?
Testing and evaluation. The output varies, so you need a fixed set of real cases, a clear pass mark and human review of the hard cases. Most teams underestimate this and overestimate the prompt work.