AI for developersLesson 1/8

Lesson 1 of 8 · 18 min

Choosing your model and provider

Claude, OpenAI, Gemini, open models: quality, price, context, data.

Integrating AI into an application starts with a decision that’s often made too quickly: which model, from which provider? This month’s ranking on social media tells you nothing about your task, your volumes and your data. This lesson gives you a method to choose on measurable criteria, and to keep the freedom to change your mind.

By the end of this lesson, you’ll be able to:

  • read a model card: context window, maximum output, price per million tokens;
  • estimate the real cost of a feature before writing it;
  • compare two models on your own cases, rather than on public rankings;
  • isolate the provider in your code so you can switch.

What you’re buying: tokens

Models don’t read words, but tokens: pieces of words. In English, count roughly one token per four characters. Everything is measured in tokens:

  • the context window: what the model can read at once (instructions, history, documents, and its answer);
  • the maximum output: the maximum length of the answer;
  • the price: one rate per million tokens of input (what you send) and another, higher one of output (what the model writes).

The main families

Closed models, served through an API: Claude (Anthropic), GPT (OpenAI), Gemini (Google). You send a request and pay per use. Each provider offers a range: a large model for hard reasoning, a mid-size model for most of the work, a small, fast, cheap model for sorting and extraction.

Open-weight models: you can download them and run them on your servers, or go through a host. Their appeal: keeping data with you and controlling costs at very large volumes. Their hidden price: infrastructure, updates and security are on you.

Here, as an example, is Claude’s current lineup, as documented by Anthropic in November 2026:

Model Identifier Typical use Input / output price (per million tokens)
Claude Opus 5.5 claude-opus-5-5 Reasoning, code, agents $4 / $20
Claude Sonnet 5.5 claude-sonnet-5-5 Production at volume $2 / $10
Claude Haiku 5.5 claude-haiku-5-5 Sorting, extraction, fast answers $0.10 / $0.50 (requests of 100,000 tokens or fewer)

All three accept a one-million-token window and answers of up to 128,000 tokens. Prices are in US dollars; batch processing (lesson 8) halves them.

Estimating the cost of a feature

The math fits on one line: (input tokens × input price + output tokens × output price) × number of calls.

Take a sorting task for customer messages: a 600-token instruction, a 250-token message, an 80-token answer, 3,000 messages a month.

  • With Claude Haiku 5.5: 3,000 × (850 × $0.10 + 80 × $0.50) ÷ 1,000,000 = about $0.38 a month.
  • With Claude Opus 5.5: 3,000 × (850 × $4 + 80 × $20) ÷ 1,000,000 = about $15 a month.

Forty times more expensive for the same task. If the small model sorts just as well (and it often does for sorting), the choice is easy. If the task needs real reasoning, the difference is justified. Only a measurement on your cases can decide.

Compare on your cases, not on rankings

Public rankings measure generic tasks. Yours isn’t. The method:

  1. Gather 20 to 50 real cases, with a good share of hard ones (an ambiguous message, mixed languages, an off-topic request).
  2. Write the expected answer for each, or at least the success criterion.
  3. Run the same cases through the two or three candidate models, with the same instruction.
  4. Compare: success rate, total cost, response time.

That’s the principle of an evaluation, which lesson 3 covers in detail. This small set of cases will serve you for the feature’s whole life: with every new model, you’ll know in ten minutes whether it does better.

The criteria that aren’t technical

  • Data. Where is it processed? How long is it kept? Is it used to train models? Business offerings answer these questions in their terms; read them. For customers’ personal information in Quebec, Law 25 requires an assessment before entrusting it to a service outside Quebec.
  • Availability. Is the model offered in your usual cloud (AWS, Google Cloud, Azure)? It’s sometimes simpler for billing and compliance.
  • Rate limits. How many requests per minute can your account send? They grow with usage and account tier.
  • Longevity. Models are retired after a few years. Note the announced retirement date and plan to migrate.

Don’t lock yourself in

Whatever you choose, isolate the model call behind a function of your own: sort_message(text) rather than API calls scattered across the codebase. The day a better model comes out, or prices change, you edit a single file and rerun your set of cases.

The Atelier Boréal case

We’re back with Atelier Boréal, the Montreal ceramics studio followed throughout our courses (a fictional business). Julie hands Léa, a freelance developer, three features for the studio’s website:

  1. sort the messages from the contact form (sign-up, question, complaint, corporate order) and spot urgent ones;
  2. answer frequent questions from the workshop rules and the care sheet for the pieces;
  3. later, an assistant that checks open spots and prepares a booking.

Léa fills in a choice sheet for each. For sorting (about 3,000 messages a month, short answer, no creativity), she starts from a small model and plans to compare it with a mid-size model on 30 real, anonymized messages. For frequent questions, she needs to quote the documents accurately: she’ll test a mid-size model. For the assistant, which chains actions, she keeps the large model in mind, but won’t go further before she has measurements.

From day one, she also writes an ai.py module that holds every call: the rest of the site doesn’t even know which provider is used.

Common mistakes

  • Choosing from a ranking. It measures tasks that aren’t yours.
  • Taking the biggest model “to be safe.” You sometimes pay forty times more for an identical result.
  • Forgetting output in the math. Output tokens cost several times more than input tokens.
  • Hard-coding a provider everywhere. On the day you switch, everything has to be rewritten.

Key takeaways

  • You buy tokens: context, maximum output, input and output prices.
  • Cost of a feature = tokens × price × volume; do the math before writing the code.
  • Compare models on 20 to 50 of your cases, not on public rankings.
  • Data, availability, rate limits and longevity matter as much as quality.
  • Isolate the provider behind a function of your own.

Quiz

1. A 600-token instruction, a 250-token message, an 80-token answer, 3,000 times a month, with a model at $4 input and $20 output per million tokens. About how much does it cost per month?
2. Why doesn’t a lower price per token guarantee a lower bill?
3. What’s the best way to compare two models for your feature?
4. Why isolate the model call behind a function of your own?
5. Which of these criteria is NOT technical, but matters as much as quality?
Next lesson: Your first API call
Next